wrap1.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/sh
  2. ##
  3. ## Shell-based package for OpenPKG source bootstrap procedure
  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. # defaults
  9. f="$0"
  10. h=0
  11. v=''
  12. p=''
  13. u=''
  14. g=''
  15. d='@DIR@'
  16. t='@TGZ@'
  17. # parse command line options
  18. for opt
  19. do
  20. case $opt in
  21. -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  22. *) arg='' ;;
  23. esac
  24. case $opt in
  25. -h | --help ) h=1 ;;
  26. -v | --verbose ) v=v ;;
  27. --prefix=* ) p=$arg ;;
  28. --user=* ) u=$arg ;;
  29. --group=* ) g=$arg ;;
  30. * ) h=1 ;;
  31. esac
  32. done
  33. if [ ".$p" = . ]; then
  34. h=1
  35. fi
  36. if [ ".$h" = .1 ]; then
  37. echo "Usage: sh $0 [-h|--help] [-v|--verbose] --prefix=<prefix> [--user=<user>] [--group=<group>]" 2>&1
  38. exit 1
  39. fi
  40. # establish standard environment
  41. LC_CTYPE=C
  42. export LC_CTYPE
  43. umask 022
  44. # determine current user and group
  45. thisuser=`(id -un) 2>/dev/null ||\
  46. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  47. (whoami) 2>/dev/null ||\
  48. (who am i | cut "-d " -f1) 2>/dev/null ||\
  49. echo $LOGNAME`
  50. thisgroup=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  51. grep "^${thisuser}:" | awk -F: '{ print $4; }'`
  52. thisgroup=`(cat /etc/group; ypcat group) 2>/dev/null |\
  53. grep ":${thisgroup}:" | awk -F: '{ print $1; }'`
  54. if [ ".$thisgroup" = . ]; then
  55. thisgroup="$thisuser"
  56. fi
  57. # perform the extraction
  58. echo "$0: extracting to $d..."
  59. uudecode $f
  60. rm -rf $d >/dev/null 2>&1
  61. mkdir $d || exit 1
  62. uncompress <$t |\
  63. (cd $d; tar x${v}f - 2>/dev/null)
  64. if [ ".$thisuser" = .root ]; then
  65. ( cd $d
  66. chown -R -h $thisuser . >/dev/null 2>&1 || true
  67. chgrp -R -h $thisgroup . >/dev/null 2>&1 || true
  68. )
  69. fi
  70. echo "$0: extraction done."
  71. # perform building
  72. echo "$0: building for $p..."
  73. cd $d || exit 1
  74. ./openpkg.boot $p $u $g || exit 1
  75. echo "$0: build done."
  76. # cleanup
  77. echo "$0: cleaning up..."
  78. cd ..
  79. rm -rf $d >/dev/null 2>&1
  80. rm -f $t >/dev/null 2>&1
  81. echo "$0: cleaned up."
  82. # die explicitly just before the shell would discover
  83. # that we carry mega-bytes of data with us...
  84. exit 0
  85. # the distribution tarball