Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles. Send errors to stderr instead of stdout.
This commit is contained in:
parent
bc42f94b01
commit
1c401bb3d7
@ -1,12 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: maketars,v 1.49 2004/01/29 08:32:51 lukem Exp $
|
||||
# $NetBSD: maketars,v 1.50 2004/01/30 08:39:50 lukem 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"
|
||||
# The X sets are "xbase xcomp xetc xfont xserver"
|
||||
#
|
||||
# If '-i installdir' is given, copy the given sets to installdir
|
||||
# (using pax -rw ...) instead of creating tar files.
|
||||
@ -29,29 +30,32 @@ dest=$DESTDIR
|
||||
metalog=
|
||||
installdir=
|
||||
etcdir=
|
||||
setfilesonly=false
|
||||
|
||||
usage()
|
||||
{
|
||||
cat 1>&2 <<USAGE
|
||||
Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir]
|
||||
Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
|
||||
[-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 [$setsdir]
|
||||
-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.*
|
||||
-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]
|
||||
[setname ...] Sets to build [$lists]
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
# handle args
|
||||
while getopts bxi:a:m:s:M:N:d:t: ch; do
|
||||
while getopts bxi:a:m:s:SM:N:d:t: ch; do
|
||||
case ${ch} in
|
||||
b)
|
||||
lists="$nlists $xlists"
|
||||
@ -72,6 +76,9 @@ while getopts bxi:a:m:s:M:N:d:t: ch; do
|
||||
s)
|
||||
setsdir=${OPTARG}
|
||||
;;
|
||||
S)
|
||||
setfilesonly=true
|
||||
;;
|
||||
M)
|
||||
metalog=${OPTARG}
|
||||
;;
|
||||
@ -98,19 +105,20 @@ if [ -n "$*" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$tars" -a -z "$installdir" ]; then
|
||||
echo \$RELEASEDIR must be set, or -i must be used
|
||||
echo 1>&2 \$RELEASEDIR must be set, or -i must be used
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$dest" ]; then
|
||||
echo \$DESTDIR must be set
|
||||
echo 1>&2 \$DESTDIR must be set
|
||||
exit 1
|
||||
fi
|
||||
: ${etcdir:=${dest}/etc}
|
||||
|
||||
SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
|
||||
|
||||
es=0
|
||||
setlistdir=${dest}/etc/mtree
|
||||
|
||||
cleanup()
|
||||
{
|
||||
es=$?
|
||||
@ -119,8 +127,11 @@ cleanup()
|
||||
}
|
||||
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
|
||||
|
||||
#
|
||||
# build the setfiles
|
||||
#
|
||||
|
||||
if [ -n "$metalog" ]; then
|
||||
echo "Parsing $metalog"
|
||||
(
|
||||
cat ${etcdir}/mtree/NetBSD.dist
|
||||
echo "/unset all"
|
||||
@ -128,46 +139,53 @@ if [ -n "$metalog" ]; then
|
||||
) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog
|
||||
rv=$?
|
||||
if [ $rv -ne 0 ]; then
|
||||
echo "${prog}: mtree failed, exiting"
|
||||
echo 1>&2 "${prog}: mtree parse of ${METALOG} failed"
|
||||
exit $rv
|
||||
fi
|
||||
fi
|
||||
for setname in $lists; do
|
||||
${HOST_SH} $setsdir/makeflist -a $MACHINE_ARCH -m $MACHINE \
|
||||
-s $setsdir $setname > $SDIR/flist.$setname
|
||||
if [ -n "$metalog" ]; then
|
||||
$setfilesonly && echo "Creating ${setlistdir}/set.${setname}"
|
||||
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
|
||||
echo "./etc/mtree/set.${setname} type=file mode=0444"
|
||||
) > ${setlistdir}/set.${setname}
|
||||
else
|
||||
mv ${SDIR}/flist.${setname} ${setlistdir}/set.${setname}
|
||||
fi
|
||||
done
|
||||
if $setfilesonly; then # exit after creating the set lists
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# now build the tarfiles
|
||||
#
|
||||
|
||||
GZIP=-9 # for pax -z
|
||||
export GZIP
|
||||
|
||||
es=0
|
||||
for setname in $lists; do
|
||||
out=$setname.tgz
|
||||
if [ -n "$installdir" ]; then
|
||||
echo "Copying set $setname"
|
||||
( cd $dest ; \
|
||||
${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \
|
||||
${installdir} < ${setlistdir}/set.${setname} )
|
||||
else
|
||||
if [ -n "$metalog" -a $tars/$out -nt "$metalog" ]; then
|
||||
echo "$out is up to date"
|
||||
continue
|
||||
fi
|
||||
echo "Creating $out"
|
||||
fi
|
||||
${HOST_SH} $setsdir/makeflist -a $MACHINE_ARCH -m $MACHINE \
|
||||
-s $setsdir $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
|
||||
< ${setlistdir}/set.${setname} ) > ${tars}/$out
|
||||
fi
|
||||
es=$(($es + $?))
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user