#!/bin/sh # # $dotat: buildworld/common.sh,v 1.49 2002/07/25 10:24:04 fanf2 Exp $ # fatal errors set -e # use the installed utilities initially PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH # be liberal with access controls umask 002 # work out the date for adding to version strings and tags, etc. DATE=`date +%Y%m%d` # logging PROG=${0##*/} LOGFILE=${LOGFILE:-$SCRIPTS/logs/${PROG%.sh}.$DATE} # overriding this might work, but I haven't tried it [ -z "$SRC" ] && SRC=/usr/src # get the real path of $SRC (is this reliable?) cd $SRC SRC=`pwd -P` # location of the build staging tree OBJ=/usr/obj$SRC # location of special-case programs for the later parts # of building and all of inistalling WEIRD=$OBJ/weirdbin # location of new root files for comparison with old ones ROOT=$OBJ/root # get the path of the X source [ -z "$XC" ] && XC=$SRC/../xc cd $XC XC=`pwd -P` # work out names of kernel config files if [ -d $SRC/sys/i386/conf ] then cd $SRC/sys/i386/conf KERNCONF=`ls | egrep -v '^\.|CVS'` else KERNCONF='GENERIC LINT' fi # ignore error returns errok () { set +e eval ${1+"$@"} set -e } # print out a command then execute it run () { echo "$@" "$@" } # some useful prettifiers banner () { echo echo ============================================================== echo '>>>' $* echo ============================================================== } centre () { fmt -c 60 62 <<-END $* END } bigbanner () { echo echo '**************************************************************' echo '**************************************************************' echo centre $* echo echo '**************************************************************' echo '**************************************************************' } # add DIR to PATH if we can't find PROG addpath () { local PROG DIR PROG=$1 DIR=$2 if [ -z "`which $PROG`" ] then PATH=$PATH:$DIR fi } # make a path which contains all the programs we need # XXX: we are using possibly cross-compiled binaries! goodpath () { local XBIN # location of the cross-compiler binaries XBIN=$OBJ/`uname -m` # create the path... PATH=$XBIN/usr/bin PATH=$PATH:$XBIN/usr/sbin PATH=$PATH:$XBIN/usr/games PATH=$PATH:$WEIRD addpath diff $OBJ/gnu/usr.bin/diff addpath gzip $OBJ/gnu/usr.bin/gzip addpath kbdcontrol $OBJ/usr.sbin/kbdcontrol addpath mtree $OBJ/usr.sbin/mtree addpath pwd_mkdb $OBJ/usr.sbin/pwd_mkdb addpath basename $OBJ/usr.bin/basename addpath chflags $OBJ/usr.bin/chflags addpath diff $OBJ/usr.bin/diff addpath file2c $OBJ/usr.bin/file2c addpath find $OBJ/usr.bin/find addpath fmt $OBJ/usr.bin/fmt addpath m4 $OBJ/usr.bin/m4 addpath mail $OBJ/usr.bin/mail addpath make $OBJ/usr.bin/make addpath sed $OBJ/usr.bin/sed addpath tee $OBJ/usr.bin/tee addpath tr $OBJ/usr.bin/tr addpath uname $OBJ/usr.bin/uname addpath mount $OBJ/sbin/mount addpath cat $OBJ/bin/cat addpath chmod $OBJ/bin/chmod addpath cp $OBJ/bin/cp addpath date $OBJ/bin/date addpath hostname $OBJ/bin/hostname addpath ln $OBJ/bin/ln addpath mkdir $OBJ/bin/mkdir addpath mv $OBJ/bin/mv addpath rm $OBJ/bin/rm addpath sh $OBJ/bin/sh addpath test $OBJ/bin/test export PATH echo PATH=$PATH }