Remove trailing slash for proxy env.
authorHuang Hao <hao.h.huang@intel.com>
Fri, 12 Oct 2012 08:02:04 +0000 (16:02 +0800)
committerHuang Hao <hao.h.huang@intel.com>
Fri, 12 Oct 2012 10:29:15 +0000 (18:29 +0800)
Fix #467.

Change-Id: I3dd6957593b3b9645f08dc936afe439ee0acebd9

depanneur

index c98c167f4249b48c09fcc49934d7ecb476a67416..fc78b3a4e8c695df79b2527109179f9afbd7efd7 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -438,7 +438,7 @@ sub clean_cache {
 sub query_git_commit_rev {
     my ($base, $commit_id) = @_;
 
-    open(my $git, '-|', "git --git-dir $base/.git rev-parse $commit_id") || 
+    open(my $git, '-|', "git --git-dir $base/.git rev-parse $commit_id") ||
         die "query git commit reversion($commit_id) failed: $!";
     my $rev = readline($git);
     close($git);
@@ -910,9 +910,20 @@ sub build_package {
 
 }
 
-
+sub strip_trailing_slash_for_proxy_env {
+    for my $key ("http_proxy", "https_proxy") {
+        if (exists $ENV{$key} && $ENV{$key} =~ m#/$#) {
+            #build could fail if proxy url ends with '/'
+            #failed: 500 Can't connect to xxx:xxx
+            $ENV{$key} =~ s#/+$##;
+            debug("strip trailing slash for env $key");
+        }
+    }
+}
 
 # MAIN
+strip_trailing_slash_for_proxy_env;
+
 info("start building packages from: " . $package_path . " ($style)");
 
 if ($buildall || @packs == 0 ) {