ropes 0.0.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48a5648903288d68f746ab41892ab96d4af86a97
4
- data.tar.gz: ef3392c150c428119d7053565f7c62937ed87413
3
+ metadata.gz: f0340a39d71d97eed45a3581d0b888b7baecaf26
4
+ data.tar.gz: aa6e407db435d64f5357122f501a378fa40cd60b
5
5
  SHA512:
6
- metadata.gz: dea4492261bd84e3672aaa8800872a8081ce0c8964c19b03732db6d653f692616a608ce6eaf3f81c3844b91427e47920e80fb8c7c74f4cfb48bcb8aa9c75263b
7
- data.tar.gz: 69cf5e37707b36252885d931bea89755eff955962f25f53c2beb19ba581b9a0ac03957a3042fcf7aac6fd094b5d49f7e36619abf5b42716a61e7975fdbe9abb4
6
+ metadata.gz: f487454858ff5e087d7fd48df9c6836d61ec5d44b3eecd3f3f5ebf393c032a19c16ad78dd50463cd0a121e0ded135781780390ff895cc37300426a97775b927a
7
+ data.tar.gz: ef54892b3d5374d2817c31f00f6d193f8346ffaf8df4b98e6a4d2d536efaadf3e22f680fe56da8c85169d1007f19ae967f4aa902ef1ca1a97859401632583320
@@ -19,7 +19,7 @@ module Ropes
19
19
  type
20
20
  distribution
21
21
  version
22
- architecture
22
+ architectures
23
23
  components
24
24
  description
25
25
  package_base}.reject do |required_option|
@@ -29,6 +29,7 @@ module Ropes
29
29
  raise "Missing options: #{missing_options.join(", ")}" unless missing_options.empty?
30
30
 
31
31
  raise InvalidRepositoryType, "Repository type #{options[:type]} is neither :apt or :yum" unless options[:type] == :yum or options[:type] == :apt
32
+ raise Error, "Architectures must be an array" unless options[:architectures].is_a? Array
32
33
 
33
34
  @release_file = nil
34
35
  @packages_file = nil
@@ -89,9 +90,9 @@ module Ropes
89
90
 
90
91
  # Get the Packages file as a string
91
92
 
92
- def packages_file
93
- return @packages_file unless @packages_file.nil?
94
- entries = @packages.map do |package|
93
+ def packages_file(arch)
94
+ packages_for_arch = @packages.select {|p| p["architecture"] == arch}
95
+ entries = packages_for_arch.map do |package|
95
96
  lines = []
96
97
  @field_order.each do |field|
97
98
  if package[field] != nil
@@ -109,15 +110,19 @@ module Ropes
109
110
  end
110
111
  lines.join("\n")
111
112
  end
112
- @packages_file = entries.join("\n\n") + "\n"
113
+ if entries.empty?
114
+ ""
115
+ else
116
+ entries.join("\n\n") + "\n"
117
+ end
113
118
  end
114
119
 
115
120
  # Get the Packages file as a gzip'ed string
116
121
 
117
- def packages_file_gz
122
+ def packages_file_gz(arch)
118
123
  io = StringIO.new("w")
119
124
  gz = Zlib::GzipWriter.new(io)
120
- gz.write(packages_file())
125
+ gz.write(packages_file(arch))
121
126
  gz.close
122
127
  io.string
123
128
  end
@@ -125,13 +130,6 @@ module Ropes
125
130
  # Get the Release file as a string
126
131
 
127
132
  def release_file
128
-
129
- # Have to create the files in real life to get the real size
130
- temp_packages_file = Tempfile.new("Packages")
131
- temp_packages_file.write packages_file
132
- temp_packages_file_gz= Tempfile.new("Packages.gz")
133
- temp_packages_file_gz.write packages_file_gz
134
-
135
133
  lines = []
136
134
  lines << "Origin: #{@options[:origin]}"
137
135
  lines << "Label: #{@options[:origin]}"
@@ -139,12 +137,19 @@ module Ropes
139
137
  lines << "Version: #{@options[:version]}"
140
138
  lines << "Codename: #{@options[:distribution]}"
141
139
  lines << "Date: #{Time.new.utc.strftime '%a, %d %b %Y %H:%M:%S UTC'}"
142
- lines << "Architectures: #{@options[:architecture]}"
140
+ lines << "Architectures: #{@options[:architectures].join(" ")}"
143
141
  lines << "Components: #{@options[:components]}"
144
142
  lines << "Description: #{@options[:description]}"
145
143
  lines << "MD5Sum:"
146
- lines << " #{Digest::MD5.hexdigest(packages_file)} #{temp_packages_file.size} #{@options[:components]}/binary-#{@options[:architecture]}/Packages"
147
- lines << " #{Digest::MD5.hexdigest(packages_file_gz)} #{temp_packages_file_gz.size} #{@options[:components]}/binary-#{@options[:architecture]}/Packages.gz"
144
+ @options[:architectures].each do |arch|
145
+ # Have to create the files in real life to get the real size
146
+ temp_packages_file = Tempfile.new("Packages")
147
+ temp_packages_file.write packages_file(arch)
148
+ temp_packages_file_gz = Tempfile.new("Packages.gz")
149
+ temp_packages_file_gz.write packages_file_gz(arch)
150
+ lines << " #{Digest::MD5.hexdigest(packages_file(arch))} #{temp_packages_file.size} #{@options[:components]}/binary-#{arch}/Packages"
151
+ lines << " #{Digest::MD5.hexdigest(packages_file_gz(arch))} #{temp_packages_file_gz.size} #{@options[:components]}/binary-#{arch}/Packages.gz"
152
+ end
148
153
  lines.join("\n") + "\n"
149
154
  end
150
155
 
data/lib/ropes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ropes
2
- VERSION = "0.0.4"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ropes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Sykes