packaging 0.99.76 → 0.99.77
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/packaging/archive.rb +6 -6
- data/lib/packaging/config.rb +5 -1
- data/lib/packaging/deb/repo.rb +5 -5
- data/lib/packaging/platforms.rb +13 -34
- data/lib/packaging/repo.rb +9 -3
- data/lib/packaging/rpm/repo.rb +4 -4
- data/lib/packaging/sign/dmg.rb +3 -3
- data/lib/packaging/sign/ips.rb +8 -8
- data/lib/packaging/sign/msi.rb +7 -3
- data/lib/packaging/util/net.rb +53 -31
- data/lib/packaging/util/ship.rb +4 -4
- data/spec/lib/packaging/artifactory_spec.rb +11 -11
- data/spec/lib/packaging/config_spec.rb +13 -15
- data/spec/lib/packaging/deb/repo_spec.rb +3 -3
- data/spec/lib/packaging/paths_spec.rb +8 -2
- data/spec/lib/packaging/platforms_spec.rb +14 -14
- data/spec/lib/packaging/repo_spec.rb +1 -1
- data/spec/lib/packaging/retrieve_spec.rb +4 -3
- data/spec/lib/packaging/rpm/repo_spec.rb +3 -3
- data/spec/lib/packaging/sign_spec.rb +0 -2
- data/spec/lib/packaging/util/net_spec.rb +22 -9
- data/spec/lib/packaging/util/ship_spec.rb +2 -2
- data/tasks/archive.rake +3 -4
- data/tasks/education.rake +5 -5
- data/tasks/nightly_repos.rake +9 -9
- data/tasks/pe_ship.rake +11 -19
- data/tasks/ship.rake +25 -17
- data/tasks/sign.rake +3 -3
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365629e0e3cba195de934ccd1cee9ecff5c7ed684ac79e4befc883420037b191
|
4
|
+
data.tar.gz: 2498029caf73135b3ee7c5a2704e310ae6398c4eb7716c3687db487fc827dc0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a73420699b6ce732c52c527468c5b9cef405c0565aab9b33c3e592109ddee4aa965f162b4d3950a7900584994dba2994cc07602d75e36b0a53bf8dbbfcd23ec
|
7
|
+
data.tar.gz: f871e9711752e70ac48956663402fa3f0cdf2693ae08eff8aa0ac59384a0081e1dd27fdbac01a3a17964de4a135a9ded98d381808cace9d9dd62c6ac37d20a8d
|
data/lib/packaging/archive.rb
CHANGED
@@ -33,7 +33,7 @@ module Pkg::Archive
|
|
33
33
|
sudo chmod g+w -R #{Pkg::Config.yum_archive_path}
|
34
34
|
mv #{full_directory} #{archive_path}
|
35
35
|
CMD
|
36
|
-
Pkg::Util::Net.
|
36
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
37
37
|
end
|
38
38
|
|
39
39
|
# Move directories from freight path (aka repo staging path) to archive staging paths
|
@@ -60,7 +60,7 @@ module Pkg::Archive
|
|
60
60
|
mv $pool_directory /opt/tmp-apt
|
61
61
|
done
|
62
62
|
CMD
|
63
|
-
Pkg::Util::Net.
|
63
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Move downloads directories to archive staging path
|
@@ -85,7 +85,7 @@ module Pkg::Archive
|
|
85
85
|
sudo chmod g+w -R #{Pkg::Config.downloads_archive_path}
|
86
86
|
mv #{full_directory} #{archive_path}
|
87
87
|
CMD
|
88
|
-
Pkg::Util::Net.
|
88
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
89
89
|
end
|
90
90
|
|
91
91
|
# Delete empty directories from repo paths on weth
|
@@ -104,7 +104,7 @@ module Pkg::Archive
|
|
104
104
|
fi
|
105
105
|
done
|
106
106
|
CMD
|
107
|
-
Pkg::Util::Net.
|
107
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,7 +112,7 @@ module Pkg::Archive
|
|
112
112
|
def remove_dead_symlinks
|
113
113
|
base_paths.each do |path|
|
114
114
|
command = "find #{path} -xtype l -delete"
|
115
|
-
Pkg::Util::Net.
|
115
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -120,7 +120,7 @@ module Pkg::Archive
|
|
120
120
|
def delete_staged_archives
|
121
121
|
archive_paths.each do |archive_path|
|
122
122
|
command = "sudo rm -rf #{File.join(archive_path, '*')}"
|
123
|
-
Pkg::Util::Net.
|
123
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
data/lib/packaging/config.rb
CHANGED
@@ -81,7 +81,11 @@ module Pkg
|
|
81
81
|
dir = "/opt/jenkins-builds/#{self.project}/#{self.ref}"
|
82
82
|
cmd = "if [ -s \"#{dir}/artifacts\" ]; then cd #{dir};"\
|
83
83
|
"find ./artifacts/ -mindepth 2 -type f; fi"
|
84
|
-
artifacts, _ = Pkg::Util::Net.
|
84
|
+
artifacts, _ = Pkg::Util::Net.remote_execute(
|
85
|
+
self.builds_server,
|
86
|
+
cmd,
|
87
|
+
{ capture_output: true }
|
88
|
+
)
|
85
89
|
|
86
90
|
artifacts = artifacts.split("\n")
|
87
91
|
data = {}
|
data/lib/packaging/deb/repo.rb
CHANGED
@@ -125,7 +125,7 @@ Description: Apt repository for acceptance testing" >> conf/distributions ; )
|
|
125
125
|
command = repo_creation_command(File.join(artifact_directory, 'repos'), artifact_paths)
|
126
126
|
|
127
127
|
begin
|
128
|
-
Pkg::Util::Net.
|
128
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, command)
|
129
129
|
# Now that we've created our package repositories, we can generate repo
|
130
130
|
# configurations for use with downstream jobs, acceptance clients, etc.
|
131
131
|
Pkg::Deb::Repo.generate_repo_configs
|
@@ -134,7 +134,7 @@ Description: Apt repository for acceptance testing" >> conf/distributions ; )
|
|
134
134
|
Pkg::Deb::Repo.ship_repo_configs
|
135
135
|
ensure
|
136
136
|
# Always remove the lock file, even if we've failed
|
137
|
-
Pkg::Util::Net.
|
137
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock")
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -146,7 +146,7 @@ Description: Apt repository for acceptance testing" >> conf/distributions ; )
|
|
146
146
|
|
147
147
|
Pkg::Util::RakeUtils.invoke_task("pl:fetch")
|
148
148
|
repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/#{target}/deb"
|
149
|
-
Pkg::Util::Net.
|
149
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
|
150
150
|
Pkg::Util::Execution.retry_on_fail(:times => 3) do
|
151
151
|
Pkg::Util::Net.rsync_to("pkg/#{target}/deb/", Pkg::Config.distribution_server, repo_dir)
|
152
152
|
end
|
@@ -252,11 +252,11 @@ SignWith: #{Pkg::Config.gpg_key}"
|
|
252
252
|
rsync_command = repo_deployment_command(apt_path, destination_staging_path, destination_server, dryrun)
|
253
253
|
cp_command = repo_deployment_command(destination_staging_path, apt_path, nil, dryrun)
|
254
254
|
|
255
|
-
Pkg::Util::Net.
|
255
|
+
Pkg::Util::Net.remote_execute(origin_server, rsync_command)
|
256
256
|
if dryrun
|
257
257
|
puts "[DRYRUN] not executing #{cp_command} on #{destination_server}"
|
258
258
|
else
|
259
|
-
Pkg::Util::Net.
|
259
|
+
Pkg::Util::Net.remote_execute(destination_server, cp_command)
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
data/lib/packaging/platforms.rb
CHANGED
@@ -12,13 +12,6 @@ module Pkg
|
|
12
12
|
# Each element in this hash
|
13
13
|
PLATFORM_INFO = {
|
14
14
|
'aix' => {
|
15
|
-
'6.1' => {
|
16
|
-
architectures: ['power'],
|
17
|
-
source_architecture: 'SRPMS',
|
18
|
-
package_format: 'rpm',
|
19
|
-
source_package_formats: ['src.rpm'],
|
20
|
-
repo: false,
|
21
|
-
},
|
22
15
|
'7.1' => {
|
23
16
|
architectures: ['power'],
|
24
17
|
source_architecture: 'SRPMS',
|
@@ -28,25 +21,6 @@ module Pkg
|
|
28
21
|
},
|
29
22
|
},
|
30
23
|
|
31
|
-
'cisco-wrlinux' => {
|
32
|
-
'5' => {
|
33
|
-
architectures: ['x86_64'],
|
34
|
-
source_architecture: 'SRPMS',
|
35
|
-
package_format: 'rpm',
|
36
|
-
source_package_formats: ['src.rpm'],
|
37
|
-
signature_format: 'v4',
|
38
|
-
repo: true,
|
39
|
-
},
|
40
|
-
'7' => {
|
41
|
-
architectures: ['x86_64'],
|
42
|
-
source_architecture: 'SRPMS',
|
43
|
-
package_format: 'rpm',
|
44
|
-
source_package_formats: ['src.rpm'],
|
45
|
-
signature_format: 'v4',
|
46
|
-
repo: true,
|
47
|
-
},
|
48
|
-
},
|
49
|
-
|
50
24
|
'debian' => {
|
51
25
|
'8' => {
|
52
26
|
codename: 'jessie',
|
@@ -109,14 +83,6 @@ module Pkg
|
|
109
83
|
}
|
110
84
|
},
|
111
85
|
|
112
|
-
'eos' => {
|
113
|
-
'4' => {
|
114
|
-
architectures: ['i386'],
|
115
|
-
package_format: 'swix',
|
116
|
-
repo: false,
|
117
|
-
},
|
118
|
-
},
|
119
|
-
|
120
86
|
'fedora' => {
|
121
87
|
'30' => {
|
122
88
|
architectures: ['x86_64'],
|
@@ -142,6 +108,14 @@ module Pkg
|
|
142
108
|
signature_format: 'v4',
|
143
109
|
repo: true,
|
144
110
|
},
|
111
|
+
'34' => {
|
112
|
+
architectures: ['x86_64'],
|
113
|
+
source_architecture: 'SRPMS',
|
114
|
+
package_format: 'rpm',
|
115
|
+
source_package_formats: ['src.rpm'],
|
116
|
+
signature_format: 'v4',
|
117
|
+
repo: true,
|
118
|
+
},
|
145
119
|
},
|
146
120
|
|
147
121
|
'osx' => {
|
@@ -160,6 +134,11 @@ module Pkg
|
|
160
134
|
package_format: 'dmg',
|
161
135
|
repo: false,
|
162
136
|
},
|
137
|
+
'11' => {
|
138
|
+
architectures: ['x86_64'],
|
139
|
+
package_format: 'dmg',
|
140
|
+
repo: false,
|
141
|
+
},
|
163
142
|
},
|
164
143
|
|
165
144
|
'redhatfips' => {
|
data/lib/packaging/repo.rb
CHANGED
@@ -110,7 +110,11 @@ module Pkg::Repo
|
|
110
110
|
cmd = "[ -d #{artifact_directory} ] || exit 1 ; "
|
111
111
|
cmd << "pushd #{artifact_directory} > /dev/null && "
|
112
112
|
cmd << "find . -name '*.#{pkg_ext}' -print0 | xargs --no-run-if-empty -0 -I {} dirname {} "
|
113
|
-
stdout,
|
113
|
+
stdout, _ = Pkg::Util::Net.remote_execute(
|
114
|
+
Pkg::Config.distribution_server,
|
115
|
+
cmd,
|
116
|
+
{ capture_output: true }
|
117
|
+
)
|
114
118
|
return stdout.split
|
115
119
|
rescue => e
|
116
120
|
fail "Error: Could not retrieve directories that contain #{pkg_ext} packages in #{Pkg::Config.distribution_server}:#{artifact_directory}"
|
@@ -120,7 +124,7 @@ module Pkg::Repo
|
|
120
124
|
cmd = "[ -d #{artifact_parent_directory}/artifacts ] || exit 1 ; "
|
121
125
|
cmd << "pushd #{artifact_parent_directory} > /dev/null && "
|
122
126
|
cmd << 'rsync --archive --verbose --one-file-system --ignore-existing artifacts/ repos/ '
|
123
|
-
Pkg::Util::Net.
|
127
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, cmd)
|
124
128
|
rescue => e
|
125
129
|
fail "Error: Could not populate repos directory in #{Pkg::Config.distribution_server}:#{artifact_parent_directory}"
|
126
130
|
end
|
@@ -143,7 +147,9 @@ module Pkg::Repo
|
|
143
147
|
__APT_PLATFORMS__: Pkg::Config.apt_releases.join(' '),
|
144
148
|
__GPG_KEY__: Pkg::Util::Gpg.key
|
145
149
|
}
|
146
|
-
Pkg::Util::Net.
|
150
|
+
Pkg::Util::Net.remote_execute(
|
151
|
+
remote_host,
|
152
|
+
Pkg::Util::Misc.search_and_replace(command, whitelist))
|
147
153
|
end
|
148
154
|
end
|
149
155
|
end
|
data/lib/packaging/rpm/repo.rb
CHANGED
@@ -16,7 +16,7 @@ module Pkg::Rpm::Repo
|
|
16
16
|
|
17
17
|
Pkg::Util::RakeUtils.invoke_task("pl:fetch")
|
18
18
|
repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/#{target}/rpm"
|
19
|
-
Pkg::Util::Net.
|
19
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
|
20
20
|
Pkg::Util::Execution.retry_on_fail(:times => 3) do
|
21
21
|
Pkg::Util::Net.rsync_to("pkg/#{target}/rpm/", Pkg::Config.distribution_server, repo_dir)
|
22
22
|
end
|
@@ -215,7 +215,7 @@ module Pkg::Rpm::Repo
|
|
215
215
|
command = Pkg::Rpm::Repo.repo_creation_command(File.join(artifact_directory, directory), artifact_paths)
|
216
216
|
|
217
217
|
begin
|
218
|
-
Pkg::Util::Net.
|
218
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, command)
|
219
219
|
# Now that we've created our package repositories, we can generate repo
|
220
220
|
# configurations for use with downstream jobs, acceptance clients, etc.
|
221
221
|
Pkg::Rpm::Repo.generate_repo_configs
|
@@ -224,7 +224,7 @@ module Pkg::Rpm::Repo
|
|
224
224
|
Pkg::Rpm::Repo.ship_repo_configs
|
225
225
|
ensure
|
226
226
|
# Always remove the lock file, even if we've failed
|
227
|
-
Pkg::Util::Net.
|
227
|
+
Pkg::Util::Net.remote_execute(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock")
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -248,7 +248,7 @@ module Pkg::Rpm::Repo
|
|
248
248
|
def deploy_repos(yum_path, origin_server, destination_server, dryrun = false)
|
249
249
|
rsync_command = repo_deployment_command(yum_path, yum_path, destination_server, dryrun)
|
250
250
|
|
251
|
-
Pkg::Util::Net.
|
251
|
+
Pkg::Util::Net.remote_execute(origin_server, rsync_command)
|
252
252
|
end
|
253
253
|
end
|
254
254
|
end
|
data/lib/packaging/sign/dmg.rb
CHANGED
@@ -15,10 +15,10 @@ module Pkg::Sign::Dmg
|
|
15
15
|
work_dir = "/tmp/#{Pkg::Util.rand_string}"
|
16
16
|
mount = File.join(work_dir, "mount")
|
17
17
|
signed = File.join(work_dir, "signed")
|
18
|
-
Pkg::Util::Net.
|
18
|
+
Pkg::Util::Net.remote_execute(ssh_host_string, "mkdir -p #{mount} #{signed}")
|
19
19
|
dmgs = Dir.glob("#{target_dir}/apple/**/*.dmg")
|
20
20
|
Pkg::Util::Net.rsync_to(dmgs.join(" "), rsync_host_string, work_dir)
|
21
|
-
Pkg::Util::Net.
|
21
|
+
Pkg::Util::Net.remote_execute(ssh_host_string, %Q[for dmg in #{dmgs.map { |d| File.basename(d, ".dmg") }.join(" ")}; do
|
22
22
|
/usr/bin/hdiutil attach #{work_dir}/$dmg.dmg -mountpoint #{mount} -nobrowse -quiet ;
|
23
23
|
/usr/bin/security -q unlock-keychain -p "#{Pkg::Config.osx_signing_keychain_pw}" "#{Pkg::Config.osx_signing_keychain}" ;
|
24
24
|
for pkg in $(ls #{mount}/*.pkg | xargs -n 1 basename); do
|
@@ -36,6 +36,6 @@ module Pkg::Sign::Dmg
|
|
36
36
|
dmgs.each do | dmg |
|
37
37
|
Pkg::Util::Net.rsync_from("#{work_dir}/#{File.basename(dmg)}", rsync_host_string, File.dirname(dmg))
|
38
38
|
end
|
39
|
-
Pkg::Util::Net.
|
39
|
+
Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -d '#{work_dir}' ]; then rm -rf '#{work_dir}'; fi")
|
40
40
|
end
|
41
41
|
end
|
data/lib/packaging/sign/ips.rb
CHANGED
@@ -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.
|
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.
|
23
|
-
Pkg::Util::Net.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
data/lib/packaging/sign/msi.rb
CHANGED
@@ -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.
|
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"])
|
@@ -111,10 +111,14 @@ for msipath in #{msis.join(" ")}; do
|
|
111
111
|
done
|
112
112
|
CMD
|
113
113
|
|
114
|
-
Pkg::Util::Net.
|
114
|
+
Pkg::Util::Net.remote_execute(
|
115
|
+
ssh_host_string,
|
116
|
+
sign_command,
|
117
|
+
{ fail_fast: false }
|
118
|
+
)
|
115
119
|
msis.each do | msi |
|
116
120
|
Pkg::Util::Net.rsync_from("/cygdrive/c/#{work_dir}/#{msi}", rsync_host_string, File.dirname(msi))
|
117
121
|
end
|
118
|
-
Pkg::Util::Net.
|
122
|
+
Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -d '/cygdrive/c/#{work_dir}' ]; then rm -rf '/cygdrive/c/#{work_dir}'; fi")
|
119
123
|
end
|
120
124
|
end
|
data/lib/packaging/util/net.rb
CHANGED
@@ -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,
|
24
|
-
if hostname == host
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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.
|
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.
|
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.
|
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.
|
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,7 +387,7 @@ 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.
|
390
|
+
Pkg::Util::Net.remote_execute(host, command)
|
369
391
|
return git_bundle_directory
|
370
392
|
end
|
371
393
|
|