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
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
11 if ( $#argv == 1 ) then
12 set pkgwild = "`bmake show-var VARNAME=PKGWILDCARD`.lck"
13 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
14 mkdir -p /tmp/track/locks
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`"
21 echo "FASTBULK FAILURE ${argv[1]}: `date`"
22 find /var/db/pkg/$pkgname -name '*.core' -delete
23 rmdir /var/db/pkg/$pkgname >& /dev/null
28 # Get the package name and clean up any garbage that might
29 # interfere with the build.
31 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
32 set logname = "$argv[1]"
33 set pkgwild = "$argv[2]"
36 # Make sure /var/db/pkg/ does not have any .core files messing it up,
37 # remove the recorded installation if it becomes empty.
39 find /var/db/pkg/$pkgname -name '*.core' -delete
40 rmdir /var/db/pkg/$pkgname >& /dev/null
42 # Check if already installed, prevent overwrite of
43 # previous run's logfile if it exists, by deleting
44 # the current run file. Else put in a simple logfile.
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
51 echo "(already installed from previous run)"
55 # Delete potential conflicts
57 pkg_delete -r "$pkgwild"
59 # If we already have a binary package just install
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}"
71 # We need to build the package.
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.
76 foreach i ( `bmake show-var VARNAME=CONFLICTS` )
77 echo "DELETING CONFLICTING PACKAGE: $i"
81 # If the dist file checksum fails and the dist file is over
82 # 4 hours old we re-download it.
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
95 # To ensure a clean build deinstall anything that
96 # may cause our build repackage to fail.
98 # Clean after repackaging to keep the work topology footprint small.
100 # We create a binary package and then pkg_add it.
102 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
103 bmake repackage SKIP_LICENSE_CHECK=yes
104 if ( $status == 0 ) then
105 bmake clean SKIP_LICENSE_CHECK=yes
106 setenv PKG_PATH /usr/pkgsrc/packages/All
107 echo "pkg_add -f ${pkgname}"
108 pkg_add -f ${pkgname}
112 # comment this bmake out if you want to keep the work dir
115 bmake clean SKIP_LICENSE_CHECK=yes