3 # $NetBSD: maketars,v 1.80 2013/02/07 16:27:41 christos 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 debug etc games man misc tests text"
10 # The X sets are "xbase xcomp xdebug 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"
31 skipkeys
=time,md5
,sha1
,sha384
,sha512
,rmd160
,cksum
36 Usage: ${prog} [-L base,x,ext] [-b] [-x] [-y] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
37 [-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
38 -L base,x,ext Make specified lists
39 -b Make both netbsd and x11 lists
40 -x Only make x11 lists
41 [Default: make netbsd lists]
42 -y Only make extsrc lists
43 [Default: make netbsd lists]
44 -i idir Install sets to idir instead of creating tar files
45 -a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
46 -m machine Set machine (e.g, amiga, i386, macppc) [${MACHINE}]
48 -s setsdir Directory to find sets [${setsdir}]
49 -S Exit after creating set files ${dest}/etc/mtree/set.*
50 -M metalog metalog file
51 -N etcdir etc dir for metalog use [${dest}/etc]
52 -d dest \${DESTDIR} [${dest}]
53 -t targetdir \${RELEASEDIR} [${tars}]
54 [setname ...] Sets to build [${lists}]
65 while getopts L
:bxyi
:a
:m
:qs
:SM
:N
:d
:t
: ch
; do
70 for _list
in ${OPTARG}; do
72 base
) lists
="${lists} ${nlists}" ;;
73 x
) lists
="${lists} ${xlists}" ;;
74 ext
) lists
="${lists} ${extlists}" ;;
81 lists
="${nlists} ${xlists}"
90 installdir
="${OPTARG}"
93 MACHINE_ARCH
="${OPTARG}"
94 MACHINE_CPU
="$(arch_to_cpu "${OPTARG}")"
125 shift $
((${OPTIND} - 1))
126 if [ -n "${installdir}" ]; then # if -i, remove etc + xetc + extetc from the default list
127 lists
="$(echo ${lists} | ${SED} -e 's/ etc / /;s/ xetc / /;s/ extetc / /')"
133 if [ -z "${tars}" -a -z "${installdir}" ]; then
134 echo >&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used"
138 if [ -z "${dest}" ]; then
139 echo >&2 "${prog}: \${DESTDIR} must be set"
142 : ${etcdir:="${dest}/etc"}
144 SDIR
="$(${MKTEMP} -d "/tmp
/${prog}.XXXXXX
")"
147 setlistdir
="${dest}/etc/mtree"
152 /bin
/rm -rf "${SDIR}" ${TMPFILES}
156 trap cleanup
0 2 3 13 # EXIT INT QUIT PIPE
162 for setname
in ${lists}; do
163 ${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
164 -s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \
166 if [ ! -s "${SDIR}/flist.
${setname}" ]; then
167 echo >&2 "makeflist output is empty
for ${setname}"
170 ${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}"
171 if [ -n "${metalog}" ]; then
172 ${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
173 > "${SDIR}/flist.
${setname}.full
" \
176 echo "/set uname
=root gname
=operator
"
177 ${AWK} -f "${rundir}/join.
awk" \
178 "${SDIR}/flist.${setname}.full" "${metalog}"
179 echo ".
/etc
/mtree
/set.
${setname} type=file mode
=0444"
180 ) | ${MTREE} -CS -k all -R "${skipkeys}" -N "${etcdir}" \
181 > "${setlistdir}/set.${setname}" \
183 # We deliberately do not add set.${setname} to ${metalog},
184 # because we depend on it as an input.
186 ${MTREE} -c -p "${dest}" -k all -R "${skipkeys}" \
187 -O "${SDIR}/flist.${setname}" | ${MTREE} -C -k all
> \
188 "${setlistdir}/set.${setname}"
191 if ${setfilesonly}; then # exit after creating the set lists
199 ${PAX} -dOw -N"${etcdir}" -M "$@" < "${setlistdir}/set.${s}")
203 # now build the tarfiles
206 GZIP=-9n # for pax -z
209 for setname in ${lists:-${nlists}}; do
211 if [ -n "${installdir}" ]; then
212 msg "Copying
set ${setname}"
213 runpax "${setname}" -rpe "${installdir}"
215 if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
217 msg "${out} is up to
date"
220 msg "Creating
${out}"
221 rm -f "${tars}/${out}"
222 TMPFILES="${TMPFILES} ${tars}/${out}.tmp
"
223 runpax "${setname}" -z --use-compress-program \
224 ${COMPRESS_PROGRAM} > "${tars}/${out}.tmp" &&
225 mv "${tars}/${out}.tmp" "${tars}/${out}"
229 if [ ${es} -gt 255 ]; then