#!/bin/sh ## ## Shell-based package for OpenPKG source bootstrap procedure ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH ## Copyright (c) 2000-2002 The OpenPKG Project ## Copyright (c) 2000-2002 Ralf S. Engelschall ## # defaults f="$0" h=0 v='' p='' u='' g='' d='@DIR@' t='@TGZ@' # parse command line options for opt do case $opt in -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;; *) arg='' ;; esac case $opt in -h | --help ) h=1 ;; -v | --verbose ) v=v ;; --prefix=* ) p=$arg ;; --user=* ) u=$arg ;; --group=* ) g=$arg ;; * ) h=1 ;; esac done if [ ".$p" = . ]; then h=1 fi if [ ".$h" = .1 ]; then echo "Usage: sh $0 [-h|--help] [-v|--verbose] --prefix= [--user=] [--group=]" 2>&1 exit 1 fi # establish standard environment LC_CTYPE=C export LC_CTYPE umask 022 # determine current user and group thisuser=`(id -un) 2>/dev/null ||\ (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\ (whoami) 2>/dev/null ||\ (who am i | cut "-d " -f1) 2>/dev/null ||\ echo $LOGNAME` thisgroup=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\ grep "^${thisuser}:" | awk -F: '{ print $4; }'` thisgroup=`(cat /etc/group; ypcat group) 2>/dev/null |\ grep ":${thisgroup}:" | awk -F: '{ print $1; }'` if [ ".$thisgroup" = . ]; then thisgroup="$thisuser" fi # perform the extraction echo "$0: extracting to $d..." uudecode $f rm -rf $d >/dev/null 2>&1 mkdir $d || exit 1 uncompress <$t |\ (cd $d; tar x${v}f - 2>/dev/null) if [ ".$thisuser" = .root ]; then ( cd $d chown -R -h $thisuser . >/dev/null 2>&1 || true chgrp -R -h $thisgroup . >/dev/null 2>&1 || true ) fi echo "$0: extraction done." # perform building echo "$0: building for $p..." cd $d || exit 1 ./openpkg.boot $p $u $g || exit 1 echo "$0: build done." # cleanup echo "$0: cleaning up..." cd .. rm -rf $d >/dev/null 2>&1 rm -f $t >/dev/null 2>&1 echo "$0: cleaned up." # die explicitly just before the shell would discover # that we carry mega-bytes of data with us... exit 0 # the distribution tarball