if [ ! -f "${agent_script}" ]; then # require pbulk deployment script
echo "${0##*/}: pbulk.sh script required" 1>&2; exit 1
fi
# Create environment, if it doesn't exist, and make it functional in general:
if [ ! -x ${JAIL}/bin/sh ]; then
create-root ${JAIL}
fi
cat /etc/resolv.conf > ${JAIL}/etc/resolv.conf
start-root ${JAIL}
mkdir -p ${DISTDIR}
mkdir -p ${PACKAGES}
mkdir -p ${JAIL}/usr/pkgsrc
mount -t null -o ro ${PKGSRCDIR} ${JAIL}/usr/pkgsrc
mount -t null -o rw ${DISTDIR} ${JAIL}/usr/pkgsrc/distfiles
mount -t null -o rw ${PACKAGES} ${JAIL}/usr/pkgsrc/packages
# Deploy bulk build tools, if not deployed already:
if [ ! -x ${JAIL}/usr/pbulk/bin/bulkbuild ]; then
cat "${agent_script}" > ${JAIL}/root/pbulk.sh
if [ -n "$mk_fragment" ]; then cat "$mk_fragment" > ${JAIL}/root/mk.conf.frag; fi
PACKAGES=/usr/pkgsrc/packages chroot ${JAIL} /bin/sh /root/pbulk.sh ${native:+-n} ${limited_list:+-l} ${mk_fragment:+-c /root/mk.conf.frag}
fi
# Configure limited list, if given:
if [ -n "$limited_list" ]; then cat "$limited_list" > ${JAIL}/usr/pbulk/etc/pbulk.list; fi