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