prm 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/prm +10 -3
- data/lib/prm/repo.rb +296 -435
- data/lib/prm/rpm.rb +256 -0
- metadata +88 -92
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8570a8d55325f10e5bd5b48aaa602685b5a102e9
|
4
|
+
data.tar.gz: 22d467345ed0d8300f04bc8ca5bdfb27824bb7e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71b0f3f455d0080baa0d3abcd9818c2d381b8c22c378abe5e033db040f2c8b3d86cb4cdcc4e8a3c153955ceb964a6adba3fb904eb20450176488fbbe6a4c558d
|
7
|
+
data.tar.gz: 382a4ba24c436de76eb29960f57ca07de363a98f8d33897d16aa6ac4f05c793f2265d0955457235ab055e9eea3d3b83cf187f2c8a4caa934222735c60c508767
|
data/bin/prm
CHANGED
@@ -13,14 +13,14 @@ end
|
|
13
13
|
class Main < Clamp::Command
|
14
14
|
option ["-t", "--type"], "TYPE", "Type of repo to create", :required => true
|
15
15
|
option ["-p", "--path"], "PATH", "Path to repo location", :required => true
|
16
|
-
option ["-c", "--component"], "COMPONENT", "Component to create", :required => true
|
17
16
|
option ["-r", "--release"], "RELEASE", "OS version to create", :required => true
|
18
17
|
option ["-a", "--arch"], "ARCH", "Architecture of repo contents", :required => true
|
18
|
+
option ["-c", "--component"], "COMPONENT", "Component to create [DEB ONLY]"
|
19
19
|
option ["--accesskey"], "ACCESS KEY", "DHO/S3 Access Key", :default => false
|
20
20
|
option ["--secretkey"], "SECRET KEY", "DHO/S3 Secret Key", :default => false
|
21
21
|
option ["-d", "--directory"], "DIRECTORY", "Move packages from directory to target", :default => false
|
22
22
|
option ["-s", "--snapshot"], "COMPONENT", "Creates a snapshot of a component", :default => false
|
23
|
-
option ["-e", "--recent"], :flag, "Snapshot the most recent unique packages"
|
23
|
+
option ["-e", "--recent"], :flag, "Snapshot the most recent unique packages", :default => false
|
24
24
|
option ["-k", "--gpg"], :flag, "Sign release files with users GPG key", :default => false
|
25
25
|
option ["-g", "--generate"], :flag , "Generate new repository"
|
26
26
|
|
@@ -28,8 +28,12 @@ class Main < Clamp::Command
|
|
28
28
|
if recent? && !snapshot
|
29
29
|
raise "--snapshot is required for --recent\n"
|
30
30
|
end
|
31
|
+
|
32
|
+
if type == "deb" && !component
|
33
|
+
raise "--deb option required the --component option!"
|
34
|
+
end
|
35
|
+
|
31
36
|
r = PRM::Repo.new
|
32
|
-
r.component = component
|
33
37
|
r.release = release
|
34
38
|
r.arch = arch
|
35
39
|
r.type = type
|
@@ -46,6 +50,9 @@ class Main < Clamp::Command
|
|
46
50
|
unless snapshot.nil?
|
47
51
|
r.snapshot = snapshot
|
48
52
|
end
|
53
|
+
unless component.nil?
|
54
|
+
r.component = component
|
55
|
+
end
|
49
56
|
if recent?
|
50
57
|
r.recent = recent?
|
51
58
|
end
|
data/lib/prm/repo.rb
CHANGED
@@ -9,501 +9,362 @@ require 'thread'
|
|
9
9
|
require 'peach'
|
10
10
|
require 'aws/s3'
|
11
11
|
require 'arr-pm'
|
12
|
+
require_relative "rpm"
|
12
13
|
|
13
|
-
module
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
module Debian
|
15
|
+
def build_apt_repo(path, component, arch, release, gpg, silent)
|
16
|
+
release.each { |r|
|
17
|
+
component.each { |c|
|
18
|
+
arch.each { |a|
|
19
|
+
fpath = path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/"
|
20
|
+
pfpath = fpath + "Packages"
|
21
|
+
rfpath = fpath + "Release"
|
22
|
+
|
23
|
+
unless silent == true
|
24
|
+
puts "Building Path: #{fpath}"
|
25
|
+
end
|
22
26
|
|
23
|
-
|
27
|
+
FileUtils.mkpath(fpath)
|
28
|
+
FileUtils.touch(pfpath)
|
29
|
+
FileUtils.touch(rfpath)
|
30
|
+
generate_packages_gz(fpath,pfpath,path,rfpath,r,c,a, silent)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
generate_release(path,r,component,arch)
|
24
34
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
primary
|
35
|
+
if gpg == true
|
36
|
+
generate_release_gpg(path,r)
|
37
|
+
end
|
29
38
|
}
|
39
|
+
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
FileUtils.mkdir(sha256_path)
|
36
|
-
end
|
37
|
-
trpm = rpm.split('/').last
|
38
|
-
if File.exists?("#{sha256_path}/#{trpm}")
|
39
|
-
file = File.open("#{sha256_path}/#{trpm}", 'r')
|
40
|
-
sha256sum = file.read
|
41
|
-
file.close
|
42
|
-
else
|
43
|
-
sha256sum = Digest::SHA256.file(rpm).hexdigest
|
44
|
-
File.open("#{sha256_path}/#{trpm}", 'w') { |file| file.write(sha256sum) }
|
45
|
-
end
|
46
|
-
|
47
|
-
nrpm = RPM::File.new(rpm)
|
48
|
-
sheader = nrpm.lead.length + nrpm.signature.length
|
49
|
-
eheader = sheader + nrpm.header.length
|
50
|
-
|
51
|
-
info = Hash[*nrpm.header.tags.collect { |t| [t.tag, t.value] }.inject([]) { |m,v| m + v }]
|
52
|
-
package_hash[trpm] = {
|
53
|
-
"sha256" => sha256sum,
|
54
|
-
"name" => info[:name],
|
55
|
-
"arch" => info[:arch],
|
56
|
-
"version" => info[:version],
|
57
|
-
"release" => info[:release],
|
58
|
-
"start_header" => sheader,
|
59
|
-
"end_header" => eheader,
|
60
|
-
"files" => nrpm.files,
|
61
|
-
"license" => info[:license],
|
62
|
-
"vendor" => info[:vendor],
|
63
|
-
"buildtime" => info[:buildtime],
|
64
|
-
"buildhost" => info[:buildhost],
|
65
|
-
"requires" => nrpm.requires,
|
66
|
-
"conflicts" => nrpm.conflicts,
|
67
|
-
"provides" => nrpm.provides,
|
68
|
-
"epoch" => info[:epochnum],
|
69
|
-
"sourcerpm" => info[:sourcerpm],
|
70
|
-
"buildtime" => info[:buildtime],
|
71
|
-
"installtime" => info[:installtime],
|
72
|
-
"url" => info[:url],
|
73
|
-
"summary" => info[:summary],
|
74
|
-
"description" => info[:description],
|
75
|
-
"packager" => info[:packager],
|
76
|
-
"size" => info[:size],
|
77
|
-
"longsize" => info[:longsize],
|
78
|
-
"filesizes" => info[:filesizes]
|
79
|
-
}
|
80
|
-
|
41
|
+
def move_packages(path,component,arch,release,directory)
|
42
|
+
unless File.exists?(directory)
|
43
|
+
puts "ERROR: #{directory} doesn't exist... not doing anything\n"
|
44
|
+
return false
|
81
45
|
end
|
82
46
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
47
|
+
files_moved = Array.new
|
48
|
+
release.each { |r|
|
49
|
+
component.each { |c|
|
50
|
+
arch.each { |a|
|
51
|
+
puts a
|
52
|
+
Dir.glob(directory + "/*.deb") do |file|
|
53
|
+
if file =~ /^.*#{a}.*\.deb$/i || file =~ /^.*all.*\.deb$/i || file =~ /^.*any.*\.deb$/i
|
54
|
+
if file =~ /^.*#{r}.*\.deb$/i
|
55
|
+
# Lets do this here to help mitigate packages like "asdf-123+wheezy.deb"
|
56
|
+
FileUtils.cp(file, "#{path}/dists/#{r}/#{c}/binary-#{a}/")
|
57
|
+
FileUtils.rm(file)
|
58
|
+
else
|
59
|
+
FileUtils.cp(file, "#{path}/dists/#{r}/#{c}/binary-#{a}/")
|
60
|
+
files_moved << file
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
}
|
65
|
+
}
|
103
66
|
}
|
104
67
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
68
|
+
files_moved.each do |f|
|
69
|
+
if File.exists?(f)
|
70
|
+
FileUtils.rm(f)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# Regex?
|
74
|
+
#/^.*#{arch}.*\.deb$/i
|
75
|
+
end
|
109
76
|
|
110
|
-
|
111
|
-
|
112
|
-
|
77
|
+
def generate_packages_gz(fpath,pfpath,path,rfpath,r,c,a,silent)
|
78
|
+
unless silent == true
|
79
|
+
puts "Generating Packages: #{r} : #{c} : binary-#{a}"
|
80
|
+
end
|
113
81
|
|
114
|
-
|
115
|
-
|
116
|
-
ff.each do |line|
|
117
|
-
gz.write(line)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
}
|
82
|
+
npath = "dists/" + r + "/" + c + "/" + "binary-" + a + "/"
|
83
|
+
packages_text = []
|
121
84
|
|
122
|
-
|
123
|
-
|
124
|
-
xml_hash[f]["xml"] = Digest::SHA256.file("#{path}/#{f}.xml.tmp").hexdigest
|
125
|
-
xml_hash[f]["size"] = File.size?("#{path}/#{f}.xml.tmp.gz")
|
126
|
-
xml_hash[f]["osize"] = File.size?("#{path}/#{f}.xml.tmp")
|
127
|
-
}
|
85
|
+
d = File.open(pfpath, "w+")
|
86
|
+
write_mutex = Mutex.new
|
128
87
|
|
129
|
-
|
130
|
-
|
131
|
-
|
88
|
+
Dir.glob("#{fpath}*.deb").peach do |deb|
|
89
|
+
md5sum = ''
|
90
|
+
tdeb = deb.split('/').last
|
91
|
+
md5sum_path = path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/md5-results/" + tdeb
|
92
|
+
|
93
|
+
FileUtils.mkdir_p "tmp/#{tdeb}/"
|
94
|
+
FileUtils.mkdir_p path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/md5-results/"
|
95
|
+
`ar p #{deb} control.tar.gz | tar zx -C tmp/#{tdeb}/`
|
132
96
|
|
133
|
-
|
134
|
-
r_file.puts erb_two
|
135
|
-
r_file.close
|
97
|
+
init_size = `wc -c < #{deb}`
|
136
98
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
99
|
+
if File.exists? md5sum_path
|
100
|
+
file = File.open(md5sum_path, 'r')
|
101
|
+
md5sum = file.read
|
102
|
+
file.close
|
103
|
+
else
|
104
|
+
md5sum = Digest::MD5.file(deb)
|
105
|
+
File.open(md5sum_path, 'w') { |file| file.write(md5sum) }
|
106
|
+
end
|
107
|
+
|
108
|
+
package_info = [
|
109
|
+
"Filename: #{npath}#{tdeb}",
|
110
|
+
"MD5sum: #{md5sum}",
|
111
|
+
"Size: #{init_size}"
|
112
|
+
]
|
113
|
+
|
114
|
+
write_mutex.synchronize do
|
115
|
+
# Copy the control file data into the Packages list
|
116
|
+
d.write(File.read("tmp/#{tdeb}/control"))
|
117
|
+
d.write(package_info.join("\n"))
|
118
|
+
d.write("\n") # blank line between package info in the Packages file
|
141
119
|
end
|
142
|
-
end
|
143
120
|
end
|
144
121
|
|
145
|
-
|
146
|
-
FileUtils.move("#{path}/#{f}.xml.tmp.gz", "#{path}/" + xml_hash[f]["gz"] + "-#{f}.xml.gz")
|
147
|
-
FileUtils.rm("#{path}/#{f}.xml.tmp")
|
148
|
-
}
|
149
|
-
FileUtils.move("#{path}/repomd.xml.tmp", "#{path}/repomd.xml")
|
150
|
-
}
|
151
|
-
}
|
152
|
-
end
|
153
|
-
end
|
122
|
+
FileUtils.rmtree 'tmp/'
|
154
123
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
unless silent == true
|
165
|
-
puts "Building Path: #{fpath}"
|
166
|
-
end
|
167
|
-
|
168
|
-
FileUtils.mkpath(fpath)
|
169
|
-
FileUtils.touch(pfpath)
|
170
|
-
FileUtils.touch(rfpath)
|
171
|
-
generate_packages_gz(fpath,pfpath,path,rfpath,r,c,a, silent)
|
172
|
-
}
|
173
|
-
}
|
174
|
-
generate_release(path,r,component,arch)
|
175
|
-
|
176
|
-
if gpg == true
|
177
|
-
generate_release_gpg(path,r)
|
178
|
-
end
|
179
|
-
}
|
180
|
-
end
|
181
|
-
|
182
|
-
def move_packages(path,component,arch,release,directory)
|
183
|
-
unless File.exists?(directory)
|
184
|
-
puts "ERROR: #{directory} doesn't exist... not doing anything\n"
|
185
|
-
return false
|
124
|
+
d.close
|
125
|
+
|
126
|
+
Zlib::GzipWriter.open(pfpath + ".gz") do |gz|
|
127
|
+
f = File.new(pfpath, "r")
|
128
|
+
f.each do |line|
|
129
|
+
gz.write(line)
|
130
|
+
end
|
131
|
+
end
|
186
132
|
end
|
187
133
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
else
|
200
|
-
FileUtils.cp(file, "#{path}/dists/#{r}/#{c}/binary-#{a}/")
|
201
|
-
files_moved << file
|
202
|
-
end
|
134
|
+
def generate_release(path,release,component,arch)
|
135
|
+
date = Time.now.utc
|
136
|
+
|
137
|
+
release_info = Hash.new()
|
138
|
+
unreasonable_array = Array.new
|
139
|
+
unreasonable_array = ["Packages", "Packages.gz", "Release"]
|
140
|
+
component_ar = Array.new
|
141
|
+
Dir.glob(path + "/dists/" + release + "/*").select { |f|
|
142
|
+
f.slice!(path + "/dists/" + release + "/")
|
143
|
+
unless f == "Release" or f == "Release.gpg"
|
144
|
+
component_ar << f
|
203
145
|
end
|
204
|
-
end
|
205
146
|
}
|
206
|
-
}
|
207
|
-
}
|
208
147
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
#/^.*#{arch}.*\.deb$/i
|
216
|
-
end
|
148
|
+
component_ar.each do |c|
|
149
|
+
arch.each do |ar|
|
150
|
+
unreasonable_array.each do |unr|
|
151
|
+
tmp_path = "#{path}/dists/#{release}/#{c}/binary-#{ar}"
|
152
|
+
tmp_hash = Hash.new
|
153
|
+
filename = "#{c}/binary-#{ar}/#{unr}".chomp
|
217
154
|
|
218
|
-
|
219
|
-
|
220
|
-
puts "Generating Packages: #{r} : #{c} : binary-#{a}"
|
221
|
-
end
|
155
|
+
byte_size = File.size("#{tmp_path}/#{unr}").to_s
|
156
|
+
md5sum = Digest::MD5.file("#{tmp_path}/#{unr}").to_s
|
222
157
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
Dir.glob("#{fpath}*.deb").peach do |deb|
|
230
|
-
md5sum = ''
|
231
|
-
tdeb = deb.split('/').last
|
232
|
-
md5sum_path = path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/md5-results/" + tdeb
|
233
|
-
|
234
|
-
FileUtils.mkdir_p "tmp/#{tdeb}/"
|
235
|
-
FileUtils.mkdir_p path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/md5-results/"
|
236
|
-
`ar p #{deb} control.tar.gz | tar zx -C tmp/#{tdeb}/`
|
237
|
-
|
238
|
-
init_size = `wc -c < #{deb}`
|
239
|
-
|
240
|
-
if File.exists? md5sum_path
|
241
|
-
file = File.open(md5sum_path, 'r')
|
242
|
-
md5sum = file.read
|
243
|
-
file.close
|
244
|
-
else
|
245
|
-
md5sum = Digest::MD5.file(deb)
|
246
|
-
File.open(md5sum_path, 'w') { |file| file.write(md5sum) }
|
247
|
-
end
|
248
|
-
|
249
|
-
package_info = [
|
250
|
-
"Filename: #{npath}#{tdeb}",
|
251
|
-
"MD5sum: #{md5sum}",
|
252
|
-
"Size: #{init_size}"
|
253
|
-
]
|
254
|
-
|
255
|
-
write_mutex.synchronize do
|
256
|
-
# Copy the control file data into the Packages list
|
257
|
-
d.write(File.read("tmp/#{tdeb}/control"))
|
258
|
-
d.write(package_info.join("\n"))
|
259
|
-
d.write("\n") # blank line between package info in the Packages file
|
260
|
-
end
|
261
|
-
end
|
158
|
+
tmp_hash['size'] = byte_size
|
159
|
+
tmp_hash['md5sum'] = md5sum
|
160
|
+
release_info[filename] = tmp_hash
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
262
164
|
|
263
|
-
FileUtils.rmtree 'tmp/'
|
264
165
|
|
265
|
-
|
166
|
+
template_dir = File.join(File.dirname(__FILE__), "..", "..", "templates")
|
167
|
+
erb = ERB.new(File.open("#{template_dir}/deb_release.erb") { |file|
|
168
|
+
file.read
|
169
|
+
}).result(binding)
|
170
|
+
|
171
|
+
release_file = File.new("#{path}/dists/#{release}/Release.tmp","wb")
|
172
|
+
release_file.puts erb
|
173
|
+
release_file.close
|
266
174
|
|
267
|
-
|
268
|
-
f = File.new(pfpath, "r")
|
269
|
-
f.each do |line|
|
270
|
-
gz.write(line)
|
271
|
-
end
|
175
|
+
FileUtils.move("#{path}/dists/#{release}/Release.tmp", "#{path}/dists/#{release}/Release")
|
272
176
|
end
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
release_info = Hash.new()
|
279
|
-
unreasonable_array = Array.new
|
280
|
-
unreasonable_array = ["Packages", "Packages.gz", "Release"]
|
281
|
-
component_ar = Array.new
|
282
|
-
Dir.glob(path + "/dists/" + release + "/*").select { |f|
|
283
|
-
f.slice!(path + "/dists/" + release + "/")
|
284
|
-
unless f == "Release" or f == "Release.gpg"
|
285
|
-
component_ar << f
|
286
|
-
end
|
287
|
-
}
|
288
|
-
|
289
|
-
component_ar.each do |c|
|
290
|
-
arch.each do |ar|
|
291
|
-
unreasonable_array.each do |unr|
|
292
|
-
tmp_path = "#{path}/dists/#{release}/#{c}/binary-#{ar}"
|
293
|
-
tmp_hash = Hash.new
|
294
|
-
filename = "#{c}/binary-#{ar}/#{unr}".chomp
|
295
|
-
|
296
|
-
byte_size = File.size("#{tmp_path}/#{unr}").to_s
|
297
|
-
md5sum = Digest::MD5.file("#{tmp_path}/#{unr}").to_s
|
298
|
-
|
299
|
-
tmp_hash['size'] = byte_size
|
300
|
-
tmp_hash['md5sum'] = md5sum
|
301
|
-
release_info[filename] = tmp_hash
|
177
|
+
|
178
|
+
# We expect that GPG is installed and a key has already been made
|
179
|
+
def generate_release_gpg(path,release)
|
180
|
+
Dir.chdir("#{path}/dists/#{release}") do
|
181
|
+
system "gpg --yes --output Release.gpg -b Release"
|
302
182
|
end
|
303
|
-
end
|
304
183
|
end
|
184
|
+
end
|
305
185
|
|
186
|
+
module SNAP
|
187
|
+
def snapshot_to(path,component,release,snapname,type,recent)
|
188
|
+
if type != "deb"
|
189
|
+
puts "Only deb supported"
|
190
|
+
return
|
191
|
+
end
|
306
192
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
193
|
+
release.each do |r|
|
194
|
+
time = Time.new
|
195
|
+
now = time.strftime("%Y-%m-%d-%H-%M")
|
196
|
+
new_snap = "#{snapname}-#{now}"
|
311
197
|
|
312
|
-
release_file = File.new("#{path}/dists/#{release}/Release.tmp","wb")
|
313
|
-
release_file.puts erb
|
314
|
-
release_file.close
|
315
198
|
|
316
|
-
|
317
|
-
|
199
|
+
component.each do |c|
|
200
|
+
if !File.exists?("#{path}/dists/#{r}/#{c}")
|
201
|
+
puts "Component doesn't exist! To snapshot you need to have an existing component\n"
|
202
|
+
return
|
203
|
+
end
|
204
|
+
end
|
318
205
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
end
|
324
|
-
end
|
325
|
-
end
|
206
|
+
if File.exists?("#{path}/dists/#{r}/#{snapname}") && !File.symlink?("#{path}/dists/#{r}/#{snapname}")
|
207
|
+
puts "Snapshot target is a filesystem, remove it or rename your snap target"
|
208
|
+
return
|
209
|
+
end
|
326
210
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
puts "Only deb supported"
|
331
|
-
return
|
332
|
-
end
|
211
|
+
unless File.exists?("#{path}/dists/#{r}/#{new_snap}/")
|
212
|
+
Dir.mkdir("#{path}/dists/#{r}/#{new_snap}")
|
213
|
+
end
|
333
214
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
if recent
|
357
|
-
component.each do |c|
|
358
|
-
arch_ar = arch.split(",")
|
359
|
-
arch_ar.each do |a|
|
360
|
-
source_dir = "#{path}/dists/#{r}/#{c}/binary-#{a}"
|
361
|
-
target_dir = "#{path}/dists/#{r}/#{new_snap}/binary-#{a}"
|
362
|
-
pfiles = Dir.glob("#{source_dir}/*").sort_by { |f| File.mtime(f) }
|
363
|
-
|
364
|
-
package_hash = Hash.new
|
365
|
-
pfiles.each do |p|
|
366
|
-
file = p.split(/[_]/)
|
367
|
-
mtime = File.mtime(p)
|
368
|
-
date_in_mil = mtime.to_f
|
369
|
-
if File.directory?(p)
|
370
|
-
next
|
371
|
-
elsif !package_hash.has_key?(file[0])
|
372
|
-
package_hash[file[0]] = { "name" => p, "time" => date_in_mil }
|
373
|
-
else
|
374
|
-
if date_in_mil > package_hash[file[0]]["time"]
|
375
|
-
package_hash[file[0]] = { "name" => p, "time" => date_in_mil }
|
215
|
+
if recent
|
216
|
+
component.each do |c|
|
217
|
+
arch_ar = arch.split(",")
|
218
|
+
arch_ar.each do |a|
|
219
|
+
source_dir = "#{path}/dists/#{r}/#{c}/binary-#{a}"
|
220
|
+
target_dir = "#{path}/dists/#{r}/#{new_snap}/binary-#{a}"
|
221
|
+
pfiles = Dir.glob("#{source_dir}/*").sort_by { |f| File.mtime(f) }
|
222
|
+
|
223
|
+
package_hash = Hash.new
|
224
|
+
pfiles.each do |p|
|
225
|
+
file = p.split(/[_]/)
|
226
|
+
mtime = File.mtime(p)
|
227
|
+
date_in_mil = mtime.to_f
|
228
|
+
if File.directory?(p)
|
229
|
+
next
|
230
|
+
elsif !package_hash.has_key?(file[0])
|
231
|
+
package_hash[file[0]] = { "name" => p, "time" => date_in_mil }
|
232
|
+
else
|
233
|
+
if date_in_mil > package_hash[file[0]]["time"]
|
234
|
+
package_hash[file[0]] = { "name" => p, "time" => date_in_mil }
|
235
|
+
end
|
236
|
+
end
|
376
237
|
end
|
377
|
-
end
|
378
|
-
end
|
379
238
|
|
380
|
-
|
381
|
-
|
382
|
-
|
239
|
+
if !File.exists?(target_dir)
|
240
|
+
FileUtils.mkdir_p(target_dir)
|
241
|
+
end
|
242
|
+
|
243
|
+
package_hash.each do |key,value|
|
244
|
+
value["name"].each do |k|
|
245
|
+
target_file = k.split("/").last
|
246
|
+
FileUtils.cp(k, "#{target_dir}/#{target_file}")
|
247
|
+
end
|
248
|
+
end
|
383
249
|
|
384
|
-
package_hash.each do |key,value|
|
385
|
-
value["name"].each do |k|
|
386
|
-
target_file = k.split("/").last
|
387
|
-
FileUtils.cp(k, "#{target_dir}/#{target_file}")
|
388
250
|
end
|
389
251
|
end
|
390
|
-
|
252
|
+
else
|
253
|
+
FileUtils.cp_r(Dir["#{path}/dists/#{r}/#{component}/*"], "#{path}/dists/#{r}/#{new_snap}")
|
391
254
|
end
|
392
|
-
end
|
393
|
-
else
|
394
|
-
FileUtils.cp_r(Dir["#{path}/dists/#{r}/#{component}/*"], "#{path}/dists/#{r}/#{new_snap}")
|
395
|
-
end
|
396
255
|
|
397
|
-
|
398
|
-
|
399
|
-
|
256
|
+
if File.exists?("#{path}/dists/#{r}/#{snapname}")
|
257
|
+
FileUtils.rm("#{path}/dists/#{r}/#{snapname}")
|
258
|
+
end
|
400
259
|
|
401
|
-
|
402
|
-
|
260
|
+
FileUtils.ln_s "#{new_snap}", "#{path}/dists/#{r}/#{snapname}", :force => true
|
261
|
+
puts "Created #{snapname} snapshot of #{component}\n"
|
262
|
+
end
|
403
263
|
end
|
404
|
-
end
|
405
264
|
end
|
406
265
|
|
407
266
|
module DHO
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
)
|
417
|
-
|
418
|
-
AWS::S3::Service.buckets.each do |bucket|
|
419
|
-
unless bucket == path
|
420
|
-
AWS::S3::Bucket.create(path)
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
new_content = Array.new
|
425
|
-
Find.find(path + "/") do |object|
|
426
|
-
object.slice!(path + "/")
|
427
|
-
if (object =~ /deb$/) || (object =~ /Release$/) || (object =~ /Packages.gz$/) || (object =~ /Packages$/) || (object =~ /gpg$/)
|
428
|
-
f = path + "/" + object
|
429
|
-
new_content << object
|
430
|
-
AWS::S3::S3Object.store(
|
431
|
-
object,
|
432
|
-
open(f),
|
433
|
-
path
|
267
|
+
def sync_to_dho(path, accesskey, secretkey,pcomponent,prelease)
|
268
|
+
component = pcomponent.join
|
269
|
+
release = prelease.join
|
270
|
+
AWS::S3::Base.establish_connection!(
|
271
|
+
:server => 'objects.dreamhost.com',
|
272
|
+
:use_ssl => true,
|
273
|
+
:access_key_id => accesskey,
|
274
|
+
:secret_access_key => secretkey
|
434
275
|
)
|
435
276
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
277
|
+
AWS::S3::Service.buckets.each do |bucket|
|
278
|
+
unless bucket == path
|
279
|
+
AWS::S3::Bucket.create(path)
|
280
|
+
end
|
281
|
+
end
|
441
282
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
283
|
+
new_content = Array.new
|
284
|
+
Find.find(path + "/") do |object|
|
285
|
+
object.slice!(path + "/")
|
286
|
+
if (object =~ /deb$/) || (object =~ /Release$/) || (object =~ /Packages.gz$/) || (object =~ /Packages$/) || (object =~ /gpg$/)
|
287
|
+
f = path + "/" + object
|
288
|
+
new_content << object
|
289
|
+
AWS::S3::S3Object.store(
|
290
|
+
object,
|
291
|
+
open(f),
|
292
|
+
path
|
293
|
+
)
|
294
|
+
|
295
|
+
policy = AWS::S3::S3Object.acl(object, path)
|
296
|
+
policy.grants = [ AWS::S3::ACL::Grant.grant(:public_read) ]
|
297
|
+
AWS::S3::S3Object.acl(object,path,policy)
|
298
|
+
end
|
448
299
|
end
|
449
|
-
|
300
|
+
|
301
|
+
bucket_info = AWS::S3::Bucket.find(path)
|
302
|
+
bucket_info.each do |obj|
|
303
|
+
o = obj.key
|
304
|
+
if (o =~ /deb$/) || (o =~ /Release$/) || (o =~ /Packages.gz$/) || (o =~ /Packages$/) || (o =~ /gpg$/)
|
305
|
+
unless new_content.include?(o)
|
306
|
+
AWS::S3::S3Object.delete(o,path)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
puts "Your apt repository is located at http://objects.dreamhost.com/#{path}/"
|
311
|
+
puts "Add the following to your apt sources.list"
|
312
|
+
puts "deb http://objects.dreamhost.com/#{path}/ #{release} #{component}"
|
450
313
|
end
|
451
|
-
puts "Your apt repository is located at http://objects.dreamhost.com/#{path}/"
|
452
|
-
puts "Add the following to your apt sources.list"
|
453
|
-
puts "deb http://objects.dreamhost.com/#{path}/ #{release} #{component}"
|
454
|
-
end
|
455
314
|
end
|
456
315
|
|
457
316
|
module PRM
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
317
|
+
class PRM::Repo
|
318
|
+
include Debian
|
319
|
+
include DHO
|
320
|
+
include SNAP
|
321
|
+
include Redhat
|
322
|
+
|
323
|
+
attr_accessor :path
|
324
|
+
attr_accessor :type
|
325
|
+
attr_accessor :component
|
326
|
+
attr_accessor :arch
|
327
|
+
attr_accessor :release
|
328
|
+
attr_accessor :gpg
|
329
|
+
attr_accessor :secretkey
|
330
|
+
attr_accessor :accesskey
|
331
|
+
attr_accessor :snapshot
|
332
|
+
attr_accessor :directory
|
333
|
+
attr_accessor :recent
|
334
|
+
|
335
|
+
def create
|
336
|
+
if "#{@type}" == "deb"
|
337
|
+
parch,pcomponent,prelease = _parse_vars(arch,component,release)
|
338
|
+
if snapshot
|
339
|
+
snapshot_to(path,pcomponent,prelease,snapshot,type,recent)
|
340
|
+
pcomponent = snapshot
|
341
|
+
end
|
342
|
+
if directory
|
343
|
+
silent = true
|
344
|
+
build_apt_repo(path,pcomponent,parch,prelease,gpg,silent)
|
345
|
+
if move_packages(path,pcomponent,parch,prelease,directory) == false
|
346
|
+
return
|
347
|
+
end
|
348
|
+
end
|
349
|
+
silent = false
|
350
|
+
build_apt_repo(path,pcomponent,parch,prelease,gpg,silent)
|
351
|
+
elsif "#{@type}" == "sync"
|
352
|
+
sync_to_dho(path, accesskey, secretkey,pcomponent,prelease)
|
353
|
+
elsif "#{@type}" == "rpm"
|
354
|
+
component = nil
|
355
|
+
parch,pcomponent,prelease = _parse_vars(arch,component,release)
|
356
|
+
silent = false
|
357
|
+
build_rpm_repo(path,parch,prelease,gpg,silent)
|
358
|
+
end
|
489
359
|
end
|
490
|
-
silent = false
|
491
|
-
build_apt_repo(path,pcomponent,parch,prelease,gpg,silent)
|
492
|
-
elsif "#{@type}" == "sync"
|
493
|
-
sync_to_dho(path, accesskey, secretkey,pcomponent,prelease)
|
494
|
-
elsif "#{@type}" == "rpm"
|
495
|
-
component = "test"
|
496
|
-
parch,prelease = _parse_vars(arch,component,release)
|
497
|
-
silent = false
|
498
|
-
build_rpm_repo(path,parch,prelease,gpg,silent)
|
499
|
-
end
|
500
|
-
end
|
501
360
|
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
361
|
+
def _parse_vars(arch_ar,component_ar,release_ar)
|
362
|
+
arch_ar = arch.split(",")
|
363
|
+
if !component.nil?
|
364
|
+
component_ar = component.split(",")
|
365
|
+
end
|
366
|
+
release_ar = release.split(",")
|
367
|
+
return [arch_ar,component_ar,release_ar]
|
368
|
+
end
|
507
369
|
end
|
508
|
-
end
|
509
370
|
end
|