Commit | Line | Data |
---|---|---|
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 | # | |
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. | |
b050e616 MD |
20 | # |
21 | set pkgname = "`bmake show-var VARNAME=PKGNAME`" | |
22 | set logname = $argv[1] | |
1b3b024a MD |
23 | unsetenv PKG_PATH |
24 | ||
25 | # Check if already installed, prevent overwrite of | |
e7db1956 MD |
26 | # previous run's logfile if it exists, by deleting |
27 | # the current run file. Else put in a simple logfile. | |
1b3b024a MD |
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)" | |
b050e616 MD |
35 | exit 0 |
36 | endif | |
37 | ||
e7db1956 MD |
38 | # If we already have a binary package just install |
39 | # it. | |
40 | # | |
1b3b024a MD |
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 | ||
e7db1956 MD |
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. | |
b050e616 MD |
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 | # | |
e7db1956 MD |
63 | # Clean after repackaging to keep the work topology footprint small. |
64 | # | |
65 | # We create a binary package and then pkg_add it. | |
b050e616 MD |
66 | # |
67 | bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes | |
e7db1956 | 68 | bmake repackage SKIP_LICENSE_CHECK=yes |
1b3b024a | 69 | if ( $status == 0 ) then |
e7db1956 | 70 | bmake clean SKIP_LICENSE_CHECK=yes |
1b3b024a MD |
71 | setenv PKG_PATH /usr/pkgsrc/packages/All |
72 | echo "pkg_add -f ${pkgname}" | |
73 | pkg_add -f ${pkgname} | |
74 | exit $status | |
75 | endif | |
e7db1956 MD |
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 | |
1b3b024a | 81 | exit 1 |