packaging 0.108.1 → 0.108.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/packaging/rpm/repo.rb +26 -8
- data/lib/packaging/sign/rpm.rb +8 -6
- data/spec/lib/packaging/rpm/repo_spec.rb +129 -72
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3fd1a48b6b204c719549f2d857edefc600eb504da996e5ec68c0298a11734c0
|
4
|
+
data.tar.gz: 2ccdf98e53f9cea5aaa92346517679e5c468bcc32f6ed6f81c22144906f8b1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef6517a8347b83b2adbe306302a4a6274a8854731b582f3ec0a1d1a7f6066e7655ad7bf953c40db9cdf359346068a4ebe4e0ebd9cb1cfac733533a1a7c27fe5f
|
7
|
+
data.tar.gz: e359e1e2c06be60e2cb668c2dd478cad89321e8bde6718968d697829dd6987d7800dde683c17325eb1c3be21470d8de497711da9f0610995ac7ea1aecde12697
|
data/lib/packaging/rpm/repo.rb
CHANGED
@@ -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(
|
12
|
-
|
13
|
-
|
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(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
|
data/lib/packaging/sign/rpm.rb
CHANGED
@@ -86,11 +86,14 @@ module Pkg::Sign::Rpm
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def passphrase_fd_flag
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
4
|
-
let(:wget) {
|
5
|
-
let(:builds_server) {
|
6
|
-
let(:project) {
|
7
|
-
let(:ref) {
|
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) { [
|
10
|
-
let(:wget_results)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
let(:wget_garbage)
|
17
|
-
let(:repo_configs)
|
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
|
38
|
-
it
|
39
|
-
Pkg::Util::Tool
|
40
|
-
|
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
|
44
|
-
Pkg::Util::Tool
|
45
|
-
|
46
|
-
|
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
|
51
|
-
Pkg::Util::Tool
|
52
|
-
|
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
|
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.
|
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.
|
61
|
-
Pkg::Platforms.
|
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.
|
64
|
-
config[i].
|
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
|
71
|
-
it
|
72
|
-
Pkg::Util::Tool
|
73
|
-
|
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
|
77
|
-
Pkg::Util::Tool
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
85
|
-
let(:command) {
|
86
|
-
let(:target_directory) {
|
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
|
89
|
-
Pkg::Rpm::Repo
|
90
|
-
|
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
|
96
|
-
let(:command) {
|
97
|
-
let(:artifact_directory) {
|
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
|
101
|
-
File.
|
102
|
-
Pkg::Repo.
|
103
|
-
Pkg::Repo.
|
104
|
-
Pkg::Rpm::Repo.
|
105
|
-
Pkg::Util::Net
|
106
|
-
|
107
|
-
|
108
|
-
Pkg::
|
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
|
114
|
-
it
|
115
|
-
Pkg::
|
116
|
-
|
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
|
121
|
-
Pkg::Config.jenkins_repo_path =
|
122
|
-
Pkg::Config.project =
|
123
|
-
Pkg::Config.ref =
|
124
|
-
Pkg::Config.distribution_server =
|
125
|
-
repo_dir =
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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.
|
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-
|
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/
|
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/
|
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/
|
311
|
-
- spec/lib/packaging/
|
312
|
-
- spec/lib/packaging/util/
|
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/
|
314
|
+
- spec/lib/packaging/util/version_spec.rb
|
320
315
|
- spec/lib/packaging/util/misc_spec.rb
|
321
|
-
- spec/lib/packaging/util/
|
322
|
-
- spec/lib/packaging/
|
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
|