#!/bin/sh # XXX merge with makeworld? usage () { echo "usage: mkbindist []" 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 2 ]; then usage fi arch=$1 branch=$2 shift 2 buildid="latest" if [ $# -gt 0 ]; then buildid="$1" shift fi pbc=${PORTBUILD_CHECKOUT:-/a/portbuild} pbd=${PORTBUILD_DATA:-/a/portbuild} builddir=${pbd}/${arch}/${branch}/builds/${buildid} if [ ! -d ${builddir} ]; then echo "build directory ${builddir} does not exist!" exit 1 fi . ${pbc}/admin/conf/admin.conf . ${pbc}/conf/server.conf . ${pbd}/${arch}/portbuild.conf if [ -f ${builddir}/portbuild.conf ]; then . ${builddir}/portbuild.conf fi . ${pbc}/scripts/buildenv if ! validate_env ${arch} ${branch}; then echo "Invalid build environment ${arch}/${branch}" exit 1 fi tmpdir=${builddir}/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 "${builddir}/bindist/delete" ]; then sed -e "s,^,${tmpdir}," ${builddir}/bindist/delete | xargs rm -rf fi if [ -s "${builddir}/bindist/dirlist" ]; then cat "${builddir}/bindist/dirlist" | xargs mkdir -p fi # XXX MCL seems to be obsoleted by individual files in clients/? if [ -d ${builddir}/bindist/files ]; then cd ${builddir}/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 ${builddir}/.bindist.tbz ${tmpdir} . mv -f ${builddir}/.bindist.tbz ${builddir}/bindist.tbz md5 ${builddir}/bindist.tbz > ${builddir}/bindist.tbz.md5 # Clean up cd ${builddir} cleandir ${tmpdir}