1996-05-20 23:10:28 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
# $NetBSD: maketars,v 1.61 2006/01/28 19:01:23 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
|
|
|
#
|
2002-12-26 02:47:32 +03:00
|
|
|
# The default sets are "base comp etc games man misc 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
|
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}]
|
|
|
|
-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
|
|
|
|
}
|
|
|
|
|
|
|
|
# handle args
|
2004-01-30 11:39:50 +03:00
|
|
|
while getopts bxi:a:m:s: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
|
|
|
;;
|
|
|
|
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")"
|
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=$?
|
2006-01-03 21:31:09 +03:00
|
|
|
/bin/rm -rf "${SDIR}"
|
|
|
|
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
|
|
|
|
${setfilesonly} && echo "Creating ${setlistdir}/set.${setname}"
|
|
|
|
${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
|
|
|
|
| ${SORT} -u > "${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" \
|
2006-01-04 18:03:39 +03:00
|
|
|
"${SDIR}/flist.${setname}.full" "${metalog}"
|
2004-01-30 11:39:50 +03:00
|
|
|
echo "./etc/mtree/set.${setname} type=file mode=0444"
|
2006-01-03 21:31:09 +03: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
|
|
|
|
#
|
|
|
|
|
|
|
|
GZIP=-9 # for pax -z
|
|
|
|
export GZIP
|
|
|
|
es=0
|
2006-01-03 21:31:09 +03:00
|
|
|
for setname in ${lists}; do
|
|
|
|
out="${setname}.tgz"
|
|
|
|
if [ -n "${installdir}" ]; then
|
|
|
|
echo "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
|
|
|
|
echo "${out} is up to date"
|
2004-01-30 11:39:50 +03:00
|
|
|
continue
|
|
|
|
fi
|
2006-01-03 21:31:09 +03:00
|
|
|
echo "Creating ${out}"
|
|
|
|
rm -f "${tars}/${out}"
|
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}
|