packaging 0.88.77 → 0.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +128 -74
  3. data/lib/packaging/artifactory.rb +60 -433
  4. data/lib/packaging/config/params.rb +7 -28
  5. data/lib/packaging/config.rb +50 -150
  6. data/lib/packaging/deb/repo.rb +19 -20
  7. data/lib/packaging/gem.rb +83 -41
  8. data/lib/packaging/ips.rb +57 -0
  9. data/lib/packaging/msi.rb +89 -0
  10. data/lib/packaging/nuget.rb +1 -1
  11. data/lib/packaging/osx.rb +36 -0
  12. data/lib/packaging/paths.rb +87 -225
  13. data/lib/packaging/platforms.rb +416 -443
  14. data/lib/packaging/repo.rb +22 -122
  15. data/lib/packaging/retrieve.rb +7 -36
  16. data/lib/packaging/rpm/repo.rb +8 -5
  17. data/lib/packaging/tar.rb +0 -9
  18. data/lib/packaging/util/date.rb +0 -5
  19. data/lib/packaging/util/execution.rb +2 -2
  20. data/lib/packaging/util/git.rb +1 -1
  21. data/lib/packaging/util/gpg.rb +1 -5
  22. data/lib/packaging/util/net.rb +37 -79
  23. data/lib/packaging/util/rake_utils.rb +0 -1
  24. data/lib/packaging/util/ship.rb +13 -142
  25. data/lib/packaging/util/tool.rb +1 -1
  26. data/lib/packaging/util/version.rb +0 -8
  27. data/lib/packaging/util.rb +2 -2
  28. data/lib/packaging.rb +3 -3
  29. data/spec/fixtures/config/params.yaml +2 -0
  30. data/spec/lib/packaging/artifactory_spec.rb +16 -66
  31. data/spec/lib/packaging/config_spec.rb +29 -49
  32. data/spec/lib/packaging/deb/repo_spec.rb +7 -16
  33. data/spec/lib/packaging/paths_spec.rb +56 -321
  34. data/spec/lib/packaging/platforms_spec.rb +21 -46
  35. data/spec/lib/packaging/repo_spec.rb +40 -78
  36. data/spec/lib/packaging/retrieve_spec.rb +8 -47
  37. data/spec/lib/packaging/rpm/repo_spec.rb +4 -4
  38. data/spec/lib/packaging/tar_spec.rb +40 -34
  39. data/spec/lib/packaging/util/git_tag_spec.rb +1 -1
  40. data/spec/lib/packaging/util/gpg_spec.rb +1 -1
  41. data/spec/lib/packaging/util/net_spec.rb +15 -35
  42. data/spec/lib/packaging/util/ship_spec.rb +63 -145
  43. data/spec/spec_helper.rb +14 -0
  44. data/tasks/00_utils.rake +6 -4
  45. data/tasks/apple.rake +0 -2
  46. data/tasks/config.rake +0 -5
  47. data/tasks/education.rake +5 -5
  48. data/tasks/fetch.rake +14 -17
  49. data/tasks/gem.rake +121 -134
  50. data/tasks/jenkins.rake +7 -51
  51. data/tasks/nightly_repos.rake +69 -20
  52. data/tasks/pe_ship.rake +11 -16
  53. data/tasks/retrieve.rake +6 -13
  54. data/tasks/ship.rake +256 -196
  55. data/tasks/sign.rake +135 -63
  56. data/tasks/tar.rake +6 -0
  57. data/templates/packaging.xml.erb +7 -9
  58. data/templates/repo.xml.erb +3 -6
  59. metadata +27 -80
  60. data/lib/packaging/archive.rb +0 -126
  61. data/lib/packaging/artifactory/extensions.rb +0 -94
  62. data/lib/packaging/config/validations.rb +0 -13
  63. data/lib/packaging/metrics.rb +0 -15
  64. data/lib/packaging/sign/deb.rb +0 -9
  65. data/lib/packaging/sign/dmg.rb +0 -41
  66. data/lib/packaging/sign/ips.rb +0 -57
  67. data/lib/packaging/sign/msi.rb +0 -124
  68. data/lib/packaging/sign/rpm.rb +0 -115
  69. data/lib/packaging/sign.rb +0 -8
  70. data/spec/lib/packaging/gem_spec.rb +0 -86
  71. data/spec/lib/packaging/sign_spec.rb +0 -133
  72. data/tasks/archive.rake +0 -69
@@ -54,82 +54,62 @@ describe "Pkg::Util::Net" do
54
54
  end
55
55
 
56
56
  describe "remote_ssh_cmd" do
57
- it "should be able to call via deprecated shim" do
58
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
59
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
60
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
61
- Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true)
62
- end
63
- end
64
-
65
- describe "remote_execute" do
66
57
  it "should fail if ssh is not present" do
67
58
  Pkg::Util::Tool.stub(:find_tool).with("ssh") { fail }
68
59
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_raise(RuntimeError)
69
- expect{ Pkg::Util::Net.remote_execute("foo", "bar") }.to raise_error(RuntimeError)
60
+ expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar") }.to raise_error(RuntimeError)
70
61
  end
71
62
 
72
63
  it "should be able to not fail fast" do
73
64
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
74
65
  Kernel.should_receive(:system).with("#{ssh} -t foo 'bar'")
75
66
  Pkg::Util::Execution.should_receive(:success?).and_return(true)
76
- Pkg::Util::Net.remote_execute(
77
- "foo", "bar", capture_output: false, extra_options: '', fail_fast: false)
78
- end
79
-
80
- it "should be able to trace output" do
81
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
82
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -x;bar'")
83
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
84
- Pkg::Util::Net.remote_execute(
85
- "foo", "bar", capture_output: false, fail_fast: false, trace: true)
86
- end
67
+ Pkg::Util::Net.remote_ssh_cmd("foo", "bar", false, '', false)
68
+ end
87
69
 
88
70
  context "without output captured" do
89
71
  it "should execute a command :foo on a host :bar using Kernel" do
90
72
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
91
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;bar'")
73
+ Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; bar'")
92
74
  Pkg::Util::Execution.should_receive(:success?).and_return(true)
93
- Pkg::Util::Net.remote_execute("foo", "bar")
75
+ Pkg::Util::Net.remote_ssh_cmd("foo", "bar")
94
76
  end
95
77
 
96
78
  it "should escape single quotes in the command" do
97
79
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
98
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;b'\\''ar'")
80
+ Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; b'\\''ar'")
99
81
  Pkg::Util::Execution.should_receive(:success?).and_return(true)
100
- Pkg::Util::Net.remote_execute("foo", "b'ar")
82
+ Pkg::Util::Net.remote_ssh_cmd("foo", "b'ar")
101
83
  end
102
84
 
103
85
  it "should raise an error if ssh fails" do
104
86
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
105
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;bar'")
87
+ Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; bar'")
106
88
  Pkg::Util::Execution.should_receive(:success?).and_return(false)
107
- expect{ Pkg::Util::Net.remote_execute("foo", "bar") }
108
- .to raise_error(RuntimeError, /failed./)
89
+ expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar") }.to raise_error(RuntimeError, /Remote ssh command failed./)
109
90
  end
110
91
  end
111
92
 
112
93
  context "with output captured" do
113
94
  it "should execute a command :foo on a host :bar using Pkg::Util::Execution.capture3" do
114
95
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
115
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
96
+ Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; bar'")
116
97
  Pkg::Util::Execution.should_receive(:success?).and_return(true)
117
- Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true)
98
+ Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true)
118
99
  end
119
100
 
120
101
  it "should escape single quotes in the command" do
121
102
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
122
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;b'\\''ar'")
103
+ Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; b'\\''ar'")
123
104
  Pkg::Util::Execution.should_receive(:success?).and_return(true)
124
- Pkg::Util::Net.remote_execute("foo", "b'ar", capture_output: true)
105
+ Pkg::Util::Net.remote_ssh_cmd("foo", "b'ar", true)
125
106
  end
126
107
 
127
108
  it "should raise an error if ssh fails" do
128
109
  Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
129
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
110
+ Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; bar'")
130
111
  Pkg::Util::Execution.should_receive(:success?).and_return(false)
131
- expect{ Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true) }
132
- .to raise_error(RuntimeError, /failed./)
112
+ expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true) }.to raise_error(RuntimeError, /Remote ssh command failed./)
133
113
  end
134
114
  end
135
115
  end
@@ -2,112 +2,80 @@ require 'spec_helper'
2
2
 
3
3
  describe '#Pkg::Util::Ship' do
4
4
  describe '#collect_packages' do
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
5
+ msi_pkgs = [
6
+ 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
7
+ 'pkg/windows/puppet5/puppet-agent-x86.msi'
11
8
  ]
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
9
+ swix_pkgs = [
10
+ 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
11
+ 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
15
12
  ]
16
13
 
17
14
  it 'returns an array of packages found on the filesystem' do
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)
15
+ allow(Dir).to receive(:glob).with('pkg/**/*.swix*').and_return(swix_pkgs)
16
+ expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.swix*'])).to eq(swix_pkgs)
20
17
  end
21
18
 
22
- context 'excluding packages' do
19
+ describe 'define excludes' do
23
20
  before :each do
24
- allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_packages)
21
+ allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_pkgs)
25
22
  end
26
23
  it 'correctly excludes any packages that match a passed excludes argument' do
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')
24
+ expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).not_to include('pkg/windows/puppet5/puppet-agent-x86.msi')
31
25
  end
32
26
  it 'correctly includes packages that do not match a passed excluded argument' do
33
- expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'],
34
- ['bogus-puppet-agent-x(86|64).msi']))
35
- .to match_array(msi_packages)
27
+ expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).to include('pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi')
36
28
  end
37
29
  end
38
30
 
39
- it 'returns an empty array when it cannot find any packages' do
31
+ it 'fails when it cannot find any packages at all' do
40
32
  allow(Dir).to receive(:glob).with('pkg/**/*.html').and_return([])
41
33
  expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.html'])).to be_empty
42
34
  end
43
35
  end
44
36
 
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
- ]
37
+ local_pkgs = [
38
+ 'pkg/deb/cumulus/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1cumulus_amd64.deb',
39
+ 'pkg/deb/wheezy/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1wheezy_i386.deb',
40
+ 'pkg/el/5/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
41
+ 'pkg/sles/11/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
42
+ 'pkg/mac/10.10/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.10.dmg',
43
+ 'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
44
+ 'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
45
+ 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
46
+ ]
47
+ new_pkgs = [
48
+ 'pkg/cumulus/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1cumulus_amd64.deb',
49
+ 'pkg/wheezy/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1wheezy_i386.deb',
50
+ 'pkg/puppet5/el/5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
51
+ 'pkg/puppet5/sles/11/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
52
+ 'pkg/mac/puppet5/10.10/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.10.dmg',
53
+ 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
54
+ 'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
55
+ 'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
56
+ ]
83
57
 
84
58
  describe '#reorganize_packages' do
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
59
+ tmpdir = Dir.mktmpdir
92
60
 
93
61
  before :each do
94
- allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
95
- expect(FileUtils).to receive(:cp).at_least(:once).and_return(true)
62
+ allow(Pkg::Paths).to receive(:repo_name).and_return('puppet5')
63
+ expect(FileUtils).to receive(:cp).at_least(:once)
96
64
  end
97
65
 
98
- original_packages = retrieved_packages
66
+ it 'makes a temporary directory' do
67
+ expect(FileUtils).to receive(:mkdir_p).at_least(:once)
68
+ Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
69
+ end
99
70
 
100
71
  it 'leaves the old packages in place' do
101
- reorganized_packages = Pkg::Util::Ship
102
- .reorganize_packages(retrieved_packages, scratch_directory)
103
-
104
- expect(retrieved_packages).to eq(original_packages)
72
+ orig = local_pkgs
73
+ Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
74
+ expect(local_pkgs).to eq(orig)
105
75
  end
106
76
 
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)
77
+ it 'returns a list of packages that do not have the temp dir in the path' do
78
+ expect(Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)).to eq(new_pkgs)
111
79
  end
112
80
  end
113
81
 
@@ -116,84 +84,34 @@ describe '#Pkg::Util::Ship' do
116
84
  test_remote_path = '/opt/repository/yum'
117
85
 
118
86
  it 'ships the packages to the staging server' do
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)
87
+ allow(Pkg::Util::Ship).to receive(:collect_packages).and_return(local_pkgs)
88
+ allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return(new_pkgs)
125
89
  allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
126
90
  # All of these expects must be called in the same block in order for the
127
91
  # tests to work without actually shipping anything
128
- expect(Pkg::Util::Net)
129
- .to receive(:remote_execute)
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)
92
+ expect(Pkg::Util::Net).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/).exactly(local_pkgs.count).times
93
+ expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything).exactly(local_pkgs.count).times
94
+ expect(Pkg::Util::Net).to receive(:remote_set_ownership).with(test_staging_server, 'root', 'release', anything).exactly(local_pkgs.count).times
95
+ expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything).exactly(local_pkgs.count).times
96
+ expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything).exactly(local_pkgs.count).times
97
+ expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything).exactly(local_pkgs.count).times
98
+ Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path)
154
99
  end
155
100
 
156
101
  it 'ships packages containing the string `pkg` to the right place' do
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])
102
+ 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' ])
103
+ 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'])
164
104
  allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
165
105
  allow(Dir).to receive(:mktmpdir).and_return('/tmp/test')
166
-
167
106
  # All of these expects must be called in the same block in order for the
168
107
  # tests to work without actually shipping anything
169
- expect(Pkg::Util::Net)
170
- .to receive(:remote_execute)
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)
191
- end
192
-
193
- it 'returns false if there are no packages to ship' do
194
- expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'],
195
- test_staging_server, test_remote_path))
196
- .to eq(false)
108
+ expect(Pkg::Util::Net).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/)
109
+ expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything)
110
+ 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'])
111
+ expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything)
112
+ expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything)
113
+ expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything)
114
+ Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path, excludes: ['puppet-agent'])
197
115
  end
198
116
  end
199
117
  end
data/spec/spec_helper.rb CHANGED
@@ -20,3 +20,17 @@ def reset_env(keys)
20
20
  ENV[key] = nil
21
21
  end
22
22
  end
23
+
24
+ RSpec.configure do |config|
25
+ if Pkg::Util::OS.windows? && RUBY_VERSION =~ /^1\./
26
+ require 'win32console'
27
+ config.output_stream = $stdout
28
+ config.error_stream = $stderr
29
+
30
+ config.formatters.each do |f|
31
+ if not f.instance_variable_get(:@output).kind_of?(::File)
32
+ f.instance_variable_set(:@output, $stdout)
33
+ end
34
+ end
35
+ end
36
+ end
data/tasks/00_utils.rake CHANGED
@@ -119,10 +119,7 @@ end
119
119
  # purport to both return the results of the command execution (ala `%x{cmd}`)
120
120
  # while also raising an exception if a command does not succeed (ala `sh "cmd"`).
121
121
  def ex(command)
122
- # We haven't done anything about this deprecation and our log files
123
- # have too many warnings from this.
124
- # Turn off the notice for now until packaging is refactored.
125
- # Pkg::Util.deprecate("ex", "Pkg::Util::Execution.ex")
122
+ Pkg::Util.deprecate("ex", "Pkg::Util::Execution.ex")
126
123
  Pkg::Util::Execution.ex(command)
127
124
  end
128
125
 
@@ -198,6 +195,11 @@ def deprecate(old_cmd, new_cmd = nil)
198
195
  Pkg::Util.deprecate(old_cmd, new_cmd)
199
196
  end
200
197
 
198
+ def remote_bootstrap(host, treeish, tar_cmd = nil, tarball = nil)
199
+ Pkg::Util.deprecate('remote_bootstrap', 'Pkg::Util::Net.remote_bootstrap')
200
+ Pkg::Util::Net.remote_bootstrap(host, treeish, tar_cmd, tarball)
201
+ end
202
+
201
203
  def remote_buildparams(host, build)
202
204
  Pkg::Util.deprecate('remote_buildparams', 'Pkg::Util::Net.remote_buildparams')
203
205
  Pkg::Util::Net.remote_buildparams(host, build)
data/tasks/apple.rake CHANGED
@@ -86,7 +86,6 @@ end
86
86
  def build_dmg
87
87
  # Local Variables
88
88
  dmg_format_code = 'UDZO'
89
- dmg_filesystem = 'HFS+'
90
89
  zlib_level = '9'
91
90
  dmg_format_option = "-imagekey zlib-level=#{zlib_level}"
92
91
  dmg_format = "#{dmg_format_code} #{dmg_format_option}"
@@ -109,7 +108,6 @@ def build_dmg
109
108
  -uid 99 \
110
109
  -gid 99 \
111
110
  -ov \
112
- -fs #{dmg_filesystem} \
113
111
  -format #{dmg_format} \
114
112
  #{dmg_file}")
115
113
 
data/tasks/config.rake CHANGED
@@ -6,11 +6,6 @@ namespace :config do
6
6
  end
7
7
  end
8
8
 
9
- desc "validate Pkg::Config values for this repo"
10
- task :validate do
11
- Pkg::Config.perform_validations
12
- end
13
-
14
9
  task :print_hosts => 'pl:fetch' do
15
10
  Pkg::Util.filter_configs('host').each do |key, value|
16
11
  puts "#{key}: #{value}"
data/tasks/education.rake CHANGED
@@ -35,7 +35,7 @@ namespace :pl do
35
35
  end
36
36
 
37
37
  # If the archive directory exists, move old VMs to it
38
- Pkg::Util::Net.remote_execute(target_host, "if [ -d #{target_directory}/archive ]; then #{archive_cmd}; fi")
38
+ Pkg::Util::Net.remote_ssh_cmd(target_host, "if [ -d #{target_directory}/archive ]; then #{archive_cmd}; fi")
39
39
 
40
40
  # Ship VM and md5 to host
41
41
  Pkg::Util::Net.rsync_to(vm, target_host, target_directory)
@@ -45,10 +45,10 @@ namespace :pl do
45
45
  link_target.each do |link|
46
46
  link_path = File.join(target_directory, link)
47
47
  link_md5_path = "#{link_path}.md5"
48
- Pkg::Util::Net.remote_execute(target_host, "if [[ -L '#{link_path}' ]] && [[ ! -e '#{link_path}' ]] ; then echo '#{link_path} is a broken link, deleting' ; unlink '#{link_path}' ; fi")
49
- Pkg::Util::Net.remote_execute(target_host, "if [[ -L '#{link_md5_path}' ]] && [[ ! -e '#{link_md5_path}' ]] ; then echo '#{link_md5_path} is a broken link, deleting' ; unlink '#{link_md5_path}' ; fi")
50
- Pkg::Util::Net.remote_execute(target_host, "cd #{target_directory} ; ln -sf #{File.basename(vm)} #{link}")
51
- Pkg::Util::Net.remote_execute(target_host, "cd #{target_directory} ; ln -sf #{File.basename(md5)} #{link}.md5")
48
+ Pkg::Util::Net.remote_ssh_cmd(target_host, "if [[ -L '#{link_path}' ]] && [[ ! -e '#{link_path}' ]] ; then echo '#{link_path} is a broken link, deleting' ; unlink '#{link_path}' ; fi")
49
+ Pkg::Util::Net.remote_ssh_cmd(target_host, "if [[ -L '#{link_md5_path}' ]] && [[ ! -e '#{link_md5_path}' ]] ; then echo '#{link_md5_path} is a broken link, deleting' ; unlink '#{link_md5_path}' ; fi")
50
+ Pkg::Util::Net.remote_ssh_cmd(target_host, "cd #{target_directory} ; ln -sf #{File.basename(vm)} #{link}")
51
+ Pkg::Util::Net.remote_ssh_cmd(target_host, "cd #{target_directory} ; ln -sf #{File.basename(md5)} #{link}.md5")
52
52
  end
53
53
 
54
54
  puts "'#{vm}' and '#{md5}' have been shipped via rsync to '#{target_host}/#{target_directory}'"
data/tasks/fetch.rake CHANGED
@@ -30,31 +30,28 @@ namespace :pl do
30
30
  task :fetch do
31
31
  # Remove .packaging directory from old-style extras loading
32
32
  rm_rf "#{ENV['HOME']}/.packaging" if File.directory?("#{ENV['HOME']}/.packaging")
33
-
34
33
  # Touch the .packaging file which is allows packaging to present remote tasks
35
34
  touch "#{ENV['HOME']}/.packaging"
36
35
 
37
36
  begin
38
- build_data_directory = Pkg::Util::File.mktemp
39
- %x(git clone #{data_repo} #{build_data_directory})
40
- unless $?.success?
41
- fail 'Error: could not fetch the build-data repo. Maybe you do not have the correct permissions?'
42
- end
43
-
44
- Dir.chdir(build_data_directory) do
45
- [team_data_branch, project_data_branch].each do |branch|
46
- %x(git checkout #{branch})
47
- unless $?.success?
48
- warn "Warning: no build_defaults found in branch '#{branch}' of '#{data_repo}'. Skipping."
49
- next
37
+ temp_build_data_dir = Pkg::Util::File.mktemp
38
+ %x(git clone #{data_repo} #{temp_build_data_dir})
39
+ if $?.success?
40
+ Dir.chdir(temp_build_data_dir) do
41
+ [team_data_branch, project_data_branch].each do |branch|
42
+ %x(git checkout #{branch})
43
+ if $?.success?
44
+ Pkg::Util::RakeUtils.invoke_task("pl:load_extras", temp_build_data_dir)
45
+ else
46
+ warn "Unable to load build_defaults from branch '#{branch}' in '#{data_repo}'. Skipping."
47
+ end
50
48
  end
51
- Pkg::Util::RakeUtils.invoke_task('pl:load_extras', build_data_directory)
52
49
  end
50
+ else
51
+ fail "There was an error attempting to fetch the build-data repo. Maybe you do not have the correct permissions?"
53
52
  end
54
53
  ensure
55
- rm_rf build_data_directory
54
+ rm_rf temp_build_data_dir
56
55
  end
57
-
58
- Pkg::Util::RakeUtils.invoke_task('config:validate')
59
56
  end
60
57
  end