Home | History | Annotate | Line # | Download | only in sets
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 
      9 prog=${0##*/}
     10 
     11 # set defaults
     12 : ${CKSUM=cksum}
     13 : ${PAX=pax}
     14 
     15 xsrcdir=
     16 
     17 GZIP=-9
     18 export GZIP
     19 
     20 usage()
     21 {
     22 	cat 1>&2 <<USAGE
     23 Usage: ${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
     27 USAGE
     28 	exit 1
     29 }
     30 
     31 # handle args
     32 while getopts x: ch; do
     33 	case ${ch} in
     34 	x)	
     35 		xsrcdir=${OPTARG}
     36 		;;
     37 	*)
     38 		usage
     39 		;;
     40 	esac
     41 done
     42 shift $((${OPTIND} - 1))
     43 
     44 if [ $# -ne 2 ]; then
     45 	echo "Usage: $0 srcdir setdir"
     46 	exit 1
     47 fi
     48 srcdir=$1
     49 setdir=$2
     50 
     51 if [ ! -d "${setdir}" ]; then
     52 	echo "${setdir} is not a directory"
     53 	exit 1
     54 fi
     55 
     56 makeset()
     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 
     76 if ! cd "${srcdir}"; then
     77 	echo "Can't chdir to ${srcdir}"
     78 	exit 1
     79 fi
     80 
     81 srcprefix=usr/src
     82 
     83 makeset src .						\
     84 		! \( \(	-path ./gnu			\
     85 		     -o -path ./share			\
     86 		     -o -path ./sys			\
     87 		     -o -path ./usr.bin/config		\
     88 		    \) -prune \)
     89 
     90 makeset gnusrc ./gnu
     91 
     92 makeset syssrc ./sys ./usr.bin/config					\
     93 		! \( -path ./sys/arch/\*/compile/\* -type d		\
     94 		    ! -name CVS -prune \)
     95 
     96 makeset sharesrc ./share
     97 
     98 
     99 # create xsrc sets
    100 #
    101 if [ -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 .
    108 fi
    109 
    110 
    111 echo "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