198 lines
3.9 KiB
Bash
Executable File
198 lines
3.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $NetBSD: maketars,v 1.42 2003/08/22 19:08:47 dsl Exp $
|
|
#
|
|
# Make release tar files for some or all lists. Usage:
|
|
# maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
|
|
# [-M metalog] [-N etcdir] [-d destdir] [-t tardir] [setname ...]
|
|
#
|
|
# The default sets are "base comp etc games man misc text"
|
|
#
|
|
# If '-i installdir' is given, copy the given sets to installdir
|
|
# (using pax -rw ...) instead of creating tar files.
|
|
# In this case, remove "etc" from the list of default sets.
|
|
#
|
|
|
|
prog=`basename $0`
|
|
|
|
# set defaults
|
|
: ${PAX=pax}
|
|
: ${MTREE=mtree}
|
|
make="${MAKE:-make} -j 1 -f `dirname $0`/Makefile"
|
|
|
|
machine=`${make} print_machine`
|
|
machine_arch=`${make} print_machine_arch`
|
|
setd=`pwd`
|
|
nlists="base comp etc games man misc text"
|
|
xlists="xbase xcomp xcontrib xfont xserver xmisc"
|
|
lists=$nlists
|
|
tars=$RELEASEDIR
|
|
dest=$DESTDIR
|
|
metalog=
|
|
installdir=
|
|
etcdir=
|
|
|
|
# handle args
|
|
while : ; do
|
|
case $1 in
|
|
-b*)
|
|
lists="$xlists $nlists"
|
|
;;
|
|
-x*)
|
|
lists=$xlists
|
|
;;
|
|
-i*)
|
|
installdir=$2; shift
|
|
;;
|
|
-a*)
|
|
machine_arch=$2; shift
|
|
;;
|
|
-M*)
|
|
metalog=$2; shift
|
|
;;
|
|
-m*)
|
|
machine=$2; shift
|
|
;;
|
|
-N*)
|
|
etcdir=$2; shift
|
|
;;
|
|
-s*)
|
|
setd=$2; shift
|
|
;;
|
|
-d*)
|
|
dest=$2; shift
|
|
;;
|
|
-t*)
|
|
tars=$2; shift
|
|
;;
|
|
-*)
|
|
cat 1>&2 <<USAGE
|
|
Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir]
|
|
[-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
|
|
-b make netbsd + x11 lists
|
|
-x only make x11 lists
|
|
-i idir install sets to idir instead of creating tar files
|
|
-a arch set arch (e.g, m68k, mipseb, mipsel, powerpc) [$machine_arch]
|
|
-m machine set machine (e.g, amiga, i386, macppc) [$machine]
|
|
-s setsdir directory to find sets [$setd]
|
|
-M metalog metalog file
|
|
-N etcdir etc dir for metalog use [$dest/etc]
|
|
-d dest \$DESTDIR [$dest]
|
|
-t targetdir \$RELEASEDIR [$tars]
|
|
[setname ...] sets to build [$lists]
|
|
USAGE
|
|
exit 1
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
if [ -n "$installdir" ]; then # if -i, remove etc from default list
|
|
lists=$(echo $lists | sed -e 's/ etc / /')
|
|
fi
|
|
if [ -n "$*" ]; then
|
|
lists="$*"
|
|
fi
|
|
|
|
if [ -z "$tars" -a -z "$installdir" ]; then
|
|
echo \$RELEASEDIR must be set, or -i must be used
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$dest" ]; then
|
|
echo \$DESTDIR must be set
|
|
exit 1
|
|
fi
|
|
: ${etcdir:=${dest}/etc}
|
|
|
|
# Make sure we don't loop forever if mkdir will always fail.
|
|
|
|
if [ ! -d /tmp ]; then
|
|
echo /tmp is not a directory
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -w /tmp ]; then
|
|
echo /tmp is not writable
|
|
exit 1
|
|
fi
|
|
|
|
SDIR_BASE=/tmp/maketar.$$
|
|
SDIR_SERIAL=0
|
|
|
|
while true; do
|
|
SDIR=${SDIR_BASE}.${SDIR_SERIAL}
|
|
mkdir -m 0700 ${SDIR} && break
|
|
SDIR_SERIAL=$((${SDIR_SERIAL} + 1))
|
|
done
|
|
|
|
es=0
|
|
cleanup()
|
|
{
|
|
/bin/rm -rf $SDIR
|
|
if [ $es -gt 255 ] ; then
|
|
es=255
|
|
fi
|
|
exit $es
|
|
}
|
|
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
|
|
|
|
if [ -n "$metalog" ]; then
|
|
echo "Parsing $metalog"
|
|
(
|
|
cat ${etcdir}/mtree/NetBSD.dist
|
|
echo "/unset all"
|
|
cat $metalog
|
|
) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog
|
|
rv=$?
|
|
if [ $rv -ne 0 ]; then
|
|
echo "${prog}: mtree failed, exiting"
|
|
exit $rv
|
|
fi
|
|
fi
|
|
|
|
GZIP=-9 # for pax -z
|
|
export GZIP
|
|
|
|
for setname in $lists; do
|
|
out=$setname.tgz
|
|
if [ -n "$installdir" ]; then
|
|
echo "Copying set $setname"
|
|
else
|
|
[ -n "$metalog" -a $tars/$out -nt "$metalog" ] && {
|
|
echo "$out is up to date"
|
|
continue
|
|
}
|
|
echo "Creating $out"
|
|
fi
|
|
sh $setd/makeflist -a $machine_arch -m $machine -s $setd $setname \
|
|
> $SDIR/flist.$setname
|
|
if [ -n "$metalog" ]; then
|
|
awk -f getdirs.awk $SDIR/flist.$setname | sort -u \
|
|
> $SDIR/flist.$setname.full
|
|
(
|
|
echo "/set uname=root gname=wheel"
|
|
awk -f join.awk $SDIR/flist.$setname.full $SDIR/metalog
|
|
) > $SDIR/plist.$setname
|
|
else
|
|
mv $SDIR/flist.$setname $SDIR/plist.$setname
|
|
fi
|
|
|
|
if [ -n "$installdir" ]; then
|
|
( cd $dest ; \
|
|
${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \
|
|
$installdir < ${SDIR}/plist.$setname )
|
|
else
|
|
( cd $dest ; \
|
|
${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \
|
|
< ${SDIR}/plist.$setname ) > ${tars}/$out
|
|
fi
|
|
es=$(($es + $?))
|
|
done
|
|
if [ $es -gt 255 ] ; then
|
|
es=255
|
|
fi
|
|
exit $es
|