makesrctars revision 1.31
1#! /bin/sh 2# 3# $NetBSD: makesrctars,v 1.31 2006/03/08 19:18:04 hubertf Exp $ 4# 5# makesrctars srcdir setdir 6# Create source tarballs in setdir from the source under srcdir. 7# 8 9prog="${0##*/}" 10rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 11. "${rundir}/sets.subr" 12 13# set defaults 14xsrcdir= 15 16GZIP=-9 17export GZIP 18 19usage() 20{ 21 cat 1>&2 <<USAGE 22Usage: ${prog} [-N password/group dir] [-x xsrcdir] srcdir setdir 23 -N dir location which contains master.passwd and group files 24 (defaults to \${srcdir}/etc) 25 -x xsrcdir build xsrc.tgz from xsrcdir 26 srcdir location of sources 27 setdir where to write the .tgz files to 28USAGE 29 exit 1 30} 31 32# handle args 33while getopts N:x: ch; do 34 case ${ch} in 35 x) 36 xsrcdir="${OPTARG}" 37 ;; 38 N) 39 PASSWD="${OPTARG}" 40 ;; 41 *) 42 usage 43 ;; 44 esac 45done 46shift $((${OPTIND} - 1)) 47 48if [ $# -ne 2 ]; then 49 usage 50fi 51srcdir="$1" 52setdir="$2" 53: ${PASSWD:="${srcdir}/etc"} 54 55if [ ! -d "${setdir}" ]; then 56 echo "${setdir} is not a directory" 57 exit 1 58fi 59 60makeset() 61{( 62 set="${1}.tgz" 63 shift 64 dir="$1" 65 shift 66 intmp="/tmp/in$$" 67 echo "Creating ${set}" 68 if [ "${dir}" != "." ]; then 69 cd "${dir}" 70 srcprefix="${srcprefix}/${dir}" 71 fi 72 # Gets rid of any obj dirs and things below it 73 echo "obj" > "${intmp}" 74 egrep="$*" 75 if [ "${egrep}" = "" ]; then 76 egrep='.' 77 fi 78 set -f 79 ${MTREE} -c -X "${intmp}" | ${MTREE} -C -k type | \ 80 ${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \ 81 ${SED} -e 's:type=file:& mode=0664:' \ 82 -e 's:type=dir:& mode=0775:' \ 83 -e 's:$: uname=root gname=wsrc:' \ 84 -e '/^\.\/build.sh /s:\(mode\)=[0-9]*:\1=0775:' | \ 85 ${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \ 86 ${GZIP_CMD} > "${setdir}/${set}" 87 rm -f "${intmp}" 88)} 89 90 91# create (base)src sets 92# 93 94if ! cd "${srcdir}"; then 95 echo "Can't chdir to ${srcdir}" 96 exit 1 97fi 98 99srcprefix=usr/src 100export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix 101 102makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config' 103 104makeset gnusrc gnu 105 106makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config' 107 108makeset sharesrc share 109 110 111# create xsrc sets 112# 113if [ -n "${xsrcdir}" ]; then 114 if ! cd "${xsrcdir}"; then 115 echo "Can't chdir to ${xsrcdir}" 116 exit 1 117 fi 118 srcprefix=usr/xsrc 119 makeset xsrc . 120fi 121 122 123echo "Creating checksum files" 124(cd "${setdir}" 125 ${CKSUM} -o1 *.tgz > BSDSUM 126 ${CKSUM} *.tgz > CKSUM 127 ${CKSUM} -a md5 *.tgz > MD5 128 ${CKSUM} -o2 *.tgz > SYSVSUM 129 ${CKSUM} -a sha512 *.tgz > SHA512 130) 131exit 0 132