fastbulk - Adjustments to fix various issues (2)
[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
6 # Nothing to do if the package already exists.  Remove the run log
7 # to prevent fastbulk from replacing the log from a previous run
8 #
9 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
10 set logname = $argv[1]
11 unsetenv PKG_PATH
12
13 # Check if already installed, prevent overwrite of
14 # previous run's logfile if it exists, else put in
15 # a simple logfile.
16 #
17 pkg_info -q -e $pkgname
18 if ( $status == 0 ) then
19     if ( -f /tmp/logs/good/$logname ) then
20         rm -f /tmp/logs/run/$logname
21     endif
22     echo "(already installed from previous run)"
23     exit 0
24 endif
25
26 if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
27     echo "(found in /usr/pkgsrc/packages)"
28     bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
29     setenv PKG_PATH /usr/pkgsrc/packages/All
30     echo "pkg_add -f ${pkgname}"
31     pkg_add -f ${pkgname}
32     exit $status
33 endif
34
35 # We have to remove any conflicting packages or the one we
36 # are trying to build will refuse to build.  Note that we
37 # leave the related packages intact.
38 #
39 foreach i ( `bmake show-var VARNAME=CONFLICTS` )
40     echo "DELETING CONFLICTING PACKAGE: $i"
41     pkg_delete -r "$i"
42 end
43
44 # To ensure a clean build deinstall anything that
45 # may cause our build repackage to fail.
46 #
47 # Clean after repackaging (if it succeeded) to keep the
48 # work topology footprint small.  The work topology is
49 # left intact for failed builds.
50 #
51 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
52 bmake repackage clean SKIP_LICENSE_CHECK=yes
53 if ( $status == 0 ) then
54     setenv PKG_PATH /usr/pkgsrc/packages/All
55     echo "pkg_add -f ${pkgname}"
56     pkg_add -f ${pkgname}
57     exit $status
58 endif
59 exit 1