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 set logname = "$argv[1]"
9 # We do not want to interfere with builds of other versions
10 # of the same package, use a temporary lock file to prevent a
13 if ( $#argv == 1 ) then
14 set pkgwild = "`bmake show-var VARNAME=PKGWILDCARD`.lck"
15 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
17 if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
18 if ( -f /tmp/logs/good/$logname ) then
19 rm -f /tmp/logs/run/$logname
20 echo "FASTBULK QUICK ${logname}: `date`" \
21 >> /tmp/logs/good/$logname
22 echo "FASTBULK: Package already exists, will not build" \
23 >> /tmp/logs/good/$logname
25 echo "FASTBULK: Package already exists, will not build"
30 mkdir -p /tmp/track/locks
31 echo "FASTBULK START ${argv[1]}: `date`"
32 lockf "/tmp/track/locks/$pkgwild" /tmp/track/dobuild ${argv[1]} "$pkgwild"
33 if ( $status == 0 ) then
34 echo "FASTBULK SUCCESS ${argv[1]}: `date`"
37 echo "FASTBULK FAILURE ${argv[1]}: `date`"
38 find /var/db/pkg/$pkgname -name '*.core' -delete
39 rmdir /var/db/pkg/$pkgname >& /dev/null
44 # Get the package name and clean up any garbage that might
45 # interfere with the build.
47 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
48 set pkgwild = "$argv[2]"
51 # Make sure /var/db/pkg/ does not have any .core files messing it up,
52 # remove the recorded installation if it becomes empty.
54 find /var/db/pkg/$pkgname -name '*.core' -delete
55 rmdir /var/db/pkg/$pkgname >& /dev/null
57 # Check if already installed, prevent overwrite of
58 # previous run's logfile if it exists, by deleting
59 # the current run file. Else put in a simple logfile.
61 pkg_info -q -e $pkgname
62 if ( $status == 0 ) then
63 if ( -f /tmp/logs/good/$logname ) then
64 rm -f /tmp/logs/run/$logname
66 echo "(already installed from previous run)"
70 # Delete potential conflicts
72 pkg_delete -r "$pkgwild"
74 # If we already have a binary package just install
77 if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
78 echo "(found in /usr/pkgsrc/packages)"
79 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
80 setenv PKG_PATH /usr/pkgsrc/packages/All
81 echo "pkg_add -f ${pkgname}"
86 # We need to build the package.
88 # Delete any conflicting installed packages or the one we want to build
89 # will refuse to build. The binary package files are left intact.
91 foreach i ( `bmake show-var VARNAME=CONFLICTS` )
92 echo "DELETING CONFLICTING PACKAGE: $i"
96 # If the dist file checksum fails and the dist file is over
97 # 4 hours old we re-download it.
101 set distfiles = "`bmake -V '${dollar}{DISTFILES}'`"
102 bmake checksum SKIP_LICENSE_CHECK=yes
103 if ( $status != 0 ) then
104 echo "Deleting distfiles ( $distfiles ) if over 4h old"
105 foreach dfile ( $distfiles )
106 find /usr/pkgsrc/distfiles -name "$dfile" -mtime +4h -delete
110 # To ensure a clean build deinstall anything that
111 # may cause our build repackage to fail.
113 # Clean after repackaging to keep the work topology footprint small.
115 # We create a binary package and then pkg_add it.
117 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
118 bmake repackage SKIP_LICENSE_CHECK=yes
119 if ( $status == 0 ) then
120 bmake clean SKIP_LICENSE_CHECK=yes
121 setenv PKG_PATH /usr/pkgsrc/packages/All
122 echo "pkg_add -f ${pkgname}"
123 pkg_add -f ${pkgname}
124 if ( $status != 0 ) then
125 if ( -f ${PKG_PATH}/${pkgname}.tgz ) then
126 echo "FASTBULK WARNING: Cannot install due to probable conflicts"
127 echo " but the binary package DID build."
128 echo " Exiting w/code 0 to mark as successful."
136 # comment this bmake out if you want to keep the work dir
139 bmake clean SKIP_LICENSE_CHECK=yes