[89994] trunk/base/src
jmr at macports.org
jmr at macports.org
Sat Feb 18 22:46:41 PST 2012
Revision: 89994
http://trac.macports.org/changeset/89994
Author: jmr at macports.org
Date: 2012-02-18 22:46:39 -0800 (Sat, 18 Feb 2012)
Log Message:
-----------
set env(HOME) to our own dirs (#31827) and link user's xcode 4.3 plist into them
Modified Paths:
--------------
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/port1.0/portmain.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2012-02-19 04:11:08 UTC (rev 89993)
+++ trunk/base/src/macports1.0/macports.tcl 2012-02-19 06:46:39 UTC (rev 89994)
@@ -6,7 +6,7 @@
# Copyright (c) 2004 - 2005 Paul Guyot, <pguyot at kallisys.net>.
# Copyright (c) 2004 - 2006 Ole Guldberg Jensen <olegb at opendarwin.org>.
# Copyright (c) 2004 - 2005 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2004 - 2011 The MacPorts Project
+# Copyright (c) 2004 - 2012 The MacPorts Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,7 @@
variable user_options "submitter_name submitter_email submitter_key"
variable portinterp_options "\
portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
- registry.path registry.format \
+ registry.path registry.format user_home \
portarchivetype archivefetch_pubkeys portautoclean porttrace keeplogs portverbose destroot_umask \
rsync_server rsync_options rsync_dir startupitem_type startupitem_install place_worksymlink macportsuser \
mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
@@ -492,16 +492,6 @@
# Set the system encoding to utf-8
encoding system utf-8
- # Ensure that the macports user directory exists if HOME is defined
- if {[info exists env(HOME)]} {
- set macports::macports_user_dir [file normalize $macports::autoconf::macports_user_dir]
- } else {
- # Otherwise define the user directory as a direcotory that will never exist
- set macports::macports_user_dir "/dev/null/NO_HOME_DIR"
- # Tcl library code wants to do tilde expansion in various places
- set env(HOME) ${macports::macports_user_dir}
- }
-
# set up platform info variables
set os_arch $tcl_platform(machine)
if {$os_arch == "Power Macintosh"} { set os_arch "powerpc" }
@@ -517,6 +507,23 @@
set macosx_version [expr 10.0 + ($os_major - 4) / 10.0]
}
+ # Ensure that the macports user directory (i.e. ~/.macports) exists if HOME is defined.
+ # Also save $HOME for later use before replacing it with our own.
+ if {[info exists env(HOME)]} {
+ set macports::user_home $env(HOME)
+ set macports::macports_user_dir [file normalize $macports::autoconf::macports_user_dir]
+ } elseif {[info exists env(SUDO_USER)] && $os_platform == "darwin"} {
+ set macports::user_home [exec dscl -q . -read /Users/$env(SUDO_USER) NFSHomeDirectory | cut -d ' ' -f 2]
+ set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
+ } elseif {[exec id -u] != 0 && $os_platform == "darwin"} {
+ set macports::user_home [exec dscl -q . -read /Users/[exec id -un] NFSHomeDirectory | cut -d ' ' -f 2]
+ set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
+ } else {
+ # Otherwise define the user directory as a directory that will never exist
+ set macports::macports_user_dir "/dev/null/NO_HOME_DIR"
+ set macports::user_home "/dev/null/NO_HOME_DIR"
+ }
+
# Configure the search path for configuration files
set conf_files ""
lappend conf_files "${macports_conf_path}/macports.conf"
@@ -656,6 +663,7 @@
}
}
+ set env(HOME) [file join $portdbpath home]
set registry.path $portdbpath
# Format for receipts; currently only "sqlite" is allowed
@@ -932,6 +940,10 @@
trace add variable macports::xcodebuildcmd read macports::setxcodeinfo
}
+ if {[vercmp $xcodeversion 4.3] >= 0} {
+ macports::link_xcode_plist $env(HOME)
+ }
+
# Set the default umask
if {![info exists destroot_umask]} {
set destroot_umask 022
@@ -1063,6 +1075,23 @@
registry::close
}
+# link plist for xcode 4.3's benefit
+proc macports::link_xcode_plist {target_homedir} {
+ global macports::user_home
+ set user_plist "${user_home}/Library/Preferences/com.apple.dt.Xcode.plist"
+ set plist_link "${target_homedir}/Library/Preferences/com.apple.dt.Xcode.plist"
+ if {[file isfile $user_plist] && ([catch {file type $plist_link} filetype]
+ || $filetype != "link" || [file link $plist_link] != $user_plist)} {
+ if {[catch {
+ file mkdir "${target_homedir}/Library/Preferences"
+ file delete -force $plist_link
+ file link -symbolic $plist_link $user_plist
+ } result]} {
+ ui_debug "Failed to link com.apple.dt.Xcode.plist: $result"
+ }
+ }
+}
+
proc macports::worker_init {workername portpath porturl portbuildpath options variations} {
global macports::portinterp_options macports::portinterp_deferred_options
@@ -1122,6 +1151,7 @@
$workername alias realpath realpath
$workername alias _mportsearchpath _mportsearchpath
$workername alias _portnameactive _portnameactive
+ $workername alias _link_xcode_plist macports::link_xcode_plist
# New Registry/Receipts stuff
$workername alias registry_new registry::new_entry
Modified: trunk/base/src/port1.0/portmain.tcl
===================================================================
--- trunk/base/src/port1.0/portmain.tcl 2012-02-19 04:11:08 UTC (rev 89993)
+++ trunk/base/src/port1.0/portmain.tcl 2012-02-19 06:46:39 UTC (rev 89994)
@@ -57,7 +57,7 @@
supported_archs depends_skip_archcheck installs_libs \
license_noconflict copy_log_files \
compiler.cpath compiler.library_path \
- add_users
+ add_users altprefix
# Order of option_proc and option_export matters. Filter before exporting.
@@ -230,30 +230,9 @@
set euid [geteuid]
set egid [getegid]
-# resolve the alternate work path in ~/.macports
-proc portmain::set_altprefix {} {
- global altprefix env euid
-
- # do tilde expansion manually - Tcl won't expand tildes automatically for curl, etc.
- if {[info exists env(HOME)]} {
- # HOME environment var is set, use it.
- set userhome "$env(HOME)"
- } elseif {$euid == 0 && [info exists env(SUDO_USER)] && $env(SUDO_USER) != ""} {
- set userhome [file normalize "~$env(SUDO_USER)"]
- } else {
- # the environment var isn't set, expand ~user instead
- set username [uid_to_name [getuid]]
- if {[catch {set userhome [file normalize "~$username"]}]} {
- set userhome ""
- }
- }
-
- set altprefix [file join $userhome .macports]
-}
-
# if unable to write to workpath, implies running without either root privileges
# or a shared directory owned by the group so use ~/.macports
-portmain::set_altprefix
+default altprefix {[file join $user_home .macports]}
if { $euid != 0 && (([info exists workpath] && [file exists $workpath] && ![file writable $workpath]) || ([info exists portdbpath] && ![file writable [file join $portdbpath build]])) } {
# set global variable indicating to other functions to use ~/.macports as well
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2012-02-19 04:11:08 UTC (rev 89993)
+++ trunk/base/src/port1.0/portutil.tcl 2012-02-19 06:46:39 UTC (rev 89994)
@@ -5,7 +5,7 @@
# Copyright (c) 2002-2003 Apple Inc.
# Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
# Copyright (c) 2006-2007 Markus W. Weissmann <mww at macports.org>
-# Copyright (c) 2004-2011 The MacPorts Project
+# Copyright (c) 2004-2012 The MacPorts Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -1301,11 +1301,14 @@
set ports_dry_last_skipped ""
proc target_run {ditem} {
- global target_state_fd workpath portpath ports_trace PortInfo ports_dryrun ports_dry_last_skipped worksrcpath prefix subport
+ global target_state_fd workpath portpath ports_trace PortInfo ports_dryrun \
+ ports_dry_last_skipped worksrcpath prefix subport env portdbpath
set portname $subport
set result 0
set skipped 0
set procedure [ditem_key $ditem procedure]
+ set savedhome [file join $portdbpath home]
+ set env(HOME) "${workpath}/.home"
if {[ditem_key $ditem state] != "no"} {
set target_state_fd [open_statefile]
@@ -1500,6 +1503,8 @@
close $target_state_fd
}
+ set env(HOME) $savedhome
+
return $result
}
@@ -1605,8 +1610,8 @@
# open_statefile
# open file to store name of completed targets
proc open_statefile {args} {
- global workpath worksymlink place_worksymlink subport portpath ports_ignore_older ports_dryrun
- global usealtworkpath altprefix env applications_dir subbuildpath
+ global workpath worksymlink place_worksymlink subport portpath ports_ignore_older ports_dryrun \
+ usealtworkpath altprefix env applications_dir subbuildpath
if {$usealtworkpath} {
ui_warn_once "privileges" "MacPorts running without privileges.\
@@ -1633,7 +1638,11 @@
if {![tbool ports_dryrun]} {
if {![file isdirectory $workpath]} {
- file mkdir $workpath
+ file mkdir "${workpath}/.home"
+ global xcodeversion
+ if {[vercmp $xcodeversion 4.3] >= 0} {
+ _link_xcode_plist "${workpath}/.home"
+ }
chownAsRoot $subbuildpath
}
# Create a symlink to the workpath for port authors
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120218/62a41d5a/attachment-0001.html>
More information about the macports-changes
mailing list