Skip to content

@jperkin /README.md
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
pbulk chroot config example

Our pbulk diffs are available in our miscfix branch:

https://github.com/joyent/pkgsrc/commits/joyent/feature/miscfix/trunk/pkgtools/pbulk

After building that, add this to pbulk.conf:

chroot_create=/scripts/mksandbox
chroot_delete=/scripts/rmsandbox
chroot_dir=/chroot/pkgsrc-trunk
build_chroots=4
scan_chroots=8

The variables should be obvious, but in case not:

  • chroot_create is a script to create the chroot
  • chroot_delete uncreates it
  • chroot_dir is the base dir of the chroot
  • build_chroots is the number of chroots to create for pbulk-build
  • scan_chroots is the number of chroots to create for pbulk-scan

Then, when running pbulk, for each build_clients and scan_clients the chroot scripts will be executed, creating individual chroot_dir areas and running the build/scan inside them.

scan_chroots can probably be set quite high. build_chroots will need to be adjusted based on your resources and e.g. MAKE_JOBS setting.

#!/bin/sh
#
# Create a per-build chroot area.
#
set -e
PATH=/sbin:/usr/sbin:/bin
if [ $# -eq 1 ]; then
chrootdir="${1%%/}"; shift
else
echo "usage: $0 <chrootdir>" >&2
exit 2
fi
if [ -d "${chrootdir}" ]; then
echo "Chroot directory ${chrootdir} already exists. Not recreating"
exit 0
fi
mkdir -p ${chrootdir}
#
# Create loopback/nfs mounts. SNGL brands are special.
#
sysdirs="/dev /lib /sbin /usr"
sysprefix=""
case "${chrootdir}" in
*-sngl)
sysprefix="/system"
# Compat symlinks only necessary for starting pbulk.
mkdir -p ${chrootdir}/usr/bin
ln -s /system/usr/bin/bash ${chrootdir}/usr/bin/bash
mkdir -p ${chrootdir}/usr/xpg4/bin
ln -s /system/usr/xpg4/bin/id ${chrootdir}/usr/xpg4/bin/id
;;
esac
for dir in ${sysdirs}
do
mkdir -p ${chrootdir}${sysprefix}${dir}
mount -F lofs -r ${dir} ${chrootdir}${sysprefix}${dir}
# SNGL symlinks except for /usr
if [ -n "${sysprefix}" -a "${dir}" != "/usr" ]; then
ln -s ${sysprefix}${dir} ${chrootdir}${dir}
fi
done
# /dev/fd
mount -F fd fd ${chrootdir}${sysprefix}/dev/fd
# /opt/pbulk
mkdir -p ${chrootdir}/opt/pbulk
mount -F lofs -r /opt/pbulk ${chrootdir}/opt/pbulk
if [ -d /opt/pbulk/var/spool/postfix ]; then
mount -F lofs /opt/pbulk/var/spool/postfix ${chrootdir}/opt/pbulk/var/spool/postfix
fi
# /proc
mkdir -p ${chrootdir}/proc
mount -F proc /proc ${chrootdir}/proc
# /system/lxproc, if supported
if [ -d /system/lxproc/1 ]; then
mkdir -p ${chrootdir}/system/lxproc
mount -F lxproc lxproc ${chrootdir}/system/lxproc
fi
# /tmp
mkdir -p ${chrootdir}/tmp
mount -F tmpfs swap ${chrootdir}/tmp
chmod 1777 ${chrootdir}/tmp
# /shared
mkdir -p ${chrootdir}/shared
mount -F nfs $INSERT_NFS_SERVER ${chrootdir}/shared >/dev/null
#
# Create files/symlinks
#
# /bin
ln -s ./usr/bin ${chrootdir}/bin
# /var/mail (for mutt's configure script)
mkdir -p -m 1777 ${chrootdir}/var/mail
# /var/tmp
mkdir -p -m 1777 ${chrootdir}/var/tmp
# /etc
mkdir -p ${chrootdir}/etc
(cd /etc; gtar -cf - . 2>/dev/null) | (cd ${chrootdir}/etc; gtar -xf -)
cp /etc/TIMEZONE ${chrootdir}/etc/TIMEZONE
# /root/.ssh
mkdir -p ${chrootdir}/root
(cd /root; gtar -cf - .ssh 2>/dev/null) | (cd ${chrootdir}/root; gtar -xf -)
# /home/pbulk only if user exists
if id pbulk >/dev/null 2>&1; then
mkdir -p ${chrootdir}/home/pbulk
rsync -a /shared/pbulk/homedir/ ${chrootdir}/home/pbulk/
chown -R pbulk:pbulk ${chrootdir}/home/pbulk
chmod 0400 ${chrootdir}/home/pbulk/.ssh/*_rsa
fi
#!/bin/sh
#
# Delete a chroot area.
#
PATH=/sbin:/usr/sbin:/bin
if [ $# -eq 1 ]; then
chrootdir="${1%%/}"; shift
else
echo "usage: $0 <chrootdir>" >&2
exit 2
fi
sysprefix=""
case "${chrootdir}" in
*-sngl)
sysprefix="/system"
;;
esac
if [ -d "${chrootdir}" ]; then
# Unmount nested mounts first
umount ${chrootdir}${sysprefix}/dev/fd
if [ -d ${chrootdir}/opt/pbulk/var/spool/postfix ]; then
umount ${chrootdir}/opt/pbulk/var/spool/postfix
fi
# System directories with optional prefix
for dir in /dev /lib /sbin /usr
do
umount ${chrootdir}${sysprefix}${dir}
rmdir ${chrootdir}${sysprefix}${dir}
done
# Remaining mounts
for dir in /opt/pbulk /proc /shared /tmp
do
umount ${chrootdir}${dir}
rmdir ${chrootdir}${dir}
done
if [ -d ${chrootdir}/system/lxproc/1 ]; then
umount ${chrootdir}/system/lxproc
rmdir ${chrootdir}/system/lxproc
rmdir ${chrootdir}/system
fi
# This must be done carefully to avoid deleting anything in writeable
# mounts, most notable /shared!
rm -rf ${chrootdir}/{bin,etc,home,opt,root,var}
# pkgsrc leftovers
rm -rf ${chrootdir}/{news,media}
# SNGL specifics
if [ -n "${sysprefix}" ]; then
rm -rf ${chrootdir}/{dev,lib,sbin,usr}
rmdir ${chrootdir}${sysprefix}
rm -f ${chrootdir}/.setup
fi
# chrootdir should now be empty, if not print what's left.
rmdir ${chrootdir}
if [ $? -ne 0 ]; then
echo "Leftovers:"
find ${chrootdir} -mount -fstype zfs
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.