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 +4 -4
- data/lib/ropes/repository.rb +22 -17
- data/lib/ropes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0340a39d71d97eed45a3581d0b888b7baecaf26
|
4
|
+
data.tar.gz: aa6e407db435d64f5357122f501a378fa40cd60b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f487454858ff5e087d7fd48df9c6836d61ec5d44b3eecd3f3f5ebf393c032a19c16ad78dd50463cd0a121e0ded135781780390ff895cc37300426a97775b927a
|
7
|
+
data.tar.gz: ef54892b3d5374d2817c31f00f6d193f8346ffaf8df4b98e6a4d2d536efaadf3e22f680fe56da8c85169d1007f19ae967f4aa902ef1ca1a97859401632583320
|
data/lib/ropes/repository.rb
CHANGED
@@ -19,7 +19,7 @@ module Ropes
|
|
19
19
|
type
|
20
20
|
distribution
|
21
21
|
version
|
22
|
-
|
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
|
-
|
94
|
-
entries =
|
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
|
-
|
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[:
|
140
|
+
lines << "Architectures: #{@options[:architectures].join(" ")}"
|
143
141
|
lines << "Components: #{@options[:components]}"
|
144
142
|
lines << "Description: #{@options[:description]}"
|
145
143
|
lines << "MD5Sum:"
|
146
|
-
|
147
|
-
|
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