aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2004-12-28 05:40:51 +0000
committerKris Kennaway <kris@FreeBSD.org>2004-12-28 05:40:51 +0000
commit5ca3821cf5709d42acef38b7115e1422d84af6c6 (patch)
tree15c2bb27ab2eac0f3ec4ceb2c059b10211c2d325 /Tools
parente47e30512604dbb97bf30d841a5b77aa05875d73 (diff)
downloadports-5ca3821cf5709d42acef38b7115e1422d84af6c6.tar.gz
ports-5ca3821cf5709d42acef38b7115e1422d84af6c6.zip
Notes
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/portbuild/scripts/checkmachines33
-rwxr-xr-xTools/portbuild/scripts/getmachine53
-rwxr-xr-xTools/portbuild/scripts/pollmachine33
-rwxr-xr-xTools/portbuild/scripts/releasemachine29
4 files changed, 119 insertions, 29 deletions
diff --git a/Tools/portbuild/scripts/checkmachines b/Tools/portbuild/scripts/checkmachines
index 7f32bac93128..c6108d63b0a4 100755
--- a/Tools/portbuild/scripts/checkmachines
+++ b/Tools/portbuild/scripts/checkmachines
@@ -24,37 +24,12 @@ while true; do
for i in ${arches}; do
mlist=${buildroot}/${i}/mlist
- unset DISPLAY
-
- min=99
set $(cat $mlist)
- while [ $# -gt 1 ]; do
+ while [ $# -gt 0 ]; do
m=$1
- l=$2
- if (/usr/local/bin/nc -w 5 $m infoseek > ${buildroot}/${i}/loads/$m < /dev/null); then
- num=$(awk '{print $1}' ${buildroot}/${i}/loads/$m)
- if [ "x$num" = "x" ]; then
- # logger "checkmachines: file ${buildroot}/${i}/loads/$m is empty"
- num=99
- fi
- else
- # Don't ever want to list machines we couldn't connect to
- num=999
- fi
-
- num=$(($num / $l))
-
- if [ $num -lt $min ]; then
- mach=$m
- min=$num
- elif [ $num = $min ]; then
- mach="$mach $m"
- fi
-
- shift 2
-
+ lockf ${buildroot}/${i}/queue/.lock ${buildroot}/scripts/pollmachine ${i} ${m}
+ shift 1
done
- echo "$mach" > ${buildroot}/${i}/ulist
-
done
+ sleep 120
done
diff --git a/Tools/portbuild/scripts/getmachine b/Tools/portbuild/scripts/getmachine
new file mode 100755
index 000000000000..849d300e6270
--- /dev/null
+++ b/Tools/portbuild/scripts/getmachine
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Choose the least-loaded machine in the queue dir
+# Called with lock held
+# We know that everything in this directory has space for another job
+
+pb=$1
+arch=$2
+branch=$3
+
+qdir=${pb}/${arch}/queue
+
+cd $qdir
+set *
+if [ "$1" = "*" ]; then
+ echo ""
+ exit 1
+fi
+
+min=9999
+while [ $# -gt 0 ]; do
+ m=$1
+ num=$(cat $m)
+ if [ $num -lt $min ]; then
+ mach=$m
+ min=$num
+ elif [ $num -eq $min ]; then
+ mach="${mach} ${m}"
+ fi
+ shift
+done
+
+if [ "$min" = 9999 -o -z "${mach}" ]; then
+ echo ""
+ exit 1
+fi
+
+# Choose highest-priority machine that is free
+mach=$(echo ${mach} | tr -s ' ' '\n' | grep -F -f - ${pb}/${arch}/mlist | head -1)
+
+. ${pb}/${arch}/portbuild.conf
+test -f ${pb}/${arch}/portbuild.${mach} && . ${pb}/${arch}/portbuild.${mach}
+
+# Now that we've found a machine, register our claim in the queue
+if [ "$((${min}+1))" -ge "${maxjobs}" ]; then
+ rm ${mach}
+else
+ echo $(($min+1)) > ${mach}
+fi
+
+# Report to caller
+echo ${mach}
+exit 0
diff --git a/Tools/portbuild/scripts/pollmachine b/Tools/portbuild/scripts/pollmachine
new file mode 100755
index 000000000000..75cd9885ddee
--- /dev/null
+++ b/Tools/portbuild/scripts/pollmachine
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+buildroot=/var/portbuild
+
+i=$1
+m=$2
+if [ "$3" = "-queue" ]; then
+ queue=1
+else
+ queue=0
+fi
+
+infoseek_host=$m
+infoseek_port=infoseek
+. ${buildroot}/${i}/portbuild.conf
+if [ -f ${buildroot}/${i}/portbuild.${m} ]; then
+ . ${buildroot}/${i}/portbuild.${m}
+fi
+if (/usr/local/bin/nc -w 5 ${infoseek_host} ${infoseek_port} > ${buildroot}/${i}/loads/$m < /dev/null); then
+ if [ "${queue}" = 1 ]; then
+ num=$(awk '{print $1}' ${buildroot}/${i}/loads/$m)
+ if [ "$num" -lt "${maxjobs}" ]; then
+ echo ${num} > ${buildroot}/${i}/queue/$m
+ chown ports-${i} ${buildroot}/${i}/queue/$m
+ else
+ rm -f ${buildroot}/${i}/queue/$m
+ fi
+ fi
+else
+ rm -f ${buildroot}/${i}/queue/$m
+ exit 1
+fi
+exit 0
diff --git a/Tools/portbuild/scripts/releasemachine b/Tools/portbuild/scripts/releasemachine
new file mode 100755
index 000000000000..66d23b193845
--- /dev/null
+++ b/Tools/portbuild/scripts/releasemachine
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+buildroot=/var/portbuild
+
+i=$1
+m=$2
+
+infoseek_host=$m
+infoseek_port=infoseek
+. ${buildroot}/${i}/portbuild.conf
+if [ -f ${buildroot}/${i}/portbuild.${m} ]; then
+ . ${buildroot}/${i}/portbuild.${m}
+fi
+
+q=${buildroot}/${i}/queue/$m
+if [ -f ${q} ]; then
+ num=$(cat $q)
+else
+ num=${maxjobs}
+fi
+
+if [ "$num" -gt 0 ]; then
+ echo $((${num}-1)) > $q
+else
+ echo 0 > $q
+fi
+
+chown ports-${i} ${q}
+exit 0