freebsd-ports/Tools/portbuild/scripts/mkbindist
Kris Kennaway a52cf32275 * Cleanup
* Remove vestiges of archaic support for building bindists from FTP
  snapshots; we haven't used this for years and building a world is no
  longer a challenge
* Revert half-baked bindist generation number and make it per-buildid
  instead.  Compress and md5 it for distribution to the clients.

TODO: Merge with makeworld?
2008-07-26 13:54:59 +00:00

78 lines
1.5 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}/${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
cd ${worlddir}; 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
cd ${here}/bindist/files; find -dx . | cpio -dump ${tmpdir}
# 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}