1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

bin/package: more cleanups (re: 9166545a)

src/cmd/INIT/package.sh, bin/package:
- Derive the command name from $0 instead of hardcoding it.
- Remove NPROC and related code to support parallel building. This
  is not supported with mamake, is unlikely to be reintroduced any
  time soon, and if it ever is it will need to be done in a
  different way anwyay.
- Invoke 'sed' and 'tr' directly instead of via $SED and $TR
  variables. We're not building our own dynamically linked 'sed'
  and 'tr' in this distribution so LD_LIBRARY_PATH is irrelevant.
  If we ever do again, there are better ways to make sure the OS
  standard 'sed' and 'tr' are invoked than this kludge.
- Use note() consistently to print warnings to standard error.
  note() is changed to print each argument on a new line prefixed
  by the command name, so arguments need to be quoted now if they
  are to be shown on a single line.
- Use a new err_out() function to error out, avoiding code
  repetition.
This commit is contained in:
Martijn Dekker 2021-12-18 14:38:23 +00:00
parent ce3e080c0e
commit 69e0de9274
2 changed files with 196 additions and 338 deletions

View file

@ -23,7 +23,6 @@
# based on AST 'package' by Glenn Fowler <gsf@research.att.com> # # based on AST 'package' by Glenn Fowler <gsf@research.att.com> #
# simplified and rewritten by Martijn Dekker <martijn@inlv.org> # # simplified and rewritten by Martijn Dekker <martijn@inlv.org> #
######################################################################## ########################################################################
command=package
# Escape from a non-POSIX shell # Escape from a non-POSIX shell
min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\ min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\
@ -95,18 +94,17 @@ lib="" # need /usr/local/lib /usr/local/shlib
ccs="/usr/kvm /usr/ccs/bin" ccs="/usr/kvm /usr/ccs/bin"
org="gnu GNU" org="gnu GNU"
makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile
env="HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH" env="HOSTTYPE PACKAGEROOT INSTALLROOT PATH"
package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC=' package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC='
CROSS=0 CROSS=0
MAKESKIP=${MAKESKIP:-"*[-.]*"} MAKESKIP=${MAKESKIP:-"*[-.]*"}
SED=
TR=
all_types='*.*|sun4' # all but sun4 match *.* all_types='*.*|sun4' # all but sun4 match *.*
command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$' 0123) USAGE=$'
[-? [-?
@ -125,7 +123,7 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
All package files are in the \b$PACKAGEROOT\b directory tree. All package files are in the \b$PACKAGEROOT\b directory tree.
Binary package files are in the \b$INSTALLROOT\b Binary package files are in the \b$INSTALLROOT\b
(\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where (\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where
\ahosttpe\a=$(\bbin/package host type\b). \ahosttype\a=$(\bbin/package host type\b).
See \bDETAILS\b for more information.] See \bDETAILS\b for more information.]
[+?Note that no environment variables need be set by the user; [+?Note that no environment variables need be set by the user;
\b'$command$'\b determines the environment based on the current working \b'$command$'\b determines the environment based on the current working
@ -371,6 +369,8 @@ do case $# in
exec 1>&2 exec 1>&2
;; ;;
esac esac
# Plain-text fallback. Regenerate with:
# ksh -c 'COLUMNS=80 bin/package --man' 2>&1 | sed "s/'/'\\\\''/g; 1s/^/echo '/; \$s/\$/'/"
echo 'NAME echo 'NAME
package - build, test and install ksh 93u+m package - build, test and install ksh 93u+m
@ -383,7 +383,7 @@ DESCRIPTION
POSIX shell and C compiler installation are the only requirements. All POSIX shell and C compiler installation are the only requirements. All
package files are in the $PACKAGEROOT directory tree. Binary package files package files are in the $PACKAGEROOT directory tree. Binary package files
are in the $INSTALLROOT ($PACKAGEROOT/arch/hosttype) tree, where are in the $INSTALLROOT ($PACKAGEROOT/arch/hosttype) tree, where
hosttpe=$(bin/package host type). See DETAILS for more information. hosttype=$(bin/package host type). See DETAILS for more information.
Note that no environment variables need be set by the user; package Note that no environment variables need be set by the user; package
determines the environment based on the current working directory. The use determines the environment based on the current working directory. The use
@ -417,8 +417,7 @@ DESCRIPTION
export [ variable ...] export [ variable ...]
List name=value for variable, one per line. If the only attribute is List name=value for variable, one per line. If the only attribute is
specified then only the variable values are listed. If no variables specified then only the variable values are listed. If no variables
are specified then HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH are are specified then HOSTTYPE PACKAGEROOT INSTALLROOT PATH are assumed.
assumed.
help [ action ] help [ action ]
Display help text on the standard error (standard output for action). Display help text on the standard error (standard output for action).
host [ attribute ... ] host [ attribute ... ]
@ -727,7 +726,7 @@ use) case $1 in
*) HOSTTYPE=$HOSTTYPE-64 ;; *) HOSTTYPE=$HOSTTYPE-64 ;;
esac esac
case $wow in case $wow in
*/32) echo $command: cannot build $bit-bit on $wow $sys >&2; exit 2 ;; */32) err_out "cannot build $bit-bit on $wow $sys" ;;
esac esac
;; ;;
esac esac
@ -739,8 +738,8 @@ use) case $1 in
$exec umask 002 $exec umask 002
$exec unset MAKESKIP $exec unset MAKESKIP
$exec export P=$PWD P=$PWD
$exec export A=$P/arch/$HOSTTYPE A=$P/arch/$HOSTTYPE
$exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package
$exec export INSTALLROOT=$A $exec export INSTALLROOT=$A
@ -857,28 +856,8 @@ hostinfo() # attribute ...
done done
PATH=$PATH:$i/bin PATH=$PATH:$i/bin
done done
# LD_LIBRARY_PATH may be out of sync with PATH here
case $SED in
'') SED=sed
$SED 1d < /dev/null > /dev/null 2>&1 ||
for dir in /bin /usr/bin
do if test -x $dir/$SED
then SED=$dir/$SED
break
fi
done
TR=tr
$TR < /dev/null > /dev/null 2>&1 ||
for dir in /bin /usr/bin
do if test -x $dir/$TR
then TR=$dir/$TR
break
fi
done
;;
esac
case $PACKAGE_PATH in case $PACKAGE_PATH in
?*) for i in $(echo "$PACKAGE_PATH" | "$SED" 's,:, ,g') ?*) for i in $(echo "$PACKAGE_PATH" | sed 's,:, ,g')
do PATH=$PATH:$i/bin do PATH=$PATH:$i/bin
done done
;; ;;
@ -902,16 +881,14 @@ hostinfo() # attribute ...
cpu|name|rating|type) cpu|name|rating|type)
something=1 something=1
;; ;;
*) echo "$command: $action: $info: unknown attribute" >&2 *) err_out "$action: $info: unknown attribute"
exit 1
;; ;;
esac esac
;; ;;
esac esac
done done
case $canon in case $canon in
-) echo "$command: $action: canon: host type name expected" >&2 -) err_out "$action: canon: host type name expected"
exit 1
;; ;;
esac esac
case $something in case $something in
@ -929,13 +906,7 @@ hostinfo() # attribute ...
for info for info
do do
case $info in case $info in
cpu) case $NPROC in cpu) cpu=$(sysctl -n hw.ncpu)
[123456789]*)
_hostinfo_="$_hostinfo_ $NPROC"
continue
;;
esac
cpu=$(sysctl -n hw.ncpu)
case $cpu in case $cpu in
[123456789]*) [123456789]*)
_hostinfo_="$_hostinfo_ $cpu" _hostinfo_="$_hostinfo_ $cpu"
@ -1002,7 +973,7 @@ hostinfo() # attribute ...
do case $# in do case $# in
0) break ;; 0) break ;;
esac esac
i=$($1 2>/dev/null | $TR ' ' ' i=$($1 2>/dev/null | tr ' ' '
' | grep -c "^$2") ' | grep -c "^$2")
case $i in case $i in
@ -1031,7 +1002,7 @@ hostinfo() # attribute ...
do case $# in do case $# in
0) break ;; 0) break ;;
esac esac
i=$($1 2>/dev/null | $SED -e "${2}!d" -e "s${3}") i=$($1 2>/dev/null | sed -e "${2}!d" -e "s${3}")
case $i in case $i in
[123456789]*) [123456789]*)
cpu=$i cpu=$i
@ -1075,7 +1046,7 @@ int main()
name) _name_=$(hostname || uname -n || cat /etc/whoami || echo local) name) _name_=$(hostname || uname -n || cat /etc/whoami || echo local)
_hostinfo_="$_hostinfo_ $_name_" _hostinfo_="$_hostinfo_ $_name_"
;; ;;
rating) for rating in $(grep -i ^bogomips /proc/cpuinfo 2>/dev/null | $SED -e 's,.*:[ ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,') rating) for rating in $(grep -i ^bogomips /proc/cpuinfo 2>/dev/null | sed -e 's,.*:[ ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,')
do case $rating in do case $rating in
[0123456789]*) break ;; [0123456789]*) break ;;
esac esac
@ -1267,14 +1238,14 @@ int main()
esac esac
a=$(arch || uname -m || att uname -m || uname -s || att uname -s) a=$(arch || uname -m || att uname -m || uname -s || att uname -s)
case $a in case $a in
*[\ \ ]*) a=$(echo $a | $SED "s/[ ]/-/g") ;; *[\ \ ]*) a=$(echo $a | sed "s/[ ]/-/g") ;;
esac esac
case $a in case $a in
'') a=unknown ;; '') a=unknown ;;
esac esac
m=$(mach || machine || uname -p || att uname -p) m=$(mach || machine || uname -p || att uname -p)
case $m in case $m in
*[\ \ ]*) m=$(echo $m | $SED "s/[ ]/-/g") ;; *[\ \ ]*) m=$(echo $m | sed "s/[ ]/-/g") ;;
esac esac
case $m in case $m in
'') m=unknown ;; '') m=unknown ;;
@ -1297,7 +1268,7 @@ int main()
esac esac
case $os in case $os in
[abcdefghijklmnopqrstuvwxyz]*[0123456789]) [abcdefghijklmnopqrstuvwxyz]*[0123456789])
eval $(echo $os | $SED -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/') eval $(echo $os | sed -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/')
;; ;;
esac esac
;; ;;
@ -1308,7 +1279,7 @@ int main()
esac esac
type=unknown type=unknown
case $host in case $host in
*.*) host=$(echo $host | $SED -e 's/\..*//') ;; *.*) host=$(echo $host | sed -e 's/\..*//') ;;
esac esac
case $mach in case $mach in
unknown) unknown)
@ -1368,14 +1339,14 @@ int main()
9000/[78]*) 9000/[78]*)
type=hp.pa type=hp.pa
;; ;;
*/*) type=hp.$(echo $arch | $SED 's,/,_,g') */*) type=hp.$(echo $arch | sed 's,/,_,g')
;; ;;
*) type=hp.$arch *) type=hp.$arch
;; ;;
esac esac
;; ;;
[Ii][Rr][Ii][Xx]*) [Ii][Rr][Ii][Xx]*)
set xx $(hinv | $SED -e '/^CPU:/!d' -e 's/CPU:[ ]*\([^ ]*\)[ ]*\([^ ]*\).*/\1 \2/' -e q | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) set xx $(hinv | sed -e '/^CPU:/!d' -e 's/CPU:[ ]*\([^ ]*\)[ ]*\([^ ]*\).*/\1 \2/' -e q | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
shift shift
type=$1 type=$1
n= n=
@ -1420,7 +1391,7 @@ int main()
fi fi
split=' split='
' '
a=$(strings $a < /dev/null | $SED -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[ ][ ]*/\'"$split"'/g' | $SED -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q) a=$(strings $a < /dev/null | sed -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[ ][ ]*/\'"$split"'/g' | sed -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q)
case $a in case $a in
[0123456789]) n=$a ;; [0123456789]) n=$a ;;
esac esac
@ -1456,7 +1427,7 @@ int main()
type=sco type=sco
;; ;;
[Ss]ol*) [Ss]ol*)
v=$(echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//') v=$(echo $rel | sed -e 's/^[25]\.//' -e 's/\.[^.]*$//')
case $v in case $v in
[6789]|[1-9][0-9]) [6789]|[1-9][0-9])
;; ;;
@ -1475,7 +1446,7 @@ int main()
esac esac
type=sol$v.$arch type=sol$v.$arch
;; ;;
[Ss]un*)type=$(echo $arch | $SED -e 's/\(sun.\).*/\1/') [Ss]un*)type=$(echo $arch | sed -e 's/\(sun.\).*/\1/')
case $type in case $type in
sparc) type=sun4 ;; sparc) type=sun4 ;;
esac esac
@ -1496,7 +1467,7 @@ int main()
esac esac
;; ;;
esac esac
v=$(echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//') v=$(echo $rel | sed -e 's/^[25]\.//' -e 's/\.[^.]*$//')
case $v in case $v in
[6789]|[1-9][0-9]) [6789]|[1-9][0-9])
;; ;;
@ -1553,7 +1524,7 @@ int main()
FTX*|ftx*) FTX*|ftx*)
case $mach in case $mach in
*[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*) *[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
mach=$(echo $mach | $SED -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//') mach=$(echo $mach | sed -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//')
;; ;;
esac esac
type=stratus.$mach type=stratus.$mach
@ -1563,7 +1534,7 @@ int main()
type=os2 type=os2
arch=$rel arch=$rel
;; ;;
*) type=$(echo $os | $SED -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//') *) type=$(echo $os | sed -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//')
;; ;;
esac esac
case $type in case $type in
@ -1572,7 +1543,7 @@ int main()
;; ;;
[Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt]) [Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt])
type=win32 type=win32
arch=$(echo $arch | $SED -e 's/_[^_]*$//') arch=$(echo $arch | sed -e 's/_[^_]*$//')
;; ;;
esac esac
case $arch in case $arch in
@ -1621,16 +1592,16 @@ int main()
esac esac
case $type in case $type in
*[-_]32|*[-_]64|*[-_]128) *[-_]32|*[-_]64|*[-_]128)
bits=$(echo $type | $SED 's,.*[-_],,') bits=$(echo $type | sed 's,.*[-_],,')
type=$(echo $type | $SED 's,[-_][0-9]*$,,') type=$(echo $type | sed 's,[-_][0-9]*$,,')
;; ;;
*) bits= *) bits=
;; ;;
esac esac
type=$(echo $type | $SED -e 's%[-+/].*%%' | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) type=$(echo $type | sed -e 's%[-+/].*%%' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
case $type in case $type in
*.*) lhs=$(echo $type | $SED -e 's/\..*//') *.*) lhs=$(echo $type | sed -e 's/\..*//')
rhs=$(echo $type | $SED -e 's/.*\.//') rhs=$(echo $type | sed -e 's/.*\.//')
case $rhs in case $rhs in
[x0123456789]*86) rhs=i$rhs ;; [x0123456789]*86) rhs=i$rhs ;;
68*) rhs=m$rhs ;; 68*) rhs=m$rhs ;;
@ -1640,7 +1611,7 @@ int main()
rhs=i386 ;; rhs=i386 ;;
powerpc) rhs=ppc ;; powerpc) rhs=ppc ;;
s[0123456789]*[0123456789]x) s[0123456789]*[0123456789]x)
rhs=$(echo $rhs | $SED -e 's/x$/-64/') ;; rhs=$(echo $rhs | sed -e 's/x$/-64/') ;;
esac esac
case $rhs in case $rhs in
arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*) arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*)
@ -1654,7 +1625,7 @@ int main()
?*dwarf)x=coff ;; ?*dwarf)x=coff ;;
?*elf) x=elf ;; ?*elf) x=elf ;;
esac esac
lhs=$(echo ${lhs}XXX | $SED -e "s/${x}XXX//") lhs=$(echo ${lhs}XXX | sed -e "s/${x}XXX//")
;; ;;
esac esac
case $lhs in case $lhs in
@ -1668,7 +1639,7 @@ int main()
;; ;;
freebsd) case $rel in freebsd) case $rel in
[01234].*) lhs=${lhs}4 ;; [01234].*) lhs=${lhs}4 ;;
[123456789]*.*) lhs=${lhs}$(echo $rel | $SED -e 's/\..*//') ;; [123456789]*.*) lhs=${lhs}$(echo $rel | sed -e 's/\..*//') ;;
esac esac
;; ;;
hpux) lhs=hp ;; hpux) lhs=hp ;;
@ -1722,7 +1693,7 @@ int b() { return 0; }
esac esac
if $cc $abi -mips$i -c $tmp.b.c && if $cc $abi -mips$i -c $tmp.b.c &&
$cc -o $tmp.exe $tmp.a.o $tmp.b.o $cc -o $tmp.exe $tmp.a.o $tmp.b.o
then type=$(echo $type | $SED -e 's/.$//')$i then type=$(echo $type | sed -e 's/.$//')$i
break break
fi fi
done done
@ -1814,7 +1785,13 @@ int b() { return 0; }
note() # message ... note() # message ...
{ {
echo $command: "$@" >&2 printf "$command: %s\\n" "$@" >&2
}
err_out()
{
note "$@"
exit 1
} }
# cc checks # cc checks
@ -1837,7 +1814,7 @@ checkcc()
fi fi
case $cc in case $cc in
'') case $action in '') case $action in
make|test) note "$CC: not found"; exit 1 ;; make|test) err_out "$CC: not found" ;;
*) note "warning: $CC: not found" ;; *) note "warning: $CC: not found" ;;
esac esac
;; ;;
@ -2022,16 +1999,12 @@ case $x in
case $action in case $action in
export|use) export|use)
packageroot $PACKAGEROOT || { packageroot $PACKAGEROOT || err_out "$PACKAGEROOT: invalid package root directory"
echo "$command: $PACKAGEROOT: invalid package root directory" >&2
exit 1
}
case $KEEP_HOSTTYPE:$hosttype in case $KEEP_HOSTTYPE:$hosttype in
0:?*) if test -d ${PACKAGEROOT:-.}/arch/$hosttype 0:?*) if test -d ${PACKAGEROOT:-.}/arch/$hosttype
then KEEP_HOSTTYPE=1 then KEEP_HOSTTYPE=1
HOSTTYPE=$hosttype HOSTTYPE=$hosttype
else echo "$command: $hosttype: package root not found" >&2 else err_out "$hosttype: package root not found"
exit 1
fi fi
;; ;;
esac esac
@ -2039,8 +2012,7 @@ case $x in
*) packageroot $PACKAGEROOT || { *) packageroot $PACKAGEROOT || {
case $KEEP_PACKAGEROOT in case $KEEP_PACKAGEROOT in
1) ;; 1) ;;
*) echo "$command: $PACKAGEROOT: must be in the package root directory tree" >&2 *) err_out "$PACKAGEROOT: must be in the package root directory tree"
exit 1
;; ;;
esac esac
} }
@ -2062,7 +2034,7 @@ case $x in
do test -h $PACKAGEROOT/bin/$i 2>/dev/null || do test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.sh"*) "$INITROOT/$i.sh"*)
note update $PACKAGEROOT/bin/$i note "update $PACKAGEROOT/bin/$i"
shellmagic shellmagic
case $SHELLMAGIC in case $SHELLMAGIC in
'') $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit '') $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit
@ -2102,11 +2074,10 @@ cat $INITROOT/$i.sh
cp $INITROOT/hello.c pkg$$.c || exit 3 cp $INITROOT/hello.c pkg$$.c || exit 3
$cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || { $cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || {
if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1 if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1
then echo "$command: ${warn}$CC: must be a C compiler (not C++)" >&2 then err_out "${warn}$CC: must be a C compiler (not C++)"
else cat pkg$$.e else cat pkg$$.e
echo "$command: ${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?" >&2 err_out "${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?"
fi fi
exit 2
} }
if ./pkg$$.exe >/dev/null 2>&1 if ./pkg$$.exe >/dev/null 2>&1
then code=0 then code=0
@ -2298,11 +2269,10 @@ cat $INITROOT/$i.sh
EXECTYPE=$_hostinfo_ EXECTYPE=$_hostinfo_
case $HOSTTYPE in case $HOSTTYPE in
$EXECTYPE) $EXECTYPE)
echo "$command: $CC: seems to be a cross-compiler" >&2 err_out "$CC seems to be a cross-compiler." \
echo "$command: set HOSTTYPE to something other than the native $EXECTYPE" >&2 "Set HOSTTYPE to something other than the native $EXECTYPE." \
echo "$command: If not, your $TMPDIR directory may be mounted without execute permission." >&2 "If not, your $TMPDIR directory may be mounted without execute permission." \
echo "$command: Try exporting TMPDIR as a directory where you can execute binary files." >&2 "Try exporting TMPDIR as a directory where you can execute binary files."
exit 1
;; ;;
esac esac
;; ;;
@ -2343,8 +2313,8 @@ cat $INITROOT/$i.sh
PATH=$save_PATH PATH=$save_PATH
unset save_PATH unset save_PATH
case $KEEP_SHELL in case $KEEP_SHELL in
0) echo "Cannot find good default shell, please supply SHELL=/path/to/shell" >&2 0) err_out "Cannot find a good default shell; please supply SHELL=/path/to/shell"
exit 1 ;; ;;
esac esac
;; ;;
esac esac
@ -2458,8 +2428,7 @@ cygwin.*)
;; ;;
esac esac
case $lose in case $lose in
?*) echo "$command: $HOSTTYPE: export '$lose' in CYGWIN or languish in Windows" >&2 ?*) err_out "$HOSTTYPE: export '$lose' in CYGWIN or languish in Windows"
exit 1
;; ;;
esac esac
;; ;;
@ -2526,7 +2495,7 @@ view() # [test] [-|type] [src|bin|all] file
esac esac
_view_= _view_=
case $_view_t_ in case $_view_t_ in
?*) echo $command: $1: $_view_t_ not found >&2 ;; ?*) note "$1: $_view_t_ not found" ;;
esac esac
return 1 return 1
} }
@ -2588,7 +2557,7 @@ int main(int argc, char** argv) { return argc || argv; }
test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || { test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || {
for i for i
do onpath $i || { do onpath $i || {
echo "$command: $i: command not found" >&2 note "$i: command not found"
return 1 return 1
} }
done done
@ -2599,7 +2568,7 @@ int main(int argc, char** argv) { return argc || argv; }
;; ;;
*) _PACKAGE_cc=1 *) _PACKAGE_cc=1
test -f $INITROOT/hello.c -a -f $INITROOT/p.c || { test -f $INITROOT/hello.c -a -f $INITROOT/p.c || {
echo "$command: $INITROOT: INIT package source not found" >&2 note "$INITROOT: INIT package source not found"
return 1 return 1
} }
@ -2615,7 +2584,7 @@ int main(int argc, char** argv) { return argc || argv; }
$show PROTOROOT=$PACKAGEROOT/proto $show PROTOROOT=$PACKAGEROOT/proto
export PROTOROOT export PROTOROOT
INITPROTO=$PROTOROOT/src/cmd/INIT INITPROTO=$PROTOROOT/src/cmd/INIT
note proto convert $PACKAGEROOT/src into $PROTOROOT/src note "proto convert $PACKAGEROOT/src into $PROTOROOT/src"
dirs="src" dirs="src"
( (
if test -f $PROTOROOT/UPDATE if test -f $PROTOROOT/UPDATE
@ -2671,17 +2640,17 @@ int main(int argc, char** argv) { return argc || argv; }
*00) view - bin/$i && continue ;; *00) view - bin/$i && continue ;;
esac esac
case $k in case $k in
000) echo "$command: $i: not found: download the INIT package $HOSTTYPE binary to continue" >&2 000) note "$i: not found: download the INIT package $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
010) echo "$command: $i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue" >&2 010) note "$i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
100) echo "$command: $i: not found: download the INIT package source or $HOSTTYPE binary to continue" >&2 100) note "$i: not found: download the INIT package source or $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
110) case $CROSS in 110) case $CROSS in
1) echo "$command: $i: not found: make the local $EXECTYPE binary package before $HOSTTYPE" >&2 1) note "$i: not found: make the local $EXECTYPE binary package before $HOSTTYPE"
return 1 return 1
;; ;;
esac esac
@ -2699,7 +2668,7 @@ int main(int argc, char** argv) { return argc || argv; }
esac esac
case $(ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null) in case $(ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.c"*) "$INITROOT/$i.c"*)
note update $INSTALLROOT/bin/$i note "update $INSTALLROOT/bin/$i"
if test proto != "$i" && executable $INSTALLROOT/bin/proto if test proto != "$i" && executable $INSTALLROOT/bin/proto
then case $exec in then case $exec in
'') $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;; '') $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;;
@ -2797,7 +2766,7 @@ capture() # file command ...
fi fi
o=$o.out o=$o.out
: > $o : > $o
note $action output captured in $o note "$action output captured in $o"
s="$command: $action start at $(date) in $INSTALLROOT" s="$command: $action start at $(date) in $INSTALLROOT"
case $quiet in case $quiet in
0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;; 0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;;
@ -2955,10 +2924,9 @@ make|view)
;; ;;
*) case " $must " in *) case " $must " in
*" $t "*) *" $t "*)
echo "$command: $t: not found -- must be on PATH to $action" >&2 err_out "$t: not found -- must be on PATH to $action"
exit 1
;; ;;
*) echo "$command: warning: $t: not found -- some $action actions may fail" >&2 *) note "warning: $t: not found -- some $action actions may fail"
;; ;;
esac esac
;; ;;
@ -2968,10 +2936,10 @@ make|view)
# verify the top view # verify the top view
if test ! -d $PACKAGEROOT/src if test ! -d $PACKAGEROOT/src
then note no source packages to make then note "no source packages to make"
exit 0 exit 0
elif test ! -d $INSTALLROOT/src elif test ! -d $INSTALLROOT/src
then note initialize the $INSTALLROOT view then note "initialize the $INSTALLROOT view"
fi fi
for i in arch arch/$HOSTTYPE for i in arch arch/$HOSTTYPE
do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
@ -3049,7 +3017,7 @@ make|view)
$exec chmod +x "$b" || exit $exec chmod +x "$b" || exit
cc=$b cc=$b
intercept=1 intercept=1
note update $b note "update $b"
;; ;;
esac esac
fi fi
@ -3070,7 +3038,7 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
@ -3088,7 +3056,7 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
@ -3100,14 +3068,13 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
case $cc in case $cc in
/*) ;; /*) ;;
*) echo "$command: $CC: not found -- set CC=C-compiler" >&2 *) err_out "$CC: not found -- set CC=C-compiler"
exit 1
;; ;;
esac esac
case $exec in case $exec in
@ -3117,11 +3084,11 @@ make|view)
if $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err && if $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err &&
test -x $tmp.exe test -x $tmp.exe
then : ok then : ok
else echo "$command: $CC: failed to compile this program:" >&2 else note "$CC: failed to compile this program:"
cat $tmp.c >&2 cat $tmp.c >&2
if test -s $tmp.err if test -s $tmp.err
then cat $tmp.err >&2 then cat $tmp.err >&2
else echo "$command: $CC: not a C compiler" >&2 else note "$CC: not a C compiler"
fi fi
rm -f $tmp.* rm -f $tmp.*
exit 1 exit 1
@ -3154,7 +3121,7 @@ make|view)
} > $INSTALLROOT/bin/cc } > $INSTALLROOT/bin/cc
chmod +x $INSTALLROOT/bin/cc chmod +x $INSTALLROOT/bin/cc
;; ;;
*) note generate a $INSTALLROOT/bin/cc wrapper for $CC *) note "generate a $INSTALLROOT/bin/cc wrapper for $CC"
;; ;;
esac esac
CC=cc CC=cc
@ -3180,7 +3147,7 @@ make|view)
case $(ls -t $i $j $k 2>/dev/null) in case $(ls -t $i $j $k 2>/dev/null) in
$i*) ;; $i*) ;;
*) if test -f $j -a -f $k *) if test -f $j -a -f $k
then note update $i then note "update $i"
shellmagic shellmagic
case $exec in case $exec in
'') { '') {
@ -3250,7 +3217,7 @@ cat $j $k
'') new="(none)" ;; '') new="(none)" ;;
*) new="'$new'" ;; *) new="'$new'" ;;
esac esac
echo "$command: $var changed from $old to $new" >&2 note "$var changed from $old to $new"
err=y ;; err=y ;;
esac esac
else test -d $INSTALLROOT/lib/package/gen && case $new in else test -d $INSTALLROOT/lib/package/gen && case $new in
@ -3260,9 +3227,9 @@ cat $j $k
fi fi
done done
case $err,${FORCE_FLAGS+f} in case $err,${FORCE_FLAGS+f} in
y,) echo "$command: This would likely break the build. Restore the flag(s)," >&2 y,) err_out "This would likely break the build. Restore the flag(s)," \
echo "$command: or delete the build directory and rebuild from scratch." >&2 "or delete the build directory and rebuild from scratch."
exit 1 ;; ;;
esac esac
unset err var store old new unset err var store old new
@ -3278,21 +3245,6 @@ cat $j $k
;; ;;
esac esac
# make in parallel if possible
case $NPROC in
'') hostinfo cpu
case $_hostinfo_ in
0|1) ;;
*) NPROC=$_hostinfo_
$show NPROC=$NPROC
$show export NPROC
export NPROC
;;
esac
;;
esac
# separate flags from target list # separate flags from target list
case $target in case $target in
@ -3412,8 +3364,7 @@ cat $j $k
test -f $OK/$i && test -f $OK/$i &&
case $exec:$i in case $exec:$i in
:ksh) :ksh)
echo "$command: $OK/$i: cannot update [may be in use by a running process] remove manually and try again" >&2 err_out "$OK/$i: cannot update [may be in use by a running process] remove manually and try again"
exit 1
;; ;;
esac esac
$exec $execrate $cp $i $OK/$i $exec $execrate $cp $i $OK/$i
@ -3440,17 +3391,13 @@ cat $j $k
# build with mamake # build with mamake
note make with mamake note "make with mamake"
case $target in case $target in
'') target="install" ;; '') target="install" ;;
esac esac
eval capture mamake \$makeflags \$noexec \$target $assign eval capture mamake \$makeflags \$noexec \$target $assign
;; ;;
remove) echo "$command: $action: not implemented yet" >&2
exit 1
;;
results)set '' $target results)set '' $target
shift shift
def=make def=make
@ -3483,8 +3430,7 @@ results)set '' $target
old) suf=old old) suf=old
;; ;;
on) case $# in on) case $# in
1) echo $command: $action: $1: host pattern argument expected >&2 1) err_out "$action: $1: host pattern argument expected"
exit 1
;; ;;
esac esac
shift shift
@ -3536,8 +3482,7 @@ results)set '' $target
;; ;;
esac esac
done done
echo "$command: $i action output not found" >&2 err_out "$i action output not found"
exit 1
done done
sep= sep=
case $t in case $t in
@ -3614,33 +3559,18 @@ use) # finalize the environment
export CDPATH export CDPATH
;; ;;
esac esac
P=$PACKAGEROOT
$show P=$P
$show export P
export P
A=$INSTALLROOT
$show A=$A
$show export A
export A
case $NPROC in
'') hostinfo cpu
case $_hostinfo_ in
0|1) ;;
*) NPROC=$_hostinfo_
$show NPROC=$NPROC
$show export NPROC
export NPROC
;;
esac
;;
esac
eval PACKAGE_USE=$package_use eval PACKAGE_USE=$package_use
export PACKAGE_USE export PACKAGE_USE
# run the command # run the command
case $run in case $run in
'') case $show in '') note "You are now entering a new environment set up to use the package in:" \
" $INSTALLROOT" \
"You're using the shell:" \
" $SHELL" \
"Type 'exit' to leave and go back to normal."
case $show in
':') $exec exec $SHELL ;; ':') $exec exec $SHELL ;;
esac esac
;; ;;
@ -3649,8 +3579,7 @@ use) # finalize the environment
esac esac
;; ;;
*) echo "$command: $action: internal error" >&2 *) err_out "$action: internal error"
exit 1
;; ;;
esac esac

View file

@ -23,7 +23,6 @@
# based on AST 'package' by Glenn Fowler <gsf@research.att.com> # # based on AST 'package' by Glenn Fowler <gsf@research.att.com> #
# simplified and rewritten by Martijn Dekker <martijn@inlv.org> # # simplified and rewritten by Martijn Dekker <martijn@inlv.org> #
######################################################################## ########################################################################
command=package
# Escape from a non-POSIX shell # Escape from a non-POSIX shell
min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\ min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\
@ -95,18 +94,17 @@ lib="" # need /usr/local/lib /usr/local/shlib
ccs="/usr/kvm /usr/ccs/bin" ccs="/usr/kvm /usr/ccs/bin"
org="gnu GNU" org="gnu GNU"
makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile
env="HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH" env="HOSTTYPE PACKAGEROOT INSTALLROOT PATH"
package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC=' package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC='
CROSS=0 CROSS=0
MAKESKIP=${MAKESKIP:-"*[-.]*"} MAKESKIP=${MAKESKIP:-"*[-.]*"}
SED=
TR=
all_types='*.*|sun4' # all but sun4 match *.* all_types='*.*|sun4' # all but sun4 match *.*
command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$' 0123) USAGE=$'
[-? [-?
@ -125,7 +123,7 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
All package files are in the \b$PACKAGEROOT\b directory tree. All package files are in the \b$PACKAGEROOT\b directory tree.
Binary package files are in the \b$INSTALLROOT\b Binary package files are in the \b$INSTALLROOT\b
(\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where (\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where
\ahosttpe\a=$(\bbin/package host type\b). \ahosttype\a=$(\bbin/package host type\b).
See \bDETAILS\b for more information.] See \bDETAILS\b for more information.]
[+?Note that no environment variables need be set by the user; [+?Note that no environment variables need be set by the user;
\b'$command$'\b determines the environment based on the current working \b'$command$'\b determines the environment based on the current working
@ -371,6 +369,8 @@ do case $# in
exec 1>&2 exec 1>&2
;; ;;
esac esac
# Plain-text fallback. Regenerate with:
# ksh -c 'COLUMNS=80 bin/package --man' 2>&1 | sed "s/'/'\\\\''/g; 1s/^/echo '/; \$s/\$/'/"
echo 'NAME echo 'NAME
package - build, test and install ksh 93u+m package - build, test and install ksh 93u+m
@ -383,7 +383,7 @@ DESCRIPTION
POSIX shell and C compiler installation are the only requirements. All POSIX shell and C compiler installation are the only requirements. All
package files are in the $PACKAGEROOT directory tree. Binary package files package files are in the $PACKAGEROOT directory tree. Binary package files
are in the $INSTALLROOT ($PACKAGEROOT/arch/hosttype) tree, where are in the $INSTALLROOT ($PACKAGEROOT/arch/hosttype) tree, where
hosttpe=$(bin/package host type). See DETAILS for more information. hosttype=$(bin/package host type). See DETAILS for more information.
Note that no environment variables need be set by the user; package Note that no environment variables need be set by the user; package
determines the environment based on the current working directory. The use determines the environment based on the current working directory. The use
@ -417,8 +417,7 @@ DESCRIPTION
export [ variable ...] export [ variable ...]
List name=value for variable, one per line. If the only attribute is List name=value for variable, one per line. If the only attribute is
specified then only the variable values are listed. If no variables specified then only the variable values are listed. If no variables
are specified then HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH are are specified then HOSTTYPE PACKAGEROOT INSTALLROOT PATH are assumed.
assumed.
help [ action ] help [ action ]
Display help text on the standard error (standard output for action). Display help text on the standard error (standard output for action).
host [ attribute ... ] host [ attribute ... ]
@ -727,7 +726,7 @@ use) case $1 in
*) HOSTTYPE=$HOSTTYPE-64 ;; *) HOSTTYPE=$HOSTTYPE-64 ;;
esac esac
case $wow in case $wow in
*/32) echo $command: cannot build $bit-bit on $wow $sys >&2; exit 2 ;; */32) err_out "cannot build $bit-bit on $wow $sys" ;;
esac esac
;; ;;
esac esac
@ -739,8 +738,8 @@ use) case $1 in
$exec umask 002 $exec umask 002
$exec unset MAKESKIP $exec unset MAKESKIP
$exec export P=$PWD P=$PWD
$exec export A=$P/arch/$HOSTTYPE A=$P/arch/$HOSTTYPE
$exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package
$exec export INSTALLROOT=$A $exec export INSTALLROOT=$A
@ -857,28 +856,8 @@ hostinfo() # attribute ...
done done
PATH=$PATH:$i/bin PATH=$PATH:$i/bin
done done
# LD_LIBRARY_PATH may be out of sync with PATH here
case $SED in
'') SED=sed
$SED 1d < /dev/null > /dev/null 2>&1 ||
for dir in /bin /usr/bin
do if test -x $dir/$SED
then SED=$dir/$SED
break
fi
done
TR=tr
$TR < /dev/null > /dev/null 2>&1 ||
for dir in /bin /usr/bin
do if test -x $dir/$TR
then TR=$dir/$TR
break
fi
done
;;
esac
case $PACKAGE_PATH in case $PACKAGE_PATH in
?*) for i in $(echo "$PACKAGE_PATH" | "$SED" 's,:, ,g') ?*) for i in $(echo "$PACKAGE_PATH" | sed 's,:, ,g')
do PATH=$PATH:$i/bin do PATH=$PATH:$i/bin
done done
;; ;;
@ -902,16 +881,14 @@ hostinfo() # attribute ...
cpu|name|rating|type) cpu|name|rating|type)
something=1 something=1
;; ;;
*) echo "$command: $action: $info: unknown attribute" >&2 *) err_out "$action: $info: unknown attribute"
exit 1
;; ;;
esac esac
;; ;;
esac esac
done done
case $canon in case $canon in
-) echo "$command: $action: canon: host type name expected" >&2 -) err_out "$action: canon: host type name expected"
exit 1
;; ;;
esac esac
case $something in case $something in
@ -929,13 +906,7 @@ hostinfo() # attribute ...
for info for info
do do
case $info in case $info in
cpu) case $NPROC in cpu) cpu=$(sysctl -n hw.ncpu)
[123456789]*)
_hostinfo_="$_hostinfo_ $NPROC"
continue
;;
esac
cpu=$(sysctl -n hw.ncpu)
case $cpu in case $cpu in
[123456789]*) [123456789]*)
_hostinfo_="$_hostinfo_ $cpu" _hostinfo_="$_hostinfo_ $cpu"
@ -1002,7 +973,7 @@ hostinfo() # attribute ...
do case $# in do case $# in
0) break ;; 0) break ;;
esac esac
i=$($1 2>/dev/null | $TR ' ' ' i=$($1 2>/dev/null | tr ' ' '
' | grep -c "^$2") ' | grep -c "^$2")
case $i in case $i in
@ -1031,7 +1002,7 @@ hostinfo() # attribute ...
do case $# in do case $# in
0) break ;; 0) break ;;
esac esac
i=$($1 2>/dev/null | $SED -e "${2}!d" -e "s${3}") i=$($1 2>/dev/null | sed -e "${2}!d" -e "s${3}")
case $i in case $i in
[123456789]*) [123456789]*)
cpu=$i cpu=$i
@ -1075,7 +1046,7 @@ int main()
name) _name_=$(hostname || uname -n || cat /etc/whoami || echo local) name) _name_=$(hostname || uname -n || cat /etc/whoami || echo local)
_hostinfo_="$_hostinfo_ $_name_" _hostinfo_="$_hostinfo_ $_name_"
;; ;;
rating) for rating in $(grep -i ^bogomips /proc/cpuinfo 2>/dev/null | $SED -e 's,.*:[ ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,') rating) for rating in $(grep -i ^bogomips /proc/cpuinfo 2>/dev/null | sed -e 's,.*:[ ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,')
do case $rating in do case $rating in
[0123456789]*) break ;; [0123456789]*) break ;;
esac esac
@ -1267,14 +1238,14 @@ int main()
esac esac
a=$(arch || uname -m || att uname -m || uname -s || att uname -s) a=$(arch || uname -m || att uname -m || uname -s || att uname -s)
case $a in case $a in
*[\ \ ]*) a=$(echo $a | $SED "s/[ ]/-/g") ;; *[\ \ ]*) a=$(echo $a | sed "s/[ ]/-/g") ;;
esac esac
case $a in case $a in
'') a=unknown ;; '') a=unknown ;;
esac esac
m=$(mach || machine || uname -p || att uname -p) m=$(mach || machine || uname -p || att uname -p)
case $m in case $m in
*[\ \ ]*) m=$(echo $m | $SED "s/[ ]/-/g") ;; *[\ \ ]*) m=$(echo $m | sed "s/[ ]/-/g") ;;
esac esac
case $m in case $m in
'') m=unknown ;; '') m=unknown ;;
@ -1297,7 +1268,7 @@ int main()
esac esac
case $os in case $os in
[abcdefghijklmnopqrstuvwxyz]*[0123456789]) [abcdefghijklmnopqrstuvwxyz]*[0123456789])
eval $(echo $os | $SED -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/') eval $(echo $os | sed -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/')
;; ;;
esac esac
;; ;;
@ -1308,7 +1279,7 @@ int main()
esac esac
type=unknown type=unknown
case $host in case $host in
*.*) host=$(echo $host | $SED -e 's/\..*//') ;; *.*) host=$(echo $host | sed -e 's/\..*//') ;;
esac esac
case $mach in case $mach in
unknown) unknown)
@ -1368,14 +1339,14 @@ int main()
9000/[78]*) 9000/[78]*)
type=hp.pa type=hp.pa
;; ;;
*/*) type=hp.$(echo $arch | $SED 's,/,_,g') */*) type=hp.$(echo $arch | sed 's,/,_,g')
;; ;;
*) type=hp.$arch *) type=hp.$arch
;; ;;
esac esac
;; ;;
[Ii][Rr][Ii][Xx]*) [Ii][Rr][Ii][Xx]*)
set xx $(hinv | $SED -e '/^CPU:/!d' -e 's/CPU:[ ]*\([^ ]*\)[ ]*\([^ ]*\).*/\1 \2/' -e q | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) set xx $(hinv | sed -e '/^CPU:/!d' -e 's/CPU:[ ]*\([^ ]*\)[ ]*\([^ ]*\).*/\1 \2/' -e q | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
shift shift
type=$1 type=$1
n= n=
@ -1420,7 +1391,7 @@ int main()
fi fi
split=' split='
' '
a=$(strings $a < /dev/null | $SED -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[ ][ ]*/\'"$split"'/g' | $SED -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q) a=$(strings $a < /dev/null | sed -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[ ][ ]*/\'"$split"'/g' | sed -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q)
case $a in case $a in
[0123456789]) n=$a ;; [0123456789]) n=$a ;;
esac esac
@ -1456,7 +1427,7 @@ int main()
type=sco type=sco
;; ;;
[Ss]ol*) [Ss]ol*)
v=$(echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//') v=$(echo $rel | sed -e 's/^[25]\.//' -e 's/\.[^.]*$//')
case $v in case $v in
[6789]|[1-9][0-9]) [6789]|[1-9][0-9])
;; ;;
@ -1475,7 +1446,7 @@ int main()
esac esac
type=sol$v.$arch type=sol$v.$arch
;; ;;
[Ss]un*)type=$(echo $arch | $SED -e 's/\(sun.\).*/\1/') [Ss]un*)type=$(echo $arch | sed -e 's/\(sun.\).*/\1/')
case $type in case $type in
sparc) type=sun4 ;; sparc) type=sun4 ;;
esac esac
@ -1496,7 +1467,7 @@ int main()
esac esac
;; ;;
esac esac
v=$(echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//') v=$(echo $rel | sed -e 's/^[25]\.//' -e 's/\.[^.]*$//')
case $v in case $v in
[6789]|[1-9][0-9]) [6789]|[1-9][0-9])
;; ;;
@ -1553,7 +1524,7 @@ int main()
FTX*|ftx*) FTX*|ftx*)
case $mach in case $mach in
*[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*) *[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
mach=$(echo $mach | $SED -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//') mach=$(echo $mach | sed -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//')
;; ;;
esac esac
type=stratus.$mach type=stratus.$mach
@ -1563,7 +1534,7 @@ int main()
type=os2 type=os2
arch=$rel arch=$rel
;; ;;
*) type=$(echo $os | $SED -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//') *) type=$(echo $os | sed -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//')
;; ;;
esac esac
case $type in case $type in
@ -1572,7 +1543,7 @@ int main()
;; ;;
[Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt]) [Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt])
type=win32 type=win32
arch=$(echo $arch | $SED -e 's/_[^_]*$//') arch=$(echo $arch | sed -e 's/_[^_]*$//')
;; ;;
esac esac
case $arch in case $arch in
@ -1621,16 +1592,16 @@ int main()
esac esac
case $type in case $type in
*[-_]32|*[-_]64|*[-_]128) *[-_]32|*[-_]64|*[-_]128)
bits=$(echo $type | $SED 's,.*[-_],,') bits=$(echo $type | sed 's,.*[-_],,')
type=$(echo $type | $SED 's,[-_][0-9]*$,,') type=$(echo $type | sed 's,[-_][0-9]*$,,')
;; ;;
*) bits= *) bits=
;; ;;
esac esac
type=$(echo $type | $SED -e 's%[-+/].*%%' | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) type=$(echo $type | sed -e 's%[-+/].*%%' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
case $type in case $type in
*.*) lhs=$(echo $type | $SED -e 's/\..*//') *.*) lhs=$(echo $type | sed -e 's/\..*//')
rhs=$(echo $type | $SED -e 's/.*\.//') rhs=$(echo $type | sed -e 's/.*\.//')
case $rhs in case $rhs in
[x0123456789]*86) rhs=i$rhs ;; [x0123456789]*86) rhs=i$rhs ;;
68*) rhs=m$rhs ;; 68*) rhs=m$rhs ;;
@ -1640,7 +1611,7 @@ int main()
rhs=i386 ;; rhs=i386 ;;
powerpc) rhs=ppc ;; powerpc) rhs=ppc ;;
s[0123456789]*[0123456789]x) s[0123456789]*[0123456789]x)
rhs=$(echo $rhs | $SED -e 's/x$/-64/') ;; rhs=$(echo $rhs | sed -e 's/x$/-64/') ;;
esac esac
case $rhs in case $rhs in
arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*) arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*)
@ -1654,7 +1625,7 @@ int main()
?*dwarf)x=coff ;; ?*dwarf)x=coff ;;
?*elf) x=elf ;; ?*elf) x=elf ;;
esac esac
lhs=$(echo ${lhs}XXX | $SED -e "s/${x}XXX//") lhs=$(echo ${lhs}XXX | sed -e "s/${x}XXX//")
;; ;;
esac esac
case $lhs in case $lhs in
@ -1668,7 +1639,7 @@ int main()
;; ;;
freebsd) case $rel in freebsd) case $rel in
[01234].*) lhs=${lhs}4 ;; [01234].*) lhs=${lhs}4 ;;
[123456789]*.*) lhs=${lhs}$(echo $rel | $SED -e 's/\..*//') ;; [123456789]*.*) lhs=${lhs}$(echo $rel | sed -e 's/\..*//') ;;
esac esac
;; ;;
hpux) lhs=hp ;; hpux) lhs=hp ;;
@ -1722,7 +1693,7 @@ int b() { return 0; }
esac esac
if $cc $abi -mips$i -c $tmp.b.c && if $cc $abi -mips$i -c $tmp.b.c &&
$cc -o $tmp.exe $tmp.a.o $tmp.b.o $cc -o $tmp.exe $tmp.a.o $tmp.b.o
then type=$(echo $type | $SED -e 's/.$//')$i then type=$(echo $type | sed -e 's/.$//')$i
break break
fi fi
done done
@ -1814,7 +1785,13 @@ int b() { return 0; }
note() # message ... note() # message ...
{ {
echo $command: "$@" >&2 printf "$command: %s\\n" "$@" >&2
}
err_out()
{
note "$@"
exit 1
} }
# cc checks # cc checks
@ -1837,7 +1814,7 @@ checkcc()
fi fi
case $cc in case $cc in
'') case $action in '') case $action in
make|test) note "$CC: not found"; exit 1 ;; make|test) err_out "$CC: not found" ;;
*) note "warning: $CC: not found" ;; *) note "warning: $CC: not found" ;;
esac esac
;; ;;
@ -2022,16 +1999,12 @@ case $x in
case $action in case $action in
export|use) export|use)
packageroot $PACKAGEROOT || { packageroot $PACKAGEROOT || err_out "$PACKAGEROOT: invalid package root directory"
echo "$command: $PACKAGEROOT: invalid package root directory" >&2
exit 1
}
case $KEEP_HOSTTYPE:$hosttype in case $KEEP_HOSTTYPE:$hosttype in
0:?*) if test -d ${PACKAGEROOT:-.}/arch/$hosttype 0:?*) if test -d ${PACKAGEROOT:-.}/arch/$hosttype
then KEEP_HOSTTYPE=1 then KEEP_HOSTTYPE=1
HOSTTYPE=$hosttype HOSTTYPE=$hosttype
else echo "$command: $hosttype: package root not found" >&2 else err_out "$hosttype: package root not found"
exit 1
fi fi
;; ;;
esac esac
@ -2039,8 +2012,7 @@ case $x in
*) packageroot $PACKAGEROOT || { *) packageroot $PACKAGEROOT || {
case $KEEP_PACKAGEROOT in case $KEEP_PACKAGEROOT in
1) ;; 1) ;;
*) echo "$command: $PACKAGEROOT: must be in the package root directory tree" >&2 *) err_out "$PACKAGEROOT: must be in the package root directory tree"
exit 1
;; ;;
esac esac
} }
@ -2062,7 +2034,7 @@ case $x in
do test -h $PACKAGEROOT/bin/$i 2>/dev/null || do test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.sh"*) "$INITROOT/$i.sh"*)
note update $PACKAGEROOT/bin/$i note "update $PACKAGEROOT/bin/$i"
shellmagic shellmagic
case $SHELLMAGIC in case $SHELLMAGIC in
'') $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit '') $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit
@ -2102,11 +2074,10 @@ cat $INITROOT/$i.sh
cp $INITROOT/hello.c pkg$$.c || exit 3 cp $INITROOT/hello.c pkg$$.c || exit 3
$cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || { $cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || {
if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1 if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1
then echo "$command: ${warn}$CC: must be a C compiler (not C++)" >&2 then err_out "${warn}$CC: must be a C compiler (not C++)"
else cat pkg$$.e else cat pkg$$.e
echo "$command: ${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?" >&2 err_out "${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?"
fi fi
exit 2
} }
if ./pkg$$.exe >/dev/null 2>&1 if ./pkg$$.exe >/dev/null 2>&1
then code=0 then code=0
@ -2298,11 +2269,10 @@ cat $INITROOT/$i.sh
EXECTYPE=$_hostinfo_ EXECTYPE=$_hostinfo_
case $HOSTTYPE in case $HOSTTYPE in
$EXECTYPE) $EXECTYPE)
echo "$command: $CC: seems to be a cross-compiler" >&2 err_out "$CC seems to be a cross-compiler." \
echo "$command: set HOSTTYPE to something other than the native $EXECTYPE" >&2 "Set HOSTTYPE to something other than the native $EXECTYPE." \
echo "$command: If not, your $TMPDIR directory may be mounted without execute permission." >&2 "If not, your $TMPDIR directory may be mounted without execute permission." \
echo "$command: Try exporting TMPDIR as a directory where you can execute binary files." >&2 "Try exporting TMPDIR as a directory where you can execute binary files."
exit 1
;; ;;
esac esac
;; ;;
@ -2343,8 +2313,8 @@ cat $INITROOT/$i.sh
PATH=$save_PATH PATH=$save_PATH
unset save_PATH unset save_PATH
case $KEEP_SHELL in case $KEEP_SHELL in
0) echo "Cannot find good default shell, please supply SHELL=/path/to/shell" >&2 0) err_out "Cannot find a good default shell; please supply SHELL=/path/to/shell"
exit 1 ;; ;;
esac esac
;; ;;
esac esac
@ -2458,8 +2428,7 @@ cygwin.*)
;; ;;
esac esac
case $lose in case $lose in
?*) echo "$command: $HOSTTYPE: export '$lose' in CYGWIN or languish in Windows" >&2 ?*) err_out "$HOSTTYPE: export '$lose' in CYGWIN or languish in Windows"
exit 1
;; ;;
esac esac
;; ;;
@ -2526,7 +2495,7 @@ view() # [test] [-|type] [src|bin|all] file
esac esac
_view_= _view_=
case $_view_t_ in case $_view_t_ in
?*) echo $command: $1: $_view_t_ not found >&2 ;; ?*) note "$1: $_view_t_ not found" ;;
esac esac
return 1 return 1
} }
@ -2588,7 +2557,7 @@ int main(int argc, char** argv) { return argc || argv; }
test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || { test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || {
for i for i
do onpath $i || { do onpath $i || {
echo "$command: $i: command not found" >&2 note "$i: command not found"
return 1 return 1
} }
done done
@ -2599,7 +2568,7 @@ int main(int argc, char** argv) { return argc || argv; }
;; ;;
*) _PACKAGE_cc=1 *) _PACKAGE_cc=1
test -f $INITROOT/hello.c -a -f $INITROOT/p.c || { test -f $INITROOT/hello.c -a -f $INITROOT/p.c || {
echo "$command: $INITROOT: INIT package source not found" >&2 note "$INITROOT: INIT package source not found"
return 1 return 1
} }
@ -2615,7 +2584,7 @@ int main(int argc, char** argv) { return argc || argv; }
$show PROTOROOT=$PACKAGEROOT/proto $show PROTOROOT=$PACKAGEROOT/proto
export PROTOROOT export PROTOROOT
INITPROTO=$PROTOROOT/src/cmd/INIT INITPROTO=$PROTOROOT/src/cmd/INIT
note proto convert $PACKAGEROOT/src into $PROTOROOT/src note "proto convert $PACKAGEROOT/src into $PROTOROOT/src"
dirs="src" dirs="src"
( (
if test -f $PROTOROOT/UPDATE if test -f $PROTOROOT/UPDATE
@ -2671,17 +2640,17 @@ int main(int argc, char** argv) { return argc || argv; }
*00) view - bin/$i && continue ;; *00) view - bin/$i && continue ;;
esac esac
case $k in case $k in
000) echo "$command: $i: not found: download the INIT package $HOSTTYPE binary to continue" >&2 000) note "$i: not found: download the INIT package $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
010) echo "$command: $i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue" >&2 010) note "$i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
100) echo "$command: $i: not found: download the INIT package source or $HOSTTYPE binary to continue" >&2 100) note "$i: not found: download the INIT package source or $HOSTTYPE binary to continue"
return 1 return 1
;; ;;
110) case $CROSS in 110) case $CROSS in
1) echo "$command: $i: not found: make the local $EXECTYPE binary package before $HOSTTYPE" >&2 1) note "$i: not found: make the local $EXECTYPE binary package before $HOSTTYPE"
return 1 return 1
;; ;;
esac esac
@ -2699,7 +2668,7 @@ int main(int argc, char** argv) { return argc || argv; }
esac esac
case $(ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null) in case $(ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.c"*) "$INITROOT/$i.c"*)
note update $INSTALLROOT/bin/$i note "update $INSTALLROOT/bin/$i"
if test proto != "$i" && executable $INSTALLROOT/bin/proto if test proto != "$i" && executable $INSTALLROOT/bin/proto
then case $exec in then case $exec in
'') $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;; '') $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;;
@ -2797,7 +2766,7 @@ capture() # file command ...
fi fi
o=$o.out o=$o.out
: > $o : > $o
note $action output captured in $o note "$action output captured in $o"
s="$command: $action start at $(date) in $INSTALLROOT" s="$command: $action start at $(date) in $INSTALLROOT"
case $quiet in case $quiet in
0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;; 0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;;
@ -2955,10 +2924,9 @@ make|view)
;; ;;
*) case " $must " in *) case " $must " in
*" $t "*) *" $t "*)
echo "$command: $t: not found -- must be on PATH to $action" >&2 err_out "$t: not found -- must be on PATH to $action"
exit 1
;; ;;
*) echo "$command: warning: $t: not found -- some $action actions may fail" >&2 *) note "warning: $t: not found -- some $action actions may fail"
;; ;;
esac esac
;; ;;
@ -2968,10 +2936,10 @@ make|view)
# verify the top view # verify the top view
if test ! -d $PACKAGEROOT/src if test ! -d $PACKAGEROOT/src
then note no source packages to make then note "no source packages to make"
exit 0 exit 0
elif test ! -d $INSTALLROOT/src elif test ! -d $INSTALLROOT/src
then note initialize the $INSTALLROOT view then note "initialize the $INSTALLROOT view"
fi fi
for i in arch arch/$HOSTTYPE for i in arch arch/$HOSTTYPE
do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
@ -3049,7 +3017,7 @@ make|view)
$exec chmod +x "$b" || exit $exec chmod +x "$b" || exit
cc=$b cc=$b
intercept=1 intercept=1
note update $b note "update $b"
;; ;;
esac esac
fi fi
@ -3070,7 +3038,7 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
@ -3088,7 +3056,7 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
@ -3100,14 +3068,13 @@ make|view)
case $(ls -t "$b" "$s" 2>/dev/null) in case $(ls -t "$b" "$s" 2>/dev/null) in
$b*) ;; $b*) ;;
$s*) $exec cp "$s" "$b" $s*) $exec cp "$s" "$b"
note update $b note "update $b"
;; ;;
esac esac
done done
case $cc in case $cc in
/*) ;; /*) ;;
*) echo "$command: $CC: not found -- set CC=C-compiler" >&2 *) err_out "$CC: not found -- set CC=C-compiler"
exit 1
;; ;;
esac esac
case $exec in case $exec in
@ -3117,11 +3084,11 @@ make|view)
if $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err && if $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err &&
test -x $tmp.exe test -x $tmp.exe
then : ok then : ok
else echo "$command: $CC: failed to compile this program:" >&2 else note "$CC: failed to compile this program:"
cat $tmp.c >&2 cat $tmp.c >&2
if test -s $tmp.err if test -s $tmp.err
then cat $tmp.err >&2 then cat $tmp.err >&2
else echo "$command: $CC: not a C compiler" >&2 else note "$CC: not a C compiler"
fi fi
rm -f $tmp.* rm -f $tmp.*
exit 1 exit 1
@ -3154,7 +3121,7 @@ make|view)
} > $INSTALLROOT/bin/cc } > $INSTALLROOT/bin/cc
chmod +x $INSTALLROOT/bin/cc chmod +x $INSTALLROOT/bin/cc
;; ;;
*) note generate a $INSTALLROOT/bin/cc wrapper for $CC *) note "generate a $INSTALLROOT/bin/cc wrapper for $CC"
;; ;;
esac esac
CC=cc CC=cc
@ -3180,7 +3147,7 @@ make|view)
case $(ls -t $i $j $k 2>/dev/null) in case $(ls -t $i $j $k 2>/dev/null) in
$i*) ;; $i*) ;;
*) if test -f $j -a -f $k *) if test -f $j -a -f $k
then note update $i then note "update $i"
shellmagic shellmagic
case $exec in case $exec in
'') { '') {
@ -3250,7 +3217,7 @@ cat $j $k
'') new="(none)" ;; '') new="(none)" ;;
*) new="'$new'" ;; *) new="'$new'" ;;
esac esac
echo "$command: $var changed from $old to $new" >&2 note "$var changed from $old to $new"
err=y ;; err=y ;;
esac esac
else test -d $INSTALLROOT/lib/package/gen && case $new in else test -d $INSTALLROOT/lib/package/gen && case $new in
@ -3260,9 +3227,9 @@ cat $j $k
fi fi
done done
case $err,${FORCE_FLAGS+f} in case $err,${FORCE_FLAGS+f} in
y,) echo "$command: This would likely break the build. Restore the flag(s)," >&2 y,) err_out "This would likely break the build. Restore the flag(s)," \
echo "$command: or delete the build directory and rebuild from scratch." >&2 "or delete the build directory and rebuild from scratch."
exit 1 ;; ;;
esac esac
unset err var store old new unset err var store old new
@ -3278,21 +3245,6 @@ cat $j $k
;; ;;
esac esac
# make in parallel if possible
case $NPROC in
'') hostinfo cpu
case $_hostinfo_ in
0|1) ;;
*) NPROC=$_hostinfo_
$show NPROC=$NPROC
$show export NPROC
export NPROC
;;
esac
;;
esac
# separate flags from target list # separate flags from target list
case $target in case $target in
@ -3412,8 +3364,7 @@ cat $j $k
test -f $OK/$i && test -f $OK/$i &&
case $exec:$i in case $exec:$i in
:ksh) :ksh)
echo "$command: $OK/$i: cannot update [may be in use by a running process] remove manually and try again" >&2 err_out "$OK/$i: cannot update [may be in use by a running process] remove manually and try again"
exit 1
;; ;;
esac esac
$exec $execrate $cp $i $OK/$i $exec $execrate $cp $i $OK/$i
@ -3440,17 +3391,13 @@ cat $j $k
# build with mamake # build with mamake
note make with mamake note "make with mamake"
case $target in case $target in
'') target="install" ;; '') target="install" ;;
esac esac
eval capture mamake \$makeflags \$noexec \$target $assign eval capture mamake \$makeflags \$noexec \$target $assign
;; ;;
remove) echo "$command: $action: not implemented yet" >&2
exit 1
;;
results)set '' $target results)set '' $target
shift shift
def=make def=make
@ -3483,8 +3430,7 @@ results)set '' $target
old) suf=old old) suf=old
;; ;;
on) case $# in on) case $# in
1) echo $command: $action: $1: host pattern argument expected >&2 1) err_out "$action: $1: host pattern argument expected"
exit 1
;; ;;
esac esac
shift shift
@ -3536,8 +3482,7 @@ results)set '' $target
;; ;;
esac esac
done done
echo "$command: $i action output not found" >&2 err_out "$i action output not found"
exit 1
done done
sep= sep=
case $t in case $t in
@ -3614,33 +3559,18 @@ use) # finalize the environment
export CDPATH export CDPATH
;; ;;
esac esac
P=$PACKAGEROOT
$show P=$P
$show export P
export P
A=$INSTALLROOT
$show A=$A
$show export A
export A
case $NPROC in
'') hostinfo cpu
case $_hostinfo_ in
0|1) ;;
*) NPROC=$_hostinfo_
$show NPROC=$NPROC
$show export NPROC
export NPROC
;;
esac
;;
esac
eval PACKAGE_USE=$package_use eval PACKAGE_USE=$package_use
export PACKAGE_USE export PACKAGE_USE
# run the command # run the command
case $run in case $run in
'') case $show in '') note "You are now entering a new environment set up to use the package in:" \
" $INSTALLROOT" \
"You're using the shell:" \
" $SHELL" \
"Type 'exit' to leave and go back to normal."
case $show in
':') $exec exec $SHELL ;; ':') $exec exec $SHELL ;;
esac esac
;; ;;
@ -3649,8 +3579,7 @@ use) # finalize the environment
esac esac
;; ;;
*) echo "$command: $action: internal error" >&2 *) err_out "$action: internal error"
exit 1
;; ;;
esac esac