[PATCH] pass proxy settings to svn command line

Blair Zajac blair at orcaware.com
Sun Sep 23 01:18:46 PDT 2012


Can somebody review the following patch which adds support to svn 
fetches to use the proxy settings in macports.conf.  This is my first 
serious Tcl coding, so there may be things done in a non-optimum or 
standard manner.  This patch works with the netpbm port.

My intention is that portfetch::svn_proxy_args can also be used in 
ports, e.g. clang-3.1, when a port needs to do an svn checkout with 
custom code.

If the patch looks good, I'll commit it.

Thanks,
Blair

--- portfetch.tcl.FCS	2012-08-08 15:37:53.000000000 -0700
+++ portfetch.tcl	2012-09-23 00:18:49.000000000 -0700
@@ -330,32 +330,58 @@
      if {[catch {command_exec cvs "" "2>&1"} result]} {
          return -code error [msgcat::mc "CVS check out failed"]
      }

      if {[info exists patchfiles]} {
          return [portfetch::fetchfiles]
      }
      return 0
  }

+# Given a URL that should be exported or checked out using the svn
+# command line client, return any command line arguments that should
+# be passed to svn for it to use as an HTTP or HTTPS proxy.
+proc portfetch::svn_proxy_args {url} {
+    global env
+
+    if {   [string compare -length 7 {http://} ${url}] == 0
+        && [info exists env(http_proxy)]} {
+        set proxy_parts [split $env(http_proxy) :]
+        set proxy_host [lindex $proxy_parts 0]
+        set proxy_port [lindex $proxy_parts 1]
+        return "--config-option 
servers:global:http-proxy-host=${proxy_host} --config-option 
servers:global:http-proxy-port=${proxy_port}"
+    } elseif {   [string compare -length 8 {https://} ${url}] == 0
+              && [info exists env(HTTPS_PROXY)]} {
+        set proxy_parts [split $env(HTTPS_PROXY) :]
+        set proxy_host [lindex $proxy_parts 0]
+        set proxy_port [lindex $proxy_parts 1]
+        return "--config-option 
servers:global:http-proxy-host=${proxy_host} --config-option 
servers:global:http-proxy-port=${proxy_port}"
+    } else {
+        return ""
+    }
+}
+
  # Perform an svn fetch
  proc portfetch::svnfetch {args} {
      global svn.args svn.method svn.revision svn.url patchfiles

      if {[regexp {\s} ${svn.url}]} {
          return -code error [msgcat::mc "Subversion URL cannot contain 
whitespace"]
      }

      if {[string length ${svn.revision}]} {
          append svn.url "@${svn.revision}"
      }
-    set svn.args "${svn.method} ${svn.args} ${svn.url}"
+
+    set proxy_args [svn_proxy_args ${svn.url}]
+
+    set svn.args "${svn.method} ${svn.args} ${proxy_args} ${svn.url}"

      if {[catch {command_exec svn "" "2>&1"} result]} {
          return -code error [msgcat::mc "Subversion check out failed"]
      }

      if {[info exists patchfiles]} {
          return [portfetch::fetchfiles]
      }

      return 0


More information about the macports-dev mailing list