#! /bin/sh # # $NetBSD: makesrctars,v 1.42.2.1 2021/09/07 22:29:46 snj Exp $ # # makesrctars srcdir setdir # Create source tarballs in setdir from the source under srcdir. # prog="${0##*/}" rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" . "${rundir}/sets.subr" # set defaults xsrcdir= quiet=false GZIP=-9n export GZIP usage() { cat 1>&2 <&2 "${prog}: ${setdir} is not a directory" exit 1 fi makeset() {( set="${1}.tgz" shift dir="$1" shift intmp="/tmp/in$$" msg "Creating ${set}" if [ "${dir}" != "." ]; then cd "${dir}" srcprefix="${srcprefix}/${dir}" fi # Gets rid of any obj dirs and things below it. Also skip # .hg or .git repositories (if we got the source via git # or mercurial) printf "obj\n./.git\n./.hg\n" > "${intmp}" egrep="$*" if [ "${egrep}" = "" ]; then egrep='.' fi set -f ${MTREE} -c -X "${intmp}" | ${MTREE} -CS -k type | \ ${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \ ${SED} -e 's:type=file:& mode=0664:' \ -e 's:type=dir:& mode=0775:' \ -e 's:$: uname=root gname=wsrc:' \ -e '/\/move-if-change /s:\(mode\)=[0-9]*:\1=0775:' \ -e '/^\.\/.*[.-]sh /s:\(mode\)=[0-9]*:\1=0775:' | \ ${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \ ${GZIP_CMD} > "${setdir}/${set}" rm -f "${intmp}" )} # create (base)src sets # if ! cd "${srcdir}"; then echo >&2 "${prog}: can't chdir to ${srcdir}" exit 1 fi srcprefix=usr/src export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix makeset src . -v '^\.\/common|^\.\/external\/gpl2|^\.\/external\/gpl3|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config' makeset gnusrc . -e '^\..type=dir|^\.\/external.type=dir|^\.\/external\/gpl2|^\.\/external\/gpl3' makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config|^\.\/common' makeset sharesrc share # create xsrc sets # if [ -n "${xsrcdir}" ]; then if ! cd "${xsrcdir}"; then echo >&2 "${prog}: can't chdir to ${xsrcdir}" exit 1 fi srcprefix=usr/xsrc makeset xsrc . fi # create extsrc sets # if [ -n "${extsrcsrcdir}" ]; then if ! cd "${extsrcsrcdir}"; then echo >&2 "${prog}: can't chdir to ${extsrcsrcdir}" exit 1 fi srcprefix=usr/extsrc makeset extsrc . fi msg "Creating checksum files" (cd "${setdir}" ${CKSUM} -a md5 *.tgz *.tar.xz > MD5 ${CKSUM} -a sha512 *.tgz *.tar.xz > SHA512 ) exit 0