[38096] branches/gsoc08-privileges/base

pmagrath at macports.org pmagrath at macports.org
Sun Jul 6 08:21:26 PDT 2008


Revision: 38096
          http://trac.macosforge.org/projects/macports/changeset/38096
Author:   pmagrath at macports.org
Date:     2008-07-06 08:21:25 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
Merged revisions 38033,38037-38038,38040 via svnmerge from 
https://svn.macosforge.org/repository/macports/trunk/base

........
  r38033 | raimue at macports.org | 2008-07-04 00:49:00 +0100 (Fri, 04 Jul 2008) | 3 lines
  
  port/port.tcl:
  Document depends: and depends_*: from r37909
........
  r38037 | raimue at macports.org | 2008-07-04 03:58:10 +0100 (Fri, 04 Jul 2008) | 3 lines
  
  portmgr/dmg/postflight:
  Copy the postflight script from the release_1_6 branch so the changes will not be lost or forgotten
........
  r38038 | raimue at macports.org | 2008-07-04 05:30:56 +0100 (Fri, 04 Jul 2008) | 4 lines
  
  port1.0/portextract.tcl:
  If the $distfile exists in $filespath, use it from there as it was not fetched
  to the distpath in this case.
........
  r38040 | raimue at macports.org | 2008-07-04 05:59:54 +0100 (Fri, 04 Jul 2008) | 3 lines
  
  portmgr/dmg/postflight:
  Remove old non-compressed man pages on install
........

Modified Paths:
--------------
    branches/gsoc08-privileges/base/portmgr/dmg/postflight
    branches/gsoc08-privileges/base/src/port/port.tcl
    branches/gsoc08-privileges/base/src/port1.0/portextract.tcl

Property Changed:
----------------
    branches/gsoc08-privileges/base/


Property changes on: branches/gsoc08-privileges/base
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/base:1-38003
   + /trunk/base:1-38095

Modified: branches/gsoc08-privileges/base/portmgr/dmg/postflight
===================================================================
--- branches/gsoc08-privileges/base/portmgr/dmg/postflight	2008-07-06 14:13:06 UTC (rev 38095)
+++ branches/gsoc08-privileges/base/portmgr/dmg/postflight	2008-07-06 15:21:25 UTC (rev 38096)
@@ -1,9 +1,7 @@
 #!/bin/bash
+# -*- coding: utf-8; mode: shell-script-mode; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=sh:et:sw=4:ts=4:sts=4
 #
-# Copyright (c) 2007 Juan Manuel Palacios <jmpp at macports.org>
-# Copyright (c) 2005 Ole Guldberg Jensen <olegb at opendarwin.org>
-# Copyright (c) 2005 Dr. Ernie Prabhakar <drernir at opendarwin.org>
-# Copyright (c) 2005 Matt Anton <matt at opendarwin.org>
+# Copyright (c) 2002-2007 Juan Manuel Palacios <jmpp at macports.org>, The MacPorts Project.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,11 +12,14 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple, Inc., The MacPorts Project nor the
+#    names of its contributors may be used to endorse or promote products
+#    derived from this software without specific prior written permission.
 #
-# THIS SOFTWARE IS PROVIDED BY Eric Melville AND CONTRIBUTORS ``AS IS'' AND
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -31,62 +32,136 @@
 # $Id$
 
 
-BINPATH=/opt/local/bin
-SBINPATH=/opt/local/sbin
+#set -x
 
+# Script identification ('cause more often than not the svn Id is not expanded):
+VERSION=1.7.0
 
-echo -e "\nChecking the PATH variable for $USER...\n"
+# Abstraction variables:
+PREFIX=/opt/local
+BINPATH=${PREFIX}/bin
+SBINPATH=${PREFIX}/sbin
+MANPAGES=${PREFIX}/share/man
+TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
+BACKUP_SUFFIX=macports-saved_${TIMESTAMP}
+OUR_STRING="MacPorts Installer addition on ${TIMESTAMP}"
 
-# No need to do any path adjustments if we're on Leopard, as we already install our path configs into /etc/paths.d/ and /etc/manpaths.d/
-if [ $(sw_vers -productVersion | awk -F . '{print $2}') -eq 5 ]; then
-    echo "No need to adjust the PATH and MANPATH environment variables on Leopard!"
-    exit 0
-fi
 
-if $SHELL -c "/usr/bin/printenv PATH" | grep -c $BINPATH > /dev/null; then
-    echo "You already have the right PATH!"
-else
-    USHELL=`basename $SHELL`
-    echo "Setting the PATH of $USHELL for $USER in ${HOME:=/Users/$USER}..."
-    case $USHELL in
-        *csh)
-	    # we backup the original
-            /bin/cp -fp $HOME/.cshrc $HOME/.cshrc.mpsaved
-            echo "#" >> $HOME/.cshrc
-            echo "# Your previous .cshrc (if any) is saved as .cshrc.mpsaved" >> $HOME/.cshrc
-            echo "# Setting the path for MacPorts." >> $HOME/.cshrc
-            echo "set path=($BINPATH $SBINPATH" '$path'")" >> $HOME/.cshrc
-            chown $USER $HOME/.cshrc
-            echo "Finished modifying $HOME/.cshrc"
+# Command to update the MacPorts installation through "selfupdate":
+function update_macports {
+    echo "Synchronizing the MacPorts installation with the project's rsync server..."
+    if ! ${BINPATH}/port -v selfupdate; then 
+        echo "An attempt to synchronize your recent MacPorts installation with the project's rsync server failed!"
+        echo "Please run 'sudo port -d selfupdate' manually to find out the cause of the error."
+    else
+        echo "Successful!"
+    fi
+}
+
+# Through this command we write an environment variable to an appropriate shell configuration file,
+# backing up the original only if it exists and if it doesn't contain the ${OUR_STRING} identification string,
+# which hints that we've already tweaked it and therefore already baked it up.
+function write_setting () {
+    if [ -f ${HOME}/.${CONF_FILE} ] && ! grep "${OUR_STRING}" ${HOME}/.${CONF_FILE} > /dev/null; then
+        echo "Backing up your ${HOME}/.${CONF_FILE} shell confguration file as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX} before adapting it for MacPorts."
+        /bin/cp -fp ${HOME}/.${CONF_FILE} "${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}" || {
+            echo "An attempt to backup your original configuration file failed! Please set your MacPorts compatible environment manually."
+            update_macports
+            exit 1
+        }
+        echo -e "\n##\n# Your previous ${HOME}/.${CONF_FILE} file was backed up as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}\n##" >> ${HOME}/.${CONF_FILE}
+    fi
+    echo -e "\n# ${OUR_STRING}: adding an appropriate ${1} variable for use with MacPorts." >> ${HOME}/.${CONF_FILE}
+    echo "${ENV_COMMAND} ${1}${ASSIGN}${2}" >> ${HOME}/.${CONF_FILE}
+    echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n" >> ${HOME}/.${CONF_FILE}
+    chown ${USER} ${HOME}/.${CONF_FILE} || echo "Warning: unable to adapt permissions on your ${HOME}/.${CONF_FILE} shell configuration file!"
+    echo "An appropriate ${1} variable has been added to your shell environment by the MacPorts installer."
+}
+
+function cleanup_man () {
+    # Remove old non-compressed man pages
+    echo -e "\nRemoving old man pages..."
+    MAN1="port.1"
+    MAN5="macports.conf.5"
+    MAN7="portfile.7 portstyle.7 porthier.7 portgroup.7"
+    for m in ${MAN1}; do rm -vf ${MANPAGES}/man1/$m ; done
+    for m in ${MAN5}; do rm -vf ${MANPAGES}/man5/$m ; done
+    for m in ${MAN7}; do rm -vf ${MANPAGES}/man7/$m ; done
+    echo -e "Done.\n"
+}
+
+
+echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
+
+# Remove old stuff
+cleanup_man
+
+# Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
+# Exit nicely if the shell is any other than bash or tcsh, as that's considered non-standard.
+USHELL=$(dscl . -read /users/${USER} shell | awk -F'/' '{print $NF}') || {
+    echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
+    update_macports
+    exit 1
+}
+case "${USHELL}" in
+    tcsh)
+        echo "Detected the tcsh shell."
+        LOGIN_FLAG=""
+        ENV_COMMAND="setenv"
+        ASSIGN=" "
+        CONF_FILE=tcshrc
         ;;
-	*sh)
-	    # we backup the original
-            /bin/cp -fp $HOME/.profile $HOME/.profile.mpsaved
-            echo "#" >> $HOME/.profile
-            echo "# Your previous .profile  (if any) is saved as .profile.mpsaved" >> $HOME/.profile
-            echo "# Setting the path for MacPorts." >> $HOME/.profile
-            echo "export PATH=$BINPATH:$SBINPATH:\$PATH" >> $HOME/.profile
-            chown $USER $HOME/.profile
-            echo "Finished modifying $HOME/.profile"
+    bash)
+        echo "Detected the bash shell."
+        LOGIN_FLAG="-l"
+        ENV_COMMAND="export"
+        ASSIGN="="
+        CONF_FILE=profile
         ;;
-	*)
-            echo "Unknown shell! Please set your own PATH manually."
+    *)
+        echo "Unknown shell ($USHELL)! Please set your MacPorts compatible environment manually."
+        update_macports
+        exit 0
         ;;
-    esac
+esac
+
+
+# Adding our setting to the PATH variable if not already there:
+if ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/printenv PATH" | grep ${PREFIX} > /dev/null; then
+    echo "Your shell already has the right PATH environment variable for use with MacPorts!"
+else
+    write_setting PATH "${BINPATH}:${SBINPATH}:\$PATH"
 fi
 
+# We gather the path into a variable of our own for faster operation:
+ORIGINAL_MANPATH="$(${SHELL} ${LOGIN_FLAG} -c "/usr/bin/printenv MANPATH")"
+# Adding out setting to the MANPATH variable only if it exists:
+if ! ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/env | grep MANPATH" > /dev/null || \
+# and following that, if it's not empty:
+  [ -z "${ORIGINAL_MANPATH}" ] || \
+# or if it doesn't already contain our path:
+  echo "${ORIGINAL_MANPATH}" | grep ${MANPAGES} > /dev/null || \
+# or if there's no empty component somewhere in the middle of it:
+  echo "${ORIGINAL_MANPATH}" | grep :: > /dev/null || \
+# or at the start of it:
+  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $1}')" ] || \
+# or at the end of it:
+  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $NF}')" ]; then
+    echo "Your shell already has the right MANPATH environment variable for use with MacPorts!"
+else
+    write_setting MANPATH "${MANPAGES}:\$MANPATH"
+fi
 
-# Run selfupdate:
-export PATH=$BINPATH:$PATH
-echo -e "\nSelfupdating The MacPorts system...\n"
-port -d selfupdate
-if [ $? != 0 ]; then
-    echo "An attempt to synchronize your recent MacPorts installation with the rsync server failed, please run 'port -d selfupdate' manually to find out the cause of the error."
-    exit 1
+# Adding a DISPLAY variable only if we're running on Tiger or less and if it doesn't already exist:
+if (($(sw_vers -productVersion | awk -F . '{print $2}') >= 5)) || ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/env | grep DISPLAY" > /dev/null; then
+    echo "Your shell already has the right DISPLAY environment variable for use with MacPorts!"
+else
+    write_setting DISPLAY ":0"
 fi
 
 
-# Postflight script is done with its job!
-echo -e "\nYou have succesfully installed the MacPorts system.\n"
-echo "Launch a terminal and try it out!"
-echo -e "Read the port manual page for help.\n"
+# Postflight script is done with its job, update MacPorts and exit gracefully!
+update_macports
+echo "You have succesfully installed the MacPorts system, launch a terminal and try it out!"
+echo "Read the port(1) manual page and http://guide.macports.org for help, http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project."
+exit 0

Modified: branches/gsoc08-privileges/base/src/port/port.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port/port.tcl	2008-07-06 14:13:06 UTC (rev 38095)
+++ branches/gsoc08-privileges/base/src/port/port.tcl	2008-07-06 15:21:25 UTC (rev 38096)
@@ -55,7 +55,6 @@
     puts stderr "\"$cmdname help\" or \"man 1 port\" for more information."
 }
 
-
 proc print_help {args} {
     global cmdname
     global action_array
@@ -97,9 +96,10 @@
 These pseudo-portnames expand to the set of ports named.
 
 Additional pseudo-portnames start with...
-variants:, variant:, description:, portdir:, homepage:, epoch:,
-platforms:, platform:, name:, long_description:, maintainers:,
-maintainer:, categories:, category:, version:, and revision:.
+variants:, variant:, description:, depends:, depends_lib:, depends_run:,
+depends_build:, portdir:, homepage:, epoch:, platforms:, platform:, name:,
+long_description:, maintainers:, maintainer:, categories:, category:, version:,
+and revision:.
 These each select a set of ports based on a regex search of metadata
 about the ports. In all such cases, a standard regex pattern following
 the colon will be used to select the set of ports to which the

Modified: branches/gsoc08-privileges/base/src/port1.0/portextract.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portextract.tcl	2008-07-06 14:13:06 UTC (rev 38095)
+++ branches/gsoc08-privileges/base/src/port1.0/portextract.tcl	2008-07-06 15:21:25 UTC (rev 38096)
@@ -93,6 +93,7 @@
 
 proc extract_main {args} {
     global UI_PREFIX euid egid worksrcpath macportsuser
+    global filespath
     
     if {![exists distfiles] && ![exists extract.only]} {
 	# nothing to do
@@ -101,7 +102,11 @@
 
     foreach distfile [option extract.only] {
 	ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]"
-	option extract.args "[option distpath]/$distfile"
+	if {[file exists $filespath/$distfile]} {
+		option extract.args "$filespath/$distfile"
+	} else {
+		option extract.args "[option distpath]/$distfile"
+	}
 	if {[catch {command_exec extract} result]} {
 	    return -code error "$result"
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080706/6a6b2472/attachment.html 


More information about the macports-changes mailing list