Changeset 37805


Ignore:
Timestamp:
Jun 24, 2008, 11:39:08 AM (12 years ago)
Author:
pmagrath@…
Message:

Use $env(HOME) to get user home directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc08-privileges/base/src/port1.0/portutil.tcl

    r37797 r37805  
    13801380proc open_statefile {args} {
    13811381    global workpath worksymlink place_worksymlink portname portpath ports_ignore_older
    1382     global altprefix macportsuser euid egid usealtworkpath
     1382    global altprefix macportsuser euid egid usealtworkpath env
    13831383   
    13841384        # start gsoc08-privileges
     
    14211421                ui_msg "Action will be performed for current user only."
    14221422                ui_msg "Install actions should be executed using sudo."
    1423    
    1424                 #set usealtworkpath [gets stdin]
    1425                 set usealtworkpath yes
    1426         } else {
    1427                 set usealtworkpath yes
    1428         }
     1423                }
    14291424       
    1430                 if {$usealtworkpath} {
    1431    
    1432                 # do tilde expansion manually - tcl won't expand tildes automatically for curl, etc.
     1425        # set global variable indicating to other functions to use ~/.macports as well
     1426        set usealtworkpath yes
     1427   
     1428                # do tilde expansion manually - tcl won't expand tildes automatically for curl, etc.
     1429                if {[info exists env(HOME)]} {
     1430                        # HOME evnironment var is set, use it.
     1431                        set userhome "$env(HOME)"
     1432                } else {
     1433                        # the environment var isn't set, make an educated guess
    14331434                        set userhome "/Users/[uid_to_name [getuid]]"
    1434                        
    1435                         # set alternative prefix global variables
    1436                         set altprefix "$userhome/.macports"
    1437                        
    1438                         # get alternative paths
    1439                         set newworkpath "$altprefix/[ string range $workpath 1 end ]"
    1440                         set newworksymlink "$altprefix/[ string range $worksymlink 1 end ]"
    1441                        
    1442                         set sourcepath [string map {"work" ""} $worksymlink]
    1443                         set newsourcepath "$altprefix/[ string range $sourcepath 1 end ]"
    1444        
    1445                         # copy Portfile if not there already
    1446                         # note to self: should this be done always in case existing Portfile is out of date?
    1447                         if {![file exists ${newsourcepath}Portfile] } {
    1448                                 file mkdir $newsourcepath
    1449                                 ui_debug "$newsourcepath created"
    1450                                 ui_debug "Going to copy: ${sourcepath}Portfile"
    1451                                 file copy ${sourcepath}Portfile $newsourcepath
    1452                         }
    1453                        
    1454                         set workpath $newworkpath
    1455                         set worksymlink $newworksymlink
    1456                        
    1457                         ui_debug "Going to use $newworkpath for statefile."
    1458                 } else {
    1459                         return -code error "Insufficient privileges."
    14601435                }
     1436               
     1437                # set alternative prefix global variables
     1438                set altprefix "$userhome/.macports"
     1439               
     1440                # get alternative paths
     1441                set newworkpath "$altprefix/[ string range $workpath 1 end ]"
     1442                set newworksymlink "$altprefix/[ string range $worksymlink 1 end ]"
     1443               
     1444                set sourcepath [string map {"work" ""} $worksymlink]
     1445                set newsourcepath "$altprefix/[ string range $sourcepath 1 end ]"
     1446
     1447                # copy Portfile if not there already
     1448                # note to self: should this be done always in case existing Portfile is out of date?
     1449                if {![file exists ${newsourcepath}Portfile] } {
     1450                        file mkdir $newsourcepath
     1451                        ui_debug "$newsourcepath created"
     1452                        ui_debug "Going to copy: ${sourcepath}Portfile"
     1453                        file copy ${sourcepath}Portfile $newsourcepath
     1454                }
     1455               
     1456                set workpath $newworkpath
     1457                set worksymlink $newworksymlink
     1458               
     1459                ui_debug "Going to use $newworkpath for statefile."
    14611460    }
    14621461    # end gsoc08-privileges
Note: See TracChangeset for help on using the changeset viewer.