maketars revision 1.51
1#!/bin/sh 2# 3# $NetBSD: maketars,v 1.51 2004/02/06 11:38:57 lukem Exp $ 4# 5# Make release tar files for some or all lists. Usage: 6# maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir] 7# [-M metalog] [-N etcdir] [-d destdir] [-t tardir] [setname ...] 8# 9# The default sets are "base comp etc games man misc text" 10# The X sets are "xbase xcomp xetc xfont xserver" 11# 12# If '-i installdir' is given, copy the given sets to installdir 13# (using pax -rw ...) instead of creating tar files. 14# In this case, remove "etc" and "xetc" from the list of default sets. 15# 16 17prog=${0##*/} 18 19# set defaults 20: ${HOST_SH=sh} 21: ${MKTEMP=mktemp} 22: ${MTREE=mtree} 23: ${PAX=pax} 24 25. $(dirname $0)/sets.subr 26lists=$nlists 27 28tars=$RELEASEDIR 29dest=$DESTDIR 30metalog= 31installdir= 32etcdir= 33setfilesonly=false 34 35usage() 36{ 37 cat 1>&2 <<USAGE 38Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S] 39 [-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...] 40 -b Make both netbsd and x11 lists 41 -x Only make x11 lists 42 [Default: make netbsd lists] 43 -i idir Install sets to idir instead of creating tar files 44 -a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [$MACHINE_ARCH] 45 -m machine Set machine (e.g, amiga, i386, macppc) [$MACHINE] 46 -s setsdir Directory to find sets [$setsdir] 47 -S Exit after creating set files $dest/etc/mtree/set.* 48 -M metalog metalog file 49 -N etcdir etc dir for metalog use [$dest/etc] 50 -d dest \$DESTDIR [$dest] 51 -t targetdir \$RELEASEDIR [$tars] 52 [setname ...] Sets to build [$lists] 53USAGE 54 exit 1 55} 56 57# handle args 58while getopts bxi:a:m:s:SM:N:d:t: ch; do 59 case ${ch} in 60 b) 61 lists="$nlists $xlists" 62 ;; 63 x) 64 lists="$xlists" 65 ;; 66 i) 67 installdir=${OPTARG} 68 ;; 69 a) 70 MACHINE_ARCH=${OPTARG} 71 MACHINE_CPU=$(arch_to_cpu ${OPTARG}) 72 ;; 73 m) 74 MACHINE=${OPTARG} 75 ;; 76 s) 77 setsdir=${OPTARG} 78 ;; 79 S) 80 setfilesonly=true 81 ;; 82 M) 83 metalog=${OPTARG} 84 ;; 85 N) 86 etcdir=${OPTARG} 87 ;; 88 d) 89 dest=${OPTARG} 90 ;; 91 t) 92 tars=${OPTARG} 93 ;; 94 *) 95 usage 96 ;; 97 esac 98done 99shift $((${OPTIND} - 1)) 100if [ -n "$installdir" ]; then # if -i, remove etc & xetc from the default list 101 lists=$(echo $lists | sed -e 's/ etc / /;s/ xetc / /') 102fi 103if [ -n "$*" ]; then 104 lists="$*" 105fi 106 107if [ -z "$tars" -a -z "$installdir" ]; then 108 echo 1>&2 \$RELEASEDIR must be set, or -i must be used 109 exit 1 110fi 111 112if [ -z "$dest" ]; then 113 echo 1>&2 \$DESTDIR must be set 114 exit 1 115fi 116: ${etcdir:=${dest}/etc} 117 118SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX) 119 120setlistdir=${dest}/etc/mtree 121 122cleanup() 123{ 124 es=$? 125 /bin/rm -rf $SDIR 126 exit $es 127} 128trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE 129 130# 131# build the setfiles 132# 133 134if [ -n "$metalog" ]; then 135 ( 136 cat ${etcdir}/mtree/NetBSD.dist 137 echo "/unset all" 138 cat $metalog 2>/dev/null 139 ) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog 140 rv=$? 141 if [ $rv -ne 0 ]; then 142 echo 1>&2 "${prog}: mtree parse of ${METALOG} failed" 143 exit $rv 144 fi 145fi 146for setname in $lists; do 147 ${HOST_SH} $setsdir/makeflist -a $MACHINE_ARCH -m $MACHINE \ 148 -s $setsdir $setname > $SDIR/flist.$setname 149 if [ -n "$metalog" ]; then 150 $setfilesonly && echo "Creating ${setlistdir}/set.${setname}" 151 awk -f getdirs.awk ${SDIR}/flist.${setname} \ 152 | sort -u > $SDIR/flist.$setname.full 153 ( 154 echo "/set uname=root gname=wheel" 155 awk -f join.awk $SDIR/flist.$setname.full $SDIR/metalog 156 echo "./etc/mtree/set.${setname} type=file mode=0444" 157 ) > ${setlistdir}/set.${setname} 158 elif ! cmp -s ${SDIR}/flist.${setname} \ 159 ${setlistdir}/set.${setname} >/dev/null 2>&1; then 160 rm -f ${setlistdir}/set.${setname} 161 cp ${SDIR}/flist.${setname} ${setlistdir}/set.${setname} 162 fi 163done 164if $setfilesonly; then # exit after creating the set lists 165 exit 0 166fi 167 168# 169# now build the tarfiles 170# 171 172GZIP=-9 # for pax -z 173export GZIP 174es=0 175for setname in $lists; do 176 out=$setname.tgz 177 if [ -n "$installdir" ]; then 178 echo "Copying set $setname" 179 ( cd $dest ; \ 180 ${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \ 181 ${installdir} < ${setlistdir}/set.${setname} ) 182 else 183 if [ -n "$metalog" -a $tars/$out -nt "$metalog" ]; then 184 echo "$out is up to date" 185 continue 186 fi 187 echo "Creating $out" 188 ( cd $dest ; \ 189 ${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \ 190 < ${setlistdir}/set.${setname} ) > ${tars}/$out 191 fi 192 es=$(($es + $?)) 193done 194if [ $es -gt 255 ] ; then 195 es=255 196fi 197exit $es 198