3 # $NetBSD: maketars,v 1.84 2015/05/27 15:18:29 martin 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] [-F setlistsdir] [-d destdir]
8 # [-t tardir] [-U] [setname ...]
10 # The default sets are "base comp debug etc games man misc tests text"
11 # The X sets are "xbase xcomp xdebug xetc xfont xserver"
12 # The extsrc sets are "extbase extcomp extetc"
14 # If '-i installdir' is given, copy the given sets to installdir
15 # (using pax -rw ...) instead of creating tar files.
16 # In this case, remove "etc", "xetc", and "extetc" from the list of default sets.
20 rundir
="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
21 .
"${rundir}/sets.subr"
33 skipkeys
=time,md5
,sha1
,sha384
,sha512
,rmd160
,cksum
39 Usage: ${prog} [-L base,x,ext] [-b] [-x] [-y] [-i idir] [-a arch] [-m machine]
40 [-s setsdir] [-S] [-M metalog] [-N etcdir] [-F setlistdir]
41 [-d dest] [-t targetdir] [setname ...]
42 -L base,x,ext Make specified lists
43 -b Make both netbsd and x11 lists
44 -x Only make x11 lists
45 [Default: make netbsd lists]
46 -y Only make extsrc lists
47 [Default: make netbsd lists]
48 -i idir Install sets to idir instead of creating tar files
49 -a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
50 -m machine Set machine (e.g, amiga, i386, macppc) [${MACHINE}]
52 -s setsdir Directory to find sets [${setsdir}]
53 -F setlistdir output directory for generated set lists [${dest}/etc/mtree/]
54 -S Exit after creating set files ${dest}/etc/mtree/set.*
55 -M metalog metalog file
56 -N etcdir etc dir for metalog use [${dest}/etc]
57 -U do not preserve file permissions (with -i ..)
58 -d dest \${DESTDIR} [${dest}]
59 -t targetdir \${RELEASEDIR} [${tars}]
60 [setname ...] Sets to build [${lists}]
71 while getopts L
:bxyi
:a
:m
:qs
:F
:SM
:N
:Ud
:t
: ch
; do
76 for _list
in ${OPTARG}; do
78 base
) lists
="${lists} ${nlists}" ;;
79 x
) lists
="${lists} ${xlists}" ;;
80 ext
) lists
="${lists} ${extlists}" ;;
87 lists
="${nlists} ${xlists}"
96 installdir
="${OPTARG}"
99 MACHINE_ARCH
="${OPTARG}"
100 MACHINE_CPU
="$(arch_to_cpu "${OPTARG}")"
112 setlistdir
="${OPTARG}"
137 shift $
((${OPTIND} - 1))
138 if [ -n "${installdir}" ]; then # if -i, remove etc + xetc + extetc from the default list
139 lists
="$(echo ${lists} | ${SED} -e 's/ etc / /;s/ xetc / /;s/ extetc / /')"
145 if [ -z "${tars}" -a -z "${installdir}" ]; then
146 echo >&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used"
150 if [ -z "${dest}" ]; then
151 echo >&2 "${prog}: \${DESTDIR} must be set"
154 : ${etcdir:="${dest}/etc"}
156 SDIR
="$(${MKTEMP} -d "/tmp
/${prog}.XXXXXX
")"
159 : ${setlistdir:="${dest}/etc/mtree"}
164 /bin
/rm -rf "${SDIR}" ${TMPFILES}
168 trap cleanup
0 2 3 13 # EXIT INT QUIT PIPE
174 for setname
in ${lists}; do
175 ${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
176 -s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \
178 if [ ! -s "${SDIR}/flist.
${setname}" ]; then
179 echo >&2 "makeflist output is empty
for ${setname}"
182 ${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}"
183 if [ -n "${metalog}" ]; then
184 ${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
185 > "${SDIR}/flist.
${setname}.full
" \
188 echo "/set uname
=root gname
=wheel
"
189 ${AWK} -f "${rundir}/join.
awk" \
190 "${SDIR}/flist.${setname}.full" "${metalog}"
191 echo ".
/etc
/mtree
/set.
${setname} type=file mode
=0444"
192 ) | ${MTREE} -CS -k all -R "${skipkeys}" -N "${etcdir}" \
193 > "${setlistdir}/set.${setname}" \
195 # We deliberately do not add set.${setname} to ${metalog},
196 # because we depend on it as an input.
198 ${MTREE} -c -p "${dest}" -k all -R "${skipkeys}" \
199 -O "${SDIR}/flist.${setname}" | ${MTREE} -C -k all
> \
200 "${setlistdir}/set.${setname}"
203 if ${setfilesonly}; then # exit after creating the set lists
211 ${PAX} -dOw -N"${etcdir}" -M "$@" < "${setlistdir}/set.${s}")
215 # now build the tarfiles
218 GZIP=-9n # for pax -z
222 for setname in ${lists:-${nlists}}; do
224 if [ -n "${installdir}" ]; then
225 msg "Copying
set ${setname}"
226 runpax "${setname}" -r ${preserve} "${installdir}"
228 if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
230 msg "${out} is up to
date"
233 msg "Creating
${out}"
234 rm -f "${tars}/${out}"
235 TMPFILES="${TMPFILES} ${tars}/${out}.tmp
"
236 runpax "${setname}" -z --use-compress-program \
237 ${COMPRESS_PROGRAM} > "${tars}/${out}.tmp" &&
238 mv "${tars}/${out}.tmp" "${tars}/${out}"
242 if [ ${es} -gt 255 ]; then