1996-05-20 23:10:28 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2003-04-07 21:22:19 +04:00
|
|
|
# $NetBSD: maketars,v 1.40 2003/04/07 17:22:19 perry Exp $
|
1996-05-20 23:10:28 +04:00
|
|
|
#
|
|
|
|
# Make release tar files for some or all lists. Usage:
|
2002-12-26 02:44:06 +03:00
|
|
|
# maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
|
|
|
|
# [-M metalog] [-N etcdir] [-d destdir] [-t tardir] [setname ...]
|
1996-05-20 23:10:28 +04:00
|
|
|
#
|
2002-12-26 02:47:32 +03:00
|
|
|
# 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.
|
|
|
|
#
|
1996-05-20 23:10:28 +04:00
|
|
|
|
|
|
|
# set defaults
|
2002-02-27 13:51:47 +03:00
|
|
|
: ${PAX=pax}
|
|
|
|
: ${MTREE=mtree}
|
2002-11-26 09:22:22 +03:00
|
|
|
make="${MAKE:-make} -j 1 -f `dirname $0`/Makefile"
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2002-11-26 09:22:22 +03:00
|
|
|
machine=`${make} print_machine`
|
|
|
|
machine_arch=`${make} print_machine_arch`
|
1996-05-20 23:10:28 +04:00
|
|
|
setd=`pwd`
|
1998-06-15 18:45:05 +04:00
|
|
|
nlists="base comp etc games man misc text"
|
2002-04-08 21:18:22 +04:00
|
|
|
xlists="xbase xcomp xcontrib xfont xserver xmisc"
|
1998-06-15 18:45:05 +04:00
|
|
|
lists=$nlists
|
1996-05-20 23:10:28 +04:00
|
|
|
tars=$RELEASEDIR
|
|
|
|
dest=$DESTDIR
|
2002-02-27 13:51:47 +03:00
|
|
|
metalog=
|
2002-12-12 11:51:49 +03:00
|
|
|
installdir=
|
2002-12-19 09:21:45 +03:00
|
|
|
etcdir=
|
1996-05-20 23:10:28 +04:00
|
|
|
|
|
|
|
# handle args
|
1998-06-15 18:45:05 +04:00
|
|
|
while : ; do
|
1996-05-20 23:10:28 +04:00
|
|
|
case $1 in
|
1998-06-15 18:45:05 +04:00
|
|
|
-b*)
|
|
|
|
lists="$xlists $nlists"
|
|
|
|
;;
|
2002-02-27 13:51:47 +03:00
|
|
|
-x*)
|
1998-06-15 18:45:05 +04:00
|
|
|
lists=$xlists
|
|
|
|
;;
|
2002-12-12 11:51:49 +03:00
|
|
|
-i*)
|
|
|
|
installdir=$2; shift
|
|
|
|
;;
|
1998-06-15 18:45:05 +04:00
|
|
|
-a*)
|
2001-11-24 06:08:27 +03:00
|
|
|
machine_arch=$2; shift
|
1998-06-15 18:45:05 +04:00
|
|
|
;;
|
2002-02-27 13:51:47 +03:00
|
|
|
-M*)
|
|
|
|
metalog=$2; shift
|
|
|
|
;;
|
1998-06-15 18:45:05 +04:00
|
|
|
-m*)
|
|
|
|
machine=$2; shift
|
|
|
|
;;
|
2002-12-19 09:21:45 +03:00
|
|
|
-N*)
|
|
|
|
etcdir=$2; shift
|
|
|
|
;;
|
1998-06-15 18:45:05 +04:00
|
|
|
-s*)
|
|
|
|
setd=$2; shift
|
|
|
|
;;
|
|
|
|
-d*)
|
|
|
|
dest=$2; shift
|
|
|
|
;;
|
2002-02-27 13:51:47 +03:00
|
|
|
-t*)
|
1998-06-15 18:45:05 +04:00
|
|
|
tars=$2; shift
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
cat 1>&2 <<USAGE
|
2002-12-19 09:21:45 +03:00
|
|
|
Usage: $0 [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir]
|
2003-01-03 18:26:32 +03:00
|
|
|
[-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
|
1998-06-15 18:45:05 +04:00
|
|
|
-b make netbsd + x11 lists
|
|
|
|
-x only make x11 lists
|
2002-12-19 09:21:45 +03:00
|
|
|
-i idir install sets to idir instead of creating tar files
|
2001-11-24 06:08:27 +03:00
|
|
|
-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]
|
2002-02-27 13:51:47 +03:00
|
|
|
-M metalog metalog file
|
2002-12-19 09:21:45 +03:00
|
|
|
-N etcdir etc dir for metalog use [$dest/etc]
|
1998-06-15 18:45:05 +04:00
|
|
|
-d dest \$DESTDIR [$dest]
|
2003-01-03 18:26:32 +03:00
|
|
|
-t targetdir \$RELEASEDIR [$tars]
|
1998-06-15 18:45:05 +04:00
|
|
|
[setname ...] sets to build [$lists]
|
|
|
|
USAGE
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
1996-05-20 23:10:28 +04:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2002-12-12 11:51:49 +03:00
|
|
|
if [ -n "$installdir" ]; then # if -i, remove etc from default list
|
|
|
|
lists=$(echo $lists | sed -e 's/ etc / /')
|
|
|
|
fi
|
1998-06-27 12:27:36 +04:00
|
|
|
if [ -n "$*" ]; then
|
|
|
|
lists="$*"
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2002-12-12 11:51:49 +03:00
|
|
|
if [ -z "$tars" -a -z "$installdir" ]; then
|
|
|
|
echo \$RELEASEDIR must be set, or -i must be used
|
1994-08-29 19:21:02 +04:00
|
|
|
exit 1
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
1994-08-29 19:21:02 +04:00
|
|
|
|
1998-06-15 18:45:05 +04:00
|
|
|
if [ -z "$dest" ]; then
|
|
|
|
echo \$DESTDIR must be set
|
1994-08-29 19:21:02 +04:00
|
|
|
exit 1
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
2002-12-19 09:21:45 +03:00
|
|
|
: ${etcdir:=${dest}/etc}
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2002-04-01 19:50:30 +04:00
|
|
|
# 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
|
2003-01-06 23:30:28 +03:00
|
|
|
echo /tmp is not writable
|
2002-04-01 19:50:30 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SDIR_BASE=/tmp/maketar.$$
|
|
|
|
SDIR_SERIAL=0
|
|
|
|
|
|
|
|
while true; do
|
2002-04-13 16:47:10 +04:00
|
|
|
SDIR=${SDIR_BASE}.${SDIR_SERIAL}
|
|
|
|
mkdir -m 0700 ${SDIR} && break
|
|
|
|
SDIR_SERIAL=$((${SDIR_SERIAL} + 1))
|
2002-04-01 19:50:30 +04:00
|
|
|
done
|
|
|
|
|
2003-01-21 22:07:05 +03:00
|
|
|
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
|
2002-02-27 13:51:47 +03:00
|
|
|
|
|
|
|
if [ -n "$metalog" ]; then
|
2002-12-12 11:51:49 +03:00
|
|
|
echo "Parsing $metalog"
|
2002-04-13 16:47:10 +04:00
|
|
|
(
|
2002-12-19 09:21:45 +03:00
|
|
|
cat ${etcdir}/mtree/NetBSD.dist
|
2002-04-13 16:47:10 +04:00
|
|
|
echo "/unset all"
|
2002-12-23 09:52:48 +03:00
|
|
|
cat $metalog
|
|
|
|
) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog
|
2002-02-27 13:51:47 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
GZIP=-9 # for pax -z
|
|
|
|
export GZIP
|
|
|
|
|
1998-06-15 18:45:05 +04:00
|
|
|
for setname in $lists; do
|
1998-12-03 21:17:45 +03:00
|
|
|
out=$setname.tgz
|
2002-12-12 11:51:49 +03:00
|
|
|
if [ -n "$installdir" ]; then
|
|
|
|
echo "Copying set $setname"
|
|
|
|
else
|
|
|
|
echo "Creating $out"
|
|
|
|
fi
|
2002-02-27 13:51:47 +03:00
|
|
|
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 \
|
2002-05-19 17:24:22 +04:00
|
|
|
> $SDIR/flist.$setname.full
|
2002-04-13 16:47:10 +04:00
|
|
|
(
|
|
|
|
echo "/set uname=root gname=wheel"
|
2002-05-19 17:24:22 +04:00
|
|
|
awk -f join.awk $SDIR/flist.$setname.full $SDIR/metalog
|
2002-04-13 16:47:10 +04:00
|
|
|
) > $SDIR/plist.$setname
|
2002-02-27 13:51:47 +03:00
|
|
|
else
|
|
|
|
mv $SDIR/flist.$setname $SDIR/plist.$setname
|
|
|
|
fi
|
|
|
|
|
2002-12-12 11:51:49 +03:00
|
|
|
if [ -n "$installdir" ]; then
|
|
|
|
( cd $dest ; \
|
2003-04-07 21:22:19 +04:00
|
|
|
${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \
|
2002-12-12 11:51:49 +03:00
|
|
|
$installdir < ${SDIR}/plist.$setname )
|
|
|
|
else
|
|
|
|
( cd $dest ; \
|
2002-12-21 18:54:48 +03:00
|
|
|
${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \
|
2002-12-12 11:51:49 +03:00
|
|
|
< ${SDIR}/plist.$setname ) > ${tars}/$out
|
|
|
|
fi
|
2002-02-27 13:51:47 +03:00
|
|
|
es=$(($es + $?))
|
1996-05-20 23:10:28 +04:00
|
|
|
done
|
2003-01-21 22:07:05 +03:00
|
|
|
if [ $es -gt 255 ] ; then
|
|
|
|
es=255
|
|
|
|
fi
|
2002-02-26 23:03:08 +03:00
|
|
|
exit $es
|