#!/bin/sh slot=$1 release=$2 ports=$3 #Audit slot and release names case $slot in *[^a-zA-Z0-9]* ) echo "Non-alphanumeric slot $slot"; exit 1 esac case $release in *[^a-zA-Z0-9-]* ) echo "Non-alphanumeric release $release"; exit 1 esac case $ports in *[^a-zA-Z0-9]* ) echo "Non-alphanumeric ports $ports"; exit 1 esac if [ -z "$slot" -o -z "$release" ]; then echo "Zero-length slot or release" exit 1 fi if [ -d /scratch/$slot ]; then echo "Pre-existing file system for this slot!" /pkgscripts/reapbuildjail $slot fi cleanup() { rm -f /scratch/$slot.lock /pkgscripts/reapbuildjail $slot exit 1 } set -e trap cleanup EXIT set -o noclobber echo > /scratch/$slot.lock set +o noclobber cat << EOF > /scratch/$slot.conf $slot { path="/scratch/$slot"; host.hostname="$slot.`hostname`"; persist="true"; mount.devfs="true"; mount.fstab="/scratch/$slot.fstab"; ip4.addr=127.0.0.1; } EOF mkdir -p /scratch/$slot mount -t tmpfs tmpfs /scratch/$slot #cp -a /scratch/$release/ /scratch/$slot tar -C /scratch/$slot -xf /buildshare/releases/$release.tar if [ -n "$ports" ]; then mkdir -p /scratch/$slot/buildshare/ports/$ports echo "/buildshare/ports/$ports /scratch/$slot/buildshare/ports/$ports nullfs ro 0 0" >> /scratch/$slot.fstab fi jail -f /scratch/$slot.conf -c $slot trap true EXIT rm /scratch/$slot.lock