fastbulk - Exit w/success on more conditions
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Aug 2012 04:53:28 +0000 (21:53 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Aug 2012 04:53:28 +0000 (21:53 -0700)
* If the binary package build succeeds but the pkg_add fails it is likely
  due to an install conflict.  Exit w/success for this case (since our goal
  is to generate the binary package, we succeeded!).

* Do an early check to see if the binary package has already been built
  and exit immediately if it has.

test/fastbulk/dobuild

index 55f1bea..1353a32 100755 (executable)
@@ -4,6 +4,8 @@
 # into a particular pkgsrc directory and wants us to build it.
 # The script is run as /tmp/track/dobuild
 
+set logname = "$argv[1]"
+
 # We do not want to interfere with builds of other versions
 # of the same package, use a temporary lock file to prevent a
 # conflict.
 if ( $#argv == 1 ) then
        set pkgwild = "`bmake show-var VARNAME=PKGWILDCARD`.lck"
        set pkgname = "`bmake show-var VARNAME=PKGNAME`"
+
+       if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
+               if ( -f /tmp/logs/good/$logname ) then
+                   rm -f /tmp/logs/run/$logname
+                   echo "FASTBULK QUICK ${logname}: `date`" \
+                       >> /tmp/logs/good/$logname
+                   echo "FASTBULK: Package already exists, will not build" \
+                       >> /tmp/logs/good/$logname
+               else
+                   echo "FASTBULK: Package already exists, will not build"
+               endif
+               exit 0
+       endif
+
        mkdir -p /tmp/track/locks
        echo "FASTBULK START ${argv[1]}: `date`"
        lockf "/tmp/track/locks/$pkgwild" /tmp/track/dobuild ${argv[1]} "$pkgwild"
@@ -29,7 +45,6 @@ endif
 # interfere with the build.
 #
 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
-set logname = "$argv[1]"
 set pkgwild = "$argv[2]"
 unsetenv PKG_PATH
 
@@ -106,7 +121,16 @@ if ( $status == 0 ) then
     setenv PKG_PATH /usr/pkgsrc/packages/All
     echo "pkg_add -f ${pkgname}"
     pkg_add -f ${pkgname}
-    exit $status
+    if ( $status != 0 ) then
+       if ( -f ${PKG_PATH}/${pkgname}.tgz ) then
+           echo "FASTBULK WARNING: Cannot install due to probable conflicts"
+           echo "                  but the binary package DID build."
+           echo "                  Exiting w/code 0 to mark as successful."
+       else
+           exit 1
+       endif
+    endif
+    exit 0
 endif
 
 # comment this bmake out if you want to keep the work dir