1 |
6f73c362
|
Renato Botelho
|
#!/bin/sh
|
2 |
|
|
#
|
3 |
|
|
# build.sh
|
4 |
|
|
#
|
5 |
|
|
# Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
6 |
|
|
#
|
7 |
|
|
# Redistribution and use in source and binary forms, with or without
|
8 |
|
|
# modification, are permitted provided that the following conditions are met:
|
9 |
|
|
#
|
10 |
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
11 |
|
|
# this list of conditions and the following disclaimer.
|
12 |
|
|
#
|
13 |
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
14 |
|
|
# notice, this list of conditions and the following disclaimer in
|
15 |
|
|
# the documentation and/or other materials provided with the
|
16 |
|
|
# distribution.
|
17 |
|
|
#
|
18 |
|
|
# 3. All advertising materials mentioning features or use of this software
|
19 |
|
|
# must display the following acknowledgment:
|
20 |
|
|
# "This product includes software developed by the pfSense Project
|
21 |
|
|
# for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
22 |
|
|
#
|
23 |
|
|
# 4. The names "pfSense" and "pfSense Project" must not be used to
|
24 |
|
|
# endorse or promote products derived from this software without
|
25 |
|
|
# prior written permission. For written permission, please contact
|
26 |
|
|
# coreteam@pfsense.org.
|
27 |
|
|
#
|
28 |
|
|
# 5. Products derived from this software may not be called "pfSense"
|
29 |
|
|
# nor may "pfSense" appear in their names without prior written
|
30 |
|
|
# permission of the Electric Sheep Fencing, LLC.
|
31 |
|
|
#
|
32 |
|
|
# 6. Redistributions of any form whatsoever must retain the following
|
33 |
|
|
# acknowledgment:
|
34 |
|
|
#
|
35 |
|
|
# "This product includes software developed by the pfSense Project
|
36 |
|
|
# for use in the pfSense software distribution (http://www.pfsense.org/).
|
37 |
|
|
#
|
38 |
|
|
# THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
39 |
|
|
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
40 |
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
41 |
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
42 |
|
|
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
43 |
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
44 |
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
45 |
|
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
46 |
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
47 |
|
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
48 |
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
49 |
|
|
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
50 |
|
|
#
|
51 |
|
|
|
52 |
|
|
set +e
|
53 |
|
|
usage() {
|
54 |
288bd310
|
Renato Botelho
|
echo "Usage $0 [options] [ iso | nanobsd | ova | nanobsd-vga | memstick | memstickserial | memstickadi | fullupdate | all | none ]"
|
55 |
6f73c362
|
Renato Botelho
|
echo " all = iso nanobsd nanobsd-vga memstick memstickserial memstickadi fullupdate"
|
56 |
288bd310
|
Renato Botelho
|
echo " none = upgrade only pkg repo"
|
57 |
6f73c362
|
Renato Botelho
|
echo " [ options ]: "
|
58 |
7d9c553c
|
Renato Botelho
|
echo " --flash-size|-f size(s) - a list of flash sizes to build with nanobsd i.e. '2g 4g'. Default: 2g"
|
59 |
6f73c362
|
Renato Botelho
|
echo " --no-buildworld|-c - Will set NO_BUILDWORLD NO_BUILDKERNEL to not build kernel and world"
|
60 |
|
|
echo " --no-cleanobjdir|--no-cleanrepos|-d - Will not clean FreeBSD object built dir to allow restarting a build with NO_CLEAN"
|
61 |
|
|
echo " --resume-image-build|-r - Includes -c -d and also will just move directly to image creation using pre-staged data"
|
62 |
|
|
echo " --setup - Install required repo and ports builder require to work"
|
63 |
2a5914c6
|
Renato Botelho
|
echo " --update-sources - Refetch FreeBSD sources"
|
64 |
fa7f03b4
|
Renato Botelho
|
echo " --rsync-repos - rsync pkg repos"
|
65 |
6f73c362
|
Renato Botelho
|
echo " --print-flags - Show current builder configuration"
|
66 |
|
|
echo " --clean-builder - clean all builder used data/resources"
|
67 |
|
|
echo " --build-kernels - build all configured kernels"
|
68 |
|
|
echo " --build-kernel argument - build specified kernel. Example --build-kernel KERNEL_NAME"
|
69 |
|
|
echo " --install-extra-kernels argument - Put extra kernel(s) under /kernel image directory. Example --install-extra-kernels KERNEL_NAME_WRAP"
|
70 |
ab943fc9
|
Renato Botelho
|
echo " --snapshots - Build snapshots and upload them to RSYNCIP"
|
71 |
919c8486
|
Renato Botelho
|
echo " --poudriere-snapshots - Update poudriere packages and send them to PKG_RSYNC_HOSTNAME"
|
72 |
6f73c362
|
Renato Botelho
|
echo " --enable-memorydisks - This will put stage_dir and iso_dir as MFS filesystems"
|
73 |
|
|
echo " --disable-memorydisks - Will just teardown these filesystems created by --enable-memorydisks"
|
74 |
|
|
echo " --setup-poudriere - Install poudriere and create necessary jails and ports tree"
|
75 |
|
|
echo " --create-unified-patch - Create a big patch with all changes done on FreeBSD"
|
76 |
|
|
echo " --update-poudriere-jails [-a ARCH_LIST] - Update poudriere jails using current patch versions"
|
77 |
fb192227
|
Renato Botelho
|
echo " --update-poudriere-ports [-a ARCH_LIST]- Update poudriere ports tree"
|
78 |
|
|
echo " --update-pkg-repo [-a ARCH_LIST]- Rebuild necessary ports on poudriere and update pkg repo"
|
79 |
7265700a
|
Renato Botelho
|
echo " --do-not-upload|-u - Do not upload pkgs or snapshots"
|
80 |
6f73c362
|
Renato Botelho
|
echo " -V VARNAME - print value of variable VARNAME"
|
81 |
|
|
exit 1
|
82 |
|
|
}
|
83 |
|
|
|
84 |
0ce2a7f3
|
Renato Botelho
|
export BUILDER_ROOT=$(realpath $(dirname ${0}))
|
85 |
|
|
export BUILDER_TOOLS="${BUILDER_ROOT}/tools"
|
86 |
6f73c362
|
Renato Botelho
|
|
87 |
|
|
unset _SKIP_REBUILD_PRESTAGE
|
88 |
|
|
unset _USE_OLD_DATESTRING
|
89 |
|
|
unset pfPORTTOBUILD
|
90 |
|
|
unset IMAGETYPE
|
91 |
|
|
unset DO_NOT_UPLOAD
|
92 |
ab943fc9
|
Renato Botelho
|
unset SNAPSHOTS
|
93 |
919c8486
|
Renato Botelho
|
unset POUDRIERE_SNAPSHOTS
|
94 |
fb192227
|
Renato Botelho
|
unset ARCH_LIST
|
95 |
6f73c362
|
Renato Botelho
|
BUILDACTION="images"
|
96 |
|
|
|
97 |
|
|
# Maybe use options for nocleans etc?
|
98 |
|
|
while test "$1" != ""; do
|
99 |
|
|
case "${1}" in
|
100 |
|
|
--no-buildworld|-c)
|
101 |
|
|
export NO_BUILDWORLD=YES
|
102 |
|
|
export NO_BUILDKERNEL=YES
|
103 |
|
|
;;
|
104 |
|
|
--no-cleanobjdir|--no-cleanrepos|-d)
|
105 |
2abc3e80
|
Renato Botelho
|
export NO_CLEAN_FREEBSD_OBJ=YES
|
106 |
|
|
export NO_CLEAN_FREEBSD_SRC=YES
|
107 |
6f73c362
|
Renato Botelho
|
;;
|
108 |
|
|
--flash-size|-f)
|
109 |
|
|
shift
|
110 |
|
|
if [ $# -eq 0 ]; then
|
111 |
|
|
echo "--flash-size needs extra parameter."
|
112 |
|
|
echo
|
113 |
|
|
usage
|
114 |
|
|
fi
|
115 |
|
|
export FLASH_SIZE="${1}"
|
116 |
|
|
;;
|
117 |
|
|
--resume-image-build|-r)
|
118 |
|
|
export NO_BUILDWORLD=YES
|
119 |
|
|
export NO_BUILDKERNEL=YES
|
120 |
2abc3e80
|
Renato Botelho
|
export NO_CLEAN_FREEBSD_OBJ=YES
|
121 |
|
|
export NO_CLEAN_FREEBSD_SRC=YES
|
122 |
6f73c362
|
Renato Botelho
|
_SKIP_REBUILD_PRESTAGE=YES
|
123 |
|
|
_USE_OLD_DATESTRING=YES
|
124 |
|
|
;;
|
125 |
|
|
--setup)
|
126 |
|
|
BUILDACTION="builder_setup"
|
127 |
|
|
;;
|
128 |
fa7f03b4
|
Renato Botelho
|
--rsync-repos)
|
129 |
|
|
BUILDACTION="rsync_repos"
|
130 |
|
|
;;
|
131 |
6f73c362
|
Renato Botelho
|
--build-kernels)
|
132 |
|
|
BUILDACTION="buildkernels"
|
133 |
|
|
;;
|
134 |
|
|
--install-extra-kernels)
|
135 |
|
|
shift
|
136 |
|
|
if [ $# -eq 0 ]; then
|
137 |
|
|
echo "--build-kernel needs extra parameter."
|
138 |
|
|
echo
|
139 |
|
|
usage
|
140 |
|
|
fi
|
141 |
|
|
export INSTALL_EXTRA_KERNELS="${1}"
|
142 |
|
|
;;
|
143 |
ab943fc9
|
Renato Botelho
|
--snapshots)
|
144 |
|
|
export SNAPSHOTS=1
|
145 |
|
|
;;
|
146 |
919c8486
|
Renato Botelho
|
--poudriere-snapshots)
|
147 |
|
|
export POUDRIERE_SNAPSHOTS=1
|
148 |
|
|
;;
|
149 |
6f73c362
|
Renato Botelho
|
--build-kernel)
|
150 |
|
|
BUILDACTION="buildkernel"
|
151 |
|
|
shift
|
152 |
|
|
if [ $# -eq 0 ]; then
|
153 |
|
|
echo "--build-kernel needs extra parameter."
|
154 |
|
|
echo
|
155 |
|
|
usage
|
156 |
|
|
fi
|
157 |
|
|
export BUILD_KERNELS="${1}"
|
158 |
|
|
;;
|
159 |
|
|
--update-sources)
|
160 |
|
|
BUILDACTION="updatesources"
|
161 |
|
|
;;
|
162 |
|
|
--print-flags)
|
163 |
|
|
BUILDACTION="printflags"
|
164 |
3ad375d4
|
Renato Botelho
|
_USE_OLD_DATESTRING=YES
|
165 |
6f73c362
|
Renato Botelho
|
;;
|
166 |
|
|
--clean-builder)
|
167 |
|
|
BUILDACTION="cleanbuilder"
|
168 |
|
|
;;
|
169 |
|
|
--enable-memorydisks)
|
170 |
|
|
BUILDACTION="enablememorydisk"
|
171 |
|
|
;;
|
172 |
|
|
--disable-memorydisks)
|
173 |
|
|
BUILDACTION="disablememorydisk"
|
174 |
|
|
;;
|
175 |
|
|
--setup-poudriere)
|
176 |
|
|
BUILDACTION="setup_poudriere"
|
177 |
|
|
;;
|
178 |
|
|
--create-unified-patch)
|
179 |
|
|
BUILDACTION="create_unified_patch"
|
180 |
|
|
;;
|
181 |
|
|
--update-poudriere-jails)
|
182 |
|
|
BUILDACTION="update_poudriere_jails"
|
183 |
fb192227
|
Renato Botelho
|
;;
|
184 |
|
|
-a)
|
185 |
6f73c362
|
Renato Botelho
|
shift
|
186 |
fb192227
|
Renato Botelho
|
if [ $# -eq 0 ]; then
|
187 |
|
|
echo "-a needs extra parameter."
|
188 |
|
|
echo
|
189 |
|
|
usage
|
190 |
6f73c362
|
Renato Botelho
|
fi
|
191 |
fb192227
|
Renato Botelho
|
export ARCH_LIST="${1}"
|
192 |
6f73c362
|
Renato Botelho
|
;;
|
193 |
|
|
--update-poudriere-ports)
|
194 |
|
|
BUILDACTION="update_poudriere_ports"
|
195 |
|
|
;;
|
196 |
|
|
--update-pkg-repo)
|
197 |
|
|
BUILDACTION="update_pkg_repo"
|
198 |
|
|
;;
|
199 |
7265700a
|
Renato Botelho
|
--do-not-upload|-u)
|
200 |
6f73c362
|
Renato Botelho
|
export DO_NOT_UPLOAD=1
|
201 |
|
|
;;
|
202 |
288bd310
|
Renato Botelho
|
all|none|*iso*|*ova*|*memstick*|*memstickserial*|*memstickadi*|*nanobsd*|*nanobsd-vga*|*fullupdate*)
|
203 |
6f73c362
|
Renato Botelho
|
BUILDACTION="images"
|
204 |
|
|
IMAGETYPE="${1}"
|
205 |
|
|
;;
|
206 |
|
|
-V)
|
207 |
3ad375d4
|
Renato Botelho
|
_USE_OLD_DATESTRING=YES
|
208 |
6f73c362
|
Renato Botelho
|
shift
|
209 |
|
|
[ -n "${1}" ] \
|
210 |
|
|
&& var_to_print="${1}"
|
211 |
|
|
;;
|
212 |
ab943fc9
|
Renato Botelho
|
--snapshot-update-status)
|
213 |
|
|
shift
|
214 |
906ca3b0
|
Renato Botelho
|
snapshot_status_message="${1}"
|
215 |
|
|
BUILDACTION="snapshot_status_message"
|
216 |
3fe334c6
|
Renato Botelho
|
_USE_OLD_DATESTRING=YES
|
217 |
ab943fc9
|
Renato Botelho
|
;;
|
218 |
6f73c362
|
Renato Botelho
|
*)
|
219 |
a53a4f3e
|
Renato Botelho
|
_USE_OLD_DATESTRING=YES
|
220 |
6f73c362
|
Renato Botelho
|
usage
|
221 |
|
|
esac
|
222 |
|
|
shift
|
223 |
|
|
done
|
224 |
|
|
|
225 |
|
|
# Suck in local vars
|
226 |
0ce2a7f3
|
Renato Botelho
|
. ${BUILDER_TOOLS}/builder_defaults.sh
|
227 |
6f73c362
|
Renato Botelho
|
|
228 |
|
|
# Suck in script helper functions
|
229 |
0ce2a7f3
|
Renato Botelho
|
. ${BUILDER_TOOLS}/builder_common.sh
|
230 |
6f73c362
|
Renato Botelho
|
|
231 |
|
|
# Print var required with -V and exit
|
232 |
|
|
if [ -n "${var_to_print}" ]; then
|
233 |
|
|
eval "echo \$${var_to_print}"
|
234 |
|
|
exit 0
|
235 |
|
|
fi
|
236 |
|
|
|
237 |
ab943fc9
|
Renato Botelho
|
# Update snapshot status and exit
|
238 |
906ca3b0
|
Renato Botelho
|
if [ "${BUILDACTION}" = "snapshot_status_message" ]; then
|
239 |
919c8486
|
Renato Botelho
|
if [ -z "${POUDRIERE_SNAPSHOTS}" ]; then
|
240 |
|
|
export SNAPSHOTS=1
|
241 |
|
|
fi
|
242 |
ab943fc9
|
Renato Botelho
|
snapshots_update_status "${snapshot_status_message}"
|
243 |
|
|
exit 0
|
244 |
|
|
fi
|
245 |
|
|
|
246 |
6f73c362
|
Renato Botelho
|
# This should be run first
|
247 |
|
|
launch
|
248 |
|
|
|
249 |
|
|
case $BUILDACTION in
|
250 |
|
|
builder_setup)
|
251 |
|
|
builder_setup
|
252 |
|
|
;;
|
253 |
|
|
buildkernels)
|
254 |
|
|
update_freebsd_sources
|
255 |
|
|
build_all_kernels
|
256 |
|
|
;;
|
257 |
|
|
buildkernel)
|
258 |
|
|
update_freebsd_sources
|
259 |
|
|
build_all_kernels
|
260 |
|
|
;;
|
261 |
|
|
cleanbuilder)
|
262 |
7e6ab3ed
|
Renato Botelho
|
clean_builder
|
263 |
6f73c362
|
Renato Botelho
|
;;
|
264 |
|
|
printflags)
|
265 |
|
|
print_flags
|
266 |
|
|
;;
|
267 |
7918276b
|
Renato Botelho
|
images)
|
268 |
6f73c362
|
Renato Botelho
|
# It will be handled below
|
269 |
|
|
;;
|
270 |
|
|
updatesources)
|
271 |
dde49bef
|
Renato Botelho
|
update_freebsd_sources
|
272 |
6f73c362
|
Renato Botelho
|
;;
|
273 |
|
|
enablememorydisk)
|
274 |
|
|
prestage_on_ram_setup
|
275 |
|
|
;;
|
276 |
|
|
disablememorydisk)
|
277 |
|
|
prestage_on_ram_cleanup
|
278 |
|
|
;;
|
279 |
|
|
setup_poudriere)
|
280 |
|
|
poudriere_init
|
281 |
|
|
;;
|
282 |
|
|
create_unified_patch)
|
283 |
|
|
poudriere_create_patch
|
284 |
|
|
;;
|
285 |
|
|
update_poudriere_jails)
|
286 |
|
|
poudriere_update_jails
|
287 |
|
|
;;
|
288 |
|
|
update_poudriere_ports)
|
289 |
|
|
poudriere_update_ports
|
290 |
|
|
;;
|
291 |
fa7f03b4
|
Renato Botelho
|
rsync_repos)
|
292 |
|
|
unset SKIP_FINAL_RSYNC
|
293 |
|
|
pkg_repo_rsync "${CORE_PKG_PATH}"
|
294 |
|
|
;;
|
295 |
6f73c362
|
Renato Botelho
|
update_pkg_repo)
|
296 |
cfa7f409
|
Renato Botelho
|
if [ -z "${DO_NOT_UPLOAD}" -a ! -f /usr/local/bin/rsync ]; then
|
297 |
|
|
echo "ERROR: rsync is not installed, aborting..."
|
298 |
|
|
exit 1
|
299 |
|
|
fi
|
300 |
6f73c362
|
Renato Botelho
|
poudriere_bulk
|
301 |
|
|
;;
|
302 |
|
|
*)
|
303 |
|
|
usage
|
304 |
|
|
;;
|
305 |
|
|
esac
|
306 |
|
|
|
307 |
|
|
if [ "${BUILDACTION}" != "images" ]; then
|
308 |
|
|
finish
|
309 |
|
|
exit 0
|
310 |
|
|
fi
|
311 |
|
|
|
312 |
ab943fc9
|
Renato Botelho
|
if [ -n "${SNAPSHOTS}" -a -z "${DO_NOT_UPLOAD}" ]; then
|
313 |
49784c55
|
Renato Botelho
|
_required=" \
|
314 |
|
|
RSYNCIP \
|
315 |
|
|
RSYNCUSER \
|
316 |
|
|
RSYNCPATH \
|
317 |
|
|
RSYNCLOGS \
|
318 |
|
|
PKG_RSYNC_HOSTNAME \
|
319 |
|
|
PKG_RSYNC_USERNAME \
|
320 |
|
|
PKG_RSYNC_SSH_PORT \
|
321 |
|
|
PKG_RSYNC_DESTDIR \
|
322 |
7ffef0a2
|
Renato Botelho
|
PKG_REPO_SERVER_DEVEL \
|
323 |
|
|
PKG_REPO_SERVER_RELEASE \
|
324 |
|
|
PKG_REPO_SERVER_STAGING \
|
325 |
|
|
PKG_REPO_BRANCH_DEVEL \
|
326 |
|
|
PKG_REPO_BRANCH_RELEASE"
|
327 |
49784c55
|
Renato Botelho
|
|
328 |
c6d14b0b
|
Renato Botelho
|
for _var in ${_required}; do
|
329 |
f238a83f
|
Renato Botelho
|
eval "_value=\${$_var}"
|
330 |
|
|
if [ -z "${_value}" ]; then
|
331 |
|
|
echo ">>> ERROR: ${_var} is not defined"
|
332 |
|
|
exit 1
|
333 |
|
|
fi
|
334 |
|
|
done
|
335 |
cfa7f409
|
Renato Botelho
|
|
336 |
|
|
if [ ! -f /usr/local/bin/rsync ]; then
|
337 |
|
|
echo "ERROR: rsync is not installed, aborting..."
|
338 |
|
|
exit 1
|
339 |
|
|
fi
|
340 |
ab943fc9
|
Renato Botelho
|
fi
|
341 |
|
|
|
342 |
6f73c362
|
Renato Botelho
|
if [ $# -gt 1 ]; then
|
343 |
|
|
echo "ERROR: Too many arguments given."
|
344 |
|
|
echo
|
345 |
|
|
usage
|
346 |
|
|
fi
|
347 |
14e2a004
|
Renato Botelho
|
|
348 |
|
|
if [ -n "${SNAPSHOTS}" -a -z "${IMAGETYPE}" ]; then
|
349 |
|
|
IMAGETYPE="all"
|
350 |
|
|
fi
|
351 |
|
|
|
352 |
6f73c362
|
Renato Botelho
|
if [ -z "${IMAGETYPE}" ]; then
|
353 |
|
|
echo "ERROR: Need to specify image type to build."
|
354 |
|
|
echo
|
355 |
|
|
usage
|
356 |
|
|
fi
|
357 |
|
|
|
358 |
288bd310
|
Renato Botelho
|
if [ "$IMAGETYPE" = "none" ]; then
|
359 |
|
|
_IMAGESTOBUILD=""
|
360 |
|
|
elif [ "$IMAGETYPE" = "all" ]; then
|
361 |
6f73c362
|
Renato Botelho
|
_IMAGESTOBUILD="iso fullupdate nanobsd nanobsd-vga memstick memstickserial"
|
362 |
|
|
if [ "${TARGET}" = "amd64" ]; then
|
363 |
|
|
_IMAGESTOBUILD="${_IMAGESTOBUILD} memstickadi"
|
364 |
|
|
fi
|
365 |
|
|
else
|
366 |
|
|
_IMAGESTOBUILD="${IMAGETYPE}"
|
367 |
|
|
fi
|
368 |
|
|
|
369 |
|
|
echo ">>> Building image type(s): ${_IMAGESTOBUILD}"
|
370 |
|
|
|
371 |
ab943fc9
|
Renato Botelho
|
if [ -n "${SNAPSHOTS}" ]; then
|
372 |
|
|
snapshots_rotate_logfile
|
373 |
|
|
|
374 |
|
|
snapshots_update_status ">>> Starting snapshot build operations"
|
375 |
|
|
|
376 |
|
|
if pkg update -r ${PRODUCT_NAME} >/dev/null 2>&1; then
|
377 |
|
|
snapshots_update_status ">>> Updating builder packages... "
|
378 |
|
|
pkg upgrade -r ${PRODUCT_NAME} -y -q >/dev/null 2>&1
|
379 |
|
|
fi
|
380 |
|
|
fi
|
381 |
|
|
|
382 |
6f73c362
|
Renato Botelho
|
if [ -z "${_SKIP_REBUILD_PRESTAGE}" ]; then
|
383 |
|
|
[ -n "${CORE_PKG_TMP}" -a -d "${CORE_PKG_TMP}" ] \
|
384 |
|
|
&& rm -rf ${CORE_PKG_TMP}
|
385 |
|
|
[ -n "${CORE_PKG_PATH}" -a -d "${CORE_PKG_PATH}" ] \
|
386 |
|
|
&& rm -rf ${CORE_PKG_PATH}
|
387 |
|
|
|
388 |
|
|
# Cleanup environment before start
|
389 |
7e6ab3ed
|
Renato Botelho
|
clean_builder
|
390 |
6f73c362
|
Renato Botelho
|
|
391 |
|
|
# Make sure source directories are present.
|
392 |
dde49bef
|
Renato Botelho
|
update_freebsd_sources
|
393 |
6f73c362
|
Renato Botelho
|
git_last_commit
|
394 |
|
|
|
395 |
|
|
# Ensure binaries are present that builder system requires
|
396 |
|
|
builder_setup
|
397 |
|
|
|
398 |
|
|
# Output build flags
|
399 |
|
|
print_flags
|
400 |
|
|
|
401 |
|
|
# Check to see if pre-staging will be hosted on ram
|
402 |
|
|
prestage_on_ram_setup
|
403 |
|
|
|
404 |
|
|
# Build world, kernel and install
|
405 |
|
|
echo ">>> Building world for ISO... $FREEBSD_BRANCH ..."
|
406 |
|
|
make_world
|
407 |
|
|
|
408 |
|
|
# Build kernels
|
409 |
|
|
echo ">>> Building kernel configs: $BUILD_KERNELS for FreeBSD: $FREEBSD_BRANCH ..."
|
410 |
|
|
build_all_kernels
|
411 |
|
|
|
412 |
|
|
# Prepare pre-final staging area
|
413 |
|
|
clone_to_staging_area
|
414 |
|
|
|
415 |
|
|
# Install packages needed for Product
|
416 |
|
|
install_pkg_install_ports
|
417 |
|
|
fi
|
418 |
|
|
|
419 |
|
|
export DEFAULT_KERNEL=${DEFAULT_KERNEL_ISO:-"${PRODUCT_NAME}"}
|
420 |
|
|
|
421 |
39ef49f6
|
Renato Botelho
|
# XXX: Figure out why wait is failing and proper fix
|
422 |
|
|
# Global variable to keep track of process running in bg
|
423 |
|
|
export _bg_pids=""
|
424 |
|
|
|
425 |
6f73c362
|
Renato Botelho
|
for _IMGTOBUILD in $_IMAGESTOBUILD; do
|
426 |
|
|
# Clean up items that should be cleaned each run
|
427 |
|
|
staginareas_clean_each_run
|
428 |
|
|
|
429 |
ed44fe76
|
Renato Botelho
|
case "${_IMGTOBUILD}" in
|
430 |
|
|
iso)
|
431 |
|
|
create_iso_image
|
432 |
|
|
;;
|
433 |
|
|
memstick)
|
434 |
|
|
create_memstick_image
|
435 |
|
|
;;
|
436 |
|
|
memstickserial)
|
437 |
|
|
create_memstick_serial_image
|
438 |
|
|
;;
|
439 |
|
|
memstickadi)
|
440 |
|
|
create_memstick_adi_image
|
441 |
|
|
;;
|
442 |
|
|
fullupdate)
|
443 |
|
|
create_Full_update_tarball
|
444 |
|
|
;;
|
445 |
|
|
nanobsd|nanobsd-vga)
|
446 |
|
|
if [ "${TARGET}" = "i386" -a "${_IMGTOBUILD}" = "nanobsd" ]; then
|
447 |
|
|
export DEFAULT_KERNEL=${DEFAULT_KERNEL_NANOBSD:-"${PRODUCT_NAME}_wrap"}
|
448 |
|
|
elif [ "${TARGET}" = "i386" -a "${_IMGTOBUILD}" = "nanobsd-vga" ]; then
|
449 |
|
|
export DEFAULT_KERNEL=${DEFAULT_KERNEL_NANOBSDVGA:-"${PRODUCT_NAME}_wrap_vga"}
|
450 |
|
|
elif [ "${TARGET}" = "amd64" ]; then
|
451 |
|
|
export DEFAULT_KERNEL=${DEFAULT_KERNEL_NANOBSD:-"${PRODUCT_NAME}"}
|
452 |
|
|
fi
|
453 |
|
|
# Create the NanoBSD disk image
|
454 |
|
|
create_nanobsd_diskimage ${_IMGTOBUILD} "${FLASH_SIZE}"
|
455 |
|
|
;;
|
456 |
|
|
ova)
|
457 |
b00400ef
|
Renato Botelho
|
old_custom_package_list="${custom_package_list}"
|
458 |
|
|
export custom_package_list="${custom_package_list} ${PRODUCT_NAME}-pkg-Open-VM-Tools"
|
459 |
|
|
install_pkg_install_ports
|
460 |
ed44fe76
|
Renato Botelho
|
create_ova_image
|
461 |
b00400ef
|
Renato Botelho
|
export custom_package_list="${old_custom_package_list}"
|
462 |
ed44fe76
|
Renato Botelho
|
install_pkg_install_ports
|
463 |
|
|
;;
|
464 |
|
|
esac
|
465 |
6f73c362
|
Renato Botelho
|
done
|
466 |
|
|
|
467 |
98978a36
|
Renato Botelho
|
core_pkg_create_repo
|
468 |
|
|
|
469 |
39ef49f6
|
Renato Botelho
|
if [ -n "${_bg_pids}" ]; then
|
470 |
|
|
if [ -n "${SNAPSHOTS}" ]; then
|
471 |
|
|
snapshots_update_status ">>> NOTE: waiting for jobs: ${_bg_pids} to finish..."
|
472 |
|
|
else
|
473 |
|
|
echo ">>> NOTE: waiting for jobs: ${_bg_pids} to finish..."
|
474 |
|
|
fi
|
475 |
|
|
wait
|
476 |
|
|
|
477 |
|
|
# XXX: For some reason wait is failing, workaround it tracking all PIDs
|
478 |
|
|
while [ -n "${_bg_pids}" ]; do
|
479 |
|
|
_tmp_pids="${_bg_pids}"
|
480 |
|
|
unset _bg_pids
|
481 |
|
|
for p in ${_tmp_pids}; do
|
482 |
|
|
[ -z "${p}" ] \
|
483 |
|
|
&& continue
|
484 |
|
|
|
485 |
|
|
kill -0 ${p} >/dev/null 2>&1 \
|
486 |
|
|
&& _bg_pids="${_bg_pids}${_bg_pids:+ }${p}"
|
487 |
|
|
done
|
488 |
|
|
[ -n "${_bg_pids}" ] \
|
489 |
|
|
&& sleep 1
|
490 |
|
|
done
|
491 |
cc145494
|
Renato Botelho
|
fi
|
492 |
6f73c362
|
Renato Botelho
|
|
493 |
ab943fc9
|
Renato Botelho
|
if [ -n "${SNAPSHOTS}" ]; then
|
494 |
288bd310
|
Renato Botelho
|
if [ "${IMAGETYPE}" = "none" -a -z "${DO_NOT_UPLOAD}" ]; then
|
495 |
|
|
pkg_repo_rsync "${CORE_PKG_PATH}"
|
496 |
|
|
elif [ "${IMAGETYPE}" != "none" ]; then
|
497 |
|
|
snapshots_copy_to_staging_iso_updates
|
498 |
|
|
snapshots_copy_to_staging_nanobsd "${FLASH_SIZE}"
|
499 |
|
|
# SCP files to snapshot web hosting area
|
500 |
|
|
if [ -z "${DO_NOT_UPLOAD}" ]; then
|
501 |
|
|
snapshots_scp_files
|
502 |
|
|
fi
|
503 |
ab943fc9
|
Renato Botelho
|
fi
|
504 |
|
|
# Alert the world that we have some snapshots ready.
|
505 |
|
|
snapshots_update_status ">>> Builder run is complete."
|
506 |
|
|
fi
|
507 |
6f73c362
|
Renato Botelho
|
|
508 |
6b733d47
|
Renato Botelho
|
echo ">>> ${IMAGES_FINAL_DIR} now contains:"
|
509 |
|
|
ls -lah ${IMAGES_FINAL_DIR}
|
510 |
|
|
|
511 |
6f73c362
|
Renato Botelho
|
set -e
|
512 |
|
|
# Run final finish routines
|
513 |
|
|
finish
|