right_publish 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,7 +14,9 @@ repositories.
14
14
  == Interface
15
15
 
16
16
  RightPublish is used as a command line tool and controlled via command line options
17
- and a YAML configuration file known as a RightPublish <i>profile</i>.
17
+ and a YAML configuration file known as a RightPublish <i>profile</i>. It expects
18
+ createrepo to be installed on yum based distros and reprepro to be installed on
19
+ debian distros. It expects the "expect" package to be installed on all distros.
18
20
 
19
21
  === Profile Format
20
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/expect --
2
+
3
+ set pass $env(GPG_PASSWORD)
4
+
5
+ set badpass 0
6
+ set timeout 5
7
+ set count 5;
8
+ eval spawn $argv
9
+ # Apt asks for your passphrase twice, hence the loop
10
+ while {$count > 0 } {
11
+ expect {
12
+ "phrase:" {
13
+ send "$pass\r"
14
+ }
15
+ "Bad passphrase" {
16
+ # CentOS/RHEL case
17
+ set badpass 1
18
+ }
19
+ "again:" {
20
+ # Ubuntu case, it reprompts. Keep sending till it runs out of retries
21
+ # else we'll corrupt the db when we exit easrly
22
+ send "$pass\r"
23
+ set badpass 1
24
+ }
25
+ eof {
26
+ if {$badpass == 1} {
27
+ puts "Failure! Bad Passphrase!"
28
+ exit 1
29
+ } else {
30
+ puts "Success!"
31
+ exit 0
32
+ }
33
+ }
34
+ timeout {
35
+ puts "\nTimeout failure. For Apt, repo DB may be locked/corrupted and need to be refetch manually"
36
+ exit 1
37
+ }
38
+ }
39
+ set count [expr $count-1];
40
+ }
41
+
42
+ puts "Failed to sign package after 5 attempts"
43
+ exit 1
@@ -1,7 +1,5 @@
1
1
  require 'right_publish/profile'
2
2
  require 'right_publish/storage'
3
- require 'pty'
4
- require 'expect'
5
3
 
6
4
  module RightPublish
7
5
 
@@ -105,23 +103,16 @@ module RightPublish
105
103
  # For automation, we want to send the password, however gpg uses getpass
106
104
  # c function, which interacts directly with /dev/pty instead of stdin/stdout
107
105
  # to hide the password as its typed in. So, we need to allocate a pty.
106
+ # We do this by shelling out to expect script (tcl based). Ruby 1.8
107
+ # implementation of "expect" is broken and has some race conditions with
108
+ # waiting for a child processes to exist, so don't use that.
108
109
  def shellout_with_password(cmd)
109
110
  password = repo_config[:gpg_password]
110
111
  raise Exception, ":gpg_password must be supplied when signing packages" unless password
111
-
112
- begin
113
- PTY.spawn(cmd) do |stdin,stdout,pid|
114
- while output = stdin.expect(/pass.?phrase/i, 2)
115
- stdout.puts(password)
116
- Profile.log(output, :debug)
117
- end
118
- Process.wait(pid)
119
- end
120
- status = $?
121
- rescue PTY::ChildExited => e
122
- status = e.status
123
- end
124
- return status.success?
112
+ ENV['GPG_PASSWORD'] = password
113
+ bin_dir = File.expand_path("../../../bin", __FILE__)
114
+ autosign = File.join(bin_dir, "autosign.expect")
115
+ system("#{autosign} #{cmd}")
125
116
  end
126
117
 
127
118
  def get_storage(provider)
@@ -8,12 +8,12 @@ module RightPublish
8
8
  REPO_KEY = :apt_repo
9
9
 
10
10
  REPO_OPTIONS = {
11
- :dists=>:addr_optional,
11
+ :dists => :addr_optional,
12
12
  :description => DEFAULT_DESCRIPTION,
13
- :auto=>DEFAULT_APT_AUTO,
14
- :subdir=>DEFAULT_APT_DIR,
15
- :gpg_key_id => :attr_optional,
16
- :gpg_password => :attr_optional }
13
+ :auto => DEFAULT_APT_AUTO,
14
+ :subdir => DEFAULT_APT_DIR,
15
+ :gpg_key_id => :attr_optional,
16
+ :gpg_password => :attr_optional }
17
17
 
18
18
  BIN_EXTENSION = 'deb'
19
19
  SRC_EXTENSION = 'dsc'
@@ -87,7 +87,7 @@ module RightPublish
87
87
  targets.each do |t|
88
88
  sub_command = (pkg.end_with?(BIN_EXTENSION) && 'includedeb') || 'includedsc'
89
89
  ask_passphrase = (repo_config[:gpg_key_id]) ? "--ask-passphrase " : ""
90
- cmd = "reprepro #{ask_passphrase}-C main -b #{repo_path} #{sub_command} #{t} #{pkg} 2>&1 >/dev/null"
90
+ cmd = "reprepro #{ask_passphrase}-C main -b #{repo_path} #{sub_command} #{t} #{pkg}"
91
91
  if repo_config[:gpg_key_id]
92
92
  exited = shellout_with_password(cmd)
93
93
  else
@@ -106,7 +106,7 @@ module RightPublish
106
106
  targets = (target && Array(target)) || repo_config[:dists]
107
107
  targets.each do |t|
108
108
  ask_passphrase = (repo_config[:gpg_key_id]) ? "--ask-passphrase" : ""
109
- cmd = "reprepro #{ask_passphrase} -b #{repo_path} #{sub_command} #{t} #{pkg_name} 2>&1 >/dev/null"
109
+ cmd = "reprepro #{ask_passphrase} -b #{repo_path} #{sub_command} #{t} #{pkg_name}"
110
110
  if repo_config[:gpg_key_id]
111
111
  exited = shellout_with_password(cmd)
112
112
  else
@@ -71,7 +71,7 @@ module RightPublish
71
71
  if repo_config[:gpg_key_id]
72
72
  do_in_subdir('') do
73
73
 
74
- cmd = "rpm --define '%_gpg_name #{repo_config[:gpg_key_id]}' --addsign #{pkgs.join(' ')} 2>&1 >/dev/null"
74
+ cmd = "rpm --define '%_gpg_name #{repo_config[:gpg_key_id]}' --addsign #{pkgs.join(' ')}"
75
75
  exited = shellout_with_password(cmd)
76
76
 
77
77
  raise Exception, "rpm signing failed; cannot continue publishing" unless exited
@@ -148,6 +148,14 @@ module RightPublish
148
148
  do_in_subdir(repo_path) do
149
149
  exit_val = system('createrepo --update -o $(pwd) $(pwd) 2>&1 >/dev/null')
150
150
  raise Exception, "yum regen_metadata failed; cannot continue publishing" unless exit_val
151
+
152
+ if repo_config[:gpg_key_id]
153
+ File.unlink("repodata/repomd.xml.asc") if File.exists?("repodata/repomd.xml.asc")
154
+ exit_val = system("gpg -a --batch --passphrase '#{repo_config[:gpg_password]}' --detach-sign repodata/repomd.xml")
155
+ raise Exception, "signing of repodata.xml failed; cannot continue publishing" unless exit_val
156
+ exit_val = system("gpg -a --export '#{repo_config[:gpg_key_id]}' > repodata/repomd.xml.key")
157
+ raise Exception, "exporting gpg public key failed; cannot continue publishing" unless exit_val
158
+ end
151
159
  end
152
160
  end
153
161
 
@@ -4,16 +4,15 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{right_publish}
8
- s.version = "0.2.0"
7
+ s.name = "right_publish"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Szmyd", "Tony Spataro"]
12
- s.date = %q{2013-07-03}
13
- s.default_executable = %q{right_publish}
14
- s.description = %q{A tool for maintaining S3-based DEB, GEM and RPM packages.}
15
- s.email = %q{support@rightscale.com}
16
- s.executables = ["right_publish"]
12
+ s.date = "2013-07-24"
13
+ s.description = "A tool for maintaining S3-based DEB, GEM and RPM packages."
14
+ s.email = "support@rightscale.com"
15
+ s.executables = ["autosign.expect", "right_publish"]
17
16
  s.extra_rdoc_files = [
18
17
  "README.rdoc"
19
18
  ]
@@ -24,6 +23,7 @@ Gem::Specification.new do |s|
24
23
  "README.rdoc",
25
24
  "Rakefile",
26
25
  "VERSION",
26
+ "bin/autosign.expect",
27
27
  "bin/right_publish",
28
28
  "lib/right_publish.rb",
29
29
  "lib/right_publish/profile.rb",
@@ -46,14 +46,13 @@ Gem::Specification.new do |s|
46
46
  "spec/stores/local_spec.rb",
47
47
  "spec/stores/s3_spec.rb"
48
48
  ]
49
- s.homepage = %q{https://github.com/rightscale/right_publish}
49
+ s.homepage = "https://github.com/rightscale/right_publish"
50
50
  s.licenses = ["Proprietary"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.7}
53
- s.summary = %q{Package publishing and indexing tool}
52
+ s.rubygems_version = "1.8.15"
53
+ s.summary = "Package publishing and indexing tool"
54
54
 
55
55
  if s.respond_to? :specification_version then
56
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
56
  s.specification_version = 3
58
57
 
59
58
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -47,7 +47,7 @@ describe RightPublish::AptRepo do
47
47
 
48
48
  system_calls = (pkgs.size * expected_dists.size) * 2
49
49
  @repo.should_receive(@system_func).times(system_calls).and_return do |cmd|
50
- path, subcmd, distro, pkg = /reprepro\s+(?:--ask-passphrase )?(?:-C main )?-b\s+(.+)\s+(includedeb|includedsc|removesrc|remove)\s+([^\s]+)\s+([^\s]+)\s+2>&1 >\/dev\/null\Z/.match(cmd).captures
50
+ path, subcmd, distro, pkg = /reprepro\s+(?:--ask-passphrase )?(?:-C main )?-b\s+(.+)\s+(includedeb|includedsc|removesrc|remove)\s+([^\s]+)\s+([^\s]+)/.match(cmd).captures
51
51
  path.should be_eql(File.join(@cache_dir,@repo_subdir))
52
52
 
53
53
  if @remove_expectations.has_key?(distro) && @remove_expectations[distro].include?(pkg)
@@ -67,6 +67,7 @@ describe RightPublish::YumRepo do
67
67
  @install_expectations.delete(dir) if @install_expectations[dir].empty?
68
68
  end
69
69
  system_calls = @install_expectations.size
70
+ system_calls *= 3 if @profile.config[:yum_repo][:gpg_key_id]
70
71
  system_sign_calls = (@profile.config[:yum_repo][:gpg_key_id]) ? 1 : 0
71
72
  @repo.should_receive(:system).times(system_calls).and_return(0)
72
73
  @repo.should_receive(:shellout_with_password).times(system_sign_calls).and_return(0)
@@ -205,6 +206,7 @@ describe RightPublish::YumRepo do
205
206
  @install_expectations.delete(pkg)
206
207
  end
207
208
  system_calls = 1
209
+ system_calls *= 3 if @profile.config[:yum_repo][:gpg_key_id]
208
210
  system_sign_calls = (@profile.config[:yum_repo][:gpg_key_id]) ? 1 : 0
209
211
  @repo.should_receive(:system).times(system_calls).and_return(0)
210
212
  @repo.should_receive(:shellout_with_password).times(system_sign_calls).and_return(0)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_publish
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Szmyd
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-07-03 00:00:00 -07:00
20
- default_executable: right_publish
19
+ date: 2013-07-24 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -29,10 +28,10 @@ dependencies:
29
28
  segments:
30
29
  - 0
31
30
  version: "0"
32
- requirement: *id001
33
31
  type: :runtime
34
- name: builder
32
+ requirement: *id001
35
33
  prerelease: false
34
+ name: builder
36
35
  - !ruby/object:Gem::Dependency
37
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
37
  none: false
@@ -44,10 +43,10 @@ dependencies:
44
43
  - 1
45
44
  - 9
46
45
  version: "1.9"
47
- requirement: *id002
48
46
  type: :runtime
49
- name: fog
47
+ requirement: *id002
50
48
  prerelease: false
49
+ name: fog
51
50
  - !ruby/object:Gem::Dependency
52
51
  version_requirements: &id003 !ruby/object:Gem::Requirement
53
52
  none: false
@@ -59,10 +58,10 @@ dependencies:
59
58
  - 2
60
59
  - 0
61
60
  version: "2.0"
62
- requirement: *id003
63
61
  type: :runtime
64
- name: trollop
62
+ requirement: *id003
65
63
  prerelease: false
64
+ name: trollop
66
65
  - !ruby/object:Gem::Dependency
67
66
  version_requirements: &id004 !ruby/object:Gem::Requirement
68
67
  none: false
@@ -74,10 +73,10 @@ dependencies:
74
73
  - 0
75
74
  - 9
76
75
  version: "0.9"
77
- requirement: *id004
78
76
  type: :development
79
- name: rake
77
+ requirement: *id004
80
78
  prerelease: false
79
+ name: rake
81
80
  - !ruby/object:Gem::Dependency
82
81
  version_requirements: &id005 !ruby/object:Gem::Requirement
83
82
  none: false
@@ -90,10 +89,10 @@ dependencies:
90
89
  - 8
91
90
  - 3
92
91
  version: 1.8.3
93
- requirement: *id005
94
92
  type: :development
95
- name: jeweler
93
+ requirement: *id005
96
94
  prerelease: false
95
+ name: jeweler
97
96
  - !ruby/object:Gem::Dependency
98
97
  version_requirements: &id006 !ruby/object:Gem::Requirement
99
98
  none: false
@@ -105,10 +104,10 @@ dependencies:
105
104
  - 1
106
105
  - 0
107
106
  version: "1.0"
108
- requirement: *id006
109
107
  type: :development
110
- name: right_develop
108
+ requirement: *id006
111
109
  prerelease: false
110
+ name: right_develop
112
111
  - !ruby/object:Gem::Dependency
113
112
  version_requirements: &id007 !ruby/object:Gem::Requirement
114
113
  none: false
@@ -121,10 +120,10 @@ dependencies:
121
120
  - 4
122
121
  - 2
123
122
  version: 2.4.2
124
- requirement: *id007
125
123
  type: :development
126
- name: rdoc
124
+ requirement: *id007
127
125
  prerelease: false
126
+ name: rdoc
128
127
  - !ruby/object:Gem::Dependency
129
128
  version_requirements: &id008 !ruby/object:Gem::Requirement
130
129
  none: false
@@ -136,10 +135,10 @@ dependencies:
136
135
  - 2
137
136
  - 0
138
137
  version: "2.0"
139
- requirement: *id008
140
138
  type: :development
141
- name: rspec
139
+ requirement: *id008
142
140
  prerelease: false
141
+ name: rspec
143
142
  - !ruby/object:Gem::Dependency
144
143
  version_requirements: &id009 !ruby/object:Gem::Requirement
145
144
  none: false
@@ -151,10 +150,10 @@ dependencies:
151
150
  - 0
152
151
  - 9
153
152
  version: "0.9"
154
- requirement: *id009
155
153
  type: :development
156
- name: flexmock
154
+ requirement: *id009
157
155
  prerelease: false
156
+ name: flexmock
158
157
  - !ruby/object:Gem::Dependency
159
158
  version_requirements: &id010 !ruby/object:Gem::Requirement
160
159
  none: false
@@ -165,10 +164,10 @@ dependencies:
165
164
  segments:
166
165
  - 0
167
166
  version: "0"
168
- requirement: *id010
169
167
  type: :development
170
- name: simplecov
168
+ requirement: *id010
171
169
  prerelease: false
170
+ name: simplecov
172
171
  - !ruby/object:Gem::Dependency
173
172
  version_requirements: &id011 !ruby/object:Gem::Requirement
174
173
  none: false
@@ -180,10 +179,10 @@ dependencies:
180
179
  - 0
181
180
  - 10
182
181
  version: "0.10"
183
- requirement: *id011
184
182
  type: :development
185
- name: ruby-debug
183
+ requirement: *id011
186
184
  prerelease: false
185
+ name: ruby-debug
187
186
  - !ruby/object:Gem::Dependency
188
187
  version_requirements: &id012 !ruby/object:Gem::Requirement
189
188
  none: false
@@ -196,13 +195,14 @@ dependencies:
196
195
  - 11
197
196
  - 6
198
197
  version: 0.11.6
199
- requirement: *id012
200
198
  type: :development
201
- name: ruby-debug19
199
+ requirement: *id012
202
200
  prerelease: false
201
+ name: ruby-debug19
203
202
  description: A tool for maintaining S3-based DEB, GEM and RPM packages.
204
203
  email: support@rightscale.com
205
204
  executables:
205
+ - autosign.expect
206
206
  - right_publish
207
207
  extensions: []
208
208
 
@@ -215,6 +215,7 @@ files:
215
215
  - README.rdoc
216
216
  - Rakefile
217
217
  - VERSION
218
+ - bin/autosign.expect
218
219
  - bin/right_publish
219
220
  - lib/right_publish.rb
220
221
  - lib/right_publish/profile.rb
@@ -236,7 +237,6 @@ files:
236
237
  - spec/storage_spec.rb
237
238
  - spec/stores/local_spec.rb
238
239
  - spec/stores/s3_spec.rb
239
- has_rdoc: true
240
240
  homepage: https://github.com/rightscale/right_publish
241
241
  licenses:
242
242
  - Proprietary
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  requirements: []
267
267
 
268
268
  rubyforge_project:
269
- rubygems_version: 1.3.7
269
+ rubygems_version: 1.8.15
270
270
  signing_key:
271
271
  specification_version: 3
272
272
  summary: Package publishing and indexing tool