diff options
author | kris <kris@FreeBSD.org> | 2003-10-13 08:06:09 +0800 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2003-10-13 08:06:09 +0800 |
commit | 73cc624697d7cc0e7d406ceae64ea866991c3af5 (patch) | |
tree | f8327a2738469925b25316e9f4ec2eff8ba0967a /Tools | |
parent | 461c6bdcd937b608d2b20bef3cf8b7bdf746c81b (diff) | |
download | freebsd-ports-graphics-73cc624697d7cc0e7d406ceae64ea866991c3af5.tar.gz freebsd-ports-graphics-73cc624697d7cc0e7d406ceae64ea866991c3af5.tar.zst freebsd-ports-graphics-73cc624697d7cc0e7d406ceae64ea866991c3af5.zip |
Add a script that prunes the contents of the failure and newfailure files
of stale entries (removed ports, ports listed in duds that were mistakenly
built, malformed entries) and refreshes the version of entries to the
latest in INDEX. This must be run under lockf (see the comments in the
script) to avoid racing with portbuild which also tries to write to
these files.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/portbuild/scripts/prunefailure | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Tools/portbuild/scripts/prunefailure b/Tools/portbuild/scripts/prunefailure new file mode 100755 index 00000000000..3d559750bcf --- /dev/null +++ b/Tools/portbuild/scripts/prunefailure @@ -0,0 +1,114 @@ +#!/bin/sh +# +# Prune the failure and newfailure files of stale entries +# +# This must be called via: +# +# lockf ${pb}/${arch}/${branch}/failure.lock ${pb}/scripts/prunefailure ${arch} ${branch} +# +# to avoid racing with any package builds in progress that might try to append to +# these files. + +# configurable variables +pb=/var/portbuild + +cleanup() { + echo "Problem writing new failure file!" + rm failure.new + exit 1 +} + +if [ $# -ne 2 ]; then + echo "prunefailure <arch> <branch>" + exit 1 +fi + +arch=$1 +branch=$2 +shift 2 + +. ${pb}/${arch}/portbuild.conf +. ${pb}/scripts/buildenv + +buildenv ${pb} ${arch} ${branch} + +home=${pb}/${arch}/${branch} +cd $home + +pkgdir=$home/packages/All +index=${PORTSDIR}/${INDEXFILE} + +if [ "`wc -l $index | awk '{print $1}'`" -lt 9000 ]; then + echo "INDEX is corrupted, terminating!" + exit 1 +fi + +echo "===> Pruning old failure file" + +rm -f failure.new +IFS='|' +while read dir name ver date count; do + + if [ -z "$dir" -o -z "$name" -o -z "$ver" -o -z "$date" -o -z "$count" ]; then + echo Malformed entry "$dir|$name|$ver|$date|$count" + continue + fi + + entry=$(grep "|/usr/ports/$dir|" $index) + if [ -z "$entry" ]; then + echo $dir not in index + continue + fi + + newver=$(echo $entry | awk '{print $1}') + + if [ -e "$home/packages/All/$newver${PKGSUFFIX}" ]; then + echo "$newver package exists, should not still be here!" + continue + fi + + if grep -q $newver $home/duds.orig; then + echo "$newver listed in duds, should not be here" + continue + fi + + (echo "$dir|$name|$newver|$date|$count" >> $home/failure.new) || cleanup +done < $home/failure + +mv failure.new failure + +echo "===> Pruning old newfailure file" + +rm -f newfailure.new +IFS='|' +while read dir name ver date; do + if [ -z "$dir" -o -z "$name" -o -z "$ver" -o -z "$date" ]; then + echo Malformed entry "$dir|$name|$ver|$date|$count" + continue + fi + + entry=$(grep "|/usr/ports/$dir|" $index) + + if [ -z "$entry" ]; then + echo $dir not in index + continue + fi + + newver=$(echo $entry | awk '{print $1}') + + if [ -e "$home/packages/All/$newver${PKGSUFFIX}" ]; then + echo "$newver package exists, should not still be here!" + continue + fi + + if grep -q $newver $home/duds.orig; then + echo "$newver listed in duds, should not be here" + continue + fi + + (echo "$dir|$name|$newver|$date" >> $home/newfailure.new) || cleanup +done < $home/newfailure + +mv newfailure.new newfailure + + |