makesrctars revision 1.21
1#! /bin/sh 2# 3# $NetBSD: makesrctars,v 1.21 2005/10/07 03:42:47 jmc Exp $ 4# 5# makesrctars srcdir setdir 6# Create source tarballs in setdir from the source under srcdir. 7# 8 9prog=${0##*/} 10 11# set defaults 12: ${CKSUM=cksum} 13: ${PAX=pax} 14 15xsrcdir= 16 17GZIP=-9 18export GZIP 19 20usage() 21{ 22 cat 1>&2 <<USAGE 23Usage: ${prog} [-x xsrcdir] srcdir setdir 24 -x xsrcdir build xsrc.tgz from xsrcdir 25 srcdir location of sources 26 setdir where to write the .tgz files to 27USAGE 28 exit 1 29} 30 31# handle args 32while getopts x: ch; do 33 case ${ch} in 34 x) 35 xsrcdir=${OPTARG} 36 ;; 37 *) 38 usage 39 ;; 40 esac 41done 42shift $((${OPTIND} - 1)) 43 44if [ $# -ne 2 ]; then 45 echo "Usage: $0 srcdir setdir" 46 exit 1 47fi 48srcdir=$1 49setdir=$2 50 51if [ ! -d "${setdir}" ]; then 52 echo "${setdir} is not a directory" 53 exit 1 54fi 55 56makeset() 57{ 58 set=$1.tgz 59 shift 60 echo "Creating ${set}" 61 set -f 62 find $* \ 63 ! \( \( -name obj -o -name 'obj.*' \) \( -type l -o -type d \) -prune \) \ 64 -print \ 65 | sort \ 66 | ${PAX} -w -d -s'|^\.|'${srcprefix}'|' \ 67 | gzip \ 68 > "${setdir}/${set}" 69 set +f 70} 71 72 73# create (base)src sets 74# 75 76if ! cd "${srcdir}"; then 77 echo "Can't chdir to ${srcdir}" 78 exit 1 79fi 80 81srcprefix=usr/src 82 83makeset src . \ 84 ! \( \( -path ./gnu \ 85 -o -path ./share \ 86 -o -path ./sys \ 87 -o -path ./usr.bin/config \ 88 \) -prune \) 89 90makeset gnusrc ./gnu 91 92makeset syssrc ./sys ./usr.bin/config \ 93 ! \( -path ./sys/arch/\*/compile/\* -type d \ 94 ! -name CVS -prune \) 95 96makeset sharesrc ./share 97 98 99# create xsrc sets 100# 101if [ -n "${xsrcdir}" ]; then 102 if ! cd "${xsrcdir}"; then 103 echo "Can't chdir to ${xsrcdir}" 104 exit 1 105 fi 106 srcprefix=usr/xsrc 107 makeset xsrc . 108fi 109 110 111echo "Creating checksum files" 112(cd ${setdir} 113 ${CKSUM} -o1 *.tgz > BSDSUM 114 ${CKSUM} *.tgz > CKSUM 115 ${CKSUM} -a md5 *.tgz > MD5 116 ${CKSUM} -o2 *.tgz > SYSVSUM 117 ${CKSUM} -a sha512 *.tgz > SHA512 118) 119