prm 0.0.3 → 0.0.4
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.
- data/prm.rb +5 -1
- data/prm/repo.rb +52 -0
- metadata +19 -5
data/prm.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'prm/trollop'
|
4
4
|
require 'prm/repo'
|
5
5
|
|
6
|
-
version_info = "0.0.
|
6
|
+
version_info = "0.0.4"
|
7
7
|
|
8
8
|
opts = Trollop::options do
|
9
9
|
version "Package Repository Manager #{version_info} - 2012 Brett Gailey"
|
@@ -14,6 +14,8 @@ opts = Trollop::options do
|
|
14
14
|
opt :arch, "Architecture for repository (Multi arch supported by comma)", :type => :string, :require => true, :short => "-a"
|
15
15
|
opt :gpg, "Sign release files with a GPG key (Expects GPG key to be available)", :default => false
|
16
16
|
opt :generate, "Create new repository", :short => "-g"
|
17
|
+
opt :accesskey, "Access Key for DreamObjects", :type => :string
|
18
|
+
opt :secretkey, "Secret Key for DreamObjects", :type => :string
|
17
19
|
end
|
18
20
|
|
19
21
|
Trollop::die "No arguments" if opts.empty?
|
@@ -26,6 +28,8 @@ r.arch = opts[:arch]
|
|
26
28
|
r.type = opts[:type]
|
27
29
|
r.path = opts[:path]
|
28
30
|
r.gpg = opts[:gpg]
|
31
|
+
r.accesskey = opts[:accesskey]
|
32
|
+
r.secretkey = opts[:secretkey]
|
29
33
|
|
30
34
|
if opts[:generate]
|
31
35
|
r.create
|
data/prm/repo.rb
CHANGED
@@ -4,6 +4,8 @@ require 'zlib'
|
|
4
4
|
require 'digest/md5'
|
5
5
|
require 'peach'
|
6
6
|
require 'erb'
|
7
|
+
require 'find'
|
8
|
+
require 'aws/s3'
|
7
9
|
|
8
10
|
module Debian
|
9
11
|
def build_apt_repo(path, component, arch, release, gpg)
|
@@ -124,9 +126,55 @@ module Debian
|
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
129
|
+
module DHO
|
130
|
+
def sync_to_dho(path, accesskey, secretkey)
|
131
|
+
AWS::S3::Base.establish_connection!(
|
132
|
+
:server => 'objects.dreamhost.com',
|
133
|
+
:use_ssl => true,
|
134
|
+
:access_key_id => accesskey,
|
135
|
+
:secret_access_key => secretkey
|
136
|
+
)
|
137
|
+
|
138
|
+
AWS::S3::Service.buckets.each do |bucket|
|
139
|
+
unless bucket == path
|
140
|
+
AWS::S3::Bucket.create(path)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
new_content = Array.new
|
145
|
+
Find.find(path + "/") do |object|
|
146
|
+
object.slice!(path + "/")
|
147
|
+
if (object =~ /deb$/) || (object =~ /Release$/) || (object =~ /Packages.gz$/) || (object =~ /Packages$/) || (object =~ /gpg$/)
|
148
|
+
f = path + "/" + object
|
149
|
+
new_content << object
|
150
|
+
AWS::S3::S3Object.store(
|
151
|
+
object,
|
152
|
+
open(f),
|
153
|
+
path
|
154
|
+
)
|
155
|
+
|
156
|
+
policy = AWS::S3::S3Object.acl(object, path)
|
157
|
+
policy.grants = [ AWS::S3::ACL::Grant.grant(:public_read) ]
|
158
|
+
AWS::S3::S3Object.acl(object,path,policy)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
bucket_info = AWS::S3::Bucket.find(path)
|
163
|
+
bucket_info.each do |obj|
|
164
|
+
o = obj.key
|
165
|
+
if (o =~ /deb$/) || (o =~ /Release$/) || (o =~ /Packages.gz$/) || (o =~ /Packages$/) || (o =~ /gpg$/)
|
166
|
+
unless new_content.include?(o)
|
167
|
+
AWS::S3::S3Object.delete(o,path)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
127
174
|
class PRM
|
128
175
|
class PRM::Repo
|
129
176
|
include Debian
|
177
|
+
include DHO
|
130
178
|
|
131
179
|
attr_accessor :path
|
132
180
|
attr_accessor :type
|
@@ -134,12 +182,16 @@ class PRM
|
|
134
182
|
attr_accessor :arch
|
135
183
|
attr_accessor :release
|
136
184
|
attr_accessor :gpg
|
185
|
+
attr_accessor :secretkey
|
186
|
+
attr_accessor :accesskey
|
137
187
|
|
138
188
|
def create
|
139
189
|
parch,pcomponent,prelease = _parse_vars(arch,component,release)
|
140
190
|
|
141
191
|
if "#{@type}" == "deb"
|
142
192
|
build_apt_repo(path,pcomponent,parch,prelease,gpg)
|
193
|
+
elsif "#{@type}" == "sync"
|
194
|
+
sync_to_dho(path, accesskey, secretkey)
|
143
195
|
elsif "#{@type}" == "rpm"
|
144
196
|
# add rpm stuff here
|
145
197
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brett Gailey
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-21 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,21 @@ dependencies:
|
|
32
32
|
version: "0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
-
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: aws-s3
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: PRM (Package Repository Manager) is an Operating System independent Package Repository tool. PRM supports Repository syncing to DreamObjects
|
36
50
|
email: brett.gailey@dreamhost.com
|
37
51
|
executables:
|
38
52
|
- prm
|