source: trunk/base/portmgr/dmg/postflight @ 42662

Last change on this file since 42662 was 42662, checked in by raimue@…, 12 years ago

Merged revisions 34469,34852,34854-34855,34900,36952-36956,37507-37508,37511-37512,41040,41042-41046,41138-41139,41142-41143,41145,41151,41403,41458,41462-41463,42575,42626,42640-42641,42659 via svnmerge from
https://svn.macosforge.org/repository/macports/branches/variant-descs-14482/base

........

r34469 | raimue@… | 2008-02-26 07:08:09 +0100 (Tue, 26 Feb 2008) | 3 lines


port/port.tcl:
Reading from .config/variant_descriptions actually works

........

r34852 | raimue@… | 2008-03-09 02:45:22 +0100 (Sun, 09 Mar 2008) | 4 lines


macports1.0/macports.tcl:
New API: macports::getsourceconfigdir
Returns the path to .config for a porturl.

........

r34854 | raimue@… | 2008-03-09 03:11:27 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Use new API macports::getsourceconfigdir

........

r34855 | raimue@… | 2008-03-09 03:12:54 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Treat variant descriptions as strings to avoid problems with braces

........

r34900 | raimue@… | 2008-03-10 16:54:25 +0100 (Mon, 10 Mar 2008) | 3 lines


port/port.tcl:
Rename variable

........

r36952 | raimue@… | 2008-05-21 04:20:27 +0200 (Wed, 21 May 2008) | 3 lines


port/port.tcl:
Remove get_variant_desc, this will now be done in port1.0/portutil.tcl instead

........

r36953 | raimue@… | 2008-05-21 04:22:04 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give the worker access to variable porturl and proc getsourceconfigdir

........

r36954 | raimue@… | 2008-05-21 04:23:37 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/tests:
Fix the portutil test after r36953

........

r36955 | raimue@… | 2008-05-21 05:01:11 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give worker access to getprotocol and getportdir as they are needed for getsourceconfigdir

........

r36956 | raimue@… | 2008-05-21 05:02:23 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/portutil.tcl:
New proc variant_desc, reads global variant description file

........

r37507 | raimue@… | 2008-06-10 16:04:54 +0200 (Tue, 10 Jun 2008) | 4 lines


port1.0/portutil.tcl:
Don't warn about a missing description if it is set global,
but warn if the variant overrides the global description

........

r37508 | raimue@… | 2008-06-10 16:14:03 +0200 (Tue, 10 Jun 2008) | 3 lines


macports1.0/macports.tcl:
Use .resources instead of .config as it is a bit clearer, see #14553

........

r37511 | raimue@… | 2008-06-10 17:22:12 +0200 (Tue, 10 Jun 2008) | 5 lines


port1.0/portutil.tcl:
Switch back to this format:
name {description}
So this could be easily extended if ever needed.

........

r37512 | raimue@… | 2008-06-10 17:27:48 +0200 (Tue, 10 Jun 2008) | 3 lines


port1.0/portutil.tcl:
Add a warning if global variant description file could not be opened

........

r41040 | raimue@… | 2008-10-21 13:06:39 +0200 (Tue, 21 Oct 2008) | 4 lines


macports/macport.tcl:

  • New flag "default" for sources to indicate fallback for resources (group)
  • Add parameter to getsourceconfigdir to get path for a requested file

........

r41042 | raimue@… | 2008-10-21 13:11:44 +0200 (Tue, 21 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Rename getsourceconfigdir to getportresourcepath

........

r41043 | raimue@… | 2008-10-21 13:15:16 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for the group files

........

r41044 | raimue@… | 2008-10-21 13:19:47 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portlint.tcl:
Use getresourcepath for group files

........

r41045 | raimue@… | 2008-10-21 13:20:36 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Add a note that we should get rid of $portresourcepath in favor of [getportresourcepath]

........

r41046 | raimue@… | 2008-10-21 13:40:29 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Missed one instance of getsourceconfigdir

........

r41138 | raimue@… | 2008-10-25 20:52:50 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for global variant descriptions

........

r41139 | raimue@… | 2008-10-25 21:23:15 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Correct XXX tag

........

r41142 | raimue@… | 2008-10-25 23:11:30 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portfetch.tcl:
Use getportresourcepath

........

r41143 | raimue@… | 2008-10-25 23:12:04 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portdestroot.tcl:
Use getportresourcepath

........

r41145 | raimue@… | 2008-10-26 00:04:15 +0200 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix a problem with URLs not using the file protocol

........

r41151 | raimue@… | 2008-10-26 03:09:54 +0100 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix issues introduced in r41145, the file exists check was wrong

........

r41403 | raimue@… | 2008-11-01 22:59:21 +0100 (Sat, 01 Nov 2008) | 3 lines


port1.0/portutil.tcl:
Add a debug output which group files are used

........

r41458 | blb@… | 2008-11-03 22:58:28 +0100 (Mon, 03 Nov 2008) | 2 lines


Add [default] tag and description to sources.conf

........

r41462 | blb@… | 2008-11-04 02:12:28 +0100 (Tue, 04 Nov 2008) | 2 lines


No longer need to install resources with base

........

r41463 | blb@… | 2008-11-04 02:14:49 +0100 (Tue, 04 Nov 2008) | 4 lines


Move the install/ subdir (containing the mtree files) into .../share/macports
from the resources dir (the mtree contains a bit of install-time info, so it
shouldn't be with the resources stuff in the port tree)

........

r42575 | blb@… | 2008-11-25 01:53:05 +0100 (Tue, 25 Nov 2008) | 3 lines


Add script to handle upgrades through configure/make/make install and
the package, so [default] is added as appropriate to sources.conf

........

r42626 | raimue@… | 2008-11-27 02:21:15 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portpkg.tcl, package1.0/portmpkg.tcl:
Remove portresourcepath and use [getportresourcepath] instead

........

r42640 | raimue@… | 2008-11-27 11:49:32 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portrpm.tcl, package1.0/portsrpm.tcl:
Remove reference to portresurcepath which is not used at all

........

r42641 | raimue@… | 2008-11-27 11:52:12 +0100 (Thu, 27 Nov 2008) | 3 lines


port1.0/portmain.tcl:
Remove definition of portresourcepath as it is not used any more

........

r42659 | raimue@… | 2008-11-28 16:44:30 +0100 (Fri, 28 Nov 2008) | 3 lines


macports1.0/macports.tcl:
Rename portresourcepath from .resources to _resources

........

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.8 KB
Line 
1#!/bin/bash
2# -*- 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
3#
4# Copyright (c) 2002-2007 Juan Manuel Palacios <jmpp@macports.org>, The MacPorts Project.
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of Apple, Inc., The MacPorts Project nor the
16#    names of its contributors may be used to endorse or promote products
17#    derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
23# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29# SUCH DAMAGE.
30#
31# postflight
32# $Id: postflight 42662 2008-11-28 23:18:50Z raimue@macports.org $
33
34
35#set -x
36
37# Script identification ('cause more often than not the svn Id is not expanded):
38VERSION=1.7.0
39
40# Abstraction variables:
41PREFIX=/opt/local
42BINPATH=${PREFIX}/bin
43SBINPATH=${PREFIX}/sbin
44MANPAGES=${PREFIX}/share/man
45TCLSH=/usr/bin/tclsh
46TCL_PACKAGE_DIR=/Library/Tcl
47TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
48BACKUP_SUFFIX=macports-saved_${TIMESTAMP}
49OUR_STRING="MacPorts Installer addition on ${TIMESTAMP}"
50
51
52# Command to update the MacPorts installation through "selfupdate":
53function update_macports {
54    echo "Synchronizing the MacPorts installation with the project's rsync server..."
55    if ! ${BINPATH}/port -v selfupdate; then 
56        echo "An attempt to synchronize your recent MacPorts installation with the project's rsync server failed!"
57        echo "Please run 'sudo port -d selfupdate' manually to find out the cause of the error."
58    else
59        echo "Successful!"
60    fi
61   
62    # Remove any duplicates from the dep map (could occur with 1.6 and earlier)
63    ${TCLSH} dep_map_clean.tcl ${TCL_PACKAGE_DIR}
64    # Add [default] tag to the central MacPorts repository, if it isn't already
65    ${TCLSH} upgrade_sources_conf_default.tcl ${PREFIX}
66}
67
68# Through this command we write an environment variable to an appropriate shell configuration file,
69# backing up the original only if it exists and if it doesn't contain the ${OUR_STRING} identification string,
70# which hints that we've already tweaked it and therefore already baked it up.
71function write_setting () {
72    if [ -f ${HOME}/.${CONF_FILE} ] && ! grep "${OUR_STRING}" ${HOME}/.${CONF_FILE} > /dev/null; then
73        echo "Backing up your ${HOME}/.${CONF_FILE} shell confguration file as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX} before adapting it for MacPorts."
74        /bin/cp -fp ${HOME}/.${CONF_FILE} "${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}" || {
75            echo "An attempt to backup your original configuration file failed! Please set your MacPorts compatible environment manually."
76            update_macports
77            exit 1
78        }
79        echo -e "\n##\n# Your previous ${HOME}/.${CONF_FILE} file was backed up as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}\n##" >> ${HOME}/.${CONF_FILE}
80    fi
81    echo -e "\n# ${OUR_STRING}: adding an appropriate ${1} variable for use with MacPorts." >> ${HOME}/.${CONF_FILE}
82    echo "${ENV_COMMAND} ${1}${ASSIGN}${2}" >> ${HOME}/.${CONF_FILE}
83    echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n" >> ${HOME}/.${CONF_FILE}
84    chown ${USER} ${HOME}/.${CONF_FILE} || echo "Warning: unable to adapt permissions on your ${HOME}/.${CONF_FILE} shell configuration file!"
85    echo "An appropriate ${1} variable has been added to your shell environment by the MacPorts installer."
86}
87
88function cleanup_man () {
89    # Remove old non-compressed man pages
90    echo -e "\nRemoving old man pages..."
91    MAN1="port.1"
92    MAN5="macports.conf.5"
93    MAN7="portfile.7 portstyle.7 porthier.7 portgroup.7"
94    for m in ${MAN1}; do rm -vf ${MANPAGES}/man1/$m ; done
95    for m in ${MAN5}; do rm -vf ${MANPAGES}/man5/$m ; done
96    for m in ${MAN7}; do rm -vf ${MANPAGES}/man7/$m ; done
97    echo -e "Done.\n"
98}
99
100
101echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
102
103# Remove old stuff
104cleanup_man
105
106# Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
107# Exit nicely if the shell is any other than bash or tcsh, as that's considered non-standard.
108USHELL=$(dscl . -read /users/${USER} shell | awk -F'/' '{print $NF}') || {
109    echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
110    update_macports
111    exit 1
112}
113case "${USHELL}" in
114    tcsh)
115        echo "Detected the tcsh shell."
116        LOGIN_FLAG=""
117        ENV_COMMAND="setenv"
118        ASSIGN=" "
119        CONF_FILE=tcshrc
120        ;;
121    bash)
122        echo "Detected the bash shell."
123        LOGIN_FLAG="-l"
124        ENV_COMMAND="export"
125        ASSIGN="="
126        CONF_FILE=profile
127        ;;
128    *)
129        echo "Unknown shell ($USHELL)! Please set your MacPorts compatible environment manually."
130        update_macports
131        exit 0
132        ;;
133esac
134
135
136# Adding our setting to the PATH variable if not already there:
137if ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/printenv PATH" | grep ${PREFIX} > /dev/null; then
138    echo "Your shell already has the right PATH environment variable for use with MacPorts!"
139else
140    write_setting PATH "${BINPATH}:${SBINPATH}:\$PATH"
141fi
142
143# We gather the path into a variable of our own for faster operation:
144ORIGINAL_MANPATH="$(${SHELL} ${LOGIN_FLAG} -c "/usr/bin/printenv MANPATH")"
145# Adding out setting to the MANPATH variable only if it exists:
146if ! ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/env | grep MANPATH" > /dev/null || \
147# and following that, if it's not empty:
148  [ -z "${ORIGINAL_MANPATH}" ] || \
149# or if it doesn't already contain our path:
150  echo "${ORIGINAL_MANPATH}" | grep ${MANPAGES} > /dev/null || \
151# or if there's no empty component somewhere in the middle of it:
152  echo "${ORIGINAL_MANPATH}" | grep :: > /dev/null || \
153# or at the start of it:
154  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $1}')" ] || \
155# or at the end of it:
156  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $NF}')" ]; then
157    echo "Your shell already has the right MANPATH environment variable for use with MacPorts!"
158else
159    write_setting MANPATH "${MANPAGES}:\$MANPATH"
160fi
161
162# Adding a DISPLAY variable only if we're running on Tiger or less and if it doesn't already exist:
163if (($(sw_vers -productVersion | awk -F . '{print $2}') >= 5)) || ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/env | grep DISPLAY" > /dev/null; then
164    echo "Your shell already has the right DISPLAY environment variable for use with MacPorts!"
165else
166    write_setting DISPLAY ":0"
167fi
168
169
170# Postflight script is done with its job, update MacPorts and exit gracefully!
171update_macports
172echo "You have succesfully installed the MacPorts system, launch a terminal and try it out!"
173echo "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."
174exit 0
Note: See TracBrowser for help on using the repository browser.