1996-05-20 23:10:28 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2004-04-18 23:52:32 +04:00
|
|
|
# $NetBSD: maketars,v 1.53 2004/04/18 19:52:32 dsl 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"
|
2004-01-30 11:39:50 +03:00
|
|
|
# The X sets are "xbase xcomp xetc xfont xserver"
|
2002-12-26 02:47:32 +03:00
|
|
|
#
|
|
|
|
# If '-i installdir' is given, copy the given sets to installdir
|
|
|
|
# (using pax -rw ...) instead of creating tar files.
|
2004-01-29 11:32:51 +03:00
|
|
|
# In this case, remove "etc" and "xetc" from the list of default sets.
|
2002-12-26 02:47:32 +03:00
|
|
|
#
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2003-09-30 09:07:40 +04:00
|
|
|
prog=${0##*/}
|
2003-07-03 10:43:02 +04:00
|
|
|
|
1996-05-20 23:10:28 +04:00
|
|
|
# set defaults
|
2003-12-29 06:13:25 +03:00
|
|
|
: ${HOST_SH=sh}
|
2003-09-30 09:07:40 +04:00
|
|
|
: ${MKTEMP=mktemp}
|
2002-02-27 13:51:47 +03:00
|
|
|
: ${MTREE=mtree}
|
2003-12-29 06:13:25 +03:00
|
|
|
: ${PAX=pax}
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
. $(dirname $0)/sets.subr
|
|
|
|
lists=$nlists
|
2003-11-25 10:19:46 +03:00
|
|
|
|
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=
|
2004-01-30 11:39:50 +03:00
|
|
|
setfilesonly=false
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat 1>&2 <<USAGE
|
2004-01-30 11:39:50 +03:00
|
|
|
Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
|
2003-01-03 18:26:32 +03:00
|
|
|
[-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
|
2004-01-30 11:39:50 +03:00
|
|
|
-b Make both netbsd and x11 lists
|
|
|
|
-x Only make x11 lists
|
|
|
|
[Default: make netbsd 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 [$setsdir]
|
|
|
|
-S Exit after creating set files $dest/etc/mtree/set.*
|
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]
|
2004-01-30 11:39:50 +03:00
|
|
|
[setname ...] Sets to build [$lists]
|
1998-06-15 18:45:05 +04:00
|
|
|
USAGE
|
2003-12-29 06:13:25 +03:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# handle args
|
2004-01-30 11:39:50 +03:00
|
|
|
while getopts bxi:a:m:s:SM:N:d:t: ch; do
|
2003-12-29 06:13:25 +03:00
|
|
|
case ${ch} in
|
|
|
|
b)
|
2004-01-29 11:32:51 +03:00
|
|
|
lists="$nlists $xlists"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
x)
|
|
|
|
lists="$xlists"
|
|
|
|
;;
|
|
|
|
i)
|
|
|
|
installdir=${OPTARG}
|
|
|
|
;;
|
|
|
|
a)
|
2004-01-03 05:38:58 +03:00
|
|
|
MACHINE_ARCH=${OPTARG}
|
|
|
|
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
m)
|
2004-01-03 05:38:58 +03:00
|
|
|
MACHINE=${OPTARG}
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
s)
|
|
|
|
setsdir=${OPTARG}
|
|
|
|
;;
|
2004-01-30 11:39:50 +03:00
|
|
|
S)
|
|
|
|
setfilesonly=true
|
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
M)
|
|
|
|
metalog=${OPTARG}
|
|
|
|
;;
|
|
|
|
N)
|
|
|
|
etcdir=${OPTARG}
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
dest=${OPTARG}
|
|
|
|
;;
|
|
|
|
t)
|
|
|
|
tars=${OPTARG}
|
1998-06-15 18:45:05 +04:00
|
|
|
;;
|
|
|
|
*)
|
2003-12-29 06:13:25 +03:00
|
|
|
usage
|
1998-06-15 18:45:05 +04:00
|
|
|
;;
|
1996-05-20 23:10:28 +04:00
|
|
|
esac
|
|
|
|
done
|
2003-12-29 06:13:25 +03:00
|
|
|
shift $((${OPTIND} - 1))
|
2004-01-29 11:32:51 +03:00
|
|
|
if [ -n "$installdir" ]; then # if -i, remove etc & xetc from the default list
|
|
|
|
lists=$(echo $lists | sed -e 's/ etc / /;s/ xetc / /')
|
2002-12-12 11:51:49 +03:00
|
|
|
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
|
2004-01-30 11:39:50 +03:00
|
|
|
echo 1>&2 \$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
|
2004-01-30 11:39:50 +03:00
|
|
|
echo 1>&2 \$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
|
|
|
|
2003-09-30 09:07:40 +04:00
|
|
|
SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
|
2002-04-01 19:50:30 +04:00
|
|
|
|
2004-01-30 11:39:50 +03:00
|
|
|
setlistdir=${dest}/etc/mtree
|
|
|
|
|
2003-01-21 22:07:05 +03:00
|
|
|
cleanup()
|
|
|
|
{
|
2003-10-16 18:20:20 +04:00
|
|
|
es=$?
|
2003-01-21 22:07:05 +03:00
|
|
|
/bin/rm -rf $SDIR
|
|
|
|
exit $es
|
|
|
|
}
|
|
|
|
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2004-01-30 11:39:50 +03:00
|
|
|
#
|
|
|
|
# build the setfiles
|
|
|
|
#
|
|
|
|
|
2002-02-27 13:51:47 +03:00
|
|
|
if [ -n "$metalog" ]; then
|
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"
|
2003-10-16 18:20:20 +04:00
|
|
|
cat $metalog 2>/dev/null
|
2002-12-23 09:52:48 +03:00
|
|
|
) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog
|
2003-07-03 10:43:02 +04:00
|
|
|
rv=$?
|
|
|
|
if [ $rv -ne 0 ]; then
|
2004-02-19 05:54:51 +03:00
|
|
|
echo 1>&2 "${prog}: mtree parse of ${metalog} failed"
|
2003-07-03 10:43:02 +04:00
|
|
|
exit $rv
|
|
|
|
fi
|
2002-02-27 13:51:47 +03:00
|
|
|
fi
|
1998-06-15 18:45:05 +04:00
|
|
|
for setname in $lists; do
|
2004-01-03 05:38:58 +03:00
|
|
|
${HOST_SH} $setsdir/makeflist -a $MACHINE_ARCH -m $MACHINE \
|
2003-12-29 06:13:25 +03:00
|
|
|
-s $setsdir $setname > $SDIR/flist.$setname
|
2002-02-27 13:51:47 +03:00
|
|
|
if [ -n "$metalog" ]; then
|
2004-01-30 11:39:50 +03:00
|
|
|
$setfilesonly && echo "Creating ${setlistdir}/set.${setname}"
|
|
|
|
awk -f getdirs.awk ${SDIR}/flist.${setname} \
|
|
|
|
| sort -u > $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
|
2004-01-30 11:39:50 +03:00
|
|
|
echo "./etc/mtree/set.${setname} type=file mode=0444"
|
|
|
|
) > ${setlistdir}/set.${setname}
|
2004-02-06 14:38:57 +03:00
|
|
|
elif ! cmp -s ${SDIR}/flist.${setname} \
|
|
|
|
${setlistdir}/set.${setname} >/dev/null 2>&1; then
|
|
|
|
rm -f ${setlistdir}/set.${setname}
|
|
|
|
cp ${SDIR}/flist.${setname} ${setlistdir}/set.${setname}
|
2002-02-27 13:51:47 +03:00
|
|
|
fi
|
2004-01-30 11:39:50 +03:00
|
|
|
done
|
|
|
|
if $setfilesonly; then # exit after creating the set lists
|
|
|
|
exit 0
|
|
|
|
fi
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2004-01-30 11:39:50 +03:00
|
|
|
#
|
|
|
|
# now build the tarfiles
|
|
|
|
#
|
|
|
|
|
|
|
|
GZIP=-9 # for pax -z
|
|
|
|
export GZIP
|
|
|
|
es=0
|
|
|
|
for setname in $lists; do
|
|
|
|
out=$setname.tgz
|
2002-12-12 11:51:49 +03:00
|
|
|
if [ -n "$installdir" ]; then
|
2004-01-30 11:39:50 +03:00
|
|
|
echo "Copying set $setname"
|
2002-12-12 11:51:49 +03:00
|
|
|
( cd $dest ; \
|
2003-04-07 21:22:19 +04:00
|
|
|
${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \
|
2004-04-18 23:52:32 +04:00
|
|
|
${installdir} < ${setlistdir}/set.${setname} )
|
2002-12-12 11:51:49 +03:00
|
|
|
else
|
2004-01-30 11:39:50 +03:00
|
|
|
if [ -n "$metalog" -a $tars/$out -nt "$metalog" ]; then
|
|
|
|
echo "$out is up to date"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Creating $out"
|
2004-04-18 23:52:32 +04:00
|
|
|
rm -f ${tars}/$out
|
2002-12-12 11:51:49 +03:00
|
|
|
( cd $dest ; \
|
2002-12-21 18:54:48 +03:00
|
|
|
${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \
|
2004-04-18 23:52:32 +04:00
|
|
|
< ${setlistdir}/set.${setname} ) > ${tars}/$out.tmp &&
|
|
|
|
mv ${tars}/$out.tmp ${tars}/$out
|
2002-12-12 11:51:49 +03:00
|
|
|
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
|