deb-s3 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +41 -9
  2. data/lib/deb/s3.rb +1 -1
  3. data/lib/deb/s3/cli.rb +75 -43
  4. metadata +2 -2
data/README.md CHANGED
@@ -43,7 +43,7 @@ $ bundle install
43
43
  Now to upload a package, simply use:
44
44
 
45
45
  ```console
46
- $ deb-s3 upload my-deb-package-1.0.0_amd64.deb --bucket my-bucket
46
+ $ deb-s3 upload --bucket my-bucket my-deb-package-1.0.0_amd64.deb
47
47
  >> Examining package file my-deb-package-1.0.0_amd64.deb
48
48
  >> Retrieving existing package manifest
49
49
  >> Uploading package and new manifests to S3
@@ -56,26 +56,58 @@ $ deb-s3 upload my-deb-package-1.0.0_amd64.deb --bucket my-bucket
56
56
 
57
57
  ```
58
58
  Usage:
59
- deb-s3 upload FILE -b, --bucket=BUCKET
59
+ deb-s3 upload FILES
60
60
 
61
61
  Options:
62
- -b, --bucket=BUCKET # The name of the S3 bucket to upload to.
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.
63
66
  -c, [--codename=CODENAME] # The codename of the APT repository.
64
67
  # Default: stable
65
- -s, [--section=SECTION] # The section of the APT repository.
68
+ -m, [--component=COMPONENT] # The component of the APT repository.
66
69
  # Default: main
67
- -a, [--arch=ARCH] # The architecture of the package in the APT repository.
70
+ [--access-key=ACCESS_KEY] # The access key for connecting to S3.
71
+ # Default: $AMAZON_ACCESS_KEY_ID
72
+ [--secret-key=SECRET_KEY] # The secret key for connecting to S3.
73
+ # Default: $AMAZON_SECRET_ACCESS_KEY
74
+ [--endpoint=ENDPOINT] # The region endpoint for connecting to S3.
68
75
  -v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
69
76
  # Default: public
77
+
78
+ Uploads the given files to a S3 bucket as an APT repository.
79
+ ```
80
+
81
+ You can also verify an existing APT repository on S3 using the `verify` command:
82
+
83
+ ```console
84
+ deb-s3 verify -b my-bucket
85
+ >> Retrieving existing manifests
86
+ >> Checking for missing packages in: stable/main i386
87
+ >> Checking for missing packages in: stable/main amd64
88
+ >> Checking for missing packages in: stable/main all
89
+ ```
90
+
91
+ ```
92
+ Usage:
93
+ deb-s3 verify
94
+
95
+ Options:
96
+ -f, [--fix-manifests] # Whether to fix problems in manifests when verifying.
97
+ -b, [--bucket=BUCKET] # The name of the S3 bucket to upload to.
98
+ -c, [--codename=CODENAME] # The codename of the APT repository.
99
+ # Default: stable
100
+ -m, [--component=COMPONENT] # The component of the APT repository.
101
+ # Default: main
70
102
  [--access-key=ACCESS_KEY] # The access key for connecting to S3.
71
103
  # Default: $AMAZON_ACCESS_KEY_ID
72
104
  [--secret-key=SECRET_KEY] # The secret key for connecting to S3.
73
105
  # Default: $AMAZON_SECRET_ACCESS_KEY
74
- [--endpoint=AWS_ENDPOINT] # The aws region endpoint for connecting to S3.
75
- [--sign=SIGN] # Sign the Release file. Use --sign with your key ID to use a specific key.
76
- -p, [--preserve-versions] # Whether to preserve other versions of a package in the repository when uploading one.
106
+ [--endpoint=ENDPOINT] # The region endpoint for connecting to S3.
107
+ -v, [--visibility=VISIBILITY] # The access policy for the uploaded files. Can be public, private, or authenticated.
108
+ # Default: public
77
109
 
78
- Uploads the given FILE to a S3 bucket as an APT repository.
110
+ Verifies that the files in the package manifests exist
79
111
  ```
80
112
 
81
113
  ## TODO
data/lib/deb/s3.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Deb
2
2
  module S3
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
data/lib/deb/s3/cli.rb CHANGED
@@ -20,11 +20,16 @@ class Deb::S3::CLI < Thor
20
20
  :aliases => "-c",
21
21
  :desc => "The codename of the APT repository."
22
22
 
23
- class_option :section,
23
+ class_option :component,
24
24
  :default => "main",
25
+ :type => :string,
26
+ :aliases => "-m",
27
+ :desc => "The component of the APT repository."
28
+
29
+ class_option :section,
25
30
  :type => :string,
26
31
  :aliases => "-s",
27
- :desc => "The section of the APT repository."
32
+ :hide => true
28
33
 
29
34
  class_option :access_key,
30
35
  :default => "$AMAZON_ACCESS_KEY_ID",
@@ -40,21 +45,21 @@ class Deb::S3::CLI < Thor
40
45
  :type => :string,
41
46
  :desc => "The region endpoint for connecting to S3."
42
47
 
43
- desc "upload FILE",
44
- "Uploads the given FILE to a S3 bucket as an APT repository."
45
-
46
- option :arch,
47
- :type => :string,
48
- :aliases => "-a",
49
- :desc => "The architecture of the package in the APT repository."
50
-
51
- option :visibility,
48
+ class_option :visibility,
52
49
  :default => "public",
53
50
  :type => :string,
54
51
  :aliases => "-v",
55
52
  :desc => "The access policy for the uploaded files. " +
56
53
  "Can be public, private, or authenticated."
57
54
 
55
+ desc "upload FILES",
56
+ "Uploads the given files to a S3 bucket as an APT repository."
57
+
58
+ option :arch,
59
+ :type => :string,
60
+ :aliases => "-a",
61
+ :desc => "The architecture of the package in the APT repository."
62
+
58
63
  option :sign,
59
64
  :type => :string,
60
65
  :desc => "Sign the Release file. Use --sign with your key ID to use " +
@@ -67,47 +72,57 @@ class Deb::S3::CLI < Thor
67
72
  :desc => "Whether to preserve other versions of a package " +
68
73
  "in the repository when uploading one."
69
74
 
70
- def upload(file)
71
- # make sure the file exists
72
- error("File doesn't exist") unless File.exists?(file)
75
+ def upload(*files)
76
+ component = options[:component]
77
+ if options[:section]
78
+ component = options[:section]
79
+ warn("===> WARNING: The --section/-s argument is deprecated, please use --component/-m.")
80
+ end
81
+
82
+ if files.nil? || files.empty?
83
+ error("You must specify at least one file to upload")
84
+ end
85
+
86
+ # make sure all the files exists
87
+ if missing_file = files.detect { |f| !File.exists?(f) }
88
+ error("File '#{missing_file}' doesn't exist")
89
+ end
73
90
 
74
91
  # configure AWS::S3
75
92
  configure_s3_client
76
93
 
77
94
  Deb::S3::Utils.signing_key = options[:sign]
78
95
 
79
- # make sure we have a valid visibility setting
80
- Deb::S3::Utils.access_policy = case options[:visibility]
81
- when "public"
82
- :public_read
83
- when "private"
84
- :private
85
- when "authenticated"
86
- :authenticated_read
87
- else
88
- error("Invalid visibility setting given. Can be public, private, or authenticated.")
89
- end
96
+ # retrieve the existing manifests
97
+ log("Retrieving existing manifests")
98
+ release = Deb::S3::Release.retrieve(options[:codename])
99
+ manifests = {}
90
100
 
91
- log("Examining package file #{File.basename(file)}")
92
- pkg = Deb::S3::Package.parse_file(file)
101
+ # examine all the files
102
+ files.collect { |f| Dir.glob(f) }.flatten.each do |file|
103
+ log("Examining package file #{File.basename(file)}")
104
+ pkg = Deb::S3::Package.parse_file(file)
93
105
 
94
- # copy over some options if they weren't given
95
- arch = options[:arch] || pkg.architecture
106
+ # copy over some options if they weren't given
107
+ arch = options[:arch] || pkg.architecture
96
108
 
97
- # validate we have them
98
- error("No architcture given and unable to determine one from the file. " +
99
- "Please specify one with --arch [i386,amd64].") unless arch
109
+ # validate we have them
110
+ error("No architcture given and unable to determine one for #{file}. " +
111
+ "Please specify one with --arch [i386,amd64].") unless arch
100
112
 
101
- log("Retrieving existing manifests")
102
- release = Deb::S3::Release.retrieve(options[:codename])
103
- manifest = Deb::S3::Manifest.retrieve(options[:codename], options[:section], arch)
113
+ # retrieve the manifest for the arch if we don't have it already
114
+ manifests[arch] ||= Deb::S3::Manifest.retrieve(options[:codename], component, arch)
104
115
 
105
- # add in the package
106
- manifest.add(pkg, options[:preserve_versions])
116
+ # add in the package
117
+ manifests[arch].add(pkg, options[:preserve_versions])
118
+ end
107
119
 
108
- log("Uploading package and new manifests to S3")
109
- manifest.write_to_s3 { |f| sublog("Transferring #{f}") }
110
- release.update_manifest(manifest)
120
+ # upload the manifest
121
+ log("Uploading packages and new manifests to S3")
122
+ manifests.each_value do |manifest|
123
+ manifest.write_to_s3 { |f| sublog("Transferring #{f}") }
124
+ release.update_manifest(manifest)
125
+ end
111
126
  release.write_to_s3 { |f| sublog("Transferring #{f}") }
112
127
 
113
128
  log("Update complete.")
@@ -122,14 +137,20 @@ class Deb::S3::CLI < Thor
122
137
  :desc => "Whether to fix problems in manifests when verifying."
123
138
 
124
139
  def verify
140
+ component = options[:component]
141
+ if options[:section]
142
+ component = options[:section]
143
+ warn("===> WARNING: The --section/-s argument is deprecated, please use --component/-m.")
144
+ end
145
+
125
146
  configure_s3_client
126
147
 
127
148
  log("Retrieving existing manifests")
128
149
  release = Deb::S3::Release.retrieve(options[:codename])
129
150
 
130
151
  %w[i386 amd64 all].each do |arch|
131
- log("Checking for missing packages in: #{options[:codename]}/#{options[:section]} #{arch}")
132
- manifest = Deb::S3::Manifest.retrieve(options[:codename], options[:section], arch)
152
+ log("Checking for missing packages in: #{options[:codename]}/#{options[:component]} #{arch}")
153
+ manifest = Deb::S3::Manifest.retrieve(options[:codename], component, arch)
133
154
  missing_packages = []
134
155
 
135
156
  manifest.packages.each do |p|
@@ -198,6 +219,17 @@ class Deb::S3::CLI < Thor
198
219
  AWS::S3::DEFAULT_HOST.replace options[:endpoint] if options[:endpoint]
199
220
 
200
221
  Deb::S3::Utils.bucket = options[:bucket]
201
- end
202
222
 
223
+ # make sure we have a valid visibility setting
224
+ Deb::S3::Utils.access_policy = case options[:visibility]
225
+ when "public"
226
+ :public_read
227
+ when "private"
228
+ :private
229
+ when "authenticated"
230
+ :authenticated_read
231
+ else
232
+ error("Invalid visibility setting given. Can be public, private, or authenticated.")
233
+ end
234
+ end
203
235
  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.0
4
+ version: 0.5.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-06-27 00:00:00.000000000 Z
12
+ date: 2013-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor