]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
proxy config: Factor out http_proxy_envsettings
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 6 Apr 2017 16:48:27 +0000 (16:48 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 11 Apr 2017 10:37:35 +0000 (11:37 +0100)
No overall functional change, other than slight syntax changes to
generated shell runes.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/TestSupport.pm

index 6ca8076fabd3b4a0ff28aa468fdc4b44dcba7a84..4af47f0b0b9cd7ae77e190926a3a582ce9080642 100644 (file)
@@ -60,6 +60,7 @@ BEGIN {
                      target_putfilecontents_root_stash
                       target_put_guest_image target_editfile
                       target_editfile_cancel target_fetchurl
+                      http_proxy_envsettings
                       target_editfile_root target_file_exists
                       target_editfile_kvp_replace
                       target_run_apt
@@ -625,15 +626,13 @@ sub target_cmd_build ($$$$) {
         export CCACHE_PREFIX DISTCC_FALLBACK DISTCC_HOSTS
 END
 
-    my $httpproxy = defined($c{HttpProxy}) ? <<END : "";
-        http_proxy=$c{HttpProxy}
-        export http_proxy
-END
+    my $httpproxy = http_proxy_envsettings($ho);
 
-    target_cmd($ho, <<END.$distcc.$httpproxy.<<END.$script, $timeout);
+    target_cmd($ho, <<END.$distcc.<<END.$script, $timeout);
        set -xe
         LC_ALL=C; export LC_ALL
         PATH=/usr/lib/ccache:\$PATH:/usr/lib/git-core
+        $httpproxy
 END
         exec </dev/null
         cd $builddir
@@ -1880,12 +1879,23 @@ END
 sub target_fetchurl($$$;$) {
     my ($ho, $url, $path, $timeo) = @_;
     $timeo ||= 2000;
-    my $useproxy = $c{HttpProxy} ? "export http_proxy=$c{HttpProxy};" : "";
+    my $useproxy = http_proxy_envsettings($ho);
     target_cmd_root($ho, <<END, $timeo);
     $useproxy wget --progress=dot:mega -O \Q$path\E \Q$url\E
 END
 }
 
+sub http_proxy_envsettings ($) {
+    # returns sh script fragment ending in ;
+    my ($ho) = @_;
+    my $proxy = $c{HttpProxy};
+    return unless $proxy;
+    my @script;
+    foreach my $var (qw(http_proxy)) {
+        push @script, "http_proxy=$proxy", "export http_proxy";
+    }
+    return (join '; ', @script).';';
+}
 
 sub target_put_guest_image ($$;$) {
     my ($ho, $gho, $default) = @_;