#!/bin/sh # # $NetBSD: maketars,v 1.54 2004/07/23 15:11:26 erh 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. # In this case, remove "etc" and "xetc" from the list of default sets. # prog=${0##*/} # set defaults : ${HOST_SH=sh} : ${MKTEMP=mktemp} : ${MTREE=mtree} : ${PAX=pax} rundir=${0%/*} . ${rundir}/sets.subr lists=$nlists tars=$RELEASEDIR dest=$DESTDIR metalog= installdir= etcdir= setfilesonly=false usage() { cat 1>&2 <&2 \$RELEASEDIR must be set, or -i must be used exit 1 fi if [ -z "$dest" ]; then echo 1>&2 \$DESTDIR must be set exit 1 fi : ${etcdir:=${dest}/etc} SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX) setlistdir=${dest}/etc/mtree cleanup() { es=$? /bin/rm -rf $SDIR exit $es } trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE # # build the setfiles # if [ -n "$metalog" ]; then ( cat ${etcdir}/mtree/NetBSD.dist echo "/unset all" cat $metalog 2>/dev/null ) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog rv=$? if [ $rv -ne 0 ]; then 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 $rundir/getdirs.awk $SDIR/flist.$setname \ | sort -u > $SDIR/flist.$setname.full ( echo "/set uname=root gname=wheel" awk -f $rundir/join.awk $SDIR/flist.$setname.full $SDIR/metalog echo "./etc/mtree/set.${setname} type=file mode=0444" ) > ${setlistdir}/set.${setname} 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} 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" rm -f ${tars}/$out ( cd $dest ; \ ${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \ < ${setlistdir}/set.${setname} ) > ${tars}/$out.tmp && mv ${tars}/$out.tmp ${tars}/$out fi es=$(($es + $?)) done if [ $es -gt 255 ] ; then es=255 fi exit $es