1 #! /bin/sh 2 # 3 # $NetBSD: makesrctars,v 1.28 2006/01/03 15:42:42 apb Exp $ 4 # 5 # makesrctars srcdir setdir 6 # Create source tarballs in setdir from the source under srcdir. 7 # 8 9 prog=${0##*/} 10 rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 11 . "${rundir}/sets.subr" 12 13 # set defaults 14 xsrcdir= 15 16 GZIP=-9 17 export GZIP 18 19 usage() 20 { 21 cat 1>&2 <<USAGE 22 Usage: ${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 28 USAGE 29 exit 1 30 } 31 32 # handle args 33 while 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 45 done 46 shift $((${OPTIND} - 1)) 47 48 if [ $# -ne 2 ]; then 49 usage 50 fi 51 srcdir=$1 52 setdir=$2 53 : ${PASSWD:=${srcdir}/etc} 54 55 if [ ! -d "${setdir}" ]; then 56 echo "${setdir} is not a directory" 57 exit 1 58 fi 59 60 makeset() 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 > "${setdir}/${set}" 85 rm -f /tmp/in$$ 86 )} 87 88 89 # create (base)src sets 90 # 91 92 if ! cd "${srcdir}"; then 93 echo "Can't chdir to ${srcdir}" 94 exit 1 95 fi 96 97 srcprefix=usr/src 98 export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix 99 100 makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config' 101 102 makeset gnusrc gnu 103 104 makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config' 105 106 makeset sharesrc share 107 108 109 # create xsrc sets 110 # 111 if [ -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 . 118 fi 119 120 121 echo "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 ) 129 exit 0 130