aboutsummaryrefslogtreecommitdiff
path: root/Tools/portbuild
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2007-07-29 20:27:54 +0000
committerKris Kennaway <kris@FreeBSD.org>2007-07-29 20:27:54 +0000
commit687f04363330d919cf0ee69d47c92437a0709b9d (patch)
tree1a8ed74b445dca9d3f33c2bba9537003308e7a16 /Tools/portbuild
parent796b5ef2df07167cd7564e4b152508e3a8da35bd (diff)
downloadports-687f04363330d919cf0ee69d47c92437a0709b9d.tar.gz
ports-687f04363330d919cf0ee69d47c92437a0709b9d.zip
Notes
Diffstat (limited to 'Tools/portbuild')
-rwxr-xr-xTools/portbuild/scripts/claim-chroot23
-rwxr-xr-xTools/portbuild/scripts/clean-chroot18
-rwxr-xr-xTools/portbuild/scripts/cleanup-chroots6
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