aboutsummaryrefslogtreecommitdiffstats
path: root/Tools/portbuild/scripts/buildfailure
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/portbuild/scripts/buildfailure')
-rwxr-xr-xTools/portbuild/scripts/buildfailure29
1 files changed, 16 insertions, 13 deletions
diff --git a/Tools/portbuild/scripts/buildfailure b/Tools/portbuild/scripts/buildfailure
index 789b9d71199..f95d96de162 100755
--- a/Tools/portbuild/scripts/buildfailure
+++ b/Tools/portbuild/scripts/buildfailure
@@ -2,6 +2,12 @@
#
# buildfailure <arch> <branch> <pkgname>
+cleanup() {
+ echo "Problem writing new failure file!"
+ rm -f failure.new
+ exit 1
+}
+
# configurable variables
pb=/var/portbuild
arch=$1
@@ -26,21 +32,18 @@ portloc=$(grep "^$pkgname|" ${index} | cut -f 2 -d \| | sed s,/usr/ports/,,)
pkgbase=$(cd ${pb}/${arch}/${branch}/ports/${portloc}/ && make -V PKGBASE)
cd ${pb}/${arch}/${branch}
-if grep -q "^${portloc}|" failure; then
- count=$(grep "^${portloc}|" failure | cut -f 5 -d \|)
- grep -v "^${portloc}|" failure > failure.new
-
- echo "${portloc}|${pkgbase}|${pkgname}|$(date +%s| tr ' ' '_')|$((${count}+1))" >> failure.new
+entry=$(grep "^${portloc}|" failure)
+date=$(date +%s)
+IFS='|'
+if [ ! -z "$entry" ]; then
+ count=$(echo $entry | cut -f 6 -d \ )
+ olddate=$(echo $entry | cut -f 4 -d \ )
+ (grep -v "^${portloc}|" failure > failure.new) || cleanup
+
+ (echo "${portloc}|${pkgbase}|${pkgname}|${olddate}|${date}|$((${count}+1))" >> failure.new) || cleanup
mv failure.new failure
else
- # Want newfailure to be in reverse chronological order
- mv newfailure newfailure.new
- echo "${portloc}|${pkgbase}|${pkgname}|$(date +%s| tr ' ' '_')" > newfailure
- cat newfailure newfailure.new > newfailure.new2
- mv newfailure.new2 newfailure
- rm newfailure.new
-
- echo "${portloc}|${pkgbase}|${pkgname}|$(date +%s)|1" >> failure
+ (echo "${portloc}|${pkgbase}|${pkgname}|${date}|${date}|1" >> failure) || cleanup
fi