[32627] branches/release_1_6/base/portmgr/dmg/postflight

jmpp at macports.org jmpp at macports.org
Wed Jan 9 21:37:46 PST 2008


Revision: 32627
          http://trac.macosforge.org/projects/macports/changeset/32627
Author:   jmpp at macports.org
Date:     2008-01-09 21:37:45 -0800 (Wed, 09 Jan 2008)

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

 * Turn the code that selfupdates the recenrtly installed MacPorts into a shell function, 'update_macports', so that it can be called from multiple places;
 * Having done that, exit gracefully after calling 'update_macports' if the shell can't be determined, so as to make sure no further attemps to tweak the environment are made;
 * Call 'update_macports' in every single place where we exit the script, as tweaking the environment (whether successfully or not) is orthogonal to updating MacPorts.

Modified Paths:
--------------
    branches/release_1_6/base/portmgr/dmg/postflight

Modified: branches/release_1_6/base/portmgr/dmg/postflight
===================================================================
--- branches/release_1_6/base/portmgr/dmg/postflight	2008-01-10 02:30:47 UTC (rev 32626)
+++ branches/release_1_6/base/portmgr/dmg/postflight	2008-01-10 05:37:45 UTC (rev 32627)
@@ -39,21 +39,9 @@
 MANPAGES=$PREFIX/share/man
 USHELL="$(basename "$SHELL" 2>/dev/null)" || {
     echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
+    update_macports
     exit 1
 }
-case "$USHELL" in
-    tcsh)
-        CONF_FILE=tcshrc
-        LOGIN_FLAG=""
-        ;;
-    bash)
-        CONF_FILE=profile
-        LOGIN_FLAG="-l"
-        ;;
-    *)
-        echo "Unknown shell! Please set your MacPorts compatible environment manually."
-        ;;
-esac
 BACKUP_SUFFIX=mpsaved_"$(date +"%Y-%m-%d_at_%H:%M:%S")"
 OUR_STRING="MacPorts setting on $(date +"%Y-%m-%d at %H:%M:%S"):"
 
@@ -65,6 +53,7 @@
     if [ -f $HOME/.$CONF_FILE ] && ! grep "$OUR_STRING" $HOME/.$CONF_FILE > /dev/null 2>&1; then
         /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
@@ -97,7 +86,36 @@
     echo -e "# Finished adapting your $1 environment variable for use with MacPorts.\n" >> $HOME/.$CONF_FILE
 }
 
+# Command to update the MacPorts installation through "selfupdate":
+function update_macports {
+    export PATH=$BINPATH:$PATH
+    echo -e "\nSynchronizing the MacPorts installation with the project's rsync server...\n"
+    port -v selfupdate || {
+        echo "An attempt to synchronize your recent MacPorts installation with the project's rsync server failed!"
+        echo "Please run 'port -d selfupdate' manually to find out the cause of the error."
+    }
+}
 
+
+# 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.
+case "$USHELL" in
+    tcsh)
+        CONF_FILE=tcshrc
+        LOGIN_FLAG=""
+        ;;
+    bash)
+        CONF_FILE=profile
+        LOGIN_FLAG="-l"
+        ;;
+    *)
+        echo "Unknown shell! Please set your MacPorts compatible environment manually."
+        update_macports
+        exit 0
+        ;;
+esac
+
+
 echo -e "\nChecking the shell environment for user \"$USER\"...\n"
 
 # Adding our setting to the PATH variable if not already there:
@@ -134,17 +152,8 @@
 fi
 
 
-# Update the MacPorts installation through "selfupdate":
-echo -e "\nSynchronizing the MacPorts installation with the project's rsync server...\n"
-export PATH=$BINPATH:$PATH
-port -v selfupdate || {
-    echo "An attempt to synchronize your recent MacPorts installation with the project's rsync server failed!"
-    echo "Please run 'port -d selfupdate' manually to find out the cause of the error."
-}
-
-
 # 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(1) manual page for help.\n"
+update_macports
+echo -e "\nYou have succesfully installed the MacPorts system, launch a terminal and try it out!\n"
+echo -e "Read the port(1) manual page and http://guide.macports.org for help.\n"
 exit 0

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


More information about the macports-changes mailing list