3 # $NetBSD: maketars,v 1.74 2010/08/15 07:27:33 mrg Exp $
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 ...]
9 # The default sets are "base comp etc games man misc tests text"
10 # The X sets are "xbase xcomp xetc xfont xserver"
11 # The extsrc sets are "extbase extcomp extetc"
13 # If '-i installdir' is given, copy the given sets to installdir
14 # (using pax -rw ...) instead of creating tar files.
15 # In this case, remove "etc", "xetc", and "extetc" from the list of default sets.
19 rundir
="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
20 .
"${rundir}/sets.subr"
35 Usage: ${prog} [-L base,x,ext] [-b] [-x] [-y] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
36 [-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
37 -L base,x,ext Make specified lists
38 -b Make both netbsd and x11 lists
39 -x Only make x11 lists
40 [Default: make netbsd lists]
41 -y Only make extsrc 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}]
47 -s setsdir Directory to find sets [${setsdir}]
48 -S Exit after creating set files ${dest}/etc/mtree/set.*
49 -M metalog metalog file
50 -N etcdir etc dir for metalog use [${dest}/etc]
51 -d dest \${DESTDIR} [${dest}]
52 -t targetdir \${RELEASEDIR} [${tars}]
53 [setname ...] Sets to build [${lists}]
64 while getopts L
:bxyi
:a
:m
:qs
:SM
:N
:d
:t
: ch
; do
69 for _list
in ${OPTARG}; do
71 base
) lists
="${lists} ${nlists}" ;;
72 x
) lists
="${lists} ${xlists}" ;;
73 ext
) lists
="${lists} ${extlists}" ;;
80 lists
="${nlists} ${xlists}"
89 installdir
="${OPTARG}"
92 MACHINE_ARCH
="${OPTARG}"
93 MACHINE_CPU
="$(arch_to_cpu "${OPTARG}")"
124 shift $
((${OPTIND} - 1))
125 if [ -n "${installdir}" ]; then # if -i, remove etc + xetc + extetc from the default list
126 lists
="$(echo ${lists} | ${SED} -e 's/ etc / /;s/ xetc / /;s/ extetc / /')"
132 if [ -z "${tars}" -a -z "${installdir}" ]; then
133 echo >&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used"
137 if [ -z "${dest}" ]; then
138 echo >&2 "${prog}: \${DESTDIR} must be set"
141 : ${etcdir:="${dest}/etc"}
143 SDIR
="$(${MKTEMP} -d "/tmp
/${prog}.XXXXXX
")"
146 setlistdir
="${dest}/etc/mtree"
151 /bin
/rm -rf "${SDIR}" ${TMPFILES}
155 trap cleanup
0 2 3 13 # EXIT INT QUIT PIPE
161 for setname
in ${lists}; do
162 ${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
163 -s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \
165 if [ ! -s "${SDIR}/flist.
${setname}" ]; then
166 echo >&2 "makeflist output is empty
for ${setname}"
169 if [ -n "${metalog}" ]; then
170 ${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}"
171 ${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
172 > "${SDIR}/flist.
${setname}.full
" \
175 echo "/set uname
=root gname
=operator
"
176 ${AWK} -f "${rundir}/join.
awk" \
177 "${SDIR}/flist.${setname}.full" "${metalog}"
178 echo ".
/etc
/mtree
/set.
${setname} type=file mode
=0444"
179 ) | ${MTREE} -CS -k all -R time -N "${etcdir}" \
180 > "${setlistdir}/set.
${setname}" \
182 # We deliberately do not add set.${setname} to ${metalog},
183 # because we depend on it as an input.
184 elif ! cmp -s "${SDIR}/flist.
${setname}" \
185 "${setlistdir}/set.
${setname}" >/dev/null 2>&1; then
186 rm -f "${setlistdir}/set.
${setname}"
187 cp "${SDIR}/flist.${setname}" "${setlistdir}/set.${setname}" \
191 if ${setfilesonly}; then # exit after creating the set lists
196 # now build the tarfiles
199 GZIP=-9n # for pax -z
202 for setname in ${lists:-${nlists}}; do
204 if [ -n "${installdir}" ]; then
205 msg "Copying
set ${setname}"
207 ${PAX} -O -rwpe -d -N"${etcdir}" ${metalog:+-M} \
208 "${installdir}" < "${setlistdir}/set.${setname}" )
210 if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
212 msg "${out} is up to
date"
215 msg "Creating
${out}"
216 rm -f "${tars}/${out}"
217 TMPFILES="${TMPFILES} ${tars}/${out}.tmp
"
219 ${PAX} -O -w -d -z -N"${etcdir}" ${metalog:+-M} \
220 --use-compress-program ${COMPRESS_PROGRAM} \
221 < "${setlistdir}/set.
${setname}" ) \
222 > "${tars}/${out}.tmp
" &&
223 mv "${tars}/${out}.tmp" "${tars}/${out}"
227 if [ ${es} -gt 255 ]; then