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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
Calculate dependencies in a chroot
Index: lib/makemake
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/makemake,v
retrieving revision 1.48
diff -u -r1.48 makemake
--- lib/makemake 6 Nov 2012 21:55:47 -0000 1.48
+++ lib/makemake 5 Oct 2013 16:30:30 -0000
@@ -135,11 +135,12 @@
my (
%pkgdir, %pkgdeps, %pkgedeps, %pkgpdeps, %pkgfdeps,
%pkgbdeps, %pkgrdeps, @duds, $portbase, $makecache,
- %pkgtdeps, %pkgpkgdeps,
+ %pkgtdeps, %pkgpkgdeps, $chroot,
);
$portbase = $ENV{'PORTSDIR'};
-$makecache = new Tinderbox::MakeCache($portbase, $ENV{'PKGSUFFIX'});
+$chroot = $ENV{'CHROOT'};
+$makecache = new Tinderbox::MakeCache($portbase, $chroot, $ENV{'PKGSUFFIX'});
while (scalar(@PORTS)) {
my $port = shift @PORTS;
@@ -148,7 +149,7 @@
next if (defined($pkgdir{$portdir}));
- $tportdir = "$portbase/$portdir";
+ $tportdir = "$chroot$portbase/$portdir";
if (!-d $tportdir) {
print STDERR "ERROR: Directory $tportdir does not exist.\n";
if (defined($pkgdeps{$portdir})
Index: lib/tc_command.pl
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.pl,v
retrieving revision 1.184
diff -u -r1.184 tc_command.pl
--- lib/tc_command.pl 28 Apr 2013 20:05:40 -0000 1.184
+++ lib/tc_command.pl 5 Oct 2013 16:30:31 -0000
@@ -1536,7 +1536,8 @@
sub addPortToOneBuild {
my $build = $ds->getBuildByName($opts->{'b'});
my $makecache =
- new Tinderbox::MakeCache($ENV{'PORTSDIR'}, $ENV{'PKGSUFFIX'});
+ new Tinderbox::MakeCache($ENV{'PORTSDIR'}, $ENV{'CHROOT'},
+ $ENV{'PKGSUFFIX'});
my @bports = ();
if (!$opts->{'d'}) {
@@ -3414,12 +3415,14 @@
my $cache = shift;
my $deps = shift;
- my $portdir = $ENV{'PORTSDIR'} . "/" . $port;
+ my $portsdir = $ENV{'CHROOT'} . $ENV{'PORTSDIR'};
+
+ my $portdir = $portsdir . "/" . $port;
return undef if (!-d $portdir);
# Canonicalize the port directory.
$port = abs_path($portdir);
- $port =~ s|$ENV{'PORTSDIR'}/||;
+ $port =~ s|$portsdir/||;
if (defined($deps)) {
my @list;
Index: lib/tc_command.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.sh,v
retrieving revision 1.175
diff -u -r1.175 tc_command.sh
--- lib/tc_command.sh 7 Aug 2013 18:25:52 -0000 1.175
+++ lib/tc_command.sh 5 Oct 2013 16:30:32 -0000
@@ -1385,7 +1385,7 @@
cleanDirs ${buildName} ${BUILD_DIR}
if [ "${MD_FSTYPE}" = "ufs" -o "${MD_FSTYPE}" = "zfs" ]; then
- if [ -n "${MD_SIZE}" -a ${MD_SIZE%[a-zA-Z]} -gt 0 ]; then
+ if [ -n "${MD_SIZE}" ] && [ ${MD_SIZE%[a-zA-Z]} -gt 0 ]; then
# setup md (ramdisk) backing for the build
mdconfig -a -t swap -s ${MD_SIZE} > /tmp/tinderbuild_md.${build}
read MD_UNIT </tmp/tinderbuild_md.${build}
@@ -1400,7 +1400,7 @@
fi
fi
elif [ "${MD_FSTYPE}" = "tmpfs" ]; then
- if [ -n "${MD_SIZE}" -a ${MD_SIZE%[a-zA-Z]} -gt 0 ]; then
+ if [ -n "${MD_SIZE}" ] && [ ${MD_SIZE%[a-zA-Z]} -gt 0 ]; then
mount -t tmpfs -o size=${MD_SIZE} tmpfs ${BUILD_DIR}
else
mount -t tmpfs tmpfs ${BUILD_DIR}
@@ -1416,7 +1416,7 @@
execute_hook "postBuildExtract" "BUILD=${buildName} DESTDIR=${BUILD_DIR} JAIL=${jailName} PB=${pb} RC=0"
# Finalize environment
- cp -f /etc/resolv.conf ${BUILD_DIR}/etc
+ cp /etc/resolv.conf ${BUILD_DIR}/etc || touch ${BUILD_DIR}/etc/resolv.conf
return 0
}
@@ -1957,7 +1957,16 @@
${tc} updatePortsTree -p ${portstree}
fi
- # Create makefile if required
+ # Set up the chrooted environment
+ osmajor=$(echo ${jail} | sed -E -e 's|(^[[:digit:]]+).*$|\1|')
+ if [ ${osmajor} -lt 6 ]; then
+ echo "tinderbuild: unhandled OS version: ${osmajor}"
+ tinderbuild_cleanup 1
+ fi
+
+ tinderbuild_setup
+
+ # Create Makefile if required
if [ ${skipmake} -eq 0 ]; then
echo "tinderbuild: creating makefile..."
@@ -1966,19 +1975,16 @@
(
export PORTBUILD_ARGS="$(echo ${pbargs})"
buildenvNoHost ${build}
- if ! requestMount -t portstree -p ${portstree}; then
- echo "tinderbuild: cannot mount portstree: ${portstree}"
- exit 1
- fi
- env PORTSDIR=$(tinderLoc portstree ${portstree})/ports \
+ buildenv ${jail} ${portstree} ${build}
+ HOST_WORKDIR=$(${tc} configGet | \
+ awk -F= '/^HOST_WORKDIR/ {print $2}')
+ env PORTSDIR=/a/ports \
+ CHROOT=$(tinderLoc buildroot ${build}) \
$(tinderLoc scripts lib/makemake) ${noduds} ${build} ${ports}
)
if [ $? -ne 0 ]; then
echo "tinderbuild: failed to generate Makefile for ${build}"
- cleanupMounts -t portstree -p ${portstree}
tinderbuild_cleanup 1
- else
- cleanupMounts -t portstree -p ${portstree}
fi
fi
@@ -1987,15 +1993,6 @@
tinderbuild_cleanup 0
fi
- # Set up the chrooted environment
- osmajor=$(echo ${jail} | sed -E -e 's|(^[[:digit:]]+).*$|\1|')
- if [ ${osmajor} -lt 6 ]; then
- echo "tinderbuild: unhandled OS version: ${osmajor}"
- tinderbuild_cleanup 1
- fi
-
- tinderbuild_setup
-
# Seatbelts off. Away we go.
${tc} updateBuildStatus -b ${build} -s PORTBUILD
tinderbuild_phase 0 ${jobs} ${pkgDir}
@@ -2045,7 +2042,11 @@
addPortToBuild_cleanup () {
jail=$1
portsTree=$2
+ build=$3
+ cleanupMounts -t buildports -b ${build}
+ cleanupMounts -t buildsrc -b ${build}
+ cleanupMounts -t buildoptions -b ${build}
cleanupMounts -t jail -j ${jail}
cleanupMounts -t portstree -p ${portsTree}
}
@@ -2070,7 +2071,29 @@
exit 1
fi
- trap "addPortToBuild_cleanup ${jail} ${portsTree}" 1 2 3 9 10 11 15
+ # Extracting the Jail tarball takes ages on some systems, so we can
+ # pretty safely (for these purposes) reuse the extraction as long as
+ # resolv.conf is newer than the tarball (resolv.conf is created
+ # by makeBuild)
+ HOST_WORKDIR=$(${tc} configGet | awk -F= '/^HOST_WORKDIR/ {print $2}')
+ if [ $(tinderLoc jailtarball ${jail}) -ot \
+ $(tinderLoc buildroot ${build})/etc/resolv.conf ]; then
+ echo "addPortToBuild: recent jail tarball exists; no need to reextract"
+ else
+ echo "addPortToBuild: extracting jail tarball to calculate dependencies inside"
+ makeBuild -b ${build}
+ fi
+
+ if ! requestMount -t buildports -b ${build} -r -n; then
+ echo "addPortToBuild: cannot mount ports source inside ${build}"
+ exit 1
+ fi
+ if ! requestMount -t buildsrc -b ${build} -r -n; then
+ echo "addPortToBuild: cannot mount base source inside ${build}"
+ exit 1
+ fi
+
+ trap "addPortToBuild_cleanup ${jail} ${portsTree} ${build}" 1 2 3 9 10 11 15
# Save TERM since we need that for OPTIONS
save_TERM=${TERM}
@@ -2082,22 +2105,30 @@
buildenv ${jail} ${portsTree} ${build}
buildenvNoHost ${build}
- export PORTSDIR=$(tinderLoc portstree ${portsTree})/ports
- if [ -z "${portDir}" ]; then
- ${tc} addPortToOneBuild -b ${build} ${norecurse}
- else
- if [ ! -d ${PORTSDIR}/${portDir} ]; then
- echo "addPort: Unknown port ${portDir}"
- exit 1
- fi
- ${tc} addPortToOneBuild -b ${build} -d ${portDir} ${norecurse}
+ if [ ${options} -eq 1 -a ${OPTIONS_ENABLED} -eq 1 ]; then
+ mkdir -p $(tinderLoc options ${build}) \
+ $(tinderLoc buildoptions ${build})
+ if ! requestMount -t buildoptions -b ${build} \
+ -s $(tinderLoc options ${build}) -n; then
+ echo "addPortToBuild: cannot mount options inside ${build}"
+ exit 1
+ fi
fi
+
+ export PORTSDIR=/a/ports
+ export CHROOT=$(tinderLoc buildroot ${build})
+
+ if [ -n "${portDir}" ] && [ ! -d ${CHROOT}/${PORTSDIR}/${portDir} ]; then
+ echo "addPort: Unknown port ${portDir}"
+ exit 1
+ fi
+
if [ ${options} -eq 1 -a ${OPTIONS_ENABLED} -eq 1 ]; then
pdirs=""
if [ -z "${portDir}" ]; then
pdirs=$(${tc} getPortsForBuild -b ${build} 2>/dev/null)
else
- pdirs="${PORTSDIR}/${portDir}"
+ pdirs="${portDir}"
fi
rmconfig=true
if [ ${cleanOptions} -eq 1 ]; then
@@ -2108,28 +2139,38 @@
fi
fi
for pdir in ${pdirs}; do
- if [ -d ${pdir} ]; then
+ if [ -d ${CHROOT}${PORTSDIR}/${pdir} ]; then
export TERM=${save_TERM}
+ if ! cp /usr/local/bin/dialog4ports-static ${CHROOT}/; then
+ echo "In order to customise OPTIONS, you must install"
+ echo "ports-mgmt/dialog4ports-static."
+ break
+ fi
read -p "Generating options for ${build}; hit Enter to continue..." key
echo ""
if [ -z "${norecurse}" ]; then
- ( cd ${pdir} && ${rmconfig} \
- && make -k config-recursive )
+ chroot ${CHROOT} /bin/sh -c \
+ "cd ${PORTSDIR}/${pdir} && ${rmconfig} && \
+ make -k DIALOG4PORTS=/dialog4ports-static \
+ config-recursive"
else
- ( cd ${pdir} && ${rmconfig} \
- && make config )
+ chroot ${CHROOT} /bin/sh -c \
+ "cd ${PORTSDIR}/${pdir} && ${rmconfig} && \
+ make DIALOG4PORTS=/dialog4ports-static config"
fi
fi
done
fi
+ ${tc} addPortToOneBuild -b ${build} ${portDir:+-d} ${portDir} ${norecurse}
+
if [ -n "${save_SRCBASE}" ]; then
export SRCBASE=${save_SRCBASE}
else
unset SRCBASE
fi
- addPortToBuild_cleanup ${jail} ${portsTree}
+ addPortToBuild_cleanup ${jail} ${portsTree} ${build}
}
addPort () {
Index: lib/tinderlib.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tinderlib.sh,v
retrieving revision 1.83
diff -u -r1.83 tinderlib.sh
--- lib/tinderlib.sh 10 Jun 2013 16:49:51 -0000 1.83
+++ lib/tinderlib.sh 5 Oct 2013 16:30:32 -0000
@@ -498,9 +498,7 @@
save_IFS=${IFS}
IFS='
'
- # Allow SRCBASE to be overridden
- eval "export SRCBASE=${SRCBASE:-`realpath $(tinderLoc jail ${jail})/src`}" \
- >/dev/null 2>&1
+ # Do not set SRCBASE here-- we use chroots nowadays so /usr/src is there
# Set ARCH (needed for cross-building)
export ARCH=$(${tc} getJailArch -j ${jail})
@@ -524,13 +522,6 @@
eval "export __MAKE_CONF=${jailBase}/make.conf" >/dev/null 2>&1
eval "export LOCALBASE=/nonexistentlocal" >/dev/null 2>&1
eval "export PKG_DBDIR=/nonexistentdb" >/dev/null 2>&1
- if [ x"${OPTIONS_ENABLED}" != x"1" ]; then
- eval "export PORT_DBDIR=/nonexistentportdb" >/dev/null 2>&1
- else
- optionsDir=$(tinderLoc options ${build})
-
- eval "export PORT_DBDIR=${optionsDir}" >/dev/null 2>&1
- fi
eval "export LINUXBASE=/nonexistentlinux" >/dev/null 2>&1
eval "unset DISPLAY" >/dev/null 2>&1
}
Index: lib/Tinderbox/MakeCache.pm
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/Tinderbox/MakeCache.pm,v
retrieving revision 1.12
diff -u -r1.12 MakeCache.pm
--- lib/Tinderbox/MakeCache.pm 4 Mar 2012 12:53:08 -0000 1.12
+++ lib/Tinderbox/MakeCache.pm 5 Oct 2013 16:30:32 -0000
@@ -49,6 +49,7 @@
CACHE => undef,
SEEN => undef,
BASEDIR => shift,
+ CHROOT => shift,
}, $name;
$self;
@@ -67,7 +68,10 @@
$tmp = '-V ' . join(' -V ', @makeTargets);
my $dir = $self->{BASEDIR} . '/' . $port;
- @ret = split("\n", `cd $dir && make $tmp`);
+ my $cmd = "cd $dir && make $tmp";
+ $cmd = "chroot $self->{CHROOT} /bin/sh -c '$cmd'";
+
+ @ret = split("\n", `$cmd`);
foreach $tmp (@makeTargets) {
$self->{CACHE}->{$port}{$tmp} = shift @ret;
? .fslckout
? .fslckout-mjFA3F63973
Index: lib/tc_command.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.sh,v
retrieving revision 1.176
diff -u -r1.176 tc_command.sh
--- lib/tc_command.sh 7 Oct 2013 16:36:54 -0000 1.176
+++ lib/tc_command.sh 7 Oct 2013 18:34:20 -0000
@@ -2049,6 +2049,7 @@
cleanupMounts -t buildoptions -b ${build}
cleanupMounts -t jail -j ${jail}
cleanupMounts -t portstree -p ${portsTree}
+ cleanenv
}
addPortToBuild () {
? .fslckout
? .fslckout-mjFA3F63973
Index: lib/tc_command.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.sh,v
retrieving revision 1.177
diff -u -r1.177 tc_command.sh
--- lib/tc_command.sh 8 Oct 2013 16:06:48 -0000 1.177
+++ lib/tc_command.sh 12 Oct 2013 11:27:28 -0000
@@ -1973,6 +1973,8 @@
# Need to do this in a subshell so as to only hide the host
# environment during makefile creation
(
+ # Everything is done in chroot, so SRCBASE is relative to /
+ export SRCBASE=/usr/src
export PORTBUILD_ARGS="$(echo ${pbargs})"
buildenvNoHost ${build}
buildenv ${jail} ${portstree} ${build}
@@ -2102,6 +2104,8 @@
if [ -n "${SRCBASE}" ]; then
save_SRCBASE=${SRCBASE}
fi
+ # Everything is done in chroot, so SRCBASE is relative to /
+ export SRCBASE=/usr/src
buildenv ${jail} ${portsTree} ${build}
buildenvNoHost ${build}
Index: lib/tinderlib.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tinderlib.sh,v
retrieving revision 1.85
diff -u -r1.85 tinderlib.sh
--- lib/tinderlib.sh 7 Oct 2013 16:36:54 -0000 1.85
+++ lib/tinderlib.sh 12 Oct 2013 11:27:29 -0000
@@ -506,7 +506,9 @@
save_IFS=${IFS}
IFS='
'
- # Do not set SRCBASE here-- we use chroots nowadays so /usr/src is there
+ # Allow SRCBASE to be overridden
+ eval "export SRCBASE=${SRCBASE:-`realpath $(tinderLoc jail ${jail})/src`}" \
+ >/dev/null 2>&1
# Set ARCH (needed for cross-building)
export ARCH=$(${tc} getJailArch -j ${jail})
|