fastbulk - more work
[dragonfly.git] / test / fastbulk / dobuild
CommitLineData
b050e616
MD
1#!/bin/csh
2#
3# This is run from the chroot via fastbulk, which has CDd
4# into a particular pkgsrc directory and wants us to build it.
e7db1956 5# The script is run as /tmp/track/dobuild
b050e616 6
e7db1956
MD
7# We do not want to interfere with builds of other versions
8# of the same package, use a temporary lock file to prevent a
9# conflict.
10#
11if ( $#argv == 1 ) then
12 set pkgwild = "`bmake show-var VARNAME=PKGWILDCARD`.lck"
13 mkdir -p /tmp/track/locks
ab988e04
MD
14 echo "FASTBULK START ${argv[1]}: `date`"
15 lockf "/tmp/track/locks/$pkgwild" /tmp/track/dobuild ${argv[1]} "$pkgwild"
16 if ( $status == 0 ) then
17 echo "FASTBULK SUCCESS ${argv[1]}: `date`"
18 exit 0
19 else
20 echo "FASTBULK FAILURE ${argv[1]}: `date`"
21 exit 1
22 endif
e7db1956
MD
23endif
24
25# Get the package name and clean up any garbage that might
26# interfere with the build.
b050e616
MD
27#
28set pkgname = "`bmake show-var VARNAME=PKGNAME`"
ab988e04
MD
29set logname = "$argv[1]"
30set pkgwild = "$argv[2]"
1b3b024a
MD
31unsetenv PKG_PATH
32
33# Check if already installed, prevent overwrite of
e7db1956
MD
34# previous run's logfile if it exists, by deleting
35# the current run file. Else put in a simple logfile.
1b3b024a
MD
36#
37pkg_info -q -e $pkgname
38if ( $status == 0 ) then
39 if ( -f /tmp/logs/good/$logname ) then
40 rm -f /tmp/logs/run/$logname
41 endif
42 echo "(already installed from previous run)"
b050e616
MD
43 exit 0
44endif
45
ab988e04
MD
46# Delete potential conflicts
47#
48pkg_delete -r "$pkgwild"
49
e7db1956
MD
50# If we already have a binary package just install
51# it.
52#
1b3b024a
MD
53if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
54 echo "(found in /usr/pkgsrc/packages)"
55 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
56 setenv PKG_PATH /usr/pkgsrc/packages/All
57 echo "pkg_add -f ${pkgname}"
58 pkg_add -f ${pkgname}
59 exit $status
60endif
61
e7db1956
MD
62# We need to build the package.
63#
64# Delete any conflicting installed packages or the one we want to build
65# will refuse to build. The binary package files are left intact.
b050e616
MD
66#
67foreach i ( `bmake show-var VARNAME=CONFLICTS` )
68 echo "DELETING CONFLICTING PACKAGE: $i"
69 pkg_delete -r "$i"
70end
71
ab988e04
MD
72# If the dist file checksum fails and the dist file is over
73# 4 hours old we re-download it.
74#
75
76set dollar = '$'
77set distfiles = "`bmake -V '${dollar}{DISTFILES}'`"
78bmake checksum SKIP_LICENSE_CHECK=yes
79if ( $status != 0 ) then
80 echo "Deleting distfiles ( $distfiles ) if over 4h old"
81 foreach dfile ( $distfiles )
82 find /usr/pkgsrc/distfiles -name "$dfile" -mtime +4h -delete
83 end
84endif
85
b050e616
MD
86# To ensure a clean build deinstall anything that
87# may cause our build repackage to fail.
88#
e7db1956
MD
89# Clean after repackaging to keep the work topology footprint small.
90#
91# We create a binary package and then pkg_add it.
b050e616
MD
92#
93bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
e7db1956 94bmake repackage SKIP_LICENSE_CHECK=yes
1b3b024a 95if ( $status == 0 ) then
e7db1956 96 bmake clean SKIP_LICENSE_CHECK=yes
1b3b024a
MD
97 setenv PKG_PATH /usr/pkgsrc/packages/All
98 echo "pkg_add -f ${pkgname}"
99 pkg_add -f ${pkgname}
100 exit $status
101endif
e7db1956
MD
102
103# comment this bmake out if you want to keep the work dir
104# for failed builds.
105#
106bmake clean SKIP_LICENSE_CHECK=yes
1b3b024a 107exit 1