fastbulk - More fixes and improvements
[dragonfly.git] / test / fastbulk / dobuild
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.
5 # The script is run as /tmp/track/dobuild
6
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 #
11 if ( $#argv == 1 ) then
12         set pkgwild = "`bmake show-var VARNAME=PKGWILDCARD`.lck"
13         mkdir -p /tmp/track/locks
14         lockf "/tmp/track/locks/$pkgwild" /tmp/track/dobuild $argv[1] locked
15         exit $status
16 endif
17
18 # Get the package name and clean up any garbage that might
19 # interfere with the build.
20 #
21 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
22 set logname = $argv[1]
23 unsetenv PKG_PATH
24
25 # Check if already installed, prevent overwrite of
26 # previous run's logfile if it exists, by deleting
27 # the current run file.  Else put in a simple logfile.
28 #
29 pkg_info -q -e $pkgname
30 if ( $status == 0 ) then
31     if ( -f /tmp/logs/good/$logname ) then
32         rm -f /tmp/logs/run/$logname
33     endif
34     echo "(already installed from previous run)"
35     exit 0
36 endif
37
38 # If we already have a binary package just install
39 # it.
40 #
41 if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
42     echo "(found in /usr/pkgsrc/packages)"
43     bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
44     setenv PKG_PATH /usr/pkgsrc/packages/All
45     echo "pkg_add -f ${pkgname}"
46     pkg_add -f ${pkgname}
47     exit $status
48 endif
49
50 # We need to build the package.
51 #
52 # Delete any conflicting installed packages or the one we want to build
53 # will refuse to build.  The binary package files are left intact.
54 #
55 foreach i ( `bmake show-var VARNAME=CONFLICTS` )
56     echo "DELETING CONFLICTING PACKAGE: $i"
57     pkg_delete -r "$i"
58 end
59
60 # To ensure a clean build deinstall anything that
61 # may cause our build repackage to fail.
62 #
63 # Clean after repackaging to keep the work topology footprint small.
64 #
65 # We create a binary package and then pkg_add it.
66 #
67 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
68 bmake repackage SKIP_LICENSE_CHECK=yes
69 if ( $status == 0 ) then
70     bmake clean SKIP_LICENSE_CHECK=yes
71     setenv PKG_PATH /usr/pkgsrc/packages/All
72     echo "pkg_add -f ${pkgname}"
73     pkg_add -f ${pkgname}
74     exit $status
75 endif
76
77 # comment this bmake out if you want to keep the work dir
78 # for failed builds.
79 #
80 bmake clean SKIP_LICENSE_CHECK=yes
81 exit 1