wrap2.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. ##
  3. ## Shell-based package for OpenPKG binary bootstrap installation
  4. ## Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  5. ## Copyright (c) 2000-2001 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. # defaults
  8. f="$0"
  9. h=0
  10. v=''
  11. p='@l_prefix@'
  12. t='@TGZ@'
  13. fsusr='@FSUSR@'
  14. fsgrp='@FSGRP@'
  15. # parse command line options
  16. for opt
  17. do
  18. case $opt in
  19. -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  20. *) arg='' ;;
  21. esac
  22. case $opt in
  23. -h | --help ) h=1 ;;
  24. -v | --verbose ) v=v ;;
  25. --prefix=* ) p=$arg ;;
  26. * ) h=1 ;;
  27. esac
  28. done
  29. if [ ".$h" = .1 ]; then
  30. echo "Usage: sh $0 [-h|--help] [-v|--verbose] [--prefix=<prefix>]" 2>&1
  31. exit 1
  32. fi
  33. # establish standard environment
  34. LC_CTYPE=C
  35. export LC_CTYPE
  36. umask 022
  37. # determine current username
  38. thisuser=`(id -un) 2>/dev/null ||\
  39. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  40. (whoami) 2>/dev/null ||\
  41. (who am i | cut "-d " -f1) 2>/dev/null ||\
  42. echo $LOGNAME`
  43. # perform the installation
  44. echo "$0: installing into $p..."
  45. # the reason of the following magic you certainly don't want to understand ;)
  46. set -- 1
  47. @PRE@
  48. d=''
  49. for c in `IFS=/; echo $p`; do
  50. d="$d/$c"
  51. if [ ! -d $d ]; then
  52. mkdir $d || exit 1
  53. chmod 755 $d || exit 1
  54. if [ ".$thisuser" = .root ]; then
  55. chown $fsusr $d >/dev/null 2>&1 || true
  56. chgrp $fsgrp $d >/dev/null 2>&1 || true
  57. fi
  58. fi
  59. done
  60. uudecode $f
  61. uncompress <$t |\
  62. (cd $p; tar x${v}f -)
  63. rm -f $t >/dev/null 2>&1
  64. if [ ".$thisuser" = .root ]; then
  65. ( cd $p || exit 1
  66. chown -R -h $fsusr . >/dev/null 2>&1 || true
  67. chgrp -R -h $fsgrp . >/dev/null 2>&1 || true
  68. )
  69. fi
  70. echo "$0: installation done."
  71. # die explicitly just before the shell would discover
  72. # that we carry mega-bytes of data with us...
  73. exit 0
  74. # the distribution tarball