#!/bin/csh # # This is run from the chroot via fastbulk, which has CDd # 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" if ( $status == 0 ) then echo "FASTBULK SUCCESS ${argv[1]}: `date`" exit 0 else echo "FASTBULK FAILURE ${argv[1]}: `date`" find /var/db/pkg/$pkgname -name '*.core' -delete rmdir /var/db/pkg/$pkgname >& /dev/null exit 1 endif endif # Get the package name and clean up any garbage that might # interfere with the build. # set pkgname = "`bmake show-var VARNAME=PKGNAME`" set pkgwild = "$argv[2]" unsetenv PKG_PATH # Make sure /var/db/pkg/ does not have any .core files messing it up, # remove the recorded installation if it becomes empty. # find /var/db/pkg/$pkgname -name '*.core' -delete rmdir /var/db/pkg/$pkgname >& /dev/null # Check if already installed, prevent overwrite of # previous run's logfile if it exists, by deleting # the current run file. Else put in a simple logfile. # pkg_info -q -e $pkgname if ( $status == 0 ) then if ( -f /tmp/logs/good/$logname ) then rm -f /tmp/logs/run/$logname endif echo "(already installed from previous run)" exit 0 endif # Delete potential conflicts # pkg_delete -r "$pkgwild" # If we already have a binary package just install # it. # if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then echo "(found in /usr/pkgsrc/packages)" bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes setenv PKG_PATH /usr/pkgsrc/packages/All echo "pkg_add -f ${pkgname}" pkg_add -f ${pkgname} exit $status endif # We need to build the package. # # Delete any conflicting installed packages or the one we want to build # will refuse to build. The binary package files are left intact. # foreach i ( `bmake show-var VARNAME=CONFLICTS` ) echo "DELETING CONFLICTING PACKAGE: $i" pkg_delete -r "$i" end # If the dist file checksum fails and the dist file is over # 4 hours old we re-download it. # set dollar = '$' set distfiles = "`bmake -V '${dollar}{DISTFILES}'`" bmake checksum SKIP_LICENSE_CHECK=yes if ( $status != 0 ) then echo "Deleting distfiles ( $distfiles ) if over 4h old" foreach dfile ( $distfiles ) find /usr/pkgsrc/distfiles -name "$dfile" -mtime +4h -delete end endif # To ensure a clean build deinstall anything that # may cause our build repackage to fail. # # Clean after repackaging to keep the work topology footprint small. # # We create a binary package and then pkg_add it. # bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes bmake repackage SKIP_LICENSE_CHECK=yes if ( $status == 0 ) then bmake clean SKIP_LICENSE_CHECK=yes setenv PKG_PATH /usr/pkgsrc/packages/All echo "pkg_add -f ${pkgname}" pkg_add -f ${pkgname} 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 # for failed builds. # bmake clean SKIP_LICENSE_CHECK=yes exit 1