1 |
6f73c362
|
Renato Botelho
|
#!/bin/sh
|
2 |
|
|
#
|
3 |
|
|
# builder_common.sh
|
4 |
|
|
#
|
5 |
ac24dc24
|
Renato Botelho
|
# part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
# Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
# Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
a68f7a3d
|
Luiz Otavio O Souza
|
# Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9 |
6f73c362
|
Renato Botelho
|
# All rights reserved.
|
10 |
|
|
#
|
11 |
|
|
# FreeSBIE portions of the code
|
12 |
|
|
# Copyright (c) 2005 Dario Freni
|
13 |
|
|
# and copied from FreeSBIE project
|
14 |
|
|
# All rights reserved.
|
15 |
|
|
#
|
16 |
b12ea3fb
|
Renato Botelho
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
17 |
|
|
# you may not use this file except in compliance with the License.
|
18 |
|
|
# You may obtain a copy of the License at
|
19 |
6f73c362
|
Renato Botelho
|
#
|
20 |
b12ea3fb
|
Renato Botelho
|
# http://www.apache.org/licenses/LICENSE-2.0
|
21 |
6f73c362
|
Renato Botelho
|
#
|
22 |
b12ea3fb
|
Renato Botelho
|
# Unless required by applicable law or agreed to in writing, software
|
23 |
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
24 |
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
25 |
|
|
# See the License for the specific language governing permissions and
|
26 |
|
|
# limitations under the License.
|
27 |
6f73c362
|
Renato Botelho
|
|
28 |
f26731b0
|
Renato Botelho
|
if [ -z "${IMAGES_FINAL_DIR}" -o "${IMAGES_FINAL_DIR}" = "/" ]; then
|
29 |
04992be2
|
Renato Botelho
|
echo "IMAGES_FINAL_DIR is not defined"
|
30 |
6f73c362
|
Renato Botelho
|
print_error_pfS
|
31 |
|
|
fi
|
32 |
|
|
|
33 |
a81faa85
|
Renato Botelho
|
kldload filemon >/dev/null 2>&1
|
34 |
|
|
|
35 |
6f73c362
|
Renato Botelho
|
lc() {
|
36 |
|
|
echo "${1}" | tr '[[:upper:]]' '[[:lower:]]'
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
git_last_commit() {
|
40 |
0b0ef57e
|
Renato Botelho
|
export CURRENT_COMMIT=$(git -C ${BUILDER_ROOT} log -1 --format='%H')
|
41 |
|
|
export CURRENT_AUTHOR=$(git -C ${BUILDER_ROOT} log -1 --format='%an')
|
42 |
78b0f246
|
Renato Botelho
|
echo ">>> Last known commit $CURRENT_AUTHOR - $CURRENT_COMMIT"
|
43 |
|
|
echo "$CURRENT_COMMIT" > $SCRATCHDIR/build_commit_info.txt
|
44 |
6f73c362
|
Renato Botelho
|
}
|
45 |
|
|
|
46 |
98978a36
|
Renato Botelho
|
# Create core pkg repository
|
47 |
|
|
core_pkg_create_repo() {
|
48 |
da781042
|
Renato Botelho
|
if [ ! -d "${CORE_PKG_REAL_PATH}/All" ]; then
|
49 |
98978a36
|
Renato Botelho
|
return
|
50 |
|
|
fi
|
51 |
|
|
|
52 |
da781042
|
Renato Botelho
|
############ ATTENTION ##############
|
53 |
|
|
#
|
54 |
|
|
# For some reason pkg-repo fail without / in the end of directory name
|
55 |
|
|
# so removing it will break command
|
56 |
|
|
#
|
57 |
|
|
# https://github.com/freebsd/pkg/issues/1364
|
58 |
|
|
#
|
59 |
98978a36
|
Renato Botelho
|
echo -n ">>> Creating core packages repository... "
|
60 |
da781042
|
Renato Botelho
|
if pkg repo -q "${CORE_PKG_REAL_PATH}/"; then
|
61 |
98978a36
|
Renato Botelho
|
echo "Done!"
|
62 |
|
|
else
|
63 |
|
|
echo "Failed!"
|
64 |
|
|
print_error_pfS
|
65 |
|
|
fi
|
66 |
da781042
|
Renato Botelho
|
|
67 |
|
|
# Use the same directory structure as poudriere does to avoid
|
68 |
|
|
# breaking snapshot repositories during rsync
|
69 |
|
|
ln -sf $(basename ${CORE_PKG_REAL_PATH}) ${CORE_PKG_PATH}/.latest
|
70 |
91039db4
|
Renato Botelho
|
ln -sf .latest/All ${CORE_PKG_ALL_PATH}
|
71 |
da781042
|
Renato Botelho
|
ln -sf .latest/digests.txz ${CORE_PKG_PATH}/digests.txz
|
72 |
f6e2e5aa
|
Renato Botelho do Couto
|
ln -sf .latest/meta.conf ${CORE_PKG_PATH}/meta.conf
|
73 |
da781042
|
Renato Botelho
|
ln -sf .latest/meta.txz ${CORE_PKG_PATH}/meta.txz
|
74 |
|
|
ln -sf .latest/packagesite.txz ${CORE_PKG_PATH}/packagesite.txz
|
75 |
98978a36
|
Renato Botelho
|
}
|
76 |
|
|
|
77 |
6f73c362
|
Renato Botelho
|
# Create core pkg (base, kernel)
|
78 |
|
|
core_pkg_create() {
|
79 |
|
|
local _template="${1}"
|
80 |
|
|
local _flavor="${2}"
|
81 |
|
|
local _version="${3}"
|
82 |
|
|
local _root="${4}"
|
83 |
318a7b77
|
Luiz Souza
|
local _findroot="${5}"
|
84 |
|
|
local _filter="${6}"
|
85 |
6f73c362
|
Renato Botelho
|
|
86 |
1217cd7a
|
Renato Botelho
|
local _template_path=${BUILDER_TOOLS}/templates/core_pkg/${_template}
|
87 |
|
|
|
88 |
dff2bf9c
|
Renato Botelho
|
# Use default pkg repo to obtain ABI and ALTABI
|
89 |
|
|
local _abi=$(sed -e "s/%%ARCH%%/${TARGET_ARCH}/g" \
|
90 |
|
|
${PKG_REPO_DEFAULT%%.conf}.abi)
|
91 |
|
|
local _altabi_arch=$(get_altabi_arch ${TARGET_ARCH})
|
92 |
|
|
local _altabi=$(sed -e "s/%%ARCH%%/${_altabi_arch}/g" \
|
93 |
|
|
${PKG_REPO_DEFAULT%%.conf}.altabi)
|
94 |
|
|
|
95 |
cdf2b5f8
|
Renato Botelho
|
${BUILDER_SCRIPTS}/create_core_pkg.sh \
|
96 |
1217cd7a
|
Renato Botelho
|
-t "${_template_path}" \
|
97 |
|
|
-f "${_flavor}" \
|
98 |
|
|
-v "${_version}" \
|
99 |
|
|
-r "${_root}" \
|
100 |
318a7b77
|
Luiz Souza
|
-s "${_findroot}" \
|
101 |
1217cd7a
|
Renato Botelho
|
-F "${_filter}" \
|
102 |
|
|
-d "${CORE_PKG_REAL_PATH}/All" \
|
103 |
dff2bf9c
|
Renato Botelho
|
-a "${_abi}" \
|
104 |
|
|
-A "${_altabi}" \
|
105 |
1217cd7a
|
Renato Botelho
|
|| print_error_pfS
|
106 |
6f73c362
|
Renato Botelho
|
}
|
107 |
|
|
|
108 |
|
|
# This routine will output that something went wrong
|
109 |
|
|
print_error_pfS() {
|
110 |
|
|
echo
|
111 |
|
|
echo "####################################"
|
112 |
|
|
echo "Something went wrong, check errors!" >&2
|
113 |
|
|
echo "####################################"
|
114 |
|
|
echo
|
115 |
|
|
echo "NOTE: a lot of times you can run './build.sh --clean-builder' to resolve."
|
116 |
|
|
echo
|
117 |
d4c6029e
|
Renato Botelho
|
[ -n "${LOGFILE}" -a -f "${LOGFILE}" ] && \
|
118 |
6f73c362
|
Renato Botelho
|
echo "Log saved on ${LOGFILE}" && \
|
119 |
|
|
echo
|
120 |
|
|
kill $$
|
121 |
|
|
exit 1
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
# This routine will verify that the kernel has been
|
125 |
|
|
# installed OK to the staging area.
|
126 |
|
|
ensure_kernel_exists() {
|
127 |
|
|
if [ ! -f "$1/boot/kernel/kernel.gz" ]; then
|
128 |
|
|
echo ">>> ERROR: Could not locate $1/boot/kernel.gz"
|
129 |
|
|
print_error_pfS
|
130 |
|
|
fi
|
131 |
|
|
KERNEL_SIZE=$(stat -f "%z" $1/boot/kernel/kernel.gz)
|
132 |
|
|
if [ "$KERNEL_SIZE" -lt 3500 ]; then
|
133 |
|
|
echo ">>> ERROR: Kernel $1/boot/kernel.gz appears to be smaller than it should be: $KERNEL_SIZE"
|
134 |
|
|
print_error_pfS
|
135 |
|
|
fi
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
get_pkg_name() {
|
139 |
|
|
echo "${PRODUCT_NAME}-${1}-${CORE_PKG_VERSION}"
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
# This routine builds all related kernels
|
143 |
|
|
build_all_kernels() {
|
144 |
|
|
# Set KERNEL_BUILD_PATH if it has not been set
|
145 |
|
|
if [ -z "${KERNEL_BUILD_PATH}" ]; then
|
146 |
|
|
KERNEL_BUILD_PATH=$SCRATCHDIR/kernels
|
147 |
|
|
echo ">>> KERNEL_BUILD_PATH has not been set. Setting to ${KERNEL_BUILD_PATH}!"
|
148 |
|
|
fi
|
149 |
|
|
|
150 |
|
|
[ -d "${KERNEL_BUILD_PATH}" ] \
|
151 |
|
|
&& rm -rf ${KERNEL_BUILD_PATH}
|
152 |
|
|
|
153 |
|
|
# Build embedded kernel
|
154 |
|
|
for BUILD_KERNEL in $BUILD_KERNELS; do
|
155 |
|
|
unset KERNCONF
|
156 |
|
|
unset KERNEL_DESTDIR
|
157 |
|
|
unset KERNEL_NAME
|
158 |
|
|
export KERNCONF=$BUILD_KERNEL
|
159 |
|
|
export KERNEL_DESTDIR="$KERNEL_BUILD_PATH/$BUILD_KERNEL"
|
160 |
|
|
export KERNEL_NAME=${BUILD_KERNEL}
|
161 |
|
|
|
162 |
|
|
LOGFILE="${BUILDER_LOGS}/kernel.${KERNCONF}.${TARGET}.log"
|
163 |
|
|
echo ">>> Building $BUILD_KERNEL kernel." | tee -a ${LOGFILE}
|
164 |
|
|
|
165 |
91039db4
|
Renato Botelho
|
if [ -n "${NO_BUILDKERNEL}" -a -f "${CORE_PKG_ALL_PATH}/$(get_pkg_name kernel-${KERNEL_NAME}).txz" ]; then
|
166 |
6f73c362
|
Renato Botelho
|
echo ">>> NO_BUILDKERNEL set, skipping build" | tee -a ${LOGFILE}
|
167 |
|
|
continue
|
168 |
|
|
fi
|
169 |
|
|
|
170 |
|
|
buildkernel
|
171 |
|
|
|
172 |
|
|
echo ">>> Staging $BUILD_KERNEL kernel..." | tee -a ${LOGFILE}
|
173 |
|
|
installkernel
|
174 |
|
|
|
175 |
|
|
ensure_kernel_exists $KERNEL_DESTDIR
|
176 |
|
|
|
177 |
044cf5bd
|
Renato Botelho
|
echo ">>> Creating pkg of $KERNEL_NAME-debug kernel to staging area..." | tee -a ${LOGFILE}
|
178 |
1ec6f217
|
Luiz Souza
|
core_pkg_create kernel-debug ${KERNEL_NAME} ${CORE_PKG_VERSION} ${KERNEL_DESTDIR} \
|
179 |
fd349773
|
Renato Botelho
|
"./usr/lib/debug/boot" \*.debug
|
180 |
72e2fb75
|
Renato Botelho
|
rm -rf ${KERNEL_DESTDIR}/usr
|
181 |
a9ae8dac
|
Renato Botelho
|
|
182 |
044cf5bd
|
Renato Botelho
|
echo ">>> Creating pkg of $KERNEL_NAME kernel to staging area..." | tee -a ${LOGFILE}
|
183 |
1ec6f217
|
Luiz Souza
|
core_pkg_create kernel ${KERNEL_NAME} ${CORE_PKG_VERSION} ${KERNEL_DESTDIR} "./boot/kernel ./boot/modules"
|
184 |
6f73c362
|
Renato Botelho
|
|
185 |
|
|
rm -rf $KERNEL_DESTDIR 2>&1 1>/dev/null
|
186 |
|
|
done
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
install_default_kernel() {
|
190 |
|
|
if [ -z "${1}" ]; then
|
191 |
|
|
echo ">>> ERROR: install_default_kernel called without a kernel config name"| tee -a ${LOGFILE}
|
192 |
|
|
print_error_pfS
|
193 |
|
|
fi
|
194 |
|
|
|
195 |
|
|
export KERNEL_NAME="${1}"
|
196 |
|
|
|
197 |
|
|
echo -n ">>> Installing kernel to be used by image ${KERNEL_NAME}..." | tee -a ${LOGFILE}
|
198 |
|
|
|
199 |
|
|
# Copy kernel package to chroot, otherwise pkg won't find it to install
|
200 |
|
|
if ! pkg_chroot_add ${FINAL_CHROOT_DIR} kernel-${KERNEL_NAME}; then
|
201 |
|
|
echo ">>> ERROR: Error installing kernel package $(get_pkg_name kernel-${KERNEL_NAME}).txz" | tee -a ${LOGFILE}
|
202 |
|
|
print_error_pfS
|
203 |
|
|
fi
|
204 |
|
|
|
205 |
d071acf5
|
Renato Botelho
|
# Set kernel pkg as vital to avoid user end up removing it for any reason
|
206 |
|
|
pkg_chroot ${FINAL_CHROOT_DIR} set -v 1 -y $(get_pkg_name kernel-${KERNEL_NAME})
|
207 |
6f73c362
|
Renato Botelho
|
|
208 |
|
|
if [ ! -f $FINAL_CHROOT_DIR/boot/kernel/kernel.gz ]; then
|
209 |
|
|
echo ">>> ERROR: No kernel installed on $FINAL_CHROOT_DIR and the resulting image will be unusable. STOPPING!" | tee -a ${LOGFILE}
|
210 |
|
|
print_error_pfS
|
211 |
|
|
fi
|
212 |
|
|
mkdir -p $FINAL_CHROOT_DIR/pkgs
|
213 |
|
|
if [ -z "${2}" -o -n "${INSTALL_EXTRA_KERNELS}" ]; then
|
214 |
91039db4
|
Renato Botelho
|
cp ${CORE_PKG_ALL_PATH}/$(get_pkg_name kernel-${KERNEL_NAME}).txz $FINAL_CHROOT_DIR/pkgs
|
215 |
6f73c362
|
Renato Botelho
|
if [ -n "${INSTALL_EXTRA_KERNELS}" ]; then
|
216 |
|
|
for _EXTRA_KERNEL in $INSTALL_EXTRA_KERNELS; do
|
217 |
91039db4
|
Renato Botelho
|
_EXTRA_KERNEL_PATH=${CORE_PKG_ALL_PATH}/$(get_pkg_name kernel-${_EXTRA_KERNEL}).txz
|
218 |
6f73c362
|
Renato Botelho
|
if [ -f "${_EXTRA_KERNEL_PATH}" ]; then
|
219 |
|
|
echo -n ". adding ${_EXTRA_KERNEL_PATH} on image /pkgs folder"
|
220 |
|
|
cp ${_EXTRA_KERNEL_PATH} $FINAL_CHROOT_DIR/pkgs
|
221 |
|
|
else
|
222 |
|
|
echo ">>> ERROR: Requested kernel $(get_pkg_name kernel-${_EXTRA_KERNEL}).txz was not found to be put on image /pkgs folder!"
|
223 |
|
|
print_error_pfS
|
224 |
|
|
fi
|
225 |
|
|
done
|
226 |
|
|
fi
|
227 |
|
|
fi
|
228 |
|
|
echo "Done." | tee -a ${LOGFILE}
|
229 |
|
|
|
230 |
|
|
unset KERNEL_NAME
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
# This builds FreeBSD (make buildworld)
|
234 |
|
|
# Imported from FreeSBIE
|
235 |
|
|
make_world() {
|
236 |
|
|
LOGFILE=${BUILDER_LOGS}/buildworld.${TARGET}
|
237 |
ab7ead15
|
Renato Botelho
|
echo ">>> LOGFILE set to $LOGFILE." | tee -a ${LOGFILE}
|
238 |
d4c6029e
|
Renato Botelho
|
if [ -n "${NO_BUILDWORLD}" ]; then
|
239 |
6f73c362
|
Renato Botelho
|
echo ">>> NO_BUILDWORLD set, skipping build" | tee -a ${LOGFILE}
|
240 |
|
|
return
|
241 |
|
|
fi
|
242 |
|
|
|
243 |
29cdd776
|
Renato Botelho
|
echo ">>> $(LC_ALL=C date) - Starting build world for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
244 |
cdf2b5f8
|
Renato Botelho
|
script -aq $LOGFILE ${BUILDER_SCRIPTS}/build_freebsd.sh -K -s ${FREEBSD_SRC_DIR} \
|
245 |
29cdd776
|
Renato Botelho
|
|| print_error_pfS
|
246 |
|
|
echo ">>> $(LC_ALL=C date) - Finished build world for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
247 |
6f73c362
|
Renato Botelho
|
|
248 |
|
|
LOGFILE=${BUILDER_LOGS}/installworld.${TARGET}
|
249 |
|
|
echo ">>> LOGFILE set to $LOGFILE." | tee -a ${LOGFILE}
|
250 |
729c0c7a
|
Renato Botelho
|
|
251 |
|
|
[ -d "${INSTALLER_CHROOT_DIR}" ] \
|
252 |
|
|
|| mkdir -p ${INSTALLER_CHROOT_DIR}
|
253 |
|
|
|
254 |
468f236d
|
Renato Botelho
|
echo ">>> Installing world with bsdinstall for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
255 |
49de5a2e
|
Renato Botelho
|
script -aq $LOGFILE ${BUILDER_SCRIPTS}/install_freebsd.sh -i -K \
|
256 |
468f236d
|
Renato Botelho
|
-s ${FREEBSD_SRC_DIR} \
|
257 |
|
|
-d ${INSTALLER_CHROOT_DIR} \
|
258 |
|
|
|| print_error_pfS
|
259 |
|
|
|
260 |
e5aeaeb6
|
jim-p
|
# Copy additional installer scripts
|
261 |
|
|
install -o root -g wheel -m 0755 ${BUILDER_TOOLS}/installer/*.sh \
|
262 |
|
|
${INSTALLER_CHROOT_DIR}/root
|
263 |
|
|
|
264 |
92db4492
|
Renato Botelho
|
# XXX set root password since we don't have nullok enabled
|
265 |
|
|
pw -R ${INSTALLER_CHROOT_DIR} usermod root -w yes
|
266 |
|
|
|
267 |
468f236d
|
Renato Botelho
|
echo ">>> Installing world without bsdinstall for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
268 |
cdf2b5f8
|
Renato Botelho
|
script -aq $LOGFILE ${BUILDER_SCRIPTS}/install_freebsd.sh -K \
|
269 |
468f236d
|
Renato Botelho
|
-s ${FREEBSD_SRC_DIR} \
|
270 |
|
|
-d ${STAGE_CHROOT_DIR} \
|
271 |
|
|
|| print_error_pfS
|
272 |
6f73c362
|
Renato Botelho
|
|
273 |
06c13973
|
Renato Botelho
|
# Use the builder cross compiler from obj to produce the final binary.
|
274 |
295b0d2b
|
Renato Botelho
|
BUILD_CC="${MAKEOBJDIRPREFIX}${FREEBSD_SRC_DIR}/${TARGET}.${TARGET_ARCH}/tmp/usr/bin/cc"
|
275 |
06c13973
|
Renato Botelho
|
|
276 |
|
|
[ -f "${BUILD_CC}" ] || print_error_pfS
|
277 |
|
|
|
278 |
468f236d
|
Renato Botelho
|
# XXX It must go to the scripts
|
279 |
6f73c362
|
Renato Botelho
|
[ -d "${STAGE_CHROOT_DIR}/usr/local/bin" ] \
|
280 |
|
|
|| mkdir -p ${STAGE_CHROOT_DIR}/usr/local/bin
|
281 |
06c13973
|
Renato Botelho
|
makeargs="CC=${BUILD_CC} DESTDIR=${STAGE_CHROOT_DIR}"
|
282 |
6f73c362
|
Renato Botelho
|
echo ">>> Building and installing crypto tools and athstats for ${TARGET} architecture... (Starting - $(LC_ALL=C date))" | tee -a ${LOGFILE}
|
283 |
d4c6029e
|
Renato Botelho
|
(script -aq $LOGFILE make -C ${FREEBSD_SRC_DIR}/tools/tools/crypto ${makeargs} clean all install || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
284 |
a0b4972b
|
Renato Botelho
|
# XXX FIX IT
|
285 |
|
|
# (script -aq $LOGFILE make -C ${FREEBSD_SRC_DIR}/tools/tools/ath/athstats ${makeargs} clean all install || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
286 |
6f73c362
|
Renato Botelho
|
echo ">>> Building and installing crypto tools and athstats for ${TARGET} architecture... (Finished - $(LC_ALL=C date))" | tee -a ${LOGFILE}
|
287 |
|
|
|
288 |
1af9fab9
|
Renato Botelho
|
if [ "${PRODUCT_NAME}" = "pfSense" -a -n "${GNID_REPO_BASE}" ]; then
|
289 |
|
|
echo ">>> Building gnid... " | tee -a ${LOGFILE}
|
290 |
0874c8f5
|
Renato Botelho
|
(\
|
291 |
|
|
cd ${GNID_SRC_DIR} && \
|
292 |
06c13973
|
Renato Botelho
|
make \
|
293 |
|
|
CC=${BUILD_CC} \
|
294 |
|
|
INCLUDE_DIR=${GNID_INCLUDE_DIR} \
|
295 |
|
|
LIBCRYPTO_DIR=${GNID_LIBCRYPTO_DIR} \
|
296 |
|
|
clean gnid \
|
297 |
0874c8f5
|
Renato Botelho
|
) || print_error_pfS
|
298 |
1af9fab9
|
Renato Botelho
|
install -o root -g wheel -m 0700 ${GNID_SRC_DIR}/gnid \
|
299 |
|
|
${STAGE_CHROOT_DIR}/usr/sbin \
|
300 |
|
|
|| print_error_pfS
|
301 |
|
|
install -o root -g wheel -m 0700 ${GNID_SRC_DIR}/gnid \
|
302 |
|
|
${INSTALLER_CHROOT_DIR}/usr/sbin \
|
303 |
|
|
|| print_error_pfS
|
304 |
|
|
fi
|
305 |
|
|
|
306 |
6f73c362
|
Renato Botelho
|
unset makeargs
|
307 |
|
|
}
|
308 |
|
|
|
309 |
|
|
# This routine creates a ova image that contains
|
310 |
|
|
# a ovf and vmdk file. These files can be imported
|
311 |
|
|
# right into vmware or virtual box.
|
312 |
|
|
# (and many other emulation platforms)
|
313 |
|
|
# http://www.vmware.com/pdf/ovf_whitepaper_specification.pdf
|
314 |
|
|
create_ova_image() {
|
315 |
|
|
# XXX create a .ovf php creator that you can pass:
|
316 |
|
|
# 1. populatedSize
|
317 |
|
|
# 2. license
|
318 |
|
|
# 3. product name
|
319 |
|
|
# 4. version
|
320 |
|
|
# 5. number of network interface cards
|
321 |
|
|
# 6. allocationUnits
|
322 |
|
|
# 7. capacity
|
323 |
|
|
# 8. capacityAllocationUnits
|
324 |
|
|
|
325 |
|
|
LOGFILE=${BUILDER_LOGS}/ova.${TARGET}.log
|
326 |
|
|
|
327 |
f25c08c9
|
Renato Botelho
|
local _mntdir=${OVA_TMP}/mnt
|
328 |
|
|
|
329 |
|
|
if [ -d "${_mntdir}" ]; then
|
330 |
ca0f9142
|
Renato Botelho
|
local _dev
|
331 |
|
|
# XXX Root cause still didn't found but it doesn't umount
|
332 |
|
|
# properly on looped builds and then require this extra
|
333 |
|
|
# check
|
334 |
|
|
while true; do
|
335 |
f25c08c9
|
Renato Botelho
|
_dev=$(mount -p ${_mntdir} 2>/dev/null | awk '{print $1}')
|
336 |
ca0f9142
|
Renato Botelho
|
[ $? -ne 0 -o -z "${_dev}" ] \
|
337 |
|
|
&& break
|
338 |
f25c08c9
|
Renato Botelho
|
umount -f ${_mntdir}
|
339 |
ca0f9142
|
Renato Botelho
|
mdconfig -d -u ${_dev#/dev/}
|
340 |
|
|
done
|
341 |
e4de9720
|
Renato Botelho
|
chflags -R noschg ${OVA_TMP}
|
342 |
|
|
rm -rf ${OVA_TMP}
|
343 |
|
|
fi
|
344 |
89a72b59
|
Renato Botelho
|
|
345 |
f26731b0
|
Renato Botelho
|
mkdir -p $(dirname ${OVAPATH})
|
346 |
|
|
|
347 |
5de5a708
|
Renato Botelho
|
mkdir -p ${_mntdir}
|
348 |
89a72b59
|
Renato Botelho
|
|
349 |
2006b940
|
Renato Botelho
|
if [ -z "${OVA_SWAP_PART_SIZE_IN_GB}" -o "${OVA_SWAP_PART_SIZE_IN_GB}" = "0" ]; then
|
350 |
|
|
# first partition size (freebsd-ufs)
|
351 |
|
|
local OVA_FIRST_PART_SIZE_IN_GB=${VMDK_DISK_CAPACITY_IN_GB}
|
352 |
c56630d7
|
Renato Botelho
|
# Calculate real first partition size, removing 256 blocks (131072 bytes) beginning/loader
|
353 |
|
|
local OVA_FIRST_PART_SIZE=$((${OVA_FIRST_PART_SIZE_IN_GB}*1024*1024*1024-131072))
|
354 |
2006b940
|
Renato Botelho
|
# Unset swap partition size variable
|
355 |
|
|
unset OVA_SWAP_PART_SIZE
|
356 |
|
|
# Parameter used by mkimg
|
357 |
|
|
unset OVA_SWAP_PART_PARAM
|
358 |
|
|
else
|
359 |
|
|
# first partition size (freebsd-ufs)
|
360 |
|
|
local OVA_FIRST_PART_SIZE_IN_GB=$((VMDK_DISK_CAPACITY_IN_GB-OVA_SWAP_PART_SIZE_IN_GB))
|
361 |
|
|
# Use first partition size in g
|
362 |
|
|
local OVA_FIRST_PART_SIZE="${OVA_FIRST_PART_SIZE_IN_GB}g"
|
363 |
c56630d7
|
Renato Botelho
|
# Calculate real swap size, removing 256 blocks (131072 bytes) beginning/loader
|
364 |
|
|
local OVA_SWAP_PART_SIZE=$((${OVA_SWAP_PART_SIZE_IN_GB}*1024*1024*1024-131072))
|
365 |
2006b940
|
Renato Botelho
|
# Parameter used by mkimg
|
366 |
|
|
local OVA_SWAP_PART_PARAM="-p freebsd-swap/swap0::${OVA_SWAP_PART_SIZE}"
|
367 |
|
|
fi
|
368 |
35104e03
|
Renato Botelho
|
|
369 |
6f73c362
|
Renato Botelho
|
# Prepare folder to be put in image
|
370 |
|
|
customize_stagearea_for_image "ova"
|
371 |
|
|
install_default_kernel ${DEFAULT_KERNEL} "no"
|
372 |
|
|
|
373 |
89a72b59
|
Renato Botelho
|
# Fill fstab
|
374 |
|
|
echo ">>> Installing platform specific items..." | tee -a ${LOGFILE}
|
375 |
c9b36088
|
Renato Botelho
|
echo "/dev/gpt/${PRODUCT_NAME} / ufs rw 1 1" > ${FINAL_CHROOT_DIR}/etc/fstab
|
376 |
2006b940
|
Renato Botelho
|
if [ -n "${OVA_SWAP_PART_SIZE}" ]; then
|
377 |
|
|
echo "/dev/gpt/swap0 none swap sw 0 0" >> ${FINAL_CHROOT_DIR}/etc/fstab
|
378 |
|
|
fi
|
379 |
89a72b59
|
Renato Botelho
|
|
380 |
|
|
# Create / partition
|
381 |
7743b4bd
|
Renato Botelho
|
echo -n ">>> Creating / partition... " | tee -a ${LOGFILE}
|
382 |
5de5a708
|
Renato Botelho
|
truncate -s ${OVA_FIRST_PART_SIZE} ${OVA_TMP}/${OVFUFS}
|
383 |
eeddd261
|
Renato Botelho
|
local _md=$(mdconfig -a -f ${OVA_TMP}/${OVFUFS})
|
384 |
5de5a708
|
Renato Botelho
|
trap "mdconfig -d -u ${_md}; return" 1 2 15 EXIT
|
385 |
|
|
|
386 |
|
|
newfs -L ${PRODUCT_NAME} -j /dev/${_md} 2>&1 >>${LOGFILE}
|
387 |
89a72b59
|
Renato Botelho
|
|
388 |
5de5a708
|
Renato Botelho
|
if ! mount /dev/${_md} ${_mntdir} 2>&1 >>${LOGFILE}; then
|
389 |
85bc1c63
|
Renato Botelho
|
echo "Failed!" | tee -a ${LOGFILE}
|
390 |
5de5a708
|
Renato Botelho
|
echo ">>> ERROR: Error mounting temporary vmdk image. STOPPING!" | tee -a ${LOGFILE}
|
391 |
85bc1c63
|
Renato Botelho
|
print_error_pfS
|
392 |
|
|
fi
|
393 |
32918935
|
Renato Botelho
|
trap "sync; sleep 3; umount ${_mntdir} || umount -f ${_mntdir}; mdconfig -d -u ${_md}; return" 1 2 15 EXIT
|
394 |
5de5a708
|
Renato Botelho
|
|
395 |
85bc1c63
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
396 |
|
|
|
397 |
5de5a708
|
Renato Botelho
|
clone_directory_contents ${FINAL_CHROOT_DIR} ${_mntdir}
|
398 |
|
|
|
399 |
|
|
sync
|
400 |
b2ee641c
|
Renato Botelho
|
sleep 3
|
401 |
32918935
|
Renato Botelho
|
umount ${_mntdir} || umount -f ${_mntdir} >>${LOGFILE} 2>&1
|
402 |
5de5a708
|
Renato Botelho
|
mdconfig -d -u ${_md}
|
403 |
|
|
trap "-" 1 2 15 EXIT
|
404 |
|
|
|
405 |
7743b4bd
|
Renato Botelho
|
# Create raw disk
|
406 |
|
|
echo -n ">>> Creating raw disk... " | tee -a ${LOGFILE}
|
407 |
89a72b59
|
Renato Botelho
|
mkimg \
|
408 |
|
|
-s gpt \
|
409 |
679b5a66
|
Renato Botelho
|
-f raw \
|
410 |
8f05bbd6
|
Renato Botelho
|
-b ${FINAL_CHROOT_DIR}/boot/pmbr \
|
411 |
|
|
-p freebsd-boot:=${FINAL_CHROOT_DIR}/boot/gptboot \
|
412 |
89a72b59
|
Renato Botelho
|
-p freebsd-ufs/${PRODUCT_NAME}:=${OVA_TMP}/${OVFUFS} \
|
413 |
2006b940
|
Renato Botelho
|
${OVA_SWAP_PART_PARAM} \
|
414 |
679b5a66
|
Renato Botelho
|
-o ${OVA_TMP}/${OVFRAW} 2>&1 >> ${LOGFILE}
|
415 |
89a72b59
|
Renato Botelho
|
|
416 |
679b5a66
|
Renato Botelho
|
if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFRAW} ]; then
|
417 |
89a72b59
|
Renato Botelho
|
if [ -f ${OVA_TMP}/${OVFUFS} ]; then
|
418 |
|
|
rm -f ${OVA_TMP}/${OVFUFS}
|
419 |
|
|
fi
|
420 |
679b5a66
|
Renato Botelho
|
if [ -f ${OVA_TMP}/${OVFRAW} ]; then
|
421 |
|
|
rm -f ${OVA_TMP}/${OVFRAW}
|
422 |
502db0bd
|
Renato Botelho
|
fi
|
423 |
7743b4bd
|
Renato Botelho
|
echo "Failed!" | tee -a ${LOGFILE}
|
424 |
502db0bd
|
Renato Botelho
|
echo ">>> ERROR: Error creating temporary vmdk image. STOPPING!" | tee -a ${LOGFILE}
|
425 |
|
|
print_error_pfS
|
426 |
|
|
fi
|
427 |
7743b4bd
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
428 |
502db0bd
|
Renato Botelho
|
|
429 |
|
|
# We don't need it anymore
|
430 |
|
|
rm -f ${OVA_TMP}/${OVFUFS} >/dev/null 2>&1
|
431 |
|
|
|
432 |
679b5a66
|
Renato Botelho
|
# Convert raw to vmdk
|
433 |
7743b4bd
|
Renato Botelho
|
echo -n ">>> Creating vmdk disk... " | tee -a ${LOGFILE}
|
434 |
beb07890
|
Renato Botelho
|
vmdktool -z9 -v ${OVA_TMP}/${OVFVMDK} ${OVA_TMP}/${OVFRAW}
|
435 |
502db0bd
|
Renato Botelho
|
|
436 |
2dc195f9
|
Renato Botelho
|
if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFVMDK} ]; then
|
437 |
679b5a66
|
Renato Botelho
|
if [ -f ${OVA_TMP}/${OVFRAW} ]; then
|
438 |
|
|
rm -f ${OVA_TMP}/${OVFRAW}
|
439 |
502db0bd
|
Renato Botelho
|
fi
|
440 |
89a72b59
|
Renato Botelho
|
if [ -f ${OVA_TMP}/${OVFVMDK} ]; then
|
441 |
|
|
rm -f ${OVA_TMP}/${OVFVMDK}
|
442 |
|
|
fi
|
443 |
7743b4bd
|
Renato Botelho
|
echo "Failed!" | tee -a ${LOGFILE}
|
444 |
89a72b59
|
Renato Botelho
|
echo ">>> ERROR: Error creating vmdk image. STOPPING!" | tee -a ${LOGFILE}
|
445 |
|
|
print_error_pfS
|
446 |
6f73c362
|
Renato Botelho
|
fi
|
447 |
7743b4bd
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
448 |
6f73c362
|
Renato Botelho
|
|
449 |
3437fab0
|
Renato Botelho
|
rm -f ${OVA_TMP}/${OVFRAW}
|
450 |
6f73c362
|
Renato Botelho
|
|
451 |
89a72b59
|
Renato Botelho
|
ova_setup_ovf_template
|
452 |
6f73c362
|
Renato Botelho
|
|
453 |
7743b4bd
|
Renato Botelho
|
echo -n ">>> Writing final ova image... " | tee -a ${LOGFILE}
|
454 |
|
|
# Create OVA file for vmware
|
455 |
89a72b59
|
Renato Botelho
|
gtar -C ${OVA_TMP} -cpf ${OVAPATH} ${PRODUCT_NAME}.ovf ${OVFVMDK}
|
456 |
7743b4bd
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
457 |
89a72b59
|
Renato Botelho
|
rm -f ${OVA_TMP}/${OVFVMDK} >/dev/null 2>&1
|
458 |
|
|
|
459 |
|
|
echo ">>> OVA created: $(LC_ALL=C date)" | tee -a ${LOGFILE}
|
460 |
6f73c362
|
Renato Botelho
|
}
|
461 |
|
|
|
462 |
|
|
# called from create_ova_image
|
463 |
a82b9f43
|
Renato Botelho
|
ova_setup_ovf_template() {
|
464 |
fc48ef54
|
Renato Botelho
|
if [ ! -f ${OVFTEMPLATE} ]; then
|
465 |
173fa93f
|
Renato Botelho
|
echo ">>> ERROR: OVF template file (${OVFTEMPLATE}) not found."
|
466 |
|
|
print_error_pfS
|
467 |
6f73c362
|
Renato Botelho
|
fi
|
468 |
|
|
|
469 |
fc48ef54
|
Renato Botelho
|
# OperatingSystemSection (${PRODUCT_NAME}.ovf)
|
470 |
|
|
# 42 FreeBSD 32-Bit
|
471 |
|
|
# 78 FreeBSD 64-Bit
|
472 |
|
|
if [ "${TARGET}" = "amd64" ]; then
|
473 |
|
|
local _os_id="78"
|
474 |
502db0bd
|
Renato Botelho
|
local _os_type="freebsd64Guest"
|
475 |
|
|
local _os_descr="FreeBSD 64-Bit"
|
476 |
fc48ef54
|
Renato Botelho
|
else
|
477 |
|
|
echo ">>> ERROR: Platform not supported for OVA (${TARGET})"
|
478 |
|
|
print_error_pfS
|
479 |
|
|
fi
|
480 |
50dcadff
|
Renato Botelho
|
|
481 |
502db0bd
|
Renato Botelho
|
local POPULATED_SIZE=$(du -d0 -k $FINAL_CHROOT_DIR | cut -f1)
|
482 |
|
|
local POPULATED_SIZE_IN_BYTES=$((${POPULATED_SIZE}*1024))
|
483 |
|
|
local VMDK_FILE_SIZE=$(stat -f "%z" ${OVA_TMP}/${OVFVMDK})
|
484 |
6f73c362
|
Renato Botelho
|
|
485 |
fc48ef54
|
Renato Botelho
|
sed \
|
486 |
502db0bd
|
Renato Botelho
|
-e "s,%%VMDK_FILE_SIZE%%,${VMDK_FILE_SIZE},g" \
|
487 |
|
|
-e "s,%%VMDK_DISK_CAPACITY_IN_GB%%,${VMDK_DISK_CAPACITY_IN_GB},g" \
|
488 |
|
|
-e "s,%%POPULATED_SIZE_IN_BYTES%%,${POPULATED_SIZE_IN_BYTES},g" \
|
489 |
fc48ef54
|
Renato Botelho
|
-e "s,%%OS_ID%%,${_os_id},g" \
|
490 |
|
|
-e "s,%%OS_TYPE%%,${_os_type},g" \
|
491 |
502db0bd
|
Renato Botelho
|
-e "s,%%OS_DESCR%%,${_os_descr},g" \
|
492 |
fc48ef54
|
Renato Botelho
|
-e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" \
|
493 |
f2d83cfb
|
Renato Botelho
|
-e "s,%%PRODUCT_NAME_SUFFIX%%,${PRODUCT_NAME_SUFFIX},g" \
|
494 |
fc48ef54
|
Renato Botelho
|
-e "s,%%PRODUCT_VERSION%%,${PRODUCT_VERSION},g" \
|
495 |
|
|
-e "s,%%PRODUCT_URL%%,${PRODUCT_URL},g" \
|
496 |
0e334a37
|
Renato Botelho
|
-e "s#%%VENDOR_NAME%%#${VENDOR_NAME}#g" \
|
497 |
|
|
-e "s#%%OVF_INFO%%#${OVF_INFO}#g" \
|
498 |
b12ea3fb
|
Renato Botelho
|
-e "/^%%PRODUCT_LICENSE%%/r ${BUILDER_ROOT}/LICENSE" \
|
499 |
fc48ef54
|
Renato Botelho
|
-e "/^%%PRODUCT_LICENSE%%/d" \
|
500 |
|
|
${OVFTEMPLATE} > ${OVA_TMP}/${PRODUCT_NAME}.ovf
|
501 |
6f73c362
|
Renato Botelho
|
}
|
502 |
|
|
|
503 |
|
|
# Cleans up previous builds
|
504 |
7e6ab3ed
|
Renato Botelho
|
clean_builder() {
|
505 |
6f73c362
|
Renato Botelho
|
# Clean out directories
|
506 |
|
|
echo ">>> Cleaning up previous build environment...Please wait!"
|
507 |
|
|
|
508 |
|
|
staginareas_clean_each_run
|
509 |
|
|
|
510 |
|
|
if [ -d "${STAGE_CHROOT_DIR}" ]; then
|
511 |
729c0c7a
|
Renato Botelho
|
echo -n ">>> Cleaning ${STAGE_CHROOT_DIR}... "
|
512 |
6f73c362
|
Renato Botelho
|
chflags -R noschg ${STAGE_CHROOT_DIR} 2>&1 >/dev/null
|
513 |
f546e6ca
|
Renato Botelho
|
rm -rf ${STAGE_CHROOT_DIR}/* 2>/dev/null
|
514 |
6f73c362
|
Renato Botelho
|
echo "Done."
|
515 |
|
|
fi
|
516 |
|
|
|
517 |
729c0c7a
|
Renato Botelho
|
if [ -d "${INSTALLER_CHROOT_DIR}" ]; then
|
518 |
|
|
echo -n ">>> Cleaning ${INSTALLER_CHROOT_DIR}... "
|
519 |
|
|
chflags -R noschg ${INSTALLER_CHROOT_DIR} 2>&1 >/dev/null
|
520 |
|
|
rm -rf ${INSTALLER_CHROOT_DIR}/* 2>/dev/null
|
521 |
|
|
echo "Done."
|
522 |
|
|
fi
|
523 |
|
|
|
524 |
2abc3e80
|
Renato Botelho
|
if [ -z "${NO_CLEAN_FREEBSD_OBJ}" -a -d "${FREEBSD_SRC_DIR}" ]; then
|
525 |
edfe9e76
|
Renato Botelho
|
OBJTREE=$(make -C ${FREEBSD_SRC_DIR} -V OBJTREE)
|
526 |
6f73c362
|
Renato Botelho
|
if [ -d "${OBJTREE}" ]; then
|
527 |
|
|
echo -n ">>> Cleaning FreeBSD objects dir staging..."
|
528 |
|
|
echo -n "."
|
529 |
|
|
chflags -R noschg ${OBJTREE} 2>&1 >/dev/null
|
530 |
|
|
echo -n "."
|
531 |
|
|
rm -rf ${OBJTREE}/*
|
532 |
|
|
echo "Done!"
|
533 |
|
|
fi
|
534 |
7e6ab3ed
|
Renato Botelho
|
if [ -d "${KERNEL_BUILD_PATH}" ]; then
|
535 |
6f73c362
|
Renato Botelho
|
echo -n ">>> Cleaning previously built kernel stage area..."
|
536 |
|
|
rm -rf $KERNEL_BUILD_PATH/*
|
537 |
|
|
echo "Done!"
|
538 |
|
|
fi
|
539 |
|
|
fi
|
540 |
|
|
mkdir -p $KERNEL_BUILD_PATH
|
541 |
|
|
|
542 |
|
|
echo -n ">>> Cleaning previously built images..."
|
543 |
04992be2
|
Renato Botelho
|
rm -rf $IMAGES_FINAL_DIR/*
|
544 |
6f73c362
|
Renato Botelho
|
echo "Done!"
|
545 |
|
|
|
546 |
|
|
echo -n ">>> Cleaning previous builder logs..."
|
547 |
|
|
if [ -d "$BUILDER_LOGS" ]; then
|
548 |
|
|
rm -rf ${BUILDER_LOGS}
|
549 |
|
|
fi
|
550 |
|
|
mkdir -p ${BUILDER_LOGS}
|
551 |
|
|
|
552 |
|
|
echo "Done!"
|
553 |
|
|
|
554 |
|
|
echo ">>> Cleaning of builder environment has finished."
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
clone_directory_contents() {
|
558 |
25c5455d
|
Renato Botelho
|
if [ ! -e "$2" ]; then
|
559 |
|
|
mkdir -p "$2"
|
560 |
|
|
fi
|
561 |
6f73c362
|
Renato Botelho
|
if [ ! -d "$1" -o ! -d "$2" ]; then
|
562 |
|
|
if [ -z "${LOGFILE}" ]; then
|
563 |
|
|
echo ">>> ERROR: Argument $1 supplied is not a directory!"
|
564 |
|
|
else
|
565 |
|
|
echo ">>> ERROR: Argument $1 supplied is not a directory!" | tee -a ${LOGFILE}
|
566 |
|
|
fi
|
567 |
|
|
print_error_pfS
|
568 |
|
|
fi
|
569 |
|
|
echo -n ">>> Using TAR to clone $1 to $2 ..."
|
570 |
|
|
tar -C ${1} -c -f - . | tar -C ${2} -x -p -f -
|
571 |
|
|
echo "Done!"
|
572 |
|
|
}
|
573 |
|
|
|
574 |
|
|
clone_to_staging_area() {
|
575 |
|
|
# Clone everything to the final staging area
|
576 |
|
|
echo -n ">>> Cloning everything to ${STAGE_CHROOT_DIR} staging area..."
|
577 |
|
|
LOGFILE=${BUILDER_LOGS}/cloning.${TARGET}.log
|
578 |
|
|
|
579 |
694028d6
|
Renato Botelho
|
tar -C ${PRODUCT_SRC} -c -f - . | \
|
580 |
6f73c362
|
Renato Botelho
|
tar -C ${STAGE_CHROOT_DIR} -x -p -f -
|
581 |
|
|
|
582 |
|
|
mkdir -p ${STAGE_CHROOT_DIR}/etc/mtree
|
583 |
|
|
mtree -Pcp ${STAGE_CHROOT_DIR}/var > ${STAGE_CHROOT_DIR}/etc/mtree/var.dist
|
584 |
|
|
mtree -Pcp ${STAGE_CHROOT_DIR}/etc > ${STAGE_CHROOT_DIR}/etc/mtree/etc.dist
|
585 |
|
|
if [ -d ${STAGE_CHROOT_DIR}/usr/local/etc ]; then
|
586 |
|
|
mtree -Pcp ${STAGE_CHROOT_DIR}/usr/local/etc > ${STAGE_CHROOT_DIR}/etc/mtree/localetc.dist
|
587 |
|
|
fi
|
588 |
|
|
|
589 |
|
|
## Add buildtime and lastcommit information
|
590 |
|
|
# This is used for detecting updates.
|
591 |
|
|
echo "$BUILTDATESTRING" > $STAGE_CHROOT_DIR/etc/version.buildtime
|
592 |
|
|
# Record last commit info if it is available.
|
593 |
|
|
if [ -f $SCRATCHDIR/build_commit_info.txt ]; then
|
594 |
|
|
cp $SCRATCHDIR/build_commit_info.txt $STAGE_CHROOT_DIR/etc/version.lastcommit
|
595 |
|
|
fi
|
596 |
|
|
|
597 |
0d67c726
|
Renato Botelho
|
local _exclude_files="${SCRATCHDIR}/base_exclude_files"
|
598 |
6f73c362
|
Renato Botelho
|
sed \
|
599 |
|
|
-e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" \
|
600 |
|
|
-e "s,%%VERSION%%,${_version},g" \
|
601 |
0ce2a7f3
|
Renato Botelho
|
${BUILDER_TOOLS}/templates/core_pkg/base/exclude_files \
|
602 |
6f73c362
|
Renato Botelho
|
> ${_exclude_files}
|
603 |
|
|
|
604 |
651f440c
|
Renato Botelho
|
mkdir -p ${STAGE_CHROOT_DIR}${PRODUCT_SHARE_DIR} >/dev/null 2>&1
|
605 |
10742be9
|
Renato Botelho
|
|
606 |
|
|
# Include a sample pkg stable conf to base
|
607 |
|
|
setup_pkg_repo \
|
608 |
db8621d8
|
Renato Botelho
|
${PKG_REPO_DEFAULT} \
|
609 |
651f440c
|
Renato Botelho
|
${STAGE_CHROOT_DIR}${PRODUCT_SHARE_DIR}/${PRODUCT_NAME}-repo.conf \
|
610 |
10742be9
|
Renato Botelho
|
${TARGET} \
|
611 |
74a4eefb
|
Renato Botelho
|
${TARGET_ARCH}
|
612 |
10742be9
|
Renato Botelho
|
|
613 |
6f73c362
|
Renato Botelho
|
mtree \
|
614 |
|
|
-c \
|
615 |
|
|
-k uid,gid,mode,size,flags,sha256digest \
|
616 |
|
|
-p ${STAGE_CHROOT_DIR} \
|
617 |
|
|
-X ${_exclude_files} \
|
618 |
651f440c
|
Renato Botelho
|
> ${STAGE_CHROOT_DIR}${PRODUCT_SHARE_DIR}/base.mtree
|
619 |
6f73c362
|
Renato Botelho
|
tar \
|
620 |
|
|
-C ${STAGE_CHROOT_DIR} \
|
621 |
651f440c
|
Renato Botelho
|
-cJf ${STAGE_CHROOT_DIR}${PRODUCT_SHARE_DIR}/base.txz \
|
622 |
6f73c362
|
Renato Botelho
|
-X ${_exclude_files} \
|
623 |
|
|
.
|
624 |
|
|
|
625 |
dab31392
|
Renato Botelho
|
core_pkg_create rc "" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
626 |
6f73c362
|
Renato Botelho
|
core_pkg_create base "" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
627 |
|
|
core_pkg_create default-config "" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
628 |
|
|
|
629 |
|
|
local DEFAULTCONF=${STAGE_CHROOT_DIR}/conf.default/config.xml
|
630 |
c4968f42
|
Renato Botelho
|
|
631 |
2f6260c5
|
Renato Botelho
|
# Save current WAN and LAN if value
|
632 |
168c162a
|
Renato Botelho
|
local _old_wan_if=$(xml sel -t -v "${XML_ROOTOBJ}/interfaces/wan/if" ${DEFAULTCONF})
|
633 |
|
|
local _old_lan_if=$(xml sel -t -v "${XML_ROOTOBJ}/interfaces/lan/if" ${DEFAULTCONF})
|
634 |
2f6260c5
|
Renato Botelho
|
|
635 |
c4968f42
|
Renato Botelho
|
# Change default interface names to match vmware driver
|
636 |
2f6260c5
|
Renato Botelho
|
xml ed -P -L -u "${XML_ROOTOBJ}/interfaces/wan/if" -v "vmx0" ${DEFAULTCONF}
|
637 |
|
|
xml ed -P -L -u "${XML_ROOTOBJ}/interfaces/lan/if" -v "vmx1" ${DEFAULTCONF}
|
638 |
fbd4dfc0
|
Renato Botelho
|
core_pkg_create default-config "vmware" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
639 |
c4968f42
|
Renato Botelho
|
|
640 |
|
|
# Restore default values to be used by serial package
|
641 |
2f6260c5
|
Renato Botelho
|
xml ed -P -L -u "${XML_ROOTOBJ}/interfaces/wan/if" -v "${_old_wan_if}" ${DEFAULTCONF}
|
642 |
|
|
xml ed -P -L -u "${XML_ROOTOBJ}/interfaces/lan/if" -v "${_old_lan_if}" ${DEFAULTCONF}
|
643 |
c4968f42
|
Renato Botelho
|
|
644 |
6f73c362
|
Renato Botelho
|
# Activate serial console in config.xml
|
645 |
2f6260c5
|
Renato Botelho
|
xml ed -L -P -d "${XML_ROOTOBJ}/system/enableserial" ${DEFAULTCONF}
|
646 |
|
|
xml ed -P -s "${XML_ROOTOBJ}/system" -t elem -n "enableserial" \
|
647 |
|
|
${DEFAULTCONF} > ${DEFAULTCONF}.tmp
|
648 |
|
|
xml fo -t ${DEFAULTCONF}.tmp > ${DEFAULTCONF}
|
649 |
|
|
rm -f ${DEFAULTCONF}.tmp
|
650 |
6f73c362
|
Renato Botelho
|
|
651 |
|
|
echo force > ${STAGE_CHROOT_DIR}/cf/conf/enableserial_force
|
652 |
|
|
|
653 |
|
|
core_pkg_create default-config-serial "" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
654 |
4cd703e9
|
Brad Davis
|
core_pkg_create default-config "bhyve" ${CORE_PKG_VERSION} ${STAGE_CHROOT_DIR}
|
655 |
6f73c362
|
Renato Botelho
|
|
656 |
|
|
rm -f ${STAGE_CHROOT_DIR}/cf/conf/enableserial_force
|
657 |
|
|
rm -f ${STAGE_CHROOT_DIR}/cf/conf/config.xml
|
658 |
|
|
|
659 |
|
|
# Make sure pkg is present
|
660 |
|
|
pkg_bootstrap ${STAGE_CHROOT_DIR}
|
661 |
|
|
|
662 |
3e80d64e
|
Renato Botelho
|
# Make sure correct repo is available on tmp dir
|
663 |
a76b4810
|
Renato Botelho
|
mkdir -p ${STAGE_CHROOT_DIR}/tmp/pkg/pkg-repos
|
664 |
3e80d64e
|
Renato Botelho
|
setup_pkg_repo \
|
665 |
dbd615c4
|
Renato Botelho
|
${PKG_REPO_BUILD} \
|
666 |
a76b4810
|
Renato Botelho
|
${STAGE_CHROOT_DIR}/tmp/pkg/pkg-repos/repo.conf \
|
667 |
3e80d64e
|
Renato Botelho
|
${TARGET} \
|
668 |
|
|
${TARGET_ARCH} \
|
669 |
a76b4810
|
Renato Botelho
|
staging \
|
670 |
|
|
${STAGE_CHROOT_DIR}/tmp/pkg/pkg.conf
|
671 |
3e80d64e
|
Renato Botelho
|
|
672 |
6f73c362
|
Renato Botelho
|
echo "Done!"
|
673 |
|
|
}
|
674 |
|
|
|
675 |
|
|
create_final_staging_area() {
|
676 |
|
|
if [ -z "${FINAL_CHROOT_DIR}" ]; then
|
677 |
|
|
echo ">>> ERROR: FINAL_CHROOT_DIR is not set, cannot continue!" | tee -a ${LOGFILE}
|
678 |
|
|
print_error_pfS
|
679 |
|
|
fi
|
680 |
|
|
|
681 |
|
|
if [ -d "${FINAL_CHROOT_DIR}" ]; then
|
682 |
|
|
echo -n ">>> Previous ${FINAL_CHROOT_DIR} detected cleaning up..." | tee -a ${LOGFILE}
|
683 |
|
|
chflags -R noschg ${FINAL_CHROOT_DIR} 2>&1 1>/dev/null
|
684 |
|
|
rm -rf ${FINAL_CHROOT_DIR}/* 2>&1 1>/dev/null
|
685 |
|
|
echo "Done." | tee -a ${LOGFILE}
|
686 |
|
|
fi
|
687 |
|
|
|
688 |
|
|
echo ">>> Preparing Final image staging area: $(LC_ALL=C date)" 2>&1 | tee -a ${LOGFILE}
|
689 |
|
|
echo ">>> Cloning ${STAGE_CHROOT_DIR} to ${FINAL_CHROOT_DIR}" 2>&1 | tee -a ${LOGFILE}
|
690 |
|
|
clone_directory_contents ${STAGE_CHROOT_DIR} ${FINAL_CHROOT_DIR}
|
691 |
|
|
|
692 |
|
|
if [ ! -f $FINAL_CHROOT_DIR/sbin/init ]; then
|
693 |
|
|
echo ">>> ERROR: Something went wrong during cloning -- Please verify!" 2>&1 | tee -a ${LOGFILE}
|
694 |
|
|
print_error_pfS
|
695 |
|
|
fi
|
696 |
|
|
}
|
697 |
|
|
|
698 |
|
|
customize_stagearea_for_image() {
|
699 |
b2fbacdc
|
Renato Botelho
|
local _image_type="$1"
|
700 |
b0d0498c
|
Renato Botelho
|
local _default_config="" # filled with $2 below
|
701 |
|
|
local _image_variant="$3"
|
702 |
75e28295
|
Renato Botelho
|
|
703 |
|
|
if [ -n "$2" ]; then
|
704 |
|
|
_default_config="$2"
|
705 |
2ac4be3a
|
Renato Botelho
|
elif [ "${_image_type}" = "memstickserial" -o \
|
706 |
75e28295
|
Renato Botelho
|
"${_image_type}" = "memstickadi" ]; then
|
707 |
|
|
_default_config="default-config-serial"
|
708 |
|
|
elif [ "${_image_type}" = "ova" ]; then
|
709 |
|
|
_default_config="default-config-vmware"
|
710 |
|
|
else
|
711 |
|
|
_default_config="default-config"
|
712 |
|
|
fi
|
713 |
b2fbacdc
|
Renato Botelho
|
|
714 |
6f73c362
|
Renato Botelho
|
# Prepare final stage area
|
715 |
|
|
create_final_staging_area
|
716 |
|
|
|
717 |
dab31392
|
Renato Botelho
|
pkg_chroot_add ${FINAL_CHROOT_DIR} rc
|
718 |
2ac4be3a
|
Renato Botelho
|
pkg_chroot_add ${FINAL_CHROOT_DIR} base
|
719 |
6ee167de
|
Renato Botelho
|
|
720 |
d071acf5
|
Renato Botelho
|
# Set base/rc pkgs as vital to avoid user end up removing it for any reason
|
721 |
|
|
pkg_chroot ${FINAL_CHROOT_DIR} set -v 1 -y $(get_pkg_name rc)
|
722 |
|
|
pkg_chroot ${FINAL_CHROOT_DIR} set -v 1 -y $(get_pkg_name base)
|
723 |
|
|
|
724 |
b2fbacdc
|
Renato Botelho
|
if [ "${_image_type}" = "iso" -o \
|
725 |
|
|
"${_image_type}" = "memstick" -o \
|
726 |
|
|
"${_image_type}" = "memstickserial" -o \
|
727 |
|
|
"${_image_type}" = "memstickadi" ]; then
|
728 |
6f73c362
|
Renato Botelho
|
mkdir -p ${FINAL_CHROOT_DIR}/pkgs
|
729 |
91039db4
|
Renato Botelho
|
cp ${CORE_PKG_ALL_PATH}/*default-config*.txz ${FINAL_CHROOT_DIR}/pkgs
|
730 |
6f73c362
|
Renato Botelho
|
fi
|
731 |
|
|
|
732 |
75e28295
|
Renato Botelho
|
pkg_chroot_add ${FINAL_CHROOT_DIR} ${_default_config}
|
733 |
052f4bdb
|
Renato Botelho
|
|
734 |
|
|
# XXX: Workaround to avoid pkg to complain regarding release
|
735 |
|
|
# repo on first boot since packages are installed from
|
736 |
|
|
# staging server during build phase
|
737 |
74a4eefb
|
Renato Botelho
|
if [ -n "${USE_PKG_REPO_STAGING}" ]; then
|
738 |
052f4bdb
|
Renato Botelho
|
_read_cmd="select value from repodata where key='packagesite'"
|
739 |
f3800174
|
Renato Botelho
|
if [ -n "${_IS_RELEASE}" -o -n "${_IS_RC}" ]; then
|
740 |
71002df8
|
Renato Botelho
|
local _tgt_server="${PKG_REPO_SERVER_RELEASE}"
|
741 |
|
|
else
|
742 |
|
|
local _tgt_server="${PKG_REPO_SERVER_DEVEL}"
|
743 |
|
|
fi
|
744 |
052f4bdb
|
Renato Botelho
|
for _db in ${FINAL_CHROOT_DIR}/var/db/pkg/repo-*sqlite; do
|
745 |
|
|
_cur=$(/usr/local/bin/sqlite3 ${_db} "${_read_cmd}")
|
746 |
71002df8
|
Renato Botelho
|
_new=$(echo "${_cur}" | sed -e "s,^${PKG_REPO_SERVER_STAGING},${_tgt_server},")
|
747 |
052f4bdb
|
Renato Botelho
|
/usr/local/bin/sqlite3 ${_db} "update repodata set value='${_new}' where key='packagesite'"
|
748 |
|
|
done
|
749 |
|
|
fi
|
750 |
b0d0498c
|
Renato Botelho
|
|
751 |
|
|
if [ -n "$_image_variant" -a \
|
752 |
|
|
-d ${BUILDER_TOOLS}/templates/custom_logos/${_image_variant} ]; then
|
753 |
|
|
mkdir -p ${FINAL_CHROOT_DIR}/usr/local/share/${PRODUCT_NAME}/custom_logos
|
754 |
|
|
cp -f \
|
755 |
c8735982
|
Renato Botelho
|
${BUILDER_TOOLS}/templates/custom_logos/${_image_variant}/*.svg \
|
756 |
|
|
${FINAL_CHROOT_DIR}/usr/local/share/${PRODUCT_NAME}/custom_logos
|
757 |
|
|
cp -f \
|
758 |
|
|
${BUILDER_TOOLS}/templates/custom_logos/${_image_variant}/*.css \
|
759 |
b0d0498c
|
Renato Botelho
|
${FINAL_CHROOT_DIR}/usr/local/share/${PRODUCT_NAME}/custom_logos
|
760 |
|
|
fi
|
761 |
3e80d64e
|
Renato Botelho
|
|
762 |
|
|
# Remove temporary repo conf
|
763 |
a76b4810
|
Renato Botelho
|
rm -rf ${FINAL_CHROOT_DIR}/tmp/pkg
|
764 |
6f73c362
|
Renato Botelho
|
}
|
765 |
|
|
|
766 |
|
|
create_distribution_tarball() {
|
767 |
729c0c7a
|
Renato Botelho
|
mkdir -p ${INSTALLER_CHROOT_DIR}/usr/freebsd-dist
|
768 |
|
|
|
769 |
cd618e85
|
Renato Botelho
|
echo -n ">>> Creating distribution tarball... " | tee -a ${LOGFILE}
|
770 |
c0ac85e7
|
Renato Botelho
|
tar -C ${FINAL_CHROOT_DIR} --exclude ./pkgs \
|
771 |
729c0c7a
|
Renato Botelho
|
-cJf ${INSTALLER_CHROOT_DIR}/usr/freebsd-dist/base.txz .
|
772 |
cd618e85
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
773 |
6f73c362
|
Renato Botelho
|
|
774 |
cd618e85
|
Renato Botelho
|
echo -n ">>> Creating manifest... " | tee -a ${LOGFILE}
|
775 |
729c0c7a
|
Renato Botelho
|
(cd ${INSTALLER_CHROOT_DIR}/usr/freebsd-dist && \
|
776 |
|
|
sh ${FREEBSD_SRC_DIR}/release/scripts/make-manifest.sh base.txz) \
|
777 |
|
|
> ${INSTALLER_CHROOT_DIR}/usr/freebsd-dist/MANIFEST
|
778 |
cd618e85
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
779 |
6f73c362
|
Renato Botelho
|
}
|
780 |
|
|
|
781 |
|
|
create_iso_image() {
|
782 |
b17d47b6
|
Renato Botelho
|
local _variant="$1"
|
783 |
|
|
|
784 |
6f73c362
|
Renato Botelho
|
LOGFILE=${BUILDER_LOGS}/isoimage.${TARGET}
|
785 |
102e7265
|
Renato Botelho
|
|
786 |
00dc6b2a
|
Renato Botelho
|
if [ -z "${ISOPATH}" ]; then
|
787 |
5df6d76a
|
Renato Botelho
|
echo ">>> ISOPATH is empty skipping generation of ISO image!" | tee -a ${LOGFILE}
|
788 |
|
|
return
|
789 |
6f73c362
|
Renato Botelho
|
fi
|
790 |
|
|
|
791 |
5df6d76a
|
Renato Botelho
|
echo ">>> Building bootable ISO image for ${TARGET}" | tee -a ${LOGFILE}
|
792 |
|
|
|
793 |
f26731b0
|
Renato Botelho
|
mkdir -p $(dirname ${ISOPATH})
|
794 |
|
|
|
795 |
b17d47b6
|
Renato Botelho
|
local _image_path=${ISOPATH}
|
796 |
|
|
if [ -n "${_variant}" ]; then
|
797 |
|
|
_image_path=$(echo "$_image_path" | \
|
798 |
|
|
sed "s/${PRODUCT_NAME_SUFFIX}-/&${_variant}-/")
|
799 |
|
|
VARIANTIMAGES="${VARIANTIMAGES}${VARIANTIMAGES:+ }${_image_path}"
|
800 |
|
|
fi
|
801 |
|
|
|
802 |
|
|
customize_stagearea_for_image "iso" "" $_variant
|
803 |
6f73c362
|
Renato Botelho
|
install_default_kernel ${DEFAULT_KERNEL}
|
804 |
|
|
|
805 |
5df6d76a
|
Renato Botelho
|
BOOTCONF=${INSTALLER_CHROOT_DIR}/boot.config
|
806 |
|
|
LOADERCONF=${INSTALLER_CHROOT_DIR}/boot/loader.conf
|
807 |
6f73c362
|
Renato Botelho
|
|
808 |
5df6d76a
|
Renato Botelho
|
rm -f ${LOADERCONF} ${BOOTCONF} >/dev/null 2>&1
|
809 |
788f1c3b
|
Renato Botelho
|
echo 'autoboot_delay="3"' > ${LOADERCONF}
|
810 |
286ec1c7
|
Renato Botelho
|
echo 'kern.cam.boot_delay=10000' >> ${LOADERCONF}
|
811 |
788f1c3b
|
Renato Botelho
|
cat ${LOADERCONF} > ${FINAL_CHROOT_DIR}/boot/loader.conf
|
812 |
6f73c362
|
Renato Botelho
|
|
813 |
|
|
create_distribution_tarball
|
814 |
|
|
|
815 |
5df6d76a
|
Renato Botelho
|
FSLABEL=$(echo ${PRODUCT_NAME} | tr '[:lower:]' '[:upper:]')
|
816 |
|
|
|
817 |
102e7265
|
Renato Botelho
|
sh ${FREEBSD_SRC_DIR}/release/${TARGET}/mkisoimages.sh -b \
|
818 |
5df6d76a
|
Renato Botelho
|
${FSLABEL} \
|
819 |
b17d47b6
|
Renato Botelho
|
${_image_path} \
|
820 |
5df6d76a
|
Renato Botelho
|
${INSTALLER_CHROOT_DIR}
|
821 |
6f73c362
|
Renato Botelho
|
|
822 |
b17d47b6
|
Renato Botelho
|
if [ ! -f "${_image_path}" ]; then
|
823 |
044ff383
|
Renato Botelho
|
echo "ERROR! ISO image was not built"
|
824 |
|
|
print_error_pfS
|
825 |
|
|
fi
|
826 |
|
|
|
827 |
b17d47b6
|
Renato Botelho
|
gzip -qf $_image_path &
|
828 |
39ef49f6
|
Renato Botelho
|
_bg_pids="${_bg_pids}${_bg_pids:+ }$!"
|
829 |
6f73c362
|
Renato Botelho
|
|
830 |
|
|
echo ">>> ISO created: $(LC_ALL=C date)" | tee -a ${LOGFILE}
|
831 |
|
|
}
|
832 |
|
|
|
833 |
|
|
create_memstick_image() {
|
834 |
b0d0498c
|
Renato Botelho
|
local _variant="$1"
|
835 |
|
|
|
836 |
6f73c362
|
Renato Botelho
|
LOGFILE=${BUILDER_LOGS}/memstick.${TARGET}
|
837 |
|
|
if [ "${MEMSTICKPATH}" = "" ]; then
|
838 |
|
|
echo ">>> MEMSTICKPATH is empty skipping generation of memstick image!" | tee -a ${LOGFILE}
|
839 |
|
|
return
|
840 |
|
|
fi
|
841 |
|
|
|
842 |
f26731b0
|
Renato Botelho
|
mkdir -p $(dirname ${MEMSTICKPATH})
|
843 |
|
|
|
844 |
b0d0498c
|
Renato Botelho
|
local _image_path=${MEMSTICKPATH}
|
845 |
|
|
if [ -n "${_variant}" ]; then
|
846 |
|
|
_image_path=$(echo "$_image_path" | \
|
847 |
|
|
sed "s/-memstick-/-memstick-${_variant}-/")
|
848 |
|
|
VARIANTIMAGES="${VARIANTIMAGES}${VARIANTIMAGES:+ }${_image_path}"
|
849 |
|
|
fi
|
850 |
|
|
|
851 |
|
|
customize_stagearea_for_image "memstick" "" $_variant
|
852 |
624376f6
|
Renato Botelho
|
install_default_kernel ${DEFAULT_KERNEL}
|
853 |
6f73c362
|
Renato Botelho
|
|
854 |
b0d0498c
|
Renato Botelho
|
echo ">>> Creating memstick to ${_image_path}." 2>&1 | tee -a ${LOGFILE}
|
855 |
6f73c362
|
Renato Botelho
|
|
856 |
6b5779e9
|
Renato Botelho
|
BOOTCONF=${INSTALLER_CHROOT_DIR}/boot.config
|
857 |
|
|
LOADERCONF=${INSTALLER_CHROOT_DIR}/boot/loader.conf
|
858 |
|
|
|
859 |
|
|
rm -f ${LOADERCONF} ${BOOTCONF} >/dev/null 2>&1
|
860 |
|
|
|
861 |
788f1c3b
|
Renato Botelho
|
echo 'autoboot_delay="3"' > ${LOADERCONF}
|
862 |
286ec1c7
|
Renato Botelho
|
echo 'kern.cam.boot_delay=10000' >> ${LOADERCONF}
|
863 |
4511fe40
|
Renato Botelho do Couto
|
echo 'boot_serial="NO"' >> ${LOADERCONF}
|
864 |
788f1c3b
|
Renato Botelho
|
cat ${LOADERCONF} > ${FINAL_CHROOT_DIR}/boot/loader.conf
|
865 |
6b5779e9
|
Renato Botelho
|
|
866 |
6f73c362
|
Renato Botelho
|
create_distribution_tarball
|
867 |
|
|
|
868 |
b66b246e
|
Renato Botelho
|
FSLABEL=$(echo ${PRODUCT_NAME} | tr '[:lower:]' '[:upper:]')
|
869 |
|
|
|
870 |
|
|
sh ${FREEBSD_SRC_DIR}/release/${TARGET}/mkisoimages.sh -b \
|
871 |
|
|
${FSLABEL} \
|
872 |
|
|
${_image_path} \
|
873 |
|
|
${INSTALLER_CHROOT_DIR}
|
874 |
729c0c7a
|
Renato Botelho
|
|
875 |
044ff383
|
Renato Botelho
|
if [ ! -f "${_image_path}" ]; then
|
876 |
|
|
echo "ERROR! memstick image was not built"
|
877 |
|
|
print_error_pfS
|
878 |
|
|
fi
|
879 |
|
|
|
880 |
b0d0498c
|
Renato Botelho
|
gzip -qf $_image_path &
|
881 |
39ef49f6
|
Renato Botelho
|
_bg_pids="${_bg_pids}${_bg_pids:+ }$!"
|
882 |
6f73c362
|
Renato Botelho
|
|
883 |
|
|
echo ">>> MEMSTICK created: $(LC_ALL=C date)" | tee -a ${LOGFILE}
|
884 |
|
|
}
|
885 |
|
|
|
886 |
|
|
create_memstick_serial_image() {
|
887 |
|
|
LOGFILE=${BUILDER_LOGS}/memstickserial.${TARGET}
|
888 |
|
|
if [ "${MEMSTICKSERIALPATH}" = "" ]; then
|
889 |
|
|
echo ">>> MEMSTICKSERIALPATH is empty skipping generation of memstick image!" | tee -a ${LOGFILE}
|
890 |
|
|
return
|
891 |
|
|
fi
|
892 |
|
|
|
893 |
f26731b0
|
Renato Botelho
|
mkdir -p $(dirname ${MEMSTICKSERIALPATH})
|
894 |
|
|
|
895 |
624376f6
|
Renato Botelho
|
customize_stagearea_for_image "memstickserial"
|
896 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
897 |
6f73c362
|
Renato Botelho
|
|
898 |
|
|
echo ">>> Creating serial memstick to ${MEMSTICKSERIALPATH}." 2>&1 | tee -a ${LOGFILE}
|
899 |
|
|
|
900 |
6b5779e9
|
Renato Botelho
|
BOOTCONF=${INSTALLER_CHROOT_DIR}/boot.config
|
901 |
|
|
LOADERCONF=${INSTALLER_CHROOT_DIR}/boot/loader.conf
|
902 |
6f73c362
|
Renato Botelho
|
|
903 |
230372b6
|
Renato Botelho
|
echo ">>> Activating serial console..." 2>&1 | tee -a ${LOGFILE}
|
904 |
6b5779e9
|
Renato Botelho
|
echo "-S115200 -D" > ${BOOTCONF}
|
905 |
6f73c362
|
Renato Botelho
|
|
906 |
|
|
# Activate serial console+video console in loader.conf
|
907 |
788f1c3b
|
Renato Botelho
|
echo 'autoboot_delay="3"' > ${LOADERCONF}
|
908 |
286ec1c7
|
Renato Botelho
|
echo 'kern.cam.boot_delay=10000' >> ${LOADERCONF}
|
909 |
788f1c3b
|
Renato Botelho
|
echo 'boot_multicons="YES"' >> ${LOADERCONF}
|
910 |
6f73c362
|
Renato Botelho
|
echo 'boot_serial="YES"' >> ${LOADERCONF}
|
911 |
|
|
echo 'console="comconsole,vidconsole"' >> ${LOADERCONF}
|
912 |
|
|
echo 'comconsole_speed="115200"' >> ${LOADERCONF}
|
913 |
|
|
|
914 |
535f8a75
|
Renato Botelho
|
cat ${BOOTCONF} >> ${FINAL_CHROOT_DIR}/boot.config
|
915 |
|
|
cat ${LOADERCONF} >> ${FINAL_CHROOT_DIR}/boot/loader.conf
|
916 |
6b5779e9
|
Renato Botelho
|
|
917 |
6f73c362
|
Renato Botelho
|
create_distribution_tarball
|
918 |
|
|
|
919 |
d84eec80
|
Renato Botelho
|
sh ${FREEBSD_SRC_DIR}/release/${TARGET}/make-memstick.sh \
|
920 |
|
|
${INSTALLER_CHROOT_DIR} \
|
921 |
|
|
${MEMSTICKSERIALPATH}
|
922 |
6b5779e9
|
Renato Botelho
|
|
923 |
044ff383
|
Renato Botelho
|
if [ ! -f "${MEMSTICKSERIALPATH}" ]; then
|
924 |
|
|
echo "ERROR! memstick serial image was not built"
|
925 |
|
|
print_error_pfS
|
926 |
|
|
fi
|
927 |
|
|
|
928 |
6f73c362
|
Renato Botelho
|
gzip -qf $MEMSTICKSERIALPATH &
|
929 |
39ef49f6
|
Renato Botelho
|
_bg_pids="${_bg_pids}${_bg_pids:+ }$!"
|
930 |
6f73c362
|
Renato Botelho
|
|
931 |
|
|
echo ">>> MEMSTICKSERIAL created: $(LC_ALL=C date)" | tee -a ${LOGFILE}
|
932 |
|
|
}
|
933 |
|
|
|
934 |
|
|
create_memstick_adi_image() {
|
935 |
462cbb5a
|
Renato Botelho
|
LOGFILE=${BUILDER_LOGS}/memstickadi.${TARGET}
|
936 |
6f73c362
|
Renato Botelho
|
if [ "${MEMSTICKADIPATH}" = "" ]; then
|
937 |
|
|
echo ">>> MEMSTICKADIPATH is empty skipping generation of memstick image!" | tee -a ${LOGFILE}
|
938 |
|
|
return
|
939 |
|
|
fi
|
940 |
|
|
|
941 |
f26731b0
|
Renato Botelho
|
mkdir -p $(dirname ${MEMSTICKADIPATH})
|
942 |
|
|
|
943 |
624376f6
|
Renato Botelho
|
customize_stagearea_for_image "memstickadi"
|
944 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
945 |
6f73c362
|
Renato Botelho
|
|
946 |
|
|
echo ">>> Creating serial memstick to ${MEMSTICKADIPATH}." 2>&1 | tee -a ${LOGFILE}
|
947 |
|
|
|
948 |
6b5779e9
|
Renato Botelho
|
BOOTCONF=${INSTALLER_CHROOT_DIR}/boot.config
|
949 |
|
|
LOADERCONF=${INSTALLER_CHROOT_DIR}/boot/loader.conf
|
950 |
6f73c362
|
Renato Botelho
|
|
951 |
230372b6
|
Renato Botelho
|
echo ">>> Activating serial console..." 2>&1 | tee -a ${LOGFILE}
|
952 |
6b5779e9
|
Renato Botelho
|
echo "-S115200 -h" > ${BOOTCONF}
|
953 |
6f73c362
|
Renato Botelho
|
|
954 |
|
|
# Activate serial console+video console in loader.conf
|
955 |
788f1c3b
|
Renato Botelho
|
echo 'autoboot_delay="3"' > ${LOADERCONF}
|
956 |
286ec1c7
|
Renato Botelho
|
echo 'kern.cam.boot_delay=10000' >> ${LOADERCONF}
|
957 |
788f1c3b
|
Renato Botelho
|
echo 'boot_serial="YES"' >> ${LOADERCONF}
|
958 |
6f73c362
|
Renato Botelho
|
echo 'console="comconsole"' >> ${LOADERCONF}
|
959 |
|
|
echo 'comconsole_speed="115200"' >> ${LOADERCONF}
|
960 |
|
|
echo 'comconsole_port="0x2F8"' >> ${LOADERCONF}
|
961 |
|
|
echo 'hint.uart.0.flags="0x00"' >> ${LOADERCONF}
|
962 |
|
|
echo 'hint.uart.1.flags="0x10"' >> ${LOADERCONF}
|
963 |
|
|
|
964 |
6b5779e9
|
Renato Botelho
|
cat ${BOOTCONF} >> ${FINAL_CHROOT_DIR}/boot.config
|
965 |
|
|
cat ${LOADERCONF} >> ${FINAL_CHROOT_DIR}/boot/loader.conf
|
966 |
|
|
|
967 |
6f73c362
|
Renato Botelho
|
create_distribution_tarball
|
968 |
|
|
|
969 |
d84eec80
|
Renato Botelho
|
sh ${FREEBSD_SRC_DIR}/release/${TARGET}/make-memstick.sh \
|
970 |
|
|
${INSTALLER_CHROOT_DIR} \
|
971 |
|
|
${MEMSTICKADIPATH}
|
972 |
6b5779e9
|
Renato Botelho
|
|
973 |
044ff383
|
Renato Botelho
|
if [ ! -f "${MEMSTICKADIPATH}" ]; then
|
974 |
|
|
echo "ERROR! memstick ADI image was not built"
|
975 |
|
|
print_error_pfS
|
976 |
|
|
fi
|
977 |
|
|
|
978 |
6f73c362
|
Renato Botelho
|
gzip -qf $MEMSTICKADIPATH &
|
979 |
39ef49f6
|
Renato Botelho
|
_bg_pids="${_bg_pids}${_bg_pids:+ }$!"
|
980 |
6f73c362
|
Renato Botelho
|
|
981 |
|
|
echo ">>> MEMSTICKADI created: $(LC_ALL=C date)" | tee -a ${LOGFILE}
|
982 |
|
|
}
|
983 |
|
|
|
984 |
dff2bf9c
|
Renato Botelho
|
get_altabi_arch() {
|
985 |
|
|
local _target_arch="$1"
|
986 |
|
|
|
987 |
|
|
if [ "${_target_arch}" = "amd64" ]; then
|
988 |
|
|
echo "x86:64"
|
989 |
|
|
elif [ "${_target_arch}" = "i386" ]; then
|
990 |
|
|
echo "x86:32"
|
991 |
82b59cee
|
Renato Botelho
|
elif [ "${_target_arch}" = "armv7" ]; then
|
992 |
e200e241
|
Renato Botelho
|
echo "32:el:eabi:softfp"
|
993 |
dff2bf9c
|
Renato Botelho
|
else
|
994 |
|
|
echo ">>> ERROR: Invalid arch"
|
995 |
|
|
print_error_pfS
|
996 |
|
|
fi
|
997 |
|
|
}
|
998 |
|
|
|
999 |
6f73c362
|
Renato Botelho
|
# Create pkg conf on desired place with desired arch/branch
|
1000 |
|
|
setup_pkg_repo() {
|
1001 |
74a4eefb
|
Renato Botelho
|
if [ -z "${4}" ]; then
|
1002 |
6f73c362
|
Renato Botelho
|
return
|
1003 |
|
|
fi
|
1004 |
|
|
|
1005 |
db8621d8
|
Renato Botelho
|
local _template="${1}"
|
1006 |
|
|
local _target="${2}"
|
1007 |
|
|
local _arch="${3}"
|
1008 |
|
|
local _target_arch="${4}"
|
1009 |
74a4eefb
|
Renato Botelho
|
local _staging="${5}"
|
1010 |
a76b4810
|
Renato Botelho
|
local _pkg_conf="${6}"
|
1011 |
5647efc6
|
Brad Davis
|
local _mirror_type="srv"
|
1012 |
|
|
local _signature_type="fingerprints"
|
1013 |
52efc840
|
Renato Botelho
|
|
1014 |
|
|
if [ -z "${_template}" -o ! -f "${_template}" ]; then
|
1015 |
|
|
echo ">>> ERROR: It was not possible to find pkg conf template ${_template}"
|
1016 |
|
|
print_error_pfS
|
1017 |
|
|
fi
|
1018 |
6f73c362
|
Renato Botelho
|
|
1019 |
74a4eefb
|
Renato Botelho
|
if [ -n "${_staging}" -a -n "${USE_PKG_REPO_STAGING}" ]; then
|
1020 |
fb4d75d9
|
Renato Botelho
|
local _pkg_repo_server_devel=${PKG_REPO_SERVER_STAGING}
|
1021 |
|
|
local _pkg_repo_branch_devel=${PKG_REPO_BRANCH_STAGING}
|
1022 |
|
|
local _pkg_repo_server_release=${PKG_REPO_SERVER_STAGING}
|
1023 |
|
|
local _pkg_repo_branch_release=${PKG_REPO_BRANCH_STAGING}
|
1024 |
74a4eefb
|
Renato Botelho
|
else
|
1025 |
fb4d75d9
|
Renato Botelho
|
local _pkg_repo_server_devel=${PKG_REPO_SERVER_DEVEL}
|
1026 |
|
|
local _pkg_repo_branch_devel=${PKG_REPO_BRANCH_DEVEL}
|
1027 |
|
|
local _pkg_repo_server_release=${PKG_REPO_SERVER_RELEASE}
|
1028 |
|
|
local _pkg_repo_branch_release=${PKG_REPO_BRANCH_RELEASE}
|
1029 |
2c27ff24
|
Renato Botelho
|
fi
|
1030 |
97fd32ba
|
Renato Botelho
|
|
1031 |
6f73c362
|
Renato Botelho
|
mkdir -p $(dirname ${_target}) >/dev/null 2>&1
|
1032 |
|
|
|
1033 |
|
|
sed \
|
1034 |
ab225f2b
|
Renato Botelho
|
-e "s/%%ARCH%%/${_target_arch}/" \
|
1035 |
5647efc6
|
Brad Davis
|
-e "s/%%MIRROR_TYPE%%/${_mirror_type}/" \
|
1036 |
fb4d75d9
|
Renato Botelho
|
-e "s/%%PKG_REPO_BRANCH_DEVEL%%/${_pkg_repo_branch_devel}/g" \
|
1037 |
|
|
-e "s/%%PKG_REPO_BRANCH_RELEASE%%/${_pkg_repo_branch_release}/g" \
|
1038 |
|
|
-e "s,%%PKG_REPO_SERVER_DEVEL%%,${_pkg_repo_server_devel},g" \
|
1039 |
|
|
-e "s,%%PKG_REPO_SERVER_RELEASE%%,${_pkg_repo_server_release},g" \
|
1040 |
f8a36c30
|
Renato Botelho
|
-e "s,%%POUDRIERE_PORTS_NAME%%,${POUDRIERE_PORTS_NAME},g" \
|
1041 |
6f73c362
|
Renato Botelho
|
-e "s/%%PRODUCT_NAME%%/${PRODUCT_NAME}/g" \
|
1042 |
062a7598
|
Renato Botelho do Couto
|
-e "s/%%REPO_BRANCH_PREFIX%%/${REPO_PATH_PREFIX}/g" \
|
1043 |
5647efc6
|
Brad Davis
|
-e "s/%%SIGNATURE_TYPE%%/${_signature_type}/" \
|
1044 |
52efc840
|
Renato Botelho
|
${_template} \
|
1045 |
6f73c362
|
Renato Botelho
|
> ${_target}
|
1046 |
a76b4810
|
Renato Botelho
|
|
1047 |
dff2bf9c
|
Renato Botelho
|
local ALTABI_ARCH=$(get_altabi_arch ${_target_arch})
|
1048 |
a76b4810
|
Renato Botelho
|
|
1049 |
|
|
ABI=$(cat ${_template%%.conf}.abi 2>/dev/null \
|
1050 |
|
|
| sed -e "s/%%ARCH%%/${_target_arch}/g")
|
1051 |
|
|
ALTABI=$(cat ${_template%%.conf}.altabi 2>/dev/null \
|
1052 |
|
|
| sed -e "s/%%ARCH%%/${ALTABI_ARCH}/g")
|
1053 |
|
|
|
1054 |
|
|
if [ -n "${_pkg_conf}" -a -n "${ABI}" -a -n "${ALTABI}" ]; then
|
1055 |
|
|
mkdir -p $(dirname ${_pkg_conf})
|
1056 |
|
|
echo "ABI=${ABI}" > ${_pkg_conf}
|
1057 |
|
|
echo "ALTABI=${ALTABI}" >> ${_pkg_conf}
|
1058 |
|
|
fi
|
1059 |
6f73c362
|
Renato Botelho
|
}
|
1060 |
|
|
|
1061 |
1b40e1a6
|
Renato Botelho
|
depend_check() {
|
1062 |
ffeac248
|
Renato Botelho
|
for _pkg in ${BUILDER_PKG_DEPENDENCIES}; do
|
1063 |
1b40e1a6
|
Renato Botelho
|
if ! pkg info -e ${_pkg}; then
|
1064 |
|
|
echo "Missing dependency (${_pkg})."
|
1065 |
|
|
print_error_pfS
|
1066 |
|
|
fi
|
1067 |
|
|
done
|
1068 |
|
|
}
|
1069 |
|
|
|
1070 |
6f73c362
|
Renato Botelho
|
# This routine ensures any ports / binaries that the builder
|
1071 |
|
|
# system needs are on disk and ready for execution.
|
1072 |
|
|
builder_setup() {
|
1073 |
|
|
# If Product-builder is already installed, just leave
|
1074 |
|
|
if pkg info -e -q ${PRODUCT_NAME}-builder; then
|
1075 |
|
|
return
|
1076 |
|
|
fi
|
1077 |
|
|
|
1078 |
52efc840
|
Renato Botelho
|
if [ ! -f ${PKG_REPO_PATH} ]; then
|
1079 |
|
|
[ -d $(dirname ${PKG_REPO_PATH}) ] \
|
1080 |
|
|
|| mkdir -p $(dirname ${PKG_REPO_PATH})
|
1081 |
6f73c362
|
Renato Botelho
|
|
1082 |
d2f163a6
|
Renato Botelho
|
update_freebsd_sources
|
1083 |
|
|
|
1084 |
6f73c362
|
Renato Botelho
|
local _arch=$(uname -m)
|
1085 |
0c096dad
|
Renato Botelho
|
setup_pkg_repo \
|
1086 |
dbd615c4
|
Renato Botelho
|
${PKG_REPO_BUILD} \
|
1087 |
52efc840
|
Renato Botelho
|
${PKG_REPO_PATH} \
|
1088 |
0c096dad
|
Renato Botelho
|
${_arch} \
|
1089 |
67f2556a
|
Renato Botelho
|
${_arch} \
|
1090 |
|
|
"staging"
|
1091 |
569929ef
|
Renato Botelho
|
|
1092 |
|
|
# Use fingerprint keys from repo
|
1093 |
|
|
sed -i '' -e "/fingerprints:/ s,\"/,\"${BUILDER_ROOT}/src/," \
|
1094 |
|
|
${PKG_REPO_PATH}
|
1095 |
6f73c362
|
Renato Botelho
|
fi
|
1096 |
|
|
|
1097 |
|
|
pkg install ${PRODUCT_NAME}-builder
|
1098 |
|
|
}
|
1099 |
|
|
|
1100 |
|
|
# Updates FreeBSD sources
|
1101 |
|
|
update_freebsd_sources() {
|
1102 |
|
|
if [ "${1}" = "full" ]; then
|
1103 |
|
|
local _full=1
|
1104 |
|
|
local _clone_params=""
|
1105 |
|
|
else
|
1106 |
|
|
local _full=0
|
1107 |
|
|
local _clone_params="--depth 1 --single-branch"
|
1108 |
|
|
fi
|
1109 |
|
|
|
1110 |
d4c6029e
|
Renato Botelho
|
if [ -n "${NO_BUILDWORLD}" -a -n "${NO_BUILDKERNEL}" ]; then
|
1111 |
6f73c362
|
Renato Botelho
|
echo ">>> NO_BUILDWORLD and NO_BUILDKERNEL set, skipping update of freebsd sources" | tee -a ${LOGFILE}
|
1112 |
|
|
return
|
1113 |
|
|
fi
|
1114 |
|
|
|
1115 |
a10a0e70
|
Renato Botelho
|
echo ">>> Obtaining FreeBSD sources (${FREEBSD_BRANCH})..."
|
1116 |
cdf2b5f8
|
Renato Botelho
|
${BUILDER_SCRIPTS}/git_checkout.sh \
|
1117 |
a10a0e70
|
Renato Botelho
|
-r ${FREEBSD_REPO_BASE} \
|
1118 |
|
|
-d ${FREEBSD_SRC_DIR} \
|
1119 |
|
|
-b ${FREEBSD_BRANCH}
|
1120 |
6f73c362
|
Renato Botelho
|
|
1121 |
a10a0e70
|
Renato Botelho
|
if [ $? -ne 0 -o ! -d "${FREEBSD_SRC_DIR}/.git" ]; then
|
1122 |
6f73c362
|
Renato Botelho
|
echo ">>> ERROR: It was not possible to clone FreeBSD src repo"
|
1123 |
|
|
print_error_pfS
|
1124 |
|
|
fi
|
1125 |
|
|
|
1126 |
|
|
if [ -n "${GIT_FREEBSD_COSHA1}" ]; then
|
1127 |
a10a0e70
|
Renato Botelho
|
echo -n ">>> Checking out desired commit (${GIT_FREEBSD_COSHA1})... "
|
1128 |
|
|
( git -C ${FREEBSD_SRC_DIR} checkout ${GIT_FREEBSD_COSHA1} ) 2>&1 | \
|
1129 |
|
|
grep -C3 -i -E 'error|fatal'
|
1130 |
|
|
echo "Done!"
|
1131 |
6f73c362
|
Renato Botelho
|
fi
|
1132 |
1af9fab9
|
Renato Botelho
|
|
1133 |
|
|
if [ "${PRODUCT_NAME}" = "pfSense" -a -n "${GNID_REPO_BASE}" ]; then
|
1134 |
|
|
echo ">>> Obtaining gnid sources..."
|
1135 |
|
|
${BUILDER_SCRIPTS}/git_checkout.sh \
|
1136 |
|
|
-r ${GNID_REPO_BASE} \
|
1137 |
|
|
-d ${GNID_SRC_DIR} \
|
1138 |
|
|
-b ${GNID_BRANCH}
|
1139 |
|
|
fi
|
1140 |
6f73c362
|
Renato Botelho
|
}
|
1141 |
|
|
|
1142 |
|
|
pkg_chroot() {
|
1143 |
|
|
local _root="${1}"
|
1144 |
|
|
shift
|
1145 |
|
|
|
1146 |
|
|
if [ $# -eq 0 ]; then
|
1147 |
|
|
return -1
|
1148 |
|
|
fi
|
1149 |
|
|
|
1150 |
|
|
if [ -z "${_root}" -o "${_root}" = "/" -o ! -d "${_root}" ]; then
|
1151 |
|
|
return -1
|
1152 |
|
|
fi
|
1153 |
|
|
|
1154 |
|
|
mkdir -p \
|
1155 |
|
|
${SCRATCHDIR}/pkg_cache \
|
1156 |
|
|
${_root}/var/cache/pkg \
|
1157 |
|
|
${_root}/dev
|
1158 |
|
|
|
1159 |
|
|
/sbin/mount -t nullfs ${SCRATCHDIR}/pkg_cache ${_root}/var/cache/pkg
|
1160 |
|
|
/sbin/mount -t devfs devfs ${_root}/dev
|
1161 |
|
|
cp -f /etc/resolv.conf ${_root}/etc/resolv.conf
|
1162 |
|
|
touch ${BUILDER_LOGS}/install_pkg_install_ports.txt
|
1163 |
3e80d64e
|
Renato Botelho
|
local _params=""
|
1164 |
a76b4810
|
Renato Botelho
|
if [ -f "${_root}/tmp/pkg/pkg-repos/repo.conf" ]; then
|
1165 |
|
|
_params="--repo-conf-dir /tmp/pkg/pkg-repos "
|
1166 |
|
|
fi
|
1167 |
|
|
if [ -f "${_root}/tmp/pkg/pkg.conf" ]; then
|
1168 |
|
|
_params="${_params} --config /tmp/pkg/pkg.conf "
|
1169 |
3e80d64e
|
Renato Botelho
|
fi
|
1170 |
|
|
script -aq ${BUILDER_LOGS}/install_pkg_install_ports.txt \
|
1171 |
5f7c49a4
|
Renato Botelho
|
chroot ${_root} pkg ${_params}$@ >/dev/null 2>&1
|
1172 |
10f26956
|
Renato Botelho
|
local result=$?
|
1173 |
6f73c362
|
Renato Botelho
|
rm -f ${_root}/etc/resolv.conf
|
1174 |
5084361d
|
Renato Botelho
|
/sbin/umount -f ${_root}/dev
|
1175 |
|
|
/sbin/umount -f ${_root}/var/cache/pkg
|
1176 |
10f26956
|
Renato Botelho
|
|
1177 |
|
|
return $result
|
1178 |
6f73c362
|
Renato Botelho
|
}
|
1179 |
|
|
|
1180 |
|
|
|
1181 |
|
|
pkg_chroot_add() {
|
1182 |
|
|
if [ -z "${1}" -o -z "${2}" ]; then
|
1183 |
|
|
return 1
|
1184 |
|
|
fi
|
1185 |
|
|
|
1186 |
|
|
local _target="${1}"
|
1187 |
|
|
local _pkg="$(get_pkg_name ${2}).txz"
|
1188 |
|
|
|
1189 |
|
|
if [ ! -d "${_target}" ]; then
|
1190 |
|
|
echo ">>> ERROR: Target dir ${_target} not found"
|
1191 |
|
|
print_error_pfS
|
1192 |
|
|
fi
|
1193 |
|
|
|
1194 |
91039db4
|
Renato Botelho
|
if [ ! -f ${CORE_PKG_ALL_PATH}/${_pkg} ]; then
|
1195 |
6f73c362
|
Renato Botelho
|
echo ">>> ERROR: Package ${_pkg} not found"
|
1196 |
|
|
print_error_pfS
|
1197 |
|
|
fi
|
1198 |
|
|
|
1199 |
91039db4
|
Renato Botelho
|
cp ${CORE_PKG_ALL_PATH}/${_pkg} ${_target}
|
1200 |
6f73c362
|
Renato Botelho
|
pkg_chroot ${_target} add /${_pkg}
|
1201 |
|
|
rm -f ${_target}/${_pkg}
|
1202 |
|
|
}
|
1203 |
|
|
|
1204 |
|
|
pkg_bootstrap() {
|
1205 |
|
|
local _root=${1:-"${STAGE_CHROOT_DIR}"}
|
1206 |
|
|
|
1207 |
0ada33a9
|
Renato Botelho
|
setup_pkg_repo \
|
1208 |
dbd615c4
|
Renato Botelho
|
${PKG_REPO_BUILD} \
|
1209 |
52efc840
|
Renato Botelho
|
${_root}${PKG_REPO_PATH} \
|
1210 |
0ada33a9
|
Renato Botelho
|
${TARGET} \
|
1211 |
|
|
${TARGET_ARCH} \
|
1212 |
74a4eefb
|
Renato Botelho
|
"staging"
|
1213 |
6f73c362
|
Renato Botelho
|
|
1214 |
|
|
pkg_chroot ${_root} bootstrap -f
|
1215 |
|
|
}
|
1216 |
|
|
|
1217 |
|
|
# This routine assists with installing various
|
1218 |
97bc6c78
|
Phil Davis
|
# freebsd ports files into the pfsense-fs staging
|
1219 |
6f73c362
|
Renato Botelho
|
# area.
|
1220 |
|
|
install_pkg_install_ports() {
|
1221 |
|
|
local MAIN_PKG="${1}"
|
1222 |
|
|
|
1223 |
|
|
if [ -z "${MAIN_PKG}" ]; then
|
1224 |
|
|
MAIN_PKG=${PRODUCT_NAME}
|
1225 |
|
|
fi
|
1226 |
|
|
|
1227 |
|
|
echo ">>> Installing pkg repository in chroot (${STAGE_CHROOT_DIR})..."
|
1228 |
|
|
|
1229 |
|
|
[ -d ${STAGE_CHROOT_DIR}/var/cache/pkg ] || \
|
1230 |
|
|
mkdir -p ${STAGE_CHROOT_DIR}/var/cache/pkg
|
1231 |
|
|
|
1232 |
|
|
[ -d ${SCRATCHDIR}/pkg_cache ] || \
|
1233 |
|
|
mkdir -p ${SCRATCHDIR}/pkg_cache
|
1234 |
|
|
|
1235 |
10f26956
|
Renato Botelho
|
echo -n ">>> Installing built ports (packages) in chroot (${STAGE_CHROOT_DIR})... "
|
1236 |
cdac78f6
|
Renato Botelho
|
# First mark all packages as automatically installed
|
1237 |
|
|
pkg_chroot ${STAGE_CHROOT_DIR} set -A 1 -a
|
1238 |
|
|
# Install all necessary packages
|
1239 |
10f26956
|
Renato Botelho
|
if ! pkg_chroot ${STAGE_CHROOT_DIR} install ${MAIN_PKG} ${custom_package_list}; then
|
1240 |
|
|
echo "Failed!"
|
1241 |
|
|
print_error_pfS
|
1242 |
|
|
fi
|
1243 |
cdac78f6
|
Renato Botelho
|
# Make sure required packages are set as non-automatic
|
1244 |
4b0f15b6
|
Renato Botelho
|
pkg_chroot ${STAGE_CHROOT_DIR} set -A 0 pkg ${MAIN_PKG} ${custom_package_list}
|
1245 |
d071acf5
|
Renato Botelho
|
# pkg and MAIN_PKG are vital
|
1246 |
|
|
pkg_chroot ${STAGE_CHROOT_DIR} set -y -v 1 pkg ${MAIN_PKG}
|
1247 |
cdac78f6
|
Renato Botelho
|
# Remove unnecessary packages
|
1248 |
6f73c362
|
Renato Botelho
|
pkg_chroot ${STAGE_CHROOT_DIR} autoremove
|
1249 |
10f26956
|
Renato Botelho
|
echo "Done!"
|
1250 |
6f73c362
|
Renato Botelho
|
}
|
1251 |
|
|
|
1252 |
|
|
staginareas_clean_each_run() {
|
1253 |
|
|
echo -n ">>> Cleaning build directories: "
|
1254 |
|
|
if [ -d "${FINAL_CHROOT_DIR}" ]; then
|
1255 |
|
|
BASENAME=$(basename ${FINAL_CHROOT_DIR})
|
1256 |
|
|
echo -n "$BASENAME "
|
1257 |
|
|
chflags -R noschg ${FINAL_CHROOT_DIR} 2>&1 >/dev/null
|
1258 |
f546e6ca
|
Renato Botelho
|
rm -rf ${FINAL_CHROOT_DIR}/* 2>/dev/null
|
1259 |
6f73c362
|
Renato Botelho
|
fi
|
1260 |
|
|
echo "Done!"
|
1261 |
|
|
}
|
1262 |
|
|
|
1263 |
|
|
# Imported from FreeSBIE
|
1264 |
|
|
buildkernel() {
|
1265 |
f41f9c0c
|
Renato Botelho
|
local _kernconf=${1:-${KERNCONF}}
|
1266 |
|
|
|
1267 |
d4c6029e
|
Renato Botelho
|
if [ -n "${NO_BUILDKERNEL}" ]; then
|
1268 |
6f73c362
|
Renato Botelho
|
echo ">>> NO_BUILDKERNEL set, skipping build" | tee -a ${LOGFILE}
|
1269 |
|
|
return
|
1270 |
|
|
fi
|
1271 |
|
|
|
1272 |
f41f9c0c
|
Renato Botelho
|
if [ -z "${_kernconf}" ]; then
|
1273 |
6f73c362
|
Renato Botelho
|
echo ">>> ERROR: No kernel configuration defined probably this is not what you want! STOPPING!" | tee -a ${LOGFILE}
|
1274 |
|
|
print_error_pfS
|
1275 |
|
|
fi
|
1276 |
|
|
|
1277 |
f41f9c0c
|
Renato Botelho
|
local _old_kernconf=${KERNCONF}
|
1278 |
|
|
export KERNCONF=${_kernconf}
|
1279 |
6f73c362
|
Renato Botelho
|
|
1280 |
29cdd776
|
Renato Botelho
|
echo ">>> $(LC_ALL=C date) - Starting build kernel for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
1281 |
cdf2b5f8
|
Renato Botelho
|
script -aq $LOGFILE ${BUILDER_SCRIPTS}/build_freebsd.sh -W -s ${FREEBSD_SRC_DIR} \
|
1282 |
29cdd776
|
Renato Botelho
|
|| print_error_pfS
|
1283 |
|
|
echo ">>> $(LC_ALL=C date) - Finished build kernel for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
1284 |
f41f9c0c
|
Renato Botelho
|
|
1285 |
|
|
export KERNCONF=${_old_kernconf}
|
1286 |
6f73c362
|
Renato Botelho
|
}
|
1287 |
|
|
|
1288 |
|
|
# Imported from FreeSBIE
|
1289 |
|
|
installkernel() {
|
1290 |
7d460897
|
Renato Botelho
|
local _destdir=${1:-${KERNEL_DESTDIR}}
|
1291 |
f41f9c0c
|
Renato Botelho
|
local _kernconf=${2:-${KERNCONF}}
|
1292 |
7d460897
|
Renato Botelho
|
|
1293 |
f41f9c0c
|
Renato Botelho
|
if [ -z "${_kernconf}" ]; then
|
1294 |
6f73c362
|
Renato Botelho
|
echo ">>> ERROR: No kernel configuration defined probably this is not what you want! STOPPING!" | tee -a ${LOGFILE}
|
1295 |
|
|
print_error_pfS
|
1296 |
|
|
fi
|
1297 |
|
|
|
1298 |
f41f9c0c
|
Renato Botelho
|
local _old_kernconf=${KERNCONF}
|
1299 |
|
|
export KERNCONF=${_kernconf}
|
1300 |
6f73c362
|
Renato Botelho
|
|
1301 |
|
|
mkdir -p ${STAGE_CHROOT_DIR}/boot
|
1302 |
f41f9c0c
|
Renato Botelho
|
echo ">>> Installing kernel (${_kernconf}) for ${TARGET} architecture..." | tee -a ${LOGFILE}
|
1303 |
cdf2b5f8
|
Renato Botelho
|
script -aq $LOGFILE ${BUILDER_SCRIPTS}/install_freebsd.sh -W -D -z \
|
1304 |
468f236d
|
Renato Botelho
|
-s ${FREEBSD_SRC_DIR} \
|
1305 |
|
|
-d ${_destdir} \
|
1306 |
|
|
|| print_error_pfS
|
1307 |
f41f9c0c
|
Renato Botelho
|
|
1308 |
|
|
export KERNCONF=${_old_kernconf}
|
1309 |
6f73c362
|
Renato Botelho
|
}
|
1310 |
|
|
|
1311 |
|
|
# Launch is ran first to setup a few variables that we need
|
1312 |
|
|
# Imported from FreeSBIE
|
1313 |
|
|
launch() {
|
1314 |
|
|
if [ "$(id -u)" != "0" ]; then
|
1315 |
|
|
echo "Sorry, this must be done as root."
|
1316 |
|
|
fi
|
1317 |
|
|
|
1318 |
|
|
echo ">>> Operation $0 has started at $(date)"
|
1319 |
|
|
}
|
1320 |
|
|
|
1321 |
|
|
finish() {
|
1322 |
|
|
echo ">>> Operation $0 has ended at $(date)"
|
1323 |
|
|
}
|
1324 |
|
|
|
1325 |
184b39e1
|
Renato Botelho
|
pkg_repo_rsync() {
|
1326 |
15333972
|
Renato Botelho
|
local _repo_path_param="${1}"
|
1327 |
92a1044d
|
Renato Botelho
|
local _ignore_final_rsync="${2}"
|
1328 |
5c0d30fb
|
Renato Botelho do Couto
|
local _aws_sync_cmd="aws s3 sync --quiet --exclude '.real*/*' --exclude '.latest/*'"
|
1329 |
184b39e1
|
Renato Botelho
|
|
1330 |
15333972
|
Renato Botelho
|
if [ -z "${_repo_path_param}" -o ! -d "${_repo_path_param}" ]; then
|
1331 |
184b39e1
|
Renato Botelho
|
return
|
1332 |
|
|
fi
|
1333 |
|
|
|
1334 |
92a1044d
|
Renato Botelho
|
if [ -n "${SKIP_FINAL_RSYNC}" ]; then
|
1335 |
|
|
_ignore_final_rsync="1"
|
1336 |
|
|
fi
|
1337 |
|
|
|
1338 |
61b63ac0
|
Renato Botelho
|
# Sanitize path
|
1339 |
15333972
|
Renato Botelho
|
_repo_path=$(realpath ${_repo_path_param})
|
1340 |
61b63ac0
|
Renato Botelho
|
|
1341 |
|
|
local _repo_dir=$(dirname ${_repo_path})
|
1342 |
|
|
local _repo_base=$(basename ${_repo_path})
|
1343 |
|
|
|
1344 |
|
|
# Add ./ it's an rsync trick to make it chdir to directory before sending it
|
1345 |
|
|
_repo_path="${_repo_dir}/./${_repo_base}"
|
1346 |
|
|
|
1347 |
184b39e1
|
Renato Botelho
|
if [ -z "${LOGFILE}" ]; then
|
1348 |
|
|
local _logfile="/dev/null"
|
1349 |
|
|
else
|
1350 |
|
|
local _logfile="${LOGFILE}"
|
1351 |
|
|
fi
|
1352 |
|
|
|
1353 |
94f7df8f
|
Renato Botelho
|
if [ -n "${PKG_REPO_SIGNING_COMMAND}" -a -z "${DO_NOT_SIGN_PKG_REPO}" ]; then
|
1354 |
efcf5e2a
|
Renato Botelho
|
# Detect poudriere directory structure
|
1355 |
|
|
if [ -L "${_repo_path}/.latest" ]; then
|
1356 |
|
|
local _real_repo_path=$(readlink -f ${_repo_path}/.latest)
|
1357 |
|
|
else
|
1358 |
|
|
local _real_repo_path=${_repo_path}
|
1359 |
|
|
fi
|
1360 |
|
|
|
1361 |
f4575189
|
Renato Botelho
|
echo -n ">>> Signing repository... " | tee -a ${_logfile}
|
1362 |
efcf5e2a
|
Renato Botelho
|
############ ATTENTION ##############
|
1363 |
|
|
#
|
1364 |
|
|
# For some reason pkg-repo fail without / in the end of directory name
|
1365 |
|
|
# so removing it will break command
|
1366 |
|
|
#
|
1367 |
c2af1487
|
Renato Botelho
|
# https://github.com/freebsd/pkg/issues/1364
|
1368 |
|
|
#
|
1369 |
efcf5e2a
|
Renato Botelho
|
if script -aq ${_logfile} pkg repo ${_real_repo_path}/ \
|
1370 |
7fb96c6c
|
Renato Botelho do Couto
|
signing_command: ${PKG_REPO_SIGNING_COMMAND} >/dev/null 2>&1; then
|
1371 |
f4575189
|
Renato Botelho
|
echo "Done!" | tee -a ${_logfile}
|
1372 |
|
|
else
|
1373 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1374 |
|
|
echo ">>> ERROR: An error occurred trying to sign repo"
|
1375 |
|
|
print_error_pfS
|
1376 |
|
|
fi
|
1377 |
|
|
|
1378 |
4199a5d9
|
Renato Botelho do Couto
|
local _pkgfile="${_repo_path}/Latest/pkg.pkg"
|
1379 |
f4575189
|
Renato Botelho
|
if [ -e ${_pkgfile} ]; then
|
1380 |
4864d7f6
|
Josh Soref
|
echo -n ">>> Signing Latest/pkg.pkg for bootstrapping... " | tee -a ${_logfile}
|
1381 |
f4575189
|
Renato Botelho
|
|
1382 |
|
|
if sha256 -q ${_pkgfile} | ${PKG_REPO_SIGNING_COMMAND} \
|
1383 |
|
|
> ${_pkgfile}.sig 2>/dev/null; then
|
1384 |
9ad8ac15
|
Renato Botelho do Couto
|
# XXX Temporary workaround to create link to pkg sig
|
1385 |
4199a5d9
|
Renato Botelho do Couto
|
[ -e ${_repo_path}/Latest/pkg.txz ] && \
|
1386 |
|
|
ln -sf pkg.pkg.sig ${_repo_path}/Latest/pkg.txz.sig
|
1387 |
f4575189
|
Renato Botelho
|
echo "Done!" | tee -a ${_logfile}
|
1388 |
|
|
else
|
1389 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1390 |
|
|
echo ">>> ERROR: An error occurred trying to sign Latest/pkg.txz"
|
1391 |
|
|
print_error_pfS
|
1392 |
|
|
fi
|
1393 |
|
|
fi
|
1394 |
|
|
fi
|
1395 |
|
|
|
1396 |
f6c83d05
|
Renato Botelho
|
if [ -z "${UPLOAD}" ]; then
|
1397 |
f4575189
|
Renato Botelho
|
return
|
1398 |
|
|
fi
|
1399 |
|
|
|
1400 |
cafd9f97
|
Brad Davis
|
local _pkg_rsync_site
|
1401 |
|
|
for _pkg_rsync_site in ${PKG_RSYNC_HOSTS}; do
|
1402 |
50ef7d15
|
Brad Davis
|
eval _pkg_rsync_hostname=\$PKG_RSYNC_HOSTNAME_$_pkg_rsync_site
|
1403 |
cafd9f97
|
Brad Davis
|
if [ -z "${_pkg_rsync_hostname}" ]; then
|
1404 |
50ef7d15
|
Brad Davis
|
echo "PKG_RSYNC_HOSTNAME_$_pkg_rsync_site is empty, skipping.."
|
1405 |
cafd9f97
|
Brad Davis
|
continue
|
1406 |
|
|
fi
|
1407 |
5163c3ca
|
Renato Botelho
|
# Make sure destination directory exist
|
1408 |
547d0883
|
Renato Botelho do Couto
|
ssh -o StrictHostKeyChecking=no -p ${PKG_RSYNC_SSH_PORT} \
|
1409 |
5163c3ca
|
Renato Botelho
|
${PKG_RSYNC_USERNAME}@${_pkg_rsync_hostname} \
|
1410 |
|
|
"mkdir -p ${PKG_RSYNC_DESTDIR}"
|
1411 |
|
|
|
1412 |
|
|
echo -n ">>> Sending updated repository to ${_pkg_rsync_hostname}... " | tee -a ${_logfile}
|
1413 |
547d0883
|
Renato Botelho do Couto
|
if script -aq ${_logfile} rsync -Have "ssh -o StrictHostKeyChecking=no -p ${PKG_RSYNC_SSH_PORT}" \
|
1414 |
5163c3ca
|
Renato Botelho
|
--timeout=60 --delete-delay ${_repo_path} \
|
1415 |
99dc9ef7
|
Brad Davis
|
${PKG_RSYNC_USERNAME}@${_pkg_rsync_hostname}:${PKG_RSYNC_DESTDIR} >> ${BUILDER_LOGS}/rsync.log 2>&1
|
1416 |
5163c3ca
|
Renato Botelho
|
then
|
1417 |
2c056b08
|
Renato Botelho
|
echo "Done!" | tee -a ${_logfile}
|
1418 |
|
|
else
|
1419 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1420 |
5163c3ca
|
Renato Botelho
|
echo ">>> ERROR: An error occurred sending repo to remote hostname"
|
1421 |
2c056b08
|
Renato Botelho
|
print_error_pfS
|
1422 |
|
|
fi
|
1423 |
|
|
|
1424 |
5163c3ca
|
Renato Botelho
|
if [ -z "${USE_PKG_REPO_STAGING}" -o -n "${_ignore_final_rsync}" ]; then
|
1425 |
|
|
return
|
1426 |
|
|
fi
|
1427 |
15333972
|
Renato Botelho
|
|
1428 |
5163c3ca
|
Renato Botelho
|
if [ -n "${_IS_RELEASE}" -o "${_repo_path_param}" = "${CORE_PKG_PATH}" ]; then
|
1429 |
cafd9f97
|
Brad Davis
|
local _pkg_final_rsync_hostname
|
1430 |
50ef7d15
|
Brad Davis
|
eval _pkg_final_rsync_hostname=\$PKG_FINAL_RSYNC_HOSTNAME_$_pkg_rsync_site
|
1431 |
cafd9f97
|
Brad Davis
|
if [ -z "${_pkg_final_rsync_hostname}" ]; then
|
1432 |
|
|
_pkg_final_rsync_hostname="$_pkg_rsync_hostname"
|
1433 |
|
|
fi
|
1434 |
|
|
|
1435 |
|
|
# Send .real* directories first to prevent having a broken repo while transfer happens
|
1436 |
|
|
local _cmd="rsync -Have \"ssh -o StrictHostKeyChecking=no -p ${PKG_FINAL_RSYNC_SSH_PORT}\" \
|
1437 |
|
|
--timeout=60 ${PKG_RSYNC_DESTDIR}/./${_repo_base%%-core}* \
|
1438 |
|
|
--include=\"/*\" --include=\"*/.real*\" --include=\"*/.real*/***\" \
|
1439 |
|
|
--exclude=\"*\" \
|
1440 |
|
|
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname}:${PKG_FINAL_RSYNC_DESTDIR}"
|
1441 |
|
|
|
1442 |
|
|
echo -n ">>> Sending updated packages to ${_pkg_final_rsync_hostname}... " | tee -a ${_logfile}
|
1443 |
|
|
if script -aq ${_logfile} ssh -o StrictHostKeyChecking=no -p ${PKG_RSYNC_SSH_PORT} \
|
1444 |
|
|
${PKG_RSYNC_USERNAME}@${_pkg_rsync_hostname} ${_cmd} >> ${BUILDER_LOGS}/rsync.log 2>&1; then
|
1445 |
|
|
echo "Done!" | tee -a ${_logfile}
|
1446 |
|
|
else
|
1447 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1448 |
|
|
echo ">>> ERROR: An error occurred sending repo to final hostname"
|
1449 |
|
|
print_error_pfS
|
1450 |
|
|
fi
|
1451 |
|
|
|
1452 |
|
|
_cmd="rsync -Have \"ssh -o StrictHostKeyChecking=no -p ${PKG_FINAL_RSYNC_SSH_PORT}\" \
|
1453 |
|
|
--timeout=60 --delete-delay ${PKG_RSYNC_DESTDIR}/./${_repo_base%%-core}* \
|
1454 |
|
|
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname}:${PKG_FINAL_RSYNC_DESTDIR}"
|
1455 |
|
|
|
1456 |
|
|
echo -n ">>> Sending updated repositories metadata to ${_pkg_final_rsync_hostname}... " | tee -a ${_logfile}
|
1457 |
|
|
if script -aq ${_logfile} ssh -o StrictHostKeyChecking=no -p ${PKG_RSYNC_SSH_PORT} \
|
1458 |
|
|
${PKG_RSYNC_USERNAME}@${_pkg_rsync_hostname} ${_cmd} >> ${BUILDER_LOGS}/rsync.log 2>&1; then
|
1459 |
|
|
echo "Done!" | tee -a ${_logfile}
|
1460 |
|
|
else
|
1461 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1462 |
|
|
echo ">>> ERROR: An error occurred sending repo to final hostname"
|
1463 |
|
|
print_error_pfS
|
1464 |
|
|
fi
|
1465 |
|
|
|
1466 |
|
|
if [ -z "${PKG_FINAL_S3_PATH}" ]; then
|
1467 |
|
|
continue
|
1468 |
|
|
fi
|
1469 |
|
|
|
1470 |
|
|
local _repos=$(ssh -o StrictHostKeyChecking=no -p ${PKG_FINAL_RSYNC_SSH_PORT} \
|
1471 |
|
|
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \
|
1472 |
|
|
"ls -1d ${PKG_FINAL_RSYNC_DESTDIR}/${_repo_base%%-core}*")
|
1473 |
|
|
for _repo in ${_repos}; do
|
1474 |
|
|
echo -n ">>> Sending updated packages to AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile}
|
1475 |
|
|
if script -aq ${_logfile} ssh -o StrictHostKeyChecking=no -p ${PKG_FINAL_RSYNC_SSH_PORT} \
|
1476 |
|
|
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \
|
1477 |
|
|
"${_aws_sync_cmd} ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then
|
1478 |
5163c3ca
|
Renato Botelho
|
echo "Done!" | tee -a ${_logfile}
|
1479 |
|
|
else
|
1480 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1481 |
cafd9f97
|
Brad Davis
|
echo ">>> ERROR: An error occurred sending files to AWS S3"
|
1482 |
5163c3ca
|
Renato Botelho
|
print_error_pfS
|
1483 |
|
|
fi
|
1484 |
cafd9f97
|
Brad Davis
|
echo -n ">>> Cleaning up packages at AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile}
|
1485 |
|
|
if script -aq ${_logfile} ssh -o StrictHostKeyChecking=no -p ${PKG_FINAL_RSYNC_SSH_PORT} \
|
1486 |
|
|
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \
|
1487 |
|
|
"${_aws_sync_cmd} --delete ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then
|
1488 |
5163c3ca
|
Renato Botelho
|
echo "Done!" | tee -a ${_logfile}
|
1489 |
|
|
else
|
1490 |
|
|
echo "Failed!" | tee -a ${_logfile}
|
1491 |
cafd9f97
|
Brad Davis
|
echo ">>> ERROR: An error occurred sending files to AWS S3"
|
1492 |
5163c3ca
|
Renato Botelho
|
print_error_pfS
|
1493 |
|
|
fi
|
1494 |
|
|
done
|
1495 |
15333972
|
Renato Botelho
|
fi
|
1496 |
5163c3ca
|
Renato Botelho
|
done
|
1497 |
184b39e1
|
Renato Botelho
|
}
|
1498 |
|
|
|
1499 |
6f73c362
|
Renato Botelho
|
poudriere_possible_archs() {
|
1500 |
|
|
local _arch=$(uname -m)
|
1501 |
44b30d59
|
Renato Botelho
|
local _archs=""
|
1502 |
6f73c362
|
Renato Botelho
|
|
1503 |
82b59cee
|
Renato Botelho
|
# If host is amd64, we'll create both repos, and if possible armv7
|
1504 |
6f73c362
|
Renato Botelho
|
if [ "${_arch}" = "amd64" ]; then
|
1505 |
44b30d59
|
Renato Botelho
|
_archs="amd64.amd64"
|
1506 |
6f73c362
|
Renato Botelho
|
|
1507 |
|
|
if [ -f /usr/local/bin/qemu-arm-static ]; then
|
1508 |
|
|
# Make sure binmiscctl is ok
|
1509 |
|
|
/usr/local/etc/rc.d/qemu_user_static forcestart >/dev/null 2>&1
|
1510 |
|
|
|
1511 |
82b59cee
|
Renato Botelho
|
if binmiscctl lookup armv7 >/dev/null 2>&1; then
|
1512 |
|
|
_archs="${_archs} arm.armv7"
|
1513 |
6f73c362
|
Renato Botelho
|
fi
|
1514 |
|
|
fi
|
1515 |
|
|
fi
|
1516 |
|
|
|
1517 |
fb192227
|
Renato Botelho
|
if [ -n "${ARCH_LIST}" ]; then
|
1518 |
|
|
local _found=0
|
1519 |
4010811b
|
Renato Botelho
|
for _desired_arch in ${ARCH_LIST}; do
|
1520 |
fb192227
|
Renato Botelho
|
_found=0
|
1521 |
4010811b
|
Renato Botelho
|
for _possible_arch in ${_archs}; do
|
1522 |
fb192227
|
Renato Botelho
|
if [ "${_desired_arch}" = "${_possible_arch}" ]; then
|
1523 |
|
|
_found=1
|
1524 |
|
|
break
|
1525 |
|
|
fi
|
1526 |
|
|
done
|
1527 |
|
|
if [ ${_found} -eq 0 ]; then
|
1528 |
|
|
echo ">>> ERROR: Impossible to build for arch: ${_desired_arch}"
|
1529 |
|
|
print_error_pfS
|
1530 |
|
|
fi
|
1531 |
|
|
done
|
1532 |
|
|
_archs="${ARCH_LIST}"
|
1533 |
|
|
fi
|
1534 |
|
|
|
1535 |
6f73c362
|
Renato Botelho
|
echo ${_archs}
|
1536 |
|
|
}
|
1537 |
|
|
|
1538 |
|
|
poudriere_jail_name() {
|
1539 |
|
|
local _jail_arch="${1}"
|
1540 |
|
|
|
1541 |
|
|
if [ -z "${_jail_arch}" ]; then
|
1542 |
|
|
return 1
|
1543 |
|
|
fi
|
1544 |
|
|
|
1545 |
0449a11f
|
Renato Botelho
|
# Remove arch
|
1546 |
83354dea
|
Renato Botelho
|
echo "${PRODUCT_NAME}_${POUDRIERE_BRANCH}_${_jail_arch##*.}"
|
1547 |
6f73c362
|
Renato Botelho
|
}
|
1548 |
|
|
|
1549 |
a3bb036b
|
Renato Botelho
|
poudriere_rename_ports() {
|
1550 |
|
|
if [ "${PRODUCT_NAME}" = "pfSense" ]; then
|
1551 |
|
|
return;
|
1552 |
|
|
fi
|
1553 |
|
|
|
1554 |
|
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
1555 |
|
|
|
1556 |
|
|
local _ports_dir="/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}"
|
1557 |
|
|
|
1558 |
|
|
echo -n ">>> Renaming product ports on ${POUDRIERE_PORTS_NAME}... " | tee -a ${LOGFILE}
|
1559 |
|
|
for d in $(find ${_ports_dir} -depth 2 -type d -name '*pfSense*'); do
|
1560 |
|
|
local _pdir=$(dirname ${d})
|
1561 |
|
|
local _pname=$(echo $(basename ${d}) | sed "s,pfSense,${PRODUCT_NAME},")
|
1562 |
c7e1c621
|
Renato Botelho
|
local _plist=""
|
1563 |
0436dfad
|
Ronald Schellberg
|
local _pdescr=""
|
1564 |
a3bb036b
|
Renato Botelho
|
|
1565 |
|
|
if [ -e ${_pdir}/${_pname} ]; then
|
1566 |
|
|
rm -rf ${_pdir}/${_pname}
|
1567 |
|
|
fi
|
1568 |
|
|
|
1569 |
|
|
cp -r ${d} ${_pdir}/${_pname}
|
1570 |
|
|
|
1571 |
c7e1c621
|
Renato Botelho
|
if [ -f ${_pdir}/${_pname}/pkg-plist ]; then
|
1572 |
|
|
_plist=${_pdir}/${_pname}/pkg-plist
|
1573 |
|
|
fi
|
1574 |
|
|
|
1575 |
0436dfad
|
Ronald Schellberg
|
if [ -f ${_pdir}/${_pname}/pkg-descr ]; then
|
1576 |
|
|
_pdescr=${_pdir}/${_pname}/pkg-descr
|
1577 |
|
|
fi
|
1578 |
|
|
|
1579 |
a3bb036b
|
Renato Botelho
|
sed -i '' -e "s,pfSense,${PRODUCT_NAME},g" \
|
1580 |
|
|
-e "s,https://www.pfsense.org,${PRODUCT_URL},g" \
|
1581 |
|
|
-e "/^MAINTAINER=/ s,^.*$,MAINTAINER= ${PRODUCT_EMAIL}," \
|
1582 |
0436dfad
|
Ronald Schellberg
|
${_pdir}/${_pname}/Makefile ${_pdescr} ${_plist}
|
1583 |
a3bb036b
|
Renato Botelho
|
|
1584 |
|
|
# PHP module is special
|
1585 |
|
|
if echo "${_pname}" | grep -q "^php[0-9]*-${PRODUCT_NAME}-module"; then
|
1586 |
|
|
local _product_capital=$(echo ${PRODUCT_NAME} | tr '[a-z]' '[A-Z]')
|
1587 |
|
|
sed -i '' -e "s,PHP_PFSENSE,PHP_${_product_capital},g" \
|
1588 |
|
|
-e "s,PFSENSE_SHARED_LIBADD,${_product_capital}_SHARED_LIBADD,g" \
|
1589 |
|
|
-e "s,pfSense,${PRODUCT_NAME},g" \
|
1590 |
0436dfad
|
Ronald Schellberg
|
-e "s,pfSense.c,${PRODUCT_NAME}\.c,g" \
|
1591 |
a3bb036b
|
Renato Botelho
|
${_pdir}/${_pname}/files/config.m4
|
1592 |
|
|
|
1593 |
|
|
sed -i '' -e "s,COMPILE_DL_PFSENSE,COMPILE_DL_${_product_capital}," \
|
1594 |
|
|
-e "s,pfSense_module_entry,${PRODUCT_NAME}_module_entry,g" \
|
1595 |
0436dfad
|
Ronald Schellberg
|
-e "s,php_pfSense.h,php_${PRODUCT_NAME}\.h,g" \
|
1596 |
a3bb036b
|
Renato Botelho
|
-e "/ZEND_GET_MODULE/ s,pfSense,${PRODUCT_NAME}," \
|
1597 |
|
|
-e "/PHP_PFSENSE_WORLD_EXTNAME/ s,pfSense,${PRODUCT_NAME}," \
|
1598 |
|
|
${_pdir}/${_pname}/files/pfSense.c \
|
1599 |
0436dfad
|
Ronald Schellberg
|
${_pdir}/${_pname}/files/dummynet.c \
|
1600 |
a3bb036b
|
Renato Botelho
|
${_pdir}/${_pname}/files/php_pfSense.h
|
1601 |
|
|
fi
|
1602 |
|
|
|
1603 |
|
|
if [ -d ${_pdir}/${_pname}/files ]; then
|
1604 |
e4fe4666
|
Ronald Schellberg
|
for fd in $(find ${_pdir}/${_pname}/files -name '*pfSense*'); do
|
1605 |
a3bb036b
|
Renato Botelho
|
local _fddir=$(dirname ${fd})
|
1606 |
|
|
local _fdname=$(echo $(basename ${fd}) | sed "s,pfSense,${PRODUCT_NAME},")
|
1607 |
|
|
|
1608 |
|
|
mv ${fd} ${_fddir}/${_fdname}
|
1609 |
|
|
done
|
1610 |
|
|
fi
|
1611 |
|
|
done
|
1612 |
|
|
echo "Done!" | tee -a ${LOGFILE}
|
1613 |
|
|
}
|
1614 |
|
|
|
1615 |
6f73c362
|
Renato Botelho
|
poudriere_create_ports_tree() {
|
1616 |
|
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
1617 |
|
|
|
1618 |
|
|
if ! poudriere ports -l | grep -q -E "^${POUDRIERE_PORTS_NAME}[[:blank:]]"; then
|
1619 |
|
|
local _branch=""
|
1620 |
|
|
if [ -z "${POUDRIERE_PORTS_GIT_URL}" ]; then
|
1621 |
|
|
echo ">>> ERROR: POUDRIERE_PORTS_GIT_URL is not defined"
|
1622 |
|
|
print_error_pfS
|
1623 |
|
|
fi
|
1624 |
|
|
if [ -n "${POUDRIERE_PORTS_GIT_BRANCH}" ]; then
|
1625 |
71e9637a
|
Brad Davis
|
_branch="${POUDRIERE_PORTS_GIT_BRANCH}"
|
1626 |
6f73c362
|
Renato Botelho
|
fi
|
1627 |
|
|
echo -n ">>> Creating poudriere ports tree, it may take some time... " | tee -a ${LOGFILE}
|
1628 |
71e9637a
|
Brad Davis
|
if [ "${AWS}" = 1 ]; then
|
1629 |
|
|
set -e
|
1630 |
|
|
script -aq ${LOGFILE} poudriere ports -c -p "${POUDRIERE_PORTS_NAME}" -m none
|
1631 |
|
|
script -aq ${LOGFILE} zfs create ${ZFS_TANK}/poudriere/ports/${POUDRIERE_PORTS_NAME}
|
1632 |
1bd84384
|
Renato Botelho do Couto
|
|
1633 |
|
|
# If S3 doesn't contain stashed ports tree, create one
|
1634 |
85e010a1
|
Renato Botelho do Couto
|
if ! aws_exec s3 ls s3://pfsense-engineering-build-pkg/${FLAVOR}-ports.tz >/dev/null 2>&1; then
|
1635 |
1bd84384
|
Renato Botelho do Couto
|
mkdir ${SCRATCHDIR}/${FLAVOR}-ports
|
1636 |
|
|
${BUILDER_SCRIPTS}/git_checkout.sh \
|
1637 |
|
|
-r ${POUDRIERE_PORTS_GIT_URL} \
|
1638 |
|
|
-d ${SCRATCHDIR}/${FLAVOR}-ports \
|
1639 |
|
|
-b ${POUDRIERE_PORTS_GIT_BRANCH}
|
1640 |
|
|
|
1641 |
|
|
tar --zstd -C ${SCRATCHDIR} -cf ${FLAVOR}-ports.tz ${FLAVOR}-ports
|
1642 |
|
|
aws_exec s3 cp ${FLAVOR}-ports.tz s3://pfsense-engineering-build-pkg/${FLAVOR}-ports.tz --no-progress
|
1643 |
|
|
else
|
1644 |
|
|
# Download local copy of the ports tree stashed in S3
|
1645 |
|
|
echo ">>> Downloading cached copy of the ports tree from S3.." | tee -a ${LOGFILE}
|
1646 |
|
|
aws_exec s3 cp s3://pfsense-engineering-build-pkg/${FLAVOR}-ports.tz . --no-progress
|
1647 |
|
|
fi
|
1648 |
|
|
|
1649 |
27bd8237
|
Renato Botelho do Couto
|
script -aq ${LOGFILE} tar --strip-components 1 -xf ${FLAVOR}-ports.tz -C /usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}
|
1650 |
71e9637a
|
Brad Davis
|
# Update the ports tree
|
1651 |
|
|
(
|
1652 |
|
|
cd /usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}
|
1653 |
|
|
echo ">>> Updating cached copy of the ports tree from git.." | tee -a ${LOGFILE}
|
1654 |
|
|
script -aq ${LOGFILE} git pull
|
1655 |
|
|
script -aq ${LOGFILE} git checkout ${_branch}
|
1656 |
|
|
)
|
1657 |
|
|
set +e
|
1658 |
|
|
else
|
1659 |
|
|
if ! script -aq ${LOGFILE} poudriere ports -c -p "${POUDRIERE_PORTS_NAME}" -m git -U ${POUDRIERE_PORTS_GIT_URL} -B ${_branch} >/dev/null 2>&1; then
|
1660 |
|
|
echo "" | tee -a ${LOGFILE}
|
1661 |
|
|
echo ">>> ERROR: Error creating poudriere ports tree, aborting..." | tee -a ${LOGFILE}
|
1662 |
|
|
print_error_pfS
|
1663 |
|
|
fi
|
1664 |
6f73c362
|
Renato Botelho
|
fi
|
1665 |
|
|
echo "Done!" | tee -a ${LOGFILE}
|
1666 |
a3bb036b
|
Renato Botelho
|
poudriere_rename_ports
|
1667 |
6f73c362
|
Renato Botelho
|
fi
|
1668 |
|
|
}
|
1669 |
|
|
|
1670 |
|
|
poudriere_init() {
|
1671 |
|
|
local _error=0
|
1672 |
|
|
local _archs=$(poudriere_possible_archs)
|
1673 |
|
|
|
1674 |
|
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
1675 |
|
|
|
1676 |
|
|
# Sanity checks
|
1677 |
|
|
if [ -z "${ZFS_TANK}" ]; then
|
1678 |
|
|
echo ">>> ERROR: \$ZFS_TANK is empty" | tee -a ${LOGFILE}
|
1679 |
|
|
error=1
|
1680 |
|
|
fi
|
1681 |
|
|
|
1682 |
|
|
if [ -z "${ZFS_ROOT}" ]; then
|
1683 |
|
|
echo ">>> ERROR: \$ZFS_ROOT is empty" | tee -a ${LOGFILE}
|
1684 |
|
|
error=1
|
1685 |
|
|
fi
|
1686 |
|
|
|
1687 |
|
|
if [ -z "${POUDRIERE_PORTS_NAME}" ]; then
|
1688 |
|
|
echo ">>> ERROR: \$POUDRIERE_PORTS_NAME is empty" | tee -a ${LOGFILE}
|
1689 |
|
|
error=1
|
1690 |
|
|
fi
|
1691 |
|
|
|
1692 |
|
|
if [ ${_error} -eq 1 ]; then
|
1693 |
|
|
print_error_pfS
|
1694 |
|
|
fi
|
1695 |
|
|
|
1696 |
|
|
# Check if zpool exists
|
1697 |
|
|
if ! zpool list ${ZFS_TANK} >/dev/null 2>&1; then
|
1698 |
|
|
echo ">>> ERROR: ZFS tank ${ZFS_TANK} not found, please create it and try again..." | tee -a ${LOGFILE}
|
1699 |
|
|
print_error_pfS
|
1700 |
|
|
fi
|
1701 |
|
|
|
1702 |
|
|
# Check if zfs rootfs exists
|
1703 |
|
|
if ! zfs list ${ZFS_TANK}${ZFS_ROOT} >/dev/null 2>&1; then
|
1704 |
01541076
|
Renato Botelho
|
echo -n ">>> Creating ZFS filesystem ${ZFS_TANK}${ZFS_ROOT}... "
|
1705 |
52ec3f66
|
Renato Botelho
|
if zfs create -o atime=off -o mountpoint=/usr/local${ZFS_ROOT} \
|
1706 |
|
|
${ZFS_TANK}${ZFS_ROOT} >/dev/null 2>&1; then
|
1707 |
01541076
|
Renato Botelho
|
echo "Done!"
|
1708 |
|
|
else
|
1709 |
|
|
echo "Failed!"
|
1710 |
|
|
print_error_pfS
|
1711 |
|
|
fi
|
1712 |
6f73c362
|
Renato Botelho
|
fi
|
1713 |
|
|
|
1714 |
|
|
# Make sure poudriere is installed
|
1715 |
6743ed95
|
Renato Botelho
|
if [ ! -f /usr/local/bin/poudriere ]; then
|
1716 |
|
|
echo ">>> Installing poudriere..." | tee -a ${LOGFILE}
|
1717 |
|
|
if ! pkg install poudriere >/dev/null 2>&1; then
|
1718 |
|
|
echo ">>> ERROR: poudriere was not installed, aborting..." | tee -a ${LOGFILE}
|
1719 |
6f73c362
|
Renato Botelho
|
print_error_pfS
|
1720 |
|
|
fi
|
1721 |
|
|
fi
|
1722 |
|
|
|
1723 |
|
|
# Create poudriere.conf
|
1724 |
|
|
if [ -z "${POUDRIERE_PORTS_GIT_URL}" ]; then
|
1725 |
|
|
echo ">>> ERROR: POUDRIERE_PORTS_GIT_URL is not defined"
|
1726 |
|
|
print_error_pfS
|
1727 |
|
|
fi
|
1728 |
0e491fe2
|
Renato Botelho do Couto
|
|
1729 |
|
|
# PARALLEL_JOBS us ncpu / 4 for best performance
|
1730 |
|
|
local _parallel_jobs=$(sysctl -qn hw.ncpu)
|
1731 |
|
|
_parallel_jobs=$((_parallel_jobs / 4))
|
1732 |
|
|
|
1733 |
6f73c362
|
Renato Botelho
|
echo ">>> Creating poudriere.conf" | tee -a ${LOGFILE}
|
1734 |
|
|
cat <<EOF >/usr/local/etc/poudriere.conf
|
1735 |
|
|
ZPOOL=${ZFS_TANK}
|
1736 |
|
|
ZROOTFS=${ZFS_ROOT}
|
1737 |
|
|
RESOLV_CONF=/etc/resolv.conf
|
1738 |
|
|
BASEFS=/usr/local/poudriere
|
1739 |
|
|
USE_PORTLINT=no
|
1740 |
|
|
USE_TMPFS=yes
|
1741 |
|
|
NOLINUX=yes
|
1742 |
382c5ba6
|
Renato Botelho
|
DISTFILES_CACHE=/usr/ports/distfiles
|
1743 |
6f73c362
|
Renato Botelho
|
CHECK_CHANGED_OPTIONS=yes
|
1744 |
|
|
CHECK_CHANGED_DEPS=yes
|
1745 |
|
|
ATOMIC_PACKAGE_REPOSITORY=yes
|
1746 |
|
|
COMMIT_PACKAGES_ON_FAILURE=no
|
1747 |
2d0b7245
|
Renato Botelho
|
ALLOW_MAKE_JOBS=yes
|
1748 |
0e491fe2
|
Renato Botelho do Couto
|
PARALLEL_JOBS=${_parallel_jobs}
|
1749 |
5f64e2ca
|
Renato Botelho
|
EOF
|
1750 |
|
|
|
1751 |
fe31dc35
|
Renato Botelho
|
if pkg info -e ccache; then
|
1752 |
|
|
cat <<EOF >>/usr/local/etc/poudriere.conf
|
1753 |
|
|
CCACHE_DIR=/var/cache/ccache
|
1754 |
|
|
EOF
|
1755 |
|
|
fi
|
1756 |
|
|
|
1757 |
5f64e2ca
|
Renato Botelho
|
# Create specific items conf
|
1758 |
|
|
[ ! -d /usr/local/etc/poudriere.d ] \
|
1759 |
|
|
&& mkdir -p /usr/local/etc/poudriere.d
|
1760 |
|
|
|
1761 |
382c5ba6
|
Renato Botelho
|
# Create DISTFILES_CACHE if it doesn't exist
|
1762 |
|
|
if [ ! -d /usr/ports/distfiles ]; then
|
1763 |
|
|
mkdir -p /usr/ports/distfiles
|
1764 |
|
|
fi
|
1765 |
|
|
|
1766 |
1e77a36d
|
Brad Davis
|
if [ "${AWS}" = 1 ]; then
|
1767 |
|
|
# Find the distfiles cache for our branch, but fall back to devel cache if it does not exist
|
1768 |
|
|
if [ "${FLAVOR}" = "Plus" ]; then
|
1769 |
|
|
DEFAULT_BRANCH="plus-devel"
|
1770 |
|
|
else
|
1771 |
|
|
DEFAULT_BRANCH="devel"
|
1772 |
|
|
fi
|
1773 |
|
|
|
1774 |
|
|
if [ "${POUDRIERE_PORTS_GIT_BRANCH}" = "${DEFAULT_BRANCH}" ]; then
|
1775 |
|
|
DISTFILES="${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles"
|
1776 |
|
|
else
|
1777 |
|
|
if aws_exec s3 ls s3://pfsense-engineering-build-pkg/${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles.tar >/dev/null 2>&1; then
|
1778 |
|
|
DISTFILES="${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles"
|
1779 |
|
|
else
|
1780 |
|
|
DISTFILES="${FLAVOR}-${DEFAULT_BRANCH}-distfiles"
|
1781 |
a69cd017
|
Brad Davis
|
echo ">>> ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles.tar, not found."
|
1782 |
|
|
echo ">>> Falling back to ${DISTFILES}.tar"
|
1783 |
1e77a36d
|
Brad Davis
|
fi
|
1784 |
|
|
fi
|
1785 |
71e9637a
|
Brad Davis
|
|
1786 |
1e77a36d
|
Brad Davis
|
if aws_exec s3 ls s3://pfsense-engineering-build-pkg/${DISTFILES}.tar >/dev/null 2>&1; then
|
1787 |
|
|
# Download a copy of the distfiles from S3
|
1788 |
|
|
echo ">>> Downloading distfile cache ${DISTFILES} from S3.." | tee -a ${LOGFILE}
|
1789 |
|
|
aws_exec s3 cp s3://pfsense-engineering-build-pkg/${DISTFILES}.tar . --no-progress
|
1790 |
|
|
script -aq ${LOGFILE} tar -xf ${DISTFILES}.tar -C /usr/ports/distfiles
|
1791 |
|
|
# Save a list of distfiles
|
1792 |
|
|
find /usr/ports/distfiles > pre-build-distfile-list
|
1793 |
|
|
else
|
1794 |
a69cd017
|
Brad Davis
|
echo ">>> No distfile cache found, all distfiles will be fetched."
|
1795 |
1e77a36d
|
Brad Davis
|
touch pre-build-distfile-list
|
1796 |
|
|
fi
|
1797 |
71e9637a
|
Brad Davis
|
fi
|
1798 |
|
|
|
1799 |
6f73c362
|
Renato Botelho
|
# Remove old jails
|
1800 |
|
|
for jail_arch in ${_archs}; do
|
1801 |
|
|
jail_name=$(poudriere_jail_name ${jail_arch})
|
1802 |
|
|
|
1803 |
|
|
if poudriere jail -i -j "${jail_name}" >/dev/null 2>&1; then
|
1804 |
|
|
echo ">>> Poudriere jail ${jail_name} already exists, deleting it..." | tee -a ${LOGFILE}
|
1805 |
0436dfad
|
Ronald Schellberg
|
poudriere jail -d -j "${jail_name}"
|
1806 |
6f73c362
|
Renato Botelho
|
fi
|
1807 |
|
|
done
|
1808 |
|
|
|
1809 |
|
|
# Remove old ports tree
|
1810 |
|
|
if poudriere ports -l | grep -q -E "^${POUDRIERE_PORTS_NAME}[[:blank:]]"; then
|
1811 |
|
|
echo ">>> Poudriere ports tree ${POUDRIERE_PORTS_NAME} already exists, deleting it..." | tee -a ${LOGFILE}
|
1812 |
|
|
poudriere ports -d -p "${POUDRIERE_PORTS_NAME}"
|
1813 |
71e9637a
|
Brad Davis
|
if [ "${AWS}" = 1 ]; then
|
1814 |
|
|
for d in `zfs list -o name`; do
|
1815 |
|
|
if [ "${d}" = "${ZFS_TANK}/poudriere/ports/${POUDRIERE_PORTS_NAME}" ]; then
|
1816 |
|
|
script -aq ${LOGFILE} zfs destroy ${ZFS_TANK}/poudriere/ports/${POUDRIERE_PORTS_NAME}
|
1817 |
|
|
fi
|
1818 |
|
|
done
|
1819 |
|
|
fi
|
1820 |
6f73c362
|
Renato Botelho
|
fi
|
1821 |
|
|
|
1822 |
|
|
local native_xtools=""
|
1823 |
|
|
# Now we are ready to create jails
|
1824 |
|
|
for jail_arch in ${_archs}; do
|
1825 |
|
|
jail_name=$(poudriere_jail_name ${jail_arch})
|
1826 |
|
|
|
1827 |
82b59cee
|
Renato Botelho
|
if [ "${jail_arch}" = "arm.armv7" ]; then
|
1828 |
6f73c362
|
Renato Botelho
|
native_xtools="-x"
|
1829 |
|
|
else
|
1830 |
|
|
native_xtools=""
|
1831 |
|
|
fi
|
1832 |
|
|
|
1833 |
71e9637a
|
Brad Davis
|
echo ">>> Creating jail ${jail_name}, it may take some time... " | tee -a ${LOGFILE}
|
1834 |
|
|
if [ "${AWS}" = "1" ]; then
|
1835 |
|
|
mkdir objs
|
1836 |
87075500
|
Renato Botelho do Couto
|
echo ">>> Downloading prebuilt release objs from s3://pfsense-engineering-build-freebsd-obj-tarballs/${FLAVOR}/${FREEBSD_BRANCH}/ ..." | tee -a ${LOGFILE}
|
1837 |
71e9637a
|
Brad Davis
|
# Download prebuilt release tarballs from previous job
|
1838 |
87075500
|
Renato Botelho do Couto
|
aws_exec s3 cp s3://pfsense-engineering-build-freebsd-obj-tarballs/${FLAVOR}/${FREEBSD_BRANCH}/LATEST-${jail_arch} objs --no-progress
|
1839 |
71e9637a
|
Brad Davis
|
SRC_COMMIT=`cat objs/LATEST-${jail_arch}`
|
1840 |
87075500
|
Renato Botelho do Couto
|
aws_exec s3 cp s3://pfsense-engineering-build-freebsd-obj-tarballs/${FLAVOR}/${FREEBSD_BRANCH}/MANIFEST-${jail_arch}-${SRC_COMMIT} objs --no-progress
|
1841 |
71e9637a
|
Brad Davis
|
ln -s MANIFEST-${jail_arch}-${SRC_COMMIT} objs/MANIFEST
|
1842 |
|
|
for i in base doc kernel src tests; do
|
1843 |
|
|
if [ ! -f objs/${i}-${jail_arch}-${SRC_COMMIT}.txz ]; then
|
1844 |
87075500
|
Renato Botelho do Couto
|
aws_exec s3 cp s3://pfsense-engineering-build-freebsd-obj-tarballs/${FLAVOR}/${FREEBSD_BRANCH}/${i}-${jail_arch}-${SRC_COMMIT}.txz objs --no-progress
|
1845 |
71e9637a
|
Brad Davis
|
ln -s ${i}-${jail_arch}-${SRC_COMMIT}.txz objs/${i}.txz
|
1846 |
|
|
fi
|
1847 |
|
|
done
|
1848 |
|
|
|
1849 |
|
|
if ! script -aq ${LOGFILE} poudriere jail -c -j "${jail_name}" -v ${FREEBSD_BRANCH} \
|
1850 |
|
|
-a ${jail_arch} -m url=file://${PWD}/objs >/dev/null 2>&1; then
|
1851 |
|
|
echo "" | tee -a ${LOGFILE}
|
1852 |
|
|
echo ">>> ERROR: Error creating jail ${jail_name}, aborting..." | tee -a ${LOGFILE}
|
1853 |
|
|
print_error_pfS
|
1854 |
|
|
fi
|
1855 |
|
|
|
1856 |
|
|
# Download a cached pkg repo from S3
|
1857 |
|
|
OLDIFS=${IFS}
|
1858 |
|
|
IFS=$'\n'
|
1859 |
|
|
echo ">>> Downloading cached pkgs for ${jail_arch} from S3.." | tee -a ${LOGFILE}
|
1860 |
8be1bb42
|
Renato Botelho do Couto
|
if aws_exec s3 ls s3://pfsense-engineering-build-pkg/${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar >/dev/null 2>&1; then
|
1861 |
|
|
aws_exec s3 cp s3://pfsense-engineering-build-pkg/${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar . --no-progress
|
1862 |
6363f2bb
|
Renato Botelho do Couto
|
[ ! -d /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME} ] && mkdir -p /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}
|
1863 |
8be1bb42
|
Renato Botelho do Couto
|
echo "Extracting ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar to /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}" | tee -a ${LOGFILE}
|
1864 |
6363f2bb
|
Renato Botelho do Couto
|
[ ! -d /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME} ] && mkdir /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}
|
1865 |
8be1bb42
|
Renato Botelho do Couto
|
script -aq ${LOGFILE} tar -xf ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar -C /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}
|
1866 |
6363f2bb
|
Renato Botelho do Couto
|
# Save a list of pkgs
|
1867 |
|
|
cd /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}/.latest
|
1868 |
|
|
find . > ${WORKSPACE}/pre-build-pkg-list-${jail_arch}
|
1869 |
|
|
cd ${WORKSPACE}
|
1870 |
|
|
else
|
1871 |
|
|
touch pre-build-pkg-list-${jail_arch}
|
1872 |
|
|
fi
|
1873 |
71e9637a
|
Brad Davis
|
IFS=${OLDIFS}
|
1874 |
|
|
else
|
1875 |
|
|
if ! script -aq ${LOGFILE} poudriere jail -c -j "${jail_name}" -v ${FREEBSD_BRANCH} \
|
1876 |
|
|
-a ${jail_arch} -m git -U ${FREEBSD_REPO_BASE_POUDRIERE} ${native_xtools} >/dev/null 2>&1; then
|
1877 |
|
|
echo "" | tee -a ${LOGFILE}
|
1878 |
|
|
echo ">>> ERROR: Error creating jail ${jail_name}, aborting..." | tee -a ${LOGFILE}
|
1879 |
|
|
print_error_pfS
|
1880 |
|
|
fi
|
1881 |
6f73c362
|
Renato Botelho
|
fi
|
1882 |
|
|
echo "Done!" | tee -a ${LOGFILE}
|
1883 |
|
|
done
|
1884 |
|
|
|
1885 |
|
|
poudriere_create_ports_tree
|
1886 |
|
|
|
1887 |
|
|
echo ">>> Poudriere is now configured!" | tee -a ${LOGFILE}
|
1888 |
|
|
}
|
1889 |
|
|
|
1890 |
|
|
poudriere_update_jails() {
|
1891 |
|
|
local _archs=$(poudriere_possible_archs)
|
1892 |
|
|
|
1893 |
|
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
1894 |
|
|
|
1895 |
|
|
local native_xtools=""
|
1896 |
|
|
for jail_arch in ${_archs}; do
|
1897 |
|
|
jail_name=$(poudriere_jail_name ${jail_arch})
|
1898 |
|
|
|
1899 |
c136dde1
|
Renato Botelho
|
local _create_or_update="-u"
|
1900 |
43f6b081
|
Renato Botelho
|
local _create_or_update_text="Updating"
|
1901 |
6f73c362
|
Renato Botelho
|
if ! poudriere jail -i -j "${jail_name}" >/dev/null 2>&1; then
|
1902 |
c136dde1
|
Renato Botelho
|
echo ">>> Poudriere jail ${jail_name} not found, creating..." | tee -a ${LOGFILE}
|
1903 |
ac464524
|
Renato Botelho
|
_create_or_update="-c -v ${FREEBSD_BRANCH} -a ${jail_arch} -m git -U ${FREEBSD_REPO_BASE_POUDRIERE}"
|
1904 |
43f6b081
|
Renato Botelho
|
_create_or_update_text="Creating"
|
1905 |
6f73c362
|
Renato Botelho
|
fi
|
1906 |
|
|
|
1907 |
82b59cee
|
Renato Botelho
|
if [ "${jail_arch}" = "arm.armv7" ]; then
|
1908 |
6f73c362
|
Renato Botelho
|
native_xtools="-x"
|
1909 |
|
|
else
|
1910 |
|
|
native_xtools=""
|
1911 |
|
|
fi
|
1912 |
|
|
|
1913 |
43f6b081
|
Renato Botelho
|
echo -n ">>> ${_create_or_update_text} jail ${jail_name}, it may take some time... " | tee -a ${LOGFILE}
|
1914 |
ac464524
|
Renato Botelho
|
if ! script -aq ${LOGFILE} poudriere jail ${_create_or_update} -j "${jail_name}" ${native_xtools} >/dev/null 2>&1; then
|
1915 |
6f73c362
|
Renato Botelho
|
echo "" | tee -a ${LOGFILE}
|
1916 |
43f6b081
|
Renato Botelho
|
echo ">>> ERROR: Error ${_create_or_update_text} jail ${jail_name}, aborting..." | tee -a ${LOGFILE}
|
1917 |
6f73c362
|
Renato Botelho
|
print_error_pfS
|
1918 |
|
|
fi
|
1919 |
|
|
echo "Done!" | tee -a ${LOGFILE}
|
1920 |
|
|
done
|
1921 |
|
|
}
|
1922 |
|
|
|
1923 |
|
|
poudriere_update_ports() {
|
1924 |
|
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
1925 |
|
|
|
1926 |
|
|
# Create ports tree if necessary
|
1927 |
|
|
if ! poudriere ports -l | grep -q -E "^${POUDRIERE_PORTS_NAME}[[:blank:]]"; then
|
1928 |
|
|
poudriere_create_ports_tree
|
1929 |
|
|
else
|
1930 |
97bc6c78
|
Phil Davis
|
echo -n ">>> Resetting local changes on ports tree ${POUDRIERE_PORTS_NAME}... " | tee -a ${LOGFILE}
|
1931 |
d94da298
|
Renato Botelho
|
script -aq ${LOGFILE} git -C "/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}" reset --hard >/dev/null 2>&1
|
1932 |
7d26baf3
|
Renato Botelho
|
script -aq ${LOGFILE} git -C "/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}" clean -fd >/dev/null 2>&1
|
1933 |
d94da298
|
Renato Botelho
|
echo "Done!" | tee -a ${LOGFILE}
|
1934 |
6f73c362
|
Renato Botelho
|
echo -n ">>> Updating ports tree ${POUDRIERE_PORTS_NAME}... " | tee -a ${LOGFILE}
|
1935 |
|
|
script -aq ${LOGFILE} poudriere ports -u -p "${POUDRIERE_PORTS_NAME}" >/dev/null 2>&1
|
1936 |
|
|
echo "Done!" | tee -a ${LOGFILE}
|
1937 |
a3bb036b
|
Renato Botelho
|
poudriere_rename_ports
|
1938 |
6f73c362
|
Renato Botelho
|
fi
|
1939 |
|
|
}
|
1940 |
|
|
|
1941 |
71e9637a
|
Brad Davis
|
save_logs_to_s3() {
|
1942 |
|
|
# Save a copy of the past few logs into S3
|
1943 |
|
|
DATE=`date +%Y%m%d-%H%M%S`
|
1944 |
|
|
script -aq ${LOGFILE} tar --zstd -cf pkg-logs-${jail_arch}-${DATE}.tar -C /usr/local/poudriere/data/logs/bulk/${jail_name}-${POUDRIERE_PORTS_NAME}/latest/ .
|
1945 |
dcc5e63d
|
Renato Botelho do Couto
|
aws_exec s3 cp pkg-logs-${jail_arch}-${DATE}.tar s3://pfsense-engineering-build-pkg/logs/ --no-progress
|
1946 |
5a1436da
|
Brad Davis
|
echo ">>> Uploading pkg-logs-${jail_arch}-${DATE}.tar to s3" | tee -a ${LOGFILE}
|
1947 |
71e9637a
|
Brad Davis
|
OLDIFS=${IFS}
|
1948 |
|
|
IFS=$'\n'
|
1949 |
|
|
local _logtemp=$( mktemp /tmp/loglist.XXXXX )
|
1950 |
dcc5e63d
|
Renato Botelho do Couto
|
for i in $(aws_exec s3 ls s3://pfsense-engineering-build-pkg/logs/); do
|
1951 |
65fc53d1
|
Brad Davis
|
echo ${i} | awk '{print $4}' | grep pkg-logs-${jail_arch} | tr -d '\r' >> ${_logtemp}
|
1952 |
71e9637a
|
Brad Davis
|
done
|
1953 |
6bdf2d74
|
Brad Davis
|
# keep at least ~30 days of logs, plus some extra for one off runs
|
1954 |
|
|
local _maxlogs=45
|
1955 |
71e9637a
|
Brad Davis
|
local _curlogs=0
|
1956 |
|
|
_curlogs=$( wc -l ${_logtemp} | awk '{print $1}' )
|
1957 |
|
|
if [ ${_curlogs} -gt ${_maxlogs} ]; then
|
1958 |
|
|
local _extralogs=$(( ${_curlogs} - ${_maxlogs} ))
|
1959 |
|
|
for _last in $( head -${_extralogs} ${_logtemp} ); do
|
1960 |
dcc5e63d
|
Renato Botelho do Couto
|
aws_exec s3 rm s3://pfsense-engineering-build-pkg/logs/${_last}
|
1961 |
71e9637a
|
Brad Davis
|
done
|
1962 |
|
|
fi
|
1963 |
|
|
IFS=${OLDIFS}
|
1964 |
|
|
}
|
1965 |
|
|
|
1966 |
e4560653
|
Brad Davis
|
save_pkgs_to_s3() {
|
1967 |
|
|
cd /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}/.latest
|
1968 |
|
|
find . > ${WORKSPACE}/post-build-pkg-list-${jail_arch}
|
1969 |
|
|
cd ${WORKSPACE}
|
1970 |
|
|
diff pre-build-pkg-list-${jail_arch} post-build-pkg-list-${jail_arch} > /dev/null
|
1971 |
|
|
if [ $? = 1 ]; then
|
1972 |
26671c4d
|
Brad Davis
|
echo ">>> Saving a copy of the package repo into S3..." | tee -a ${LOGFILE}
|
1973 |
8be1bb42
|
Renato Botelho do Couto
|
[ -f ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar ] && rm ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar
|
1974 |
|
|
script -aq ${LOGFILE} tar -cf ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar -C /usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME} .
|
1975 |
|
|
aws_exec s3 cp ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-pkgs-${jail_arch}.tar s3://pfsense-engineering-build-pkg/ --no-progress
|
1976 |
26671c4d
|
Brad Davis
|
else
|
1977 |
|
|
echo ">>> No pkgs different, not saving to S3..." | tee -a ${LOGFILE}
|
1978 |
e4560653
|
Brad Davis
|
fi
|
1979 |
26671c4d
|
Brad Davis
|
save_logs_to_s3
|
1980 |
e4560653
|
Brad Davis
|
}
|
1981 |
|
|
|
1982 |
dcc5e63d
|
Renato Botelho do Couto
|
aws_exec() {
|
1983 |
|
|
script -aq ${LOGFILE} \
|
1984 |
|
|
env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
|
1985 |
|
|
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
|
1986 |
|
|
AWS_DEFAULT_REGION=us-east-2 \
|
1987 |
b7ab1742
|
Brad Davis
|
AWS_DEFAULT_OUTPUT=text \
|
1988 |
dcc5e63d
|
Renato Botelho do Couto
|
aws $@
|
1989 |
|
|
return $?
|
1990 |
|
|
}
|
1991 |
|
|
|
1992 |
6f73c362
|
Renato Botelho
|
poudriere_bulk() {
|
1993 |
|
|
local _archs=$(poudriere_possible_archs)
|
1994 |
61de46d7
|
Renato Botelho
|
local _makeconf
|
1995 |
6f73c362
|
Renato Botelho
|
|
1996 |
88340f50
|
Renato Botelho do Couto
|
# Create DISTFILES_CACHE if it doesn't exist
|
1997 |
|
|
if [ ! -d /usr/ports/distfiles ]; then
|
1998 |
|
|
mkdir -p /usr/ports/distfiles
|
1999 |
|
|
fi
|
2000 |
|
|
|
2001 |
6f73c362
|
Renato Botelho
|
LOGFILE=${BUILDER_LOGS}/poudriere.log
|
2002 |
|
|
|
2003 |
af7b55fc
|
Brad Davis
|
local _pkg_rsync_site_count=0
|
2004 |
|
|
for _pkg_rsync_site in ${PKG_RSYNC_HOSTS}; do
|
2005 |
50ef7d15
|
Brad Davis
|
eval _pkg_rsync_hostname=\$PKG_RSYNC_HOSTNAME_$_pkg_rsync_site
|
2006 |
af7b55fc
|
Brad Davis
|
[ -n "${_pkg_rsync_hostname}" ] && \
|
2007 |
|
|
_pkg_rsync_site_count=$(( ${_pkg_rsync_site_count} + 1 ))
|
2008 |
|
|
done
|
2009 |
|
|
|
2010 |
|
|
if [ -n "${UPLOAD}" ] && [ "${_pkg_rsync_site_count}" -eq 0 ]; then
|
2011 |
|
|
echo ">>> ERROR: PKG_RSYNC_HOSTS is not set"
|
2012 |
e295b113
|
Renato Botelho
|
print_error_pfS
|
2013 |
|
|
fi
|
2014 |
|
|
|
2015 |
26f1087f
|
Renato Botelho
|
rm -f ${LOGFILE}
|
2016 |
|
|
|
2017 |
6f73c362
|
Renato Botelho
|
poudriere_create_ports_tree
|
2018 |
|
|
|
2019 |
|
|
[ -d /usr/local/etc/poudriere.d ] || \
|
2020 |
|
|
mkdir -p /usr/local/etc/poudriere.d
|
2021 |
|
|
|
2022 |
61de46d7
|
Renato Botelho
|
_makeconf=/usr/local/etc/poudriere.d/${POUDRIERE_PORTS_NAME}-make.conf
|
2023 |
edef37f6
|
Renato Botelho
|
if [ -f "${BUILDER_TOOLS}/conf/pfPorts/make.conf" ]; then
|
2024 |
4cea5c50
|
Renato Botelho do Couto
|
sed -e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" \
|
2025 |
6bfe7f67
|
Renato Botelho do Couto
|
-e "s,%%PRODUCT_VERSION%%,${PRODUCT_VERSION},g" \
|
2026 |
4cea5c50
|
Renato Botelho do Couto
|
"${BUILDER_TOOLS}/conf/pfPorts/make.conf" > ${_makeconf}
|
2027 |
6f73c362
|
Renato Botelho
|
fi
|
2028 |
|
|
|
2029 |
39f2cfd1
|
Renato Botelho
|
cat <<EOF >>/usr/local/etc/poudriere.d/${POUDRIERE_PORTS_NAME}-make.conf
|
2030 |
3209e782
|
Renato Botelho do Couto
|
|
2031 |
39f2cfd1
|
Renato Botelho
|
PKG_REPO_BRANCH_DEVEL=${PKG_REPO_BRANCH_DEVEL}
|
2032 |
7e9a12e9
|
Brad Davis
|
PKG_REPO_BRANCH_NEXT=${PKG_REPO_BRANCH_NEXT}
|
2033 |
39f2cfd1
|
Renato Botelho
|
PKG_REPO_BRANCH_RELEASE=${PKG_REPO_BRANCH_RELEASE}
|
2034 |
7e9a12e9
|
Brad Davis
|
PKG_REPO_BRANCH_PREVIOUS=${PKG_REPO_BRANCH_PREVIOUS}
|
2035 |
39f2cfd1
|
Renato Botelho
|
PKG_REPO_SERVER_DEVEL=${PKG_REPO_SERVER_DEVEL}
|
2036 |
|
|
PKG_REPO_SERVER_RELEASE=${PKG_REPO_SERVER_RELEASE}
|
2037 |
|
|
POUDRIERE_PORTS_NAME=${POUDRIERE_PORTS_NAME}
|
2038 |
15f12d8e
|
Renato Botelho
|
PFSENSE_DEFAULT_REPO=${PFSENSE_DEFAULT_REPO}
|
2039 |
39f2cfd1
|
Renato Botelho
|
PRODUCT_NAME=${PRODUCT_NAME}
|
2040 |
062a7598
|
Renato Botelho do Couto
|
REPO_BRANCH_PREFIX=${REPO_PATH_PREFIX}
|
2041 |
39f2cfd1
|
Renato Botelho
|
EOF
|
2042 |
|
|
|
2043 |
61de46d7
|
Renato Botelho
|
local _value=""
|
2044 |
f7961bd1
|
Renato Botelho
|
for jail_arch in ${_archs}; do
|
2045 |
f2bd5e35
|
Renato Botelho
|
eval "_value=\${PKG_REPO_BRANCH_DEVEL_${jail_arch##*.}}"
|
2046 |
61de46d7
|
Renato Botelho
|
if [ -n "${_value}" ]; then
|
2047 |
f2bd5e35
|
Renato Botelho
|
echo "PKG_REPO_BRANCH_DEVEL_${jail_arch##*.}=${_value}" \
|
2048 |
61de46d7
|
Renato Botelho
|
>> ${_makeconf}
|
2049 |
f7961bd1
|
Renato Botelho
|
fi
|
2050 |
f2bd5e35
|
Renato Botelho
|
eval "_value=\${PKG_REPO_BRANCH_RELEASE_${jail_arch##*.}}"
|
2051 |
61de46d7
|
Renato Botelho
|
if [ -n "${_value}" ]; then
|
2052 |
f2bd5e35
|
Renato Botelho
|
echo "PKG_REPO_BRANCH_RELEASE_${jail_arch##*.}=${_value}" \
|
2053 |
61de46d7
|
Renato Botelho
|
>> ${_makeconf}
|
2054 |
f7961bd1
|
Renato Botelho
|
fi
|
2055 |
f2bd5e35
|
Renato Botelho
|
eval "_value=\${PKG_REPO_SERVER_DEVEL_${jail_arch##*.}}"
|
2056 |
61de46d7
|
Renato Botelho
|
if [ -n "${_value}" ]; then
|
2057 |
f2bd5e35
|
Renato Botelho
|
echo "PKG_REPO_SERVER_DEVEL_${jail_arch##*.}=${_value}" \
|
2058 |
61de46d7
|
Renato Botelho
|
>> ${_makeconf}
|
2059 |
f7961bd1
|
Renato Botelho
|
fi
|
2060 |
f2bd5e35
|
Renato Botelho
|
eval "_value=\${PKG_REPO_SERVER_RELEASE_${jail_arch##*.}}"
|
2061 |
61de46d7
|
Renato Botelho
|
if [ -n "${_value}" ]; then
|
2062 |
f2bd5e35
|
Renato Botelho
|
echo "PKG_REPO_SERVER_RELEASE_${jail_arch##*.}=${_value}" \
|
2063 |
61de46d7
|
Renato Botelho
|
>> ${_makeconf}
|
2064 |
f7961bd1
|
Renato Botelho
|
fi
|
2065 |
|
|
done
|
2066 |
|
|
|
2067 |
d94da298
|
Renato Botelho
|
# Change version of pfSense meta ports for snapshots
|
2068 |
|
|
if [ -z "${_IS_RELEASE}" ]; then
|
2069 |
b00400ef
|
Renato Botelho
|
local _meta_pkg_version="$(echo "${PRODUCT_VERSION}" | sed 's,DEVELOPMENT,ALPHA,')-${DATESTRING}"
|
2070 |
02ec5bd3
|
Renato Botelho
|
sed -i '' \
|
2071 |
|
|
-e "/^DISTVERSION/ s,^.*,DISTVERSION= ${_meta_pkg_version}," \
|
2072 |
|
|
-e "/^PORTREVISION=/d" \
|
2073 |
39f2cfd1
|
Renato Botelho
|
/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}/security/${PRODUCT_NAME}/Makefile \
|
2074 |
|
|
/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}/sysutils/${PRODUCT_NAME}-repo/Makefile
|
2075 |
d94da298
|
Renato Botelho
|
fi
|
2076 |
|
|
|
2077 |
39f2cfd1
|
Renato Botelho
|
# Copy over pkg repo templates to pfSense-repo
|
2078 |
|
|
mkdir -p /usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}/sysutils/${PRODUCT_NAME}-repo/files
|
2079 |
a546d014
|
Renato Botelho
|
cp -f ${PKG_REPO_BASE}/* \
|
2080 |
39f2cfd1
|
Renato Botelho
|
/usr/local/poudriere/ports/${POUDRIERE_PORTS_NAME}/sysutils/${PRODUCT_NAME}-repo/files
|
2081 |
|
|
|
2082 |
6f73c362
|
Renato Botelho
|
for jail_arch in ${_archs}; do
|
2083 |
|
|
jail_name=$(poudriere_jail_name ${jail_arch})
|
2084 |
|
|
|
2085 |
|
|
if ! poudriere jail -i -j "${jail_name}" >/dev/null 2>&1; then
|
2086 |
|
|
echo ">>> Poudriere jail ${jail_name} not found, skipping..." | tee -a ${LOGFILE}
|
2087 |
|
|
continue
|
2088 |
|
|
fi
|
2089 |
|
|
|
2090 |
deb5f1da
|
Luiz Souza
|
_ref_bulk=${SCRATCHDIR}/poudriere_bulk.${POUDRIERE_BRANCH}.ref.${jail_arch}
|
2091 |
|
|
rm -rf ${_ref_bulk} ${_ref_bulk}.tmp
|
2092 |
|
|
touch ${_ref_bulk}.tmp
|
2093 |
bd936941
|
Luiz Souza
|
if [ -f "${POUDRIERE_BULK}.${jail_arch#*.}" ]; then
|
2094 |
|
|
cat "${POUDRIERE_BULK}.${jail_arch#*.}" >> ${_ref_bulk}.tmp
|
2095 |
deb5f1da
|
Luiz Souza
|
fi
|
2096 |
|
|
if [ -f "${POUDRIERE_BULK}" ]; then
|
2097 |
|
|
cat "${POUDRIERE_BULK}" >> ${_ref_bulk}.tmp
|
2098 |
6f73c362
|
Renato Botelho
|
fi
|
2099 |
deb5f1da
|
Luiz Souza
|
cat ${_ref_bulk}.tmp | sort -u > ${_ref_bulk}
|
2100 |
6f73c362
|
Renato Botelho
|
|
2101 |
deb5f1da
|
Luiz Souza
|
_bulk=${SCRATCHDIR}/poudriere_bulk.${POUDRIERE_BRANCH}.${jail_arch}
|
2102 |
6f73c362
|
Renato Botelho
|
sed -e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" ${_ref_bulk} > ${_bulk}
|
2103 |
|
|
|
2104 |
f72d162f
|
Renato Botelho
|
local _exclude_bulk="${POUDRIERE_BULK}.exclude.${jail_arch}"
|
2105 |
|
|
if [ -f "${_exclude_bulk}" ]; then
|
2106 |
|
|
mv ${_bulk} ${_bulk}.tmp
|
2107 |
|
|
sed -e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" ${_exclude_bulk} > ${_bulk}.exclude
|
2108 |
855d9774
|
Renato Botelho
|
cat ${_bulk}.tmp ${_bulk}.exclude | sort | uniq -u > ${_bulk}
|
2109 |
|
|
rm -f ${_bulk}.tmp ${_bulk}.exclude
|
2110 |
f72d162f
|
Renato Botelho
|
fi
|
2111 |
|
|
|
2112 |
71e9637a
|
Brad Davis
|
echo ">>> Poudriere bulk started at `date "+%Y/%m/%d %H:%M:%S"` for ${jail_arch}"
|
2113 |
6f73c362
|
Renato Botelho
|
if ! poudriere bulk -f ${_bulk} -j ${jail_name} -p ${POUDRIERE_PORTS_NAME}; then
|
2114 |
|
|
echo ">>> ERROR: Something went wrong..."
|
2115 |
71e9637a
|
Brad Davis
|
if [ "${AWS}" = 1 ]; then
|
2116 |
e4560653
|
Brad Davis
|
save_pkgs_to_s3
|
2117 |
71e9637a
|
Brad Davis
|
fi
|
2118 |
6f73c362
|
Renato Botelho
|
print_error_pfS
|
2119 |
|
|
fi
|
2120 |
71e9637a
|
Brad Davis
|
echo ">>> Poudriere bulk complated at `date "+%Y/%m/%d %H:%M:%S"` for ${jail_arch}"
|
2121 |
6f73c362
|
Renato Botelho
|
|
2122 |
|
|
echo ">>> Cleaning up old packages from repo..."
|
2123 |
|
|
if ! poudriere pkgclean -f ${_bulk} -j ${jail_name} -p ${POUDRIERE_PORTS_NAME} -y; then
|
2124 |
|
|
echo ">>> ERROR: Something went wrong..."
|
2125 |
|
|
print_error_pfS
|
2126 |
|
|
fi
|
2127 |
|
|
|
2128 |
71e9637a
|
Brad Davis
|
if [ "${AWS}" = 1 ]; then
|
2129 |
e4560653
|
Brad Davis
|
save_pkgs_to_s3
|
2130 |
71e9637a
|
Brad Davis
|
fi
|
2131 |
|
|
|
2132 |
61b63ac0
|
Renato Botelho
|
pkg_repo_rsync "/usr/local/poudriere/data/packages/${jail_name}-${POUDRIERE_PORTS_NAME}"
|
2133 |
6f73c362
|
Renato Botelho
|
done
|
2134 |
71e9637a
|
Brad Davis
|
|
2135 |
|
|
if [ "${AWS}" = 1 ]; then
|
2136 |
05a02665
|
Brad Davis
|
echo ">>> Run poudriere distclean to prune old distfiles..." | tee -a ${LOGFILE}
|
2137 |
b79dff5b
|
Brad Davis
|
if ! poudriere distclean -f ${_bulk} -p ${POUDRIERE_PORTS_NAME} -n; then
|
2138 |
05a02665
|
Brad Davis
|
echo ">>> ERROR: Something went wrong..."
|
2139 |
|
|
print_error_pfS
|
2140 |
|
|
fi
|
2141 |
71e9637a
|
Brad Davis
|
echo ">>> Save a copy of the distfiles into S3..." | tee -a ${LOGFILE}
|
2142 |
|
|
# Save a copy of the distfiles from S3
|
2143 |
|
|
find /usr/ports/distfiles > post-build-distfile-list
|
2144 |
|
|
diff pre-build-distfile-list post-build-distfile-list > /dev/null
|
2145 |
|
|
if [ $? -eq 1 ]; then
|
2146 |
1e77a36d
|
Brad Davis
|
rm -f ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles.tar
|
2147 |
700f4da0
|
Brad Davis
|
script -aq ${LOGFILE} tar -cf ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles.tar -C /usr/ports/distfiles .
|
2148 |
|
|
aws_exec s3 cp ${FLAVOR}-${POUDRIERE_PORTS_GIT_BRANCH}-distfiles.tar s3://pfsense-engineering-build-pkg/ --no-progress
|
2149 |
71e9637a
|
Brad Davis
|
fi
|
2150 |
|
|
fi
|
2151 |
6f73c362
|
Renato Botelho
|
}
|
2152 |
ab943fc9
|
Renato Botelho
|
|
2153 |
|
|
# This routine is called to write out to stdout
|
2154 |
|
|
# a string. The string is appended to $SNAPSHOTSLOGFILE
|
2155 |
|
|
snapshots_update_status() {
|
2156 |
919c8486
|
Renato Botelho
|
if [ -z "$1" ]; then
|
2157 |
|
|
return
|
2158 |
|
|
fi
|
2159 |
|
|
if [ -z "${SNAPSHOTS}" -a -z "${POUDRIERE_SNAPSHOTS}" ]; then
|
2160 |
ab943fc9
|
Renato Botelho
|
return
|
2161 |
|
|
fi
|
2162 |
0cc93b74
|
Renato Botelho
|
echo "$*"
|
2163 |
|
|
echo "`date` -|- $*" >> $SNAPSHOTSLOGFILE
|
2164 |
ab943fc9
|
Renato Botelho
|
}
|
2165 |
|
|
|
2166 |
97f7a154
|
Renato Botelho
|
create_sha256() {
|
2167 |
|
|
local _file="${1}"
|
2168 |
|
|
|
2169 |
|
|
if [ ! -f "${_file}" ]; then
|
2170 |
|
|
return 1
|
2171 |
|
|
fi
|
2172 |
|
|
|
2173 |
|
|
( \
|
2174 |
|
|
cd $(dirname ${_file}) && \
|
2175 |
|
|
sha256 $(basename ${_file}) > $(basename ${_file}).sha256 \
|
2176 |
|
|
)
|
2177 |
|
|
}
|
2178 |
|
|
|
2179 |
e28305f4
|
Renato Botelho
|
snapshots_create_latest_symlink() {
|
2180 |
|
|
local _image="${1}"
|
2181 |
|
|
|
2182 |
|
|
if [ -z "${_image}" ]; then
|
2183 |
|
|
return
|
2184 |
|
|
fi
|
2185 |
|
|
|
2186 |
|
|
if [ -z "${TIMESTAMP_SUFFIX}" ]; then
|
2187 |
|
|
return
|
2188 |
|
|
fi
|
2189 |
|
|
|
2190 |
5a944dd5
|
Renato Botelho
|
if [ ! -f "${_image}" ]; then
|
2191 |
a4a336b2
|
Renato Botelho
|
return
|
2192 |
e28305f4
|
Renato Botelho
|
fi
|
2193 |
|
|
|
2194 |
695ba439
|
Renato Botelho
|
local _symlink=$(echo ${_image} | sed "s,${TIMESTAMP_SUFFIX},-latest,")
|
2195 |
|
|
ln -sf $(basename ${_image}) ${_symlink}
|
2196 |
e28305f4
|
Renato Botelho
|
ln -sf $(basename ${_image}).sha256 ${_symlink}.sha256
|
2197 |
|
|
}
|
2198 |
|
|
|
2199 |
f26731b0
|
Renato Botelho
|
snapshots_create_sha256() {
|
2200 |
87925fd1
|
Renato Botelho
|
local _img=""
|
2201 |
ab943fc9
|
Renato Botelho
|
|
2202 |
b0d0498c
|
Renato Botelho
|
for _img in ${ISOPATH} ${MEMSTICKPATH} ${MEMSTICKSERIALPATH} ${MEMSTICKADIPATH} ${OVAPATH} ${VARIANTIMAGES}; do
|
2203 |
f26731b0
|
Renato Botelho
|
if [ -f "${_img}.gz" ]; then
|
2204 |
|
|
_img="${_img}.gz"
|
2205 |
|
|
fi
|
2206 |
|
|
if [ ! -f "${_img}" ]; then
|
2207 |
87925fd1
|
Renato Botelho
|
continue
|
2208 |
|
|
fi
|
2209 |
97f7a154
|
Renato Botelho
|
create_sha256 ${_img}
|
2210 |
f26731b0
|
Renato Botelho
|
snapshots_create_latest_symlink ${_img}
|
2211 |
87925fd1
|
Renato Botelho
|
done
|
2212 |
ab943fc9
|
Renato Botelho
|
}
|
2213 |
|
|
|
2214 |
|
|
snapshots_scp_files() {
|
2215 |
d4c6029e
|
Renato Botelho
|
if [ -z "${RSYNC_COPY_ARGUMENTS}" ]; then
|
2216 |
547d0883
|
Renato Botelho do Couto
|
RSYNC_COPY_ARGUMENTS="-Have \"ssh -o StrictHostKeyChecking=no\" --timeout=60"
|
2217 |
ab943fc9
|
Renato Botelho
|
fi
|
2218 |
48396120
|
Renato Botelho
|
|
2219 |
|
|
snapshots_update_status ">>> Copying core pkg repo to ${PKG_RSYNC_HOSTNAME}"
|
2220 |
61b63ac0
|
Renato Botelho
|
pkg_repo_rsync "${CORE_PKG_PATH}"
|
2221 |
48396120
|
Renato Botelho
|
snapshots_update_status ">>> Finished copying core pkg repo"
|
2222 |
|
|
|
2223 |
5163c3ca
|
Renato Botelho
|
for _rsyncip in ${RSYNCIP}; do
|
2224 |
|
|
snapshots_update_status ">>> Copying files to ${_rsyncip}"
|
2225 |
ab943fc9
|
Renato Botelho
|
|
2226 |
5163c3ca
|
Renato Botelho
|
# Ensure directory(s) are available
|
2227 |
547d0883
|
Renato Botelho do Couto
|
ssh -o StrictHostKeyChecking=no ${RSYNCUSER}@${_rsyncip} "mkdir -p ${RSYNCPATH}/installer"
|
2228 |
5163c3ca
|
Renato Botelho
|
if [ -d $IMAGES_FINAL_DIR/virtualization ]; then
|
2229 |
547d0883
|
Renato Botelho do Couto
|
ssh -o StrictHostKeyChecking=no ${RSYNCUSER}@${_rsyncip} "mkdir -p ${RSYNCPATH}/virtualization"
|
2230 |
5163c3ca
|
Renato Botelho
|
fi
|
2231 |
|
|
# ensure permissions are correct for r+w
|
2232 |
547d0883
|
Renato Botelho do Couto
|
ssh -o StrictHostKeyChecking=no ${RSYNCUSER}@${_rsyncip} "chmod -R ug+rw ${RSYNCPATH}/."
|
2233 |
5163c3ca
|
Renato Botelho
|
rsync $RSYNC_COPY_ARGUMENTS $IMAGES_FINAL_DIR/installer/* \
|
2234 |
|
|
${RSYNCUSER}@${_rsyncip}:${RSYNCPATH}/installer/
|
2235 |
|
|
if [ -d $IMAGES_FINAL_DIR/virtualization ]; then
|
2236 |
|
|
rsync $RSYNC_COPY_ARGUMENTS $IMAGES_FINAL_DIR/virtualization/* \
|
2237 |
|
|
${RSYNCUSER}@${_rsyncip}:${RSYNCPATH}/virtualization/
|
2238 |
|
|
fi
|
2239 |
ab943fc9
|
Renato Botelho
|
|
2240 |
5163c3ca
|
Renato Botelho
|
snapshots_update_status ">>> Finished copying files."
|
2241 |
|
|
done
|
2242 |
ab943fc9
|
Renato Botelho
|
}
|