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

Last change on this file since 31681 was 31681, checked in by jmpp@…, 11 years ago

Cosmetic only changes to the postflight script.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1#!/bin/bash
2#
3# Copyright (c) 2007 Juan Manuel Palacios <jmpp@macports.org>
4# Copyright (c) 2005 Ole Guldberg Jensen <olegb@opendarwin.org>
5# Copyright (c) 2005 Dr. Ernie Prabhakar <drernir@opendarwin.org>
6# Copyright (c) 2005 Matt Anton <matt@opendarwin.org>
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY Eric Melville AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30# postflight
31# $Id: postflight 31681 2007-12-03 01:57:53Z jmpp@macports.org $
32
33
34BINPATH=/opt/local/bin
35SBINPATH=/opt/local/sbin
36
37
38echo -e "\nChecking the PATH variable for $USER...\n"
39
40# 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/
41if [ $(sw_vers -productVersion | awk -F . '{print $2}') -eq 5 ]; then
42    echo "No need to adjust the PATH and MANPATH environment variables on Leopard!"
43    exit 0
44fi
45
46if $SHELL -c "/usr/bin/printenv PATH" | grep -c $BINPATH > /dev/null; then
47    echo "You already have the right PATH!"
48else
49    USHELL=`basename $SHELL`
50    echo "Setting the PATH of $USHELL for $USER in ${HOME:=/Users/$USER}..."
51    case $USHELL in
52        *csh)
53            # we backup the original
54            /bin/cp -fp $HOME/.cshrc $HOME/.cshrc.mpsaved
55            echo "#" >> $HOME/.cshrc
56            echo "# Your previous .cshrc (if any) is saved as .cshrc.mpsaved" >> $HOME/.cshrc
57            echo "# Setting the path for MacPorts." >> $HOME/.cshrc
58            echo "set path=($BINPATH $SBINPATH" '$path'")" >> $HOME/.cshrc
59            chown $USER $HOME/.cshrc
60            echo "Finished modifying $HOME/.cshrc"
61        ;;
62        *sh)
63            # we backup the original
64            /bin/cp -fp $HOME/.profile $HOME/.profile.mpsaved
65            echo "#" >> $HOME/.profile
66            echo "# Your previous .profile  (if any) is saved as .profile.mpsaved" >> $HOME/.profile
67            echo "# Setting the path for MacPorts." >> $HOME/.profile
68            echo "export PATH=$BINPATH:$SBINPATH:\$PATH" >> $HOME/.profile
69            chown $USER $HOME/.profile
70            echo "Finished modifying $HOME/.profile"
71        ;;
72        *)
73            echo "Unknown shell! Please set your own PATH manually."
74        ;;
75    esac
76fi
77
78
79# Run selfupdate:
80export PATH=$BINPATH:$PATH
81echo -e "\nSelfupdating The MacPorts system...\n"
82port -d selfupdate
83if [ $? != 0 ]; then
84    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."
85    exit 1
86fi
87
88
89# Postflight script is done with its job!
90echo -e "\nYou have succesfully installed the MacPorts system.\n"
91echo "Launch a terminal and try it out!"
92echo -e "Read the port manual page for help.\n"
Note: See TracBrowser for help on using the repository browser.