118 lines
1.8 KiB
Bash
Executable File
118 lines
1.8 KiB
Bash
Executable File
#! /bin/sh
|
|
#
|
|
# $NetBSD: makesrctars,v 1.20 2005/07/05 08:41:16 tron 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 $* \
|
|
! \( \( -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 ./usr.bin/config \
|
|
\) -prune \)
|
|
|
|
makeset gnusrc ./gnu
|
|
|
|
makeset syssrc ./sys ./usr.bin/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
|
|
)
|