home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / Perl / Perl.pkg / Perl.pre_install < prev    next >
Encoding:
Text File  |  1996-03-08  |  2.4 KB  |  95 lines

  1. #!/bin/sh
  2. # $Id$
  3. # Copyright 1996 TipTop Software
  4.  
  5. packagePath=$1
  6. installPath=$2
  7.  
  8. PATH=$PATH:$packagePath; export PATH
  9.  
  10. checkIfSameDir()
  11. {
  12.   d1=$1
  13.   d2=$2
  14.  
  15.   echo "Checking if $d1 and $d2 are the same directory."
  16.   if test \( -d $d1 -o -h $d1 \) -a \( -d $d2 -o -h $d2 \); then
  17.     FILENAME=`date`
  18.     touch $d1/$FILENAME
  19.     if test -f $d2/$FILENAME; then
  20.       rm $d1/$FILENAME
  21.       echo "Great!  $d1 and $d2 are the same directory."
  22.       return 0;
  23.     fi
  24.     rm $d1/$FILENAME
  25.     ap=`alertpanel "Alert" "$d1 and $d2 are not the same directory.  It is HIGHLY desirable that you merge these directories and create a symbolic link from one to the other (so that they are effectively the same directory)!  Do you want to continue anyway?" "Exit" "Continue"`
  26.     if test "$ap" = "Exit"; then 
  27.       echo "Merge $d1 and $d2 and create a symlink from one to the other"
  28.       echo "(so that they are effectively the same directory)."
  29.       return 1
  30.     fi
  31.  
  32.     echo " "
  33.     echo "WARNING: $d1 and $d2 are not the same directory."
  34.     echo "Continuing anyway!"
  35.     echo " "
  36.     return 0
  37.   fi
  38.  
  39.   if test -d $d2 -o -h $d2; then
  40.     p=`expr "$d1" : '\(.*[^/]\)/*'`
  41.     p=`expr "$p" : '\(.*\)/[^/]*'`
  42.     mkdirs $p
  43.     ln -s $d2 $d1
  44.     echo "Creating symlink $d1 --> $d2"
  45.     return 0
  46.   fi
  47.  
  48.   p=`expr "$d2" : '\(.*[^/]\)/*'`
  49.   p=`expr "$p" : '\(.*\)/[^/]*'`
  50.   mkdirs $p
  51.   ln -s $d1 $d2
  52.   echo "Creating symlink $d2 --> $d1"
  53.   return 0
  54. }
  55.  
  56. preparePackage()
  57. {
  58.   packageName=`basename $packagePath`
  59.   packageName=`expr "$packageName" : '\(.*\)\.pkg'`
  60.   
  61.   # Do this only if a prior Install hasn't been done.
  62.   if [ -f "${packagePath}/${packageName}.tar.gz" ]; then
  63.     trap "rm -f /tmp/##${packageName}##.tar.Z /tmp/.#yes# /tmp/.#no#" 1 2 3 15
  64.     echo -n "\n    Decompressing $packageName contents "
  65.     rm -f /tmp/.#yes# /tmp/.#no#
  66.     (gzcat ${packagePath}/${packageName}.tar.gz |\
  67.       compress -c > /tmp/##${packageName}##.tar.Z
  68.       if [ $? -eq 1 ]; then
  69.     touch /tmp/.#no#
  70.       else
  71.     touch /tmp/.#yes#
  72.       fi) &
  73.     while [ ! -f /tmp/.#yes# -a ! -f /tmp/.#no# ]; do
  74.       sleep 5
  75.       echo -n .
  76.     done
  77.     if [ -f /tmp/.#yes# ]; then
  78.       echo " OK."
  79.       rm -f /tmp/.#yes#
  80.     else
  81.       echo " Error."
  82.       rm -f ./tmp/.#no# /tmp/##${packageName}##.tar.Z
  83.       return 1
  84.     fi
  85.   fi
  86.   return 0
  87. }
  88.  
  89. echo " "
  90. checkIfSameDir /LocalDeveloper/Libraries /usr/local/lib || exit 1
  91. preparePackage || exit 1
  92.  
  93. exit 0
  94. # EOF
  95.