src/scripts/pkgrecv.sh
author Rich Burridge <rich.burridge@sun.com>
Mon, 30 Nov 2009 13:01:40 -0800
changeset 1516 8c950a3b4171
parent 395 0ae5e72ba7ee
child 3177 173c3b46334b
permissions -rw-r--r--
10485 move pkg(5) to Python 2.6 10482 upgrade to cherrypy 3.1.2 11836 shebang line for python modules should be python version-agnostic 11950 ldtp used by pkg build process not setup to easily use Python 2.6 11989 pkg python dependency analysis tests fail
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
395
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     1
#!/bin/sh
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     2
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     4
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     8
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    13
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    19
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    21
#
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    22
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    23
# Use is subject to license terms.
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    24
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    25
# Resolve a symbolic link to the true file location
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    26
resolve_symlink () {
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    27
    file="$1"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    28
    while [ -h "$file" ]; do
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    29
        ls=`ls -ld "$file"`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    30
        link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    31
        if expr "$link" : '^/' 2> /dev/null >/dev/null; then
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    32
            file="$link"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    33
        else
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    34
            file=`dirname "$1"`"/$link"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    35
        fi
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    36
    done
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    37
    echo "$file"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    38
}
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    39
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    40
# Take a relative path and make it absolute. Pwd -P will
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    41
# resolve any symlinks in the path
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    42
make_absolute () {
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    43
    save_pwd=`pwd`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    44
    cd $1;
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    45
    full_path=`pwd -P`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    46
    cd $save_pwd
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    47
    echo "$full_path"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    48
}
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    49
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    50
cmd=`resolve_symlink $0` 
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    51
my_home_relative=`dirname $cmd`  
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    52
my_home=`make_absolute $my_home_relative`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    53
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    54
my_base=`cd ${my_home}/../../..; pwd`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    55
my_ips_base=`cd ${my_home}/../..; pwd`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    56
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${my_ips_base}/usr/lib
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    57
PYTHONHOME=${my_base}/python
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 395
diff changeset
    58
PYTHONPATH=${PYTHONPATH}:${my_ips_base}/usr/lib/python2.6/vendor-packages
395
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    59
PKG_HOME=${my_ips_base}/usr
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    60
export LD_LIBRARY_PATH PYTHONHOME PYTHONPATH PKG_HOME
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 395
diff changeset
    61
if [ -x ${my_base}/python/bin/python2.6 ] ; then
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 395
diff changeset
    62
  PYEXE=${my_base}/python/bin/python2.6
395
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    63
else
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    64
  PYEXE=`which python`
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    65
  unset PYTHONHOME
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    66
fi
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    67
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    68
exec ${PYEXE} ${my_home}/pull.py "$@"
0ae5e72ba7ee 1958 Modify setup.py to handle pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
diff changeset
    69