1996-05-20 23:10:28 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2009-04-11 19:09:32 +04:00
|
|
|
# $NetBSD: maketars,v 1.68 2009/04/11 15:09:32 apb Exp $
|
1996-05-20 23:10:28 +04:00
|
|
|
#
|
|
|
|
# Make release tar files for some or all lists. Usage:
|
2002-12-26 02:44:06 +03:00
|
|
|
# maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
|
|
|
|
# [-M metalog] [-N etcdir] [-d destdir] [-t tardir] [setname ...]
|
1996-05-20 23:10:28 +04:00
|
|
|
#
|
2007-11-12 18:06:45 +03:00
|
|
|
# The default sets are "base comp etc games man misc tests text"
|
2004-01-30 11:39:50 +03:00
|
|
|
# The X sets are "xbase xcomp xetc xfont xserver"
|
2002-12-26 02:47:32 +03:00
|
|
|
#
|
|
|
|
# If '-i installdir' is given, copy the given sets to installdir
|
|
|
|
# (using pax -rw ...) instead of creating tar files.
|
2004-01-29 11:32:51 +03:00
|
|
|
# In this case, remove "etc" and "xetc" from the list of default sets.
|
2002-12-26 02:47:32 +03:00
|
|
|
#
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
prog="${0##*/}"
|
2006-01-03 18:42:42 +03:00
|
|
|
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
|
|
|
|
. "${rundir}/sets.subr"
|
2003-07-03 10:43:02 +04:00
|
|
|
|
1996-05-20 23:10:28 +04:00
|
|
|
# set defaults
|
2006-01-03 21:31:09 +03:00
|
|
|
lists="${nlists}"
|
|
|
|
tars="${RELEASEDIR}"
|
|
|
|
dest="${DESTDIR}"
|
2002-02-27 13:51:47 +03:00
|
|
|
metalog=
|
2002-12-12 11:51:49 +03:00
|
|
|
installdir=
|
2002-12-19 09:21:45 +03:00
|
|
|
etcdir=
|
2004-01-30 11:39:50 +03:00
|
|
|
setfilesonly=false
|
2008-03-16 10:02:22 +03:00
|
|
|
quiet=false
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat 1>&2 <<USAGE
|
2004-01-30 11:39:50 +03:00
|
|
|
Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
|
2003-01-03 18:26:32 +03:00
|
|
|
[-M metalog] [-N etcdir] [-d dest] [-t targetdir] [setname ...]
|
2004-01-30 11:39:50 +03:00
|
|
|
-b Make both netbsd and x11 lists
|
|
|
|
-x Only make x11 lists
|
|
|
|
[Default: make netbsd lists]
|
|
|
|
-i idir Install sets to idir instead of creating tar files
|
2006-01-03 21:31:09 +03:00
|
|
|
-a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
|
|
|
|
-m machine Set machine (e.g, amiga, i386, macppc) [${MACHINE}]
|
2008-03-16 10:02:22 +03:00
|
|
|
-q Quiet operation
|
2006-01-03 21:31:09 +03:00
|
|
|
-s setsdir Directory to find sets [${setsdir}]
|
|
|
|
-S Exit after creating set files ${dest}/etc/mtree/set.*
|
2002-02-27 13:51:47 +03:00
|
|
|
-M metalog metalog file
|
2006-01-03 21:31:09 +03:00
|
|
|
-N etcdir etc dir for metalog use [${dest}/etc]
|
|
|
|
-d dest \${DESTDIR} [${dest}]
|
|
|
|
-t targetdir \${RELEASEDIR} [${tars}]
|
|
|
|
[setname ...] Sets to build [${lists}]
|
1998-06-15 18:45:05 +04:00
|
|
|
USAGE
|
2003-12-29 06:13:25 +03:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2008-03-16 10:02:22 +03:00
|
|
|
msg()
|
|
|
|
{
|
|
|
|
$quiet || echo $*
|
|
|
|
}
|
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
# handle args
|
2008-03-16 10:02:22 +03:00
|
|
|
while getopts bxi:a:m:qs:SM:N:d:t: ch; do
|
2003-12-29 06:13:25 +03:00
|
|
|
case ${ch} in
|
|
|
|
b)
|
2006-01-03 21:31:09 +03:00
|
|
|
lists="${nlists} ${xlists}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
x)
|
2006-01-03 21:31:09 +03:00
|
|
|
lists="${xlists}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
i)
|
2006-01-03 21:31:09 +03:00
|
|
|
installdir="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
a)
|
2006-01-03 21:31:09 +03:00
|
|
|
MACHINE_ARCH="${OPTARG}"
|
|
|
|
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
m)
|
2006-01-03 21:31:09 +03:00
|
|
|
MACHINE="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
2008-03-16 10:02:22 +03:00
|
|
|
q)
|
|
|
|
quiet=true
|
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
s)
|
2006-01-03 21:31:09 +03:00
|
|
|
setsdir="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
2004-01-30 11:39:50 +03:00
|
|
|
S)
|
|
|
|
setfilesonly=true
|
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
M)
|
2006-01-03 21:31:09 +03:00
|
|
|
metalog="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
N)
|
2006-01-03 21:31:09 +03:00
|
|
|
etcdir="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
d)
|
2006-01-03 21:31:09 +03:00
|
|
|
dest="${OPTARG}"
|
2003-12-29 06:13:25 +03:00
|
|
|
;;
|
|
|
|
t)
|
2006-01-03 21:31:09 +03:00
|
|
|
tars="${OPTARG}"
|
1998-06-15 18:45:05 +04:00
|
|
|
;;
|
|
|
|
*)
|
2003-12-29 06:13:25 +03:00
|
|
|
usage
|
1998-06-15 18:45:05 +04:00
|
|
|
;;
|
1996-05-20 23:10:28 +04:00
|
|
|
esac
|
|
|
|
done
|
2003-12-29 06:13:25 +03:00
|
|
|
shift $((${OPTIND} - 1))
|
2006-01-03 21:31:09 +03:00
|
|
|
if [ -n "${installdir}" ]; then # if -i, remove etc & xetc from the default list
|
|
|
|
lists="$(echo ${lists} | ${SED} -e 's/ etc / /;s/ xetc / /')"
|
2002-12-12 11:51:49 +03:00
|
|
|
fi
|
1998-06-27 12:27:36 +04:00
|
|
|
if [ -n "$*" ]; then
|
|
|
|
lists="$*"
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
if [ -z "${tars}" -a -z "${installdir}" ]; then
|
2006-01-08 13:10:03 +03:00
|
|
|
echo >&2 "${prog}: \${RELEASEDIR} must be set, or -i must be used"
|
1994-08-29 19:21:02 +04:00
|
|
|
exit 1
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
1994-08-29 19:21:02 +04:00
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
if [ -z "${dest}" ]; then
|
2006-01-08 13:10:03 +03:00
|
|
|
echo >&2 "${prog}: \${DESTDIR} must be set"
|
1994-08-29 19:21:02 +04:00
|
|
|
exit 1
|
1998-06-15 18:45:05 +04:00
|
|
|
fi
|
2006-01-03 21:31:09 +03:00
|
|
|
: ${etcdir:="${dest}/etc"}
|
1996-05-20 23:10:28 +04:00
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")"
|
2008-03-16 07:39:19 +03:00
|
|
|
TMPFILES=
|
2002-04-01 19:50:30 +04:00
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
setlistdir="${dest}/etc/mtree"
|
2004-01-30 11:39:50 +03:00
|
|
|
|
2003-01-21 22:07:05 +03:00
|
|
|
cleanup()
|
|
|
|
{
|
2003-10-16 18:20:20 +04:00
|
|
|
es=$?
|
2008-03-16 07:39:19 +03:00
|
|
|
/bin/rm -rf "${SDIR}" ${TMPFILES}
|
|
|
|
trap - 0
|
2006-01-03 21:31:09 +03:00
|
|
|
exit ${es}
|
2003-01-21 22:07:05 +03:00
|
|
|
}
|
|
|
|
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2004-01-30 11:39:50 +03:00
|
|
|
#
|
|
|
|
# build the setfiles
|
|
|
|
#
|
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
for setname in ${lists}; do
|
|
|
|
${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
|
|
|
|
-s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}"
|
|
|
|
if [ -n "${metalog}" ]; then
|
2008-03-16 10:02:22 +03:00
|
|
|
${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}"
|
2006-01-03 21:31:09 +03:00
|
|
|
${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
|
2009-04-11 19:09:32 +04:00
|
|
|
> "${SDIR}/flist.${setname}.full"
|
2002-04-13 16:47:10 +04:00
|
|
|
(
|
|
|
|
echo "/set uname=root gname=wheel"
|
2006-01-03 21:31:09 +03:00
|
|
|
${AWK} -f "${rundir}/join.awk" \
|
2009-04-11 19:09:32 +04:00
|
|
|
"${SDIR}/flist.${setname}.full" "${metalog}"
|
2004-01-30 11:39:50 +03:00
|
|
|
echo "./etc/mtree/set.${setname} type=file mode=0444"
|
2009-04-11 19:09:32 +04:00
|
|
|
) | ${MTREE} -CS -k all -R time -N "${etcdir}" \
|
2009-04-02 22:06:54 +04:00
|
|
|
> "${setlistdir}/set.${setname}"
|
2006-01-04 18:03:39 +03:00
|
|
|
# We deliberately do not add set.${setname} to ${metalog},
|
|
|
|
# because we depend on it as an input.
|
2006-01-03 21:31:09 +03:00
|
|
|
elif ! cmp -s "${SDIR}/flist.${setname}" \
|
|
|
|
"${setlistdir}/set.${setname}" >/dev/null 2>&1; then
|
|
|
|
rm -f "${setlistdir}/set.${setname}"
|
|
|
|
cp "${SDIR}/flist.${setname}" "${setlistdir}/set.${setname}"
|
2002-02-27 13:51:47 +03:00
|
|
|
fi
|
2004-01-30 11:39:50 +03:00
|
|
|
done
|
2006-01-03 21:31:09 +03:00
|
|
|
if ${setfilesonly}; then # exit after creating the set lists
|
2004-01-30 11:39:50 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
2002-02-27 13:51:47 +03:00
|
|
|
|
2004-01-30 11:39:50 +03:00
|
|
|
#
|
|
|
|
# now build the tarfiles
|
|
|
|
#
|
|
|
|
|
2009-04-04 02:36:34 +04:00
|
|
|
GZIP=-9n # for pax -z
|
2004-01-30 11:39:50 +03:00
|
|
|
export GZIP
|
|
|
|
es=0
|
2006-01-03 21:31:09 +03:00
|
|
|
for setname in ${lists}; do
|
|
|
|
out="${setname}.tgz"
|
|
|
|
if [ -n "${installdir}" ]; then
|
2008-03-16 10:02:22 +03:00
|
|
|
msg "Copying set ${setname}"
|
2006-01-28 22:01:23 +03:00
|
|
|
( cd "${dest}"; \
|
2006-01-03 21:31:09 +03:00
|
|
|
${PAX} -O -rwpe -d -N"${etcdir}" ${metalog:+-M} \
|
|
|
|
"${installdir}" < "${setlistdir}/set.${setname}" )
|
2002-12-12 11:51:49 +03:00
|
|
|
else
|
2006-01-03 21:31:09 +03:00
|
|
|
if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
|
|
|
|
then
|
2008-03-16 10:02:22 +03:00
|
|
|
msg "${out} is up to date"
|
2004-01-30 11:39:50 +03:00
|
|
|
continue
|
|
|
|
fi
|
2008-03-16 10:02:22 +03:00
|
|
|
msg "Creating ${out}"
|
2006-01-03 21:31:09 +03:00
|
|
|
rm -f "${tars}/${out}"
|
2008-03-16 07:39:19 +03:00
|
|
|
TMPFILES="${TMPFILES} ${tars}/${out}.tmp"
|
2006-01-28 22:01:23 +03:00
|
|
|
( cd "${dest}"; \
|
2006-01-03 21:31:09 +03:00
|
|
|
${PAX} -O -w -d -z -N"${etcdir}" ${metalog:+-M} \
|
|
|
|
< "${setlistdir}/set.${setname}" ) \
|
|
|
|
> "${tars}/${out}.tmp" &&
|
|
|
|
mv "${tars}/${out}.tmp" "${tars}/${out}"
|
2002-12-12 11:51:49 +03:00
|
|
|
fi
|
2006-01-03 21:31:09 +03:00
|
|
|
es=$((${es} + $?))
|
1996-05-20 23:10:28 +04:00
|
|
|
done
|
2006-01-28 22:01:23 +03:00
|
|
|
if [ ${es} -gt 255 ]; then
|
2003-01-21 22:07:05 +03:00
|
|
|
es=255
|
|
|
|
fi
|
2006-01-03 21:31:09 +03:00
|
|
|
exit ${es}
|