tools/llvm: Do not build with symbols
[minix3.git] / distrib / sets / maketars
blobbd8532e0d7012f436285da471c51b63a1104a8cd
1 #!/bin/sh
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.
18 prog="${0##*/}"
19 rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
20 . "${rundir}/sets.subr"
22 # set defaults
23 lists=
24 tars="${RELEASEDIR}"
25 dest="${DESTDIR}"
26 metalog=
27 installdir=
28 etcdir=
29 setfilesonly=false
30 quiet=false
31 skipkeys=time,md5,sha1,sha384,sha512,rmd160,cksum
33 usage()
35 cat 1>&2 <<USAGE
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}]
47 -q Quiet operation
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}]
55 USAGE
56 exit 1
59 msg()
61 $quiet || echo $*
64 # handle args
65 while getopts L:bxyi:a:m:qs:SM:N:d:t: ch; do
66 case ${ch} in
68 save_IFS="${IFS}"
69 IFS=,
70 for _list in ${OPTARG}; do
71 case $_list in
72 base) lists="${lists} ${nlists}" ;;
73 x) lists="${lists} ${xlists}" ;;
74 ext) lists="${lists} ${extlists}" ;;
75 esac
76 done
77 IFS="${save_IFS}"
79 # backward compat
81 lists="${nlists} ${xlists}"
84 lists="${xlists}"
87 lists="${extlists}"
90 installdir="${OPTARG}"
93 MACHINE_ARCH="${OPTARG}"
94 MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
97 MACHINE="${OPTARG}"
100 quiet=true
103 setsdir="${OPTARG}"
106 setfilesonly=true
109 metalog="${OPTARG}"
112 etcdir="${OPTARG}"
115 dest="${OPTARG}"
118 tars="${OPTARG}"
121 usage
123 esac
124 done
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 / /')"
129 if [ -n "$*" ]; then
130 lists="$*"
133 if [ -z "${tars}" -a -z "${installdir}" ]; then
134 echo >&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used"
135 exit 1
138 if [ -z "${dest}" ]; then
139 echo >&2 "${prog}: \${DESTDIR} must be set"
140 exit 1
142 : ${etcdir:="${dest}/etc"}
144 SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")"
145 TMPFILES=
147 setlistdir="${dest}/etc/mtree"
149 cleanup()
151 es=$?
152 /bin/rm -rf "${SDIR}" ${TMPFILES}
153 trap - 0
154 exit ${es}
156 trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
159 # build the setfiles
162 for setname in ${lists}; do
163 ${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
164 -s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \
165 || exit 1
166 if [ ! -s "${SDIR}/flist.${setname}" ]; then
167 echo >&2 "makeflist output is empty for ${setname}"
168 exit 1
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" \
174 || exit 1
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}" \
182 || exit 1
183 # We deliberately do not add set.${setname} to ${metalog},
184 # because we depend on it as an input.
185 else
186 ${MTREE} -c -p "${dest}" -k all -R "${skipkeys}" \
187 -O "${SDIR}/flist.${setname}" | ${MTREE} -C -k all > \
188 "${setlistdir}/set.${setname}"
190 done
191 if ${setfilesonly}; then # exit after creating the set lists
192 exit 0
195 runpax() {
196 local s="$1"
197 shift
198 (cd "${dest}" &&
199 ${PAX} -dOw -N"${etcdir}" -M "$@" < "${setlistdir}/set.${s}")
203 # now build the tarfiles
206 GZIP=-9n # for pax -z
207 export GZIP
208 es=0
209 for setname in ${lists:-${nlists}}; do
210 out="${setname}.tgz"
211 if [ -n "${installdir}" ]; then
212 msg "Copying set ${setname}"
213 runpax "${setname}" -rpe "${installdir}"
214 else
215 if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
216 then
217 msg "${out} is up to date"
218 continue
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}"
227 es=$((${es} + $?))
228 done
229 if [ ${es} -gt 255 ]; then
230 es=255
232 exit ${es}