packaging 0.99.70 → 0.99.75
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 +4 -4
- data/lib/packaging/config/params.rb +1 -0
- data/lib/packaging/gem.rb +14 -10
- data/lib/packaging/paths.rb +54 -10
- data/lib/packaging/platforms.rb +1 -1
- data/lib/packaging/util/git.rb +1 -1
- data/lib/packaging/util/net.rb +1 -1
- data/lib/packaging/util/ship.rb +20 -5
- data/spec/lib/packaging/paths_spec.rb +233 -114
- data/spec/lib/packaging/util/ship_spec.rb +142 -72
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4eba143d4627b1c6ce1eb694894a79987fb4c9eb169a8de3dfe756c037f2cfd
|
4
|
+
data.tar.gz: fc772076ec4a28f57e2a99afb51a29ecba0d20b6b0eea0d32d16f43575f8c8d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e6b6a56070e12ea898725f030d2cf95b6e04f6ac329f6dab38a20ab9aa765a3a7667f6967373dbde8cf8686403784ad9ca4e49bc83923e260a7c9517e457329
|
7
|
+
data.tar.gz: 5a3cadefed6983b5bcacf0f2abb117b8f2c5aa829dc8567a041b4e4b679d1489d8a2badb80a1c7c1b0a51cbda94ad07d8f00d9378dcaca9ab02b4cd831aeab2f
|
@@ -298,6 +298,7 @@ module Pkg::Params
|
|
298
298
|
{ :var => :team, :envvar => :TEAM },
|
299
299
|
{ :var => :update_version_file, :envvar => :NEW_STYLE_PACKAGE },
|
300
300
|
{ :var => :vanagon_project, :envvar => :VANAGON_PROJECT, :type => :bool },
|
301
|
+
{ :var => :version, :envvar => :PACKAGING_PACKAGE_VERSION },
|
301
302
|
{ :var => :yum_archive_path, :envvar => :YUM_ARCHIVE_PATH },
|
302
303
|
{ :var => :yum_host, :envvar => :YUM_HOST },
|
303
304
|
{ :var => :yum_repo_path, :envvar => :YUM_REPO },
|
data/lib/packaging/gem.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
module Pkg::Gem
|
3
3
|
class << self
|
4
|
-
# This is preserved because I don't want to update the deprecated code path
|
5
|
-
# yet; I'm not entirely sure I've fixed everything that might attempt
|
6
|
-
# to call this method so this is now a wrapper for a wrapper.
|
7
4
|
def ship(file)
|
8
5
|
rsync_to_downloads(file)
|
9
6
|
ship_to_rubygems(file)
|
@@ -13,17 +10,21 @@ module Pkg::Gem
|
|
13
10
|
# checksums, or other glob-able artifacts to an external download server.
|
14
11
|
def rsync_to_downloads(file)
|
15
12
|
Pkg::Util.deprecate('Pkg::Gem.rsync_to_downloads', 'Pkg::Util::Ship.ship_pkgs')
|
16
|
-
Pkg::Util::Ship.ship_pkgs(["#{file}*"], Pkg::Config.gem_host,
|
13
|
+
Pkg::Util::Ship.ship_pkgs(["#{file}*"], Pkg::Config.gem_host,
|
14
|
+
Pkg::Config.gem_path, platform_independent: true)
|
17
15
|
end
|
18
16
|
|
19
17
|
def shipped_to_rubygems?(gem_name, gem_version, gem_platform)
|
20
|
-
|
21
|
-
|
18
|
+
rubygems_url = "https://rubygems.org/api/v1/versions/#{gem_name}.json"
|
19
|
+
gem_data = JSON.parse(%x(curl --silent #{rubygems_url}))
|
20
|
+
gem = gem_data.select do |data|
|
21
|
+
data['number'] == gem_version && data['platform'] == gem_platform
|
22
|
+
end
|
22
23
|
return !gem.empty?
|
23
24
|
rescue => e
|
24
|
-
puts "
|
25
|
+
puts "Something went wrong searching for gem '#{gem_name}':"
|
25
26
|
puts e
|
26
|
-
puts "Perhaps you're shipping
|
27
|
+
puts "Perhaps you're shipping '#{gem_name}' for the first time?"
|
27
28
|
return false
|
28
29
|
end
|
29
30
|
|
@@ -40,7 +41,7 @@ module Pkg::Gem
|
|
40
41
|
gem_platform ||= 'ruby'
|
41
42
|
|
42
43
|
if shipped_to_rubygems?(Pkg::Config.gem_name, Pkg::Config.gemversion, gem_platform)
|
43
|
-
puts "#{file} has already been shipped to rubygems, skipping
|
44
|
+
puts "#{file} has already been shipped to rubygems, skipping."
|
44
45
|
return
|
45
46
|
end
|
46
47
|
Pkg::Util::File.file_exists?("#{ENV['HOME']}/.gem/credentials", :required => true)
|
@@ -60,7 +61,10 @@ module Pkg::Gem
|
|
60
61
|
|
61
62
|
def ship_to_internal_mirror(file)
|
62
63
|
internal_mirror_api_key_name = 'artifactory_api_key'
|
63
|
-
ship_to_rubygems(file, {
|
64
|
+
ship_to_rubygems(file, {
|
65
|
+
host: Pkg::Config.internal_gem_host,
|
66
|
+
key: internal_mirror_api_key_name
|
67
|
+
})
|
64
68
|
end
|
65
69
|
end
|
66
70
|
end
|
data/lib/packaging/paths.rb
CHANGED
@@ -16,9 +16,9 @@ module Pkg::Paths
|
|
16
16
|
if source_formats.find { |fmt| path =~ /#{fmt}$/ }
|
17
17
|
return Pkg::Platforms.get_attribute_for_platform_version(platform, version, :source_architecture)
|
18
18
|
end
|
19
|
-
arches.find { |a| path.include?(a) } || arches[0]
|
19
|
+
arches.find { |a| path.include?(package_arch(platform, a)) } || arches[0]
|
20
20
|
rescue
|
21
|
-
arches.find { |a| path.include?(a) } || arches[0]
|
21
|
+
arches.find { |a| path.include?(package_arch(platform, a)) } || arches[0]
|
22
22
|
end
|
23
23
|
|
24
24
|
# Given a path to an artifact, divine the appropriate platform tag associated
|
@@ -109,9 +109,19 @@ module Pkg::Paths
|
|
109
109
|
platform_name = path_data[:platform_name]
|
110
110
|
platform_tag = path_data[:platform_tag]
|
111
111
|
|
112
|
+
repo_name = Pkg::Config.repo_name
|
113
|
+
|
112
114
|
case package_format
|
113
115
|
when 'deb'
|
114
116
|
debian_code_name = Pkg::Platforms.get_attribute(platform_tag, :codename)
|
117
|
+
|
118
|
+
# In puppet7 and beyond, we moved the repo_name to the top to allow each
|
119
|
+
# puppet major release to have its own apt repo.
|
120
|
+
if %w(FUTURE-puppet7 FUTURE-puppet7-nightly).include? repo_name
|
121
|
+
return File.join(prefix, apt_repo_name(is_nonfinal), debian_code_name)
|
122
|
+
end
|
123
|
+
|
124
|
+
# For puppet6 and prior
|
115
125
|
return File.join(prefix, debian_code_name, apt_repo_name(is_nonfinal))
|
116
126
|
when 'dmg'
|
117
127
|
return File.join(prefix, 'mac', repo_name(is_nonfinal))
|
@@ -292,30 +302,53 @@ module Pkg::Paths
|
|
292
302
|
|
293
303
|
# This is where deb packages end up after freight repo updates
|
294
304
|
def apt_package_base_path(platform_tag, repo_name, project, nonfinal = false)
|
295
|
-
|
305
|
+
unless Pkg::Platforms.package_format_for_tag(platform_tag) == 'deb'
|
306
|
+
fail "Can't determine path for non-debian platform #{platform_tag}."
|
307
|
+
end
|
308
|
+
|
296
309
|
platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag)
|
297
|
-
|
298
|
-
|
310
|
+
code_name = Pkg::Platforms.codename_for_platform_version(platform, version)
|
311
|
+
remote_repo_path = remote_repo_base(platform_tag, nonfinal: nonfinal)
|
312
|
+
|
313
|
+
# In puppet7 and beyond, we moved the puppet major version to near the top to allow each
|
314
|
+
# puppet major release to have its own apt repo, for example:
|
315
|
+
# /opt/repository/apt/puppet7/pool/bionic/p/puppet-agent
|
316
|
+
if %w(FUTURE-puppet7 FUTURE-puppet7-nightly).include? repo_name
|
317
|
+
return File.join(remote_repo_path, repo_name, 'pool', code_name, project[0], project)
|
318
|
+
end
|
319
|
+
|
320
|
+
# For repos prior to puppet7, the puppet version was part of the repository
|
321
|
+
# For example: /opt/repository/apt/pool/bionic/puppet6/p/puppet-agent
|
322
|
+
if %w(puppet7 puppet7-nightly
|
323
|
+
puppet6 puppet6-nightly
|
324
|
+
puppet5 puppet5-nightly
|
325
|
+
puppet).include? repo_name
|
326
|
+
return File.join(remote_repo_path, 'pool', code_name, repo_name, project[0], project)
|
327
|
+
end
|
328
|
+
|
329
|
+
raise "Error: Cannot determine apt_package_base_path for repo: \"#{repo_name}\"."
|
299
330
|
end
|
300
331
|
|
301
332
|
def release_package_link_path(platform_tag, nonfinal = false)
|
302
|
-
platform, version,
|
333
|
+
platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag)
|
303
334
|
package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
|
304
335
|
case package_format
|
305
336
|
when 'rpm'
|
306
|
-
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
|
337
|
+
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
|
338
|
+
"#{repo_name(nonfinal)}-release-#{platform}-#{version}.noarch.rpm")
|
307
339
|
when 'deb'
|
308
340
|
codename = Pkg::Platforms.codename_for_platform_version(platform, version)
|
309
|
-
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
|
341
|
+
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
|
342
|
+
"#{repo_name(nonfinal)}-release-#{codename}.deb")
|
310
343
|
else
|
311
|
-
warn "No release packages for package format '#{package_format}', skipping
|
344
|
+
warn "No release packages for package format '#{package_format}', skipping."
|
312
345
|
return nil
|
313
346
|
end
|
314
347
|
end
|
315
348
|
|
316
349
|
def debian_component_from_path(path)
|
317
350
|
# substitute '.' and '/' since those aren't valid characters for debian components
|
318
|
-
matches = path.match(/(
|
351
|
+
matches = path.match(/(\d+\.\d+|master|main)\/(\w+)/)
|
319
352
|
regex_for_substitution = /[\.\/]/
|
320
353
|
fail "Error: Could not determine Debian Component from path #{path}" if matches.nil?
|
321
354
|
base_component = matches[1]
|
@@ -328,4 +361,15 @@ module Pkg::Paths
|
|
328
361
|
return base_component if component_qualifier == 'repos'
|
329
362
|
return full_component
|
330
363
|
end
|
364
|
+
|
365
|
+
#for ubuntu-20.04-aarch64, debian package architecture is arm64
|
366
|
+
def package_arch(platform, arch)
|
367
|
+
if platform == 'ubuntu' && arch == 'aarch64'
|
368
|
+
return 'arm64'
|
369
|
+
end
|
370
|
+
arch
|
371
|
+
end
|
372
|
+
|
373
|
+
private :package_arch
|
374
|
+
|
331
375
|
end
|
data/lib/packaging/platforms.rb
CHANGED
data/lib/packaging/util/git.rb
CHANGED
@@ -6,7 +6,7 @@ module Pkg::Util::Git
|
|
6
6
|
# Git utility to create a new git commit
|
7
7
|
def commit_file(file, message = 'changes')
|
8
8
|
fail_unless_repo
|
9
|
-
puts '
|
9
|
+
puts 'Committing changes:'
|
10
10
|
puts
|
11
11
|
diff, = Pkg::Util::Execution.capture3("#{Pkg::Util::Tool::GIT} diff HEAD #{file}")
|
12
12
|
puts diff
|
data/lib/packaging/util/net.rb
CHANGED
@@ -372,7 +372,7 @@ DOC
|
|
372
372
|
def remote_bundle_install_command
|
373
373
|
export_packaging_location = ''
|
374
374
|
export_packaging_location = "export PACKAGING_LOCATION='#{ENV['PACKAGING_LOCATION']}';" if ENV['PACKAGING_LOCATION'] && !ENV['PACKAGING_LOCATION'].empty?
|
375
|
-
command = "source /usr/local/rvm/scripts/rvm; rvm use ruby-2.
|
375
|
+
command = "source /usr/local/rvm/scripts/rvm; rvm use ruby-2.5.1; #{export_packaging_location} bundle install --path .bundle/gems ;"
|
376
376
|
end
|
377
377
|
|
378
378
|
# Given a BuildInstance object and a host, send its params to the host. Return
|
data/lib/packaging/util/ship.rb
CHANGED
@@ -105,12 +105,22 @@ module Pkg::Util::Ship
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def ship_rpms(local_staging_directory, remote_path, opts = {})
|
108
|
-
|
108
|
+
things_to_ship = [
|
109
|
+
"#{local_staging_directory}/**/*.rpm",
|
110
|
+
"#{local_staging_directory}/**/*.srpm"
|
111
|
+
]
|
112
|
+
ship_pkgs(things_to_ship, Pkg::Config.yum_staging_server, remote_path, opts)
|
109
113
|
end
|
110
114
|
|
111
115
|
def ship_debs(local_staging_directory, remote_path, opts = {})
|
112
|
-
|
113
|
-
|
116
|
+
things_to_ship = [
|
117
|
+
"#{local_staging_directory}/**/*.debian.tar.gz",
|
118
|
+
"#{local_staging_directory}/**/*.orig.tar.gz",
|
119
|
+
"#{local_staging_directory}/**/*.dsc",
|
120
|
+
"#{local_staging_directory}/**/*.deb",
|
121
|
+
"#{local_staging_directory}/**/*.changes"
|
122
|
+
]
|
123
|
+
ship_pkgs(things_to_ship, Pkg::Config.apt_signing_server, remote_path, opts)
|
114
124
|
end
|
115
125
|
|
116
126
|
def ship_svr4(local_staging_directory, remote_path, opts = {})
|
@@ -122,12 +132,17 @@ module Pkg::Util::Ship
|
|
122
132
|
end
|
123
133
|
|
124
134
|
def ship_dmg(local_staging_directory, remote_path, opts = {})
|
125
|
-
packages_have_shipped = ship_pkgs(["#{local_staging_directory}/**/*.dmg"],
|
135
|
+
packages_have_shipped = ship_pkgs(["#{local_staging_directory}/**/*.dmg"],
|
136
|
+
Pkg::Config.dmg_staging_server, remote_path, opts)
|
126
137
|
|
127
138
|
if packages_have_shipped
|
128
139
|
Pkg::Platforms.platform_tags_for_package_format('dmg').each do |platform_tag|
|
129
140
|
# Create the latest symlink for the current supported repo
|
130
|
-
Pkg::Util::Net.remote_create_latest_symlink(
|
141
|
+
Pkg::Util::Net.remote_create_latest_symlink(
|
142
|
+
Pkg::Config.project,
|
143
|
+
Pkg::Paths.artifacts_path(platform_tag, remote_path, opts[:nonfinal]),
|
144
|
+
'dmg'
|
145
|
+
)
|
131
146
|
end
|
132
147
|
end
|
133
148
|
end
|
@@ -3,42 +3,39 @@ require 'spec_helper'
|
|
3
3
|
describe 'Pkg::Paths' do
|
4
4
|
describe '#arch_from_artifact_path' do
|
5
5
|
arch_transformations = {
|
6
|
-
['artifacts/aix/6.1/
|
7
|
-
['pkg/el-
|
8
|
-
['
|
9
|
-
['
|
6
|
+
['artifacts/aix/6.1/puppet6/ppc/puppet-agent-6.9.0-1.aix6.1.ppc.rpm', 'aix', '6.1'] => 'power',
|
7
|
+
['pkg/el-8-x86_64/puppet-agent-6.9.0-1.el8.x86_64.rpm', 'el', '8'] => 'x86_64',
|
8
|
+
['pkg/el/8/puppet6/aarch64/puppet-agent-6.5.0.3094.g16b6fa6f-1.el8.aarch64.rpm', 'el', '8'] => 'aarch64',
|
9
|
+
['artifacts/fedora/32/puppet6/x86_64/puppet-agent-6.9.0-1.fc30.x86_64.rpm', 'fedora', '32'] => 'x86_64',
|
10
10
|
['pkg/ubuntu-16.04-amd64/puppet-agent_4.99.0-1xenial_amd64.deb', 'ubuntu', '16.04'] => 'amd64',
|
11
|
+
['artifacts/deb/focal/puppet6/puppet-agent_6.5.0.3094.g16b6fa6f-1focal_arm64.deb', 'ubuntu', '20.04'] => 'aarch64',
|
12
|
+
|
13
|
+
['artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz', 'ubuntu', '16.04'] => 'source',
|
11
14
|
['artifacts/deb/jessie/PC1/puppetserver_5.0.1.master.orig.tar.gz', 'debian', '8'] => 'source',
|
12
15
|
['artifacts/el/6/PC1/SRPMS/puppetserver-5.0.1.master-0.1SNAPSHOT.2017.08.18T0951.el6.src.rpm', 'el', '6'] => 'SRPMS'
|
13
16
|
}
|
14
17
|
arch_transformations.each do |path_array, arch|
|
15
18
|
it "should correctly return #{arch} for #{path_array[0]}" do
|
16
|
-
expect(Pkg::Paths.arch_from_artifact_path(path_array[1], path_array[2], path_array[0]))
|
19
|
+
expect(Pkg::Paths.arch_from_artifact_path(path_array[1], path_array[2], path_array[0]))
|
20
|
+
.to eq(arch)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
describe '#tag_from_artifact_path' do
|
22
26
|
path_tranformations = {
|
23
|
-
'artifacts/aix/6.1/
|
24
|
-
'pkg/el-7-x86_64/puppet-agent-
|
25
|
-
'pkg/ubuntu-
|
26
|
-
'pkg/windows
|
27
|
+
'artifacts/aix/6.1/puppet6/ppc/puppet-agent-6.9.0-1.aix6.1.ppc.rpm' => 'aix-6.1-power',
|
28
|
+
'pkg/el-7-x86_64/puppet-agent-5.5.22-1.el8.x86_64.rpm' => 'el-7-x86_64',
|
29
|
+
'pkg/ubuntu-20.04-amd64/puppet-agent_5.5.22-1xenial_amd64.deb' => 'ubuntu-20.04-amd64',
|
30
|
+
'pkg/windows/puppet-agent-5.5.22-x86.msi' => 'windows-2012-x86',
|
27
31
|
'artifacts/el/6/products/x86_64/pe-r10k-2.5.4.3-1.el6.x86_64.rpm' => 'el-6-x86_64',
|
28
32
|
'pkg/pe/rpm/el-6-i386/pe-puppetserver-2017.3.0.3-1.el6.noarch.rpm' => 'el-6-i386',
|
29
|
-
'pkg/deb/
|
30
|
-
'pkg/
|
31
|
-
'pkg/pe/deb/
|
32
|
-
'artifacts/deb/
|
33
|
-
'pkg/
|
34
|
-
'pkg/apple/10.14/PC1/x86_64/puppet-agent-1.9.0-1.osx10.14.dmg' => 'osx-10.14-x86_64',
|
35
|
-
'artifacts/mac/10.15/PC1/x86_64/puppet-agent-1.9.0-1.osx10.15.dmg' => 'osx-10.15-x86_64',
|
36
|
-
'artifacts/eos/4/PC1/i386/puppet-agent-1.9.0-1.eos4.i386.swix' => 'eos-4-i386',
|
33
|
+
'pkg/deb/bionic/pe-r10k_3.5.2.0-1bionic_amd64.deb' => 'ubuntu-18.04-amd64',
|
34
|
+
'pkg/deb/buster/pe-r10k_3.5.2.0-1buster_amd64.deb' => 'debian-10-amd64',
|
35
|
+
'pkg/pe/deb/bionic/pe-puppetserver_2019.8.2.32-1bionic_all.deb' => 'ubuntu-18.04-amd64',
|
36
|
+
'artifacts/deb/focal/puppet6/puppetdb_6.13.0-1focal_all.deb' => 'ubuntu-20.04-amd64',
|
37
|
+
'pkg/apple/10.15/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg' => 'osx-10.15-x86_64',
|
37
38
|
'pkg/windows/puppet-agent-1.9.0-x86.msi' => 'windows-2012-x86',
|
38
|
-
'artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz' => 'ubuntu-16.04-source',
|
39
|
-
'http://saturn.puppetlabs.net/deb_repos/1234abcd/repos/apt/xenial' => 'ubuntu-16.04-amd64',
|
40
|
-
'http://builds.puppetlabs.lan/puppet-agent/0ce4e6a0448366e01537323bbab77f834d7035c7/repos/el/6/PC1/x86_64/' => 'el-6-x86_64',
|
41
|
-
'http://builds.puppetlabs.lan/puppet-agent/0ce4e6a0448366e01537323bbab77f834d7035c7/repos/el/6/PC1/x86_64/' => 'el-6-x86_64',
|
42
39
|
'pkg/pe/rpm/el-6-i386/pe-puppetserver-2017.3.0.3-1.el6.src.rpm' => 'el-6-SRPMS',
|
43
40
|
'pkg/pe/deb/xenial/pe-puppetserver_2017.3.0.3-1puppet1.orig.tar.gz' => 'ubuntu-16.04-source',
|
44
41
|
'pkg/puppet-agent-5.1.0.79.g782e03c.gem' => nil,
|
@@ -63,10 +60,14 @@ describe 'Pkg::Paths' do
|
|
63
60
|
end
|
64
61
|
|
65
62
|
describe '#repo_name' do
|
63
|
+
it 'should return repo_name for final version' do
|
64
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
65
|
+
expect(Pkg::Paths.repo_name).to eq('puppet6')
|
66
|
+
end
|
66
67
|
|
67
68
|
it 'should return repo_name for final version' do
|
68
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
69
|
-
expect(Pkg::Paths.repo_name).to eq('
|
69
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
70
|
+
expect(Pkg::Paths.repo_name).to eq('FUTURE-puppet7')
|
70
71
|
end
|
71
72
|
|
72
73
|
it 'should be empty string if repo_name is not set for final version' do
|
@@ -75,56 +76,84 @@ describe 'Pkg::Paths' do
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it 'should return nonfinal_repo_name for non-final version' do
|
78
|
-
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('
|
79
|
-
expect(Pkg::Paths.repo_name(true)).to eq('
|
79
|
+
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet6-nightly')
|
80
|
+
expect(Pkg::Paths.repo_name(true)).to eq('puppet6-nightly')
|
80
81
|
end
|
81
82
|
|
82
83
|
it 'should fail if nonfinal_repo_name is not set for non-final version' do
|
83
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
84
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
84
85
|
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
|
85
86
|
expect { Pkg::Paths.repo_name(true) }.to raise_error
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
90
|
describe '#artifacts_path' do
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
context 'all puppet versions' do
|
92
|
+
before :each do
|
93
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
94
|
+
end
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
+
it 'should work on all current platforms' do
|
97
|
+
Pkg::Platforms.platform_tags.each do |tag|
|
98
|
+
expect { Pkg::Paths.artifacts_path(tag) }.not_to raise_error
|
99
|
+
end
|
100
|
+
end
|
96
101
|
end
|
97
102
|
|
98
|
-
|
99
|
-
|
100
|
-
|
103
|
+
context 'for puppet 6 and prior' do
|
104
|
+
before :each do
|
105
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
106
|
+
end
|
101
107
|
|
102
|
-
|
103
|
-
|
104
|
-
|
108
|
+
it 'should be correct for el7' do
|
109
|
+
expect(Pkg::Paths.artifacts_path('el-7-x86_64'))
|
110
|
+
.to eq('artifacts/puppet6/el/7/x86_64')
|
111
|
+
end
|
105
112
|
|
106
|
-
|
107
|
-
|
108
|
-
|
113
|
+
it 'should be correct for bionic' do
|
114
|
+
expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64'))
|
115
|
+
.to eq('artifacts/bionic/puppet6')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should be correct for solaris 11' do
|
119
|
+
expect(Pkg::Paths.artifacts_path('solaris-11-sparc'))
|
120
|
+
.to eq('artifacts/solaris/puppet6/11')
|
121
|
+
end
|
109
122
|
|
110
|
-
|
111
|
-
|
123
|
+
it 'should be correct for osx' do
|
124
|
+
expect(Pkg::Paths.artifacts_path('osx-10.15-x86_64'))
|
125
|
+
.to eq('artifacts/mac/puppet6/10.15/x86_64')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should be correct for windows' do
|
129
|
+
expect(Pkg::Paths.artifacts_path('windows-2012-x64'))
|
130
|
+
.to eq('artifacts/windows/puppet6')
|
131
|
+
end
|
112
132
|
end
|
113
133
|
|
114
|
-
|
115
|
-
|
116
|
-
|
134
|
+
context 'after puppet 7 apt changes' do
|
135
|
+
before :each do
|
136
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should be correct for bionic' do
|
140
|
+
expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64'))
|
141
|
+
.to eq('artifacts/FUTURE-puppet7/bionic')
|
142
|
+
end
|
143
|
+
it 'should be correct for focal' do
|
144
|
+
expect(Pkg::Paths.artifacts_path('ubuntu-20.04-amd64'))
|
145
|
+
.to eq('artifacts/FUTURE-puppet7/focal')
|
117
146
|
end
|
118
147
|
end
|
119
148
|
end
|
120
149
|
|
121
150
|
describe '#repo_path' do
|
122
151
|
before :each do
|
123
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
152
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
124
153
|
end
|
125
154
|
|
126
155
|
it 'should be correct' do
|
127
|
-
expect(Pkg::Paths.repo_path('el-7-x86_64')).to eq('repos/
|
156
|
+
expect(Pkg::Paths.repo_path('el-7-x86_64')).to eq('repos/puppet6/el/7/x86_64')
|
128
157
|
end
|
129
158
|
|
130
159
|
it 'should work on all current platforms' do
|
@@ -135,8 +164,16 @@ describe 'Pkg::Paths' do
|
|
135
164
|
end
|
136
165
|
|
137
166
|
describe '#repo_config_path' do
|
138
|
-
it 'should
|
139
|
-
expect(Pkg::Paths.repo_config_path('el-7-x86_64'))
|
167
|
+
it 'should construct rpm/deb-specific repo configs' do
|
168
|
+
expect(Pkg::Paths.repo_config_path('el-7-x86_64'))
|
169
|
+
.to eq('repo_configs/rpm/*el-7-x86_64*.repo')
|
170
|
+
expect(Pkg::Paths.repo_config_path('ubuntu-18.04-amd64'))
|
171
|
+
.to eq('repo_configs/deb/*bionic*.list')
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should raise a RuntimeError with unfamilar repo configs' do
|
175
|
+
expect { Pkg::Paths.repo_config_path('bogus') }
|
176
|
+
.to raise_error(/Could not verify that 'bogus' is a valid tag/)
|
140
177
|
end
|
141
178
|
|
142
179
|
it 'should work on all current platforms' do
|
@@ -148,15 +185,15 @@ describe 'Pkg::Paths' do
|
|
148
185
|
|
149
186
|
describe '#apt_repo_name' do
|
150
187
|
it 'should return `Pkg::Config.repo_name` if set' do
|
151
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
152
|
-
allow(Pkg::Config).to receive(:apt_repo_name).and_return('
|
153
|
-
expect(Pkg::Paths.apt_repo_name).to eq('
|
188
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
189
|
+
allow(Pkg::Config).to receive(:apt_repo_name).and_return('stuff')
|
190
|
+
expect(Pkg::Paths.apt_repo_name).to eq('puppet6')
|
154
191
|
end
|
155
192
|
|
156
193
|
it 'should return `Pkg::Config.apt_repo_name` if `Pkg::Config.repo_name` is not set' do
|
157
194
|
allow(Pkg::Config).to receive(:repo_name).and_return(nil)
|
158
|
-
allow(Pkg::Config).to receive(:apt_repo_name).and_return('
|
159
|
-
expect(Pkg::Paths.apt_repo_name).to eq('
|
195
|
+
allow(Pkg::Config).to receive(:apt_repo_name).and_return('puppet6')
|
196
|
+
expect(Pkg::Paths.apt_repo_name).to eq('puppet6')
|
160
197
|
end
|
161
198
|
|
162
199
|
it 'should return \'main\' if nothing is set' do
|
@@ -164,14 +201,15 @@ describe 'Pkg::Paths' do
|
|
164
201
|
allow(Pkg::Config).to receive(:apt_repo_name).and_return(nil)
|
165
202
|
expect(Pkg::Paths.apt_repo_name).to eq('main')
|
166
203
|
end
|
204
|
+
|
167
205
|
it 'should return nonfinal_repo_name for nonfinal version' do
|
168
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
169
|
-
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('
|
170
|
-
expect(Pkg::Paths.apt_repo_name(true)).to eq('
|
206
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
207
|
+
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('FUTURE-puppet7-nightly')
|
208
|
+
expect(Pkg::Paths.apt_repo_name(true)).to eq('FUTURE-puppet7-nightly')
|
171
209
|
end
|
172
210
|
|
173
211
|
it 'should fail if nonfinal_repo_name is not set for non-final version' do
|
174
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
212
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
175
213
|
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
|
176
214
|
expect { Pkg::Paths.apt_repo_name(true) }.to raise_error
|
177
215
|
end
|
@@ -179,15 +217,15 @@ describe 'Pkg::Paths' do
|
|
179
217
|
|
180
218
|
describe '#yum_repo_name' do
|
181
219
|
it 'should return `Pkg::Config.repo_name` if set' do
|
182
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
183
|
-
allow(Pkg::Config).to receive(:yum_repo_name).and_return('
|
184
|
-
expect(Pkg::Paths.yum_repo_name).to eq('
|
220
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
221
|
+
allow(Pkg::Config).to receive(:yum_repo_name).and_return('stuff')
|
222
|
+
expect(Pkg::Paths.yum_repo_name).to eq('puppet6')
|
185
223
|
end
|
186
224
|
|
187
225
|
it 'should return `Pkg::Config.yum_repo_name` if `Pkg::Config.repo_name` is not set' do
|
188
226
|
allow(Pkg::Config).to receive(:repo_name).and_return(nil)
|
189
|
-
allow(Pkg::Config).to receive(:yum_repo_name).and_return('
|
190
|
-
expect(Pkg::Paths.yum_repo_name).to eq('
|
227
|
+
allow(Pkg::Config).to receive(:yum_repo_name).and_return('FUTURE-puppet7')
|
228
|
+
expect(Pkg::Paths.yum_repo_name).to eq('FUTURE-puppet7')
|
191
229
|
end
|
192
230
|
|
193
231
|
it 'should return \'products\' if nothing is set' do
|
@@ -197,40 +235,50 @@ describe 'Pkg::Paths' do
|
|
197
235
|
end
|
198
236
|
|
199
237
|
it 'should return nonfinal_repo_name for nonfinal version' do
|
200
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
201
|
-
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('
|
202
|
-
expect(Pkg::Paths.yum_repo_name(true)).to eq('
|
238
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
239
|
+
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('FUTURE-puppet7-nightly')
|
240
|
+
expect(Pkg::Paths.yum_repo_name(true)).to eq('FUTURE-puppet7-nightly')
|
203
241
|
end
|
204
242
|
|
205
243
|
it 'should fail if nonfinal_repo_name is not set for non-final version' do
|
206
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
244
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
|
207
245
|
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
|
208
246
|
expect { Pkg::Paths.yum_repo_name(true) }.to raise_error
|
209
247
|
end
|
210
248
|
end
|
211
249
|
|
212
250
|
describe '#remote_repo_base' do
|
251
|
+
fake_yum_repo_path = '/fake/yum'
|
252
|
+
fake_yum_nightly_repo_path = '/fake/yum-nightly'
|
253
|
+
fake_apt_repo_path = '/fake/apt'
|
254
|
+
fake_apt_nightly_repo_path = '/fake/apt-nightly'
|
255
|
+
|
213
256
|
before :each do
|
214
|
-
allow(Pkg::Config).to receive(:yum_repo_path).and_return(
|
215
|
-
allow(Pkg::Config).to receive(:apt_repo_path).and_return(
|
257
|
+
allow(Pkg::Config).to receive(:yum_repo_path).and_return(fake_yum_repo_path)
|
258
|
+
allow(Pkg::Config).to receive(:apt_repo_path).and_return(fake_apt_repo_path)
|
216
259
|
allow(Pkg::Config).to receive(:dmg_path).and_return('/opt/downloads/mac')
|
217
|
-
allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(
|
218
|
-
allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(
|
260
|
+
allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(fake_yum_nightly_repo_path)
|
261
|
+
allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(fake_apt_nightly_repo_path)
|
219
262
|
end
|
220
263
|
it 'returns yum_repo_path for rpms' do
|
221
|
-
expect(Pkg::Paths.remote_repo_base('el-7-x86_64'))
|
264
|
+
expect(Pkg::Paths.remote_repo_base('el-7-x86_64'))
|
265
|
+
.to eq(fake_yum_repo_path)
|
222
266
|
end
|
223
267
|
it 'returns apt_repo_path for debs' do
|
224
|
-
expect(Pkg::Paths.remote_repo_base('ubuntu-18.04-amd64'))
|
268
|
+
expect(Pkg::Paths.remote_repo_base('ubuntu-18.04-amd64'))
|
269
|
+
.to eq(fake_apt_repo_path)
|
225
270
|
end
|
226
271
|
it 'returns nonfinal_yum_repo_path for nonfinal rpms' do
|
227
|
-
expect(Pkg::Paths.remote_repo_base('fedora-31-x86_64', nonfinal: true))
|
272
|
+
expect(Pkg::Paths.remote_repo_base('fedora-31-x86_64', nonfinal: true))
|
273
|
+
.to eq(fake_yum_nightly_repo_path)
|
228
274
|
end
|
229
275
|
it 'returns nonfinal_apt_repo_path for nonfinal debs' do
|
230
|
-
expect(Pkg::Paths.remote_repo_base('debian-9-amd64', nonfinal: true))
|
276
|
+
expect(Pkg::Paths.remote_repo_base('debian-9-amd64', nonfinal: true))
|
277
|
+
.to eq(fake_apt_nightly_repo_path)
|
231
278
|
end
|
232
279
|
it 'fails if neither tag nor package_format is provided' do
|
233
|
-
expect { Pkg::Paths.remote_repo_base }
|
280
|
+
expect { Pkg::Paths.remote_repo_base }
|
281
|
+
.to raise_error(/Pkg::Paths.remote_repo_base must have/)
|
234
282
|
end
|
235
283
|
|
236
284
|
it 'returns /opt/downloads if the path is /opt/downloads/<something>' do
|
@@ -238,56 +286,127 @@ describe 'Pkg::Paths' do
|
|
238
286
|
end
|
239
287
|
|
240
288
|
it 'fails for all other package formats' do
|
241
|
-
expect { Pkg::Paths.remote_repo_base('solaris-11-i386') }
|
289
|
+
expect { Pkg::Paths.remote_repo_base('solaris-11-i386') }
|
290
|
+
.to raise_error(/Can't determine remote repo base path/)
|
242
291
|
end
|
243
292
|
end
|
244
293
|
|
245
294
|
describe '#apt_package_base_path' do
|
246
295
|
it 'fails for non-debian platforms' do
|
247
|
-
expect { Pkg::Paths.apt_package_base_path('el-7-x86_64', 'puppet6', 'puppet-agent') }
|
296
|
+
expect { Pkg::Paths.apt_package_base_path('el-7-x86_64', 'puppet6', 'puppet-agent') }
|
297
|
+
.to raise_error(/Can't determine path for non-debian platform/)
|
248
298
|
end
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
299
|
+
|
300
|
+
context 'for puppet 6 and prior' do
|
301
|
+
it 'returns the approprate apt repo path' do
|
302
|
+
allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository/apt')
|
303
|
+
expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6', 'puppet-agent'))
|
304
|
+
.to eq('/opt/repository/apt/pool/bionic/puppet6/p/puppet-agent')
|
305
|
+
expect(Pkg::Paths.apt_package_base_path('debian-9-amd64', 'puppet6', 'bolt-server'))
|
306
|
+
.to eq('/opt/repository/apt/pool/stretch/puppet6/b/bolt-server')
|
307
|
+
|
308
|
+
|
309
|
+
end
|
310
|
+
it 'returns the appropriate nonfinal repo path' do
|
311
|
+
allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt')
|
312
|
+
expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6-nightly',
|
313
|
+
'puppet-agent', true))
|
314
|
+
.to eq('/opt/repository-nightlies/apt/pool/bionic/puppet6-nightly/p/puppet-agent')
|
315
|
+
expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'puppet6-nightly',
|
316
|
+
'pdk', true))
|
317
|
+
.to eq('/opt/repository-nightlies/apt/pool/buster/puppet6-nightly/p/pdk')
|
318
|
+
end
|
253
319
|
end
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
320
|
+
|
321
|
+
context 'for puppet 7 and after' do
|
322
|
+
it 'returns the approprate apt repo path' do
|
323
|
+
allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository/apt')
|
324
|
+
expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'FUTURE-puppet7', 'puppet-agent'))
|
325
|
+
.to eq('/opt/repository/apt/FUTURE-puppet7/pool/bionic/p/puppet-agent')
|
326
|
+
expect(Pkg::Paths.apt_package_base_path('ubuntu-20.04-amd64', 'FUTURE-puppet7', 'puppet-agent'))
|
327
|
+
.to eq('/opt/repository/apt/FUTURE-puppet7/pool/focal/p/puppet-agent')
|
328
|
+
end
|
329
|
+
it 'returns the appropriate nonfinal repo path' do
|
330
|
+
allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt')
|
331
|
+
expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'FUTURE-puppet7-nightly', 'pdk', true))
|
332
|
+
.to eq('/opt/repository-nightlies/apt/FUTURE-puppet7-nightly/pool/buster/p/pdk')
|
333
|
+
end
|
258
334
|
end
|
259
335
|
end
|
260
336
|
|
261
337
|
describe '#release_package_link_path' do
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
338
|
+
context 'for puppet 6' do
|
339
|
+
repo_name = 'puppet6'
|
340
|
+
nonfinal_repo_name = 'puppet6-nightly'
|
341
|
+
yum_repo_path = '/opt/repository/yum'
|
342
|
+
apt_repo_path = '/opt/repository/apt'
|
343
|
+
nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
|
344
|
+
nonfinal_apt_repo_path = '/opt/repository-nightlies/apt'
|
345
|
+
before :each do
|
346
|
+
allow(Pkg::Config).to receive(:repo_name).and_return(repo_name)
|
347
|
+
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nonfinal_repo_name)
|
348
|
+
allow(Pkg::Config).to receive(:yum_repo_path).and_return(yum_repo_path)
|
349
|
+
allow(Pkg::Config).to receive(:apt_repo_path).and_return(apt_repo_path)
|
350
|
+
allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path)
|
351
|
+
allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path)
|
352
|
+
end
|
353
|
+
it 'returns the appropriate link path for rpm release packages' do
|
354
|
+
expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le'))
|
355
|
+
.to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm")
|
356
|
+
end
|
357
|
+
it 'returns the appropriate link path for deb release packages' do
|
358
|
+
expect(Pkg::Paths.release_package_link_path('ubuntu-16.04-amd64'))
|
359
|
+
.to eq("#{apt_repo_path}/#{repo_name}-release-xenial.deb")
|
360
|
+
end
|
361
|
+
it 'returns the appropriate link path for nonfinal rpm release packages' do
|
362
|
+
expect(Pkg::Paths.release_package_link_path('el-7-x86_64', true))
|
363
|
+
.to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-7.noarch.rpm")
|
364
|
+
end
|
365
|
+
it 'returns the appropriate link path for nonfinal deb release packages' do
|
366
|
+
expect(Pkg::Paths.release_package_link_path('debian-9-i386', true))
|
367
|
+
.to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-stretch.deb")
|
368
|
+
end
|
369
|
+
it 'returns nil for package formats that do not have release packages' do
|
370
|
+
expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
|
371
|
+
expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
|
372
|
+
end
|
287
373
|
end
|
288
|
-
|
289
|
-
|
290
|
-
|
374
|
+
|
375
|
+
context 'for puppet 7' do
|
376
|
+
repo_name = 'FUTURE-puppet7'
|
377
|
+
nonfinal_repo_name = 'FUTURE-puppet7-nightly'
|
378
|
+
yum_repo_path = '/opt/repository/yum'
|
379
|
+
apt_repo_path = '/opt/repository/apt'
|
380
|
+
nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
|
381
|
+
nonfinal_apt_repo_path = '/opt/repository-nightlies/apt'
|
382
|
+
before :each do
|
383
|
+
allow(Pkg::Config).to receive(:repo_name).and_return(repo_name)
|
384
|
+
allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nonfinal_repo_name)
|
385
|
+
allow(Pkg::Config).to receive(:yum_repo_path).and_return(yum_repo_path)
|
386
|
+
allow(Pkg::Config).to receive(:apt_repo_path).and_return(apt_repo_path)
|
387
|
+
allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path)
|
388
|
+
allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path)
|
389
|
+
end
|
390
|
+
it 'returns the appropriate link path for rpm release packages' do
|
391
|
+
expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le'))
|
392
|
+
.to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm")
|
393
|
+
end
|
394
|
+
it 'returns the appropriate link path for deb release packages' do
|
395
|
+
expect(Pkg::Paths.release_package_link_path('ubuntu-20.04-amd64'))
|
396
|
+
.to eq("#{apt_repo_path}/#{repo_name}-release-focal.deb")
|
397
|
+
end
|
398
|
+
it 'returns the appropriate link path for nonfinal rpm release packages' do
|
399
|
+
expect(Pkg::Paths.release_package_link_path('el-8-x86_64', true))
|
400
|
+
.to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-8.noarch.rpm")
|
401
|
+
end
|
402
|
+
it 'returns the appropriate link path for nonfinal deb release packages' do
|
403
|
+
expect(Pkg::Paths.release_package_link_path('debian-10-i386', true))
|
404
|
+
.to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-buster.deb")
|
405
|
+
end
|
406
|
+
it 'returns nil for package formats that do not have release packages' do
|
407
|
+
expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
|
408
|
+
expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
|
409
|
+
end
|
291
410
|
end
|
292
411
|
end
|
293
412
|
end
|
@@ -2,88 +2,112 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe '#Pkg::Util::Ship' do
|
4
4
|
describe '#collect_packages' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
msi_packages = %w[
|
6
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x64.msi
|
7
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x86.msi
|
8
|
+
pkg/windowsfips/puppet6/puppet-agent-6.19.0-x64.msi
|
9
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
10
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
10
11
|
]
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
solaris_packages = %w[
|
13
|
+
pkg/solaris/10/puppet6/puppet-agent-6.9.0-1.sparc.pkg.gz
|
14
|
+
pkg/solaris/10/puppet6/puppet-agent-6.9.0-1.sparc.pkg.gz.asc
|
14
15
|
]
|
15
16
|
|
16
17
|
it 'returns an array of packages found on the filesystem' do
|
17
|
-
allow(Dir).to receive(:glob).with('pkg/**/*.
|
18
|
-
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.
|
18
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.sparc*').and_return(solaris_packages)
|
19
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.sparc*'])).to eq(solaris_packages)
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
context 'excluding packages' do
|
22
23
|
before :each do
|
23
|
-
allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(
|
24
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_packages)
|
24
25
|
end
|
25
26
|
it 'correctly excludes any packages that match a passed excludes argument' do
|
26
|
-
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi']))
|
27
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi']))
|
28
|
+
.not_to include('pkg/windows/puppet6/puppet-agent-x86.msi')
|
29
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi']))
|
30
|
+
.not_to include('pkg/windows/puppet6/puppet-agent-x64.msi')
|
27
31
|
end
|
28
32
|
it 'correctly includes packages that do not match a passed excluded argument' do
|
29
|
-
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'],
|
30
|
-
|
31
|
-
|
32
|
-
'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
|
33
|
-
'pkg/windowsfips/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x64.msi',
|
34
|
-
]
|
35
|
-
)
|
33
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'],
|
34
|
+
['bogus-puppet-agent-x(86|64).msi']))
|
35
|
+
.to match_array(msi_packages)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
39
|
+
it 'returns an empty array when it cannot find any packages' do
|
40
40
|
allow(Dir).to receive(:glob).with('pkg/**/*.html').and_return([])
|
41
41
|
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.html'])).to be_empty
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
45
|
+
# Sample data for #reorganize_packages and #ship_pkgs specs
|
46
|
+
retrieved_packages = %w[
|
47
|
+
pkg/deb/bionic/puppet6/puppet-agent_6.19.0-1bionic_amd64.deb
|
48
|
+
pkg/el/7/puppet6/aarch64/puppet-agent-6.19.0-1.el7.aarch64.rpm
|
49
|
+
pkg/el/7/puppet6/ppc64le/puppet-agent-6.19.0-1.el7.ppc64le.rpm
|
50
|
+
pkg/el/7/puppet6/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm
|
51
|
+
pkg/sles/12/puppet6/ppc64le/puppet-agent-6.19.0-1.sles12.ppc64le.rpm
|
52
|
+
pkg/sles/12/puppet6/x86_64/puppet-agent-6.19.0-1.sles12.x86_64.rpm
|
53
|
+
pkg/sles/15/puppet6/x86_64/puppet-agent-6.19.0-1.sles15.x86_64.rpm
|
54
|
+
pkg/apple/10.14/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.14.dmg
|
55
|
+
pkg/apple/10.15/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg
|
56
|
+
pkg/fedora/32/puppet6/x86_64/puppet-agent-6.19.0-1.fc32.x86_64.rpm
|
57
|
+
pkg/windows/puppet-agent-6.19.0-x64.msi
|
58
|
+
pkg/windows/puppet-agent-6.19.0-x86.msi
|
59
|
+
pkg/windowsfips/puppet-agent-6.19.0-x64.msi
|
60
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
61
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
62
|
+
]
|
63
|
+
|
64
|
+
# After reorganization, the packages should look like this.
|
65
|
+
# Beware apple->mac transforms.
|
66
|
+
expected_reorganized_packages = %w[
|
67
|
+
pkg/bionic/puppet6/puppet-agent_6.19.0-1bionic_amd64.deb
|
68
|
+
pkg/puppet6/el/7/aarch64/puppet-agent-6.19.0-1.el7.aarch64.rpm
|
69
|
+
pkg/puppet6/el/7/ppc64le/puppet-agent-6.19.0-1.el7.ppc64le.rpm
|
70
|
+
pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm
|
71
|
+
pkg/puppet6/sles/12/ppc64le/puppet-agent-6.19.0-1.sles12.ppc64le.rpm
|
72
|
+
pkg/puppet6/sles/12/x86_64/puppet-agent-6.19.0-1.sles12.x86_64.rpm
|
73
|
+
pkg/puppet6/sles/15/x86_64/puppet-agent-6.19.0-1.sles15.x86_64.rpm
|
74
|
+
pkg/mac/puppet6/10.14/x86_64/puppet-agent-6.19.0-1.osx10.14.dmg
|
75
|
+
pkg/mac/puppet6/10.15/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg
|
76
|
+
pkg/puppet6/fedora/32/x86_64/puppet-agent-6.19.0-1.fc32.x86_64.rpm
|
77
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x64.msi
|
78
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x86.msi
|
79
|
+
pkg/windowsfips/puppet6/puppet-agent-6.19.0-x64.msi
|
80
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
81
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
82
|
+
]
|
65
83
|
|
66
84
|
describe '#reorganize_packages' do
|
67
|
-
|
85
|
+
# This is a sampling of packages found on builds.delivery.puppetlabs.net in
|
86
|
+
# '/opt/jenkins-builds/puppet-agent/<version>/artifacts'
|
87
|
+
# pl:jenkins:retrieve replaces 'artifacts' with 'pkg', so we pick up the
|
88
|
+
# action from that point by pretending that we've scanned the directory and
|
89
|
+
# made this list:
|
90
|
+
|
91
|
+
scratch_directory = Dir.mktmpdir
|
68
92
|
|
69
93
|
before :each do
|
70
|
-
allow(Pkg::Config).to receive(:repo_name).and_return('
|
71
|
-
expect(FileUtils).to receive(:cp).at_least(:once)
|
94
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
95
|
+
expect(FileUtils).to receive(:cp).at_least(:once).and_return(true)
|
72
96
|
end
|
73
97
|
|
74
|
-
|
75
|
-
expect(FileUtils).to receive(:mkdir_p).at_least(:once)
|
76
|
-
Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
|
77
|
-
end
|
98
|
+
original_packages = retrieved_packages
|
78
99
|
|
79
100
|
it 'leaves the old packages in place' do
|
80
|
-
|
81
|
-
|
82
|
-
|
101
|
+
reorganized_packages = Pkg::Util::Ship
|
102
|
+
.reorganize_packages(retrieved_packages, scratch_directory)
|
103
|
+
|
104
|
+
expect(retrieved_packages).to eq(original_packages)
|
83
105
|
end
|
84
106
|
|
85
|
-
it 'returns a list of
|
86
|
-
|
107
|
+
it 'returns a list of properly reorganized packages' do
|
108
|
+
reorganized_packages = Pkg::Util::Ship
|
109
|
+
.reorganize_packages(retrieved_packages, scratch_directory)
|
110
|
+
expect(reorganized_packages).to eq(expected_reorganized_packages)
|
87
111
|
end
|
88
112
|
end
|
89
113
|
|
@@ -92,38 +116,84 @@ new_pkgs = [
|
|
92
116
|
test_remote_path = '/opt/repository/yum'
|
93
117
|
|
94
118
|
it 'ships the packages to the staging server' do
|
95
|
-
allow(Pkg::Util::Ship)
|
96
|
-
|
119
|
+
allow(Pkg::Util::Ship)
|
120
|
+
.to receive(:collect_packages)
|
121
|
+
.and_return(retrieved_packages)
|
122
|
+
allow(Pkg::Util::Ship)
|
123
|
+
.to receive(:reorganize_packages)
|
124
|
+
.and_return(expected_reorganized_packages)
|
97
125
|
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
98
126
|
# All of these expects must be called in the same block in order for the
|
99
127
|
# tests to work without actually shipping anything
|
100
|
-
expect(Pkg::Util::Net)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(Pkg::Util::Net)
|
105
|
-
|
106
|
-
|
128
|
+
expect(Pkg::Util::Net)
|
129
|
+
.to receive(:remote_ssh_cmd)
|
130
|
+
.with(test_staging_server, /#{test_remote_path}/)
|
131
|
+
.exactly(retrieved_packages.count).times
|
132
|
+
expect(Pkg::Util::Net)
|
133
|
+
.to receive(:rsync_to)
|
134
|
+
.with(anything, test_staging_server, /#{test_remote_path}/, anything)
|
135
|
+
.exactly(retrieved_packages.count).times
|
136
|
+
expect(Pkg::Util::Net)
|
137
|
+
.to receive(:remote_set_ownership)
|
138
|
+
.with(test_staging_server, 'root', 'release', anything)
|
139
|
+
.exactly(retrieved_packages.count).times
|
140
|
+
expect(Pkg::Util::Net)
|
141
|
+
.to receive(:remote_set_permissions)
|
142
|
+
.with(test_staging_server, '775', anything)
|
143
|
+
.exactly(retrieved_packages.count).times
|
144
|
+
expect(Pkg::Util::Net)
|
145
|
+
.to receive(:remote_set_permissions)
|
146
|
+
.with(test_staging_server, '0664', anything)
|
147
|
+
.exactly(retrieved_packages.count).times
|
148
|
+
expect(Pkg::Util::Net)
|
149
|
+
.to receive(:remote_set_immutable)
|
150
|
+
.with(test_staging_server, anything)
|
151
|
+
.exactly(retrieved_packages.count).times
|
152
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path))
|
153
|
+
.to eq(true)
|
107
154
|
end
|
108
155
|
|
109
156
|
it 'ships packages containing the string `pkg` to the right place' do
|
110
|
-
|
111
|
-
|
157
|
+
retrieved_package = 'pkg/el/7/puppet6/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm'
|
158
|
+
reorganized_package = 'pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm'
|
159
|
+
package_basename = File.basename(reorganized_package)
|
160
|
+
repository_base_path = '/opt/repository/yum/puppet6/el/7/x86_64'
|
161
|
+
|
162
|
+
allow(Pkg::Util::Ship).to receive(:collect_packages).and_return([retrieved_package])
|
163
|
+
allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return([reorganized_package])
|
112
164
|
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
113
165
|
allow(Dir).to receive(:mktmpdir).and_return('/tmp/test')
|
166
|
+
|
114
167
|
# All of these expects must be called in the same block in order for the
|
115
168
|
# tests to work without actually shipping anything
|
116
|
-
expect(Pkg::Util::Net)
|
117
|
-
|
118
|
-
|
119
|
-
expect(Pkg::Util::Net)
|
120
|
-
|
121
|
-
|
122
|
-
expect(Pkg::Util::
|
169
|
+
expect(Pkg::Util::Net)
|
170
|
+
.to receive(:remote_ssh_cmd)
|
171
|
+
.with(test_staging_server, /#{test_remote_path}/)
|
172
|
+
expect(Pkg::Util::Net)
|
173
|
+
.to receive(:rsync_to)
|
174
|
+
.with(anything, test_staging_server, /#{test_remote_path}/, anything)
|
175
|
+
expect(Pkg::Util::Net)
|
176
|
+
.to receive(:remote_set_ownership)
|
177
|
+
.with(test_staging_server, 'root', 'release',
|
178
|
+
[repository_base_path, "#{repository_base_path}/#{package_basename}"])
|
179
|
+
expect(Pkg::Util::Net)
|
180
|
+
.to receive(:remote_set_permissions)
|
181
|
+
.with(test_staging_server, '775', anything)
|
182
|
+
expect(Pkg::Util::Net)
|
183
|
+
.to receive(:remote_set_permissions)
|
184
|
+
.with(test_staging_server, '0664', anything)
|
185
|
+
expect(Pkg::Util::Net)
|
186
|
+
.to receive(:remote_set_immutable)
|
187
|
+
.with(test_staging_server, anything)
|
188
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server,
|
189
|
+
test_remote_path, excludes: ['puppet-agent']))
|
190
|
+
.to eq(true)
|
123
191
|
end
|
124
192
|
|
125
193
|
it 'returns false if there are no packages to ship' do
|
126
|
-
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'],
|
194
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'],
|
195
|
+
test_staging_server, test_remote_path))
|
196
|
+
.to eq(false)
|
127
197
|
end
|
128
198
|
end
|
129
199
|
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.99.
|
4
|
+
version: 0.99.75
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -259,28 +259,28 @@ signing_key:
|
|
259
259
|
specification_version: 4
|
260
260
|
summary: Puppet Labs' packaging automation
|
261
261
|
test_files:
|
262
|
-
- spec/lib/
|
263
|
-
- spec/lib/packaging/sign_spec.rb
|
264
|
-
- spec/lib/packaging/platforms_spec.rb
|
262
|
+
- spec/lib/packaging_spec.rb
|
265
263
|
- spec/lib/packaging/rpm/repo_spec.rb
|
266
|
-
- spec/lib/packaging/
|
267
|
-
- spec/lib/packaging/
|
268
|
-
- spec/lib/packaging/gem_spec.rb
|
269
|
-
- spec/lib/packaging/util/execution_spec.rb
|
264
|
+
- spec/lib/packaging/paths_spec.rb
|
265
|
+
- spec/lib/packaging/deb/repo_spec.rb
|
270
266
|
- spec/lib/packaging/util/gpg_spec.rb
|
267
|
+
- spec/lib/packaging/util/os_spec.rb
|
268
|
+
- spec/lib/packaging/util/file_spec.rb
|
269
|
+
- spec/lib/packaging/util/ship_spec.rb
|
271
270
|
- spec/lib/packaging/util/git_spec.rb
|
272
|
-
- spec/lib/packaging/util/
|
273
|
-
- spec/lib/packaging/util/rake_utils_spec.rb
|
274
|
-
- spec/lib/packaging/util/net_spec.rb
|
275
|
-
- spec/lib/packaging/util/git_tag_spec.rb
|
271
|
+
- spec/lib/packaging/util/execution_spec.rb
|
276
272
|
- spec/lib/packaging/util/misc_spec.rb
|
277
|
-
- spec/lib/packaging/util/
|
278
|
-
- spec/lib/packaging/util/file_spec.rb
|
273
|
+
- spec/lib/packaging/util/rake_utils_spec.rb
|
279
274
|
- spec/lib/packaging/util/version_spec.rb
|
280
|
-
- spec/lib/packaging/util/
|
281
|
-
- spec/lib/packaging/
|
275
|
+
- spec/lib/packaging/util/git_tag_spec.rb
|
276
|
+
- spec/lib/packaging/util/jenkins_spec.rb
|
277
|
+
- spec/lib/packaging/util/net_spec.rb
|
282
278
|
- spec/lib/packaging/deb_spec.rb
|
283
|
-
- spec/lib/packaging/
|
279
|
+
- spec/lib/packaging/config_spec.rb
|
280
|
+
- spec/lib/packaging/artifactory_spec.rb
|
281
|
+
- spec/lib/packaging/gem_spec.rb
|
284
282
|
- spec/lib/packaging/tar_spec.rb
|
285
|
-
- spec/lib/packaging/
|
286
|
-
- spec/lib/
|
283
|
+
- spec/lib/packaging/sign_spec.rb
|
284
|
+
- spec/lib/packaging/repo_spec.rb
|
285
|
+
- spec/lib/packaging/platforms_spec.rb
|
286
|
+
- spec/lib/packaging/retrieve_spec.rb
|