freebsd-ports/Tools/portbuild/scripts/prunefailure
Kris Kennaway c6484234da Prune out packages that will not be built because a dependency is marked
IGNORE/FORBIDDEN/etc (using duds.full).
2004-03-08 01:28:28 +00:00

78 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
#
# Prune the failure 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 -f 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 olddate date count; do
if [ -z "$dir" -o -z "$name" -o -z "$ver" -o -z "$olddate" -o -z "$date" -o -z "$count" ]; then
echo Malformed entry "$dir|$name|$ver|$olddate|$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 -qxF $newver $home/duds.full; then
echo "$newver listed in duds, should not be here"
continue
fi
(echo "$dir|$name|$newver|$olddate|$date|$count" >> $home/failure.new) || cleanup
done < $home/failure
mv failure.new failure