[37797] branches/gsoc08-privileges/base/src/port1.0

pmagrath at macports.org pmagrath at macports.org
Mon Jun 23 15:04:58 PDT 2008


Revision: 37797
          http://trac.macosforge.org/projects/macports/changeset/37797
Author:   pmagrath at macports.org
Date:     2008-06-23 15:04:58 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Tidy up code. Replace external call to whoami with nicer tcl code with same effect.

Modified Paths:
--------------
    branches/gsoc08-privileges/base/src/port1.0/portfetch.tcl
    branches/gsoc08-privileges/base/src/port1.0/portutil.tcl

Modified: branches/gsoc08-privileges/base/src/port1.0/portfetch.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portfetch.tcl	2008-06-23 20:57:34 UTC (rev 37796)
+++ branches/gsoc08-privileges/base/src/port1.0/portfetch.tcl	2008-06-23 22:04:58 UTC (rev 37797)
@@ -626,15 +626,16 @@
 
 # Initialize fetch target and call checkfiles.
 proc fetch_init {args} {
-    global usealtworkpath distfiles distname distpath all_dist_files dist_subdir fetch.type fetch_init_done
+    global distfiles distname distpath all_dist_files dist_subdir fetch.type fetch_init_done
+    global altprefix usealtworkpath
     
     if {[info exists distpath] && [info exists dist_subdir] && ![info exists fetch_init_done]} {
 
 		# start gsoc08-privileges
-    	if { $usealtworkpath} {
+    	if { $usealtworkpath } {
     	# I have removed ![file writable $distpath] from the if condition as
     	# the writable condition seems to get confused by effective uids.
-			set distpath "/Users/[exec whoami]/.macports/[ string range $distpath 1 end ]"
+			set distpath "$altprefix/[ string range $distpath 1 end ]"
 			ui_debug "Going to use $distpath for fetch."
     	}
     	# end gsoc08-privileges

Modified: branches/gsoc08-privileges/base/src/port1.0/portutil.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portutil.tcl	2008-06-23 20:57:34 UTC (rev 37796)
+++ branches/gsoc08-privileges/base/src/port1.0/portutil.tcl	2008-06-23 22:04:58 UTC (rev 37797)
@@ -1378,12 +1378,13 @@
 # open_statefile
 # open file to store name of completed targets
 proc open_statefile {args} {
-    global macportsuser euid egid usealtworkpath workpath worksymlink place_worksymlink portname portpath ports_ignore_older
+    global workpath worksymlink place_worksymlink portname portpath ports_ignore_older
+    global altprefix macportsuser euid egid usealtworkpath
     
 	# start gsoc08-privileges
 	
 	# TODO: move the macportsuser setting to macports.conf
-	set macportsuser "paul"
+	set macportsuser "[uid_to_name [getuid]]"
 
 	# descalate privileges - only ran if macports stated with sudo
 	if { [geteuid] == 0 } {
@@ -1429,14 +1430,17 @@
 		if {$usealtworkpath} {
     
     		# do tilde expansion manually - tcl won't expand tildes automatically for curl, etc.
-			set userhome "/Users/[exec whoami]"
+			set userhome "/Users/[uid_to_name [getuid]]"
 			
+			# set alternative prefix global variables
+			set altprefix "$userhome/.macports"
+			
 			# get alternative paths
-			set newworkpath "$userhome/.macports/[ string range $workpath 1 end ]"
-			set newworksymlink "$userhome/.macports/[ string range $worksymlink 1 end ]"
+			set newworkpath "$altprefix/[ string range $workpath 1 end ]"
+			set newworksymlink "$altprefix/[ string range $worksymlink 1 end ]"
 			
 			set sourcepath [string map {"work" ""} $worksymlink] 
-			set newsourcepath "$userhome/.macports/[ string range $sourcepath 1 end ]"
+			set newsourcepath "$altprefix/[ string range $sourcepath 1 end ]"
 	
 			# copy Portfile if not there already
 			# note to self: should this be done always in case existing Portfile is out of date?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080623/4ac7f5ba/attachment.htm 


More information about the macports-changes mailing list