NetBSD/distrib/sets/makesrctars

119 lines
1.8 KiB
Plaintext
Raw Normal View History

#! /bin/sh
1997-02-18 10:06:00 +03:00
#
# $NetBSD: makesrctars,v 1.19 2005/05/22 03:05:15 lukem Exp $
#
# makesrctars srcdir setdir
# Create source tarballs in setdir from the source under srcdir.
1997-02-18 10:06:00 +03:00
#
prog=${0##*/}
# set defaults
2002-04-11 10:04:42 +04:00
: ${CKSUM=cksum}
: ${PAX=pax}
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} [-x xsrcdir] srcdir setdir
-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 x: ch; do
case ${ch} in
x)
xsrcdir=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((${OPTIND} - 1))
if [ $# -ne 2 ]; then
echo "Usage: $0 srcdir setdir"
exit 1
fi
srcdir=$1
setdir=$2
if [ ! -d "${setdir}" ]; then
echo "${setdir} is not a directory"
exit 1
fi
makeset()
{
set=$1.tgz
shift
echo "Creating ${set}"
set -f
find $* \
! \( \( -name obj -o -name 'obj.*' \) \( -type l -o -type d \) -prune \) \
-print \
| sort \
| ${PAX} -w -d -s'|^\.|'${srcprefix}'|' \
| gzip \
> "${setdir}/${set}"
set +f
}
# create (base)src sets
#
if ! cd "${srcdir}"; then
echo "Can't chdir to ${srcdir}"
exit 1
fi
srcprefix=usr/src
makeset src . \
! \( \( -path ./gnu \
-o -path ./share \
-o -path ./sys \
-o -path ./contrib/sys \
-o -path ./usr.sbin/config \
\) -prune \)
makeset gnusrc ./gnu
makeset syssrc ./sys ./contrib/sys ./usr.sbin/config \
! \( -path ./sys/arch/\*/compile/\* -type d \
! -name CVS -prune \)
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
${CKSUM} -m *.tgz > MD5
${CKSUM} -o2 *.tgz > SYSVSUM
)