src/scripts/pkg.sh
changeset 290 6c5c87515614
child 1516 8c950a3b4171
equal deleted inserted replaced
289:c2e63370fb2b 290:6c5c87515614
       
     1 #!/bin/sh
       
     2 #
       
     3 # CDDL HEADER START
       
     4 #
       
     5 # The contents of this file are subject to the terms of the
       
     6 # Common Development and Distribution License (the "License").
       
     7 # You may not use this file except in compliance with the License.
       
     8 #
       
     9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    10 # or http://www.opensolaris.org/os/licensing.
       
    11 # See the License for the specific language governing permissions
       
    12 # and limitations under the License.
       
    13 #
       
    14 # When distributing Covered Code, include this CDDL HEADER in each
       
    15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    16 # If applicable, add the following below this CDDL HEADER, with the
       
    17 # fields enclosed by brackets "[]" replaced with your own identifying
       
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
       
    23 # Use is subject to license terms.
       
    24 
       
    25 # Resolve a symbolic link to the true file location
       
    26 resolve_symlink () {
       
    27     file="$1"
       
    28     while [ -h "$file" ]; do
       
    29         ls=`ls -ld "$file"`
       
    30         link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
       
    31         if expr "$link" : '^/' 2> /dev/null >/dev/null; then
       
    32             file="$link"
       
    33         else
       
    34             file=`dirname "$1"`"/$link"
       
    35         fi
       
    36     done
       
    37     echo "$file"
       
    38 }
       
    39 
       
    40 # Take a relative path and make it absolute. Pwd -P will
       
    41 # resolve any symlinks in the path
       
    42 make_absolute () {
       
    43     save_pwd=`pwd`
       
    44     cd $1;
       
    45     full_path=`pwd -P`
       
    46     cd $save_pwd
       
    47     echo "$full_path"
       
    48 }
       
    49 
       
    50 cmd=`resolve_symlink $0` 
       
    51 my_home_relative=`dirname $cmd`  
       
    52 my_home=`make_absolute $my_home_relative`
       
    53 
       
    54 my_base=`cd ${my_home}/../../..; pwd`
       
    55 my_ips_base=`cd ${my_home}/../..; pwd`
       
    56 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${my_ips_base}/usr/lib
       
    57 PYTHONHOME=${my_base}/python
       
    58 PYTHONPATH=${PYTHONPATH}:${my_ips_base}/usr/lib/python2.4/vendor-packages
       
    59 PKG_HOME=${my_ips_base}/usr
       
    60 export LD_LIBRARY_PATH PYTHONHOME PYTHONPATH PKG_HOME
       
    61 if [ -x ${my_base}/python/bin/python2.4 ] ; then
       
    62   PYEXE=${my_base}/python/bin/python2.4
       
    63 else
       
    64   PYEXE=`which python`
       
    65   unset PYTHONHOME
       
    66 fi
       
    67 
       
    68 exec ${PYEXE} ${my_home}/client.py "$@"
       
    69