maketars revision 1.19 1 1.2 gwr #!/bin/sh
2 1.2 gwr #
3 1.19 lukem # $NetBSD: maketars,v 1.19 2002/03/01 07:21:14 lukem Exp $
4 1.2 gwr #
5 1.2 gwr # Make release tar files for some or all lists. Usage:
6 1.18 lukem # maketars [-b] [-x] [-a arch] [-m machine] [-s setsdir]
7 1.18 lukem # [-M metalog] [-d destdir] [-t tardir] [setname ...]
8 1.2 gwr #
9 1.2 gwr
10 1.2 gwr # set defaults
11 1.13 itohy : ${MAKE=make}
12 1.18 lukem : ${PAX=pax}
13 1.18 lukem : ${MTREE=mtree}
14 1.18 lukem
15 1.16 thorpej machine=`${MAKE} print_machine`
16 1.16 thorpej machine_arch=`${MAKE} print_machine_arch`
17 1.2 gwr setd=`pwd`
18 1.9 lukem nlists="base comp etc games man misc text"
19 1.14 thorpej xlists="xbase xcomp xcontrib xfont xserver xmisc"
20 1.9 lukem lists=$nlists
21 1.2 gwr tars=$RELEASEDIR
22 1.2 gwr dest=$DESTDIR
23 1.18 lukem metalog=
24 1.2 gwr
25 1.2 gwr # handle args
26 1.9 lukem while : ; do
27 1.2 gwr case $1 in
28 1.9 lukem -b*)
29 1.9 lukem lists="$xlists $nlists"
30 1.9 lukem ;;
31 1.18 lukem -x*)
32 1.9 lukem lists=$xlists
33 1.9 lukem ;;
34 1.9 lukem -a*)
35 1.16 thorpej machine_arch=$2; shift
36 1.9 lukem ;;
37 1.18 lukem -M*)
38 1.18 lukem metalog=$2; shift
39 1.18 lukem ;;
40 1.9 lukem -m*)
41 1.9 lukem machine=$2; shift
42 1.9 lukem ;;
43 1.9 lukem -s*)
44 1.9 lukem setd=$2; shift
45 1.9 lukem ;;
46 1.9 lukem -d*)
47 1.9 lukem dest=$2; shift
48 1.9 lukem ;;
49 1.18 lukem -t*)
50 1.9 lukem tars=$2; shift
51 1.9 lukem ;;
52 1.9 lukem -*)
53 1.9 lukem cat 1>&2 <<USAGE
54 1.18 lukem Usage: $0 [-b] [-x] [-a arch] [-m machine] [-s setsdir] [-M metalog]
55 1.9 lukem [-d dest] [-t tars] [setname ...]
56 1.9 lukem -b make netbsd + x11 lists
57 1.9 lukem -x only make x11 lists
58 1.16 thorpej -a arch set arch (e.g, m68k, mipseb, mipsel, powerpc) [$machine_arch]
59 1.16 thorpej -m machine set machine (e.g, amiga, i386, macppc) [$machine]
60 1.16 thorpej -s setsdir directory to find sets [$setd]
61 1.18 lukem -M metalog metalog file
62 1.9 lukem -d dest \$DESTDIR [$dest]
63 1.9 lukem -t tars \$RELEASEDIR [$tars]
64 1.9 lukem [setname ...] sets to build [$lists]
65 1.9 lukem USAGE
66 1.9 lukem exit 1
67 1.9 lukem ;;
68 1.9 lukem *)
69 1.9 lukem break
70 1.9 lukem ;;
71 1.2 gwr esac
72 1.2 gwr shift
73 1.2 gwr done
74 1.10 ross if [ -n "$*" ]; then
75 1.10 ross lists="$*"
76 1.9 lukem fi
77 1.1 cgd
78 1.9 lukem if [ -z "$tars" ]; then
79 1.9 lukem echo \$RELEASEDIR must be set
80 1.1 cgd exit 1
81 1.9 lukem fi
82 1.1 cgd
83 1.9 lukem if [ -z "$dest" ]; then
84 1.9 lukem echo \$DESTDIR must be set
85 1.1 cgd exit 1
86 1.9 lukem fi
87 1.1 cgd
88 1.18 lukem SDIR=`mktemp -d /tmp/maketar.XXXXXX` || exit 1
89 1.19 lukem trap "/bin/rm -rf $SDIR ; exit 0" 0 2 3 13 # EXIT INT QUIT PIPE
90 1.18 lukem
91 1.18 lukem if [ -n "$metalog" ]; then
92 1.18 lukem echo "parsing $metalog"
93 1.19 lukem ${MTREE} -D -k all -N ${DESTDIR}/etc \
94 1.19 lukem -f ${DESTDIR}/etc/mtree/NetBSD.dist | \
95 1.18 lukem sed -e 's,\(.*\) \(\..*\),\2 \1,' > $SDIR/metadirs
96 1.18 lukem sed -e "s,^\.$dest,.," < $metalog > $SDIR/metafiles
97 1.18 lukem cat $SDIR/metadirs $SDIR/metafiles | sort -u > $SDIR/metalog
98 1.18 lukem fi
99 1.18 lukem
100 1.18 lukem GZIP=-9 # for pax -z
101 1.18 lukem export GZIP
102 1.18 lukem
103 1.17 he es=0
104 1.9 lukem for setname in $lists; do
105 1.12 frueauf out=$setname.tgz
106 1.2 gwr echo "making $out"
107 1.18 lukem sh $setd/makeflist -a $machine_arch -m $machine -s $setd $setname \
108 1.18 lukem > $SDIR/flist.$setname
109 1.18 lukem if [ -n "$metalog" ]; then
110 1.18 lukem awk -f getdirs.awk $SDIR/flist.$setname | sort -u \
111 1.18 lukem > $SDIR/flist.full
112 1.18 lukem echo "/set uname=root gname=wheel" > $SDIR/plist.$setname
113 1.18 lukem join $SDIR/flist.full $SDIR/metalog >> $SDIR/plist.$setname
114 1.18 lukem else
115 1.18 lukem mv $SDIR/flist.$setname $SDIR/plist.$setname
116 1.18 lukem fi
117 1.18 lukem
118 1.18 lukem ( cd $dest ; \
119 1.18 lukem ${PAX} -w -d -z ${metalog:+-N$dest/etc} ${metalog:+-M} \
120 1.18 lukem < ${SDIR}/plist.$setname ) > ${tars}/$out
121 1.18 lukem es=$(($es + $?))
122 1.2 gwr done
123 1.17 he exit $es
124