packaging 0.108.1 → 0.108.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54d6abc8bcaa0d29d1580feff3d35577a3c49dc90721708623971cc189007f74
4
- data.tar.gz: 0643a3a7bd158d488ae66b2b245ad3a36ce59875a0d067f7e3d5a88f6a1a0f52
3
+ metadata.gz: f3fd1a48b6b204c719549f2d857edefc600eb504da996e5ec68c0298a11734c0
4
+ data.tar.gz: 2ccdf98e53f9cea5aaa92346517679e5c468bcc32f6ed6f81c22144906f8b1fe
5
5
  SHA512:
6
- metadata.gz: 0b095ae28da4b0843c4f15fa3e597ff18fe693d50556c89a246a735846be5608831fce42e4e44d34f794dc2f98b3db512e635bc74604a2df9fee9caa5e0e0079
7
- data.tar.gz: a1e5cc54bdfbd24e529e0b7c99a22675f7c4911cb2f59046ea8a0ac0aa147069a13185351fe0654bb5ba936af39e16fc8dd3435ea3f93e8199ab1d8fb5be022a
6
+ metadata.gz: ef6517a8347b83b2adbe306302a4a6274a8854731b582f3ec0a1d1a7f6066e7655ad7bf953c40db9cdf359346068a4ebe4e0ebd9cb1cfac733533a1a7c27fe5f
7
+ data.tar.gz: e359e1e2c06be60e2cb668c2dd478cad89321e8bde6718968d697829dd6987d7800dde683c17325eb1c3be21470d8de497711da9f0610995ac7ea1aecde12697
@@ -8,17 +8,35 @@ module Pkg::Rpm::Repo
8
8
  "http://#{Pkg::Config.builds_server}/#{Pkg::Config.project}/#{Pkg::Config.ref}"
9
9
  end
10
10
 
11
- def ship_repo_configs(target = "repo_configs")
12
- if Pkg::Util::File.empty_dir?("pkg/#{target}/rpm")
13
- warn "No repo configs have been generated! Try pl:rpm_repo_configs."
11
+ def ship_repo_configs(repo_configs_directory = 'repo_configs')
12
+ local_repos_path = File.join('pkg', repo_configs_directory, 'rpm')
13
+
14
+ remote_repos_path = File.join(
15
+ Pkg::Config.jenkins_repo_path,
16
+ Pkg::Config.project,
17
+ Pkg::Config.ref,
18
+ repo_configs_directory,
19
+ 'rpm'
20
+ )
21
+
22
+ if !Dir.exist?(local_repos_path) || Dir.empty?(local_repos_path)
23
+ warn "No repo_configs found in \"#{Dir.pwd}/#{local_repos_path}\". " \
24
+ 'Skipping repo shipping.'
14
25
  return
15
26
  end
16
27
 
17
- Pkg::Util::RakeUtils.invoke_task("pl:fetch")
18
- repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/#{target}/rpm"
19
- Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
20
- Pkg::Util::Execution.retry_on_fail(:times => 3) do
21
- Pkg::Util::Net.rsync_to("pkg/#{target}/rpm/", Pkg::Config.distribution_server, repo_dir)
28
+ Pkg::Util::RakeUtils.invoke_task('pl:fetch')
29
+ Pkg::Util::Net.remote_execute(
30
+ Pkg::Config.distribution_server,
31
+ "mkdir -p #{remote_repos_path}"
32
+ )
33
+
34
+ Pkg::Util::Execution.retry_on_fail(times: 3) do
35
+ Pkg::Util::Net.rsync_to(
36
+ "#{local_repos_path}/",
37
+ Pkg::Config.distribution_server,
38
+ remote_repos_path
39
+ )
22
40
  end
23
41
  end
24
42
 
@@ -86,11 +86,14 @@ module Pkg::Sign::Rpm
86
86
  end
87
87
 
88
88
  def passphrase_fd_flag
89
- if Pkg::Util.boolean_value(ENV['RPM_GPG_AGENT'])
90
- ''
91
- else
92
- '--passphrase-fd 3'
93
- end
89
+ # We use passphrase caching on GPG >= 2.1, so no passphrase-fd is needed.
90
+ return '' unless gpg_version_older_than_21?
91
+
92
+ # If the user has provided us their gpg agent setup, don't muck with it.
93
+ return '' if Pkg::Util.boolean_value(ENV['RPM_GPG_AGENT'])
94
+
95
+ # Assume our old setup where expect is providing input on fd 3
96
+ return '--passphrase-fd 3'
94
97
  end
95
98
 
96
99
  def define_gpg_check_password_cmd
@@ -101,7 +104,6 @@ module Pkg::Sign::Rpm
101
104
  end
102
105
  end
103
106
 
104
-
105
107
  def signed?(rpm)
106
108
  # This should allow the `Pkg::Util::Gpg.key` method to fail if gpg_key is
107
109
  # not set, before shelling out. We also only want the short key, all
@@ -1,20 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Rpm::Repo" do
4
- let(:wget) { "/opt/tools/bin/wget" }
5
- let(:builds_server) { "saturn.puppetlabs.net" }
6
- let(:project) { "rpm_repos" }
7
- let(:ref) { "1234abcd" }
3
+ describe 'Pkg::Rpm::Repo' do
4
+ let(:wget) { '/opt/tools/bin/wget' }
5
+ let(:builds_server) { 'saturn.puppetlabs.net' }
6
+ let(:project) { 'rpm_repos' }
7
+ let(:ref) { '1234abcd' }
8
8
  let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" }
9
- let(:mocks) { ["el-5-i386", "el-5-x86_64", "el-5-SRPMS"] }
10
- let(:wget_results) {
11
- mocks.map do |mock|
12
- dist, version, arch = mock.split('-')
13
- "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/"
14
- end.join("\n")
15
- }
16
- let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" }
17
- let(:repo_configs) { mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" } }
9
+ let(:mocks) { %w[el-5-i386 el-5-x86_64 el-5-SRPMS] }
10
+ let(:wget_results) do
11
+ mocks.map do |mock|
12
+ dist, version, arch = mock.split('-')
13
+ "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/"
14
+ end.join("\n")
15
+ end
16
+ let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" }
17
+ let(:repo_configs) do
18
+ mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" }
19
+ end
18
20
 
19
21
  # Setup and tear down for the tests
20
22
  around do |example|
@@ -34,99 +36,154 @@ describe "Pkg::Rpm::Repo" do
34
36
  Pkg::Config.jenkins_repo_path = orig_repo_path
35
37
  end
36
38
 
37
- describe "#generate_repo_configs" do
38
- it "fails if wget isn't available" do
39
- Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
40
- expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
39
+ describe '#generate_repo_configs' do
40
+ it 'fails if wget isn\'t available' do
41
+ allow(Pkg::Util::Tool)
42
+ .to receive(:find_tool)
43
+ .with('wget', { required: true })
44
+ .and_return(false)
45
+ expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError)
41
46
  end
42
47
 
43
- it "warns if there are no rpm repos available for the build" do
44
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
45
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return("")
46
- Pkg::Rpm::Repo.should_receive(:warn).with("No rpm repos were found to generate configs from!")
48
+ it 'warns if there are no rpm repos available for the build' do
49
+ expect(Pkg::Util::Tool)
50
+ .to receive(:find_tool)
51
+ .with('wget', { required: true })
52
+ .and_return(wget)
53
+ expect(Pkg::Util::Execution)
54
+ .to receive(:capture3)
55
+ .with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1")
56
+ .and_return('')
57
+ expect(Pkg::Rpm::Repo)
58
+ .to receive(:warn)
59
+ .with("No rpm repos were found to generate configs from!")
47
60
  Pkg::Rpm::Repo.generate_repo_configs
48
61
  end
49
62
 
50
- it "writes the expected repo configs to disk" do
51
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
52
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return(wget_results + wget_garbage)
63
+ it 'writes the expected repo configs to disk' do
64
+ expect(Pkg::Util::Tool)
65
+ .to receive(:find_tool)
66
+ .with("wget", { required: true })
67
+ .and_return(wget)
68
+ expect(Pkg::Util::Execution)
69
+ .to receive(:capture3)
70
+ .with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1")
71
+ .and_return(wget_results + wget_garbage)
53
72
  wget_results.split.each do |result|
54
73
  cur_result = result.chomp('repodata/')
55
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1").and_return("#{cur_result}/thing.rpm")
74
+ expect(Pkg::Util::Execution)
75
+ .to receive(:capture3)
76
+ .with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1")
77
+ .and_return("#{cur_result}/thing.rpm")
56
78
  end
57
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs/rpm")
79
+ expect(FileUtils).to receive(:mkdir_p).with('pkg/repo_configs/rpm')
58
80
  config = []
59
81
  repo_configs.each_with_index do |repo_config, i|
60
- Pkg::Paths.should_receive(:tag_from_artifact_path).and_return(mocks[i])
61
- Pkg::Platforms.should_receive(:parse_platform_tag).and_return(mocks[i].split('-'))
82
+ expect(Pkg::Paths).to receive(:tag_from_artifact_path).and_return(mocks[i])
83
+ expect(Pkg::Platforms).to receive(:parse_platform_tag).and_return(mocks[i].split('-'))
62
84
  config[i] = double(File)
63
- File.should_receive(:open).with(repo_config, 'w').and_yield(config[i])
64
- config[i].should_receive(:puts)
85
+ expect(File).to receive(:open).with(repo_config, 'w').and_yield(config[i])
86
+ expect(config[i]).to receive(:puts)
65
87
  end
66
88
  Pkg::Rpm::Repo.generate_repo_configs
67
89
  end
68
90
  end
69
91
 
70
- describe "#retrieve_repo_configs" do
71
- it "fails if wget isn't available" do
72
- Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
73
- expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
92
+ describe '#retrieve_repo_configs' do
93
+ it 'fails if wget isn\'t available' do
94
+ allow(Pkg::Util::Tool)
95
+ .to receive(:find_tool)
96
+ .with('wget', { required: true })
97
+ .and_return(false)
98
+ expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError)
74
99
  end
75
100
 
76
- it "fails if there are no deb repos available for the build" do
77
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
78
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true)
79
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/").and_raise(RuntimeError)
80
- expect {Pkg::Rpm::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/)
101
+ it 'fails if there are no deb repos available for the build' do
102
+ expect(Pkg::Util::Tool)
103
+ .to receive(:find_tool)
104
+ .with('wget', { required: true })
105
+ .and_return(wget)
106
+ expect(FileUtils)
107
+ .to receive(:mkdir_p)
108
+ .with('pkg/repo_configs')
109
+ .and_return(true)
110
+ expect(Pkg::Util::Execution)
111
+ .to receive(:capture3)
112
+ .with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/")
113
+ .and_raise(RuntimeError)
114
+ expect { Pkg::Rpm::Repo.retrieve_repo_configs }
115
+ .to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/)
81
116
  end
82
117
  end
83
118
 
84
- describe "#create_local_repos" do
85
- let(:command) { "/usr/bin/make some repos" }
86
- let(:target_directory) { "/tmp/dir/thing" }
119
+ describe '#create_local_repos' do
120
+ let(:command) { '/usr/bin/make some repos' }
121
+ let(:target_directory) { '/tmp/dir/thing' }
87
122
 
88
- it "makes a repo in the target directory" do
89
- Pkg::Rpm::Repo.should_receive(:repo_creation_command).with(target_directory).and_return("run this thing")
90
- Pkg::Util::Execution.should_receive(:capture3).with("bash -c 'run this thing'")
123
+ it 'makes a repo in the target directory' do
124
+ expect(Pkg::Rpm::Repo)
125
+ .to receive(:repo_creation_command)
126
+ .with(target_directory)
127
+ .and_return("run this thing")
128
+ expect(Pkg::Util::Execution)
129
+ .to receive(:capture3)
130
+ .with("bash -c 'run this thing'")
91
131
  Pkg::Rpm::Repo.create_local_repos(target_directory)
92
132
  end
93
133
  end
94
134
 
95
- describe "#create_remote_repos" do
96
- let(:command) { "/usr/bin/make some repos" }
97
- let(:artifact_directory) { "/tmp/dir/thing" }
135
+ describe '#create_remote_repos' do
136
+ let(:command) { '/usr/bin/make some repos' }
137
+ let(:artifact_directory) { '/tmp/dir/thing' }
98
138
  let(:pkg_directories) { ['el-6-i386', 'el/7/x86_64'] }
99
139
 
100
- it "makes a repo in the target directory" do
101
- File.stub(:join) {artifact_directory}
102
- Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories)
103
- Pkg::Repo.should_receive(:populate_repo_directory)
104
- Pkg::Rpm::Repo.should_receive(:repo_creation_command).and_return(command)
105
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command)
106
- Pkg::Rpm::Repo.should_receive(:generate_repo_configs)
107
- Pkg::Rpm::Repo.should_receive(:ship_repo_configs)
108
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
140
+ it 'makes a repo in the target directory' do
141
+ allow(File).to receive(:join).and_return(artifact_directory)
142
+ expect(Pkg::Repo).to receive(:directories_that_contain_packages).and_return(pkg_directories)
143
+ expect(Pkg::Repo).to receive(:populate_repo_directory)
144
+ expect(Pkg::Rpm::Repo).to receive(:repo_creation_command).and_return(command)
145
+ expect(Pkg::Util::Net)
146
+ .to receive(:remote_execute)
147
+ .with(Pkg::Config.distribution_server, command)
148
+ expect(Pkg::Rpm::Repo).to receive(:generate_repo_configs)
149
+ expect(Pkg::Rpm::Repo).to receive(:ship_repo_configs)
150
+ expect(Pkg::Util::Net)
151
+ .to receive(:remote_execute)
152
+ .with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock")
109
153
  Pkg::Rpm::Repo.create_remote_repos
110
154
  end
111
155
  end
112
156
 
113
- describe "#ship_repo_configs" do
114
- it "warn if there are no repo configs to ship" do
115
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(true)
116
- Pkg::Rpm::Repo.should_receive(:warn).with("No repo configs have been generated! Try pl:rpm_repo_configs.")
157
+ describe '#ship_repo_configs' do
158
+ it 'warn if there are no repo configs to ship' do
159
+ Pkg::Config.jenkins_repo_path = '/a/b/c/d'
160
+ expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(false)
161
+ expect(Pkg::Rpm::Repo).to receive(:warn)
162
+ expect(Pkg::Util::RakeUtils).not_to receive(:invoke_task)
117
163
  Pkg::Rpm::Repo.ship_repo_configs
118
164
  end
119
165
 
120
- it "ships repo configs to the build server" do
121
- Pkg::Config.jenkins_repo_path = "/a/b/c/d"
122
- Pkg::Config.project = "thing2"
123
- Pkg::Config.ref = "abcd1234"
124
- Pkg::Config.distribution_server = "a.host.that.wont.exist"
125
- repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/rpm"
126
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(false)
127
- Pkg::Util::RakeUtils.should_receive(:invoke_task).with("pl:fetch")
128
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
129
- Pkg::Util::Execution.should_receive(:retry_on_fail).with(:times => 3)
166
+ it 'ships repo configs to the build server' do
167
+ Pkg::Config.jenkins_repo_path = '/a/b/c/d'
168
+ Pkg::Config.project = 'thing2'
169
+ Pkg::Config.ref = 'abcd1234'
170
+ Pkg::Config.distribution_server = 'a.host.that.wont.exist'
171
+ repo_dir = File.join(
172
+ Pkg::Config.jenkins_repo_path,
173
+ Pkg::Config.project,
174
+ Pkg::Config.ref,
175
+ 'repo_configs',
176
+ 'rpm'
177
+ )
178
+ expect(Dir).to receive(:exist?).with('pkg/repo_configs/rpm').and_return(true)
179
+ expect(Dir).to receive(:empty?).with('pkg/repo_configs/rpm').and_return(false)
180
+ expect(Pkg::Util::RakeUtils).to receive(:invoke_task).with('pl:fetch')
181
+ expect(Pkg::Util::Net)
182
+ .to receive(:remote_execute)
183
+ .with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
184
+ expect(Pkg::Util::Net)
185
+ .to receive(:rsync_to)
186
+ .with('pkg/repo_configs/rpm/', Pkg::Config.distribution_server, repo_dir)
130
187
  Pkg::Rpm::Repo.ship_repo_configs
131
188
  end
132
189
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.108.1
4
+ version: 0.108.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -295,28 +295,28 @@ signing_key:
295
295
  specification_version: 4
296
296
  summary: Puppet Labs' packaging automation
297
297
  test_files:
298
- - spec/lib/packaging_spec.rb
299
- - spec/lib/packaging/sign_spec.rb
300
- - spec/lib/packaging/artifactory_spec.rb
301
- - spec/lib/packaging/retrieve_spec.rb
302
298
  - spec/lib/packaging/config_spec.rb
303
- - spec/lib/packaging/rpm/repo_spec.rb
304
- - spec/lib/packaging/deb_spec.rb
305
- - spec/lib/packaging/repo_spec.rb
299
+ - spec/lib/packaging/platforms_spec.rb
306
300
  - spec/lib/packaging/gem_spec.rb
307
- - spec/lib/packaging/deb/repo_spec.rb
308
- - spec/lib/packaging/tar_spec.rb
301
+ - spec/lib/packaging/sign_spec.rb
309
302
  - spec/lib/packaging/paths_spec.rb
310
- - spec/lib/packaging/platforms_spec.rb
311
- - spec/lib/packaging/util/jenkins_spec.rb
312
- - spec/lib/packaging/util/ship_spec.rb
313
- - spec/lib/packaging/util/version_spec.rb
303
+ - spec/lib/packaging/deb/repo_spec.rb
304
+ - spec/lib/packaging/rpm/repo_spec.rb
305
+ - spec/lib/packaging/util/git_spec.rb
314
306
  - spec/lib/packaging/util/os_spec.rb
307
+ - spec/lib/packaging/util/gpg_spec.rb
308
+ - spec/lib/packaging/util/execution_spec.rb
315
309
  - spec/lib/packaging/util/git_tag_spec.rb
310
+ - spec/lib/packaging/util/net_spec.rb
311
+ - spec/lib/packaging/util/ship_spec.rb
316
312
  - spec/lib/packaging/util/rake_utils_spec.rb
317
- - spec/lib/packaging/util/gpg_spec.rb
318
313
  - spec/lib/packaging/util/file_spec.rb
319
- - spec/lib/packaging/util/net_spec.rb
314
+ - spec/lib/packaging/util/version_spec.rb
320
315
  - spec/lib/packaging/util/misc_spec.rb
321
- - spec/lib/packaging/util/execution_spec.rb
322
- - spec/lib/packaging/util/git_spec.rb
316
+ - spec/lib/packaging/util/jenkins_spec.rb
317
+ - spec/lib/packaging/deb_spec.rb
318
+ - spec/lib/packaging/tar_spec.rb
319
+ - spec/lib/packaging/repo_spec.rb
320
+ - spec/lib/packaging/artifactory_spec.rb
321
+ - spec/lib/packaging/retrieve_spec.rb
322
+ - spec/lib/packaging_spec.rb