diff options
author | Kris Kennaway <kris@FreeBSD.org> | 2004-07-14 10:44:36 +0000 |
---|---|---|
committer | Kris Kennaway <kris@FreeBSD.org> | 2004-07-14 10:44:36 +0000 |
commit | 2bec66d63999c0388980edfde0159101ad642d4b (patch) | |
tree | b6dd5dd38c75cdf1aaa28ebe69d61e8c31145d44 /Tools | |
parent | 2ad9df1acfa05b5549a41db64f3f18afb01a4cc8 (diff) |
Notes
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/portbuild/scripts/claim-chroot | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Tools/portbuild/scripts/claim-chroot b/Tools/portbuild/scripts/claim-chroot new file mode 100755 index 000000000000..fae7e86c165c --- /dev/null +++ b/Tools/portbuild/scripts/claim-chroot @@ -0,0 +1,52 @@ +#!/bin/sh + +# usage: claim-chroot ${arch} ${branch} ${pkgname} + +# configurable variables +pb=/var/portbuild + +arch=$1 +shift + +. ${pb}/${arch}/portbuild.conf +. ${pb}/${arch}/portbuild.$(hostname) +. ${pb}/scripts/buildenv + +buildroot=${scratchdir} +error=0 + +branch=$1 +shift + +buildenv ${pb} ${arch} ${branch} + +pkgname=$(basename $1 ${PKGSUFFIX}) + +chrootdir=${buildroot}/${branch}/chroot + +found=0 +# Look for pre-existing chroot directories that are populated and unused +for dir in ${chrootdir}/*; do + if [ -f ${dir}/.ready -a -d ${dir}/tmp ]; then + # Atomically claim the directory + mkdir ${dir}/used 2>/dev/null || continue + touch ${dir}/used/${pkgname} + found=1 + chroot=${dir} + break + fi +done + +chrootnum=$$ +# If we didn't find a pre-existing directory, create and claim a new one. +while [ ${found} != 1 ]; do + chrootnum=$((chrootnum+1)) + chroot=${chrootdir}/${chrootnum} + mkdir -p ${chroot} 2>/dev/null || continue + mkdir ${chroot}/used 2>/dev/null || continue + touch ${chroot}/used/${pkgname} + touch ${chroot}/.notready + found=1 +done + +echo ${chroot} |