[24949] branches/dp2mp-move/base/src/macports1.0/macports.tcl

source_changes at macosforge.org source_changes at macosforge.org
Tue May 8 19:25:16 PDT 2007


Revision: 24949
          http://trac.macosforge.org/projects/macports/changeset/24949
Author:   jmpp at macports.org
Date:     2007-05-08 19:25:16 -0700 (Tue, 08 May 2007)

Log Message:
-----------

Prematurely commiting a new test proc, "findBinary", that will eventually unite how our base code finds external programs we need.
It's meant to eliminate direct calls to both the "binaryInPath" proc and autoconf module variables to determine the path to binaries,
concentrating them all in unified calls to this new proc.

This is still pretty much experimental code and does not yet work as expected. The "file" and "rsync" synchronization methods in the
mportsync proc have been adapted to use "findBinary" and no longer do their business, so clearly more work is needed. However, it is
my intention to extend "findBinary" usage to the rest of our sources once bugs have been ironed out.

Modified Paths:
--------------
    branches/dp2mp-move/base/src/macports1.0/macports.tcl

Modified: branches/dp2mp-move/base/src/macports1.0/macports.tcl
===================================================================
--- branches/dp2mp-move/base/src/macports1.0/macports.tcl	2007-05-09 02:22:50 UTC (rev 24948)
+++ branches/dp2mp-move/base/src/macports1.0/macports.tcl	2007-05-09 02:25:16 UTC (rev 24949)
@@ -157,18 +157,32 @@
 	catch "tcl::puts $args"
 }
 
+# 
+proc findBinary {prog {autoconf_hint ""}} {
+# debug, remove when done!
+    puts "entering findBinary proc"
+    puts "naming hint passed is: ${autoconf_hint}"
+    if {${autoconf_hint} != "" and [file executable ${autoconf_hint}]} {
+	return [set cmd [set ${autoconf_hint}]]
+    } else {
+	if {[catch {set cmd [binaryInPath "${prog}"]}] == 0} {
+	    return $cmd
+	} else {
+	    return -code error "Command ${prog} couldn't be found"
+	}
+    }
+}
+
 # check for a binary in the path
 # returns an error code if it can not be found
-# copied from portutil.tcl
-proc macports::binaryInPath {binary} {
+proc macports::binaryInPath {prog} {
     global env
     foreach dir [split $env(PATH) :] { 
-	if {[file executable [file join $dir $binary]]} {
-	    return [file join $dir $binary]
+	if {[file executable [file join $dir $prog]]} {
+	    return [file join $dir $prog]
 	}
     }
-    
-    return -code error [format [msgcat::mc "Failed to locate '%s' in path: '%s'"] $binary $env(PATH)];
+    return -code error [format [msgcat::mc "Failed to locate '%s' in path: '%s'"] $prog $env(PATH)];
 }
 
 # deferred option processing
@@ -1171,8 +1185,10 @@
 	    {^file$} {
 		set portdir [macports::getportdir $source]
 		if {[file exists $portdir/.svn]} {
-		    if {[catch {set svncmd [macports::binaryInPath "svn"]}] == 0} {
-			set svn_commandline "${svncmd} update --non-interactive \"${portdir}\""
+		    if {[catch {set svn_command [findBinary "svn" "${macports::autoconf::svn_path}"]}] == 0} {
+			# debug, remove!
+			puts "entered findBinary conditional..."
+			set svn_commandline "${svn_command} update --non-interactive \"${portdir}\""
 			ui_debug $svn_commandline
 			if {[catch {system $svn_commandline}]} {
 			    return -code error "sync failed doing svn update"
@@ -1181,7 +1197,7 @@
 			    ui_warn "Setting world read permissions on parts of the ports tree failed, need root?"
 			}
 		    } else {
-			return -code error "svn command not found"
+			return -code error "Synchronizing the svn checkout failed due to an unknown reason"
 		    }
 		}
 	    }
@@ -1191,21 +1207,26 @@
 	    {^rsync$} {
 		# Where to, boss?
 		set destdir [file dirname [macports::getindex $source]]
-		
 		if {[catch {file mkdir $destdir} result]} {
 		    return -code error $result
-		}		
+		}
 		# Keep rsync happy with a trailing slash
 		if {[string index $source end] != "/"} {
 		    set source "${source}/"
-		}		
+		}
 		# Do rsync fetch
-		if {[catch {system "${macports::autoconf::rsync_path} $rsync_options \"$source\" \"$destdir\""}]} {
-		    return -code error "sync failed doing rsync"
+		if {[catch {set rsync_command [findBinary "rsync" "${macports::autoconf::rsync_path}"]}] == 0} {
+		    set rsync_commandline "${rsync_command} ${rsync_options} \"${source}\" \"${destdir}\""
+		    ui_debug $rsync_commandline
+		    if {[catch {system $rsync_commandline}]} {
+			return -code error "sync failed doing rsync"
+		    }
+		    if {[catch {system "chmod -R a+r \"$destdir\""}]} {
+			ui_warn "Setting world read permissions on parts of the ports tree failed, need root?"
+		    }
+		} else {
+		    return -code error "bye!"
 		}
-		if {[catch {system "chmod -R a+r \"$destdir\""}]} {
-		    ui_warn "Setting world read permissions on parts of the ports tree failed, need root?"
-		}
 	    }
 	    {^https?$|^ftp$} {
 		set indexfile [macports::getindex $source]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070508/5a6a77a9/attachment.html


More information about the macports-changes mailing list