[118017] trunk/base

jmr at macports.org jmr at macports.org
Wed Mar 19 06:47:17 PDT 2014


Revision: 118017
          https://trac.macports.org/changeset/118017
Author:   jmr at macports.org
Date:     2014-03-19 06:47:16 -0700 (Wed, 19 Mar 2014)
Log Message:
-----------
set TCLSH in postflight from autoconf

Modified Paths:
--------------
    trunk/base/configure
    trunk/base/configure.ac

Added Paths:
-----------
    trunk/base/portmgr/dmg/postflight.in

Removed Paths:
-------------
    trunk/base/portmgr/dmg/postflight

Property Changed:
----------------
    trunk/base/portmgr/dmg/

Modified: trunk/base/configure
===================================================================
--- trunk/base/configure	2014-03-19 13:17:39 UTC (rev 118016)
+++ trunk/base/configure	2014-03-19 13:47:16 UTC (rev 118017)
@@ -10591,7 +10591,7 @@
 
 
 # Output
-ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/Makefile doc/base.mtree doc/macosx.mtree doc/macports.conf doc/prefix.mtree doc/pubkeys.conf portmgr/freebsd/Makefile setupenv.bash src/Makefile src/cflib1.0/Makefile src/cregistry/Makefile src/darwintracelib1.0/Makefile src/machista1.0/Makefile src/macports1.0/Makefile src/macports1.0/macports_autoconf.tcl src/macports1.0/macports_fastload.tcl src/macports1.0/macports_test_autoconf.tcl src/package1.0/Makefile src/package1.0/package_test_autoconf.tcl src/pextlib1.0/Makefile src/port/Makefile src/port1.0/Makefile src/port1.0/port_autoconf.tcl src/port1.0/port_test_autoconf.tcl src/programs/Makefile src/registry2.0/Makefile src/registry2.0/registry_autoconf.tcl tests/Makefile vendor/Makefile"
+ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/Makefile doc/base.mtree doc/macosx.mtree doc/macports.conf doc/prefix.mtree doc/pubkeys.conf portmgr/freebsd/Makefile portmgr/dmg/postflight setupenv.bash src/Makefile src/cflib1.0/Makefile src/cregistry/Makefile src/darwintracelib1.0/Makefile src/machista1.0/Makefile src/macports1.0/Makefile src/macports1.0/macports_autoconf.tcl src/macports1.0/macports_fastload.tcl src/macports1.0/macports_test_autoconf.tcl src/package1.0/Makefile src/package1.0/package_test_autoconf.tcl src/pextlib1.0/Makefile src/port/Makefile src/port1.0/Makefile src/port1.0/port_autoconf.tcl src/port1.0/port_test_autoconf.tcl src/programs/Makefile src/registry2.0/Makefile src/registry2.0/registry_autoconf.tcl tests/Makefile vendor/Makefile"
 
 
 ac_config_files="$ac_config_files src/pkg_mkindex.sh"
@@ -11299,6 +11299,7 @@
     "doc/prefix.mtree") CONFIG_FILES="$CONFIG_FILES doc/prefix.mtree" ;;
     "doc/pubkeys.conf") CONFIG_FILES="$CONFIG_FILES doc/pubkeys.conf" ;;
     "portmgr/freebsd/Makefile") CONFIG_FILES="$CONFIG_FILES portmgr/freebsd/Makefile" ;;
+    "portmgr/dmg/postflight") CONFIG_FILES="$CONFIG_FILES portmgr/dmg/postflight" ;;
     "setupenv.bash") CONFIG_FILES="$CONFIG_FILES setupenv.bash" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "src/cflib1.0/Makefile") CONFIG_FILES="$CONFIG_FILES src/cflib1.0/Makefile" ;;

Modified: trunk/base/configure.ac
===================================================================
--- trunk/base/configure.ac	2014-03-19 13:17:39 UTC (rev 118016)
+++ trunk/base/configure.ac	2014-03-19 13:47:16 UTC (rev 118017)
@@ -404,6 +404,7 @@
 	doc/prefix.mtree
 	doc/pubkeys.conf
 	portmgr/freebsd/Makefile
+	portmgr/dmg/postflight
 	setupenv.bash
 	src/Makefile
 	src/cflib1.0/Makefile


Property changes on: trunk/base/portmgr/dmg
___________________________________________________________________
Added: svn:ignore
   + postflight


Deleted: trunk/base/portmgr/dmg/postflight
===================================================================
--- trunk/base/portmgr/dmg/postflight	2014-03-19 13:17:39 UTC (rev 118016)
+++ trunk/base/portmgr/dmg/postflight	2014-03-19 13:47:16 UTC (rev 118017)
@@ -1,281 +0,0 @@
-#!/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) 2008-2012 The MacPorts Project
-# 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
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 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 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 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 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)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# postflight
-# $Id$
-
-
-#set -x
-
-# Script identification ('cause more often than not the svn Id is not expanded):
-VERSION=2.1.0
-
-# Abstraction variables:
-PREFIX=__PREFIX__
-BINPATH=${PREFIX}/bin
-SBINPATH=${PREFIX}/sbin
-CONFIGPATH=${PREFIX}/etc/macports
-MANPAGES=${PREFIX}/share/man
-MACPORTS_TCL_DIR=${PREFIX}/share/macports/Tcl
-REG1DIR=${MACPORTS_TCL_DIR}/registry1.0
-DSCL=/usr/bin/dscl
-RUNUSR=macports
-TCLSH=/usr/bin/tclsh
-TCL_PACKAGE_DIR=/Library/Tcl
-TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
-BACKUP_SUFFIX=macports-saved_${TIMESTAMP}
-OUR_STRING="MacPorts Installer addition on ${TIMESTAMP}"
-
-# Create config files from defaults if not present
-function setup_configs {
-    for f in archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf ; do
-        if [[ ! -f ${CONFIGPATH}/${f} ]]; then
-            echo "Copying ${f}.default to ${f}"
-            /bin/cp ${CONFIGPATH}/${f}.default ${CONFIGPATH}/${f}
-            /bin/chmod 644 ${CONFIGPATH}/${f}
-        fi
-    done
-}
-
-# Command to update the MacPorts installation through "selfupdate":
-function update_macports {
-    SCRIPT_DIR=$(dirname $0)
-    # Add [default] tag to the central MacPorts repository, if it isn't already
-    echo "Adding [default] tag to sources.conf if needed..."
-    ${TCLSH} ${SCRIPT_DIR}/upgrade_sources_conf_default.tcl ${PREFIX}
-    # Convert image directories (and direct mode installs) to image archives
-    echo "Updating port image format..."
-    ${TCLSH} ${SCRIPT_DIR}/images_to_archives.tcl ${MACPORTS_TCL_DIR}
-    ${TCLSH} ${SCRIPT_DIR}/dedup_portfiles.tcl ${MACPORTS_TCL_DIR}
-
-    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 backed 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"
-}
-
-# Delete the old registry1.0 directory
-function delete_reg1 {
-    if [[ -d ${REG1DIR} ]]; then
-        rm -vrf ${REG1DIR}
-    fi
-}
-
-# link macports1.0 into tcl package dir if possible
-function link_tcl_package {
-    # delete old directory if present
-    if [[ ! -L "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
-        if [[ ! -e "${TCL_PACKAGE_DIR}" ]]; then
-            /usr/bin/install -d "${TCL_PACKAGE_DIR}" || true
-        fi
-        if [[ -d "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
-            rm -vrf "${TCL_PACKAGE_DIR}/macports1.0" || true
-        fi
-        if [[ ! -e "${TCL_PACKAGE_DIR}/macports1.0" && -d "${TCL_PACKAGE_DIR}" ]]; then
-            ln -vs "${MACPORTS_TCL_DIR}/macports1.0" "${TCL_PACKAGE_DIR}/macports1.0" || true
-        fi
-	fi
-}
-
-# create the user to use for privilege dropping
-function create_run_user {
-    DSEDITGROUP=/usr/sbin/dseditgroup
-    if ! ${DSCL} -q . -read /Groups/${RUNUSR} > /dev/null 2>&1 ; then
-        echo "Creating group \"${RUNUSR}\""
-        ${DSEDITGROUP} -q -o create ${RUNUSR}
-    fi
-    if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then
-        echo "Creating user \"${RUNUSR}\""
-        NEXTUID=501
-        while [[ -n "`${DSCL} -q /Search -search /Users UniqueID $NEXTUID`" ]]; do
-            let "NEXTUID=NEXTUID+1"
-        done
-        ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $NEXTUID
-
-        # These are implicitly added on Mac OSX Lion.  AuthenticationAuthority
-        # causes the user to be visible in the Users & Groups Preference Pane,
-        # and the others are just noise, so delete them.
-        # https://trac.macports.org/ticket/30168
-        ${DSCL} -q . -delete /Users/${RUNUSR} AuthenticationAuthority
-        ${DSCL} -q . -delete /Users/${RUNUSR} PasswordPolicyOptions
-        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:KerberosKeys
-        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:ShadowHashData
-
-        ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts
-        ${DSCL} -q . -create /Users/${RUNUSR} Password \*
-        ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
-        ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${PREFIX}/var/macports/home
-        ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false
-    fi
-    if [[ $(sw_vers -productVersion | /usr/bin/awk -F . '{print $2}') -eq 4 ]]; then
-        GID=$(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
-        if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} PrimaryGroupID 2>/dev/null | /usr/bin/awk '{print $2}')" != "$GID" ]]; then
-            echo "Fixing PrimaryGroupID for user \"${RUNUSR}\""
-            ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $GID
-            ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts
-        fi
-    fi
-    if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} NFSHomeDirectory)" = "NFSHomeDirectory: /var/empty" ]]; then
-        echo "Updating home directory location for user \"${RUNUSR}\""
-        ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${PREFIX}/var/macports/home
-    fi
-}
-
-echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
-
-# create macports user
-create_run_user
-# Set up config files
-setup_configs
-# link macports1.0 pkg
-link_tcl_package
-
-# Remove old stuff
-cleanup_man
-delete_reg1
-
-# 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=" "
-        if [[ -f "${HOME}/.tcshrc" ]]; then
-            CONF_FILE=tcshrc
-        elif [[ -f "${HOME}/.cshrc" ]]; then
-            CONF_FILE=cshrc
-        else
-            CONF_FILE=tcshrc
-        fi
-        ;;
-    bash)
-        echo "Detected the bash shell."
-        LOGIN_FLAG="-l"
-        ENV_COMMAND="export"
-        ASSIGN="="
-        if [[ -f "${HOME}/.bash_profile" ]]; then
-            CONF_FILE=bash_profile
-        elif [[ -f "${HOME}/.bash_login" ]]; then
-            CONF_FILE=bash_login
-        else
-            CONF_FILE=profile
-        fi
-        ;;
-    *)
-        echo "Unknown shell ($USHELL)! Please set your MacPorts compatible environment manually."
-        update_macports
-        exit 0
-        ;;
-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 our 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
-
-# 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, update MacPorts and exit gracefully!
-update_macports
-echo "You have successfully 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."
-echo "See http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project."
-exit 0

Copied: trunk/base/portmgr/dmg/postflight.in (from rev 118016, trunk/base/portmgr/dmg/postflight)
===================================================================
--- trunk/base/portmgr/dmg/postflight.in	                        (rev 0)
+++ trunk/base/portmgr/dmg/postflight.in	2014-03-19 13:47:16 UTC (rev 118017)
@@ -0,0 +1,281 @@
+#!/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) 2008-2012 The MacPorts Project
+# 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
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 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 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 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 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)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# postflight
+# $Id$
+
+
+#set -x
+
+# Script identification ('cause more often than not the svn Id is not expanded):
+VERSION=2.3.0
+
+# Abstraction variables:
+PREFIX=__PREFIX__
+BINPATH=${PREFIX}/bin
+SBINPATH=${PREFIX}/sbin
+CONFIGPATH=${PREFIX}/etc/macports
+MANPAGES=${PREFIX}/share/man
+MACPORTS_TCL_DIR=${PREFIX}/share/macports/Tcl
+REG1DIR=${MACPORTS_TCL_DIR}/registry1.0
+DSCL=/usr/bin/dscl
+RUNUSR=macports
+TCLSH=@TCLSH@
+TCL_PACKAGE_DIR=/Library/Tcl
+TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
+BACKUP_SUFFIX=macports-saved_${TIMESTAMP}
+OUR_STRING="MacPorts Installer addition on ${TIMESTAMP}"
+
+# Create config files from defaults if not present
+function setup_configs {
+    for f in archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf ; do
+        if [[ ! -f ${CONFIGPATH}/${f} ]]; then
+            echo "Copying ${f}.default to ${f}"
+            /bin/cp ${CONFIGPATH}/${f}.default ${CONFIGPATH}/${f}
+            /bin/chmod 644 ${CONFIGPATH}/${f}
+        fi
+    done
+}
+
+# Command to update the MacPorts installation through "selfupdate":
+function update_macports {
+    SCRIPT_DIR=$(dirname $0)
+    # Add [default] tag to the central MacPorts repository, if it isn't already
+    echo "Adding [default] tag to sources.conf if needed..."
+    ${TCLSH} ${SCRIPT_DIR}/upgrade_sources_conf_default.tcl ${PREFIX}
+    # Convert image directories (and direct mode installs) to image archives
+    echo "Updating port image format..."
+    ${TCLSH} ${SCRIPT_DIR}/images_to_archives.tcl ${MACPORTS_TCL_DIR}
+    ${TCLSH} ${SCRIPT_DIR}/dedup_portfiles.tcl ${MACPORTS_TCL_DIR}
+
+    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 backed 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"
+}
+
+# Delete the old registry1.0 directory
+function delete_reg1 {
+    if [[ -d ${REG1DIR} ]]; then
+        rm -vrf ${REG1DIR}
+    fi
+}
+
+# link macports1.0 into tcl package dir if possible
+function link_tcl_package {
+    # delete old directory if present
+    if [[ ! -L "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
+        if [[ ! -e "${TCL_PACKAGE_DIR}" ]]; then
+            /usr/bin/install -d "${TCL_PACKAGE_DIR}" || true
+        fi
+        if [[ -d "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
+            rm -vrf "${TCL_PACKAGE_DIR}/macports1.0" || true
+        fi
+        if [[ ! -e "${TCL_PACKAGE_DIR}/macports1.0" && -d "${TCL_PACKAGE_DIR}" ]]; then
+            ln -vs "${MACPORTS_TCL_DIR}/macports1.0" "${TCL_PACKAGE_DIR}/macports1.0" || true
+        fi
+	fi
+}
+
+# create the user to use for privilege dropping
+function create_run_user {
+    DSEDITGROUP=/usr/sbin/dseditgroup
+    if ! ${DSCL} -q . -read /Groups/${RUNUSR} > /dev/null 2>&1 ; then
+        echo "Creating group \"${RUNUSR}\""
+        ${DSEDITGROUP} -q -o create ${RUNUSR}
+    fi
+    if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then
+        echo "Creating user \"${RUNUSR}\""
+        NEXTUID=501
+        while [[ -n "`${DSCL} -q /Search -search /Users UniqueID $NEXTUID`" ]]; do
+            let "NEXTUID=NEXTUID+1"
+        done
+        ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $NEXTUID
+
+        # These are implicitly added on Mac OSX Lion.  AuthenticationAuthority
+        # causes the user to be visible in the Users & Groups Preference Pane,
+        # and the others are just noise, so delete them.
+        # https://trac.macports.org/ticket/30168
+        ${DSCL} -q . -delete /Users/${RUNUSR} AuthenticationAuthority
+        ${DSCL} -q . -delete /Users/${RUNUSR} PasswordPolicyOptions
+        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:KerberosKeys
+        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:ShadowHashData
+
+        ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts
+        ${DSCL} -q . -create /Users/${RUNUSR} Password \*
+        ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
+        ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${PREFIX}/var/macports/home
+        ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false
+    fi
+    if [[ $(sw_vers -productVersion | /usr/bin/awk -F . '{print $2}') -eq 4 ]]; then
+        GID=$(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
+        if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} PrimaryGroupID 2>/dev/null | /usr/bin/awk '{print $2}')" != "$GID" ]]; then
+            echo "Fixing PrimaryGroupID for user \"${RUNUSR}\""
+            ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $GID
+            ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts
+        fi
+    fi
+    if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} NFSHomeDirectory)" = "NFSHomeDirectory: /var/empty" ]]; then
+        echo "Updating home directory location for user \"${RUNUSR}\""
+        ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${PREFIX}/var/macports/home
+    fi
+}
+
+echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
+
+# create macports user
+create_run_user
+# Set up config files
+setup_configs
+# link macports1.0 pkg
+link_tcl_package
+
+# Remove old stuff
+cleanup_man
+delete_reg1
+
+# 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=" "
+        if [[ -f "${HOME}/.tcshrc" ]]; then
+            CONF_FILE=tcshrc
+        elif [[ -f "${HOME}/.cshrc" ]]; then
+            CONF_FILE=cshrc
+        else
+            CONF_FILE=tcshrc
+        fi
+        ;;
+    bash)
+        echo "Detected the bash shell."
+        LOGIN_FLAG="-l"
+        ENV_COMMAND="export"
+        ASSIGN="="
+        if [[ -f "${HOME}/.bash_profile" ]]; then
+            CONF_FILE=bash_profile
+        elif [[ -f "${HOME}/.bash_login" ]]; then
+            CONF_FILE=bash_login
+        else
+            CONF_FILE=profile
+        fi
+        ;;
+    *)
+        echo "Unknown shell ($USHELL)! Please set your MacPorts compatible environment manually."
+        update_macports
+        exit 0
+        ;;
+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 our 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
+
+# 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, update MacPorts and exit gracefully!
+update_macports
+echo "You have successfully 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."
+echo "See http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project."
+exit 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140319/da38a479/attachment-0001.html>


More information about the macports-changes mailing list