deb-s3 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +40 -29
- data/lib/deb/s3.rb +1 -1
- data/lib/deb/s3/cli.rb +152 -82
- data/lib/deb/s3/manifest.rb +16 -0
- data/lib/deb/s3/package.rb +2 -1
- data/lib/deb/s3/templates/package.erb +7 -4
- data/lib/deb/s3/utils.rb +22 -10
- metadata +5 -5
data/README.md
CHANGED
@@ -59,25 +59,39 @@ Usage:
|
|
59
59
|
deb-s3 upload FILES
|
60
60
|
|
61
61
|
Options:
|
62
|
-
-a, [--arch=ARCH]
|
63
|
-
[--sign=SIGN]
|
64
|
-
-p, [--preserve-versions]
|
65
|
-
-b, [--bucket=BUCKET]
|
66
|
-
-c, [--codename=CODENAME]
|
67
|
-
|
68
|
-
-m, [--component=COMPONENT]
|
69
|
-
|
70
|
-
[--access-key=ACCESS_KEY]
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
[--endpoint=ENDPOINT] # The region endpoint for connecting to S3.
|
75
|
-
-v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
|
76
|
-
# Default: public
|
62
|
+
-a, [--arch=ARCH] # The architecture of the package in the APT repository.
|
63
|
+
[--sign=SIGN] # Sign the Release file. Use --sign with your key ID to use a specific key.
|
64
|
+
-p, [--preserve-versions] # Whether to preserve other versions of a package in the repository when uploading one.
|
65
|
+
-b, [--bucket=BUCKET] # The name of the S3 bucket to upload to.
|
66
|
+
-c, [--codename=CODENAME] # The codename of the APT repository.
|
67
|
+
# Default: stable
|
68
|
+
-m, [--component=COMPONENT] # The component of the APT repository.
|
69
|
+
# Default: main
|
70
|
+
[--access-key-id=ACCESS_KEY] # The access key for connecting to S3.
|
71
|
+
[--secret-access-key=SECRET_KEY] # The secret key for connecting to S3.
|
72
|
+
-v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
|
73
|
+
# Default: public
|
77
74
|
|
78
75
|
Uploads the given files to a S3 bucket as an APT repository.
|
79
76
|
```
|
80
77
|
|
78
|
+
You can also delete packages from the APT repository. Please keep in mind that
|
79
|
+
this does NOT delete the .deb file itself, it only removes it from the list of
|
80
|
+
packages in the specified component, codename and architecture.
|
81
|
+
|
82
|
+
Now to delete the package:
|
83
|
+
```console
|
84
|
+
$ deb-s3 delete --arch amd64 --bucket my-bucket --versions 1.0.0 my-deb-package
|
85
|
+
>> Retrieving existing manifests
|
86
|
+
-- Deleting my-deb-package version 1.0.0
|
87
|
+
>> Uploading new manifests to S3
|
88
|
+
-- Transferring dists/stable/main/binary-amd64/Packages
|
89
|
+
-- Transferring dists/stable/main/binary-amd64/Packages.gz
|
90
|
+
-- Transferring dists/stable/Release
|
91
|
+
>> Update complete.
|
92
|
+
|
93
|
+
````
|
94
|
+
|
81
95
|
You can also verify an existing APT repository on S3 using the `verify` command:
|
82
96
|
|
83
97
|
```console
|
@@ -93,20 +107,17 @@ Usage:
|
|
93
107
|
deb-s3 verify
|
94
108
|
|
95
109
|
Options:
|
96
|
-
-f, [--fix-manifests]
|
97
|
-
[--sign=SIGN]
|
98
|
-
-b, [--bucket=BUCKET]
|
99
|
-
-c, [--codename=CODENAME]
|
100
|
-
|
101
|
-
-m, [--component=COMPONENT]
|
102
|
-
|
103
|
-
[--access-key=ACCESS_KEY]
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
[--endpoint=ENDPOINT] # The region endpoint for connecting to S3.
|
108
|
-
-v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
|
109
|
-
# Default: public
|
110
|
+
-f, [--fix-manifests] # Whether to fix problems in manifests when verifying.
|
111
|
+
[--sign=SIGN] # Sign the Release file. Use --sign with your key ID to use a specific key.
|
112
|
+
-b, [--bucket=BUCKET] # The name of the S3 bucket to upload to.
|
113
|
+
-c, [--codename=CODENAME] # The codename of the APT repository.
|
114
|
+
# Default: stable
|
115
|
+
-m, [--component=COMPONENT] # The component of the APT repository.
|
116
|
+
# Default: main
|
117
|
+
[--access-key-id=ACCESS_KEY] # The access key for connecting to S3.
|
118
|
+
[--secret-access-key=SECRET_KEY] # The secret key for connecting to S3.
|
119
|
+
-v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
|
120
|
+
# Default: public
|
110
121
|
|
111
122
|
Verifies that the files in the package manifests exist
|
112
123
|
```
|
data/lib/deb/s3.rb
CHANGED
data/lib/deb/s3/cli.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "aws"
|
2
2
|
require "thor"
|
3
3
|
|
4
|
+
# Hack: aws requires this!
|
5
|
+
require "json"
|
6
|
+
|
4
7
|
require "deb/s3"
|
5
8
|
require "deb/s3/utils"
|
6
9
|
require "deb/s3/manifest"
|
@@ -8,75 +11,77 @@ require "deb/s3/package"
|
|
8
11
|
require "deb/s3/release"
|
9
12
|
|
10
13
|
class Deb::S3::CLI < Thor
|
11
|
-
|
12
14
|
class_option :bucket,
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
:type => :string,
|
16
|
+
:aliases => "-b",
|
17
|
+
:desc => "The name of the S3 bucket to upload to."
|
18
|
+
|
19
|
+
class_option :prefix,
|
20
|
+
:type => :string,
|
21
|
+
:desc => "The path prefix to use when storing on S3."
|
16
22
|
|
17
23
|
class_option :codename,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
:default => "stable",
|
25
|
+
:type => :string,
|
26
|
+
:aliases => "-c",
|
27
|
+
:desc => "The codename of the APT repository."
|
22
28
|
|
23
29
|
class_option :component,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
:default => "main",
|
31
|
+
:type => :string,
|
32
|
+
:aliases => "-m",
|
33
|
+
:desc => "The component of the APT repository."
|
28
34
|
|
29
35
|
class_option :section,
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
:type => :string,
|
37
|
+
:aliases => "-s",
|
38
|
+
:hide => true
|
33
39
|
|
34
|
-
class_option :
|
35
|
-
|
36
|
-
|
37
|
-
:desc => "The access key for connecting to S3."
|
40
|
+
class_option :access_key_id,
|
41
|
+
:type => :string,
|
42
|
+
:desc => "The access key for connecting to S3."
|
38
43
|
|
39
|
-
class_option :
|
40
|
-
|
41
|
-
|
42
|
-
:desc => "The secret key for connecting to S3."
|
44
|
+
class_option :secret_access_key,
|
45
|
+
:type => :string,
|
46
|
+
:desc => "The secret key for connecting to S3."
|
43
47
|
|
44
48
|
class_option :endpoint,
|
45
|
-
|
46
|
-
|
49
|
+
:type => :string,
|
50
|
+
:desc => "The region endpoint for connecting to S3.",
|
51
|
+
:default => "s3.amazonaws.com"
|
47
52
|
|
48
53
|
class_option :visibility,
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
:default => "public",
|
55
|
+
:type => :string,
|
56
|
+
:aliases => "-v",
|
57
|
+
:desc => "The access policy for the uploaded files. " +
|
58
|
+
"Can be public, private, or authenticated."
|
54
59
|
|
55
60
|
class_option :sign,
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
:type => :string,
|
62
|
+
:desc => "Sign the Release file when uploading a package," +
|
63
|
+
"or when verifying it after removing a package." +
|
64
|
+
"Use --sign with your key ID to use a specific key."
|
60
65
|
|
61
66
|
class_option :gpg_options,
|
62
|
-
|
63
|
-
|
64
|
-
|
67
|
+
:default => "",
|
68
|
+
:type => :string,
|
69
|
+
:desc => "Additional command line options to pass to GPG when signing"
|
65
70
|
|
66
71
|
desc "upload FILES",
|
67
|
-
|
72
|
+
"Uploads the given files to a S3 bucket as an APT repository."
|
68
73
|
|
69
74
|
option :arch,
|
70
|
-
|
71
|
-
|
72
|
-
|
75
|
+
:type => :string,
|
76
|
+
:aliases => "-a",
|
77
|
+
:desc => "The architecture of the package in the APT repository."
|
73
78
|
|
74
79
|
option :preserve_versions,
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
:default => false,
|
81
|
+
:type => :boolean,
|
82
|
+
:aliases => "-p",
|
83
|
+
:desc => "Whether to preserve other versions of a package " +
|
84
|
+
"in the repository when uploading one."
|
80
85
|
|
81
86
|
def upload(*files)
|
82
87
|
component = options[:component]
|
@@ -132,13 +137,82 @@ class Deb::S3::CLI < Thor
|
|
132
137
|
log("Update complete.")
|
133
138
|
end
|
134
139
|
|
140
|
+
desc "delete PACKAGE",
|
141
|
+
"Remove the package named PACKAGE. If --versions is not specified, delete" +
|
142
|
+
"all versions of PACKAGE. Otherwise, only the specified versions will be " +
|
143
|
+
"deleted."
|
144
|
+
|
145
|
+
option :arch,
|
146
|
+
:type => :string,
|
147
|
+
:aliases => "-a",
|
148
|
+
:desc => "The architecture of the package in the APT repository."
|
149
|
+
|
150
|
+
option :versions,
|
151
|
+
:default => nil,
|
152
|
+
:type => :array,
|
153
|
+
:desc => "The space-delimited versions of PACKAGE to delete. If not" +
|
154
|
+
"specified, ALL VERSIONS will be deleted. Fair warning." +
|
155
|
+
"E.g. --versions \"0.1 0.2 0.3\""
|
156
|
+
|
157
|
+
def delete(package)
|
158
|
+
component = options[:component]
|
159
|
+
if options[:section]
|
160
|
+
component = options[:section]
|
161
|
+
warn("===> WARNING: The --section/-s argument is deprecated, please use --component/-m.")
|
162
|
+
end
|
163
|
+
|
164
|
+
if package.nil?
|
165
|
+
error("You must specify a package name.")
|
166
|
+
end
|
167
|
+
|
168
|
+
versions = options[:versions]
|
169
|
+
if versions.nil?
|
170
|
+
warn("===> WARNING: Deleting all versions of #{package}")
|
171
|
+
else
|
172
|
+
log("Versions to delete: #{versions.join(', ')}")
|
173
|
+
end
|
174
|
+
|
175
|
+
arch = options[:arch]
|
176
|
+
if arch.nil?
|
177
|
+
error("You must specify the architecture of the package to remove.")
|
178
|
+
end
|
179
|
+
|
180
|
+
configure_s3_client
|
181
|
+
|
182
|
+
# retrieve the existing manifests
|
183
|
+
log("Retrieving existing manifests")
|
184
|
+
release = Deb::S3::Release.retrieve(options[:codename])
|
185
|
+
manifest = Deb::S3::Manifest.retrieve(options[:codename], component, options[:arch])
|
186
|
+
|
187
|
+
deleted = manifest.delete_package(package, versions)
|
188
|
+
if deleted.length == 0
|
189
|
+
if versions.nil?
|
190
|
+
error("No packages were deleted. #{package} not found.")
|
191
|
+
else
|
192
|
+
error("No packages were deleted. #{package} versions #{versions.join(', ')} could not be found.")
|
193
|
+
end
|
194
|
+
else
|
195
|
+
deleted.each { |p|
|
196
|
+
sublog("Deleting #{p.name} version #{p.version}")
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
log("Uploading new manifests to S3")
|
201
|
+
manifest.write_to_s3 {|f| sublog("Transferring #{f}") }
|
202
|
+
release.update_manifest(manifest)
|
203
|
+
release.write_to_s3 {|f| sublog("Transferring #{f}") }
|
204
|
+
|
205
|
+
log("Update complete.")
|
206
|
+
end
|
207
|
+
|
208
|
+
|
135
209
|
desc "verify", "Verifies that the files in the package manifests exist"
|
136
210
|
|
137
211
|
option :fix_manifests,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
212
|
+
:default => false,
|
213
|
+
:type => :boolean,
|
214
|
+
:aliases => "-f",
|
215
|
+
:desc => "Whether to fix problems in manifests when verifying."
|
142
216
|
|
143
217
|
def verify
|
144
218
|
component = options[:component]
|
@@ -152,7 +226,7 @@ class Deb::S3::CLI < Thor
|
|
152
226
|
log("Retrieving existing manifests")
|
153
227
|
release = Deb::S3::Release.retrieve(options[:codename])
|
154
228
|
|
155
|
-
%w[i386
|
229
|
+
%w[amd64 armel i386 all].each do |arch|
|
156
230
|
log("Checking for missing packages in: #{options[:codename]}/#{options[:component]} #{arch}")
|
157
231
|
manifest = Deb::S3::Manifest.retrieve(options[:codename], component, arch)
|
158
232
|
missing_packages = []
|
@@ -194,48 +268,44 @@ class Deb::S3::CLI < Thor
|
|
194
268
|
exit 1
|
195
269
|
end
|
196
270
|
|
197
|
-
def
|
198
|
-
|
199
|
-
|
200
|
-
else
|
201
|
-
options[:access_key]
|
202
|
-
end
|
203
|
-
end
|
271
|
+
def provider
|
272
|
+
access_key_id = options[:access_key_id]
|
273
|
+
secret_access_key = options[:secret_access_key]
|
204
274
|
|
205
|
-
|
206
|
-
|
207
|
-
ENV["AMAZON_SECRET_ACCESS_KEY"]
|
208
|
-
else
|
209
|
-
options[:secret_key]
|
275
|
+
if access_key_id.nil? ^ secret_access_key.nil?
|
276
|
+
error("If you specify one of --access-key-id or --secret-access-key, you must specify the other.")
|
210
277
|
end
|
278
|
+
|
279
|
+
static_credentials = {}
|
280
|
+
static_credentials[:access_key_id] = access_key_id if access_key_id
|
281
|
+
static_credentials[:secret_access_key] = secret_access_key if secret_access_key
|
282
|
+
|
283
|
+
AWS::Core::CredentialProviders::DefaultProvider.new(static_credentials)
|
211
284
|
end
|
212
285
|
|
213
286
|
def configure_s3_client
|
214
|
-
error("No access key given for S3. Please specify one.") unless access_key
|
215
|
-
error("No secret access key given for S3. Please specify one.") unless secret_key
|
216
287
|
error("No value provided for required options '--bucket'") unless options[:bucket]
|
217
288
|
|
218
|
-
|
219
|
-
|
220
|
-
:secret_access_key => secret_key
|
221
|
-
)
|
222
|
-
|
223
|
-
AWS::S3::DEFAULT_HOST.replace options[:endpoint] if options[:endpoint]
|
289
|
+
settings = { :s3_endpoint => options[:endpoint] }
|
290
|
+
settings.merge!(provider.credentials)
|
224
291
|
|
292
|
+
Deb::S3::Utils.s3 = AWS::S3.new(settings)
|
225
293
|
Deb::S3::Utils.bucket = options[:bucket]
|
226
294
|
Deb::S3::Utils.signing_key = options[:sign]
|
227
295
|
Deb::S3::Utils.gpg_options = options[:gpg_options]
|
296
|
+
Deb::S3::Utils.prefix = options[:prefix]
|
228
297
|
|
229
298
|
# make sure we have a valid visibility setting
|
230
|
-
Deb::S3::Utils.access_policy =
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
299
|
+
Deb::S3::Utils.access_policy =
|
300
|
+
case options[:visibility]
|
301
|
+
when "public"
|
302
|
+
:public_read
|
303
|
+
when "private"
|
304
|
+
:private
|
305
|
+
when "authenticated"
|
306
|
+
:authenticated_read
|
307
|
+
else
|
308
|
+
error("Invalid visibility setting given. Can be public, private, or authenticated.")
|
309
|
+
end
|
240
310
|
end
|
241
311
|
end
|
data/lib/deb/s3/manifest.rb
CHANGED
@@ -55,6 +55,22 @@ class Deb::S3::Manifest
|
|
55
55
|
pkg
|
56
56
|
end
|
57
57
|
|
58
|
+
def delete_package(pkg, versions=nil)
|
59
|
+
deleted = []
|
60
|
+
new_packages = @packages.select { |p|
|
61
|
+
# Include packages we didn't name
|
62
|
+
if p.name != pkg
|
63
|
+
p
|
64
|
+
# Also include the packages not matching a specified version
|
65
|
+
elsif (!versions.nil? and p.name == pkg and !versions.include? p.version)
|
66
|
+
p
|
67
|
+
end
|
68
|
+
}
|
69
|
+
deleted = @packages - new_packages
|
70
|
+
@packages = new_packages
|
71
|
+
deleted
|
72
|
+
end
|
73
|
+
|
58
74
|
def generate
|
59
75
|
@packages.collect { |pkg| pkg.generate }.join("\n")
|
60
76
|
end
|
data/lib/deb/s3/package.rb
CHANGED
@@ -214,7 +214,7 @@ class Deb::S3::Package
|
|
214
214
|
|
215
215
|
# from fpm
|
216
216
|
def extract_info(control)
|
217
|
-
parse = lambda do |field|
|
217
|
+
parse = lambda do |field|
|
218
218
|
value = control[/^#{field}: .*/]
|
219
219
|
if value.nil?
|
220
220
|
return nil
|
@@ -239,6 +239,7 @@ class Deb::S3::Package
|
|
239
239
|
self.url = parse.call("Homepage")
|
240
240
|
self.vendor = parse.call("Vendor") || self.vendor
|
241
241
|
self.attributes[:deb_priority] = parse.call("Priority")
|
242
|
+
self.attributes[:deb_origin] = parse.call("Origin")
|
242
243
|
self.attributes[:deb_installed_size] = parse.call("Installed-Size")
|
243
244
|
|
244
245
|
# Packages manifest fields
|
@@ -11,7 +11,7 @@ Depends: <%= dependencies.collect { |d| fix_dependency(d) }.flatten.join(", ") %
|
|
11
11
|
<% if !conflicts.empty? -%>
|
12
12
|
Conflicts: <%= conflicts.join(", ") %>
|
13
13
|
<% end -%>
|
14
|
-
<% if attributes[:
|
14
|
+
<% if attributes[:deb_pre_depends] -%>
|
15
15
|
Pre-Depends: <%= attributes[:deb_pre_depends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
16
16
|
<% end -%>
|
17
17
|
<% if !provides.empty? -%>
|
@@ -22,13 +22,16 @@ Provides: <%= provides.map {|p| p.split(" ").first}.join ", " %>
|
|
22
22
|
<% if !replaces.empty? -%>
|
23
23
|
Replaces: <%= replaces.join(", ") %>
|
24
24
|
<% end -%>
|
25
|
-
<% if attributes[:
|
25
|
+
<% if attributes[:deb_recommends] -%>
|
26
26
|
Recommends: <%= attributes[:deb_recommends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
27
27
|
<% end -%>
|
28
|
-
<% if attributes[:
|
28
|
+
<% if attributes[:deb_suggests] -%>
|
29
29
|
Suggests: <%= attributes[:deb_suggests].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
30
30
|
<% end -%>
|
31
31
|
Section: <%= category %>
|
32
|
+
<% if attributes[:deb_origin] -%>
|
33
|
+
Origin: <%= attributes[:deb_origin] %>
|
34
|
+
<% end -%>
|
32
35
|
Priority: <%= attributes[:deb_priority] %>
|
33
36
|
Homepage: <%= url or "http://nourlgiven.example.com/" %>
|
34
37
|
Filename: <%= url_filename_encoded %>
|
@@ -50,7 +53,7 @@ Description: <%= firstline %>
|
|
50
53
|
<% if remainder.any? -%>
|
51
54
|
<%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
|
52
55
|
<% end -%>
|
53
|
-
<% if attributes[:
|
56
|
+
<% if attributes[:deb_field] -%>
|
54
57
|
<% attributes[:deb_field].each do |field, value| -%>
|
55
58
|
<%= field %>: <%= value %>
|
56
59
|
<% end -%>
|
data/lib/deb/s3/utils.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "digest/md5"
|
1
3
|
require "erb"
|
2
4
|
require "tmpdir"
|
3
5
|
|
4
6
|
module Deb::S3::Utils
|
5
7
|
module_function
|
8
|
+
def s3; @s3 end
|
9
|
+
def s3= v; @s3 = v end
|
6
10
|
def bucket; @bucket end
|
7
11
|
def bucket= v; @bucket = v end
|
8
12
|
def access_policy; @access_policy end
|
@@ -11,6 +15,8 @@ module Deb::S3::Utils
|
|
11
15
|
def signing_key= v; @signing_key = v end
|
12
16
|
def gpg_options; @gpg_options end
|
13
17
|
def gpg_options= v; @gpg_options = v end
|
18
|
+
def prefix; @prefix end
|
19
|
+
def prefix= v; @prefix = v end
|
14
20
|
|
15
21
|
def safesystem(*args)
|
16
22
|
success = system(*args)
|
@@ -32,6 +38,10 @@ module Deb::S3::Utils
|
|
32
38
|
ERB.new(template_code, nil, "-")
|
33
39
|
end
|
34
40
|
|
41
|
+
def s3_path(path)
|
42
|
+
File.join(*[Deb::S3::Utils.prefix, path].compact)
|
43
|
+
end
|
44
|
+
|
35
45
|
# from fog, Fog::AWS.escape
|
36
46
|
def s3_escape(string)
|
37
47
|
string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
|
@@ -40,27 +50,29 @@ module Deb::S3::Utils
|
|
40
50
|
end
|
41
51
|
|
42
52
|
def s3_exists?(path)
|
43
|
-
|
53
|
+
Deb::S3::Utils.s3.buckets[Deb::S3::Utils.bucket].objects[s3_path(path)].exists?
|
44
54
|
end
|
45
55
|
|
46
56
|
def s3_read(path)
|
47
57
|
return nil unless s3_exists?(path)
|
48
|
-
|
49
|
-
AWS::S3::S3Object.stream(path, Deb::S3::Utils.bucket) do |chunk|
|
50
|
-
s += chunk
|
51
|
-
end
|
52
|
-
s
|
58
|
+
Deb::S3::Utils.s3.buckets[Deb::S3::Utils.bucket].objects[s3_path(path)].read
|
53
59
|
end
|
54
60
|
|
55
61
|
def s3_store(path, filename=nil)
|
56
62
|
filename = File.basename(path) unless filename
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
obj = Deb::S3::Utils.s3.buckets[Deb::S3::Utils.bucket].objects[s3_path(filename)]
|
64
|
+
|
65
|
+
# check if the object already exists
|
66
|
+
if obj.exists?
|
67
|
+
file_md5 = Digest::MD5.file(path)
|
68
|
+
return if file_md5.to_s == obj.etag.gsub('"', '')
|
60
69
|
end
|
70
|
+
|
71
|
+
# upload the file
|
72
|
+
obj.write(Pathname.new(path), :acl => Deb::S3::Utils.access_policy)
|
61
73
|
end
|
62
74
|
|
63
75
|
def s3_remove(path)
|
64
|
-
|
76
|
+
Deb::S3::Utils.s3.buckets[Deb::S3::Utils.bucket].objects[s3_path(path)].delete if s3_exists?(path)
|
65
77
|
end
|
66
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deb-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -28,13 +28,13 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.18.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: aws-
|
31
|
+
name: aws-sdk
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: '1.18'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: '1.18'
|
46
46
|
description: Easily create and manage an APT repository on S3.
|
47
47
|
email: ken@invalidlogic.com
|
48
48
|
executables:
|