diff options
author | kris <kris@FreeBSD.org> | 2007-07-30 04:27:54 +0800 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2007-07-30 04:27:54 +0800 |
commit | bcdce2783c9086129205c78d9606f4d6aee33f32 (patch) | |
tree | c7f9be0a2cb186d14737f9a863fe4f401eb2018d /Tools/portbuild | |
parent | 3da28110ec42c28d09a429ffbf3004613148e274 (diff) | |
download | freebsd-ports-gnome-bcdce2783c9086129205c78d9606f4d6aee33f32.tar.gz freebsd-ports-gnome-bcdce2783c9086129205c78d9606f4d6aee33f32.tar.zst freebsd-ports-gnome-bcdce2783c9086129205c78d9606f4d6aee33f32.zip |
Support builds using zfs and tmpfs backing store
zfs:
* Enabled by use_zfs=1 in portbuild.conf
* Populate build chroots by cloning a zfs snapshot instead of maintaining
many duplicate copies. In principle this is very efficient since
everything is copy-on-write and zfs snapshot creation is almost
instantaneous. There might be additional overheads from building on zfs
though. Currently the snapshot base is hard-wired to y/${branch}@base
but should be parametrized. This also must be populated beforehand, e.g.
during machine startup
* Clean build chroots by just destroying the snapshot.
tmpfs:
* Enabled by use_tmpfs=1 and tmpfs_size in portbuild.conf
* The previous md strategy of mounting in used/, populating and then
remounting (to avoid possible races from multiple builds claiming the
same chroot) doesn't work here because tmpfs instances are destroyed at
umount. I am not entirely sure the simpler approach is free from races.
Diffstat (limited to 'Tools/portbuild')
-rwxr-xr-x | Tools/portbuild/scripts/claim-chroot | 23 | ||||
-rwxr-xr-x | Tools/portbuild/scripts/clean-chroot | 18 | ||||
-rwxr-xr-x | Tools/portbuild/scripts/cleanup-chroots | 6 |
3 files changed, 40 insertions, 7 deletions
diff --git a/Tools/portbuild/scripts/claim-chroot b/Tools/portbuild/scripts/claim-chroot index 2af3ae2aff45..46a31c4f553a 100755 --- a/Tools/portbuild/scripts/claim-chroot +++ b/Tools/portbuild/scripts/claim-chroot @@ -27,7 +27,11 @@ buildenv ${pb} ${arch} ${branch} pkgname=$(basename $1 ${PKGSUFFIX}) -chrootdir=${buildroot}/${branch}/chroot +if [ "${use_zfs}" = 1 ]; then + chrootdir=${buildroot}/${branch} +else + chrootdir=${buildroot}/${branch}/chroot +fi # Perform initial sanity check @@ -73,7 +77,11 @@ done chrootnum=$$ # If we didn't find a pre-existing directory, create and claim a new one. while [ ${found} != 1 ]; do - if [ "${use_md_swap}" = "1" ]; then + if [ "${use_zfs}" = "1" ]; then + chroot=${chrootdir}/${chrootnum} + zfs clone y/${branch}@base $(echo ${chrootdir} | sed -e 's,/,,')/${chrootnum} + mkdir ${chroot}/used + elif [ "${use_md_swap}" = "1" ]; then unit=$(mdconfig -a -t swap -s ${md_size}) newfs /dev/${unit} > /dev/null chrootnum=$(echo ${unit} | sed 's,md,,') @@ -85,14 +93,21 @@ while [ ${found} != 1 ]; do touch ${chroot}/used/used/${pkgname} umount ${chroot}/used mount -o async /dev/${unit} ${chroot}/ + touch ${chroot}/.notready else chrootnum=$(($chrootnum+1)) chroot=${chrootdir}/${chrootnum} - mkdir -p ${chroot} 2>/dev/null || continue + mkdir -p ${chrootdir} 2> /dev/null || continue + mkdir ${chroot} 2>/dev/null || continue mkdir ${chroot}/used 2>/dev/null || continue + touch ${chroot}/.notready + fi + if [ "${use_tmpfs}" = "1" ]; then + mount -t tmpfs -o "size=${tmpfs_size}" foo ${chroot} + mkdir ${chroot}/used 2>/dev/null || echo "ERROR: mkdir race" + touch ${chroot}/.notready fi touch ${chroot}/used/${pkgname} - touch ${chroot}/.notready found=1 done diff --git a/Tools/portbuild/scripts/clean-chroot b/Tools/portbuild/scripts/clean-chroot index 182e0cccab52..6e17a69bcc9a 100755 --- a/Tools/portbuild/scripts/clean-chroot +++ b/Tools/portbuild/scripts/clean-chroot @@ -73,10 +73,24 @@ done #kill_procs ${chroot} -if [ "${use_md_swap}" = "1" -a \( "${md_persistent}" != "1" -a "${clean}" -gt "0" \) -o "${clean}" = "2" ]; then +if [ "${use_zfs}" = "1" ]; then + cleanup_mount ${chroot} "" + zfs destroy $(echo ${chroot} | sed -e 's,/,,' ) +elif [ "${use_tmpfs}" = "1" -a "${clean}" = "2" ]; then + cleanup_mount ${chroot} "" + if ! rm -rf ${chroot} >/dev/null 2>&1; then + chflags -R noschg ${chroot} >/dev/null 2>&1 + rm -rf ${chroot} >/dev/null 2>&1 + fi + # XXX possible race from cleanup and claim by next build? +elif [ "${use_md_swap}" = "1" -a \( "${md_persistent}" != "1" -a "${clean}" -gt "0" \) -o "${clean}" = "2" ]; then + cleanup_mount ${chroot} /used cleanup_mount ${chroot} "" mdconfig -d -u $(basename ${chroot}) - rm -rf ${chroot} + if ! rm -rf ${chroot} >/dev/null 2>&1; then + chflags -R noschg ${chroot} >/dev/null 2>&1 + rm -rf ${chroot} >/dev/null 2>&1 + fi else if [ "${clean}" = 1 ]; then rm -rf ${chroot}/tmp/* diff --git a/Tools/portbuild/scripts/cleanup-chroots b/Tools/portbuild/scripts/cleanup-chroots index 48a9f893e5e4..c6a095af0ab3 100755 --- a/Tools/portbuild/scripts/cleanup-chroots +++ b/Tools/portbuild/scripts/cleanup-chroots @@ -42,7 +42,11 @@ arch=$(cat /etc/arch) . ${pb}/${arch}/portbuild.conf -old=$(find ${scratchdir}/*/chroot/* -prune -mmin +20 2> /dev/null) +if [ "${use_zfs}" = "1" ]; then + old=$(find ${scratchdir}/*/* -prune -mmin +20 2> /dev/null) +else + old=$(find ${scratchdir}/*/chroot/* -prune -mmin +20 2> /dev/null) +endif if [ -z "${old}" ]; then exit 0 |