blob: e4a9525efbbd0c47c93d4da881c80bd8b3656c6a (
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
#!/bin/sh
# usage: $0 DIRNAME PHASE
# PHASE is 1 (checksum) or 2 (package)
mountprocfs() {
arch=$1
if [ ${arch} = "i386" ]; then
# JDK ports need linprocfs :(
mkdir -p /compat/linux/proc
mount_linprocfs linprocfs /compat/linux/proc
fi
}
umountprocfs() {
arch=$1
if [ ${arch} = "i386" ]; then
umount -f /compat/linux/proc 2> /dev/null > /dev/null
fi
}
cleanup() {
status=$1
cd ${dir}
keep_distfiles=$(make -V ALWAYS_KEEP_DISTFILES)
distdir=$(make -V DISTDIR)
if [ -z "${keep_distfiles}" -a ! -z "${distdir}" ]; then
rm -rf ${distdir}/*
fi
if [ -e ${dir}/.keep ]; then
cd ${dir}
objdir=$(make -V WRKDIR)
tar cfjC /tmp/work.tbz ${objdir}/.. work
fi
cat /tmp/make.log${status}
echo 1 > /tmp/status
echo "================================================================"
echo -n "build of ${dir} ended at "
date
exit 0
}
add_pkg() {
pkgs=$*
echo add_pkg $pkgs
cd /tmp/depends
export PKG_PATH=/tmp/depends
if [ ! -z "${pkgs}" ]; then
arch=$(uname -m)
umountprocfs ${arch}
echo "adding dependencies"
for i in $pkgs; do
echo "pkg_add $i"
base=$(basename $i .tgz)
base=$(basename $base .tbz)
if pkg_info -q -e $base; then
echo "skipping $base, already added"
else
if ! pkg_add $i; then
echo "error in dependency $i, exiting"
echo "1" > /tmp/status
exit 1
fi
fi
done
mountprocfs ${arch}
fi
}
del_pkg() {
pkgs=$*
cd /tmp/depends
export PKG_PATH=/tmp/depends
if [ ! -z "${pkgs}" ]; then
unset delpkg
for i in $pkgs; do
base=$(basename $i .tgz)
base=$(basename $base .tbz)
if ! pkg_info -q -e $base; then
echo "skipping $base, already deleted"
else
delpkg="${base} ${delpkg}"
fi
done
echo "Deleting $delpkg"
if ! (echo ${delpkg} | xargs pkg_delete -f); then
echo "error in pkg_delete, exiting"
echo "1" > /tmp/status
exit 1
fi
fi
}
dir=$1
phase=$2
ED=$3
PD=$4
FD=$5
BD=$6
RD=$7
if [ $phase = 1 ]; then
cd $dir || exit 1
echo "maintained by: $(make maintainer)"
echo "port directory: ${dir}"
echo "build started at $(date)"
echo "FETCH_DEPENDS=${FD}"
echo "PATCH_DEPENDS=${PD}"
echo "EXTRACT_DEPENDS=${ED}"
echo "BUILD_DEPENDS=${BD}"
echo "RUN_DEPENDS=${RD}"
add_pkg $FD
#Allow ports to notice they're being run on bento
export PACKAGE_BUILDING=1
cd $dir || exit 1
pkgname=$(make package-name)
echo "================================================================"
echo "====================<phase 1: make checksum>===================="
if /pnohang $TIMEOUT /tmp/make.log1 ${pkgname} make checksum; then
cat /tmp/make.log1
echo "0" > /tmp/status
else
cleanup 1
fi
else
cd $dir || exit 1
pkgname=$(make package-name)
echo "================================================================"
echo "====================<phase 2: make extract>===================="
add_pkg ${ED}
cd $dir
/pnohang $TIMEOUT /tmp/make.log2 ${pkgname} make extract || cleanup 2
cat /tmp/make.log2
del_pkg ${ED}
echo "================================================================"
echo "====================<phase 3: make patch>===================="
add_pkg ${PD}
cd $dir
/pnohang $TIMEOUT /tmp/make.log3 ${pkgname} make patch || cleanup 3
cat /tmp/make.log3
del_pkg ${PD}
echo "================================================================"
echo "====================<phase 4: make build>===================="
add_pkg ${BD}
xvfb=0
if which -s Xvfb; then
xvfb=1
pid=$(echo $$ % 32768 | bc)
X11BASE=$(which Xvfb | sed -e 's./bin/Xvfb..')
Xvfb :${pid} -fp ${X11BASE}/lib/X11/fonts/misc &
DISPLAY=:${pid}
export DISPLAY
fi
cd $dir
/pnohang $TIMEOUT /tmp/make.log4 ${pkgname} make build || cleanup 4
cat /tmp/make.log4
echo "================================================================"
echo "====================<phase 5: make package>===================="
add_pkg ${RD}
cat > /tmp/mtree.exclude <<EOF
./root/*
./var/*
./tmp/*
./etc/make.conf.bak
./etc/make.conf
./work/*
./compat/linux/proc
EOF
mtree -X /tmp/mtree.exclude -xcn -k uid,gid,mode -p / > /tmp/mtree
cd $dir
if /pnohang $TIMEOUT /tmp/make.log5 ${pkgname} make package; then
cat /tmp/make.log5
echo "0" > /tmp/status
prefix=$(make -V PREFIX)
del_pkg ${pkgname}
mtree -X /tmp/mtree.exclude -x -f /tmp/mtree -p / | egrep -v '^(usr/local/var|usr/local/www/|usr/X11R6/lib/X11/xserver/SecurityPolicy|usr/local/share/nls/POSIX|usr/local/share/nls/en_US.US-ASCII|etc/services|compat |usr/X11R6 |etc/manpath.config|etc/.*.bak|usr/local/info/dir|usr/X11R6/lib/X11/fonts/.*/fonts\.|usr/X11R6/(include|share)/pixmaps|usr/local/lib/xemacs|usr/(X11R6|local)/man/..( |/man. )|usr/X11R6/lib/X11/fonts/TrueType )' > /tmp/list3
if [ -s /tmp/list3 ]; then
cd /
grep ' extra$' /tmp/list3 | awk '{print $1}' | xargs -J % find % -ls > /tmp/list4
grep ' missing$' /tmp/list3 > /tmp/list5
grep -vE ' (extra|missing)$' /tmp/list3 > /tmp/list6
if [ "x${NOPLISTCHECK}" = "x" ]; then
if grep -qE 'usr/(local|X11R6)/(bin/|include/|man/|sbin/|share/|share/|lib/|libdata/|libexec/)' /tmp/list4; then
echo "1" > /tmp/status
fi
if [ -s /tmp/list5 ]; then
echo "1" > /tmp/status
fi
fi
echo "================================================================"
fi
# BUILD_DEPENDS need to be present at install-time, e.g. gmake
# Concatenate and remove duplicates
BRD=$(echo $BD $RD | tr ' ' '\n' | sort -u | tr '\n' ' ')
del_pkg ${BRD}
cd /var/db/pkg
if [ $(echo $(echo * | wc -c)) != 2 ]; then
echo "leftover packages:" *
del_pkg *
fi
echo
echo "=== Checking filesystem state"
if [ -s /tmp/list4 ]; then
echo "list of extra files and directories in / (not present before this port was installed but present after it was deinstalled)"
cat /tmp/list4
fi
if [ -s /tmp/list5 ]; then
echo "list of files present before this port was installed but missing after it was deinstalled)"
cat /tmp/list5
fi
if [ -s /tmp/list6 ]; then
echo "list of filesystem changes from before and after port installation and deinstallation"
cat /tmp/list6
if [ "x${NOPLISTCHECK}" = "x" ]; then
echo "1" > /tmp/status
fi
fi
else
cleanup 5
fi
if [ ${xvfb} = 1 ]; then
kill $(jobid %1)
fi
cd ${dir}
keep_distfiles=$(make -V ALWAYS_KEEP_DISTFILES)
distdir=$(make -V DISTDIR)
if [ -z "${keep_distfiles}" -a ! -z "${distdir}" ]; then
rm -rf ${distdir}/*
fi
if [ -e ${dir}/.keep ]; then
cd ${dir}
objdir=$(make -V WRKDIR)
tar cfjC /tmp/work.tbz ${objdir}/.. work
fi
echo "================================================================"
echo -n "build of ${dir} ended at "
date
fi
exit 0
|