summaryrefslogtreecommitdiff
path: root/mk/bulk/build
blob: de0161977ed99165277303bb51fb80cf6be49896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
# $NetBSD: build,v 1.10 2001/03/19 11:25:39 dmcmahill Exp $
#
# Do builk build
#
# (c) 2000 Hubert Feyrer, All Rights Reserved.
#

echo Bulk build started: `date`
echo ""

# Pull in ADMIN etc.:
if [ -f "$BULK_BUILD_CONF" ]; then
    . $BULK_BUILD_CONF
else
	conf=`dirname $0`/build.conf
	if [ -f "$conf" ]; then
		. $conf
	else
		echo "$0: Cannot find config file $conf, aborting."
		exit 1
	fi
fi

if [ "$http_proxy" != "" ]; then
	echo "Using HTTP proxy $http_proxy"
	export http_proxy
fi
if [ "$ftp_proxy" != "" ]; then
	echo "Using FTP proxy $ftp_proxy"
	export ftp_proxy
fi
echo ""

unset DISPLAY		# allow sane failure for gimp, xlispstat

cd ${USR_PKGSRC}

if [ "$1" = "restart" ]; then
	echo Restarting - skipping pre-build script
else
	sh mk/bulk/pre-build	# make veryveryclean :)
fi

cd pkgtools/pkglint
DEPENDSTREEFILE=`make show-var VARNAME=DEPENDSTREEFILE`
DEPENDSFILE=`make show-var VARNAME=DEPENDSFILE`
SUPPORTSFILE=`make show-var VARNAME=SUPPORTSFILE`
INDEXFILE=`make show-var VARNAME=INDEXFILE`
ORDERFILE=`make show-var VARNAME=ORDERFILE`
cd ${USR_PKGSRC}	

# get the list of packages which should always be installed during the build
cd ${USR_PKGSRC}/pkgtools/pkglint
BULK_PREREQ=`make show-var VARNAME=BULK_PREREQ`
cd ${USR_PKGSRC}

# install prerequisite packages.  Note:  we do this _before_ the depends tree
# because some packages like xpkgwedge only become DEPENDS if its installed
echo "Installing prerequisite packages specified with BULK_PREREQ..."
for pkgdir in $BULK_PREREQ
do
	echo $pkgdir
	# make sure its installed _and_ packaged
	cd ${USR_PKGSRC}/$pkgdir && make bulk-install && make bulk-package && make clean
done

# Figure out optimal build order.
cd ${USR_PKGSRC}
if [ "$1" != "restart" ]; then
	echo "Building dependency tree (this may take a while)..."
	sh mk/bulk/printdepends > $DEPENDSTREEFILE

	echo "Sorting build order..."
	tsort $DEPENDSTREEFILE > $ORDERFILE

	echo "Generating up and down dependency files..."
	./mk/bulk/tflat -u $DEPENDSTREEFILE > $SUPPORTSFILE
	./mk/bulk/tflat -d $DEPENDSTREEFILE > $DEPENDSFILE

	echo "Generating package name <=> package directory cross reference file (this may take a while)..."
	sh mk/bulk/printindex > $INDEXFILE

fi

echo "Starting actual build using the order specified in $ORDERFILE..."
cd ${USR_PKGSRC}
nice -n 20 make \
		USE_BULK_CACHE=yes \
		SPECIFIC_PKGS=1 \
		GROUP_SPECIFIC_PKGS="`cat $ORDERFILE | tr '\012' ' '`" \
		bulk-package | sed 's/^/'`uname -p`'> /g'

echo "Build finished.  Removing all installed packages left over from build..."

for pkgname in `pkg_info -e \*`
do
	if `pkg_info -qe $pkgname`; then 
		pkgdir=`grep " $pkgname " $INDEXFILE | awk '{print $1}'`	
		case "${BULK_PREREQ}" in 
			*$pkgdir* ) 
				echo "Keeping BULK_PREREQ: $pkgname ($pkgdir)" ;
				;; 
			* ) 
				echo pkg_delete -r $pkgname
				pkg_delete -r $pkgname
				if `pkg_info -qe $pkgname` ; then
					echo "$pkgname ($pkgdir) did not deinstall nicely.  Forcing the deinstall"
					pkg_delete -f $pkgname || true 
				fi 
				;; 
		esac
	fi
done

echo "Post processing bulk build results..."

#rm $DEPENDSTREEFILE $DEPENDSFILE $SUPPORTSFILE $INDEXFILE $ORDERFILE

# Perl was wiped, reinstall it!
( cd lang/perl5-base ; make bulk-install )
perl mk/bulk/post-build | mail -s "pkgsrc/`uname -p` bulk build results `date +%F`" $ADMIN

# Done!
echo ""
echo Bulk build ended: `date`