NetBSD/distrib/sets/makesrctars
lukem aa5498d450 makesrctars:
* Support '-x xsrcdir' to tar up xsrcdir as xsrc.tgz, with the
  contents of the tarfile being relative to xsrcdir and
  prefixed with 'usr/xsrc'
* Convert to getopts a la the other scripts in this directory

Makefile
* if ${MKX11} != no, call makesrctars with '-x ${X11SRCDIR}'
2004-04-20 06:36:34 +00:00

118 lines
1.8 KiB
Bash
Executable File

#! /bin/sh
#
# $NetBSD: makesrctars,v 1.17 2004/04/20 06:36:35 lukem Exp $
#
# makesrctars srcdir setdir
# Create source tarballs in setdir from the source under srcdir.
#
prog=${0##*/}
# set defaults
: ${CKSUM=cksum}
: ${PAX=pax}
xsrcdir=
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 -s $* \
! \( \( -name obj -o -name 'obj.*' \) \( -type l -o -type d \) \) \
-print \
| ${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}
${CKSUM} -o1 *.tgz > BSDSUM
${CKSUM} *.tgz > CKSUM
${CKSUM} -m *.tgz > MD5
${CKSUM} -o2 *.tgz > SYSVSUM
)