summaryrefslogtreecommitdiff
path: root/mk/bulk/pre-build
blob: 5ae97e679b6beaefbfaa425618a53b6d45b70446 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh
# $NetBSD: pre-build,v 1.18 2002/03/14 00:13:29 hubertf Exp $
#
# Clean up system to be ready for bulk pkg build
#
# (c) 2000 Hubert Feyrer, All Rights Reserved.
#

#set -v		# Debug

# Pull in USR_PKGSRC, CVS_USER:
if [ -f "$BULK_BUILD_CONF" ]; then
    . $BULK_BUILD_CONF
else
    . `dirname $0`/build.conf
fi

PRUNEDISTFILES=${PRUNEDISTFILES:-"yes"}
PRUNEPACKAGES=${PRUNEPACKAGES:-"no"}
PRUNELINKS=${PRUNEPACKAGES:-"no"}
PRUNEDISTFILES=`echo $PRUNEDISTFILES | tr "[:lower:]" "[:upper:]"`
PRUNEPACKAGES=`echo $PRUNEPACKAGES | tr "[:lower:]" "[:upper:]"`
PRUNELINKS=`echo $PRUNELINKS | tr "[:lower:]" "[:upper:]"`

# extract the name of the files used for the build log and broken build log.
# these have defaults set by bsd.bulk-pkg.mk and may be overridden in /etc/mk.conf
export BROKENF=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=BROKENFILE )`;
if [ "$BROKENF" = "" ]; then
	echo "Had problems determining the name of the .broken.files"
	exit 1
fi
BLDLOG=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=BUILDLOG )`;
if [ "$BLDLOG" = "" ]; then
	echo "Had problems determining the name of the .make.files"
	exit 1
fi



#
# Clean out everything and it's mother
#
echo Removing all installed packages 

if [ -d /var/db/pkg ]; then
	cd /var/db/pkg
	for pkg in *
	do
		if `pkg_info -qe $pkg`; then 
			echo pkg_delete -r $pkg
			pkg_delete -r $pkg
		fi
	done
	# this should have removed everything.  Now force any broken pkgs
	# to deinstall
	for pkg in *
	do
		if `pkg_info -qe $pkg`; then 
			echo pkg_delete -f $pkg
			pkg_delete -f $pkg
		fi
	done
	
	# We've tried our best to get rid of the pkgs, now do it the hard way
	# If it wasn't for stuff in $X11BASE, I wouldn't have hard feelings
	# about this!
	rm -fr *
fi

LOCALBASE=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=LOCALBASE )`;
X11BASE=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=X11BASE )`;
	
# General cleanout - easy!
cd $LOCALBASE && rm -fr * && rm -fr .??*

# Stuff known to be broken
rm -fr $X11BASE/share/gimp
rm -fr $X11BASE/share/gnome
rm -fr $X11BASE/share/kde
rm -fr $X11BASE/share/netscape
rm -fr /var/tmp/inst*
rm -fr $X11BASE/lib/libgimp*	# gimp doesn't build with old libs around
rm -fr /nonexistant		# broken useradd on pop3d
rm -fr /home/majordom		# mail/majordomo pkg
rm -fr /home/nut		# sysutils/ups-net
rm -fr /var/wwwoffle		# www/wwwoffle


# Clean up state files
cd ${USR_PKGSRC}
rm -f $BROKENF */*/$BROKENF
rm -f $BLDLOG */*/$BLDLOG
rm -f .start.${arch}




#
# Install cvs package and do a cvs update here
#
if [ "$CVS_USER" != "" ]; then
	if [ ! -f /usr/bin/cvs ]; then
		echo Installing required cvs pkgs for CVS update
		( cd ${USR_PKGSRC}/devel/cvs ; make bulk-install )
	fi
	if [ ! -f /usr/bin/ssh ]; then
		echo Installing required ssh pkgs for CVS update
		( cd ${USR_PKGSRC}/security/ssh ; make bulk-install )
	fi
	echo Performing CVS update - this will take some time
	su - ${CVS_USER} -c 'stty sane ; setenv CVS_RSH ssh ; cd '${USR_PKGSRC}' ; cvs -q update -Pd'
	echo CVS update done.
fi


#
# Remove old/broken distfiles and binary packages
#
DISTDIR=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=DISTDIR )`;
PACKAGES=`( cd $USR_PKGSRC/pkgtools/pkglint ; make show-var VARNAME=PACKAGES )`;

if [ $PRUNEDISTFILES = "YES" ]; then
	echo "Removing old/broken distfiles"
	( cd ${USR_PKGSRC}/pkgtools/pkglint ; make PRECLEAN=yes bulk-install )
	lintpkgsrc -K $PACKAGES -P $USR_PKGSRC -M $DISTDIR -o -m -r
	echo done.
else
	echo "Skipping distfile pruning."
fi

if [ $PRUNEPACKAGES = "YES" ]; then
	echo "Removing old (out of date) binary packages"
	( cd ${USR_PKGSRC}/pkgtools/pkglint ; make PRECLEAN=yes bulk-install )
	lintpkgsrc -K $PACKAGES -P $USR_PKGSRC -M $DISTDIR -p -r
	echo done.
else
	echo "Skipping packages pruning."
fi

if [ $PRUNELINKS = "YES" ]; then
	echo "Checking for and removing orphaned packages links"
	find $PACKAGES -type l -print |  \
	while read f 
	do
		if [ ! -d $f -a ! -f $f ]; then
			echo "Removing orphaned link:  \"$f\""
			rm $f
		fi
	done
	echo done.
else
	echo "Skipping pruning of packages links."
fi


if [ -f mk/bulk/pre-build.local ]; then
	. mk/bulk/pre-build.local
fi

touch .start.${arch}