makesrctars revision 1.29
1#! /bin/sh 2# 3# $NetBSD: makesrctars,v 1.29 2006/01/03 16:40:16 apb 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 echo "Creating ${set}" 67 if [ "${dir}" != "." ]; then 68 cd $dir 69 srcprefix="${srcprefix}/${dir}" 70 fi 71 # Gets rid of any obj dirs and things below it 72 echo "obj" > /tmp/in$$ 73 egrep=$* 74 if [ "$egrep" = "" ]; then 75 egrep='.' 76 fi 77 set -f 78 ${MTREE} -c -X /tmp/in$$ | ${MTREE} -C -k type | \ 79 ${EGREP} -v 'type=link' | ${EGREP} $egrep | \ 80 ${SED} -e 's:type=file:& mode=0664:' \ 81 -e 's:type=dir:& mode=0775:' \ 82 -e 's:$: uname=root gname=wsrc:' | \ 83 ${PAX} -M -N ${PASSWD} -w -d -s'|^\.|'${srcprefix}'|' | \ 84 ${GZIP_CMD} > "${setdir}/${set}" 85 rm -f /tmp/in$$ 86)} 87 88 89# create (base)src sets 90# 91 92if ! cd "${srcdir}"; then 93 echo "Can't chdir to ${srcdir}" 94 exit 1 95fi 96 97srcprefix=usr/src 98export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix 99 100makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config' 101 102makeset gnusrc gnu 103 104makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config' 105 106makeset sharesrc share 107 108 109# create xsrc sets 110# 111if [ -n "${xsrcdir}" ]; then 112 if ! cd "${xsrcdir}"; then 113 echo "Can't chdir to ${xsrcdir}" 114 exit 1 115 fi 116 srcprefix=usr/xsrc 117 makeset xsrc . 118fi 119 120 121echo "Creating checksum files" 122(cd ${setdir} 123 ${CKSUM} -o1 *.tgz > BSDSUM 124 ${CKSUM} *.tgz > CKSUM 125 ${CKSUM} -a md5 *.tgz > MD5 126 ${CKSUM} -o2 *.tgz > SYSVSUM 127 ${CKSUM} -a sha512 *.tgz > SHA512 128) 129exit 0 130