release.sh: restore -jJAILDIR option
[minix.git] / distrib / sets / makesrctars
blobbacbe2af15d160adad42c748b8aa3ec4f0fc1d1f
1 #! /bin/sh
3 # $NetBSD: makesrctars,v 1.38 2009/11/30 16:13:23 uebayasi Exp $
5 # makesrctars srcdir setdir
6 # Create source tarballs in setdir from the source under srcdir.
9 prog="${0##*/}"
10 rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
11 . "${rundir}/sets.subr"
13 # set defaults
14 xsrcdir=
15 quiet=false
17 GZIP=-9n
18 export GZIP
20 usage()
22 cat 1>&2 <<USAGE
23 Usage: ${prog} [-N password/group dir] [-q] [-x xsrcdir] [-y extsrcsrcdir] srcdir setdir
24 -N dir location which contains master.passwd and group files
25 (defaults to \${srcdir}/etc)
26 -q quiet operation
27 -x xsrcdir build xsrc.tgz from xsrcdir
28 -y extsrcsrcdir build extsrc.tgz from extsrcsrcdir
29 srcdir location of sources
30 setdir where to write the .tgz files to
31 USAGE
32 exit 1
35 msg()
37 $quiet || echo $*
41 # handle args
42 while getopts N:qx:y: ch; do
43 case ${ch} in
45 quiet=true
48 xsrcdir="${OPTARG}"
51 extsrcsrcdir="${OPTARG}"
54 PASSWD="${OPTARG}"
57 usage
59 esac
60 done
61 shift $((${OPTIND} - 1))
63 if [ $# -ne 2 ]; then
64 usage
66 srcdir="$1"
67 setdir="$2"
68 : ${PASSWD:="${srcdir}/etc"}
70 if [ ! -d "${setdir}" ]; then
71 echo >&2 "${prog}: ${setdir} is not a directory"
72 exit 1
75 makeset()
77 set="${1}.tgz"
78 shift
79 dir="$1"
80 shift
81 intmp="/tmp/in$$"
82 msg "Creating ${set}"
83 if [ "${dir}" != "." ]; then
84 cd "${dir}"
85 srcprefix="${srcprefix}/${dir}"
87 # Gets rid of any obj dirs and things below it
88 echo "obj" > "${intmp}"
89 egrep="$*"
90 if [ "${egrep}" = "" ]; then
91 egrep='.'
93 set -f
94 ${MTREE} -c -X "${intmp}" | ${MTREE} -CS -k type | \
95 ${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \
96 ${SED} -e 's:type=file:& mode=0664:' \
97 -e 's:type=dir:& mode=0775:' \
98 -e 's:$: uname=root gname=wsrc:' \
99 -e '/\/move-if-change /s:\(mode\)=[0-9]*:\1=0775:' \
100 -e '/^\.\/build.sh /s:\(mode\)=[0-9]*:\1=0775:' | \
101 ${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \
102 ${GZIP_CMD} > "${setdir}/${set}"
103 rm -f "${intmp}"
107 # create (base)src sets
110 if ! cd "${srcdir}"; then
111 echo >&2 "${prog}: can't chdir to ${srcdir}"
112 exit 1
115 srcprefix=usr/src
116 export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix
118 makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config|^\.\/common'
120 makeset gnusrc gnu
122 makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config|^\.\/common'
124 makeset sharesrc share
127 # create xsrc sets
129 if [ -n "${xsrcdir}" ]; then
130 if ! cd "${xsrcdir}"; then
131 echo >&2 "${prog}: can't chdir to ${xsrcdir}"
132 exit 1
134 srcprefix=usr/xsrc
135 makeset xsrc .
139 # create extsrc sets
141 if [ -n "${extsrcsrcdir}" ]; then
142 if ! cd "${extsrcsrcdir}"; then
143 echo >&2 "${prog}: can't chdir to ${extsrcsrcdir}"
144 exit 1
146 srcprefix=usr/extsrc
147 makeset extsrc .
151 msg "Creating checksum files"
152 (cd "${setdir}"
153 ${CKSUM} -a md5 *.tgz > MD5
154 ${CKSUM} -a sha512 *.tgz > SHA512
156 exit 0