freebsd-ports/Tools/portbuild/scripts/mkbindist
Mark Linimon ae733423e0 Generalize the packge building scripts to be able to be run on more than
one 'head' node, rather than just pointyhat itself.

Constants are factored out into installation-specific files known as
portbuild/conf/server.conf and portbuild/conf/client.conf.  There is
only one server.conf file.  Individual <arch> directories may have
their own client.conf files, or may symlink to ../conf/client.conf.

This first set of files only gets the *.conf files and some cleanup.

Feature safe:	yes
2010-06-25 22:49:56 +00:00

83 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
# XXX merge with makeworld?
usage () {
echo "usage: mkbindist <arch> <branch> <buildid>"
exit 1
}
cleandir() {
dir=$1
rm -rf ${dir} 2>/dev/null
if [ -d ${dir} ]; then
chflags -R noschg ${dir}
rm -rf ${dir}
fi
}
if [ $# -lt 3 ]; then
usage
fi
arch=$1
branch=$2
buildid=$3
shift 3
pb=/var/portbuild
. ${pb}/conf/server.conf
. ${pb}/${arch}/portbuild.conf
. ${pb}/scripts/buildenv
if ! validate_env ${arch} ${branch}; then
echo "Invalid build environment ${arch}/${branch}"
exit 1
fi
here=${pb}/${arch}/${branch}/builds/${buildid}
if [ ! -d ${here} ]; then
echo "Invalid build ID ${buildid}"
exit 1
fi
tmpdir=${here}/bindist/tmp
# Clean up ${tmpdir}
cleandir ${tmpdir}
mkdir -p ${tmpdir}
# Copy the files into the tmpdir from an existing built world
destdir=${WORLDDIR}/${arch}/${branch}
cd ${destdir}; find -dx . | \
grep -v -E '^./usr/(local|obj|opt|ports|src)' | \
grep -v '^./home' | \
grep -v '^./var/db/pkg' | \
cpio -dump ${tmpdir}
cd ${tmpdir}
# Customize the tmpdir
if [ -s "${here}/bindist/delete" ]; then
sed -e "s,^,${tmpdir}," ${here}/bindist/delete | xargs rm -rf
fi
if [ -s "${here}/bindist/dirlist" ]; then
cat "${here}/bindist/dirlist" | xargs mkdir -p
fi
# XXX MCL seems to be obsoleted by individual files in clients/?
if [ -d ${here}/bindist/files ]; then
cd ${here}/bindist/files; find -dx . | cpio -dump ${tmpdir}
fi
# Post-processing of installed world
date '+%Y%m%d' > ${tmpdir}/var/db/port.mkversion
# Create the tarball
tar cfCj ${here}/.bindist.tbz ${tmpdir} .
mv -f ${here}/.bindist.tbz ${here}/bindist.tbz
md5 ${here}/bindist.tbz > ${here}/bindist.tbz.md5
# Clean up
cd ${here}
cleandir ${tmpdir}