summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2016-02-29 11:32:29 +0100
committeranonym <anonym@riseup.net>2016-02-29 11:32:29 +0100
commit71fc7578c4c3854621f363c2723df1231401ba58 (patch)
tree5d48c347b51b6dd17c1a814c8a5f201e84552eff /Rakefile
parent91ebb3163f8e842b185c1975cea79097399657df (diff)
Refactor.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile21
1 files changed, 14 insertions, 7 deletions
diff --git a/Rakefile b/Rakefile
index 3345d25..f8f124a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -60,6 +60,17 @@ def capture_vagrant(*args)
return stdout, stderr
end
+def vagrant_ssh_config(key)
+ if $vagrant_ssh_config.nil?
+ $vagrant_ssh_config = capture_vagrant('ssh-config').first.split("\n") \
+ .map { |line| line.strip.split(/\s+/, 2) } .to_h
+ # The path in the ssh-config output is quoted, which is not what
+ # is expected outside of a shell, so let's get rid of the quotes.
+ $vagrant_ssh_config['IdentityFile'].gsub!(/^"|"$/, '')
+ end
+ $vagrant_ssh_config[key]
+end
+
def current_vm_cpus
capture_vagrant('ssh', '-c', 'grep -c "^processor\s*:" /proc/cpuinfo').first.chomp.to_i
end
@@ -261,13 +272,9 @@ task :build => ['parse_build_options', 'ensure_clean_repository', 'ensure_clean_
artifacts = capture_vagrant('ssh', '-c', 'ls -1 tails-*.iso*').first.split("\n")
if not artifacts.empty?
- ssh_info = capture_vagrant('ssh-config').first.split("\n") \
- .map { |line| line.strip.split(/\s+/, 2) } .to_h
- user = ssh_info['User']
- hostname = ssh_info['HostName']
- # The path in the ssh-config output is quoted, which is not what
- # is expected outside of a shell, so let's get rid of the quotes.
- key_file = ssh_info['IdentityFile'].gsub(/^"|"$/, '')
+ user = vagrant_ssh_config('User')
+ hostname = vagrant_ssh_config('HostName')
+ key_file = vagrant_ssh_config('IdentityFile')
Net::SCP.start(hostname, user, :keys => [key_file]) do |scp|
artifacts.each do |artifact_name|
artifact_path = "/home/#{user}/#{artifact_name}"