packaging 0.99.72 → 0.99.77

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,14 +15,14 @@ module Pkg::Sign::Ips
15
15
  repo_dir = "#{work_dir}/repo"
16
16
  signed_dir = "#{work_dir}/pkgs"
17
17
 
18
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "mkdir -p #{repo_dir} #{unsigned_dir} #{signed_dir}")
18
+ Pkg::Util::Net.remote_execute(ssh_host_string, "mkdir -p #{repo_dir} #{unsigned_dir} #{signed_dir}")
19
19
  Pkg::Util::Net.rsync_to(p5p, rsync_host_string, unsigned_dir)
20
20
 
21
21
  # Before we can get started with signing packages we need to create a repo
22
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "sudo -E /usr/bin/pkgrepo create #{repo_dir}")
23
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "sudo -E /usr/bin/pkgrepo set -s #{repo_dir} publisher/prefix=puppetlabs.com")
22
+ Pkg::Util::Net.remote_execute(ssh_host_string, "sudo -E /usr/bin/pkgrepo create #{repo_dir}")
23
+ Pkg::Util::Net.remote_execute(ssh_host_string, "sudo -E /usr/bin/pkgrepo set -s #{repo_dir} publisher/prefix=puppetlabs.com")
24
24
  # And import all the packages into the repo.
25
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "sudo -E /usr/bin/pkgrecv -s #{unsigned_dir}/#{File.basename(p5p)} -d #{repo_dir} '*'")
25
+ Pkg::Util::Net.remote_execute(ssh_host_string, "sudo -E /usr/bin/pkgrecv -s #{unsigned_dir}/#{File.basename(p5p)} -d #{repo_dir} '*'")
26
26
  # We are going to hard code the values for signing cert locations for now.
27
27
  # This autmation will require an update to actually become reusable, but
28
28
  # for now these values will stay this way so solaris signing will stop
@@ -37,21 +37,21 @@ module Pkg::Sign::Ips
37
37
  -k /root/signing/signing_key_2020.pem \
38
38
  -s 'file://#{work_dir}/repo' '*'"
39
39
  puts "About to sign #{p5p} with #{sign_cmd} in #{work_dir}"
40
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, sign_cmd.squeeze(' '))
40
+ Pkg::Util::Net.remote_execute(ssh_host_string, sign_cmd.squeeze(' '))
41
41
  # pkgrecv with -a will pull packages out of the repo, so we need to do that too to actually get the packages we signed
42
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "sudo -E /usr/bin/pkgrecv -d #{signed_dir}/#{File.basename(p5p)} -a -s #{repo_dir} '*'")
42
+ Pkg::Util::Net.remote_execute(ssh_host_string, "sudo -E /usr/bin/pkgrecv -d #{signed_dir}/#{File.basename(p5p)} -a -s #{repo_dir} '*'")
43
43
  begin
44
44
  # lets make sure we actually signed something?
45
45
  # **NOTE** if we're repeatedly trying to sign the same version this
46
46
  # might explode because I don't know how to reset the IPS cache.
47
47
  # Everything is amazing.
48
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "sudo -E /usr/bin/pkg contents -m -g #{signed_dir}/#{File.basename(p5p)} '*' | grep '^signature '")
48
+ Pkg::Util::Net.remote_execute(ssh_host_string, "sudo -E /usr/bin/pkg contents -m -g #{signed_dir}/#{File.basename(p5p)} '*' | grep '^signature '")
49
49
  rescue RuntimeError
50
50
  raise "Looks like #{File.basename(p5p)} was not signed correctly, quitting!"
51
51
  end
52
52
  # and pull the packages back.
53
53
  Pkg::Util::Net.rsync_from("#{signed_dir}/#{File.basename(p5p)}", rsync_host_string, File.dirname(p5p))
54
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "if [ -e '#{work_dir}' ] ; then sudo rm -r '#{work_dir}' ; fi")
54
+ Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -e '#{work_dir}' ] ; then sudo rm -r '#{work_dir}' ; fi")
55
55
  end
56
56
  end
57
57
  end
@@ -8,7 +8,7 @@ module Pkg::Sign::Msi
8
8
  rsync_host_string = "-e 'ssh #{use_identity}' Administrator@#{Pkg::Config.msi_signing_server}"
9
9
 
10
10
  work_dir = "Windows/Temp/#{Pkg::Util.rand_string}"
11
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "mkdir -p C:/#{work_dir}")
11
+ Pkg::Util::Net.remote_execute(ssh_host_string, "mkdir -p C:/#{work_dir}")
12
12
  msis = Dir.glob("#{target_dir}/windows*/**/*.msi")
13
13
  Pkg::Util::Net.rsync_to(msis.join(" "), rsync_host_string, "/cygdrive/c/#{work_dir}",
14
14
  extra_flags: ["--ignore-existing --relative"])
@@ -71,9 +71,8 @@ for msipath in #{msis.join(" ")}; do
71
71
  echo "$msi is already signed, skipping . . ." ;
72
72
  else
73
73
  tries=5
74
- sha1Servers=(http://timestamp.verisign.com/scripts/timstamp.dll
75
- http://timestamp.globalsign.com/scripts/timstamp.dll
76
- http://www.startssl.com/timestamp)
74
+ sha1Servers=(http://timestamp.digicert.com/sha1/timestamp
75
+ http://timestamp.comodoca.com/authenticode)
77
76
  for timeserver in "${sha1Servers[@]}"; do
78
77
  for ((try=1; try<=$tries; try++)) do
79
78
  ret=$(/cygdrive/c/tools/osslsigncode-fork/osslsigncode.exe sign \
@@ -112,10 +111,14 @@ for msipath in #{msis.join(" ")}; do
112
111
  done
113
112
  CMD
114
113
 
115
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, sign_command, false, '', false)
114
+ Pkg::Util::Net.remote_execute(
115
+ ssh_host_string,
116
+ sign_command,
117
+ { fail_fast: false }
118
+ )
116
119
  msis.each do | msi |
117
120
  Pkg::Util::Net.rsync_from("/cygdrive/c/#{work_dir}/#{msi}", rsync_host_string, File.dirname(msi))
118
121
  end
119
- Pkg::Util::Net.remote_ssh_cmd(ssh_host_string, "if [ -d '/cygdrive/c/#{work_dir}' ]; then rm -rf '/cygdrive/c/#{work_dir}'; fi")
122
+ Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -d '/cygdrive/c/#{work_dir}' ]; then rm -rf '/cygdrive/c/#{work_dir}'; fi")
120
123
  end
121
124
  end
@@ -20,13 +20,11 @@ module Pkg::Util::Net
20
20
  end
21
21
 
22
22
  # Check that the current host matches the one we think it should
23
- def check_host(host, args = { :required => true })
24
- if hostname == host
25
- return true
26
- else
27
- fail "#{hostname} does not match #{host}" if args[:required]
28
- return nil
29
- end
23
+ def check_host(host, options = { required: true })
24
+ return true if hostname == host
25
+
26
+ fail "Error: #{hostname} does not match #{host}" if options[:required]
27
+ return nil
30
28
  end
31
29
 
32
30
  # @param hosts - An array of hosts to try ssh-ing into
@@ -38,7 +36,7 @@ module Pkg::Util::Net
38
36
  errs = []
39
37
  Array(hosts).flatten.each do |host|
40
38
  begin
41
- remote_ssh_cmd(host, 'exit', false, '-oBatchMode=yes')
39
+ remote_execute(host, 'exit', { extra_options: '-oBatchMode=yes' })
42
40
  rescue
43
41
  errs << host
44
42
  end
@@ -56,7 +54,8 @@ module Pkg::Util::Net
56
54
  errs = []
57
55
  Array(hosts).flatten.each do |host|
58
56
  begin
59
- remote_ssh_cmd(host, "gpg --list-secret-keys #{gpg} > /dev/null 2&>1", false, '-oBatchMode=yes')
57
+ remote_execute(host, "gpg --list-secret-keys #{gpg} > /dev/null 2&>1",
58
+ { extra_options: '-oBatchMode=yes' })
60
59
  rescue
61
60
  errs << host
62
61
  end
@@ -64,40 +63,62 @@ module Pkg::Util::Net
64
63
  return errs
65
64
  end
66
65
 
67
- def remote_ssh_cmd(target, command, capture_output = false, extra_options = '', fail_fast = true, trace = false) # rubocop:disable Style/ParameterLists
66
+ def remote_execute(target_host, command, user_options = {})
67
+ option_defaults = {
68
+ capture_output: false,
69
+ extra_options: '',
70
+ fail_fast: true,
71
+ trace: false
72
+ }
73
+ options = option_defaults.merge(user_options)
68
74
 
69
75
  ssh = Pkg::Util::Tool.check_tool('ssh')
70
76
 
71
77
  # we pass some pretty complicated commands in via ssh. We need this to fail
72
78
  # if any part of the remote ssh command fails.
73
79
  shell_flags = ''
74
- shell_flags += 'set -e;' if fail_fast
75
- shell_flags += 'set -x;' if trace
80
+ shell_flags += 'set -e;' if options[:fail_fast]
81
+ shell_flags += 'set -x;' if options[:trace]
76
82
  shell_commands = "#{shell_flags}#{command}"
77
83
 
78
- cmd = "#{ssh} #{extra_options} -t #{target} '#{shell_commands.gsub("'", "'\\\\''")}'"
84
+ remote_command = "#{ssh} #{options[:extra_options]} -t #{target_host} " +
85
+ "'#{shell_commands.gsub("'", "'\\\\''")}'"
79
86
 
80
87
  # This is NOT a good way to support this functionality.
81
- # It needs to be refactored into a set of methods that
82
- # other methods can use to safely and deterministically
83
- # support dry-run operations.
84
- # But I need to ship packages RIGHT NOW.
85
- # - Ryan McKern, 13/01/2016
86
88
  if ENV['DRYRUN']
87
89
  puts "[DRY-RUN] Executing '#{command}' on #{target}"
88
90
  puts "[DRY-RUN] #{cmd}"
89
- return
91
+ return ''
90
92
  end
91
93
 
92
- puts "Executing '#{command}' on #{target}"
93
- if capture_output
94
- stdout, stderr, exitstatus = Pkg::Util::Execution.capture3(cmd)
95
- Pkg::Util::Execution.success?(exitstatus) or raise "Remote ssh command failed."
94
+ # We're forced to make different calls depending on the capture_output option
95
+ # because something about our #capture3 method screws up gpg. This should
96
+ # be untangled.
97
+ if options[:capture_output]
98
+ stdout, stderr, exitstatus = Pkg::Util::Execution.capture3(remote_command)
99
+ Pkg::Util::Execution.success?(exitstatus) or
100
+ raise "Remote ssh command (\"#{remote_command}\") failed."
96
101
  return stdout, stderr
97
- else
98
- Kernel.system(cmd)
99
- Pkg::Util::Execution.success? or raise "Remote ssh command failed."
100
102
  end
103
+
104
+ # Pkg::Util::Execution.capture3 reports its command but Kernel.system does not
105
+ # Let's print it out for some amount of consistency.
106
+ puts "Remote Execute: '#{remote_command}'"
107
+ Kernel.system(remote_command)
108
+ Pkg::Util::Execution.success? or
109
+ raise "Remote ssh command (\"#{remote_command}\") failed."
110
+ end
111
+
112
+ ###
113
+ ### Deprecated method implemented as a shim to the new `remote_execute` method
114
+ ###
115
+ def remote_ssh_cmd(target, command, capture_output = false, extra_options = '', fail_fast = true, trace = false) # rubocop:disable Style/ParameterLists
116
+ puts "Warn: \"remote_ssh_cmd\" call in packaging is deprecated. Use \"remote_execute\" instead."
117
+ remote_execute(target, command, {
118
+ capture_output: capture_output,
119
+ extra_options: extra_options,
120
+ fail_fast: fail_fast,
121
+ trace: trace })
101
122
  end
102
123
 
103
124
  # Construct a valid rsync command
@@ -272,17 +293,17 @@ module Pkg::Util::Net
272
293
 
273
294
  def remote_set_ownership(host, owner, group, files)
274
295
  remote_cmd = "for file in #{files.join(" ")}; do if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then sudo chown #{owner}:#{group} $file; else echo \"$file is immutable\"; fi; done"
275
- Pkg::Util::Net.remote_ssh_cmd(host, remote_cmd)
296
+ Pkg::Util::Net.remote_execute(host, remote_cmd)
276
297
  end
277
298
 
278
299
  def remote_set_permissions(host, permissions, files)
279
300
  remote_cmd = "for file in #{files.join(" ")}; do if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then sudo chmod #{permissions} $file; else echo \"$file is immutable\"; fi; done"
280
- Pkg::Util::Net.remote_ssh_cmd(host, remote_cmd)
301
+ Pkg::Util::Net.remote_execute(host, remote_cmd)
281
302
  end
282
303
 
283
304
  # Remotely set the immutable bit on a list of files
284
305
  def remote_set_immutable(host, files)
285
- Pkg::Util::Net.remote_ssh_cmd(host, "sudo chattr +i #{files.join(" ")}")
306
+ Pkg::Util::Net.remote_execute(host, "sudo chattr +i #{files.join(" ")}")
286
307
  end
287
308
 
288
309
  # Create a symlink indicating the latest version of a package
@@ -328,7 +349,8 @@ module Pkg::Util::Net
328
349
  ln -sf "$link_target" #{full_package_name}-latest.#{platform_ext}
329
350
  CMD
330
351
 
331
- _, err = Pkg::Util::Net.remote_ssh_cmd(Pkg::Config.staging_server, cmd, true)
352
+ _, err = Pkg::Util::Net.remote_execute(
353
+ Pkg::Config.staging_server, cmd, { capture_output: true })
332
354
  $stderr.puts err
333
355
  end
334
356
 
@@ -365,14 +387,14 @@ module Pkg::Util::Net
365
387
  #{tar} -zxvf /tmp/#{tarball_name}.tar.gz -C /tmp/ ;
366
388
  git clone --recursive /tmp/#{tarball_name} #{git_bundle_directory} ;
367
389
  DOC
368
- Pkg::Util::Net.remote_ssh_cmd(host, command)
390
+ Pkg::Util::Net.remote_execute(host, command)
369
391
  return git_bundle_directory
370
392
  end
371
393
 
372
394
  def remote_bundle_install_command
373
395
  export_packaging_location = ''
374
396
  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.4.1; #{export_packaging_location} bundle install --path .bundle/gems ;"
397
+ command = "source /usr/local/rvm/scripts/rvm; rvm use ruby-2.5.1; #{export_packaging_location} bundle install --path .bundle/gems ;"
376
398
  end
377
399
 
378
400
  # Given a BuildInstance object and a host, send its params to the host. Return
@@ -86,7 +86,7 @@ module Pkg::Util::Ship
86
86
  sub_string = 'pkg'
87
87
  remote_pkg = pkg.sub(sub_string, remote_path)
88
88
  remote_basepath = File.dirname(remote_pkg)
89
- Pkg::Util::Net.remote_ssh_cmd(staging_server, "mkdir -p #{remote_basepath}")
89
+ Pkg::Util::Net.remote_execute(staging_server, "mkdir -p #{remote_basepath}")
90
90
  Pkg::Util::Net.rsync_to(
91
91
  File.join(tmpdir, pkg),
92
92
  staging_server,
@@ -202,7 +202,7 @@ module Pkg::Util::Ship
202
202
  def create_rolling_repo_link(platform_tag, staging_server, repo_path, nonfinal = false)
203
203
  command = rolling_repo_link_command(platform_tag, repo_path, nonfinal)
204
204
 
205
- Pkg::Util::Net.remote_ssh_cmd(staging_server, command) unless command.nil?
205
+ Pkg::Util::Net.remote_execute(staging_server, command) unless command.nil?
206
206
  rescue => e
207
207
  fail "Failed to create rolling repo link for '#{platform_tag}'.\n#{e}\n#{e.backtrace}"
208
208
  end
@@ -265,13 +265,13 @@ module Pkg::Util::Ship
265
265
  fi
266
266
  ln -sf #{remote_path} #{link_path}
267
267
  CMD
268
- Pkg::Util::Net.remote_ssh_cmd(Pkg::Config.staging_server, link_command)
268
+ Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, link_command)
269
269
  end
270
270
  end
271
271
 
272
272
  def test_ship(vm, ship_task)
273
273
  command = 'getent group release || groupadd release'
274
- Pkg::Util::Net.remote_ssh_cmd(vm, command)
274
+ Pkg::Util::Net.remote_execute(vm, command)
275
275
  hosts_to_override = %w(
276
276
  APT_HOST
277
277
  DMG_HOST
@@ -36,16 +36,16 @@ describe 'artifactory.rb' do
36
36
  :repo_config => '',
37
37
  :additional_artifacts => ["./windowsfips/puppet-agent-extras-5.3.1.34-x64.msi"],
38
38
  },
39
- 'eos-4-i386' => {
40
- :artifact => "./eos/4/PC1/i386/puppet-agent-5.3.1.34.gf65f9ef-1.eos4.i386.swix",
41
- :repo_config => '',
42
- :additional_artifacts => ["./eos/4/PC1/i386/puppet-agent-extras-5.3.1.34.gf65f9ef-1.eos4.i386.swix"],
43
- },
44
39
  'osx-10.15-x86_64' => {
45
40
  :artifact => "./apple/10.15/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg",
46
41
  :repo_config => '',
47
42
  :additional_artifacts => ["./apple/10.15/PC1/x86_64/puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg"],
48
43
  },
44
+ 'osx-11-x86_64' => {
45
+ :artifact => "./apple/11/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg",
46
+ :repo_config => '',
47
+ :additional_artifacts => ["./apple/11/PC1/x86_64/puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg"],
48
+ },
49
49
  'solaris-10-sparc' => {
50
50
  :artifact => "./solaris/10/PC1/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz",
51
51
  :repo_config => '',
@@ -89,18 +89,18 @@ describe 'artifactory.rb' do
89
89
  :package_name => 'path/to/a/windowsfips/package/puppet-agent-5.3.1.34-x64.msi',
90
90
  :all_package_names => ['puppet-agent-5.3.1.34-x64.msi','puppet-agent-extras-5.3.1.34-x64.msi']
91
91
  },
92
- 'eos-4-i386' => {
93
- :toplevel_repo => 'generic',
94
- :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/eos-4-i386",
95
- :package_name => 'path/to/an/eos/4/package/puppet-agent-5.3.1.34.gf65f9ef-1.eos4.i386.swix',
96
- :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.eos4.i386.swix', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.eos4.i386.swix']
97
- },
98
92
  'osx-10.15-x86_64' => {
99
93
  :toplevel_repo => 'generic',
100
94
  :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-10.15-x86_64",
101
95
  :package_name => 'path/to/an/osx/10.15/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg',
102
96
  :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg']
103
97
  },
98
+ 'osx-11-x86_64' => {
99
+ :toplevel_repo => 'generic',
100
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-11-x86_64",
101
+ :package_name => 'path/to/an/osx/11/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg',
102
+ :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg']
103
+ },
104
104
  'solaris-10-sparc' => {
105
105
  :toplevel_repo => 'generic',
106
106
  :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/solaris-10-sparc",
@@ -202,9 +202,8 @@ describe "Pkg::Config" do
202
202
 
203
203
  describe "#platform_data" do
204
204
  platform_tags = [
205
- 'eos-4-i386',
206
205
  'osx-10.15-x86_64',
207
- 'cisco-wrlinux-7-x86_64',
206
+ 'osx-11-x86_64',
208
207
  'ubuntu-16.04-i386',
209
208
  'el-6-x86_64',
210
209
  'el-7-ppc64le',
@@ -212,16 +211,15 @@ describe "Pkg::Config" do
212
211
  ]
213
212
 
214
213
  artifacts = \
215
- "./artifacts/eos/4/PC1/i386/puppet-agent-5.3.2-1.eos4.i386.swix\n" \
216
214
  "./artifacts/apple/10.15/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx10.15.dmg\n" \
217
- "./artifacts/cisco-wrlinux/7/PC1/x86_64/puppet-agent-5.3.2-1.cisco_wrlinux7.x86_64.rpm\n" \
215
+ "./artifacts/apple/11/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx11.dmg\n" \
218
216
  "./artifacts/deb/xenial/PC1/puppet-agent_5.3.2-1xenial_i386.deb\n" \
219
217
  "./artifacts/el/6/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.el6.x86_64.rpm\n" \
220
218
  "./artifacts/el/7/PC1/ppc64le/puppet-agent-5.3.2-1.el7.ppc64le.rpm\n" \
221
219
  "./artifacts/sles/12/PC1/x86_64/puppet-agent-5.3.2-1.sles12.x86_64.rpm"
222
220
 
223
221
  aix_artifacts = \
224
- "./artifacts/aix/6.1/PC1/ppc/puppet-agent-5.3.2-1.aix6.1.ppc.rpm"
222
+ "./artifacts/aix/7.1/PC1/ppc/puppet-agent-5.3.2-1.aix7.1.ppc.rpm"
225
223
 
226
224
  fedora_artifacts = \
227
225
  "./artifacts/fedora/31/PC1/x86_64/puppet-agent-5.3.2-1.fc31.x86_64.rpm"
@@ -259,7 +257,7 @@ describe "Pkg::Config" do
259
257
  end
260
258
 
261
259
  it "should return a hash mapping platform tags to paths" do
262
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(artifacts, nil)
260
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(artifacts, nil)
263
261
  expect(Pkg::Config.platform_data.keys).to eql(platform_tags)
264
262
  end
265
263
 
@@ -279,21 +277,21 @@ describe "Pkg::Config" do
279
277
  end
280
278
 
281
279
  it "should not use 'f' in fedora platform tags" do
282
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(fedora_artifacts, nil)
280
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(fedora_artifacts, nil)
283
281
  data = Pkg::Config.platform_data
284
282
  expect(data).to include('fedora-31-x86_64')
285
283
  expect(data).not_to include('fedora-f31-x86_64')
286
284
  end
287
285
 
288
286
  it "should collect packages whose extname differ from package_format" do
289
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(solaris_artifacts, nil)
287
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(solaris_artifacts, nil)
290
288
  data = Pkg::Config.platform_data
291
289
  expect(data).to include('solaris-10-i386' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz', :repo_config => nil})
292
290
  expect(data).to include('solaris-11-sparc' => {:artifact => './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p', :repo_config => nil})
293
291
  end
294
292
 
295
293
  it "should collect versioned msis" do
296
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(windows_artifacts, nil)
294
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(windows_artifacts, nil)
297
295
  data = Pkg::Config.platform_data
298
296
  expect(data['windows-2012-x86']).to include(:artifact => './windows/puppet-agent-5.3.2-x86.msi')
299
297
  expect(data['windows-2012-x64']).to include(:artifact => './windows/puppet-agent-5.3.2-x64.msi')
@@ -301,13 +299,13 @@ describe "Pkg::Config" do
301
299
  end
302
300
 
303
301
  it "should not collect debug packages" do
304
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(stretch_artifacts, nil)
302
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(stretch_artifacts, nil)
305
303
  data = Pkg::Config.platform_data
306
304
  expect(data['debian-9-amd64']).to include(:artifact => './deb/stretch/PC1/puppet-agent_5.3.2.658.gc79ef9a-1stretch_amd64.deb')
307
305
  end
308
306
 
309
307
  it "should collect packages that don't match the project name" do
310
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(artifacts_not_matching_project, nil)
308
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(artifacts_not_matching_project, nil)
311
309
  data = Pkg::Config.platform_data
312
310
  expect(data['ubuntu-16.04-amd64']).to include(:artifact => './deb/xenial/pe-postgresql-contrib_2019.1.9.6.12-1xenial_amd64.deb')
313
311
  expect(data['ubuntu-16.04-amd64'][:additional_artifacts].size).to eq(3)
@@ -317,15 +315,15 @@ describe "Pkg::Config" do
317
315
  end
318
316
 
319
317
  it "should use 'ppc' instead of 'power' in aix paths" do
320
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(aix_artifacts, nil)
318
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
321
319
  data = Pkg::Config.platform_data
322
- expect(data['aix-6.1-power']).to include(:artifact => './aix/6.1/PC1/ppc/puppet-agent-5.3.2-1.aix6.1.ppc.rpm')
320
+ expect(data['aix-7.1-power']).to include(:artifact => './aix/7.1/PC1/ppc/puppet-agent-5.3.2-1.aix7.1.ppc.rpm')
323
321
  end
324
322
 
325
323
  it "should not record an aix repo config" do
326
- allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(aix_artifacts, nil)
324
+ allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
327
325
  data = Pkg::Config.platform_data
328
- expect(data['aix-6.1-power'][:repo_config]).to be_nil
326
+ expect(data['aix-7.1-power'][:repo_config]).to be_nil
329
327
  end
330
328
  end
331
329
 
@@ -92,10 +92,10 @@ describe "Pkg::Deb::Repo" do
92
92
  Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories)
93
93
  Pkg::Repo.should_receive(:populate_repo_directory)
94
94
  Pkg::Deb::Repo.should_receive(:repo_creation_command).and_return(command)
95
- Pkg::Util::Net.should_receive(:remote_ssh_cmd).with(Pkg::Config.distribution_server, command)
95
+ Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command)
96
96
  Pkg::Deb::Repo.should_receive(:generate_repo_configs)
97
97
  Pkg::Deb::Repo.should_receive(:ship_repo_configs)
98
- Pkg::Util::Net.should_receive(:remote_ssh_cmd).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
98
+ Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
99
99
  Pkg::Deb::Repo.create_repos
100
100
  end
101
101
  end
@@ -115,7 +115,7 @@ describe "Pkg::Deb::Repo" do
115
115
  repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/deb"
116
116
  Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/deb").and_return(false)
117
117
  Pkg::Util::RakeUtils.should_receive(:invoke_task).with("pl:fetch")
118
- Pkg::Util::Net.should_receive(:remote_ssh_cmd).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
118
+ Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
119
119
  Pkg::Util::Execution.should_receive(:retry_on_fail).with(:times => 3)
120
120
  Pkg::Deb::Repo.ship_repo_configs
121
121
  end
@@ -3,10 +3,11 @@ 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/puppet6/ppc/puppet-agent-6.9.0-1.aix6.1.ppc.rpm', 'aix', '6.1'] => 'power',
7
6
  ['pkg/el-8-x86_64/puppet-agent-6.9.0-1.el8.x86_64.rpm', 'el', '8'] => 'x86_64',
7
+ ['pkg/el/8/puppet6/aarch64/puppet-agent-6.5.0.3094.g16b6fa6f-1.el8.aarch64.rpm', 'el', '8'] => 'aarch64',
8
8
  ['artifacts/fedora/32/puppet6/x86_64/puppet-agent-6.9.0-1.fc30.x86_64.rpm', 'fedora', '32'] => 'x86_64',
9
9
  ['pkg/ubuntu-16.04-amd64/puppet-agent_4.99.0-1xenial_amd64.deb', 'ubuntu', '16.04'] => 'amd64',
10
+ ['artifacts/deb/focal/puppet6/puppet-agent_6.5.0.3094.g16b6fa6f-1focal_arm64.deb', 'ubuntu', '20.04'] => 'aarch64',
10
11
 
11
12
  ['artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz', 'ubuntu', '16.04'] => 'source',
12
13
  ['artifacts/deb/jessie/PC1/puppetserver_5.0.1.master.orig.tar.gz', 'debian', '8'] => 'source',
@@ -22,7 +23,6 @@ describe 'Pkg::Paths' do
22
23
 
23
24
  describe '#tag_from_artifact_path' do
24
25
  path_tranformations = {
25
- 'artifacts/aix/6.1/puppet6/ppc/puppet-agent-6.9.0-1.aix6.1.ppc.rpm' => 'aix-6.1-power',
26
26
  'pkg/el-7-x86_64/puppet-agent-5.5.22-1.el8.x86_64.rpm' => 'el-7-x86_64',
27
27
  'pkg/ubuntu-20.04-amd64/puppet-agent_5.5.22-1xenial_amd64.deb' => 'ubuntu-20.04-amd64',
28
28
  'pkg/windows/puppet-agent-5.5.22-x86.msi' => 'windows-2012-x86',
@@ -33,6 +33,7 @@ describe 'Pkg::Paths' do
33
33
  'pkg/pe/deb/bionic/pe-puppetserver_2019.8.2.32-1bionic_all.deb' => 'ubuntu-18.04-amd64',
34
34
  'artifacts/deb/focal/puppet6/puppetdb_6.13.0-1focal_all.deb' => 'ubuntu-20.04-amd64',
35
35
  'pkg/apple/10.15/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg' => 'osx-10.15-x86_64',
36
+ 'pkg/apple/11/puppet6/x86_64/puppet-agent-6.19.0-1.osx11.dmg' => 'osx-11-x86_64',
36
37
  'pkg/windows/puppet-agent-1.9.0-x86.msi' => 'windows-2012-x86',
37
38
  'pkg/pe/rpm/el-6-i386/pe-puppetserver-2017.3.0.3-1.el6.src.rpm' => 'el-6-SRPMS',
38
39
  'pkg/pe/deb/xenial/pe-puppetserver_2017.3.0.3-1puppet1.orig.tar.gz' => 'ubuntu-16.04-source',
@@ -64,8 +65,8 @@ describe 'Pkg::Paths' do
64
65
  end
65
66
 
66
67
  it 'should return repo_name for final version' do
67
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
68
- expect(Pkg::Paths.repo_name).to eq('puppet7')
68
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
69
+ expect(Pkg::Paths.repo_name).to eq('FUTURE-puppet7')
69
70
  end
70
71
 
71
72
  it 'should be empty string if repo_name is not set for final version' do
@@ -123,6 +124,11 @@ describe 'Pkg::Paths' do
123
124
  .to eq('artifacts/mac/puppet6/10.15/x86_64')
124
125
  end
125
126
 
127
+ it 'should be correct for osx11' do
128
+ expect(Pkg::Paths.artifacts_path('osx-11-x86_64'))
129
+ .to eq('artifacts/mac/puppet6/11/x86_64')
130
+ end
131
+
126
132
  it 'should be correct for windows' do
127
133
  expect(Pkg::Paths.artifacts_path('windows-2012-x64'))
128
134
  .to eq('artifacts/windows/puppet6')
@@ -131,16 +137,16 @@ describe 'Pkg::Paths' do
131
137
 
132
138
  context 'after puppet 7 apt changes' do
133
139
  before :each do
134
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
140
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
135
141
  end
136
142
 
137
143
  it 'should be correct for bionic' do
138
144
  expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64'))
139
- .to eq('artifacts/puppet7/bionic')
145
+ .to eq('artifacts/FUTURE-puppet7/bionic')
140
146
  end
141
147
  it 'should be correct for focal' do
142
148
  expect(Pkg::Paths.artifacts_path('ubuntu-20.04-amd64'))
143
- .to eq('artifacts/puppet7/focal')
149
+ .to eq('artifacts/FUTURE-puppet7/focal')
144
150
  end
145
151
  end
146
152
  end
@@ -201,13 +207,13 @@ describe 'Pkg::Paths' do
201
207
  end
202
208
 
203
209
  it 'should return nonfinal_repo_name for nonfinal version' do
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')
210
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
211
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('FUTURE-puppet7-nightly')
212
+ expect(Pkg::Paths.apt_repo_name(true)).to eq('FUTURE-puppet7-nightly')
207
213
  end
208
214
 
209
215
  it 'should fail if nonfinal_repo_name is not set for non-final version' do
210
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
216
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
211
217
  allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
212
218
  expect { Pkg::Paths.apt_repo_name(true) }.to raise_error
213
219
  end
@@ -222,8 +228,8 @@ describe 'Pkg::Paths' do
222
228
 
223
229
  it 'should return `Pkg::Config.yum_repo_name` if `Pkg::Config.repo_name` is not set' do
224
230
  allow(Pkg::Config).to receive(:repo_name).and_return(nil)
225
- allow(Pkg::Config).to receive(:yum_repo_name).and_return('puppet7')
226
- expect(Pkg::Paths.yum_repo_name).to eq('puppet7')
231
+ allow(Pkg::Config).to receive(:yum_repo_name).and_return('FUTURE-puppet7')
232
+ expect(Pkg::Paths.yum_repo_name).to eq('FUTURE-puppet7')
227
233
  end
228
234
 
229
235
  it 'should return \'products\' if nothing is set' do
@@ -233,13 +239,13 @@ describe 'Pkg::Paths' do
233
239
  end
234
240
 
235
241
  it 'should return nonfinal_repo_name for nonfinal version' do
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')
242
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
243
+ allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return('FUTURE-puppet7-nightly')
244
+ expect(Pkg::Paths.yum_repo_name(true)).to eq('FUTURE-puppet7-nightly')
239
245
  end
240
246
 
241
247
  it 'should fail if nonfinal_repo_name is not set for non-final version' do
242
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet7')
248
+ allow(Pkg::Config).to receive(:repo_name).and_return('FUTURE-puppet7')
243
249
  allow(Pkg::Config).to receive(:nonfinal_repo_name).and_return(nil)
244
250
  expect { Pkg::Paths.yum_repo_name(true) }.to raise_error
245
251
  end
@@ -319,15 +325,15 @@ describe 'Pkg::Paths' do
319
325
  context 'for puppet 7 and after' do
320
326
  it 'returns the approprate apt repo path' do
321
327
  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')
328
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'FUTURE-puppet7', 'puppet-agent'))
329
+ .to eq('/opt/repository/apt/FUTURE-puppet7/pool/bionic/p/puppet-agent')
330
+ expect(Pkg::Paths.apt_package_base_path('ubuntu-20.04-amd64', 'FUTURE-puppet7', 'puppet-agent'))
331
+ .to eq('/opt/repository/apt/FUTURE-puppet7/pool/focal/p/puppet-agent')
326
332
  end
327
333
  it 'returns the appropriate nonfinal repo path' do
328
334
  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')
335
+ expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'FUTURE-puppet7-nightly', 'pdk', true))
336
+ .to eq('/opt/repository-nightlies/apt/FUTURE-puppet7-nightly/pool/buster/p/pdk')
331
337
  end
332
338
  end
333
339
  end
@@ -366,13 +372,14 @@ describe 'Pkg::Paths' do
366
372
  end
367
373
  it 'returns nil for package formats that do not have release packages' do
368
374
  expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
375
+ expect(Pkg::Paths.release_package_link_path('osx-11-x86_64')).to eq(nil)
369
376
  expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
370
377
  end
371
378
  end
372
379
 
373
380
  context 'for puppet 7' do
374
- repo_name = 'puppet7'
375
- nonfinal_repo_name = 'puppet7-nightly'
381
+ repo_name = 'FUTURE-puppet7'
382
+ nonfinal_repo_name = 'FUTURE-puppet7-nightly'
376
383
  yum_repo_path = '/opt/repository/yum'
377
384
  apt_repo_path = '/opt/repository/apt'
378
385
  nonfinal_yum_repo_path = '/opt/repository-nightlies/yum'
@@ -403,6 +410,7 @@ describe 'Pkg::Paths' do
403
410
  end
404
411
  it 'returns nil for package formats that do not have release packages' do
405
412
  expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to eq(nil)
413
+ expect(Pkg::Paths.release_package_link_path('osx-11-x86_64')).to eq(nil)
406
414
  expect(Pkg::Paths.release_package_link_path('windows-2012-x86')).to eq(nil)
407
415
  end
408
416
  end