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