aux.wrapbin.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/sh
  2. ##
  3. ## Shell-based package for OpenPKG BINARY bootstrap installation
  4. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  5. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  6. ## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
  7. ##
  8. ## Permission to use, copy, modify, and distribute this software for
  9. ## any purpose with or without fee is hereby granted, provided that
  10. ## the above copyright notice and this permission notice appear in all
  11. ## copies.
  12. ##
  13. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  14. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  17. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  20. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  23. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. ## SUCH DAMAGE.
  25. ##
  26. # defaults
  27. f="$0"
  28. help=0
  29. verbose=0
  30. prefix='@l_prefix@'
  31. t='@TGZ@'
  32. susr='@SUSR@'
  33. sgrp='@SGRP@'
  34. musr='@MUSR@'
  35. mgrp='@MGRP@'
  36. rusr='@RUSR@'
  37. rgrp='@RGRP@'
  38. nusr='@NUSR@'
  39. ngrp='@NGRP@'
  40. # parse command line options
  41. for opt
  42. do
  43. case $opt in
  44. -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  45. *) arg='' ;;
  46. esac
  47. case $opt in
  48. -h | --help ) help=1 ;;
  49. -v | --verbose ) verbose=1 ;;
  50. --prefix=* ) prefix=$arg ;;
  51. * ) help=1 ;;
  52. esac
  53. done
  54. if [ ".$prefix" = . ]; then
  55. help=1
  56. fi
  57. if [ ".$help" = .1 ]; then
  58. echo "Usage: sh $0 [-h|--help] [-v|--verbose] [--prefix=<prefix>]" 2>&1
  59. exit 1
  60. fi
  61. # establish standard environment
  62. LC_CTYPE=C
  63. export LC_CTYPE
  64. umask 022
  65. # determine current username
  66. cusr=`(id -un) 2>/dev/null ||\
  67. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  68. (whoami) 2>/dev/null ||\
  69. (who am i | cut "-d " -f1) 2>/dev/null ||\
  70. echo $LOGNAME`
  71. # perform the installation
  72. echo "$0: installing into $prefix..."
  73. # the reason of the following magic you certainly don't want to understand ;)
  74. set -- 1
  75. @PRE@
  76. d=''
  77. for c in `IFS=/; echo $prefix`; do
  78. d="$d/$c"
  79. if [ ! -d $d ]; then
  80. mkdir $d || exit 1
  81. chmod 755 $d || exit 1
  82. if [ ".$cusr" = .root ]; then
  83. chown $musr $d >/dev/null 2>&1 || true
  84. chgrp $mgrp $d >/dev/null 2>&1 || true
  85. fi
  86. fi
  87. done
  88. uudecode $f
  89. uncompress <$t |\
  90. (cd $prefix; tar x${v}f -)
  91. rm -f $t >/dev/null 2>&1
  92. if [ ".$cusr" = .root ]; then
  93. ( cd $prefix || exit 1
  94. chown -R -h $musr . >/dev/null 2>&1 || true
  95. chgrp -R -h $mgrp . >/dev/null 2>&1 || true
  96. )
  97. fi
  98. echo "$0: installation done."
  99. # die explicitly just before the shell would discover
  100. # that we carry mega-bytes of data with us...
  101. exit 0
  102. # the distribution tarball