#!/bin/sh # # $NetBSD: maketars,v 1.89.2.1 2019/11/17 07:04:33 martin Exp $ # # Make release tar files for some or all lists. Usage: # maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir] # [-M metalog] [-N etcdir] [-F setlistsdir] [-d destdir] # [-t tardir] [-U] [setname ...] # # The default sets are "base comp debug etc games man misc rescue tests text" # The X sets are "xbase xcomp xdebug xetc xfont xserver" # The extsrc sets are "extbase extcomp extetc" # # If '-i installdir' is given, copy the given sets to installdir # (using pax -rw ...) instead of creating tar files. # In this case, remove "etc", "xetc", and "extetc" from the list of default sets. # prog="${0##*/}" rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" . "${rundir}/sets.subr" # set defaults lists= tars="${RELEASEDIR}" dest="${DESTDIR}" metalog= installdir= etcdir= setlistdir= timestamp= setfilesonly=false quiet=false skipkeys=time,md5,sha1,sha384,sha512,rmd160,cksum preserve="-pe" usage() { cat 1>&2 <&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used" exit 1 fi if [ -z "${dest}" ]; then echo >&2 "${prog}: \${DESTDIR} must be set" exit 1 fi : ${etcdir:="${dest}/etc"} SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")" TMPFILES= : ${setlistdir:="${dest}/etc/mtree"} cleanup() { es=$? /bin/rm -rf "${SDIR}" ${TMPFILES} trap - 0 exit ${es} } trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE # # build the setfiles # for setname in ${lists}; do ${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \ -s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \ || exit 1 if [ ! -s "${SDIR}/flist.${setname}" ]; then echo >&2 "makeflist output is empty for ${setname}" exit 1 fi ${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}" if [ -n "${metalog}" ]; then ${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \ > "${SDIR}/flist.${setname}.full" \ || exit 1 ( echo "/set uname=root gname=wheel" ${AWK} -f "${rundir}/join.awk" \ "${SDIR}/flist.${setname}.full" "${metalog}" echo "./etc/mtree/set.${setname} type=file mode=0444" ) | ${MTREE} -CS -k all -R "${skipkeys}" -N "${etcdir}" \ > "${setlistdir}/set.${setname}" \ || exit 1 # We deliberately do not add set.${setname} to ${metalog}, # because we depend on it as an input. else ${MTREE} -c -p "${dest}" -k all -R "${skipkeys}" \ -N "${etcdir}" -O "${SDIR}/flist.${setname}" \ | ${MTREE} -C -k all -N "${etcdir}" \ > "${setlistdir}/set.${setname}" fi done if ${setfilesonly}; then # exit after creating the set lists exit 0 fi runpax() { local s="$1" shift (cd "${dest}" && ${PAX} -dOw ${timestamp} -N"${etcdir}" -M "$@" < "${setlistdir}/set.${s}") } # # now build the tarfiles # GZIP=-9n # for pax -z export GZIP es=0 for setname in ${lists:-${nlists}}; do out="${setname}.${TAR_SUFF:-tgz}" if [ -n "${installdir}" ]; then msg "Copying set ${setname}" runpax "${setname}" -r ${preserve} "${installdir}" else if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ] then msg "${out} is up to date" continue fi msg "Creating ${out}" rm -f "${tars}/${out}" TMPFILES="${TMPFILES} ${tars}/${out}.tmp" runpax "${setname}" -z --use-compress-program \ ${COMPRESS_PROGRAM} > "${tars}/${out}.tmp" && mv "${tars}/${out}.tmp" "${tars}/${out}" fi es=$((${es} + $?)) done if [ ${es} -gt 255 ]; then es=255 fi exit ${es}