packaging 0.99.71 → 0.99.72

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc55afd9bcd5d03c49cd0ce6f89ae31a209356058fb3462bafc8c65fe49d4797
4
- data.tar.gz: 502621e9b2c3596626e56e0a38855ced2b118bcf501dc8a87381fda4f1c06f76
3
+ metadata.gz: 0d7bf70560a370066a2f9ab94c35c38093b5884e7baeabc9efe0926de62e262f
4
+ data.tar.gz: c6bf09ab5b588fa500b3db7408372194e2b7a1ac154ea98e1481085166deb28b
5
5
  SHA512:
6
- metadata.gz: cb7d531d46d326390769e3c1f27210b3ae65907d9e48adae43248a13b850b5688e008f4d229267d0d936b8d80c6b0c8569b5823e41c55d60ed0145d4b47a9ec6
7
- data.tar.gz: 5c9c2ee3f31fdfc657efb40e17ff9f5283707a883cc1c2bea3ec81dafed9da39a56ae58d6e791f657759ae419c96cfb726a1a30332dba174ab36a6087c50d4a7
6
+ metadata.gz: 91aa048b12dfe8fd25867d9d5522db55559f2273284cafb3089362f0f14ee09ae536c3d039a04d63ebb95d0c1238a6467f60e27d8a1b41b512234ba609cb58ff
7
+ data.tar.gz: b26d4ff051f2b7ff0cddfdb1a8f3237377d237a3bc59511cbef6785ccb566eac8917d100108acbe41488d2748e8439860f26038069fd8f818d72c7474e4468e8
@@ -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 },
@@ -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, Pkg::Config.gem_path, platform_independent: true)
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
- gem_data = JSON.parse(`curl https://rubygems.org/api/v1/versions/#{gem_name}.json`)
21
- gem = gem_data.select { |data| data['number'] == gem_version && data['platform'] == gem_platform }
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 "Uh oh, something went wrong searching for gem '#{gem_name}':"
25
+ puts "Something went wrong searching for gem '#{gem_name}':"
25
26
  puts e
26
- puts "Perhaps you're shipping gem '#{gem_name}' for the first time? Congrats!"
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, { :host => Pkg::Config.internal_gem_host, :key => internal_mirror_api_key_name })
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
@@ -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(puppet7 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,23 +302,43 @@ 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
- fail "Can't determine path for non-debian platform #{platform_tag}." unless Pkg::Platforms.package_format_for_tag(platform_tag) == 'deb'
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
- codename = Pkg::Platforms.codename_for_platform_version(platform, version)
298
- return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), 'pool', codename, repo_name, project[0], project)
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(puppet7 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(puppet puppet5 puppet6 puppet-nightly puppet5-nightly puppet6-nightly).include? repo_name
323
+ return File.join(remote_repo_path, 'pool', code_name, repo_name, project[0], project)
324
+ end
325
+
326
+ raise "Error: Cannot determine apt_package_base_path for repo: \"#{repo_name}\"."
299
327
  end
300
328
 
301
329
  def release_package_link_path(platform_tag, nonfinal = false)
302
- platform, version, arch = Pkg::Platforms.parse_platform_tag(platform_tag)
330
+ platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag)
303
331
  package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
304
332
  case package_format
305
333
  when 'rpm'
306
- return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), "#{repo_name(nonfinal)}-release-#{platform}-#{version}.noarch.rpm")
334
+ return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
335
+ "#{repo_name(nonfinal)}-release-#{platform}-#{version}.noarch.rpm")
307
336
  when 'deb'
308
337
  codename = Pkg::Platforms.codename_for_platform_version(platform, version)
309
- return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), "#{repo_name(nonfinal)}-release-#{codename}.deb")
338
+ return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal),
339
+ "#{repo_name(nonfinal)}-release-#{codename}.deb")
310
340
  else
311
- warn "No release packages for package format '#{package_format}', skipping . . ."
341
+ warn "No release packages for package format '#{package_format}', skipping."
312
342
  return nil
313
343
  end
314
344
  end
@@ -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 'Commiting changes:'
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
@@ -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
- ship_pkgs(["#{local_staging_directory}/**/*.rpm", "#{local_staging_directory}/**/*.srpm"], Pkg::Config.yum_staging_server, remote_path, opts)
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
- ship_pkgs(["#{local_staging_directory}/**/*.debian.tar.gz", "#{local_staging_directory}/**/*.orig.tar.gz" "#{local_staging_directory}/**/*.dsc", "#{local_staging_directory}/**/*.deb", "#{local_staging_directory}/**/*.changes"], Pkg::Config.apt_signing_server, remote_path, opts)
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"], Pkg::Config.dmg_staging_server, remote_path, opts)
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(Pkg::Config.project, Pkg::Paths.artifacts_path(platform_tag, remote_path, opts[:nonfinal]), 'dmg')
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,37 @@ 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/PC1/ppc/puppet-agent-5.1.0.79.g782e03c-1.aix6.1.ppc.rpm', 'aix', '6.1'] => 'power',
7
- ['pkg/el-7-x86_64/puppet-agent-4.99.0-1.el7.x86_64.rpm', 'el', '7'] => 'x86_64',
8
- ['artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz', 'ubuntu', '16.04'] => 'source',
9
- ['http://saturn.puppetlabs.net/deb_repos/1234abcd/repos/apt/xenial', 'ubuntu', '16.04'] => 'amd64',
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
+ ['artifacts/fedora/32/puppet6/x86_64/puppet-agent-6.9.0-1.fc30.x86_64.rpm', 'fedora', '32'] => 'x86_64',
10
9
  ['pkg/ubuntu-16.04-amd64/puppet-agent_4.99.0-1xenial_amd64.deb', 'ubuntu', '16.04'] => 'amd64',
10
+
11
+ ['artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz', 'ubuntu', '16.04'] => 'source',
11
12
  ['artifacts/deb/jessie/PC1/puppetserver_5.0.1.master.orig.tar.gz', 'debian', '8'] => 'source',
12
13
  ['artifacts/el/6/PC1/SRPMS/puppetserver-5.0.1.master-0.1SNAPSHOT.2017.08.18T0951.el6.src.rpm', 'el', '6'] => 'SRPMS'
13
14
  }
14
15
  arch_transformations.each do |path_array, arch|
15
16
  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])).to eq(arch)
17
+ expect(Pkg::Paths.arch_from_artifact_path(path_array[1], path_array[2], path_array[0]))
18
+ .to eq(arch)
17
19
  end
18
20
  end
19
21
  end
20
22
 
21
23
  describe '#tag_from_artifact_path' do
22
24
  path_tranformations = {
23
- 'artifacts/aix/6.1/PC1/ppc/puppet-agent-5.1.0.79.g782e03c-1.aix6.1.ppc.rpm' => 'aix-6.1-power',
24
- 'pkg/el-7-x86_64/puppet-agent-4.99.0-1.el7.x86_64.rpm' => 'el-7-x86_64',
25
- 'pkg/ubuntu-16.04-amd64/puppet-agent_4.99.0-1xenial_amd64.deb' => 'ubuntu-16.04-amd64',
26
- 'pkg/windows-x64/puppet-agent-4.99.0-x64.msi' => 'windows-2012-x64',
25
+ 'artifacts/aix/6.1/puppet6/ppc/puppet-agent-6.9.0-1.aix6.1.ppc.rpm' => 'aix-6.1-power',
26
+ 'pkg/el-7-x86_64/puppet-agent-5.5.22-1.el8.x86_64.rpm' => 'el-7-x86_64',
27
+ 'pkg/ubuntu-20.04-amd64/puppet-agent_5.5.22-1xenial_amd64.deb' => 'ubuntu-20.04-amd64',
28
+ 'pkg/windows/puppet-agent-5.5.22-x86.msi' => 'windows-2012-x86',
27
29
  'artifacts/el/6/products/x86_64/pe-r10k-2.5.4.3-1.el6.x86_64.rpm' => 'el-6-x86_64',
28
30
  'pkg/pe/rpm/el-6-i386/pe-puppetserver-2017.3.0.3-1.el6.noarch.rpm' => 'el-6-i386',
29
- 'pkg/deb/trusty/pe-r10k_2.5.4.3-1trusty_amd64.deb' => 'ubuntu-14.04-amd64',
30
- 'pkg/pe/deb/xenial/pe-puppetserver_2017.3.0.3-1puppet1_all.deb' => 'ubuntu-16.04-amd64',
31
- 'pkg/pe/deb/xenial/super-trusty-package_1.0.0-1puppet1_all.deb' => 'ubuntu-16.04-amd64',
32
- 'artifacts/deb/stretch/PC1/puppetdb_4.3.1-1puppetlabs1_all.deb' => 'debian-9-amd64',
33
- 'pkg/el/7/PC1/x86_64/puppetdb-4.3.1-1.el7.noarch.rpm' => 'el-7-x86_64',
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',
31
+ 'pkg/deb/bionic/pe-r10k_3.5.2.0-1bionic_amd64.deb' => 'ubuntu-18.04-amd64',
32
+ 'pkg/deb/buster/pe-r10k_3.5.2.0-1buster_amd64.deb' => 'debian-10-amd64',
33
+ 'pkg/pe/deb/bionic/pe-puppetserver_2019.8.2.32-1bionic_all.deb' => 'ubuntu-18.04-amd64',
34
+ 'artifacts/deb/focal/puppet6/puppetdb_6.13.0-1focal_all.deb' => 'ubuntu-20.04-amd64',
35
+ 'pkg/apple/10.15/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg' => 'osx-10.15-x86_64',
37
36
  '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
37
  'pkg/pe/rpm/el-6-i386/pe-puppetserver-2017.3.0.3-1.el6.src.rpm' => 'el-6-SRPMS',
43
38
  'pkg/pe/deb/xenial/pe-puppetserver_2017.3.0.3-1puppet1.orig.tar.gz' => 'ubuntu-16.04-source',
44
39
  'pkg/puppet-agent-5.1.0.79.g782e03c.gem' => nil,
@@ -63,10 +58,14 @@ describe 'Pkg::Paths' do
63
58
  end
64
59
 
65
60
  describe '#repo_name' do
61
+ it 'should return repo_name for final version' do
62
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
63
+ expect(Pkg::Paths.repo_name).to eq('puppet6')
64
+ end
66
65
 
67
66
  it 'should return repo_name for final version' do
68
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
69
- expect(Pkg::Paths.repo_name).to eq('puppet5')
67
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
68
+ expect(Pkg::Paths.repo_name).to eq('puppet7')
70
69
  end
71
70
 
72
71
  it 'should be empty string if repo_name is not set for final version' do
@@ -75,56 +74,84 @@ describe 'Pkg::Paths' do
75
74
  end
76
75
 
77
76
  it 'should return nonfinal_repo_name for non-final version' do
78
- allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet5-nightly')
79
- expect(Pkg::Paths.repo_name(true)).to eq('puppet5-nightly')
77
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet6-nightly')
78
+ expect(Pkg::Paths.repo_name(true)).to eq('puppet6-nightly')
80
79
  end
81
80
 
82
81
  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('puppet5')
82
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
84
83
  allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
85
84
  expect { Pkg::Paths.repo_name(true) }.to raise_error
86
85
  end
87
86
  end
88
87
 
89
88
  describe '#artifacts_path' do
90
- before :each do
91
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
92
- end
89
+ context 'all puppet versions' do
90
+ before :each do
91
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
92
+ end
93
93
 
94
- it 'should be correct for el7' do
95
- expect(Pkg::Paths.artifacts_path('el-7-x86_64')).to eq('artifacts/puppet5/el/7/x86_64')
94
+ it 'should work on all current platforms' do
95
+ Pkg::Platforms.platform_tags.each do |tag|
96
+ expect { Pkg::Paths.artifacts_path(tag) }.not_to raise_error
97
+ end
98
+ end
96
99
  end
97
100
 
98
- it 'should be correct for bionic' do
99
- expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64')).to eq('artifacts/bionic/puppet5')
100
- end
101
+ context 'for puppet 6 and prior' do
102
+ before :each do
103
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
104
+ end
101
105
 
102
- it 'should be correct for solaris 11' do
103
- expect(Pkg::Paths.artifacts_path('solaris-11-sparc')).to eq('artifacts/solaris/puppet5/11')
104
- end
106
+ it 'should be correct for el7' do
107
+ expect(Pkg::Paths.artifacts_path('el-7-x86_64'))
108
+ .to eq('artifacts/puppet6/el/7/x86_64')
109
+ end
105
110
 
106
- it 'should be correct for osx' do
107
- expect(Pkg::Paths.artifacts_path('osx-10.15-x86_64')).to eq('artifacts/mac/puppet5/10.15/x86_64')
108
- end
111
+ it 'should be correct for bionic' do
112
+ expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64'))
113
+ .to eq('artifacts/bionic/puppet6')
114
+ end
115
+
116
+ it 'should be correct for solaris 11' do
117
+ expect(Pkg::Paths.artifacts_path('solaris-11-sparc'))
118
+ .to eq('artifacts/solaris/puppet6/11')
119
+ end
109
120
 
110
- it 'should be correct for windows' do
111
- expect(Pkg::Paths.artifacts_path('windows-2012-x64')).to eq('artifacts/windows/puppet5')
121
+ it 'should be correct for osx' do
122
+ expect(Pkg::Paths.artifacts_path('osx-10.15-x86_64'))
123
+ .to eq('artifacts/mac/puppet6/10.15/x86_64')
124
+ end
125
+
126
+ it 'should be correct for windows' do
127
+ expect(Pkg::Paths.artifacts_path('windows-2012-x64'))
128
+ .to eq('artifacts/windows/puppet6')
129
+ end
112
130
  end
113
131
 
114
- it 'should work on all current platforms' do
115
- Pkg::Platforms.platform_tags.each do |tag|
116
- expect { Pkg::Paths.artifacts_path(tag) }.not_to raise_error
132
+ context 'after puppet 7 apt changes' do
133
+ before :each do
134
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
135
+ end
136
+
137
+ it 'should be correct for bionic' do
138
+ expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64'))
139
+ .to eq('artifacts/puppet7/bionic')
140
+ end
141
+ it 'should be correct for focal' do
142
+ expect(Pkg::Paths.artifacts_path('ubuntu-20.04-amd64'))
143
+ .to eq('artifacts/puppet7/focal')
117
144
  end
118
145
  end
119
146
  end
120
147
 
121
148
  describe '#repo_path' do
122
149
  before :each do
123
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
150
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
124
151
  end
125
152
 
126
153
  it 'should be correct' do
127
- expect(Pkg::Paths.repo_path('el-7-x86_64')).to eq('repos/puppet5/el/7/x86_64')
154
+ expect(Pkg::Paths.repo_path('el-7-x86_64')).to eq('repos/puppet6/el/7/x86_64')
128
155
  end
129
156
 
130
157
  it 'should work on all current platforms' do
@@ -135,8 +162,16 @@ describe 'Pkg::Paths' do
135
162
  end
136
163
 
137
164
  describe '#repo_config_path' do
138
- it 'should be correct' do
139
- expect(Pkg::Paths.repo_config_path('el-7-x86_64')).to eq('repo_configs/rpm/*el-7-x86_64*.repo')
165
+ it 'should construct rpm/deb-specific repo configs' do
166
+ expect(Pkg::Paths.repo_config_path('el-7-x86_64'))
167
+ .to eq('repo_configs/rpm/*el-7-x86_64*.repo')
168
+ expect(Pkg::Paths.repo_config_path('ubuntu-18.04-amd64'))
169
+ .to eq('repo_configs/deb/*bionic*.list')
170
+ end
171
+
172
+ it 'should raise a RuntimeError with unfamilar repo configs' do
173
+ expect { Pkg::Paths.repo_config_path('bogus') }
174
+ .to raise_error(/Could not verify that 'bogus' is a valid tag/)
140
175
  end
141
176
 
142
177
  it 'should work on all current platforms' do
@@ -148,15 +183,15 @@ describe 'Pkg::Paths' do
148
183
 
149
184
  describe '#apt_repo_name' do
150
185
  it 'should return `Pkg::Config.repo_name` if set' do
151
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
152
- allow(Pkg::Config).to receive(:apt_repo_name).and_return('PC1')
153
- expect(Pkg::Paths.apt_repo_name).to eq('puppet5')
186
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
187
+ allow(Pkg::Config).to receive(:apt_repo_name).and_return('stuff')
188
+ expect(Pkg::Paths.apt_repo_name).to eq('puppet6')
154
189
  end
155
190
 
156
191
  it 'should return `Pkg::Config.apt_repo_name` if `Pkg::Config.repo_name` is not set' do
157
192
  allow(Pkg::Config).to receive(:repo_name).and_return(nil)
158
- allow(Pkg::Config).to receive(:apt_repo_name).and_return('PC1')
159
- expect(Pkg::Paths.apt_repo_name).to eq('PC1')
193
+ allow(Pkg::Config).to receive(:apt_repo_name).and_return('puppet6')
194
+ expect(Pkg::Paths.apt_repo_name).to eq('puppet6')
160
195
  end
161
196
 
162
197
  it 'should return \'main\' if nothing is set' do
@@ -164,14 +199,15 @@ describe 'Pkg::Paths' do
164
199
  allow(Pkg::Config).to receive(:apt_repo_name).and_return(nil)
165
200
  expect(Pkg::Paths.apt_repo_name).to eq('main')
166
201
  end
202
+
167
203
  it 'should return nonfinal_repo_name for nonfinal version' do
168
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
169
- allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet5-nightly')
170
- expect(Pkg::Paths.apt_repo_name(true)).to eq('puppet5-nightly')
204
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
205
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet7-nightly')
206
+ expect(Pkg::Paths.apt_repo_name(true)).to eq('puppet7-nightly')
171
207
  end
172
208
 
173
209
  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('puppet5')
210
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
175
211
  allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
176
212
  expect { Pkg::Paths.apt_repo_name(true) }.to raise_error
177
213
  end
@@ -179,15 +215,15 @@ describe 'Pkg::Paths' do
179
215
 
180
216
  describe '#yum_repo_name' do
181
217
  it 'should return `Pkg::Config.repo_name` if set' do
182
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
183
- allow(Pkg::Config).to receive(:yum_repo_name).and_return('PC1')
184
- expect(Pkg::Paths.yum_repo_name).to eq('puppet5')
218
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
219
+ allow(Pkg::Config).to receive(:yum_repo_name).and_return('stuff')
220
+ expect(Pkg::Paths.yum_repo_name).to eq('puppet6')
185
221
  end
186
222
 
187
223
  it 'should return `Pkg::Config.yum_repo_name` if `Pkg::Config.repo_name` is not set' do
188
224
  allow(Pkg::Config).to receive(:repo_name).and_return(nil)
189
- allow(Pkg::Config).to receive(:yum_repo_name).and_return('PC1')
190
- expect(Pkg::Paths.yum_repo_name).to eq('PC1')
225
+ allow(Pkg::Config).to receive(:yum_repo_name).and_return('puppet7')
226
+ expect(Pkg::Paths.yum_repo_name).to eq('puppet7')
191
227
  end
192
228
 
193
229
  it 'should return \'products\' if nothing is set' do
@@ -197,40 +233,50 @@ describe 'Pkg::Paths' do
197
233
  end
198
234
 
199
235
  it 'should return nonfinal_repo_name for nonfinal version' do
200
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet5')
201
- allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet5-nightly')
202
- expect(Pkg::Paths.yum_repo_name(true)).to eq('puppet5-nightly')
236
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
237
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('puppet7-nightly')
238
+ expect(Pkg::Paths.yum_repo_name(true)).to eq('puppet7-nightly')
203
239
  end
204
240
 
205
241
  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('puppet5')
242
+ allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
207
243
  allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
208
244
  expect { Pkg::Paths.yum_repo_name(true) }.to raise_error
209
245
  end
210
246
  end
211
247
 
212
248
  describe '#remote_repo_base' do
249
+ fake_yum_repo_path = '/fake/yum'
250
+ fake_yum_nightly_repo_path = '/fake/yum-nightly'
251
+ fake_apt_repo_path = '/fake/apt'
252
+ fake_apt_nightly_repo_path = '/fake/apt-nightly'
253
+
213
254
  before :each do
214
- allow(Pkg::Config).to receive(:yum_repo_path).and_return('foo')
215
- allow(Pkg::Config).to receive(:apt_repo_path).and_return('bar')
255
+ allow(Pkg::Config).to receive(:yum_repo_path).and_return(fake_yum_repo_path)
256
+ allow(Pkg::Config).to receive(:apt_repo_path).and_return(fake_apt_repo_path)
216
257
  allow(Pkg::Config).to receive(:dmg_path).and_return('/opt/downloads/mac')
217
- allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return('foo-nightly')
218
- allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return('bar-nightly')
258
+ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(fake_yum_nightly_repo_path)
259
+ allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(fake_apt_nightly_repo_path)
219
260
  end
220
261
  it 'returns yum_repo_path for rpms' do
221
- expect(Pkg::Paths.remote_repo_base('el-7-x86_64')).to eq('foo')
262
+ expect(Pkg::Paths.remote_repo_base('el-7-x86_64'))
263
+ .to eq(fake_yum_repo_path)
222
264
  end
223
265
  it 'returns apt_repo_path for debs' do
224
- expect(Pkg::Paths.remote_repo_base('ubuntu-18.04-amd64')).to eq('bar')
266
+ expect(Pkg::Paths.remote_repo_base('ubuntu-18.04-amd64'))
267
+ .to eq(fake_apt_repo_path)
225
268
  end
226
269
  it 'returns nonfinal_yum_repo_path for nonfinal rpms' do
227
- expect(Pkg::Paths.remote_repo_base('fedora-31-x86_64', nonfinal: true)).to eq('foo-nightly')
270
+ expect(Pkg::Paths.remote_repo_base('fedora-31-x86_64', nonfinal: true))
271
+ .to eq(fake_yum_nightly_repo_path)
228
272
  end
229
273
  it 'returns nonfinal_apt_repo_path for nonfinal debs' do
230
- expect(Pkg::Paths.remote_repo_base('debian-9-amd64', nonfinal: true)).to eq('bar-nightly')
274
+ expect(Pkg::Paths.remote_repo_base('debian-9-amd64', nonfinal: true))
275
+ .to eq(fake_apt_nightly_repo_path)
231
276
  end
232
277
  it 'fails if neither tag nor package_format is provided' do
233
- expect { Pkg::Paths.remote_repo_base }.to raise_error(/Pkg::Paths.remote_repo_base must have/)
278
+ expect { Pkg::Paths.remote_repo_base }
279
+ .to raise_error(/Pkg::Paths.remote_repo_base must have/)
234
280
  end
235
281
 
236
282
  it 'returns /opt/downloads if the path is /opt/downloads/<something>' do
@@ -238,56 +284,127 @@ describe 'Pkg::Paths' do
238
284
  end
239
285
 
240
286
  it 'fails for all other package formats' do
241
- expect { Pkg::Paths.remote_repo_base('solaris-11-i386') }.to raise_error(/Can't determine remote repo base path/)
287
+ expect { Pkg::Paths.remote_repo_base('solaris-11-i386') }
288
+ .to raise_error(/Can't determine remote repo base path/)
242
289
  end
243
290
  end
244
291
 
245
292
  describe '#apt_package_base_path' do
246
293
  it 'fails for non-debian platforms' do
247
- expect { Pkg::Paths.apt_package_base_path('el-7-x86_64', 'puppet6', 'puppet-agent') }.to raise_error(/Can't determine path for non-debian platform/)
294
+ expect { Pkg::Paths.apt_package_base_path('el-7-x86_64', 'puppet6', 'puppet-agent') }
295
+ .to raise_error(/Can't determine path for non-debian platform/)
248
296
  end
249
- it 'returns the approprate apt repo path' do
250
- allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository/apt')
251
- expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6', 'puppet-agent')).to eq('/opt/repository/apt/pool/bionic/puppet6/p/puppet-agent')
252
- expect(Pkg::Paths.apt_package_base_path('debian-9-amd64', 'puppet6', 'razor-server')).to eq('/opt/repository/apt/pool/stretch/puppet6/r/razor-server')
297
+
298
+ context 'for puppet 6 and prior' do
299
+ it 'returns the approprate apt repo path' do
300
+ allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository/apt')
301
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6', 'puppet-agent'))
302
+ .to eq('/opt/repository/apt/pool/bionic/puppet6/p/puppet-agent')
303
+ expect(Pkg::Paths.apt_package_base_path('debian-9-amd64', 'puppet6', 'bolt-server'))
304
+ .to eq('/opt/repository/apt/pool/stretch/puppet6/b/bolt-server')
305
+
306
+
307
+ end
308
+ it 'returns the appropriate nonfinal repo path' do
309
+ allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt')
310
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6-nightly',
311
+ 'puppet-agent', true))
312
+ .to eq('/opt/repository-nightlies/apt/pool/bionic/puppet6-nightly/p/puppet-agent')
313
+ expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'puppet6-nightly',
314
+ 'pdk', true))
315
+ .to eq('/opt/repository-nightlies/apt/pool/buster/puppet6-nightly/p/pdk')
316
+ end
253
317
  end
254
- it 'returns the appropriate nonfinal repo path' do
255
- allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt')
256
- expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6-nightly', 'puppet-agent', true)).to eq('/opt/repository-nightlies/apt/pool/bionic/puppet6-nightly/p/puppet-agent')
257
- expect(Pkg::Paths.apt_package_base_path('debian-9-amd64', 'puppet6-nightly', 'razor-server', true)).to eq('/opt/repository-nightlies/apt/pool/stretch/puppet6-nightly/r/razor-server')
318
+
319
+ context 'for puppet 7 and after' do
320
+ it 'returns the approprate apt repo path' do
321
+ allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository/apt')
322
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet7', 'puppet-agent'))
323
+ .to eq('/opt/repository/apt/puppet7/pool/bionic/p/puppet-agent')
324
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-20.04-amd64', 'puppet7', 'puppet-agent'))
325
+ .to eq('/opt/repository/apt/puppet7/pool/focal/p/puppet-agent')
326
+ end
327
+ it 'returns the appropriate nonfinal repo path' do
328
+ allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt')
329
+ expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'puppet7-nightly', 'pdk', true))
330
+ .to eq('/opt/repository-nightlies/apt/puppet7-nightly/pool/buster/p/pdk')
331
+ end
258
332
  end
259
333
  end
260
334
 
261
335
  describe '#release_package_link_path' do
262
- repo_name = 'puppet6'
263
- nonfinal_repo_name = 'puppet6-nightly'
264
- yum_repo_path = '/opt/repository/yum'
265
- apt_repo_path = '/opt/repository/apt'
266
- nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
267
- nonfinal_apt_repo_path = '/opt/repository-nightlies/apt'
268
- before :each do
269
- allow(Pkg::Config).to receive(:repo_name).and_return(repo_name)
270
- allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nonfinal_repo_name)
271
- allow(Pkg::Config).to receive(:yum_repo_path).and_return(yum_repo_path)
272
- allow(Pkg::Config).to receive(:apt_repo_path).and_return(apt_repo_path)
273
- allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path)
274
- allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path)
275
- end
276
- it 'returns the appropriate link path for rpm release packages' do
277
- expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le')).to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm")
278
- end
279
- it 'returns the appropriate link path for deb release packages' do
280
- expect(Pkg::Paths.release_package_link_path('ubuntu-16.04-amd64')).to eq("#{apt_repo_path}/#{repo_name}-release-xenial.deb")
281
- end
282
- it 'returns the appropriate link path for nonfinal rpm release packages' do
283
- expect(Pkg::Paths.release_package_link_path('el-7-x86_64', true)).to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-7.noarch.rpm")
284
- end
285
- it 'returns the appropriate link path for nonfinal deb release packages' do
286
- expect(Pkg::Paths.release_package_link_path('debian-9-i386', true)).to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-stretch.deb")
336
+ context 'for puppet 6' do
337
+ repo_name = 'puppet6'
338
+ nonfinal_repo_name = 'puppet6-nightly'
339
+ yum_repo_path = '/opt/repository/yum'
340
+ apt_repo_path = '/opt/repository/apt'
341
+ nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
342
+ nonfinal_apt_repo_path = '/opt/repository-nightlies/apt'
343
+ before :each do
344
+ allow(Pkg::Config).to receive(:repo_name).and_return(repo_name)
345
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nonfinal_repo_name)
346
+ allow(Pkg::Config).to receive(:yum_repo_path).and_return(yum_repo_path)
347
+ allow(Pkg::Config).to receive(:apt_repo_path).and_return(apt_repo_path)
348
+ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path)
349
+ allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path)
350
+ end
351
+ it 'returns the appropriate link path for rpm release packages' do
352
+ expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le'))
353
+ .to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm")
354
+ end
355
+ it 'returns the appropriate link path for deb release packages' do
356
+ expect(Pkg::Paths.release_package_link_path('ubuntu-16.04-amd64'))
357
+ .to eq("#{apt_repo_path}/#{repo_name}-release-xenial.deb")
358
+ end
359
+ it 'returns the appropriate link path for nonfinal rpm release packages' do
360
+ expect(Pkg::Paths.release_package_link_path('el-7-x86_64', true))
361
+ .to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-7.noarch.rpm")
362
+ end
363
+ it 'returns the appropriate link path for nonfinal deb release packages' do
364
+ expect(Pkg::Paths.release_package_link_path('debian-9-i386', true))
365
+ .to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-stretch.deb")
366
+ end
367
+ it 'returns nil for package formats that do not have release packages' do
368
+ expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
369
+ expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
370
+ end
287
371
  end
288
- it 'returns nil for package formats that do not have release packages' do
289
- expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
290
- expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
372
+
373
+ context 'for puppet 7' do
374
+ repo_name = 'puppet7'
375
+ nonfinal_repo_name = 'puppet7-nightly'
376
+ yum_repo_path = '/opt/repository/yum'
377
+ apt_repo_path = '/opt/repository/apt'
378
+ nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
379
+ nonfinal_apt_repo_path = '/opt/repository-nightlies/apt'
380
+ before :each do
381
+ allow(Pkg::Config).to receive(:repo_name).and_return(repo_name)
382
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nonfinal_repo_name)
383
+ allow(Pkg::Config).to receive(:yum_repo_path).and_return(yum_repo_path)
384
+ allow(Pkg::Config).to receive(:apt_repo_path).and_return(apt_repo_path)
385
+ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path)
386
+ allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path)
387
+ end
388
+ it 'returns the appropriate link path for rpm release packages' do
389
+ expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le'))
390
+ .to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm")
391
+ end
392
+ it 'returns the appropriate link path for deb release packages' do
393
+ expect(Pkg::Paths.release_package_link_path('ubuntu-20.04-amd64'))
394
+ .to eq("#{apt_repo_path}/#{repo_name}-release-focal.deb")
395
+ end
396
+ it 'returns the appropriate link path for nonfinal rpm release packages' do
397
+ expect(Pkg::Paths.release_package_link_path('el-8-x86_64', true))
398
+ .to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-8.noarch.rpm")
399
+ end
400
+ it 'returns the appropriate link path for nonfinal deb release packages' do
401
+ expect(Pkg::Paths.release_package_link_path('debian-10-i386', true))
402
+ .to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-buster.deb")
403
+ end
404
+ it 'returns nil for package formats that do not have release packages' do
405
+ expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
406
+ expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
407
+ end
291
408
  end
292
409
  end
293
410
  end
@@ -2,88 +2,112 @@ require 'spec_helper'
2
2
 
3
3
  describe '#Pkg::Util::Ship' do
4
4
  describe '#collect_packages' do
5
- msi_pkgs = [
6
- 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
7
- 'pkg/windows/puppet5/puppet-agent-x86.msi',
8
- 'pkg/windowsfips/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x64.msi',
9
- 'pkg/windowsfips/puppet5/puppet-agent-x64.msi'
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
- swix_pkgs = [
12
- 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
13
- 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
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/**/*.swix*').and_return(swix_pkgs)
18
- expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.swix*'])).to eq(swix_pkgs)
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
- describe 'define excludes' do
22
+ context 'excluding packages' do
22
23
  before :each do
23
- allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_pkgs)
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'])).not_to include('pkg/windows/puppet5/puppet-agent-x86.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'], ['puppet-agent-x(86|64).msi'])).to \
30
- match_array(
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 'fails when it cannot find any packages at all' do
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
- local_pkgs = [
46
- 'pkg/deb/stretch/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1stretch_i386.deb',
47
- 'pkg/el/5/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
48
- 'pkg/sles/11/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
49
- 'pkg/sles/12/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.sles12.x86_64.rpm',
50
- 'pkg/mac/10.15/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.15.dmg',
51
- 'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
52
- 'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
53
- 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
54
- ]
55
- new_pkgs = [
56
- 'pkg/stretch/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1stretch_i386.deb',
57
- 'pkg/puppet5/el/5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
58
- 'pkg/puppet5/sles/11/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
59
- 'pkg/puppet5/sles/12/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.sles12.x86_64.rpm',
60
- 'pkg/mac/puppet5/10.15/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.15.dmg',
61
- 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
62
- 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
63
- 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
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
- tmpdir = Dir.mktmpdir
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('puppet5')
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
- it 'makes a temporary directory' do
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
- orig = local_pkgs
81
- Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
82
- expect(local_pkgs).to eq(orig)
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 packages that do not have the temp dir in the path' do
86
- expect(Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)).to eq(new_pkgs)
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).to receive(:collect_packages).and_return(local_pkgs)
96
- allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return(new_pkgs)
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).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/).exactly(local_pkgs.count).times
101
- expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything).exactly(local_pkgs.count).times
102
- expect(Pkg::Util::Net).to receive(:remote_set_ownership).with(test_staging_server, 'root', 'release', anything).exactly(local_pkgs.count).times
103
- expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything).exactly(local_pkgs.count).times
104
- expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything).exactly(local_pkgs.count).times
105
- expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything).exactly(local_pkgs.count).times
106
- expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path)).to eq(true)
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
- allow(Pkg::Util::Ship).to receive(:collect_packages).and_return(['pkg/el/5/puppet5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm' ])
111
- allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return(['pkg/puppet5/el/5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm'])
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).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/)
117
- expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything)
118
- expect(Pkg::Util::Net).to receive(:remote_set_ownership).with(test_staging_server, 'root', 'release', ['/opt/repository/yum/puppet5/el/5/x86_64', '/opt/repository/yum/puppet5/el/5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm'])
119
- expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything)
120
- expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything)
121
- expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything)
122
- expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path, excludes: ['puppet-agent'])).to eq(true)
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'], test_staging_server, test_remote_path)).to eq(false)
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.71
4
+ version: 0.99.72
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-10-02 00:00:00.000000000 Z
11
+ date: 2020-10-27 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/packaging/artifactory_spec.rb
263
- - spec/lib/packaging/sign_spec.rb
264
- - spec/lib/packaging/platforms_spec.rb
265
- - spec/lib/packaging/rpm/repo_spec.rb
266
- - spec/lib/packaging/repo_spec.rb
267
- - spec/lib/packaging/config_spec.rb
268
- - spec/lib/packaging/gem_spec.rb
262
+ - spec/lib/packaging_spec.rb
263
+ - spec/lib/packaging/paths_spec.rb
269
264
  - spec/lib/packaging/util/execution_spec.rb
270
- - spec/lib/packaging/util/gpg_spec.rb
271
- - spec/lib/packaging/util/git_spec.rb
272
265
  - spec/lib/packaging/util/jenkins_spec.rb
273
- - spec/lib/packaging/util/rake_utils_spec.rb
274
- - spec/lib/packaging/util/net_spec.rb
266
+ - spec/lib/packaging/util/gpg_spec.rb
275
267
  - spec/lib/packaging/util/git_tag_spec.rb
268
+ - spec/lib/packaging/util/git_spec.rb
276
269
  - spec/lib/packaging/util/misc_spec.rb
270
+ - spec/lib/packaging/util/rake_utils_spec.rb
277
271
  - spec/lib/packaging/util/ship_spec.rb
272
+ - spec/lib/packaging/util/net_spec.rb
278
273
  - spec/lib/packaging/util/file_spec.rb
279
- - spec/lib/packaging/util/version_spec.rb
280
274
  - spec/lib/packaging/util/os_spec.rb
281
- - spec/lib/packaging/paths_spec.rb
282
- - spec/lib/packaging/deb_spec.rb
283
- - spec/lib/packaging/retrieve_spec.rb
275
+ - spec/lib/packaging/util/version_spec.rb
276
+ - spec/lib/packaging/config_spec.rb
284
277
  - spec/lib/packaging/tar_spec.rb
278
+ - spec/lib/packaging/platforms_spec.rb
279
+ - spec/lib/packaging/rpm/repo_spec.rb
280
+ - spec/lib/packaging/retrieve_spec.rb
281
+ - spec/lib/packaging/artifactory_spec.rb
282
+ - spec/lib/packaging/gem_spec.rb
285
283
  - spec/lib/packaging/deb/repo_spec.rb
286
- - spec/lib/packaging_spec.rb
284
+ - spec/lib/packaging/repo_spec.rb
285
+ - spec/lib/packaging/sign_spec.rb
286
+ - spec/lib/packaging/deb_spec.rb