NetBSD/distrib/sets/makesrctars

133 lines
2.4 KiB
Plaintext
Raw Normal View History

#! /bin/sh
1997-02-18 10:06:00 +03:00
#
# $NetBSD: makesrctars,v 1.32 2006/09/07 22:03:58 tron Exp $
#
# makesrctars srcdir setdir
# Create source tarballs in setdir from the source under srcdir.
1997-02-18 10:06:00 +03:00
#
prog="${0##*/}"
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
# set defaults
xsrcdir=
2002-04-11 10:04:42 +04:00
2002-04-12 11:08:37 +04:00
GZIP=-9
export GZIP
usage()
{
cat 1>&2 <<USAGE
Usage: ${prog} [-N password/group dir] [-x xsrcdir] srcdir setdir
-N dir location which contains master.passwd and group files
(defaults to \${srcdir}/etc)
-x xsrcdir build xsrc.tgz from xsrcdir
srcdir location of sources
setdir where to write the .tgz files to
USAGE
exit 1
}
# handle args
while getopts N:x: ch; do
case ${ch} in
x)
xsrcdir="${OPTARG}"
;;
N)
PASSWD="${OPTARG}"
;;
*)
usage
;;
esac
done
shift $((${OPTIND} - 1))
if [ $# -ne 2 ]; then
usage
fi
srcdir="$1"
setdir="$2"
: ${PASSWD:="${srcdir}/etc"}
if [ ! -d "${setdir}" ]; then
echo "${setdir} is not a directory"
exit 1
fi
makeset()
{(
set="${1}.tgz"
shift
dir="$1"
shift
intmp="/tmp/in$$"
echo "Creating ${set}"
if [ "${dir}" != "." ]; then
cd "${dir}"
srcprefix="${srcprefix}/${dir}"
fi
# Gets rid of any obj dirs and things below it
echo "obj" > "${intmp}"
egrep="$*"
if [ "${egrep}" = "" ]; then
egrep='.'
fi
set -f
${MTREE} -c -X "${intmp}" | ${MTREE} -C -k type | \
${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \
${SED} -e 's:type=file:& mode=0664:' \
-e 's:type=dir:& mode=0775:' \
-e 's:$: uname=root gname=wsrc:' \
-e '/\/move-if-change /s:\(mode\)=[0-9]*:\1=0775:' \
-e '/^\.\/build.sh /s:\(mode\)=[0-9]*:\1=0775:' | \
${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \
${GZIP_CMD} > "${setdir}/${set}"
rm -f "${intmp}"
)}
# create (base)src sets
#
if ! cd "${srcdir}"; then
echo "Can't chdir to ${srcdir}"
exit 1
fi
srcprefix=usr/src
export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix
2005-10-21 06:56:27 +04:00
makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config'
makeset gnusrc gnu
2005-10-21 06:56:27 +04:00
makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config'
makeset sharesrc share
# create xsrc sets
#
if [ -n "${xsrcdir}" ]; then
if ! cd "${xsrcdir}"; then
echo "Can't chdir to ${xsrcdir}"
exit 1
fi
srcprefix=usr/xsrc
makeset xsrc .
fi
echo "Creating checksum files"
(cd "${setdir}"
2002-04-11 10:04:42 +04:00
${CKSUM} -o1 *.tgz > BSDSUM
${CKSUM} *.tgz > CKSUM
2005-10-07 07:42:47 +04:00
${CKSUM} -a md5 *.tgz > MD5
2002-04-11 10:04:42 +04:00
${CKSUM} -o2 *.tgz > SYSVSUM
2005-10-07 07:42:47 +04:00
${CKSUM} -a sha512 *.tgz > SHA512
2002-04-11 10:04:42 +04:00
)
exit 0