1 |
8f3dccb6
|
Scott Ullrich
|
#!/bin/sh
|
2 |
958ff0e9
|
Dario Freni
|
#
|
3 |
67c08ef2
|
Scott Ullrich
|
# builder_common.sh
|
4 |
63e553e1
|
Scott Ullrich
|
# Copyright (C) 2004-2011 Scott Ullrich
|
5 |
4023cddf
|
Ermal
|
# Copyright (C) 2014 Ermal Luçi
|
6 |
67c08ef2
|
Scott Ullrich
|
# All rights reserved.
|
7 |
a8f92d06
|
Scott Ullrich
|
#
|
8 |
fc5134b2
|
Scott Ullrich
|
# NanoBSD portions of the code
|
9 |
|
|
# Copyright (c) 2005 Poul-Henning Kamp.
|
10 |
|
|
# and copied from nanobsd.sh
|
11 |
|
|
# All rights reserved.
|
12 |
a8f92d06
|
Scott Ullrich
|
#
|
13 |
fc5134b2
|
Scott Ullrich
|
# FreeSBIE portions of the code
|
14 |
|
|
# Copyright (c) 2005 Dario Freni
|
15 |
|
|
# and copied from FreeSBIE project
|
16 |
|
|
# All rights reserved.
|
17 |
67c08ef2
|
Scott Ullrich
|
#
|
18 |
|
|
# Redistribution and use in source and binary forms, with or without
|
19 |
|
|
# modification, are permitted provided that the following conditions are met:
|
20 |
|
|
#
|
21 |
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
22 |
|
|
# this list of conditions and the following disclaimer.
|
23 |
|
|
#
|
24 |
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
25 |
|
|
# notice, this list of conditions and the following disclaimer in the
|
26 |
|
|
# documentation and/or other materials provided with the distribution.
|
27 |
|
|
#
|
28 |
|
|
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
29 |
|
|
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
30 |
|
|
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
31 |
|
|
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
32 |
|
|
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
33 |
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
34 |
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
35 |
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
36 |
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
37 |
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
38 |
|
|
#
|
39 |
20ab9ac3
|
Scott Ullrich
|
# This is the brains of the builder and is included
|
40 |
|
|
# by the various pfSense builder scripts such as
|
41 |
|
|
# build_iso.sh and build_nano.sh, etc.
|
42 |
|
|
#
|
43 |
4615affa
|
Scott Ullrich
|
# Crank up error reporting, debugging.
|
44 |
0941bfbd
|
Scott Ullrich
|
# set -e
|
45 |
|
|
# set -x
|
46 |
4615affa
|
Scott Ullrich
|
|
47 |
28c1f5d7
|
Ermal
|
if [ "$MAKEOBJDIRPREFIXFINAL" != "" ]; then
|
48 |
15b89299
|
Scott Ullrich
|
mkdir -p $MAKEOBJDIRPREFIXFINAL
|
49 |
|
|
else
|
50 |
|
|
echo "MAKEOBJDIRPREFIXFINAL is not defined"
|
51 |
|
|
print_error_pfS
|
52 |
|
|
fi
|
53 |
|
|
|
54 |
aa0bbaae
|
Scott Ullrich
|
# This routine will post a tweet to twitter
|
55 |
3a79c6b5
|
Scott Ullrich
|
post_tweet() {
|
56 |
68d79e27
|
Scott Ullrich
|
TWEET_MESSAGE="$1"
|
57 |
|
|
if [ "$TWITTER_USERNAME" ="" ]; then
|
58 |
|
|
echo ">>> ERROR: Could not find TWITTER_USERNAME -- tweet cancelled."
|
59 |
3a79c6b5
|
Scott Ullrich
|
return
|
60 |
|
|
fi
|
61 |
68d79e27
|
Scott Ullrich
|
if [ "$TWITTER_PASSWORD" = "" ]; then
|
62 |
|
|
echo ">>> ERROR: Could not find TWITTER_PASSWORD -- tweet cancelled."
|
63 |
3a79c6b5
|
Scott Ullrich
|
return
|
64 |
|
|
fi
|
65 |
98b1c984
|
Renato Botelho
|
if [ ! -f "/usr/local/bin/curl" ]; then
|
66 |
68d79e27
|
Scott Ullrich
|
echo ">>> ERROR: Could not find /usr/local/bin/curl -- tweet cancelled."
|
67 |
3a79c6b5
|
Scott Ullrich
|
return
|
68 |
|
|
fi
|
69 |
0704e26f
|
Scott Ullrich
|
echo -n ">>> Posting tweet to twitter: $TWEET_MESSAGE"
|
70 |
29042937
|
Scott Ullrich
|
`/usr/local/bin/curl --silent --basic --user "$TWITTER_USERNAME:$TWITTER_PASSWORD" --data status="$TWEET_MESSAGE" http://twitter.com/statuses/update.xml`
|
71 |
0704e26f
|
Scott Ullrich
|
echo "Done!"
|
72 |
3a79c6b5
|
Scott Ullrich
|
}
|
73 |
|
|
|
74 |
c93dc90c
|
Ermal
|
get_date_string() {
|
75 |
69ba7f52
|
Ermal
|
# This is used for detecting updates.
|
76 |
|
|
echo "$BUILTDATESTRING" > $PFSENSEISODIR/etc/version.buildtime
|
77 |
c93dc90c
|
Ermal
|
}
|
78 |
|
|
|
79 |
0b716c06
|
Ermal
|
git_last_commit() {
|
80 |
|
|
if [ -d "${GIT_REPO_DIR}/pfSenseGITREPO" ]; then
|
81 |
c735bb3e
|
Ermal
|
CURRENT_COMMIT=$(cd ${GIT_REPO_DIR}/pfSenseGITREPO && git log | head -n1 | cut -d' ' -f2)
|
82 |
8242b11d
|
Ermal
|
CURRENT_AUTHOR=$(cd ${GIT_REPO_DIR}/pfSenseGITREPO && git log | head -n3 | grep "Author" | cut -d':' -f2 | cut -d'<' -f1)
|
83 |
510f69fa
|
Ermal
|
echo ">>> Last known commit $CURRENT_AUTHOR - $CURRENT_COMMIT"
|
84 |
|
|
echo "$CURRENT_COMMIT" > $SCRATCHDIR/build_commit_info.txt
|
85 |
0b716c06
|
Ermal
|
else
|
86 |
|
|
echo ">>> WARNING: pfSenseGITREPO variable not set! Previous commit functions disabled."
|
87 |
|
|
fi
|
88 |
|
|
}
|
89 |
|
|
|
90 |
886246c1
|
Ermal
|
# This routine handles the athstats directory since it lives in
|
91 |
|
|
# SRCDIR/tools/tools/ath/athstats and changes from various freebsd
|
92 |
|
|
# versions which makes adding this to pfPorts difficult.
|
93 |
|
|
handle_tools_stats_crypto() {
|
94 |
a467bb85
|
Ermal
|
if [ -d $SRCDIR/tools/tools/crypto ]; then
|
95 |
|
|
echo -n ">>> Building tools/crytpo..."
|
96 |
|
|
(cd $SRCDIR/tools/tools/crypto && make clean && make cleandir && env SRCCONF=${SRC_CONF} make && env SRCCONF=${SRC_CONF} make install) 2>&1 | egrep -wi '(^>>>|error)'
|
97 |
|
|
echo "Done!"
|
98 |
|
|
fi
|
99 |
886246c1
|
Ermal
|
|
100 |
|
|
}
|
101 |
|
|
|
102 |
aa0bbaae
|
Scott Ullrich
|
# This routine will output that something went wrong
|
103 |
14757a57
|
Scott Ullrich
|
print_error_pfS() {
|
104 |
c8dbc3c5
|
Scott Ullrich
|
echo
|
105 |
|
|
echo "####################################"
|
106 |
6a3445a3
|
Seth Mos
|
echo "Something went wrong, check errors!" >&2
|
107 |
c8dbc3c5
|
Scott Ullrich
|
echo "####################################"
|
108 |
|
|
echo
|
109 |
8326a7c1
|
Ermal
|
echo "NOTE: a lot of times you can run './build.sh --clean-builder' to resolve."
|
110 |
96f5498d
|
Scott Ullrich
|
echo
|
111 |
cae6477a
|
Scott Ullrich
|
if [ "$1" != "" ]; then
|
112 |
|
|
echo $1
|
113 |
|
|
fi
|
114 |
14757a57
|
Scott Ullrich
|
[ -n "${LOGFILE:-}" ] && \
|
115 |
25ddd34d
|
Seth Mos
|
echo "Log saved on ${LOGFILE}" && \
|
116 |
cc9f6cf9
|
Scott Ullrich
|
tail -n20 ${LOGFILE} >&2
|
117 |
1877d415
|
Scott Ullrich
|
report_error_pfsense
|
118 |
b6c757d1
|
Scott Ullrich
|
echo
|
119 |
aa0bbaae
|
Scott Ullrich
|
echo "Press enter to continue."
|
120 |
|
|
read ans
|
121 |
8f3dccb6
|
Scott Ullrich
|
kill $$
|
122 |
14757a57
|
Scott Ullrich
|
}
|
123 |
|
|
|
124 |
d13406a5
|
Ermal
|
prestage_on_ram_setup() {
|
125 |
|
|
_AVAIL_MEM=$(($(sysctl -n hw.usermem) / 1024 / 1024))
|
126 |
|
|
if [ $_AVAIL_MEM -lt 1400 ]; then
|
127 |
|
|
echo ">>> Builder has less than 1.4GiB RAM skipping memory disks"
|
128 |
|
|
return
|
129 |
|
|
else
|
130 |
|
|
echo "######################################################################################"
|
131 |
|
|
echo
|
132 |
|
|
echo ">>> Builder has more than 1.4GiB RAM enabling memory disks"
|
133 |
385877a8
|
Renato Botelho
|
echo ">>> WARNING: Remember to remove these memory disks by running $0 --disable-memorydisks"
|
134 |
d13406a5
|
Ermal
|
echo
|
135 |
|
|
echo "######################################################################################"
|
136 |
|
|
fi
|
137 |
|
|
|
138 |
|
|
MOUNT_PRESTAGE=$(mount | grep prestagebacking | grep -v grep | wc -l)
|
139 |
|
|
if [ $MOUNT_PRESTAGE -eq 0 ]; then
|
140 |
b3bdfdbf
|
Ermal
|
mdconfig -a -t swap -u 10001 -s ${MEMORYDISK_SIZE}
|
141 |
d13406a5
|
Ermal
|
mkdir -p ${PFSENSESTAGEDIR}
|
142 |
19fd6b31
|
Renato Botelho
|
newfs -L prestagebacking -U /dev/md10001
|
143 |
d13406a5
|
Ermal
|
mount /dev/ufs/prestagebacking ${PFSENSESTAGEDIR}
|
144 |
|
|
else
|
145 |
385877a8
|
Renato Botelho
|
echo ">>> Detected preexisting memory disk enabled for ${PFSENSESTAGEDIR}."
|
146 |
d13406a5
|
Ermal
|
fi
|
147 |
|
|
|
148 |
|
|
MOUNT_STAGE=$(mount | grep finalstagebacking | grep -v grep | wc -l)
|
149 |
|
|
if [ $MOUNT_STAGE -eq 0 ]; then
|
150 |
b3bdfdbf
|
Ermal
|
mdconfig -a -t swap -u 10002 -s ${MEMORYDISK_SIZE}
|
151 |
d13406a5
|
Ermal
|
mkdir -p ${PFSENSEISODIR}
|
152 |
19fd6b31
|
Renato Botelho
|
newfs -L finalstagebacking -U /dev/md10002
|
153 |
d13406a5
|
Ermal
|
mount /dev/ufs/finalstagebacking ${PFSENSEISODIR}
|
154 |
|
|
else
|
155 |
385877a8
|
Renato Botelho
|
echo ">>> Detected preexisting memory disk enabled for ${PFSENSEISODIR}."
|
156 |
d13406a5
|
Ermal
|
fi
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
unset MOUNT_PRESTAGE
|
160 |
|
|
unset MOUNT_STAGE
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
prestage_on_ram_cleanup() {
|
164 |
313e8bdc
|
Ermal
|
if [ -c /dev/md10001 ]; then
|
165 |
d13406a5
|
Ermal
|
if [ -d ${PFSENSESTAGEDIR} ]; then
|
166 |
|
|
umount ${PFSENSESTAGEDIR}
|
167 |
|
|
fi
|
168 |
313e8bdc
|
Ermal
|
mdconfig -d -u 10001
|
169 |
d13406a5
|
Ermal
|
fi
|
170 |
313e8bdc
|
Ermal
|
if [ -c /dev/md10002 ]; then
|
171 |
d13406a5
|
Ermal
|
if [ -d ${PFSENSEISODIR} ]; then
|
172 |
|
|
umount ${PFSENSEISODIR}
|
173 |
|
|
fi
|
174 |
313e8bdc
|
Ermal
|
mdconfig -d -u 10002
|
175 |
d13406a5
|
Ermal
|
fi
|
176 |
|
|
}
|
177 |
|
|
|
178 |
aa0bbaae
|
Scott Ullrich
|
# This routine will verify that the kernel has been
|
179 |
|
|
# installed OK to the staging area.
|
180 |
b1198c09
|
Scott Ullrich
|
ensure_kernel_exists() {
|
181 |
|
|
if [ ! -f "$1/boot/kernel/kernel.gz" ]; then
|
182 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Could not locate $1/boot/kernel.gz"
|
183 |
b1198c09
|
Scott Ullrich
|
print_error_pfS
|
184 |
cc9f6cf9
|
Scott Ullrich
|
kill $$
|
185 |
b1198c09
|
Scott Ullrich
|
fi
|
186 |
|
|
KERNEL_SIZE=`ls -la $1/boot/kernel/kernel.gz | awk '{ print $5 }'`
|
187 |
|
|
if [ "$KERNEL_SIZE" -lt 3500 ]; then
|
188 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Kernel $1/boot/kernel.gz appears to be smaller than it should be: $KERNEL_SIZE"
|
189 |
b1198c09
|
Scott Ullrich
|
print_error_pfS
|
190 |
cc9f6cf9
|
Scott Ullrich
|
kill $$
|
191 |
b1198c09
|
Scott Ullrich
|
fi
|
192 |
|
|
}
|
193 |
|
|
|
194 |
0390491c
|
Ermal Luçi
|
fixup_kernel_options() {
|
195 |
403cc07d
|
Ermal
|
if [ -d "$KERNEL_DESTDIR/boot" ]; then
|
196 |
23f2b219
|
Ermal
|
chflags -R noschg $KERNEL_DESTDIR/boot/
|
197 |
403cc07d
|
Ermal
|
rm -rf $KERNEL_DESTDIR/boot/*
|
198 |
|
|
fi
|
199 |
b1928bb4
|
Scott Ullrich
|
|
200 |
57ade0c9
|
Scott Ullrich
|
# Create area where kernels will be copied on LiveCD
|
201 |
859b069b
|
Ermal
|
mkdir -p $PFSENSESTAGEDIR/kernels/
|
202 |
403cc07d
|
Ermal
|
# Make sure directories exist
|
203 |
535f23a8
|
Ermal
|
mkdir -p $KERNEL_DESTDIR/boot/kernel
|
204 |
|
|
mkdir -p $KERNEL_DESTDIR/boot/defaults
|
205 |
b1928bb4
|
Scott Ullrich
|
|
206 |
98b1c984
|
Renato Botelho
|
if [ "$TARGET_ARCH" = "" ]; then
|
207 |
9f2a340a
|
Ermal
|
TARGET_ARCH=$TARGET
|
208 |
109e0766
|
Ermal
|
fi
|
209 |
02b5627b
|
Scott Ullrich
|
|
210 |
c9d3cd97
|
Ermal
|
# Add APIC options for i386 platform
|
211 |
9f2a340a
|
Ermal
|
if [ "$TARGET" = "i386" ]; then
|
212 |
c9d3cd97
|
Ermal
|
echo "device apic" >> $KERNELCONF
|
213 |
|
|
fi
|
214 |
|
|
|
215 |
6c73df3e
|
Ermal
|
if [ "$EXTRA_DEVICES" != "" ]; then
|
216 |
535f23a8
|
Ermal
|
echo "devices $EXTRA_DEVICES" >> $KERNELCONF
|
217 |
|
|
fi
|
218 |
6c73df3e
|
Ermal
|
if [ "$NOEXTRA_DEVICES" != "" ]; then
|
219 |
|
|
echo "nodevices $NOEXTRA_DEVICES" >> $KERNELCONF
|
220 |
535f23a8
|
Ermal
|
fi
|
221 |
6c73df3e
|
Ermal
|
if [ "$EXTRA_OPTIONS" != "" ]; then
|
222 |
535f23a8
|
Ermal
|
echo "options $EXTRA_OPTIONS" >> $KERNELCONF
|
223 |
|
|
fi
|
224 |
6c73df3e
|
Ermal
|
if [ "$NOEXTRA_OPTIONS" != "" ]; then
|
225 |
535f23a8
|
Ermal
|
echo "nooptions $NOEXTRA_OPTIONS" >> $KERNELCONF
|
226 |
53ee1f53
|
Scott Ullrich
|
fi
|
227 |
109e0766
|
Ermal
|
|
228 |
673c2707
|
Scott Ullrich
|
# NOTE! If you remove this, you WILL break booting! These file(s) are read
|
229 |
57ade0c9
|
Scott Ullrich
|
# by FORTH and for some reason installkernel with DESTDIR does not
|
230 |
673c2707
|
Scott Ullrich
|
# copy this file over and you will end up with a blank file?
|
231 |
535f23a8
|
Ermal
|
cp $SRCDIR/sys/boot/forth/loader.conf $KERNEL_DESTDIR/boot/defaults
|
232 |
9f2a340a
|
Ermal
|
if [ -f $SRCDIR/sys/$TARGET/conf/GENERIC.hints ]; then
|
233 |
|
|
cp $SRCDIR/sys/$TARGET/conf/GENERIC.hints $KERNEL_DESTDIR/boot/device.hints
|
234 |
2955aece
|
Scott Ullrich
|
fi
|
235 |
9f2a340a
|
Ermal
|
if [ -f $SRCDIR/sys/$TARGET/conf/$KERNCONF.hints ]; then
|
236 |
|
|
cp $SRCDIR/sys/$TARGET/conf/$KERNCONF.hints $KERNEL_DESTDIR/boot/device.hints
|
237 |
43ffea22
|
Scott Ullrich
|
fi
|
238 |
673c2707
|
Scott Ullrich
|
# END NOTE.
|
239 |
57ade0c9
|
Scott Ullrich
|
|
240 |
523c7e06
|
Scott Ullrich
|
# Danger will robinson -- 7.2+ will NOT boot if these files are not present.
|
241 |
|
|
# the loader will stop at |
|
242 |
535f23a8
|
Ermal
|
touch $KERNEL_DESTDIR/boot/loader.conf
|
243 |
98b1c984
|
Renato Botelho
|
|
244 |
5c9da6be
|
Scott Ullrich
|
}
|
245 |
28afcca9
|
Scott Ullrich
|
|
246 |
98b1c984
|
Renato Botelho
|
# This routine builds all pfSense related kernels
|
247 |
5c9da6be
|
Scott Ullrich
|
build_all_kernels() {
|
248 |
726b87dd
|
Scott Ullrich
|
|
249 |
9c88f59f
|
Ermal
|
# Set KERNEL_BUILD_PATH if it has not been set
|
250 |
|
|
if [ -z "${KERNEL_BUILD_PATH}" ]; then
|
251 |
|
|
KERNEL_BUILD_PATH=$SCRATCHDIR/kernels
|
252 |
|
|
echo ">>> KERNEL_BUILD_PATH has not been set. Setting to ${KERNEL_BUILD_PATH}!"
|
253 |
|
|
fi
|
254 |
|
|
|
255 |
1f5a4fda
|
Scott Ullrich
|
# Build embedded kernel
|
256 |
2f481b4b
|
Ermal
|
for BUILD_KERNEL in $BUILD_KERNELS; do
|
257 |
c750b40c
|
Ermal
|
unset KERNCONF
|
258 |
|
|
unset KERNEL_DESTDIR
|
259 |
|
|
unset KERNELCONF
|
260 |
33da87d4
|
Renato Botelho
|
unset KERNEL_NAME
|
261 |
c750b40c
|
Ermal
|
export KERNCONF=$BUILD_KERNEL
|
262 |
|
|
export KERNEL_DESTDIR="$KERNEL_BUILD_PATH/$BUILD_KERNEL"
|
263 |
60befe96
|
Ermal
|
export KERNELCONF="$SRCDIR/sys/${TARGET}/conf/$BUILD_KERNEL"
|
264 |
c750b40c
|
Ermal
|
|
265 |
9f2a340a
|
Ermal
|
LOGFILE="${BUILDER_LOGS}/kernel.${KERNCONF}.${TARGET}.log"
|
266 |
bd76a364
|
Ermal
|
echo ">>> Building $BUILD_KERNEL kernel." | tee -a ${LOGFILE}
|
267 |
c949003f
|
Ermal
|
|
268 |
d4a5c43c
|
Ermal
|
# Copy pfSense kernel configuration files over to $SRCDIR/sys/$TARGET/conf
|
269 |
|
|
cp $BUILDER_TOOLS/builder_scripts/conf/kernel/$KERNCONF $KERNELCONF
|
270 |
|
|
if [ ! -f "$KERNELCONF" ]; then
|
271 |
|
|
echo ">>> ERROR: Could not find $KERNELCONF"
|
272 |
|
|
print_error_pfS
|
273 |
|
|
fi
|
274 |
|
|
echo "" >> $KERNELCONF
|
275 |
|
|
|
276 |
9d04fe98
|
Ermal
|
# Use kernel INSTALL_NAME if it exists
|
277 |
d4a5c43c
|
Ermal
|
KERNEL_INSTALL_NAME=$(cat $BUILDER_TOOLS/builder_scripts/conf/kernel/$KERNCONF | /usr/bin/sed -e '/INSTALL_NAME/!d; s/^.*INSTALL_NAME[[:blank:]]*//' \
|
278 |
9d04fe98
|
Ermal
|
| /usr/bin/head -n 1)
|
279 |
|
|
|
280 |
|
|
if [ -z "${KERNEL_INSTALL_NAME}" ]; then
|
281 |
|
|
export KERNEL_NAME=$(echo ${BUILD_KERNEL} | sed -e 's/pfSense_//; s/\.[0-9].*$//')
|
282 |
|
|
else
|
283 |
|
|
export KERNEL_NAME=${KERNEL_INSTALL_NAME}
|
284 |
8c4d5de5
|
Ermal
|
unset KERNEL_INSTALL_NAME
|
285 |
9d04fe98
|
Ermal
|
fi
|
286 |
|
|
|
287 |
|
|
if [ -n "${NO_BUILDKERNEL:-}" -a -f $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz ]; then
|
288 |
|
|
echo ">>> NO_BUILDKERNEL set, skipping build" | tee -a ${LOGFILE}
|
289 |
|
|
continue
|
290 |
|
|
fi
|
291 |
|
|
|
292 |
c750b40c
|
Ermal
|
# Common fixup code
|
293 |
|
|
fixup_kernel_options
|
294 |
c5643146
|
Ermal
|
export SRC_CONF=${SRC_CONF}
|
295 |
|
|
buildkernel
|
296 |
ac8aac3e
|
Ermal
|
|
297 |
c5643146
|
Ermal
|
OSRC_CONF=${SRC_CONF}
|
298 |
ac8aac3e
|
Ermal
|
if [ -n "${SRC_CONF_INSTALL:-}" ]; then
|
299 |
|
|
export SRC_CONF=$SRC_CONF_INSTALL
|
300 |
|
|
fi
|
301 |
|
|
|
302 |
adbddb0e
|
Ermal
|
echo ">>> Staging $BUILD_KERNEL kernel..." | tee -a ${LOGFILE}
|
303 |
c5643146
|
Ermal
|
installkernel
|
304 |
|
|
|
305 |
|
|
SRC_CONF=${OSRC_CONF}
|
306 |
|
|
|
307 |
c750b40c
|
Ermal
|
ensure_kernel_exists $KERNEL_DESTDIR
|
308 |
|
|
|
309 |
adbddb0e
|
Ermal
|
echo -n ">>> Creating archive of $KERNEL_NAME kernel to staging area..." | tee -a ${LOGFILE}
|
310 |
9c88f59f
|
Ermal
|
chflags -R noschg $KERNEL_DESTDIR/boot/ 2>&1 >/dev/null
|
311 |
adbddb0e
|
Ermal
|
mkdir -p $KERNEL_BUILD_PATH/kernels
|
312 |
|
|
(cd $KERNEL_DESTDIR/boot/ && tar czf $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz .)
|
313 |
|
|
rm -rf $KERNEL_DESTDIR 2>&1 1>/dev/null
|
314 |
5f131906
|
Ermal
|
|
315 |
adbddb0e
|
Ermal
|
echo ".Done" | tee -a ${LOGFILE}
|
316 |
c750b40c
|
Ermal
|
done
|
317 |
adbddb0e
|
Ermal
|
}
|
318 |
9fa1c18f
|
Ermal
|
|
319 |
adbddb0e
|
Ermal
|
install_default_kernel() {
|
320 |
|
|
if [ -z "${1}" ]; then
|
321 |
|
|
echo ">>> ERROR: install_default_kernel called without a kernel config name"| tee -a ${LOGFILE}
|
322 |
9fa1c18f
|
Ermal
|
print_error_pfS
|
323 |
|
|
fi
|
324 |
adbddb0e
|
Ermal
|
|
325 |
|
|
# Use kernel INSTALL_NAME if it exists
|
326 |
d4a5c43c
|
Ermal
|
if [ -f $BUILDER_TOOLS/builder_scripts/conf/kernel/${1} ]; then
|
327 |
e923bf13
|
Ermal
|
KERNEL_INSTALL_NAME=$(cat $BUILDER_TOOLS/builder_scripts/conf/kernel/${1} \
|
328 |
d4a5c43c
|
Ermal
|
| /usr/bin/sed -e '/INSTALL_NAME/!d; s/^.*INSTALL_NAME[[:blank:]]*//' \
|
329 |
|
|
| /usr/bin/head -n 1)
|
330 |
|
|
fi
|
331 |
adbddb0e
|
Ermal
|
|
332 |
|
|
if [ -z "${KERNEL_INSTALL_NAME}" ]; then
|
333 |
8c67da63
|
Ermal
|
export KERNEL_NAME=$(echo ${1} | sed -e 's/pfSense_//; s/\.[0-9].*$//')
|
334 |
adbddb0e
|
Ermal
|
else
|
335 |
|
|
export KERNEL_NAME=${KERNEL_INSTALL_NAME}
|
336 |
8c4d5de5
|
Ermal
|
unset KERNEL_INSTALL_NAME
|
337 |
adbddb0e
|
Ermal
|
fi
|
338 |
|
|
|
339 |
|
|
echo -n ">>> Installing kernel to be used by image ${KERNEL_NAME}..." | tee -a ${LOGFILE}
|
340 |
|
|
# If something is missing complain
|
341 |
|
|
if [ ! -f $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz ]; then
|
342 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: The kernel archive($PFSENSESTAGEDIR/kernels/kernel_${KERNEL_NAME}.gz) to install as default does not exist" | tee -a ${LOGFILE}
|
343 |
adbddb0e
|
Ermal
|
print_error_pfS
|
344 |
|
|
fi
|
345 |
|
|
|
346 |
|
|
# Just to make sure
|
347 |
|
|
mkdir -p $PFSENSEISODIR/boot
|
348 |
|
|
(cd $PFSENSEISODIR/boot/ && tar xzf $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz -C $PFSENSEISODIR/boot/)
|
349 |
|
|
|
350 |
|
|
if [ ! -f $PFSENSEISODIR/boot/kernel/kernel.gz ]; then
|
351 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: No kernel installed on $PFSENSEISODIR and the resulting image will be unusable. STOPPING!" | tee -a ${LOGFILE}
|
352 |
adbddb0e
|
Ermal
|
print_error_pfS
|
353 |
|
|
fi
|
354 |
082f5eb7
|
Ermal
|
mkdir -p $PFSENSEISODIR/kernels
|
355 |
bd40be69
|
Ermal
|
if [ -z "${2}" -o -n "${INSTALL_EXTRA_KERNELS}" ]; then
|
356 |
180165d3
|
Ermal
|
cp $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz $PFSENSEISODIR/kernels
|
357 |
6d28482f
|
Ermal
|
if [ -n "${INSTALL_EXTRA_KERNELS}" ]; then
|
358 |
|
|
for _EXTRA_KERNEL in $INSTALL_EXTRA_KERNELS; do
|
359 |
|
|
KERNEL_NAME=$(echo ${_EXTRA_KERNEL} | sed -e 's/pfSense_//; s/\.[0-9].*$//')
|
360 |
|
|
if [ -f "${KERNEL_BUILD_PATH}/kernels/kernel_${KERNEL_NAME}.gz" ]; then
|
361 |
5fa0cebb
|
Ermal
|
echo -n ". adding kernel_${KERNEL_NAME}.gz on image /kernels folder"
|
362 |
6d28482f
|
Ermal
|
cp $KERNEL_BUILD_PATH/kernels/kernel_${KERNEL_NAME}.gz $PFSENSEISODIR/kernels
|
363 |
|
|
else
|
364 |
|
|
echo ">>> ERROR: Requested kernel kernel_${KERNEL_NAME}.gz was not found to be put on image /kernels folder!"
|
365 |
|
|
print_error_pfS
|
366 |
|
|
fi
|
367 |
|
|
done
|
368 |
|
|
fi
|
369 |
180165d3
|
Ermal
|
fi
|
370 |
adbddb0e
|
Ermal
|
echo "Done." | tee -a ${LOGFILE}
|
371 |
|
|
|
372 |
|
|
unset KERNEL_NAME
|
373 |
9d505798
|
Scott Ullrich
|
}
|
374 |
|
|
|
375 |
aa0bbaae
|
Scott Ullrich
|
# This routine rebuilds all pfPorts files which are generally
|
376 |
|
|
# in /home/pfsense/tools/pfPorts/
|
377 |
d73e0f2b
|
Scott Ullrich
|
recompile_pfPorts() {
|
378 |
770270b3
|
Scott Ullrich
|
|
379 |
57f8d55d
|
Scott Ullrich
|
if [ ! -d /usr/ports/ ]; then
|
380 |
4369d2c2
|
Scott Ullrich
|
echo "==> Please wait, grabbing port files from FreeBSD.org..."
|
381 |
57f8d55d
|
Scott Ullrich
|
portsnap fetch
|
382 |
4369d2c2
|
Scott Ullrich
|
echo "==> Please wait, extracting port files..."
|
383 |
57f8d55d
|
Scott Ullrich
|
portsnap extract
|
384 |
|
|
fi
|
385 |
|
|
|
386 |
b5b7f3ef
|
Ermal
|
if [ ! -f $SCRATCHDIR/pfSense_do_not_build_pfPorts ] || [ "$1" != "" ]; then
|
387 |
59d65b10
|
Scott Ullrich
|
|
388 |
981e708a
|
Scott Ullrich
|
# Set some neede variables
|
389 |
25cf7ed0
|
Renato Botelho
|
PFPORTS_CONF_DIR="${BUILDER_TOOLS}/builder_scripts/conf/pfPorts"
|
390 |
59d65b10
|
Scott Ullrich
|
if [ -n "$PFSPORTSFILE" ]; then
|
391 |
25cf7ed0
|
Renato Botelho
|
USE_PORTS_FILE="${PFPORTS_CONF_DIR}/${PFSPORTSFILE}"
|
392 |
98b1c984
|
Renato Botelho
|
else
|
393 |
25cf7ed0
|
Renato Botelho
|
USE_PORTS_FILE="${PFPORTS_CONF_DIR}/buildports.${PFSENSETAG}"
|
394 |
59d65b10
|
Scott Ullrich
|
fi
|
395 |
edbdf710
|
Renato Botelho
|
|
396 |
|
|
if [ ! -f "${USE_PORTS_FILE}" ]; then
|
397 |
|
|
echo ">>> ERROR: Ports file doesn't exist: '${USE_PORTS_FILE}'"
|
398 |
|
|
exit 1
|
399 |
|
|
fi
|
400 |
|
|
|
401 |
8c67da63
|
Ermal
|
PFPORTSBASENAME=$(basename ${USE_PORTS_FILE})
|
402 |
98b1c984
|
Renato Botelho
|
|
403 |
4369d2c2
|
Scott Ullrich
|
echo "--> Preparing for pfPorts build ${PFPORTSBASENAME}"
|
404 |
e6c459c7
|
jim-p
|
if [ "$1" = "" ]; then
|
405 |
859b069b
|
Ermal
|
update_freebsd_sources_and_apply_patches
|
406 |
|
|
|
407 |
e6c459c7
|
jim-p
|
# Warn user about make includes operation
|
408 |
|
|
echo "--> WARNING! We are about to run make includes."
|
409 |
|
|
echo -n "--> Press CTRl-C to abort this operation"
|
410 |
|
|
echo -n "."
|
411 |
|
|
sleep 1
|
412 |
|
|
echo -n "."
|
413 |
|
|
sleep 1
|
414 |
|
|
echo -n "."
|
415 |
|
|
sleep 1
|
416 |
|
|
echo -n "."
|
417 |
|
|
sleep 1
|
418 |
|
|
echo "."
|
419 |
|
|
sleep 1
|
420 |
|
|
|
421 |
523cbacb
|
Ermal
|
# Since we are using NAT-T and custom patches
|
422 |
|
|
# to the build this is needed.
|
423 |
|
|
# The other option is to create build env for ports and
|
424 |
|
|
# not pollute the host
|
425 |
e6c459c7
|
jim-p
|
echo "==> Starting make includes operation..."
|
426 |
a467bb85
|
Ermal
|
( cd $SRCDIR && env SRCCONF=${SRC_CONF} make includes ) | egrep -wi '(^>>>|error)'
|
427 |
e6c459c7
|
jim-p
|
else
|
428 |
ad5a2ffc
|
jim-p
|
echo "--> Skipping the make includes run for a single port build."
|
429 |
e6c459c7
|
jim-p
|
fi
|
430 |
98b1c984
|
Renato Botelho
|
|
431 |
4369d2c2
|
Scott Ullrich
|
echo "==> Compiling pfPorts..."
|
432 |
25cf7ed0
|
Renato Botelho
|
DCPUS=`sysctl kern.smp.cpus | cut -d' ' -f2`
|
433 |
|
|
CPUS=`expr $DCPUS '*' 2`
|
434 |
b5b7f3ef
|
Ermal
|
echo SUBTHREADS="${CPUS}" > $SCRATCHDIR/pfPorts_make.conf
|
435 |
9f2a340a
|
Ermal
|
if [ "$TARGET" = "mips" ]; then
|
436 |
b5b7f3ef
|
Ermal
|
echo "WITHOUT_PERL_MALLOC=1" >> $SCRATCHDIR/pfPorts_make.conf
|
437 |
|
|
echo "TARGET_BIG_ENDIAN=yes" >> $SCRATCHDIR/pfPorts_make.conf
|
438 |
25cf7ed0
|
Renato Botelho
|
fi
|
439 |
|
|
if [ -f "${PFPORTS_CONF_DIR}/make.conf" ]; then
|
440 |
b5b7f3ef
|
Ermal
|
cat ${PFPORTS_CONF_DIR}/make.conf >> $SCRATCHDIR/pfPorts_make.conf
|
441 |
b11e3e0f
|
Scott Ullrich
|
fi
|
442 |
25cf7ed0
|
Renato Botelho
|
|
443 |
60c45702
|
Scott Ullrich
|
export FORCE_PKG_REGISTER=yo
|
444 |
d897edad
|
Ermal
|
export BATCH=yo
|
445 |
b7a5f7a8
|
jim-p
|
export DISABLE_VULNERABILITIES=yo
|
446 |
e753b988
|
Scott Ullrich
|
|
447 |
784675b1
|
Scott Ullrich
|
echo ">>> Executing $PFPORTSBASENAME"
|
448 |
9b4abac6
|
jim-p
|
|
449 |
|
|
if [ "$1" != "" ]; then
|
450 |
edbdf710
|
Renato Botelho
|
( ${BUILDER_TOOLS}/builder_scripts/scripts/buildports.sh \
|
451 |
|
|
-l ${USE_PORTS_FILE} -P ${1} -J "${MAKEJ_PORTS}" \
|
452 |
b5b7f3ef
|
Ermal
|
-m $SCRATCHDIR/pfPorts_make.conf ${CHECK_PORTS_INSTALLED} ) 2>&1
|
453 |
bd1f5a42
|
jim-p
|
else
|
454 |
edbdf710
|
Renato Botelho
|
( ${BUILDER_TOOLS}/builder_scripts/scripts/buildports.sh \
|
455 |
|
|
-l ${USE_PORTS_FILE} -J "${MAKEJ_PORTS}" \
|
456 |
b5b7f3ef
|
Ermal
|
-m $SCRATCHDIR/pfPorts_make.conf ${CHECK_PORTS_INSTALLED} ) 2>&1 \
|
457 |
76f35b66
|
Ermal
|
| egrep -wi "(^>>>|error)"
|
458 |
9b4abac6
|
jim-p
|
fi
|
459 |
|
|
|
460 |
886246c1
|
Ermal
|
handle_tools_stats_crypto
|
461 |
|
|
|
462 |
a467bb85
|
Ermal
|
if [ "$1" = "" ]; then
|
463 |
b5b7f3ef
|
Ermal
|
touch $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
464 |
9b4abac6
|
jim-p
|
echo "==> End of pfPorts..."
|
465 |
|
|
fi
|
466 |
98b1c984
|
Renato Botelho
|
|
467 |
60c45702
|
Scott Ullrich
|
else
|
468 |
b5b7f3ef
|
Ermal
|
echo "--> $SCRATCHDIR/pfSense_do_not_build_pfPorts is set, skipping pfPorts build..."
|
469 |
60c45702
|
Scott Ullrich
|
fi
|
470 |
5099714d
|
Scott Ullrich
|
}
|
471 |
76b70bc4
|
Scott Ullrich
|
|
472 |
aa0bbaae
|
Scott Ullrich
|
# This routine overlays needed binaries found in the
|
473 |
|
|
# CUSTOM_COPY_LIST variable. Clog and syslgod are handled
|
474 |
|
|
# specially.
|
475 |
f35786c0
|
Scott Ullrich
|
cust_overlay_host_binaries() {
|
476 |
7373442c
|
Scott Ullrich
|
# Ensure directories exist
|
477 |
6bc6ed54
|
Scott Ullrich
|
# BEGIN required by gather_pfPorts_binaries_in_tgz
|
478 |
859b069b
|
Ermal
|
mkdir -p ${PFSENSESTAGEDIR}/lib/geom
|
479 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/lib/php/20060613/
|
480 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/share/rrdtool/fonts/
|
481 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/share/smartmontools/
|
482 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/lib/lighttpd/
|
483 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/share/man/man8
|
484 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/share/man/man5
|
485 |
6bc6ed54
|
Scott Ullrich
|
# END required by gather_pfPorts_binaries_in_tgz
|
486 |
859b069b
|
Ermal
|
mkdir -p ${PFSENSESTAGEDIR}/bin
|
487 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/sbin
|
488 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/bin
|
489 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/sbin
|
490 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/lib
|
491 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/sbin
|
492 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/libexec
|
493 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/bin
|
494 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/sbin
|
495 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/lib
|
496 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/lib/mysql
|
497 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/usr/local/libexec
|
498 |
adbddb0e
|
Ermal
|
if [ ! -d $PFSENSESTAGEDIR/tank ]; then
|
499 |
|
|
mkdir $PFSENSESTAGEDIR/tank
|
500 |
fb0c8192
|
Scott Ullrich
|
fi
|
501 |
adbddb0e
|
Ermal
|
mkdir -p ${BUILDER_LOGS}/pfPort
|
502 |
fb0c8192
|
Scott Ullrich
|
|
503 |
adbddb0e
|
Ermal
|
# Create a copy of this file just in case
|
504 |
|
|
cp $PFSENSESTAGEDIR/etc/gettytab $PFSENSESTAGEDIR/etc/gettytab.bak
|
505 |
7373442c
|
Scott Ullrich
|
|
506 |
3bcbae5b
|
Scott Ullrich
|
if [ ! -z "${CUSTOM_COPY_LIST:-}" ]; then
|
507 |
784675b1
|
Scott Ullrich
|
echo ">>> Using ${CUSTOM_COPY_LIST:-}..."
|
508 |
3bcbae5b
|
Scott Ullrich
|
FOUND_FILES=`cat ${CUSTOM_COPY_LIST:-}`
|
509 |
|
|
else
|
510 |
784675b1
|
Scott Ullrich
|
echo ">>> Using copy.list.${PFSENSETAG}..."
|
511 |
e12b56e6
|
Ermal
|
FOUND_FILES=`cat conf/copylist/copy.list.${PFSENSETAG}`
|
512 |
3bcbae5b
|
Scott Ullrich
|
fi
|
513 |
|
|
|
514 |
41bff025
|
Ermal
|
if [ -f ${BUILDER_LOGS}/pfPort/copy.list ]; then
|
515 |
|
|
rm ${BUILDER_LOGS}/pfPort/copy.list
|
516 |
|
|
touch ${BUILDER_LOGS}/pfPort/copy.list
|
517 |
5848bab9
|
sullrich
|
else
|
518 |
41bff025
|
Ermal
|
touch ${BUILDER_LOGS}/pfPort/copy.list
|
519 |
5848bab9
|
sullrich
|
fi
|
520 |
|
|
|
521 |
adbddb0e
|
Ermal
|
if [ "${TARGET}" = "${BUILDER_HOST_TARGET}" ]; then
|
522 |
|
|
# XXX: handle syslogd
|
523 |
|
|
if [ ! -f $PFSENSESTAGEDIR/usr/sbin/syslogd ]; then
|
524 |
|
|
echo ">>> Syslogd is missing on staging area copying from host " | tee -a ${LOGFILE}
|
525 |
|
|
install /usr/sbin/syslogd $PFSENSESTAGEDIR/usr/sbin/
|
526 |
|
|
fi
|
527 |
|
|
|
528 |
|
|
# Process base system libraries
|
529 |
|
|
NEEDEDLIBS=""
|
530 |
|
|
echo ">>> Populating newer binaries found on host jail/os (usr/local)..."
|
531 |
|
|
for TEMPFILE in $FOUND_FILES; do
|
532 |
|
|
if [ -f /${TEMPFILE} ]; then
|
533 |
|
|
FILETYPE=`file /$TEMPFILE | egrep "(dynamically|shared)" | wc -l | awk '{ print $1 }'`
|
534 |
|
|
mkdir -p `dirname ${PFSENSESTAGEDIR}/${TEMPFILE}`
|
535 |
|
|
if [ "$FILETYPE" -gt 0 ]; then
|
536 |
|
|
NEEDLIB=`ldd /${TEMPFILE} | grep "=>" | awk '{ print $3 }'`
|
537 |
|
|
NEEDEDLIBS="$NEEDEDLIBS $NEEDLIB"
|
538 |
|
|
if [ ! -f ${PFSENSESTAGEDIR}/${TEMPFILE} ] || [ /${TEMPFILE} -nt ${PFSENSESTAGEDIR}/${TEMPFILE} ]; then
|
539 |
|
|
cp /${TEMPFILE} ${PFSENSESTAGEDIR}/${TEMPFILE}
|
540 |
|
|
chmod a+rx ${PFSENSESTAGEDIR}/${TEMPFILE}
|
541 |
|
|
fi
|
542 |
|
|
for NEEDL in $NEEDLIB; do
|
543 |
|
|
if [ -f $NEEDL ]; then
|
544 |
|
|
if [ ! -f ${PFSENSESTAGEDIR}${NEEDL} ] || [ $NEEDL -nt ${PFSENSESTAGEDIR}${NEEDL} ]; then
|
545 |
|
|
if [ ! -d "$(dirname ${PFSENSESTAGEDIR}${NEEDL})" ]; then
|
546 |
|
|
mkdir -p $(dirname ${PFSENSESTAGEDIR}${NEEDL})
|
547 |
|
|
fi
|
548 |
|
|
cp $NEEDL ${PFSENSESTAGEDIR}${NEEDL}
|
549 |
694ae0f3
|
jim-p
|
fi
|
550 |
151402e5
|
Scott Ullrich
|
fi
|
551 |
adbddb0e
|
Ermal
|
done
|
552 |
|
|
else
|
553 |
|
|
cp /${TEMPFILE} ${PFSENSESTAGEDIR}/$TEMPFILE
|
554 |
72635f13
|
Scott Ullrich
|
fi
|
555 |
5848bab9
|
sullrich
|
else
|
556 |
adbddb0e
|
Ermal
|
if [ -f ${GIT_REPO_DIR}/pfSenseGITREPO/${TEMPFILE} ]; then
|
557 |
|
|
FILETYPE=`file ${GIT_REPO_DIR}/pfSenseGITREPO/${TEMPFILE} | grep dynamically | wc -l | awk '{ print $1 }'`
|
558 |
|
|
if [ "$FILETYPE" -gt 0 ]; then
|
559 |
|
|
NEEDEDLIBS="$NEEDEDLIBS `ldd ${GIT_REPO_DIR}/pfSenseGITREPO/${TEMPFILE} | grep "=>" | awk '{ print $3 }'`"
|
560 |
|
|
fi
|
561 |
|
|
else
|
562 |
|
|
echo "Could not locate $TEMPFILE" >> ${BUILDER_LOGS}/pfPort/copy.list
|
563 |
|
|
fi
|
564 |
72635f13
|
Scott Ullrich
|
fi
|
565 |
adbddb0e
|
Ermal
|
done
|
566 |
|
|
#export DONTSTRIP=1
|
567 |
|
|
echo ">>> Installing collected library information, please wait..."
|
568 |
|
|
# Unique the libraries so we only copy them once
|
569 |
|
|
NEEDEDLIBS=`for LIB in ${NEEDEDLIBS} ; do echo $LIB ; done |sort -u`
|
570 |
|
|
for NEEDLIB in $NEEDEDLIBS; do
|
571 |
|
|
if [ -f $NEEDLIB ]; then
|
572 |
|
|
if [ ! -f ${PFSENSESTAGEDIR}${NEEDLIB} ] || [ ${NEEDLIB} -nt ${PFSENSESTAGEDIR}${NEEDLIB} ]; then
|
573 |
|
|
install ${NEEDLIB} ${PFSENSESTAGEDIR}${NEEDLIB}
|
574 |
|
|
fi
|
575 |
72635f13
|
Scott Ullrich
|
fi
|
576 |
adbddb0e
|
Ermal
|
done
|
577 |
|
|
#unset DONTSTRIP
|
578 |
|
|
else
|
579 |
|
|
echo ">>> NOTE: Cross compiling detected so binaries overlayed cannot be checked for missing libraries to be copied from host!" | tee -a ${LOGFILE}
|
580 |
|
|
fi
|
581 |
98b1c984
|
Renato Botelho
|
|
582 |
adbddb0e
|
Ermal
|
echo ">>> Deleting files listed in ${PRUNE_LIST}" | tee -a ${LOGFILE}
|
583 |
859b069b
|
Ermal
|
(cd ${PFSENSESTAGEDIR} && sed 's/^#.*//g' ${PRUNE_LIST} | xargs rm -rvf > /dev/null 2>&1)
|
584 |
72635f13
|
Scott Ullrich
|
|
585 |
adbddb0e
|
Ermal
|
# Check for zero sized files.
|
586 |
|
|
echo ">>> Checking and reporting zero size files..." | tee -a ${LOGFILE}
|
587 |
|
|
check_for_zero_size_files ${PFSENSESTAGEDIR}
|
588 |
a6bfb6cb
|
Scott Ullrich
|
}
|
589 |
|
|
|
590 |
aa0bbaae
|
Scott Ullrich
|
# This routine notes any files that are 0 sized.
|
591 |
a6bfb6cb
|
Scott Ullrich
|
check_for_zero_size_files() {
|
592 |
adbddb0e
|
Ermal
|
if [ -f $BUILDER_LOGS/zero_sized_files.txt ]; then
|
593 |
|
|
rm -f $BUILDER_LOGS/zero_sized_files.txt
|
594 |
|
|
fi
|
595 |
|
|
if [ -n "${1}" ]; then
|
596 |
c90bbf4a
|
Ermal
|
(find ${1} -perm -+x -type f -size 0 > $BUILDER_LOGS/zero_sized_files.txt)
|
597 |
|
|
if [ -f $BUILDER_LOGS/zero_sized_files.txt ]; then
|
598 |
|
|
cat $BUILDER_LOGS/zero_sized_files.txt | tee -a ${LOGFILE}
|
599 |
|
|
fi
|
600 |
adbddb0e
|
Ermal
|
fi
|
601 |
a6bfb6cb
|
Scott Ullrich
|
}
|
602 |
|
|
|
603 |
aa0bbaae
|
Scott Ullrich
|
# Install custom BSDInstaller bits for pfSense
|
604 |
5c67ed31
|
Scott Ullrich
|
cust_populate_installer_bits() {
|
605 |
5acd3712
|
Ermal
|
# Add lua installer items
|
606 |
adbddb0e
|
Ermal
|
echo ">>> Using FreeBSD ${FREEBSD_VERSION} BSDInstaller dfuibelua structure." | tee -a ${LOGFILE}
|
607 |
|
|
mkdir -p $PFSENSEISODIR/usr/local/share/dfuibe_lua/install/
|
608 |
|
|
mkdir -p $PFSENSEISODIR/scripts/
|
609 |
5acd3712
|
Ermal
|
# This is now ready for general consumption! \o/
|
610 |
adbddb0e
|
Ermal
|
mkdir -p $PFSENSEISODIR/usr/local/share/dfuibe_lua/conf/
|
611 |
5acd3712
|
Ermal
|
cp -r $BUILDER_TOOLS/installer/conf \
|
612 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
613 |
4fd2bf6f
|
jim-p
|
# Rebrand installer!
|
614 |
|
|
if [ "${PRODUCT_NAME}" != "" ]; then
|
615 |
adbddb0e
|
Ermal
|
sed -i "" -e "s/name = \"pfSense\"/name = \"${PRODUCT_NAME}\"/" $PFSENSEISODIR/usr/local/share/dfuibe_lua/conf/pfSense.lua
|
616 |
4fd2bf6f
|
jim-p
|
fi
|
617 |
6ce2072a
|
jim-p
|
if [ "${PFSENSE_VERSION}" != "" ]; then
|
618 |
adbddb0e
|
Ermal
|
sed -i "" -e "s/version = \"1.2RC3\"/version = \"${PFSENSE_VERSION}\"/" $PFSENSEISODIR/usr/local/share/dfuibe_lua/conf/pfSense.lua
|
619 |
4fd2bf6f
|
jim-p
|
fi
|
620 |
|
|
|
621 |
6ed90b1c
|
sullrich
|
# 597_ belongs in installation directory
|
622 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/597* \
|
623 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/install/
|
624 |
bc8313c5
|
Scott Ullrich
|
# 599_ belongs in installation directory
|
625 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/599* \
|
626 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/install/
|
627 |
bc8313c5
|
Scott Ullrich
|
# 300_ belongs in dfuibe_lua/
|
628 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/300* \
|
629 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
630 |
bc8313c5
|
Scott Ullrich
|
# 500_ belongs in dfuibe_lua/
|
631 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/500* \
|
632 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
633 |
488631ee
|
Scott Ullrich
|
# Copy Centipede Networks sponsored easy-install into place
|
634 |
|
|
cp -r $BUILDER_TOOLS/installer/easy_install \
|
635 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
636 |
2347d79a
|
Scott Ullrich
|
# Copy Centipede Networks sponsored easy-install into place
|
637 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/150_easy_install.lua \
|
638 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
639 |
1555881c
|
Scott Ullrich
|
# Override the base installers welcome and call the Install step "Custom Install"
|
640 |
|
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/200_install.lua \
|
641 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
642 |
b5b7f3ef
|
Ermal
|
# Copy custom 950_reboot.lua script which touches $SCRATCHDIR/install_complete
|
643 |
5955e9fa
|
Scott Ullrich
|
cp $BUILDER_TOOLS/installer/installer_root_dir7/950_reboot.lua \
|
644 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/share/dfuibe_lua/
|
645 |
ee72afa3
|
Scott Ullrich
|
# Copy cleargpt.sh utility
|
646 |
|
|
cp $BUILDER_TOOLS/installer/cleargpt.sh \
|
647 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/sbin/
|
648 |
|
|
chmod a+rx $PFSENSEISODIR/usr/sbin/cleargpt.sh
|
649 |
c516a385
|
Scott Ullrich
|
# Copy installer launcher scripts
|
650 |
adbddb0e
|
Ermal
|
cp $BUILDER_TOOLS/installer/scripts/pfi $PFSENSEISODIR/scripts/
|
651 |
|
|
cp $BUILDER_TOOLS/installer/scripts/lua_installer $PFSENSEISODIR/scripts/lua_installer
|
652 |
|
|
cp $BUILDER_TOOLS/installer/scripts/freebsd_installer $PFSENSEISODIR/scripts/
|
653 |
|
|
cp $BUILDER_TOOLS/installer/scripts/lua_installer_rescue $PFSENSEISODIR/scripts/
|
654 |
|
|
cp $BUILDER_TOOLS/installer/scripts/lua_installer_rescue $PFSENSEISODIR/scripts/
|
655 |
|
|
cp $BUILDER_TOOLS/installer/scripts/lua_installer_full $PFSENSEISODIR/scripts/
|
656 |
|
|
chmod a+rx $PFSENSEISODIR/scripts/*
|
657 |
|
|
mkdir -p $PFSENSEISODIR/usr/local/bin/
|
658 |
2b9f6c00
|
Ermal
|
cp $BUILDER_TOOLS/installer/scripts/after_installation_routines.sh \
|
659 |
adbddb0e
|
Ermal
|
$PFSENSEISODIR/usr/local/bin/after_installation_routines.sh
|
660 |
|
|
chmod a+rx $PFSENSEISODIR/scripts/*
|
661 |
5c67ed31
|
Scott Ullrich
|
}
|
662 |
|
|
|
663 |
81db86f9
|
Ermal
|
# Copies all extra files to the repository staging
|
664 |
4121355a
|
Scott Ullrich
|
# area and ISO staging area (as needed)
|
665 |
f35786c0
|
Scott Ullrich
|
cust_populate_extra() {
|
666 |
adbddb0e
|
Ermal
|
echo ">>> Phase populate_extra..." | tee -a ${LOGFILE}
|
667 |
e5bf6221
|
Scott Ullrich
|
|
668 |
adbddb0e
|
Ermal
|
mkdir -p ${PFSENSEISODIR}/home
|
669 |
|
|
mkdir -p ${PFSENSEISODIR}/lib
|
670 |
|
|
|
671 |
|
|
if [ ! -f ${PFSENSEISODIR}/usr/lib/pam_unix.so ]; then
|
672 |
|
|
echo ">>> pam_unix.so is missing copying from host " | tee -a ${LOGFILE}
|
673 |
b52931df
|
Ermal
|
if [ -f /usr/lib/pam_unix.so ]; then
|
674 |
adbddb0e
|
Ermal
|
install -s /usr/lib/pam_unix.so ${PFSENSEISODIR}/usr/lib/
|
675 |
b52931df
|
Ermal
|
fi
|
676 |
6a0db6f5
|
Scott Ullrich
|
fi
|
677 |
98b1c984
|
Renato Botelho
|
|
678 |
408b116e
|
Scott Ullrich
|
STRUCTURE_TO_CREATE="root etc usr/local/pkg/parse_config var/run scripts conf usr/local/share/dfuibe_installer root usr/local/bin usr/local/sbin usr/local/lib usr/local/etc usr/local/lib/php/20060613 usr/local/lib/lighttpd"
|
679 |
98b1c984
|
Renato Botelho
|
|
680 |
|
|
for TEMPDIR in $STRUCTURE_TO_CREATE; do
|
681 |
adbddb0e
|
Ermal
|
mkdir -p ${PFSENSEISODIR}/${TEMPDIR}
|
682 |
388f0756
|
Scott Ullrich
|
done
|
683 |
98b1c984
|
Renato Botelho
|
|
684 |
f36c4efd
|
Ermal
|
# bsnmpd
|
685 |
adbddb0e
|
Ermal
|
mkdir -p $PFSENSEISODIR/usr/share/snmp/defs/
|
686 |
|
|
cp -R /usr/share/snmp/defs/ $PFSENSEISODIR/usr/share/snmp/defs/
|
687 |
78a9cc5f
|
Dario Freni
|
|
688 |
f36c4efd
|
Ermal
|
# Set buildtime
|
689 |
c93dc90c
|
Ermal
|
get_date_string
|
690 |
26e9089d
|
Scott Ullrich
|
|
691 |
e750d78f
|
Scott Ullrich
|
# Record last commit info if it is available.
|
692 |
b5b7f3ef
|
Ermal
|
if [ -f $SCRATCHDIR/build_commit_info.txt ]; then
|
693 |
adbddb0e
|
Ermal
|
cp $SCRATCHDIR/build_commit_info.txt $PFSENSEISODIR/etc/version.lastcommit
|
694 |
e750d78f
|
Scott Ullrich
|
fi
|
695 |
859b069b
|
Ermal
|
}
|
696 |
|
|
|
697 |
aa0bbaae
|
Scott Ullrich
|
# Copy a custom defined config.xml used commonly
|
698 |
|
|
# in rebranding and such applications.
|
699 |
05c4bcd7
|
Scott Ullrich
|
cust_install_config_xml() {
|
700 |
|
|
if [ ! -z "${USE_CONFIG_XML:-}" ]; then
|
701 |
|
|
if [ -f "$USE_CONFIG_XML" ]; then
|
702 |
adbddb0e
|
Ermal
|
echo ">>> Using custom config.xml file ${USE_CONFIG_XML} ..." | tee -a ${LOGFILE}
|
703 |
|
|
cp ${USE_CONFIG_XML} ${PFSENSEISODIR}/cf/conf/config.xml
|
704 |
|
|
cp ${USE_CONFIG_XML} ${PFSENSEISODIR}/conf.default/config.xml 2>/dev/null
|
705 |
05c4bcd7
|
Scott Ullrich
|
fi
|
706 |
|
|
fi
|
707 |
|
|
}
|
708 |
|
|
|
709 |
f36c4efd
|
Ermal
|
# This routine will copy over $custom_overlay onto
|
710 |
aa0bbaae
|
Scott Ullrich
|
# the staging area. It is commonly used for rebranding
|
711 |
|
|
# and or custom appliances.
|
712 |
ded3b96a
|
Scott Ullrich
|
install_custom_overlay() {
|
713 |
351bbef3
|
Scott Ullrich
|
# Extract custom overlay if it's defined.
|
714 |
6f354731
|
Scott Ullrich
|
if [ ! -z "${custom_overlay:-}" ]; then
|
715 |
adbddb0e
|
Ermal
|
echo -n ">>> Custom overlay defined - " | tee -a ${LOGFILE}
|
716 |
3426f6c3
|
jim-p
|
if [ -d $custom_overlay ]; then
|
717 |
adbddb0e
|
Ermal
|
echo " found directory, $custom_overlay copying..." | tee -a ${LOGFILE}
|
718 |
3e590d5b
|
Scott Ullrich
|
for i in $custom_overlay/*
|
719 |
|
|
do
|
720 |
f36c4efd
|
Ermal
|
if [ -d "$i" ]; then
|
721 |
adbddb0e
|
Ermal
|
echo ">>> Copying dir: $i ..." | tee -a ${LOGFILE}
|
722 |
|
|
cp -R $i $PFSENSEISODIR
|
723 |
3e590d5b
|
Scott Ullrich
|
else
|
724 |
adbddb0e
|
Ermal
|
echo ">>> Copying file: $i ..." | tee -a ${LOGFILE}
|
725 |
|
|
cp $i $PFSENSEISODIR
|
726 |
3e590d5b
|
Scott Ullrich
|
fi
|
727 |
|
|
done
|
728 |
40d67665
|
Daniel Stefan Haischt
|
elif [ -f $custom_overlay ]; then
|
729 |
adbddb0e
|
Ermal
|
echo " found file, $custom_overlay extracting..." | tee -a ${LOGFILE}
|
730 |
|
|
tar xzpf $custom_overlay -C $PFSENSEISODIR
|
731 |
f2945ca4
|
Scott Ullrich
|
else
|
732 |
0da88a9f
|
Ermal
|
echo "ERROR: file not found $custom_overlay" | tee -a ${LOGFILE}
|
733 |
ee8c39a4
|
Scott Ullrich
|
print_error_pfS
|
734 |
f2945ca4
|
Scott Ullrich
|
fi
|
735 |
351bbef3
|
Scott Ullrich
|
fi
|
736 |
3426f6c3
|
jim-p
|
if [ ! -z "${custom_overlay_archive:-}" ]; then
|
737 |
adbddb0e
|
Ermal
|
echo -n ">>> Custom overlay archive defined - " | tee -a ${LOGFILE}
|
738 |
3426f6c3
|
jim-p
|
if [ -d $custom_overlay_archive ]; then
|
739 |
adbddb0e
|
Ermal
|
echo " found directory, $custom_overlay_archive extracting files..." | tee -a ${LOGFILE}
|
740 |
3426f6c3
|
jim-p
|
for i in $custom_overlay_archive/*
|
741 |
|
|
do
|
742 |
84216eb7
|
Ermal
|
if [ -f "$i" ]; then
|
743 |
adbddb0e
|
Ermal
|
echo ">>> Extracting file: $i ..." | tee -a ${LOGFILE}
|
744 |
|
|
tar xzpf $i -C $PFSENSEISODIR
|
745 |
3426f6c3
|
jim-p
|
fi
|
746 |
|
|
done
|
747 |
|
|
elif [ -f $custom_overlay_archive ]; then
|
748 |
adbddb0e
|
Ermal
|
echo " found file, $custom_overlay_archive extracting..." | tee -a ${LOGFILE}
|
749 |
|
|
tar xzpf $custom_overlay_archive -C $PFSENSEISODIR
|
750 |
3426f6c3
|
jim-p
|
else
|
751 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: file not found $custom_overlay_archive" | tee -a ${LOGFILE}
|
752 |
3426f6c3
|
jim-p
|
print_error_pfS
|
753 |
|
|
fi
|
754 |
|
|
fi
|
755 |
c2e91c23
|
Scott Ullrich
|
}
|
756 |
|
|
|
757 |
aa0bbaae
|
Scott Ullrich
|
# This rotine will overlay $custom_overlay_final when
|
758 |
|
|
# the build is 99% completed. Used to overwrite globals.inc
|
759 |
|
|
# and other files when we need to install packages from pfSense
|
760 |
98b1c984
|
Renato Botelho
|
# which would require a normal globals.inc.
|
761 |
e3cb0ed8
|
Scott Ullrich
|
install_custom_overlay_final() {
|
762 |
|
|
# Extract custom overlay if it's defined.
|
763 |
|
|
if [ ! -z "${custom_overlay_final:-}" ]; then
|
764 |
5b619f04
|
Ermal
|
echo -n ">>> Custom overlay defined - "
|
765 |
f36c4efd
|
Ermal
|
if [ -d $custom_overlay_final ]; then
|
766 |
71d3924c
|
Ermal
|
echo " found directory, $custom_overlay_final copying..."
|
767 |
e3cb0ed8
|
Scott Ullrich
|
for i in $custom_overlay_final/*
|
768 |
|
|
do
|
769 |
f36c4efd
|
Ermal
|
if [ -d $i ]; then
|
770 |
adbddb0e
|
Ermal
|
echo ">>> Copying dir: $i $PFSENSEISODIR ..." | tee -a ${LOGFILE}
|
771 |
|
|
cp -R $i $PFSENSEISODIR
|
772 |
f36c4efd
|
Ermal
|
else
|
773 |
adbddb0e
|
Ermal
|
echo ">>> Copying file: $i $PFSENSEISODIR ..." | tee -a ${LOGFILE}
|
774 |
|
|
cp $i $PFSENSEISODIR
|
775 |
f36c4efd
|
Ermal
|
fi
|
776 |
e3cb0ed8
|
Scott Ullrich
|
done
|
777 |
f36c4efd
|
Ermal
|
elif [ -f $custom_overlay_final ]; then
|
778 |
adbddb0e
|
Ermal
|
echo " found file, $custom_overlay_final extracting..." |tee -a ${LOGFILE}
|
779 |
|
|
tar xzpf $custom_overlay_final -C $PFSENSEISODIR
|
780 |
e3cb0ed8
|
Scott Ullrich
|
else
|
781 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: file not found $custom_overlay_final" | tee -a ${LOGFILE}
|
782 |
ee8c39a4
|
Scott Ullrich
|
print_error_pfS
|
783 |
e3cb0ed8
|
Scott Ullrich
|
fi
|
784 |
|
|
fi
|
785 |
3c740eeb
|
Scott Ullrich
|
}
|
786 |
|
|
|
787 |
bb1a32d7
|
sullrich
|
setup_serial_hints() {
|
788 |
|
|
# When using the serial port as a boot console, be sure to update
|
789 |
|
|
# /boot/device.hints and /etc/ttys before booting the new kernel.
|
790 |
|
|
# If you forget to do so, you can still manually specify the hints
|
791 |
|
|
# at the loader prompt:
|
792 |
adbddb0e
|
Ermal
|
if [ ! -f $PFSENSEISODIR/boot/device.hints ]; then
|
793 |
|
|
touch $PFSENSEISODIR/boot/device.hints
|
794 |
|
|
fi
|
795 |
|
|
echo -n ">>> Setting uart hints on device.hints..." | tee -a ${LOGFILE}
|
796 |
|
|
echo 'hint.uart.0.at="isa"' >> $PFSENSEISODIR/boot/device.hints
|
797 |
|
|
echo 'hint.uart.0.port="0x3F8"' >> $PFSENSEISODIR/boot/device.hints
|
798 |
|
|
echo 'hint.uart.0.flags="0x10"' >> $PFSENSEISODIR/boot/device.hints
|
799 |
|
|
echo 'hint.uart.0.irq="4"' >> $PFSENSEISODIR/boot/device.hints
|
800 |
|
|
echo "Done." | tee -a ${LOGFILE}
|
801 |
bb1a32d7
|
sullrich
|
}
|
802 |
|
|
|
803 |
aa0bbaae
|
Scott Ullrich
|
# Items that need to be fixed up that are
|
804 |
|
|
# specific to nanobsd builds
|
805 |
0d62e756
|
Scott Ullrich
|
cust_fixup_nanobsd() {
|
806 |
adbddb0e
|
Ermal
|
_NANO_WITH_VGA="${1}"
|
807 |
|
|
_FLASH_SIZE="${2}"
|
808 |
0d62e756
|
Scott Ullrich
|
|
809 |
adbddb0e
|
Ermal
|
echo ">>> Fixing up NanoBSD Specific items..." | tee -a ${LOGFILE}
|
810 |
bcec907f
|
Ermal
|
if [ "${_NANO_WITH_VGA}" = "nanobsd" ]; then
|
811 |
adbddb0e
|
Ermal
|
cp $PFSENSEISODIR/boot/loader.conf_wrap $PFSENSEISODIR/boot/loader.conf
|
812 |
|
|
cp $PFSENSEISODIR/etc/ttys_wrap $PFSENSEISODIR/etc/ttys
|
813 |
|
|
fi
|
814 |
0d62e756
|
Scott Ullrich
|
|
815 |
e0c04d08
|
Renato Botelho
|
# Be sure loader.conf exists, to avoid errors
|
816 |
adbddb0e
|
Ermal
|
touch $PFSENSEISODIR/boot/loader.conf
|
817 |
4aac1707
|
Scott Ullrich
|
|
818 |
adbddb0e
|
Ermal
|
# create diskless marker file
|
819 |
|
|
touch ${PFSENSEISODIR}/etc/diskless
|
820 |
|
|
touch ${PFSENSEISODIR}/nanobuild
|
821 |
|
|
|
822 |
|
|
# Make root filesystem R/O by default
|
823 |
|
|
echo "root_rw_mount=NO" >> ${PFSENSEISODIR}/etc/defaults/rc.conf
|
824 |
0d62e756
|
Scott Ullrich
|
|
825 |
adbddb0e
|
Ermal
|
echo "" > $PFSENSEISODIR/etc/motd
|
826 |
0d62e756
|
Scott Ullrich
|
|
827 |
adbddb0e
|
Ermal
|
mkdir -p $PFSENSEISODIR/cf/conf/backup
|
828 |
0d62e756
|
Scott Ullrich
|
|
829 |
adbddb0e
|
Ermal
|
rm -f $PFSENSEISODIR/usr/local/bin/after_installation_routines.sh 2>/dev/null
|
830 |
|
|
|
831 |
|
|
echo "nanobsd" > $PFSENSEISODIR/etc/platform
|
832 |
|
|
|
833 |
|
|
if [ "${_NANO_WITH_VGA}" = "nanobsd" ]; then
|
834 |
6fa894fd
|
Renato Botelho
|
# Tell loader to use serial console early.
|
835 |
adbddb0e
|
Ermal
|
echo "-h" >> $PFSENSEISODIR/boot.config
|
836 |
0d62e756
|
Scott Ullrich
|
|
837 |
89001bc1
|
Renato Botelho
|
# Enable getty on console
|
838 |
adbddb0e
|
Ermal
|
sed -i "" -e /ttyd0/s/off/on/ ${PFSENSEISODIR}/etc/ttys
|
839 |
0d62e756
|
Scott Ullrich
|
|
840 |
89001bc1
|
Renato Botelho
|
# Disable getty on syscons devices
|
841 |
adbddb0e
|
Ermal
|
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${PFSENSEISODIR}/etc/ttys
|
842 |
6fa894fd
|
Renato Botelho
|
else
|
843 |
|
|
# Empty file to identify nanobsd_vga images
|
844 |
adbddb0e
|
Ermal
|
touch ${PFSENSEISODIR}/etc/nano_use_vga.txt
|
845 |
0d62e756
|
Scott Ullrich
|
fi
|
846 |
adbddb0e
|
Ermal
|
|
847 |
|
|
unset _NANO_WITH_VGA
|
848 |
|
|
unset _FLASH_SIZE
|
849 |
0d62e756
|
Scott Ullrich
|
}
|
850 |
|
|
|
851 |
aa0bbaae
|
Scott Ullrich
|
# This routine will verify that PHP is sound and that it
|
852 |
|
|
# can open and read config.xml and ensure the hostname
|
853 |
55b9f1f0
|
Scott Ullrich
|
test_php_install() {
|
854 |
967d0d64
|
Ermal
|
if [ "${TARGET}" != "${BUILDER_HOST_TARGET}" ]; then
|
855 |
adbddb0e
|
Ermal
|
echo ">>> WARNING: Cannot test PHP installation due to different platform ABIs... Skipping!" | tee -a ${LOGFILE}
|
856 |
967d0d64
|
Ermal
|
return
|
857 |
|
|
fi
|
858 |
|
|
|
859 |
0d439e6b
|
Renato Botelho
|
# We might need to setup php.ini
|
860 |
adbddb0e
|
Ermal
|
if test -f "/boot/kernel/ng_socket.ko" && !(kldstat -m ng_socket 2>&1 1>/dev/null); then
|
861 |
|
|
echo ">>> Loading ng_socket.ko needed for testing php." | tee -a ${LOGFILE}
|
862 |
0d439e6b
|
Renato Botelho
|
kldload -v /boot/kernel/ng_socket.ko 2>/dev/null
|
863 |
adbddb0e
|
Ermal
|
if [ $? -ne 0 ]; then
|
864 |
|
|
echo ">>> ERROR: root priviledges required for this operation please preload this if running as non-root or check why ng_socket.ko cannot be loaded!" | tee -a ${LOGFILE}
|
865 |
|
|
print_error_pfS
|
866 |
|
|
fi
|
867 |
0d439e6b
|
Renato Botelho
|
fi
|
868 |
|
|
|
869 |
adbddb0e
|
Ermal
|
echo -n ">>> Testing PHP installation in ${PFSENSEISODIR}:" | tee -a ${LOGFILE}
|
870 |
2f0db86f
|
Scott Ullrich
|
|
871 |
|
|
# backup original conf dir
|
872 |
adbddb0e
|
Ermal
|
if [ -d $PFSENSEISODIR/conf ]; then
|
873 |
|
|
/bin/mv $PFSENSEISODIR/conf $PFSENSEISODIR/conf.org
|
874 |
|
|
mkdir -p $PFSENSEISODIR/tmp/
|
875 |
|
|
/usr/bin/touch $PFSENSEISODIR/tmp/restore_conf_dir
|
876 |
2f0db86f
|
Scott Ullrich
|
fi
|
877 |
|
|
|
878 |
|
|
# test whether conf dir is already a symlink
|
879 |
200f41cb
|
Ermal
|
if [ ! -L $PFSENSEISODIR/conf ]; then
|
880 |
2f0db86f
|
Scott Ullrich
|
# install the symlink as it would exist on a live system
|
881 |
adbddb0e
|
Ermal
|
chroot $PFSENSEISODIR /bin/ln -s /conf.default /conf 2>&1 >> ${LOGFILE}
|
882 |
200f41cb
|
Ermal
|
chroot $PFSENSEISODIR /bin/ln -s /conf.default /cf 2>&1 >> ${LOGFILE}
|
883 |
adbddb0e
|
Ermal
|
/usr/bin/touch $PFSENSEISODIR/tmp/remove_conf_symlink
|
884 |
2f0db86f
|
Scott Ullrich
|
fi
|
885 |
|
|
|
886 |
adbddb0e
|
Ermal
|
if [ -f "$PFSENSEISODIR/etc/rc.php_ini_setup" ]; then
|
887 |
|
|
mkdir -p $PFSENSEISODIR/usr/local/lib/ $PFSENSEISODIR/usr/local/etc/
|
888 |
|
|
chroot $PFSENSEISODIR /etc/rc.php_ini_setup 2>/dev/null
|
889 |
88fdfd32
|
Scott Ullrich
|
fi
|
890 |
|
|
|
891 |
adbddb0e
|
Ermal
|
if [ ${FREEBSD_VERSION} -lt 10 ]; then
|
892 |
|
|
cp $BUILDER_SCRIPTS/scripts/test_php.php $PFSENSEISODIR/
|
893 |
|
|
chmod a+rx $PFSENSEISODIR/test_php.php
|
894 |
|
|
HOSTNAME=`env SHELL=/bin/sh chroot $PFSENSEISODIR /test_php.php`
|
895 |
|
|
echo -n " $HOSTNAME "
|
896 |
|
|
if [ "$HOSTNAME" != "FCGI-PASSED PASSED" ]; then
|
897 |
|
|
echo
|
898 |
|
|
echo
|
899 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: An error occured while testing the php installation in $PFSENSEISODIR" | tee -a ${LOGFILE}
|
900 |
adbddb0e
|
Ermal
|
echo
|
901 |
|
|
print_error_pfS
|
902 |
|
|
die
|
903 |
|
|
else
|
904 |
|
|
echo " [OK]" | tee -a ${LOGFILE}
|
905 |
|
|
fi
|
906 |
628183cf
|
Ermal
|
else
|
907 |
|
|
echo " [ UNKOWN] since a new test needs to be written for php-fpm" | tee -a ${LOGFILE}
|
908 |
55b9f1f0
|
Scott Ullrich
|
fi
|
909 |
2f0db86f
|
Scott Ullrich
|
|
910 |
|
|
#
|
911 |
|
|
# Cleanup, aisle 7!
|
912 |
|
|
#
|
913 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/remove_platform ]; then
|
914 |
|
|
/bin/rm $PFSENSEISODIR/etc/platform
|
915 |
|
|
/bin/rm $PFSENSEISODIR/tmp/remove_platform
|
916 |
2f0db86f
|
Scott Ullrich
|
fi
|
917 |
|
|
|
918 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/remove_conf_symlink ]; then
|
919 |
|
|
/bin/rm $PFSENSEISODIR/conf
|
920 |
200f41cb
|
Ermal
|
if [ -L $PFSENSEISODIR/cf ]; then
|
921 |
adbddb0e
|
Ermal
|
/bin/rm $PFSENSEISODIR/cf
|
922 |
2f0db86f
|
Scott Ullrich
|
fi
|
923 |
adbddb0e
|
Ermal
|
/bin/rm $PFSENSEISODIR/tmp/remove_conf_symlink
|
924 |
2f0db86f
|
Scott Ullrich
|
fi
|
925 |
|
|
|
926 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/restore_conf_dir ]; then
|
927 |
|
|
/bin/mv $PFSENSEISODIR/conf.org $PFSENSEISODIR/conf
|
928 |
|
|
/bin/rm $PFSENSEISODIR/tmp/restore_conf_dir
|
929 |
2f0db86f
|
Scott Ullrich
|
fi
|
930 |
|
|
|
931 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/platform ]; then
|
932 |
|
|
mv $PFSENSEISODIR/tmp/platform $PFSENSEISODIR/etc/platform
|
933 |
2f0db86f
|
Scott Ullrich
|
fi
|
934 |
|
|
|
935 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/config.cache ]; then
|
936 |
|
|
/bin/rm $PFSENSEISODIR/tmp/config.cache
|
937 |
2f0db86f
|
Scott Ullrich
|
fi
|
938 |
|
|
|
939 |
adbddb0e
|
Ermal
|
if [ -f $PFSENSEISODIR/tmp/php.ini ]; then
|
940 |
|
|
cp /tmp/php.ini $PFSENSEISODIR/usr/local/lib/php.ini
|
941 |
|
|
cp /tmp/php.ini $PFSENSEISODIR/usr/local/etc/php.ini
|
942 |
2f0db86f
|
Scott Ullrich
|
fi
|
943 |
9517d953
|
Scott Ullrich
|
|
944 |
adbddb0e
|
Ermal
|
rm $PFSENSEISODIR/test_php.php 2>/dev/null
|
945 |
|
|
rm $PFSENSEISODIR/tmp/*.cache 2>/dev/null
|
946 |
|
|
rm $PFSENSEISODIR/tmp/*.lock 2>/dev/null
|
947 |
55b9f1f0
|
Scott Ullrich
|
}
|
948 |
|
|
|
949 |
aa0bbaae
|
Scott Ullrich
|
# This routine creates a on disk summary of all file
|
950 |
|
|
# checksums which could be used to verify that a file
|
951 |
|
|
# is indeed how it was shipped.
|
952 |
4a2f9630
|
Scott Ullrich
|
create_md5_summary_file() {
|
953 |
adbddb0e
|
Ermal
|
if [ "${TARGET}" != "${BUILDER_HOST_TARGET}" ]; then
|
954 |
|
|
echo ">>> WARNING: cross compiling detected, skipping generation of md5 summaries!" | tee -a ${LOGFILE}
|
955 |
|
|
return
|
956 |
|
|
fi
|
957 |
|
|
echo -n ">>> Creating md5 summary of files present..." | tee -a ${LOGFILE}
|
958 |
|
|
rm -f $PFSENSEISODIR/etc/pfSense_md5.txt
|
959 |
|
|
echo "#!/bin/sh" > $PFSENSEISODIR/chroot.sh
|
960 |
|
|
echo "find / -type f | /usr/bin/xargs /sbin/md5 >> /etc/pfSense_md5.txt" >> $PFSENSEISODIR/chroot.sh
|
961 |
|
|
chmod a+rx $PFSENSEISODIR/chroot.sh
|
962 |
|
|
(chroot $PFSENSEISODIR /chroot.sh) 2>&1 | egrep -wi '(^>>>|errors)'
|
963 |
|
|
rm $PFSENSEISODIR/chroot.sh
|
964 |
|
|
echo "Done." | tee -a ${LOGFILE}
|
965 |
4a2f9630
|
Scott Ullrich
|
}
|
966 |
|
|
|
967 |
50dafea3
|
jim-p
|
# This routine creates an mtree file that can be used to check
|
968 |
|
|
# and correct file permissions post-install, to correct for the
|
969 |
|
|
# fact that the ISO image doesn't support some permissions.
|
970 |
|
|
create_mtree_summary_file() {
|
971 |
adbddb0e
|
Ermal
|
if [ "${TARGET}" != "${BUILDER_HOST_TARGET}" ]; then
|
972 |
|
|
echo ">>> WARNING: cross compiling detected, skipping generation of md5 summaries!" | tee -a ${LOGFILE}
|
973 |
|
|
return
|
974 |
|
|
fi
|
975 |
|
|
echo -n ">>> Creating mtree summary of files present..." | tee -a ${LOGFILE}
|
976 |
|
|
rm -f $PFSENSEISODIR/etc/installed_filesystem.mtree
|
977 |
|
|
echo "#!/bin/sh" > $PFSENSEISODIR/chroot.sh
|
978 |
|
|
echo "cd /" >> $PFSENSEISODIR/chroot.sh
|
979 |
|
|
echo "/tmp" >> $PFSENSEISODIR/tmp/installed_filesystem.mtree.exclude
|
980 |
|
|
echo "/dev" >> $PFSENSEISODIR/tmp/installed_filesystem.mtree.exclude
|
981 |
|
|
echo "/usr/sbin/mtree -c -k uid,gid,mode,size,sha256digest -p / -X /tmp/installed_filesystem.mtree.exclude > /tmp/installed_filesystem.mtree" >> $PFSENSEISODIR/chroot.sh
|
982 |
|
|
echo "/bin/chmod 600 /tmp/installed_filesystem.mtree" >> $PFSENSEISODIR/chroot.sh
|
983 |
|
|
echo "/bin/mv /tmp/installed_filesystem.mtree /etc/" >> $PFSENSEISODIR/chroot.sh
|
984 |
|
|
|
985 |
|
|
chmod a+rx $PFSENSEISODIR/chroot.sh
|
986 |
|
|
(chroot $PFSENSEISODIR /chroot.sh) 2>&1 | egrep -wi '(^>>>|errors)'
|
987 |
|
|
rm $PFSENSEISODIR/chroot.sh
|
988 |
|
|
echo "Done." | tee -a ${LOGFILE}
|
989 |
50dafea3
|
jim-p
|
}
|
990 |
|
|
|
991 |
aa0bbaae
|
Scott Ullrich
|
# Creates a full update file
|
992 |
3c740eeb
|
Scott Ullrich
|
create_pfSense_Full_update_tarball() {
|
993 |
|
|
mkdir -p $UPDATESDIR
|
994 |
|
|
|
995 |
adbddb0e
|
Ermal
|
OLDPWD=`pwd`
|
996 |
|
|
|
997 |
|
|
customize_stagearea_for_image "fullupdate"
|
998 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
999 |
|
|
|
1000 |
|
|
rm -rf ${PFSENSEISODIR}/cf
|
1001 |
|
|
rm -rf ${PFSENSEISODIR}/conf
|
1002 |
|
|
rm -f ${PFSENSEISODIR}/etc/rc.conf
|
1003 |
|
|
rm -f ${PFSENSEISODIR}/etc/motd
|
1004 |
|
|
rm -f ${PFSENSEISODIR}/etc/pwd.db 2>/dev/null
|
1005 |
|
|
rm -f ${PFSENSEISODIR}/etc/group 2>/dev/null
|
1006 |
|
|
rm -f ${PFSENSEISODIR}/etc/spwd.db 2>/dev/null
|
1007 |
|
|
rm -f ${PFSENSEISODIR}/etc/passwd 2>/dev/null
|
1008 |
|
|
rm -f ${PFSENSEISODIR}/etc/master.passwd 2>/dev/null
|
1009 |
|
|
rm -f ${PFSENSEISODIR}/etc/fstab 2>/dev/null
|
1010 |
|
|
rm -f ${PFSENSEISODIR}/etc/ttys 2>/dev/null
|
1011 |
|
|
rm -f ${PFSENSEISODIR}/etc/bogons 2>/dev/null
|
1012 |
|
|
# Remove loader.conf and friends. Ticket #560
|
1013 |
|
|
rm ${PFSENSEISODIR}/boot/loader.conf 2>/dev/null
|
1014 |
|
|
rm ${PFSENSEISODIR}/boot/loader.conf.local 2>/dev/null
|
1015 |
03dde81f
|
Scott Ullrich
|
|
1016 |
98b1c984
|
Renato Botelho
|
|
1017 |
adbddb0e
|
Ermal
|
mkdir -p ${PFSENSEISODIR}/usr/local/livefs/lib/
|
1018 |
9d420190
|
Scott Ullrich
|
|
1019 |
adbddb0e
|
Ermal
|
echo ">>> Creating ${UPDATES_TARBALL_FILENAME} ..." | tee -a ${LOGFILE}
|
1020 |
|
|
cd ${PFSENSEISODIR} && tar czPf ${UPDATES_TARBALL_FILENAME} .
|
1021 |
3c740eeb
|
Scott Ullrich
|
|
1022 |
adbddb0e
|
Ermal
|
cd $OLDPWD
|
1023 |
|
|
unset OLDPWD
|
1024 |
3c740eeb
|
Scott Ullrich
|
}
|
1025 |
|
|
|
1026 |
aa0bbaae
|
Scott Ullrich
|
# Does the work of checking out the specific branch of pfSense
|
1027 |
6a30cc43
|
Scott Ullrich
|
checkout_pfSense_git() {
|
1028 |
84e681c2
|
Scott Ullrich
|
|
1029 |
787cbc79
|
Ermal
|
mkdir -p ${GIT_REPO_DIR}/pfSenseGITREPO
|
1030 |
5ce63e88
|
Ermal
|
|
1031 |
|
|
branch_exists=`(cd ${GIT_REPO_DIR}/pfSenseGITREPO \
|
1032 |
b6160dbe
|
Renato Botelho
|
&& git branch -a | grep "${PFSENSETAG}\$")`
|
1033 |
5ce63e88
|
Ermal
|
tag_exists=`(cd ${GIT_REPO_DIR}/pfSenseGITREPO \
|
1034 |
|
|
&& git tag -l | grep "^${PFSENSETAG}\$")`
|
1035 |
|
|
|
1036 |
|
|
if [ -z "${branch_exists}" -a -z "${tag_exists}" ]; then
|
1037 |
|
|
BRANCH=master
|
1038 |
787cbc79
|
Ermal
|
else
|
1039 |
|
|
BRANCH="${PFSENSETAG}"
|
1040 |
5ce63e88
|
Ermal
|
fi
|
1041 |
a4f59510
|
jim-p
|
|
1042 |
5ce63e88
|
Ermal
|
# If we are using a git tag, don't specify origin/ in the remote.
|
1043 |
3c1a0575
|
Ermal
|
if [ -z "${tag_exists}" ]; then
|
1044 |
|
|
ORIGIN=origin/
|
1045 |
|
|
fi
|
1046 |
a4f59510
|
jim-p
|
|
1047 |
859b069b
|
Ermal
|
echo -n ">>> Checking out tag ${BRANCH} ..."
|
1048 |
5ce63e88
|
Ermal
|
if [ "${BRANCH}" = "master" ]; then
|
1049 |
3c1a0575
|
Ermal
|
(cd ${GIT_REPO_DIR}/pfSenseGITREPO && git checkout master) \
|
1050 |
5ce63e88
|
Ermal
|
2>&1 | egrep -wi '(^>>>|error)'
|
1051 |
|
|
elif [ -z "${branch_exists}" ]; then
|
1052 |
|
|
(cd ${GIT_REPO_DIR}/pfSenseGITREPO \
|
1053 |
|
|
&& git checkout -b "${PFSENSETAG}" "${ORIGIN}${PFSENSETAG}") \
|
1054 |
|
|
2>&1 | egrep -wi '(^>>>|error)'
|
1055 |
|
|
else
|
1056 |
|
|
(cd ${GIT_REPO_DIR}/pfSenseGITREPO \
|
1057 |
3c1a0575
|
Ermal
|
&& git checkout "${PFSENSETAG}") 2>&1 \
|
1058 |
5ce63e88
|
Ermal
|
| egrep -wi '(^>>>|error)'
|
1059 |
787cbc79
|
Ermal
|
fi
|
1060 |
|
|
echo 'Done!'
|
1061 |
|
|
|
1062 |
|
|
echo -n '>>> Making sure we are in the right branch...'
|
1063 |
|
|
selected_branch=`cd ${GIT_REPO_DIR}/pfSenseGITREPO && \
|
1064 |
|
|
git branch | grep '^\*' | cut -d' ' -f2`
|
1065 |
|
|
if [ "${selected_branch}" = "${BRANCH}" ]; then
|
1066 |
|
|
echo " [OK] (${BRANCH})"
|
1067 |
|
|
else
|
1068 |
a4f59510
|
jim-p
|
tag_exists=`(cd ${GIT_REPO_DIR}/pfSenseGITREPO \
|
1069 |
|
|
&& git tag -l | grep "^${PFSENSETAG}\$")`
|
1070 |
|
|
|
1071 |
|
|
if [ -z "${tag_exists}" ] || [ "${selected_branch}" != "(no" ]; then
|
1072 |
|
|
echo " [FAILED!] (${BRANCH})"
|
1073 |
|
|
print_error_pfS 'Checked out branch/tag differs from configured BRANCH, something is wrong with the build system!'
|
1074 |
|
|
kill $$
|
1075 |
|
|
fi
|
1076 |
787cbc79
|
Ermal
|
fi
|
1077 |
6a30cc43
|
Scott Ullrich
|
}
|
1078 |
|
|
|
1079 |
aa0bbaae
|
Scott Ullrich
|
# Outputs various set variables aka env
|
1080 |
3c740eeb
|
Scott Ullrich
|
print_flags() {
|
1081 |
3e590d5b
|
Scott Ullrich
|
|
1082 |
1b84dbfc
|
Scott Ullrich
|
echo
|
1083 |
|
|
printf " MAKEOBJDIRPREFIX: %s\n" $MAKEOBJDIRPREFIX
|
1084 |
7dc95442
|
Scott Ullrich
|
printf " pfSense version: %s\n" $PFSENSE_VERSION
|
1085 |
20822c1e
|
Scott Ullrich
|
printf " BASE_DIR: %s\n" $BASE_DIR
|
1086 |
859b069b
|
Ermal
|
printf " Stage DIR: %s\n" $PFSENSESTAGEDIR
|
1087 |
7dc95442
|
Scott Ullrich
|
printf " Updates dir: %s\n" $UPDATESDIR
|
1088 |
adbddb0e
|
Ermal
|
printf " Image Preparation Stage DIR: %s\n" $PFSENSEISODIR
|
1089 |
7dc95442
|
Scott Ullrich
|
printf " Custom overlay: %s\n" $custom_overlay
|
1090 |
adbddb0e
|
Ermal
|
printf " Source DIR: %s\n" $SRCDIR
|
1091 |
8326a7c1
|
Ermal
|
printf " FreeBSD repository: %s\n" $FREEBSD_REPO_BASE
|
1092 |
ffa5da64
|
Ermal
|
printf " FreeBSD version: %s\n" $FREEBSD_VERSION
|
1093 |
7dc95442
|
Scott Ullrich
|
printf " FreeBSD branch: %s\n" $FREEBSD_BRANCH
|
1094 |
adbddb0e
|
Ermal
|
printf " BUILD_KERNELS: %s\n" $BUILD_KERNELS
|
1095 |
859b069b
|
Ermal
|
printf " Git Repository: %s\n" $GIT_REPO_PFSENSE
|
1096 |
7dc95442
|
Scott Ullrich
|
printf " pfSense Tag: %s\n" $PFSENSETAG
|
1097 |
1ba696d9
|
Scott Ullrich
|
printf " MODULES_OVERRIDE: %s\n" $MODULES_OVERRIDE
|
1098 |
7dc95442
|
Scott Ullrich
|
printf " Custom Config: %s\n" $USE_CONFIG_XML
|
1099 |
859b069b
|
Ermal
|
printf " BUILD_COMPLETED_MAIL: %s\n" $BUILD_COMPLETED_MAIL
|
1100 |
|
|
printf " BUILD_ERROR_MAIL: %s\n" $BUILD_ERROR_MAIL
|
1101 |
4d7a75fc
|
jim-p
|
printf " OVADISKSIZE: %s\n" $OVADISKSIZE
|
1102 |
|
|
printf " OVABLOCKSIZE: %s\n" $OVABLOCKSIZE
|
1103 |
|
|
printf " OVA_FIRST_PART_SIZE: %s\n" $OVA_FIRST_PART_SIZE
|
1104 |
|
|
printf " OVA_SWAP_PART_SIZE: %s\n" $OVA_SWAP_PART_SIZE
|
1105 |
adbddb0e
|
Ermal
|
printf " OVFFILE: %s\n" $OVFFILE
|
1106 |
010be2fb
|
Scott Ullrich
|
printf " OVAFILE: %s\n" $OVAFILE
|
1107 |
|
|
printf " OVFVMDK: %s\n" $OVFVMDK
|
1108 |
4cd2bb8e
|
Scott Ullrich
|
printf " OVFSTRINGS: %s\n" $OVFSTRINGS
|
1109 |
|
|
printf " OVFMF: %s\n" $OVFMF
|
1110 |
|
|
printf " OVFCERT: %s\n" $OVFCERT
|
1111 |
7dc95442
|
Scott Ullrich
|
printf " SRC_CONF: %s\n" $SRC_CONF
|
1112 |
adbddb0e
|
Ermal
|
printf " Remove list: %s\n" $CUSTOM_REMOVE_LIST
|
1113 |
|
|
printf " Copy list: %s\n" $CUSTOM_COPY_LIST
|
1114 |
40bb7954
|
Ermal
|
printf " ISOPATH: %s\n" $ISOPATH
|
1115 |
|
|
printf " MEMSTICKPATH: %s\n" $MEMSTICKPATH
|
1116 |
f0a96569
|
Scott Ullrich
|
printf " UPDATES_TARBALL_FILENAME: %s\n" $UPDATES_TARBALL_FILENAME
|
1117 |
b5462c45
|
Scott Ullrich
|
printf " PKG_INSTALL_PORTSPFS: %s\n" $PKG_INSTALL_PORTSPFS
|
1118 |
b85af073
|
Scott Ullrich
|
printf " CUSTOM_CALL_SHELL_FUNCTION: %s\n" $CUSTOM_CALL_SHELL_FUNCTION
|
1119 |
b740b03b
|
Scott Ullrich
|
if [ -n "$SHOW_ENV" ]; then
|
1120 |
818b4379
|
Scott Ullrich
|
for LINE in `env | grep -v "terminal" | grep -v "PASS" | grep -v "NAME" | grep -v "USER" | grep -v "SSH" | grep -v "GROUP" | grep -v "HOST"`; do
|
1121 |
4e2ff3ee
|
Scott Ullrich
|
echo "SHOW_ENV: $LINE"
|
1122 |
b740b03b
|
Scott Ullrich
|
done
|
1123 |
|
|
fi
|
1124 |
f8b2df4a
|
Scott Ullrich
|
echo
|
1125 |
d1b4f5e3
|
Scott Ullrich
|
|
1126 |
3c740eeb
|
Scott Ullrich
|
}
|
1127 |
|
|
|
1128 |
5ce63e88
|
Ermal
|
# This updates the pfSense sources
|
1129 |
1205e00b
|
Ermal
|
update_pfSense_repository() {
|
1130 |
ccc87ea5
|
Ermal
|
if [ ! -d "${GIT_REPO_DIR}" ]; then
|
1131 |
|
|
echo ">>> Creating ${GIT_REPO_DIR}"
|
1132 |
|
|
mkdir -p ${GIT_REPO_DIR}
|
1133 |
|
|
fi
|
1134 |
060734ab
|
Ermal
|
|
1135 |
ea3049df
|
Ermal
|
OLDPWD=`pwd`
|
1136 |
|
|
|
1137 |
060734ab
|
Ermal
|
echo ">>> Using GIT to checkout ${PFSENSETAG}"
|
1138 |
|
|
echo -n ">>> "
|
1139 |
|
|
|
1140 |
4d10750d
|
Ermal
|
if [ ! -d "${GIT_REPO_DIR}/pfSenseGITREPO/.git" ]; then
|
1141 |
e339e8a7
|
Ermal
|
echo -n ">>> Cloning ${GIT_REPO_PFSENSE} ..."
|
1142 |
|
|
(cd ${GIT_REPO_DIR} && /usr/local/bin/git clone ${GIT_REPO_PFSENSE} pfSenseGITREPO) 2>&1 | egrep -B3 -A3 -wi '(error)'
|
1143 |
ccc87ea5
|
Ermal
|
if [ -d "${GIT_REPO_DIR}/pfSenseGITREPO" ]; then
|
1144 |
|
|
if [ ! -d "${GIT_REPO_DIR}/pfSenseGITREPO/conf.default" ]; then
|
1145 |
c8969afc
|
Ermal
|
echo
|
1146 |
|
|
echo "!!!! An error occured while checking out pfSense"
|
1147 |
ccc87ea5
|
Ermal
|
echo " Could not locate ${GIT_REPO_DIR}/pfSenseGITREPO/conf.default"
|
1148 |
c8969afc
|
Ermal
|
echo
|
1149 |
|
|
print_error_pfS
|
1150 |
|
|
kill $$
|
1151 |
ea659bdb
|
Bill Marquette
|
fi
|
1152 |
ccc87ea5
|
Ermal
|
else
|
1153 |
|
|
echo
|
1154 |
|
|
echo "!!!! An error occured while checking out pfSense"
|
1155 |
|
|
echo " Could not locate ${GIT_REPO_DIR}/pfSenseGITREPO"
|
1156 |
|
|
echo
|
1157 |
6a30cc43
|
Scott Ullrich
|
print_error_pfS
|
1158 |
ccc87ea5
|
Ermal
|
kill $$
|
1159 |
9f6dcb75
|
Scott Ullrich
|
fi
|
1160 |
ccc87ea5
|
Ermal
|
echo "Done!"
|
1161 |
a9a4557e
|
Ermal
|
else
|
1162 |
|
|
# Fetch an update of the repository
|
1163 |
|
|
# Proper branch checkout will be done from checkout_pfSense_git
|
1164 |
f67ce519
|
Ermal
|
( cd ${GIT_REPO_DIR}/pfSenseGITREPO && git checkout master; git fetch origin; git reset --hard; git clean -fxd; git rebase origin ) 2>&1 | grep -C3 -i 'error'
|
1165 |
ccc87ea5
|
Ermal
|
fi
|
1166 |
|
|
checkout_pfSense_git
|
1167 |
|
|
if [ $? != 0 ]; then
|
1168 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something went wrong while checking out GIT."
|
1169 |
ccc87ea5
|
Ermal
|
print_error_pfS
|
1170 |
eff0acbd
|
Scott Ullrich
|
fi
|
1171 |
ea3049df
|
Ermal
|
|
1172 |
|
|
cd $OLDPWD
|
1173 |
|
|
unset OLDPWD
|
1174 |
57f7433c
|
Dario Freni
|
}
|
1175 |
|
|
|
1176 |
aa0bbaae
|
Scott Ullrich
|
# This builds FreeBSD (make buildworld)
|
1177 |
859b069b
|
Ermal
|
# Imported from FreeSBIE
|
1178 |
3f734d74
|
Scott Ullrich
|
make_world() {
|
1179 |
649d5a0f
|
sullrich
|
|
1180 |
9f2a340a
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/buildworld.${TARGET}
|
1181 |
859b069b
|
Ermal
|
if [ -n "${NO_BUILDWORLD:-}" ]; then
|
1182 |
|
|
echo ">>> NO_BUILDWORLD set, skipping build" | tee -a ${LOGFILE}
|
1183 |
|
|
return
|
1184 |
|
|
fi
|
1185 |
|
|
|
1186 |
|
|
export MAKE_CONF="__MAKE_CONF=$MAKE_CONF"
|
1187 |
|
|
|
1188 |
|
|
if [ ! -z ${MAKEOBJDIRPREFIX:-} ]; then
|
1189 |
49f8a0b3
|
Ermal
|
# FreeBSD 8 has issues with putting this in MAKE opt rather than environment
|
1190 |
|
|
#export MAKE_CONF="${MAKE_CONF} MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}"
|
1191 |
859b069b
|
Ermal
|
mkdir -p $MAKEOBJDIRPREFIX
|
1192 |
|
|
fi
|
1193 |
|
|
|
1194 |
|
|
# Check if the world and kernel are already built and set
|
1195 |
|
|
# the NO variables accordingly
|
1196 |
|
|
if [ -d "${MAKEOBJDIRPREFIX}" ]; then
|
1197 |
|
|
ISINSTALLED=`find ${MAKEOBJDIRPREFIX}/ -name init | wc -l`
|
1198 |
|
|
if [ "$ISINSTALLED" -gt 0 ]; then
|
1199 |
8c5d3d1e
|
Ermal
|
export MAKE_CONF="${MAKE_CONF} NO_CLEAN=yes"
|
1200 |
03de72f3
|
Ermal
|
fi
|
1201 |
e456a4b3
|
sullrich
|
fi
|
1202 |
3f734d74
|
Scott Ullrich
|
|
1203 |
3714bc63
|
Ermal
|
if [ -z "${TARGET}" -o "${BUILDER_HOST_TARGET}" = "${TARGET}" ]; then
|
1204 |
68c6eeb1
|
Ermal
|
export MAKE_CONF="${MAKE_CONF} WITHOUT_CROSS_COMPILER=yes"
|
1205 |
8c57777c
|
Ermal
|
else
|
1206 |
8c5d3d1e
|
Ermal
|
if [ -f ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}/${SRCDIR}/tmp/usr/bin/cc ]; then
|
1207 |
|
|
export MAKE_CONF="${MAKE_CONF} NO_CLEAN=yes "
|
1208 |
|
|
fi
|
1209 |
57ea07f8
|
Ermal
|
if [ "${TARGET}" = "mips" ]; then
|
1210 |
|
|
MAKEJ_WORLD=""
|
1211 |
|
|
fi
|
1212 |
8c5d3d1e
|
Ermal
|
echo "** --------------------------------------------- ***"
|
1213 |
8c57777c
|
Ermal
|
echo ">>> Cross compiling settings defined building environment." | tee -a ${LOGFILE}
|
1214 |
|
|
echo ">>> Building toolchain for ${TARGET} architecture... (Starting - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1215 |
38f525a4
|
Ermal
|
echo ">>> Builder is running the command: env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${MAKEOPT} ${MAKE_CONF} SRCCONF=${SRC_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} toolchain" | tee -a ${LOGFILE}
|
1216 |
a3cd3fea
|
Ermal
|
if [ -z "${NO_BUILDTOOLCHAIN}" ]; then
|
1217 |
2937fd6d
|
Ermal
|
(cd $SRCDIR; env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${MAKEOPT} ${MAKE_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} toolchain || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
1218 |
a3cd3fea
|
Ermal
|
cd $BUILDER_SCRIPTS
|
1219 |
|
|
echo ">>> Building toolchain for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1220 |
|
|
else
|
1221 |
|
|
echo ">>> NO_BUILDTOOLCHAIN set SKIPPING - Building toolchain for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1222 |
|
|
fi
|
1223 |
8c57777c
|
Ermal
|
|
1224 |
|
|
echo ">>> Building kernel-toolchain for ${TARGET} architecture... (Starting - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1225 |
38f525a4
|
Ermal
|
echo ">>> Builder is running the command: env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${MAKEOPT} ${MAKE_CONF} SRCCONF=${SRC_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} kernel-toolchain" | tee -a ${LOGFILE}
|
1226 |
a3cd3fea
|
Ermal
|
if [ -z "${NO_BUILDTOOLCHAIN}" ]; then
|
1227 |
2937fd6d
|
Ermal
|
(cd $SRCDIR; env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${MAKEOPT} ${MAKE_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} kernel-toolchain || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
1228 |
8c57777c
|
Ermal
|
cd $BUILDER_SCRIPTS
|
1229 |
a3cd3fea
|
Ermal
|
echo ">>> Building kernel-toolchain for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1230 |
|
|
else
|
1231 |
|
|
echo ">>> NO_BUILDTOOLCHAIN set SKIPPING - Building kernel-toolchain for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1232 |
|
|
fi
|
1233 |
0ce143cd
|
Ermal
|
echo "** --------------------------------------------- ***"
|
1234 |
68c6eeb1
|
Ermal
|
fi
|
1235 |
|
|
|
1236 |
859b069b
|
Ermal
|
# Set SRC_CONF variable if it's not already set.
|
1237 |
|
|
if [ -z "${SRC_CONF:-}" ]; then
|
1238 |
|
|
echo ">>> SRC_CONF is unset make sure this is what you want!" | tee -a ${LOGFILE}
|
1239 |
|
|
else
|
1240 |
|
|
echo ">>> Setting SRC_CONF to $SRC_CONF" | tee -a ${LOGFILE}
|
1241 |
1d218631
|
Scott Ullrich
|
fi
|
1242 |
c9de5069
|
Scott Ullrich
|
|
1243 |
859b069b
|
Ermal
|
echo ">>> LOGFILE set to $LOGFILE." | tee -a ${LOGFILE}
|
1244 |
9f2a340a
|
Ermal
|
makeargs="${MAKEOPT:-} ${MAKEJ_WORLD:-} ${MAKE_CONF} SRCCONF=${SRC_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
|
1245 |
|
|
echo ">>> Building world for ${TARGET} architecture... (Starting - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1246 |
859b069b
|
Ermal
|
echo ">>> Builder is running the command: env $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} buildworld" | tee -a ${LOGFILE}
|
1247 |
|
|
cd $SRCDIR
|
1248 |
4f293f30
|
Ermal
|
(env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} buildworld || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
1249 |
859b069b
|
Ermal
|
cd $BUILDER_SCRIPTS
|
1250 |
9f2a340a
|
Ermal
|
echo ">>> Building world for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1251 |
859b069b
|
Ermal
|
|
1252 |
c5643146
|
Ermal
|
OSRC_CONF=${SRC_CONF}
|
1253 |
ac8aac3e
|
Ermal
|
if [ -n "${SRC_CONF_INSTALL:-}" ]; then
|
1254 |
|
|
export SRC_CONF=$SRC_CONF_INSTALL
|
1255 |
|
|
fi
|
1256 |
|
|
|
1257 |
9f2a340a
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/installworld.${TARGET}
|
1258 |
859b069b
|
Ermal
|
echo ">>> LOGFILE set to $LOGFILE." | tee -a ${LOGFILE}
|
1259 |
|
|
# Create if cleaned up
|
1260 |
|
|
mkdir -p ${PFSENSESTAGEDIR}
|
1261 |
9f2a340a
|
Ermal
|
makeargs="${MAKEOPT:-} ${MAKEJ_WORLD:-} ${MAKE_CONF} SRCCONF=${SRC_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} DESTDIR=${PFSENSESTAGEDIR}"
|
1262 |
|
|
echo ">>> Installing world for ${TARGET} architecture... (Starting - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1263 |
859b069b
|
Ermal
|
echo ">>> Builder is running the command: env $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} installworld" | tee -a ${LOGFILE}
|
1264 |
|
|
cd $SRCDIR
|
1265 |
4f293f30
|
Ermal
|
(env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} installworld || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
1266 |
859b069b
|
Ermal
|
cd $BUILDER_SCRIPTS
|
1267 |
9f2a340a
|
Ermal
|
echo ">>> Installing world for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1268 |
903cee4a
|
Scott Ullrich
|
|
1269 |
9f2a340a
|
Ermal
|
makeargs="${MAKEOPT:-} ${MAKEJ_WORLD:-} ${MAKE_CONF} SRCCONF=${SRC_CONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} DESTDIR=${PFSENSESTAGEDIR}"
|
1270 |
|
|
echo ">>> Distribution world for ${TARGET} architecture... (Starting - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1271 |
859b069b
|
Ermal
|
echo ">>> Builder is running the command: env $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} distribution " | tee -a ${LOGFILE}
|
1272 |
|
|
cd $SRCDIR
|
1273 |
4f293f30
|
Ermal
|
(env MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX} $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} distribution || print_error_pfS;) | egrep '^>>>' | tee -a ${LOGFILE}
|
1274 |
859b069b
|
Ermal
|
cd $BUILDER_SCRIPTS
|
1275 |
9f2a340a
|
Ermal
|
echo ">>> Distribution world for ${TARGET} architecture... (Finished - `LC_ALL=C date`)" | tee -a ${LOGFILE}
|
1276 |
859b069b
|
Ermal
|
|
1277 |
|
|
unset MAKE_CONF
|
1278 |
|
|
unset makeargs
|
1279 |
c5643146
|
Ermal
|
|
1280 |
859b069b
|
Ermal
|
SRC_CONF=${OSRC_CONF}
|
1281 |
3f734d74
|
Scott Ullrich
|
}
|
1282 |
66700206
|
Scott Ullrich
|
|
1283 |
aa0bbaae
|
Scott Ullrich
|
# This routine originated in nanobsd.sh
|
1284 |
66700206
|
Scott Ullrich
|
FlashDevice () {
|
1285 |
1bce42bf
|
Scott Ullrich
|
a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
|
1286 |
|
|
a2=`echo $2 | tr '[:upper:]' '[:lower:]'`
|
1287 |
|
|
case $a1 in
|
1288 |
|
|
integral)
|
1289 |
|
|
# Source: mich@FreeBSD.org
|
1290 |
|
|
case $a2 in
|
1291 |
eaa938e6
|
Ermal
|
256|256m|256mb)
|
1292 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 259596288 / 512`
|
1293 |
|
|
NANO_HEADS=16
|
1294 |
|
|
NANO_SECTS=63
|
1295 |
|
|
;;
|
1296 |
|
|
*)
|
1297 |
|
|
echo "Unknown Integral i-Pro Flash capacity"
|
1298 |
|
|
exit 2
|
1299 |
|
|
;;
|
1300 |
|
|
esac
|
1301 |
|
|
;;
|
1302 |
|
|
memorycorp)
|
1303 |
|
|
# Source: simon@FreeBSD.org
|
1304 |
|
|
case $a2 in
|
1305 |
eaa938e6
|
Ermal
|
512|512m|512mb)
|
1306 |
1bce42bf
|
Scott Ullrich
|
# MC512CFLS2
|
1307 |
|
|
NANO_MEDIASIZE=`expr 519192576 / 512`
|
1308 |
|
|
NANO_HEADS=16
|
1309 |
|
|
NANO_SECTS=63
|
1310 |
|
|
;;
|
1311 |
|
|
*)
|
1312 |
|
|
echo "Unknown Memory Corp Flash capacity"
|
1313 |
|
|
exit 2
|
1314 |
|
|
;;
|
1315 |
|
|
esac
|
1316 |
|
|
;;
|
1317 |
|
|
sandisk)
|
1318 |
|
|
# Source:
|
1319 |
|
|
# SanDisk CompactFlash Memory Card
|
1320 |
|
|
# Product Manual
|
1321 |
|
|
# Version 10.9
|
1322 |
|
|
# Document No. 20-10-00038
|
1323 |
|
|
# April 2005
|
1324 |
98b1c984
|
Renato Botelho
|
# Table 2-7
|
1325 |
1bce42bf
|
Scott Ullrich
|
# NB: notice math error in SDCFJ-4096-388 line.
|
1326 |
|
|
#
|
1327 |
|
|
case $a2 in
|
1328 |
eaa938e6
|
Ermal
|
32|32m|32mb)
|
1329 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 32112640 / 512`
|
1330 |
|
|
NANO_HEADS=4
|
1331 |
|
|
NANO_SECTS=32
|
1332 |
|
|
;;
|
1333 |
eaa938e6
|
Ermal
|
64|64m|64mb)
|
1334 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 64225280 / 512`
|
1335 |
|
|
NANO_HEADS=8
|
1336 |
|
|
NANO_SECTS=32
|
1337 |
|
|
;;
|
1338 |
eaa938e6
|
Ermal
|
128|128m|128mb)
|
1339 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 128450560 / 512`
|
1340 |
|
|
NANO_HEADS=8
|
1341 |
|
|
NANO_SECTS=32
|
1342 |
|
|
;;
|
1343 |
eaa938e6
|
Ermal
|
256|256m|256mb)
|
1344 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 256901120 / 512`
|
1345 |
|
|
NANO_HEADS=16
|
1346 |
|
|
NANO_SECTS=32
|
1347 |
|
|
;;
|
1348 |
eaa938e6
|
Ermal
|
512|512m|512mb)
|
1349 |
1bce42bf
|
Scott Ullrich
|
NANO_MEDIASIZE=`expr 512483328 / 512`
|
1350 |
|
|
NANO_HEADS=16
|
1351 |
|
|
NANO_SECTS=63
|
1352 |
|
|
;;
|
1353 |
eaa938e6
|
Ermal
|
1024|1024m|1024mb|1g)
|
1354 |
748dd221
|
jim-p
|
NANO_MEDIASIZE=`expr 997129216 / 512`
|
1355 |
1bce42bf
|
Scott Ullrich
|
NANO_HEADS=16
|
1356 |
|
|
NANO_SECTS=63
|
1357 |
|
|
;;
|
1358 |
eaa938e6
|
Ermal
|
2048|2048m|2048mb|2g)
|
1359 |
748dd221
|
jim-p
|
NANO_MEDIASIZE=`expr 1989999616 / 512`
|
1360 |
1bce42bf
|
Scott Ullrich
|
NANO_HEADS=16
|
1361 |
|
|
NANO_SECTS=63
|
1362 |
|
|
;;
|
1363 |
eaa938e6
|
Ermal
|
3670|3670m|3670mb|3.5g)
|
1364 |
b5760b5d
|
jim-p
|
NANO_MEDIASIZE=`expr -e 3758096384 / 512`
|
1365 |
|
|
NANO_HEADS=16
|
1366 |
|
|
NANO_SECTS=63
|
1367 |
|
|
;;
|
1368 |
eaa938e6
|
Ermal
|
4096|4096m|4096mb|4g)
|
1369 |
748dd221
|
jim-p
|
NANO_MEDIASIZE=`expr -e 3989999616 / 512`
|
1370 |
1bce42bf
|
Scott Ullrich
|
NANO_HEADS=16
|
1371 |
|
|
NANO_SECTS=63
|
1372 |
|
|
;;
|
1373 |
eaa938e6
|
Ermal
|
8192|8192m|8192mb|8g)
|
1374 |
748dd221
|
jim-p
|
NANO_MEDIASIZE=`expr -e 7989999616 / 512`
|
1375 |
4682e06d
|
jim-p
|
NANO_HEADS=16
|
1376 |
|
|
NANO_SECTS=63
|
1377 |
|
|
;;
|
1378 |
eaa938e6
|
Ermal
|
16384|16384m|16384mb|16g)
|
1379 |
748dd221
|
jim-p
|
NANO_MEDIASIZE=`expr -e 15989999616 / 512`
|
1380 |
4682e06d
|
jim-p
|
NANO_HEADS=16
|
1381 |
|
|
NANO_SECTS=63
|
1382 |
|
|
;;
|
1383 |
1bce42bf
|
Scott Ullrich
|
*)
|
1384 |
|
|
echo "Unknown Sandisk Flash capacity"
|
1385 |
|
|
exit 2
|
1386 |
|
|
;;
|
1387 |
|
|
esac
|
1388 |
|
|
;;
|
1389 |
|
|
siliconsystems)
|
1390 |
|
|
case $a2 in
|
1391 |
|
|
4096|4g)
|
1392 |
|
|
NANO_MEDIASIZE=`expr -e 4224761856 / 512`
|
1393 |
|
|
NANO_HEADS=16
|
1394 |
|
|
NANO_SECTS=63
|
1395 |
|
|
;;
|
1396 |
|
|
*)
|
1397 |
|
|
echo "Unknown SiliconSystems Flash capacity"
|
1398 |
|
|
exit 2
|
1399 |
|
|
;;
|
1400 |
|
|
esac
|
1401 |
|
|
;;
|
1402 |
|
|
soekris)
|
1403 |
|
|
case $a2 in
|
1404 |
|
|
net4526 | 4526 | net4826 | 4826 | 64 | 64mb)
|
1405 |
|
|
NANO_MEDIASIZE=125056
|
1406 |
|
|
NANO_HEADS=4
|
1407 |
|
|
NANO_SECTS=32
|
1408 |
|
|
;;
|
1409 |
|
|
*)
|
1410 |
|
|
echo "Unknown Soekris Flash capacity"
|
1411 |
|
|
exit 2
|
1412 |
|
|
;;
|
1413 |
|
|
esac
|
1414 |
|
|
;;
|
1415 |
4d6fdbb8
|
Scott Ullrich
|
generic-hdd)
|
1416 |
|
|
case $a2 in
|
1417 |
|
|
4096|4g)
|
1418 |
|
|
NANO_HEADS=64
|
1419 |
|
|
NANO_SECTS=32
|
1420 |
|
|
NANO_MEDIASIZE="7812500"
|
1421 |
|
|
;;
|
1422 |
|
|
*)
|
1423 |
|
|
echo "Unknwon generic-hdd capacity"
|
1424 |
|
|
exit 2
|
1425 |
|
|
;;
|
1426 |
|
|
esac
|
1427 |
98b1c984
|
Renato Botelho
|
;;
|
1428 |
1bce42bf
|
Scott Ullrich
|
transcend)
|
1429 |
|
|
case $a2 in
|
1430 |
|
|
dom064m)
|
1431 |
|
|
NANO_MEDIASIZE=125184
|
1432 |
|
|
NANO_HEADS=4
|
1433 |
|
|
NANO_SECTS=32
|
1434 |
|
|
;;
|
1435 |
|
|
2048|2g)
|
1436 |
80ff17b3
|
Warren Baker
|
NANO_MEDIASIZE=3980592
|
1437 |
1bce42bf
|
Scott Ullrich
|
NANO_HEADS=16
|
1438 |
80ff17b3
|
Warren Baker
|
NANO_SECTS=63
|
1439 |
1bce42bf
|
Scott Ullrich
|
;;
|
1440 |
|
|
*)
|
1441 |
|
|
echo "Unknown Transcend Flash capacity"
|
1442 |
|
|
exit 2
|
1443 |
|
|
;;
|
1444 |
|
|
esac
|
1445 |
|
|
;;
|
1446 |
|
|
*)
|
1447 |
|
|
echo "Unknown Flash manufacturer"
|
1448 |
|
|
exit 2
|
1449 |
|
|
;;
|
1450 |
|
|
esac
|
1451 |
4d6fdbb8
|
Scott Ullrich
|
echo ">>> [nanoo] $1 $2"
|
1452 |
|
|
echo ">>> [nanoo] NANO_MEDIASIZE: $NANO_MEDIASIZE"
|
1453 |
|
|
echo ">>> [nanoo] NANO_HEADS: $NANO_HEADS"
|
1454 |
|
|
echo ">>> [nanoo] NANO_SECTS: $NANO_SECTS"
|
1455 |
1341b026
|
Scott Ullrich
|
echo ">>> [nanoo] NANO_BOOT0CFG: $NANO_BOOT0CFG"
|
1456 |
66700206
|
Scott Ullrich
|
}
|
1457 |
|
|
|
1458 |
b346b7ff
|
Scott Ullrich
|
pprint() {
|
1459 |
b5b7f3ef
|
Ermal
|
echo $2 >> $BUILDER_LOGS/nanobsd_cmds.sh
|
1460 |
b346b7ff
|
Scott Ullrich
|
}
|
1461 |
|
|
|
1462 |
dd416214
|
Scott Ullrich
|
create_mips_diskimage()
|
1463 |
|
|
{
|
1464 |
36f8a201
|
Scott Ullrich
|
echo ">>> building NanoBSD disk image (mips)..."
|
1465 |
b5b7f3ef
|
Ermal
|
echo ">>> Log file can be found in $BUILDER_LOGS/nanobsd_cmds.sh"
|
1466 |
|
|
echo "`date`" > $BUILDER_LOGS/nanobsd_cmds.sh
|
1467 |
36f8a201
|
Scott Ullrich
|
|
1468 |
2476e16c
|
Scott Ullrich
|
NANO_MAKEFS="makefs -B big -o bsize=4096,fsize=512,density=8192,optimization=space"
|
1469 |
3c400ddf
|
Scott Ullrich
|
NANO_MD_BACKING="file"
|
1470 |
319d47c9
|
Scott Ullrich
|
NANO_BOOTLOADER="boot/boot0sio"
|
1471 |
859b069b
|
Ermal
|
NANO_WORLDDIR=${PFSENSEISODIR}/
|
1472 |
|
|
NANO_CFGDIR=${PFSENSEISODIR}/cf
|
1473 |
781ca2bd
|
Scott Ullrich
|
|
1474 |
dd416214
|
Scott Ullrich
|
pprint 2 "build diskimage"
|
1475 |
910af988
|
Scott Ullrich
|
pprint 3 "log: ${MAKEOBJDIRPREFIXFINAL}/_.di"
|
1476 |
2476e16c
|
Scott Ullrich
|
pprint 2 "NANO_MEDIASIZE: $NANO_MEDIASIZE"
|
1477 |
|
|
pprint 2 "NANO_IMAGES: $NANO_IMAGES"
|
1478 |
|
|
pprint 2 "NANO_SECTS: $NANO_SECTS"
|
1479 |
|
|
pprint 2 "NANO_HEADS: $NANO_HEADS"
|
1480 |
|
|
pprint 2 "NANO_CODESIZE: $NANO_CODESIZE"
|
1481 |
|
|
pprint 2 "NANO_CONFSIZE: $NANO_CONFSIZE"
|
1482 |
|
|
pprint 2 "NANO_DATASIZE: $NANO_DATASIZE"
|
1483 |
dd416214
|
Scott Ullrich
|
|
1484 |
d8dda5a2
|
Scott Ullrich
|
echo $NANO_MEDIASIZE \
|
1485 |
|
|
$NANO_IMAGES \
|
1486 |
|
|
$NANO_SECTS \
|
1487 |
|
|
$NANO_HEADS \
|
1488 |
|
|
$NANO_CODESIZE \
|
1489 |
|
|
$NANO_CONFSIZE \
|
1490 |
|
|
$NANO_DATASIZE |
|
1491 |
|
|
awk '
|
1492 |
|
|
{
|
1493 |
|
|
printf "# %s\n", $0
|
1494 |
|
|
|
1495 |
|
|
# size of cylinder in sectors
|
1496 |
|
|
cs = $3 * $4
|
1497 |
|
|
|
1498 |
|
|
# number of full cylinders on media
|
1499 |
|
|
cyl = int ($1 / cs)
|
1500 |
|
|
|
1501 |
|
|
# output fdisk geometry spec, truncate cyls to 1023
|
1502 |
|
|
if (cyl <= 1023)
|
1503 |
|
|
print "g c" cyl " h" $4 " s" $3
|
1504 |
|
|
else
|
1505 |
|
|
print "g c" 1023 " h" $4 " s" $3
|
1506 |
|
|
|
1507 |
|
|
if ($7 > 0) {
|
1508 |
|
|
# size of data partition in full cylinders
|
1509 |
|
|
dsl = int (($7 + cs - 1) / cs)
|
1510 |
|
|
} else {
|
1511 |
|
|
dsl = 0;
|
1512 |
|
|
}
|
1513 |
dd416214
|
Scott Ullrich
|
|
1514 |
d8dda5a2
|
Scott Ullrich
|
# size of config partition in full cylinders
|
1515 |
|
|
csl = int (($6 + cs - 1) / cs)
|
1516 |
|
|
|
1517 |
|
|
if ($5 == 0) {
|
1518 |
|
|
# size of image partition(s) in full cylinders
|
1519 |
|
|
isl = int ((cyl - dsl - csl) / $2)
|
1520 |
|
|
} else {
|
1521 |
|
|
isl = int (($5 + cs - 1) / cs)
|
1522 |
dd416214
|
Scott Ullrich
|
}
|
1523 |
d8dda5a2
|
Scott Ullrich
|
|
1524 |
|
|
# First image partition start at second track
|
1525 |
|
|
print "p 1 165 " $3, isl * cs - $3
|
1526 |
|
|
c = isl * cs;
|
1527 |
|
|
|
1528 |
|
|
# Second image partition (if any) also starts offset one
|
1529 |
|
|
# track to keep them identical.
|
1530 |
|
|
if ($2 > 1) {
|
1531 |
|
|
print "p 2 165 " $3 + c, isl * cs - $3
|
1532 |
|
|
c += isl * cs;
|
1533 |
|
|
}
|
1534 |
|
|
|
1535 |
|
|
# Config partition starts at cylinder boundary.
|
1536 |
|
|
print "p 3 165 " c, csl * cs
|
1537 |
|
|
c += csl * cs
|
1538 |
|
|
|
1539 |
|
|
# Data partition (if any) starts at cylinder boundary.
|
1540 |
|
|
if ($7 > 0) {
|
1541 |
|
|
print "p 4 165 " c, dsl * cs
|
1542 |
|
|
} else if ($7 < 0 && $1 > c) {
|
1543 |
|
|
print "p 4 165 " c, $1 - c
|
1544 |
|
|
} else if ($1 < c) {
|
1545 |
|
|
print "Disk space overcommitted by", \
|
1546 |
|
|
c - $1, "sectors" > "/dev/stderr"
|
1547 |
|
|
exit 2
|
1548 |
|
|
}
|
1549 |
|
|
|
1550 |
|
|
# Force slice 1 to be marked active. This is necessary
|
1551 |
|
|
# for booting the image from a USB device to work.
|
1552 |
|
|
print "a 1"
|
1553 |
|
|
}
|
1554 |
dd416214
|
Scott Ullrich
|
' > ${MAKEOBJDIRPREFIXFINAL}/_.fdisk
|
1555 |
|
|
|
1556 |
2476e16c
|
Scott Ullrich
|
pprint 2 "${MAKEOBJDIRPREFIXFINAL}/_.fdisk"
|
1557 |
f0535e64
|
Scott Ullrich
|
pprint 2 "`cat ${MAKEOBJDIRPREFIXFINAL}/_.fdisk`"
|
1558 |
2476e16c
|
Scott Ullrich
|
|
1559 |
3e5af59d
|
Scott Ullrich
|
IMG=${MAKEOBJDIRPREFIXFINAL}/nanobsd.full.img
|
1560 |
dd416214
|
Scott Ullrich
|
BS=${NANO_SECTS}b
|
1561 |
|
|
|
1562 |
|
|
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
|
1563 |
27dde9ac
|
Scott Ullrich
|
pprint 2 "Creating swap backing file ..."
|
1564 |
dd416214
|
Scott Ullrich
|
MD=`mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} -y ${NANO_HEADS}`
|
1565 |
3c400ddf
|
Scott Ullrich
|
pprint 2 "mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} -y ${NANO_HEADS}"
|
1566 |
dd416214
|
Scott Ullrich
|
else
|
1567 |
3ce5da65
|
Scott Ullrich
|
pprint 2 "Creating md backing file ${IMG} ..."
|
1568 |
dd416214
|
Scott Ullrich
|
_c=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
|
1569 |
c0945323
|
Seth Mos
|
pprint 2 "dd if=/dev/zero of=${IMG} bs=${BS} count=0 seek=${_c}"
|
1570 |
|
|
dd if=/dev/zero of=${IMG} bs=${BS} count=0 seek=${_c}
|
1571 |
dd416214
|
Scott Ullrich
|
pprint 2 "mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} -y ${NANO_HEADS}"
|
1572 |
|
|
MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} -y ${NANO_HEADS}`
|
1573 |
|
|
fi
|
1574 |
|
|
|
1575 |
dde60168
|
Scott Ullrich
|
trap "mdconfig -d -u $MD" 1 2 15 EXIT
|
1576 |
dd416214
|
Scott Ullrich
|
|
1577 |
dde60168
|
Scott Ullrich
|
pprint 2 "Write partition table ${MAKEOBJDIRPREFIXFINAL}/_.fdisk ..."
|
1578 |
dd416214
|
Scott Ullrich
|
FDISK=${MAKEOBJDIRPREFIXFINAL}/_.fdisk
|
1579 |
b9ca3f0e
|
Erik Fonnesbeck
|
pprint 2 "fdisk -i -f ${FDISK} ${MD}"
|
1580 |
|
|
fdisk -i -f ${FDISK} ${MD}
|
1581 |
dd416214
|
Scott Ullrich
|
pprint 2 "fdisk ${MD}"
|
1582 |
|
|
fdisk ${MD}
|
1583 |
|
|
|
1584 |
|
|
# Create first image
|
1585 |
7057707e
|
Scott Ullrich
|
IMG1=${MAKEOBJDIRPREFIXFINAL}/_.disk.image1
|
1586 |
3ce5da65
|
Scott Ullrich
|
pprint 2 "Create first image ${IMG1} ..."
|
1587 |
dd416214
|
Scott Ullrich
|
SIZE=`awk '/^p 1/ { print $5 "b" }' ${FDISK}`
|
1588 |
|
|
pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}"
|
1589 |
|
|
${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}
|
1590 |
f0535914
|
jim-p
|
pprint 2 "dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}"
|
1591 |
|
|
dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}
|
1592 |
50764c9a
|
Scott Ullrich
|
pprint 2 "tunefs -L pfsense0 /dev/${MD}s1"
|
1593 |
2476e16c
|
Scott Ullrich
|
tunefs -L pfsense0 /dev/${MD}s1
|
1594 |
dd416214
|
Scott Ullrich
|
|
1595 |
|
|
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
|
1596 |
7057707e
|
Scott Ullrich
|
IMG2=${MAKEOBJDIRPREFIXFINAL}/_.disk.image2
|
1597 |
3ce5da65
|
Scott Ullrich
|
pprint 2 "Create second image ${IMG2}..."
|
1598 |
27dde9ac
|
Scott Ullrich
|
for f in ${NANO_WORLDDIR}/etc/fstab
|
1599 |
dd416214
|
Scott Ullrich
|
do
|
1600 |
b9ca3f0e
|
Erik Fonnesbeck
|
sed -i "" "s/${NANO_DRIVE}s1/${NANO_DRIVE}s2/g" $f
|
1601 |
dd416214
|
Scott Ullrich
|
done
|
1602 |
|
|
SIZE=`awk '/^p 2/ { print $5 "b" }' ${FDISK}`
|
1603 |
|
|
pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}"
|
1604 |
|
|
${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}
|
1605 |
f0535914
|
jim-p
|
pprint 2 "dd if=${IMG2} of=/dev/${MD}s2 bs=${BS}"
|
1606 |
|
|
dd if=${IMG1} of=/dev/${MD}s2 bs=${BS}
|
1607 |
dd416214
|
Scott Ullrich
|
fi
|
1608 |
|
|
|
1609 |
|
|
# Create Config slice
|
1610 |
2476e16c
|
Scott Ullrich
|
if [ $NANO_CONFSIZE -gt 0 ] ; then
|
1611 |
|
|
CFG=${MAKEOBJDIRPREFIXFINAL}/_.disk.cfg
|
1612 |
3ce5da65
|
Scott Ullrich
|
pprint 2 "Creating config partition ${CFG}..."
|
1613 |
2476e16c
|
Scott Ullrich
|
SIZE=`awk '/^p 3/ { print $5 "b" }' ${FDISK}`
|
1614 |
|
|
pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}"
|
1615 |
|
|
${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}
|
1616 |
f0535914
|
jim-p
|
pprint 2 "dd if=${CFG} of=/dev/${MD}s3 bs=${BS}"
|
1617 |
|
|
dd if=${CFG} of=/dev/${MD}s3 bs=${BS}
|
1618 |
2476e16c
|
Scott Ullrich
|
pprint 2 "tunefs -L cf /dev/${MD}s3"
|
1619 |
|
|
tunefs -L cf /dev/${MD}s3
|
1620 |
|
|
pprint 2 "rm ${CFG}"
|
1621 |
|
|
rm ${CFG}; CFG= # NB: disable printing below
|
1622 |
|
|
else
|
1623 |
3ce5da65
|
Scott Ullrich
|
pprint 2 ">>> [nanoo] NANO_CONFSIZE is not set. Not adding a /conf partition.. You sure about this??"
|
1624 |
2476e16c
|
Scott Ullrich
|
fi
|
1625 |
dd416214
|
Scott Ullrich
|
|
1626 |
|
|
# Create Data slice, if any.
|
1627 |
883a304b
|
Scott Ullrich
|
# Note the changing of the variable to NANO_CONFSIZE
|
1628 |
|
|
# from NANO_DATASIZE. We also added glabel support
|
1629 |
|
|
# and populate the pfSense configuration from the /cf
|
1630 |
859b069b
|
Ermal
|
# directory located in PFSENSEISODIR
|
1631 |
883a304b
|
Scott Ullrich
|
#if [ $NANO_CONFSIZE -gt 0 ] ; then
|
1632 |
|
|
# DATA=${MAKEOBJDIRPREFIXFINAL}/_.disk.data
|
1633 |
|
|
# echo ""; echo "Creating data partition ${DATA}..."
|
1634 |
|
|
# SIZE=`awk '/^p 4/ { print $5 "b" }' ${FDISK}`
|
1635 |
|
|
# # XXX: fill from where ?
|
1636 |
|
|
# pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty"
|
1637 |
|
|
# ${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty
|
1638 |
f0535914
|
jim-p
|
# pprint 2 "dd if=${DATA} of=/dev/${MD}s4 bs=${BS}"
|
1639 |
|
|
# dd if=${DATA} of=/dev/${MD}s4 bs=${BS}
|
1640 |
883a304b
|
Scott Ullrich
|
# pprint 2 "rm ${DATA}"
|
1641 |
|
|
# rm ${DATA}; DATA= # NB: disable printing below
|
1642 |
|
|
#else
|
1643 |
|
|
# ">>> [nanoo] NANO_CONFSIZE is not set. Not adding a /conf partition.. You sure about this??"
|
1644 |
|
|
#fi
|
1645 |
dd416214
|
Scott Ullrich
|
|
1646 |
|
|
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
|
1647 |
3ce5da65
|
Scott Ullrich
|
pprint 2 "Writing out ${IMG}..."
|
1648 |
f0535914
|
jim-p
|
dd if=/dev/${MD} of=${IMG} bs=${BS}
|
1649 |
dd416214
|
Scott Ullrich
|
fi
|
1650 |
|
|
|
1651 |
77fcb40b
|
Scott Ullrich
|
pprint 2 "IMG1: $IMG1"
|
1652 |
|
|
pprint 2 "IMG2: $IMG2"
|
1653 |
dab4664d
|
Scott Ullrich
|
pprint 2 "`date`"
|
1654 |
21588818
|
Scott Ullrich
|
pprint 2 "Full disk: ${IMG}"
|
1655 |
|
|
pprint 2 "Primary partition: ${IMG1}"
|
1656 |
|
|
test "${IMG2}" && pprint 2 "2ndary partition: ${IMG2}"
|
1657 |
|
|
test "${CFG}" && pprint 2 "/cfg partition: ${CFG}"
|
1658 |
|
|
test "${DATA}" && pprint 2 "/data partition: ${DATA}"
|
1659 |
|
|
|
1660 |
e9bd24aa
|
Scott Ullrich
|
#) > ${MAKEOBJDIRPREFIXFINAL}/_.di 2>&1
|
1661 |
21588818
|
Scott Ullrich
|
|
1662 |
dd416214
|
Scott Ullrich
|
}
|
1663 |
|
|
|
1664 |
aa0bbaae
|
Scott Ullrich
|
# This routine originated in nanobsd.sh
|
1665 |
17bfb853
|
jim-p
|
create_nanobsd_diskimage () {
|
1666 |
adbddb0e
|
Ermal
|
if [ -z "${1}" ]; then
|
1667 |
|
|
echo ">>> ERROR: Type of image has not been specified"
|
1668 |
|
|
print_error_pfS
|
1669 |
|
|
fi
|
1670 |
|
|
if [ -z "${2}" ]; then
|
1671 |
|
|
echo ">>> ERROR: Size of image has not been specified"
|
1672 |
|
|
print_error_pfS
|
1673 |
|
|
fi
|
1674 |
dd416214
|
Scott Ullrich
|
|
1675 |
adbddb0e
|
Ermal
|
if [ "${1}" = "nanobsd" ]; then
|
1676 |
859b069b
|
Ermal
|
# It's serial
|
1677 |
|
|
export NANO_BOOTLOADER="boot/boot0sio"
|
1678 |
aef1b261
|
Ermal
|
elif [ "${1}" = "nanobsd-vga" ]; then
|
1679 |
859b069b
|
Ermal
|
# It's vga
|
1680 |
|
|
export NANO_BOOTLOADER="boot/boot0"
|
1681 |
adbddb0e
|
Ermal
|
else
|
1682 |
|
|
echo ">>> ERROR: Type of image to create unkown"
|
1683 |
|
|
print_error_pfS
|
1684 |
859b069b
|
Ermal
|
fi
|
1685 |
|
|
|
1686 |
378d60ac
|
Ermal
|
if [ -z "${2}" ]; then
|
1687 |
|
|
echo ">>> ERROR: Media size(s) not specified."
|
1688 |
|
|
print_error_pfS
|
1689 |
|
|
fi
|
1690 |
adbddb0e
|
Ermal
|
|
1691 |
378d60ac
|
Ermal
|
if [ -z "${FLASH_MODEL}" -o -z "${2}" ]; then
|
1692 |
|
|
echo ">>> ERROR: either FLASH_MODEL=${FLASH_MODEL} or FLASH_SIZE=${2} is not set."
|
1693 |
abd356f9
|
Ermal
|
print_error_pfS
|
1694 |
|
|
fi
|
1695 |
|
|
|
1696 |
b4745611
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/${1}.${TARGET}
|
1697 |
|
|
# Prepare folder to be put in image
|
1698 |
|
|
customize_stagearea_for_image "${1}"
|
1699 |
180165d3
|
Ermal
|
install_default_kernel ${DEFAULT_KERNEL} "no"
|
1700 |
b4745611
|
Ermal
|
|
1701 |
|
|
# Must be run after customize_stagearea_for_image
|
1702 |
|
|
cust_fixup_nanobsd ${1} $NANO_MEDIASIZE
|
1703 |
|
|
|
1704 |
d13406a5
|
Ermal
|
for _NANO_MEDIASIZE in ${2}; do
|
1705 |
|
|
if [ -z "${_NANO_MEDIASIZE}" ]; then
|
1706 |
378d60ac
|
Ermal
|
continue;
|
1707 |
|
|
fi
|
1708 |
abd356f9
|
Ermal
|
|
1709 |
d13406a5
|
Ermal
|
echo ">>> building NanoBSD(${1}) disk image with size ${_NANO_MEDIASIZE} for platform (${TARGET})..." | tee -a ${LOGFILE}
|
1710 |
378d60ac
|
Ermal
|
echo "" > $BUILDER_LOGS/nanobsd_cmds.sh
|
1711 |
|
|
|
1712 |
d13406a5
|
Ermal
|
IMG="${MAKEOBJDIRPREFIXFINAL}/${PRODUCT_NAME}-${PFSENSE_VERSION}-${_NANO_MEDIASIZE}-${TARGET}-${1}-${DATESTRING}.img"
|
1713 |
|
|
IMGUPDATE="${MAKEOBJDIRPREFIXFINAL}/${PRODUCT_NAME}-${PFSENSE_VERSION}-${_NANO_MEDIASIZE}-${TARGET}-${1}-upgrade-${DATESTRING}.img"
|
1714 |
378d60ac
|
Ermal
|
|
1715 |
d13406a5
|
Ermal
|
FlashDevice ${FLASH_MODEL} ${_NANO_MEDIASIZE}
|
1716 |
378d60ac
|
Ermal
|
|
1717 |
d13406a5
|
Ermal
|
# These are defined in FlashDevice and on builder_default.sh
|
1718 |
378d60ac
|
Ermal
|
echo $NANO_MEDIASIZE \
|
1719 |
|
|
$NANO_IMAGES \
|
1720 |
|
|
$NANO_SECTS \
|
1721 |
|
|
$NANO_HEADS \
|
1722 |
|
|
$NANO_CODESIZE \
|
1723 |
|
|
$NANO_CONFSIZE \
|
1724 |
|
|
$NANO_DATASIZE |
|
1725 |
509e87d3
|
Scott Ullrich
|
awk '
|
1726 |
|
|
{
|
1727 |
|
|
printf "# %s\n", $0
|
1728 |
|
|
|
1729 |
|
|
# size of cylinder in sectors
|
1730 |
|
|
cs = $3 * $4
|
1731 |
|
|
|
1732 |
|
|
# number of full cylinders on media
|
1733 |
|
|
cyl = int ($1 / cs)
|
1734 |
|
|
|
1735 |
|
|
# output fdisk geometry spec, truncate cyls to 1023
|
1736 |
|
|
if (cyl <= 1023)
|
1737 |
|
|
print "g c" cyl " h" $4 " s" $3
|
1738 |
|
|
else
|
1739 |
|
|
print "g c" 1023 " h" $4 " s" $3
|
1740 |
|
|
|
1741 |
98b1c984
|
Renato Botelho
|
if ($7 > 0) {
|
1742 |
509e87d3
|
Scott Ullrich
|
# size of data partition in full cylinders
|
1743 |
|
|
dsl = int (($7 + cs - 1) / cs)
|
1744 |
|
|
} else {
|
1745 |
|
|
dsl = 0;
|
1746 |
66700206
|
Scott Ullrich
|
}
|
1747 |
509e87d3
|
Scott Ullrich
|
|
1748 |
|
|
# size of config partition in full cylinders
|
1749 |
|
|
csl = int (($6 + cs - 1) / cs)
|
1750 |
|
|
|
1751 |
|
|
if ($5 == 0) {
|
1752 |
|
|
# size of image partition(s) in full cylinders
|
1753 |
|
|
isl = int ((cyl - dsl - csl) / $2)
|
1754 |
|
|
} else {
|
1755 |
|
|
isl = int (($5 + cs - 1) / cs)
|
1756 |
|
|
}
|
1757 |
|
|
|
1758 |
|
|
# First image partition start at second track
|
1759 |
|
|
print "p 1 165 " $3, isl * cs - $3
|
1760 |
|
|
c = isl * cs;
|
1761 |
|
|
|
1762 |
98b1c984
|
Renato Botelho
|
# Second image partition (if any) also starts offset one
|
1763 |
509e87d3
|
Scott Ullrich
|
# track to keep them identical.
|
1764 |
|
|
if ($2 > 1) {
|
1765 |
|
|
print "p 2 165 " $3 + c, isl * cs - $3
|
1766 |
|
|
c += isl * cs;
|
1767 |
|
|
}
|
1768 |
|
|
|
1769 |
|
|
# Config partition starts at cylinder boundary.
|
1770 |
|
|
print "p 3 165 " c, csl * cs
|
1771 |
|
|
c += csl * cs
|
1772 |
|
|
|
1773 |
|
|
# Data partition (if any) starts at cylinder boundary.
|
1774 |
|
|
if ($7 > 0) {
|
1775 |
|
|
print "p 4 165 " c, dsl * cs
|
1776 |
|
|
} else if ($7 < 0 && $1 > c) {
|
1777 |
|
|
print "p 4 165 " c, $1 - c
|
1778 |
|
|
} else if ($1 < c) {
|
1779 |
|
|
print "Disk space overcommitted by", \
|
1780 |
|
|
c - $1, "sectors" > "/dev/stderr"
|
1781 |
|
|
exit 2
|
1782 |
|
|
}
|
1783 |
|
|
|
1784 |
|
|
# Force slice 1 to be marked active. This is necessary
|
1785 |
|
|
# for booting the image from a USB device to work.
|
1786 |
|
|
print "a 1"
|
1787 |
|
|
}
|
1788 |
e023fdda
|
Scott Ullrich
|
' > ${MAKEOBJDIRPREFIXFINAL}/_.fdisk
|
1789 |
66700206
|
Scott Ullrich
|
|
1790 |
378d60ac
|
Ermal
|
MNT=${MAKEOBJDIRPREFIXFINAL}/_.mnt
|
1791 |
|
|
mkdir -p ${MNT}
|
1792 |
66700206
|
Scott Ullrich
|
|
1793 |
378d60ac
|
Ermal
|
dd if=/dev/zero of=${IMG} bs=${NANO_SECTS}b \
|
1794 |
|
|
count=0 seek=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}` 2>&1 >> ${LOGFILE}
|
1795 |
90fabf95
|
Ermal
|
|
1796 |
df310507
|
Ermal
|
MD=$(mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} -y ${NANO_HEADS})
|
1797 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1798 |
66700206
|
Scott Ullrich
|
|
1799 |
378d60ac
|
Ermal
|
fdisk -i -f ${MAKEOBJDIRPREFIXFINAL}/_.fdisk ${MD} 2>&1 >> ${LOGFILE}
|
1800 |
|
|
fdisk ${MD} 2>&1 >> ${LOGFILE}
|
1801 |
90fabf95
|
Ermal
|
|
1802 |
378d60ac
|
Ermal
|
boot0cfg -B -b ${PFSENSEISODIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD} 2>&1 >> ${LOGFILE}
|
1803 |
859b069b
|
Ermal
|
|
1804 |
378d60ac
|
Ermal
|
# Create first image
|
1805 |
|
|
bsdlabel -m i386 -w -B -b ${PFSENSEISODIR}/boot/boot ${MD}s1 2>&1 >> ${LOGFILE}
|
1806 |
|
|
bsdlabel -m i386 ${MD}s1 2>&1 >> ${LOGFILE}
|
1807 |
|
|
newfs -L pfsense0 ${NANO_NEWFS} /dev/${MD}s1a 2>&1 >> ${LOGFILE}
|
1808 |
|
|
mount /dev/ufs/pfsense0 ${MNT}
|
1809 |
859b069b
|
Ermal
|
if [ $? -ne 0 ]; then
|
1810 |
378d60ac
|
Ermal
|
echo ">>> ERROR: Something wrong happened during mount of first slice image creation. STOPPING!" | tee -a ${LOGFILE}
|
1811 |
859b069b
|
Ermal
|
print_error_pfS
|
1812 |
|
|
kill $$
|
1813 |
|
|
fi
|
1814 |
90fabf95
|
Ermal
|
# Consider the unmounting as well
|
1815 |
d13406a5
|
Ermal
|
trap "umount /dev/ufs/pfsense0; mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1816 |
90fabf95
|
Ermal
|
|
1817 |
859b069b
|
Ermal
|
clone_directory_contents ${PFSENSEISODIR} ${MNT}
|
1818 |
378d60ac
|
Ermal
|
|
1819 |
d13406a5
|
Ermal
|
# Set NanoBSD image size
|
1820 |
|
|
echo "${_NANO_MEDIASIZE}" > ${MNT}/etc/nanosize.txt
|
1821 |
71daa7b1
|
Ermal
|
rm -f $MNT/conf.default/config.xml 2>/dev/null
|
1822 |
|
|
rm -f $MNT/cf/conf/* 2>/dev/null
|
1823 |
d13406a5
|
Ermal
|
|
1824 |
|
|
echo "/dev/ufs/pfsense0 / ufs ro,sync,noatime 1 1" > ${MNT}/etc/fstab
|
1825 |
|
|
if [ $NANO_CONFSIZE -gt 0 ] ; then
|
1826 |
|
|
echo "/dev/ufs/cf /cf ufs ro,sync,noatime 1 1" >> ${MNT}/etc/fstab
|
1827 |
|
|
fi
|
1828 |
|
|
|
1829 |
|
|
umount ${MNT}
|
1830 |
|
|
sync
|
1831 |
378d60ac
|
Ermal
|
# Restore the original trap
|
1832 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1833 |
98b1c984
|
Renato Botelho
|
|
1834 |
378d60ac
|
Ermal
|
# Setting NANO_IMAGES to 1 and NANO_INIT_IMG2 will tell
|
1835 |
|
|
# NanoBSD to only create one partition. We default to 2
|
1836 |
|
|
# partitions in case anything happens to the first the
|
1837 |
|
|
# operator can boot from the 2nd and should be OK.
|
1838 |
|
|
|
1839 |
|
|
# Before just going to use dd for duplicate think!
|
1840 |
|
|
# The images are created as sparse so lets take advantage
|
1841 |
|
|
# of that by just exec some commands.
|
1842 |
|
|
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
|
1843 |
|
|
# Duplicate to second image (if present)
|
1844 |
385877a8
|
Renato Botelho
|
echo ">>> Creating NanoBSD second slice by duplicating first slice." | tee -a ${LOGFILE}
|
1845 |
378d60ac
|
Ermal
|
# Create second image
|
1846 |
d13406a5
|
Ermal
|
dd if=/dev/${MD}s1 of=/dev/${MD}s2 conv=sparse bs=64k 2>&1 >> ${LOGFILE}
|
1847 |
|
|
tunefs -L pfsense1 /dev/${MD}s2a 2>&1 >> ${LOGFILE}
|
1848 |
378d60ac
|
Ermal
|
mount /dev/ufs/pfsense1 ${MNT}
|
1849 |
|
|
if [ $? -ne 0 ]; then
|
1850 |
|
|
echo ">>> ERROR: Something wrong happened during mount of second slice image creation. STOPPING!" | tee -a ${LOGFILE}
|
1851 |
|
|
print_error_pfS
|
1852 |
|
|
kill $$
|
1853 |
|
|
fi
|
1854 |
|
|
# Consider the unmounting as well
|
1855 |
d13406a5
|
Ermal
|
trap "umount /dev/ufs/pfsense1; mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1856 |
66700206
|
Scott Ullrich
|
|
1857 |
d13406a5
|
Ermal
|
# Set NanoBSD image size
|
1858 |
|
|
echo "${_NANO_MEDIASIZE}" > ${MNT}/etc/nanosize.txt
|
1859 |
|
|
|
1860 |
|
|
echo "/dev/ufs/pfsense1 / ufs ro,sync,noatime 1 1" > ${MNT}/etc/fstab
|
1861 |
|
|
if [ $NANO_CONFSIZE -gt 0 ] ; then
|
1862 |
|
|
echo "/dev/ufs/cf /cf ufs ro,sync,noatime 1 1" >> ${MNT}/etc/fstab
|
1863 |
|
|
fi
|
1864 |
90fabf95
|
Ermal
|
|
1865 |
378d60ac
|
Ermal
|
umount ${MNT}
|
1866 |
|
|
# Restore the trap back
|
1867 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1868 |
378d60ac
|
Ermal
|
fi
|
1869 |
fd315fb7
|
Scott Ullrich
|
|
1870 |
378d60ac
|
Ermal
|
# Create Data slice, if any.
|
1871 |
|
|
# Note the changing of the variable to NANO_CONFSIZE
|
1872 |
|
|
# from NANO_DATASIZE. We also added glabel support
|
1873 |
|
|
# and populate the pfSense configuration from the /cf
|
1874 |
|
|
# directory located in PFSENSEISODIR
|
1875 |
|
|
if [ $NANO_CONFSIZE -gt 0 ] ; then
|
1876 |
|
|
echo ">>> Creating /cf area to hold config.xml"
|
1877 |
|
|
newfs -L cf ${NANO_NEWFS} /dev/${MD}s3 2>&1 >> ${LOGFILE}
|
1878 |
|
|
# Mount data partition and copy contents of /cf
|
1879 |
|
|
# Can be used later to create custom default config.xml while building
|
1880 |
|
|
mount /dev/ufs/cf ${MNT}
|
1881 |
|
|
if [ $? -ne 0 ]; then
|
1882 |
|
|
echo ">>> ERROR: Something wrong happened during mount of cf slice image creation. STOPPING!" | tee -a ${LOGFILE}
|
1883 |
|
|
print_error_pfS
|
1884 |
|
|
kill $$
|
1885 |
|
|
fi
|
1886 |
|
|
# Consider the unmounting as well
|
1887 |
d13406a5
|
Ermal
|
trap "umount /dev/ufs/cf; mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1888 |
98b1c984
|
Renato Botelho
|
|
1889 |
378d60ac
|
Ermal
|
clone_directory_contents ${PFSENSEISODIR}/cf ${MNT}
|
1890 |
d13406a5
|
Ermal
|
|
1891 |
378d60ac
|
Ermal
|
umount ${MNT}
|
1892 |
|
|
# Restore the trap back
|
1893 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}; return" 1 2 15 EXIT
|
1894 |
378d60ac
|
Ermal
|
else
|
1895 |
|
|
">>> [nanoo] NANO_CONFSIZE is not set. Not adding a /conf partition.. You sure about this??" | tee -a ${LOGFILE}
|
1896 |
|
|
fi
|
1897 |
98b1c984
|
Renato Botelho
|
|
1898 |
378d60ac
|
Ermal
|
echo ">>> [nanoo] Creating NanoBSD upgrade file from first slice..." | tee -a ${LOGFILE}
|
1899 |
d13406a5
|
Ermal
|
dd if=/dev/${MD}s1 of=$IMGUPDATE conv=sparse bs=64k 2>&1 >> ${LOGFILE}
|
1900 |
378d60ac
|
Ermal
|
|
1901 |
|
|
mdconfig -d -u $MD
|
1902 |
|
|
# Restore default action
|
1903 |
d13406a5
|
Ermal
|
trap "-" 1 2 15 EXIT
|
1904 |
378d60ac
|
Ermal
|
|
1905 |
|
|
# Check each image and ensure that they are over
|
1906 |
|
|
# 3 megabytes. If either image is under 20 megabytes
|
1907 |
|
|
# in size then error out.
|
1908 |
|
|
IMGSIZE=`ls -la $IMG | awk '{ print $5 }'`
|
1909 |
|
|
IMGUPDATESIZE=`ls -la $IMGUPDATE | awk '{ print $5 }'`
|
1910 |
|
|
CHECKSIZE="20040710"
|
1911 |
|
|
if [ "$IMGSIZE" -lt "$CHECKSIZE" ]; then
|
1912 |
|
|
echo ">>> ERROR: Something went wrong when building NanoBSD. The image size is under 20 megabytes!" | tee -a ${LOGFILE}
|
1913 |
|
|
print_error_pfS
|
1914 |
d13406a5
|
Ermal
|
kill $$
|
1915 |
378d60ac
|
Ermal
|
fi
|
1916 |
|
|
if [ "$IMGUPDATESIZE" -lt "$CHECKSIZE" ]; then
|
1917 |
|
|
echo ">>> ERROR: Something went wrong when building NanoBSD upgrade image. The image size is under 20 megabytes!" | tee -a ${LOGFILE}
|
1918 |
|
|
print_error_pfS
|
1919 |
d13406a5
|
Ermal
|
kill $$
|
1920 |
378d60ac
|
Ermal
|
fi
|
1921 |
adbddb0e
|
Ermal
|
|
1922 |
378d60ac
|
Ermal
|
# Wrap up the show, Johnny
|
1923 |
d13406a5
|
Ermal
|
echo ">>> NanoBSD Image completed for flash type: $FLASH_MODEL size: $_NANO_MEDIASIZE." | tee -a ${LOGFILE}
|
1924 |
adbddb0e
|
Ermal
|
|
1925 |
d13406a5
|
Ermal
|
gzip -f $IMG &
|
1926 |
|
|
gzip -f $IMGUPDATE &
|
1927 |
378d60ac
|
Ermal
|
done
|
1928 |
adbddb0e
|
Ermal
|
|
1929 |
|
|
unset IMG
|
1930 |
|
|
unset IMGUPDATE
|
1931 |
|
|
unset IMGUPDATESIZE
|
1932 |
|
|
unset IMGSIZE
|
1933 |
|
|
|
1934 |
|
|
ls -lah $MAKEOBJDIRPREFIXFINAL
|
1935 |
66700206
|
Scott Ullrich
|
}
|
1936 |
c09562f1
|
Scott Ullrich
|
|
1937 |
41ba6de7
|
Scott Ullrich
|
# This routine creates a ova image that contains
|
1938 |
|
|
# a ovf and vmdk file. These files can be imported
|
1939 |
|
|
# right into vmware or virtual box.
|
1940 |
|
|
# (and many other emulation platforms)
|
1941 |
ba719932
|
Scott Ullrich
|
# http://www.vmware.com/pdf/ovf_whitepaper_specification.pdf
|
1942 |
41ba6de7
|
Scott Ullrich
|
create_ova_image() {
|
1943 |
b9f939d4
|
Scott Ullrich
|
# XXX create a .ovf php creator that you can pass:
|
1944 |
0618df8e
|
Scott Ullrich
|
# 1. populatedSize
|
1945 |
b9f939d4
|
Scott Ullrich
|
# 2. license
|
1946 |
|
|
# 3. product name
|
1947 |
49c45011
|
Scott Ullrich
|
# 4. version
|
1948 |
|
|
# 5. number of network interface cards
|
1949 |
0618df8e
|
Scott Ullrich
|
# 6. allocationUnits
|
1950 |
|
|
# 7. capacity
|
1951 |
|
|
# 8. capacityAllocationUnits
|
1952 |
adbddb0e
|
Ermal
|
|
1953 |
|
|
LOGFILE=${BUILDER_LOGS}/ova.${TARGET}.log
|
1954 |
|
|
|
1955 |
|
|
# Prepare folder to be put in image
|
1956 |
|
|
export PKG_INSTALL_PORTSPFS="${PKG_INSTALL_PORTSPFS} /usr/ports/emulators/open-vm-tools-nox11"
|
1957 |
|
|
customize_stagearea_for_image "ova"
|
1958 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
1959 |
|
|
|
1960 |
ee0a4f5c
|
Scott Ullrich
|
ova_prereq_check
|
1961 |
|
|
ova_remove_old_tmp_files
|
1962 |
|
|
ova_setup_ovf_file
|
1963 |
|
|
ova_create_raw_backed_file
|
1964 |
adbddb0e
|
Ermal
|
/bin/echo -n ">>> Creating mdconfig image ${OVFPATH}/${OVFVMDK}.raw... " | tee -a ${LOGFILE}
|
1965 |
ee0a4f5c
|
Scott Ullrich
|
MD=`mdconfig -a -t vnode -f ${OVFPATH}/${OVFVMDK}.raw`
|
1966 |
adbddb0e
|
Ermal
|
# Just in case
|
1967 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}" 1 2 15 EXIT
|
1968 |
adbddb0e
|
Ermal
|
|
1969 |
ee0a4f5c
|
Scott Ullrich
|
# comment out if using pc-sysinstall
|
1970 |
cb392cad
|
Scott Ullrich
|
ova_partition_gpart $MD
|
1971 |
ee0a4f5c
|
Scott Ullrich
|
ova_set_default_network_interfaces
|
1972 |
|
|
ova_mount_mnt $MD
|
1973 |
|
|
ova_cpdup_files
|
1974 |
ef7f6c1b
|
Scott Ullrich
|
ova_setup_platform_specific # after cpdup
|
1975 |
ee0a4f5c
|
Scott Ullrich
|
ova_calculate_mnt_size
|
1976 |
|
|
ova_umount_mnt $MD
|
1977 |
adbddb0e
|
Ermal
|
# Restore default action
|
1978 |
d13406a5
|
Ermal
|
trap "-" 1 2 15 EXIT
|
1979 |
2828294b
|
Ermal
|
ova_umount_mdconfig $MD
|
1980 |
63457486
|
Scott Ullrich
|
# We use vbox because it compresses the vmdk on export
|
1981 |
ee0a4f5c
|
Scott Ullrich
|
ova_create_vbox_image
|
1982 |
63457486
|
Scott Ullrich
|
# We repack the file with a more universal xml file that
|
1983 |
|
|
# works in both virtual box and esx server
|
1984 |
d451db3b
|
Scott Ullrich
|
ova_repack_vbox_image
|
1985 |
|
|
}
|
1986 |
|
|
|
1987 |
|
|
ova_repack_vbox_image() {
|
1988 |
0c6b0fcf
|
Scott Ullrich
|
BUILDPLATFORM=`uname -p`
|
1989 |
adbddb0e
|
Ermal
|
POPULATEDSIZE=`du -d0 -h $PFSENSEISODIR | awk '{ print \$1 }' | cut -dM -f1`
|
1990 |
d451db3b
|
Scott Ullrich
|
POPULATEDSIZEBYTES=`echo "${POPULATEDSIZE}*1024^2" | bc`
|
1991 |
13947d04
|
Ermal
|
REFERENCESSIZE=`ls -la ${OVFPATH}/${OVFVMDK} | awk '{ print \$5 }'`
|
1992 |
adbddb0e
|
Ermal
|
echo ">>> Setting REFERENCESSIZE to ${REFERENCESSIZE}..." | tee -a ${LOGFILE}
|
1993 |
eff29873
|
Ermal
|
file_search_replace REFERENCESSIZE ${REFERENCESSIZE} ${OVFPATH}/${PRODUCT_NAME}.ovf
|
1994 |
adbddb0e
|
Ermal
|
echo ">>> Setting POPULATEDSIZEBYTES to ${POPULATEDSIZEBYTES}..." | tee -a ${LOGFILE}
|
1995 |
8e2c268b
|
Scott Ullrich
|
# OperatingSystemSection (pfSense.ovf)
|
1996 |
|
|
# 42 FreeBSD 32-Bit
|
1997 |
|
|
# 78 FreeBSD 64-Bit
|
1998 |
0c6b0fcf
|
Scott Ullrich
|
if [ "$BUILDPLATFORM" = "i386" ]; then
|
1999 |
eff29873
|
Ermal
|
file_search_replace '"101"' '"42"' ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2000 |
18ae9c2d
|
jim-p
|
file_search_replace 'FreeBSD XX-Bit' 'FreeBSD' ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2001 |
0c6b0fcf
|
Scott Ullrich
|
fi
|
2002 |
|
|
if [ "$BUILDPLATFORM" = "amd64" ]; then
|
2003 |
eff29873
|
Ermal
|
file_search_replace '"101"' '"78"' ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2004 |
18ae9c2d
|
jim-p
|
file_search_replace 'FreeBSD XX-Bit' 'FreeBSD 64-Bit' ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2005 |
0c6b0fcf
|
Scott Ullrich
|
fi
|
2006 |
eff29873
|
Ermal
|
file_search_replace DISKSECTIONPOPULATEDSIZE $POPULATEDSIZEBYTES ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2007 |
f27c154e
|
Scott Ullrich
|
# 10737254400 = 10240MB = virtual box vmdk file size XXX grab this value from vbox creation
|
2008 |
|
|
# 10737418240 = 10GB
|
2009 |
adbddb0e
|
Ermal
|
echo ">>> Setting DISKSECTIONALLOCATIONUNITS to 10737254400..." | tee -a ${LOGFILE}
|
2010 |
eff29873
|
Ermal
|
file_search_replace DISKSECTIONALLOCATIONUNITS $OVA_DISKSECTIONALLOCATIONUNITS ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2011 |
adbddb0e
|
Ermal
|
echo ">>> Setting DISKSECTIONCAPACITY to 10737418240..." | tee -a ${LOGFILE}
|
2012 |
eff29873
|
Ermal
|
file_search_replace DISKSECTIONCAPACITY $OVADISKSIZE ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2013 |
adbddb0e
|
Ermal
|
echo ">>> Repacking OVA with universal OVF file..." | tee -a ${LOGFILE}
|
2014 |
13947d04
|
Ermal
|
mv ${OVFPATH}/${OVFVMDK} ${OVFPATH}/${PRODUCT_NAME}-disk1.vmdk
|
2015 |
|
|
OWD=`pwd`
|
2016 |
f27c154e
|
Scott Ullrich
|
cd ${OVFPATH} && tar cpf ${PRODUCT_NAME}.ova ${PRODUCT_NAME}.ovf ${PRODUCT_NAME}-disk1.vmdk
|
2017 |
51edeabe
|
Ermal
|
cd ${OWD}
|
2018 |
13947d04
|
Ermal
|
rm $OVFPATH/${PRODUCT_NAME}-disk1.vmdk
|
2019 |
f27c154e
|
Scott Ullrich
|
ls -lah ${OVFPATH}/${PRODUCT_NAME}*ov*
|
2020 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2021 |
|
|
|
2022 |
|
|
# called from create_ova_image
|
2023 |
|
|
ova_umount_mnt() {
|
2024 |
|
|
# Unmount /dev/mdX
|
2025 |
|
|
umount /mnt
|
2026 |
|
|
sync ; sync
|
2027 |
|
|
}
|
2028 |
|
|
|
2029 |
|
|
# called from create_ova_image
|
2030 |
|
|
ova_umount_mdconfig() {
|
2031 |
|
|
MD=$1
|
2032 |
|
|
# Show gpart info
|
2033 |
|
|
gpart show $MD
|
2034 |
adbddb0e
|
Ermal
|
echo ">>> Unmounting ${MD}..." | tee -a ${LOGFILE}
|
2035 |
ee0a4f5c
|
Scott Ullrich
|
mdconfig -d -u $MD
|
2036 |
|
|
sync ; sync
|
2037 |
|
|
}
|
2038 |
|
|
|
2039 |
|
|
# called from create_ova_image
|
2040 |
|
|
ova_mount_mnt() {
|
2041 |
|
|
MD=$1
|
2042 |
adbddb0e
|
Ermal
|
echo ">>> Mounting image to /mnt..." | tee -a ${LOGFILE}
|
2043 |
20af348c
|
Scott Ullrich
|
mount -o rw /dev/${MD}p2 /mnt/
|
2044 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2045 |
|
|
|
2046 |
|
|
# called from create_ova_image
|
2047 |
|
|
ova_setup_ovf_file() {
|
2048 |
51edeabe
|
Ermal
|
if [ -f ${OVFFILE} ]; then
|
2049 |
eff29873
|
Ermal
|
cp ${OVFFILE} ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2050 |
993f9b80
|
Scott Ullrich
|
fi
|
2051 |
51edeabe
|
Ermal
|
|
2052 |
eff29873
|
Ermal
|
if [ ! -f ${OVFPATH}/${PRODUCT_NAME}.ovf ]; then
|
2053 |
44980473
|
Ermal
|
cp ${BUILDER_SCRIPTS}/conf/ovf/pfSense.ovf ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2054 |
708b07d6
|
jim-p
|
file_search_replace PFSENSE_VERSION $PFSENSE_VERSION ${OVFPATH}/${PRODUCT_NAME}.ovf
|
2055 |
993f9b80
|
Scott Ullrich
|
fi
|
2056 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2057 |
|
|
|
2058 |
|
|
# called from create_ova_image
|
2059 |
|
|
ova_prereq_check() {
|
2060 |
42a33c36
|
Ermal
|
if [ ! -f /usr/local/bin/qemu-img]; then
|
2061 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: qemu-img is not present please check port emulators/qemu installation" | tee -a ${LOGFILE}
|
2062 |
adbddb0e
|
Ermal
|
print_error_pfS
|
2063 |
d5fe819c
|
Ermal
|
fi
|
2064 |
ee0a4f5c
|
Scott Ullrich
|
sysctl kern.geom.debugflags=16
|
2065 |
|
|
}
|
2066 |
|
|
|
2067 |
0539bd8c
|
Scott Ullrich
|
disable_lan_disable_dhcpd_enable_sshd() {
|
2068 |
adbddb0e
|
Ermal
|
if [ "${TARGET}" != "${BUILDER_HOST_TARGET}" ]; then
|
2069 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Cannot perform the modifications since cross compiling!" | tee -a ${LOGFILE}
|
2070 |
adbddb0e
|
Ermal
|
print_error_pfS
|
2071 |
|
|
fi
|
2072 |
|
|
|
2073 |
|
|
cat <<EOF >$PFSENSEISODIR/remove_lan.php
|
2074 |
d8816a21
|
Scott Ullrich
|
#!/usr/local/bin/php -f
|
2075 |
|
|
<?php
|
2076 |
|
|
require_once("globals.inc");
|
2077 |
|
|
require_once("functions.inc");
|
2078 |
|
|
require_once("config.inc");
|
2079 |
|
|
require_once("util.inc");
|
2080 |
|
|
\$config = parse_config(true);
|
2081 |
60dbea86
|
Scott Ullrich
|
echo ">>> Disabling LAN interface...\n";
|
2082 |
d8816a21
|
Scott Ullrich
|
unset(\$config['interfaces']['lan']);
|
2083 |
60dbea86
|
Scott Ullrich
|
echo ">>> Disabling DHCPD on LAN interface...\n";
|
2084 |
d8816a21
|
Scott Ullrich
|
unset(\$config['dhcpd']['lan']['enable']);
|
2085 |
|
|
\$config['system']['enablesshd'] = true;
|
2086 |
6ac9367c
|
Scott Ullrich
|
echo ">>> Adding allow all rule to WAN...\n";
|
2087 |
d8816a21
|
Scott Ullrich
|
\$filterent = array();
|
2088 |
|
|
\$filterent["type"] = "pass";
|
2089 |
|
|
\$filterent["interface"] = "wan";
|
2090 |
|
|
\$filterent["source"]["any"] = "";
|
2091 |
|
|
\$filterent["destination"]["any"] = "";
|
2092 |
|
|
\$filterent["statetype"] = "keep state";
|
2093 |
|
|
\$filterent["os"] = "";
|
2094 |
|
|
\$filterent["descr"] = "Allow all via DevBuilder";
|
2095 |
|
|
\$config["filter"]["rule"][] = \$filterent;
|
2096 |
60dbea86
|
Scott Ullrich
|
echo ">>> Turning off block private networks (if on)...\n";
|
2097 |
d8816a21
|
Scott Ullrich
|
unset(\$config["interfaces"]["wan"]["blockpriv"]);
|
2098 |
|
|
unset(\$config['interfaces']['wan']['blockbogons']);
|
2099 |
|
|
unlink_if_exists("/tmp/config.cache");
|
2100 |
60dbea86
|
Scott Ullrich
|
echo ">>> Writing config...\n";
|
2101 |
d8816a21
|
Scott Ullrich
|
write_config("DevBuilder changes.");
|
2102 |
|
|
\$config = parse_config(true);
|
2103 |
60dbea86
|
Scott Ullrich
|
echo ">>> Finished with config.xml modificaitons...\n";
|
2104 |
d8816a21
|
Scott Ullrich
|
?>
|
2105 |
|
|
EOF
|
2106 |
|
|
|
2107 |
|
|
# Setup config environment
|
2108 |
adbddb0e
|
Ermal
|
cp $PFSENSEISODIR/cf/conf/config.xml $PFSENSEISODIR/conf/
|
2109 |
|
|
mkdir -p $PFSENSEISODIR/conf/backup
|
2110 |
|
|
mkdir -p $PFSENSEISODIR/cf/conf/backup
|
2111 |
|
|
chmod a+rx $PFSENSEISODIR/remove_lan.php
|
2112 |
d8816a21
|
Scott Ullrich
|
# chroot in and do the operations
|
2113 |
adbddb0e
|
Ermal
|
chroot $PFSENSEISODIR /remove_lan.php
|
2114 |
d8816a21
|
Scott Ullrich
|
# copy the altered config.xml into place
|
2115 |
adbddb0e
|
Ermal
|
cp $PFSENSEISODIR/cf/conf/config.xml $PFSENSEISODIR/conf.default/config.xml
|
2116 |
d8816a21
|
Scott Ullrich
|
# Break environment back down
|
2117 |
adbddb0e
|
Ermal
|
rm -rf $PFSENSEISODIR/cf/conf/backup
|
2118 |
|
|
rm -rf $PFSENSEISODIR/conf/*
|
2119 |
|
|
rm -rf $PFSENSEISODIR/tmp/*
|
2120 |
|
|
rm $PFSENSEISODIR/remove_lan.php
|
2121 |
74758aaa
|
Scott Ullrich
|
}
|
2122 |
|
|
|
2123 |
ee0a4f5c
|
Scott Ullrich
|
# called from create_ova_image
|
2124 |
|
|
ova_calculate_mnt_size() {
|
2125 |
adbddb0e
|
Ermal
|
/bin/echo -n ">>> Calculating size of /mnt..." | tee -a ${LOFGILE}
|
2126 |
ee0a4f5c
|
Scott Ullrich
|
INSTALLSIZE=`du -s /mnt/ | awk '{ print $1 }'`
|
2127 |
ef7f6c1b
|
Scott Ullrich
|
INSTALLSIZEH=`du -d0 -h /mnt/ | awk '{ print $1 }'`
|
2128 |
|
|
echo $INSTALLSIZEH
|
2129 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2130 |
|
|
|
2131 |
|
|
# called from create_ova_image
|
2132 |
|
|
ova_create_raw_backed_file() {
|
2133 |
660de32f
|
Scott Ullrich
|
DISKSIZE=$OVADISKSIZE
|
2134 |
|
|
BLOCKSIZE=$OVABLOCKSIZE
|
2135 |
b571ff11
|
jim-p
|
COUNT=`expr -e $DISKSIZE / $BLOCKSIZE`
|
2136 |
f775eefe
|
jim-p
|
DISKFILE=${OVFPATH}/${OVFVMDK}.raw
|
2137 |
adbddb0e
|
Ermal
|
echo ">>> Creating raw backing file ${DISKFILE} (Disk Size: ${DISKSIZE}, Block Size: ${BLOCKSIZE}, Count: ${COUNT})..." | tee -a ${LOGFILE}
|
2138 |
c0945323
|
Seth Mos
|
dd if=/dev/zero of=$DISKFILE bs=$BLOCKSIZE count=0 seek=$COUNT
|
2139 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2140 |
|
|
|
2141 |
|
|
# called from create_ova_image
|
2142 |
|
|
ova_remove_old_tmp_files() {
|
2143 |
|
|
rm ${OVFPATH}/*.ovf.final 2>/dev/null
|
2144 |
|
|
rm ${OVFPATH}/*.ova 2>/dev/null
|
2145 |
|
|
}
|
2146 |
|
|
|
2147 |
|
|
# called from create_ova_image
|
2148 |
|
|
ova_set_default_network_interfaces() {
|
2149 |
adbddb0e
|
Ermal
|
echo ">>> Setting default interfaces to em0 and em1 in config.xml..." | tee -a ${LOGFILE}
|
2150 |
|
|
file_search_replace vr0 em0 ${PFSENSEISODIR}/conf.default/config.xml
|
2151 |
|
|
file_search_replace vr1 em1 ${PFSENSEISODIR}/conf.default/config.xml
|
2152 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2153 |
|
|
|
2154 |
|
|
# called from create_ova_image
|
2155 |
|
|
ova_create_vbox_image() {
|
2156 |
|
|
# VirtualBox
|
2157 |
adbddb0e
|
Ermal
|
echo ">>> Creating image using qemu-img..." | tee -a ${LOGFILE}
|
2158 |
ee0a4f5c
|
Scott Ullrich
|
rm ${OVFPATH}/${OVFVMDK} 2>/dev/null
|
2159 |
42a33c36
|
Ermal
|
qemu-img convert -f raw -O vmdk ${OVFPATH}/${OVFVMDK}.raw ${OVFPATH}/${OVFVMDK}
|
2160 |
13947d04
|
Ermal
|
rm -rf ${OVFPATH}/${OVFVMDK}.raw
|
2161 |
adbddb0e
|
Ermal
|
echo ">>> ${OVFPATH}/${OVFVMDK} created." | tee -a ${LOGFILE}
|
2162 |
ee0a4f5c
|
Scott Ullrich
|
}
|
2163 |
|
|
|
2164 |
|
|
# called from create_ova_image
|
2165 |
|
|
ova_cpdup_files() {
|
2166 |
92036b4d
|
Scott Ullrich
|
echo ">>> Populating vmdk staging area..."
|
2167 |
adbddb0e
|
Ermal
|
cpdup -o ${PFSENSEISODIR}/COPYRIGHT /mnt/COPYRIGHT
|
2168 |
|
|
cpdup -o ${PFSENSEISODIR}/boot /mnt/boot
|
2169 |
|
|
cpdup -o ${PFSENSEISODIR}/bin /mnt/bin
|
2170 |
|
|
cpdup -o ${PFSENSEISODIR}/conf /mnt/conf
|
2171 |
|
|
cpdup -o ${PFSENSEISODIR}/conf.default /mnt/conf.default
|
2172 |
|
|
cpdup -o ${PFSENSEISODIR}/dev /mnt/dev
|
2173 |
|
|
cpdup -o ${PFSENSEISODIR}/etc /mnt/etc
|
2174 |
|
|
cpdup -o ${PFSENSEISODIR}/home /mnt/home
|
2175 |
|
|
cpdup -o ${PFSENSEISODIR}/kernels /mnt/kernels
|
2176 |
|
|
cpdup -o ${PFSENSEISODIR}/libexec /mnt/libexec
|
2177 |
|
|
cpdup -o ${PFSENSEISODIR}/lib /mnt/lib
|
2178 |
|
|
cpdup -o ${PFSENSEISODIR}/root /mnt/root
|
2179 |
|
|
cpdup -o ${PFSENSEISODIR}/sbin /mnt/sbin
|
2180 |
|
|
cpdup -o ${PFSENSEISODIR}/usr /mnt/usr
|
2181 |
|
|
cpdup -o ${PFSENSEISODIR}/var /mnt/var
|
2182 |
ee0a4f5c
|
Scott Ullrich
|
sync ; sync ; sync ; sync
|
2183 |
|
|
}
|
2184 |
|
|
|
2185 |
ef7f6c1b
|
Scott Ullrich
|
ova_setup_platform_specific() {
|
2186 |
adbddb0e
|
Ermal
|
echo ">>> Installing platform specific items..." | tee -a ${LOGFILE}
|
2187 |
ef7f6c1b
|
Scott Ullrich
|
echo "/dev/label/${PRODUCT_NAME} / ufs rw 0 0" > /mnt/etc/fstab
|
2188 |
adbddb0e
|
Ermal
|
echo "/dev/label/swap0 none swap sw 0 0" >> /mnt/etc/fstab
|
2189 |
ef7f6c1b
|
Scott Ullrich
|
echo pfSense > /mnt/etc/platform
|
2190 |
|
|
rmdir /mnt/conf
|
2191 |
adbddb0e
|
Ermal
|
mkdir -p /mnt/cf
|
2192 |
|
|
mkdir -p /mnt/cf/conf
|
2193 |
ef7f6c1b
|
Scott Ullrich
|
cp /mnt/conf.default/config.xml /mnt/cf/conf/
|
2194 |
|
|
chroot /mnt /bin/ln -s /cf/conf /conf
|
2195 |
adbddb0e
|
Ermal
|
mkdir -p /mnt/tmp
|
2196 |
ef7f6c1b
|
Scott Ullrich
|
}
|
2197 |
|
|
|
2198 |
ee0a4f5c
|
Scott Ullrich
|
# called from create_ova_image
|
2199 |
|
|
ova_partition_gpart() {
|
2200 |
adbddb0e
|
Ermal
|
# XXX: Switch to mkimg tool!!
|
2201 |
ee0a4f5c
|
Scott Ullrich
|
MD=$1
|
2202 |
adbddb0e
|
Ermal
|
echo ">>> Creating GPT..." | tee -a ${LOGFILE}
|
2203 |
ee0a4f5c
|
Scott Ullrich
|
gpart create -s gpt $MD
|
2204 |
adbddb0e
|
Ermal
|
echo ">>> Embedding GPT bootstrap into protective MBR..." | tee -a ${LOGFILE}
|
2205 |
cb392cad
|
Scott Ullrich
|
gpart bootcode -b /boot/pmbr $MD
|
2206 |
adbddb0e
|
Ermal
|
echo ">>> Creating GPT boot partition..." | tee -a ${LOGFILE}
|
2207 |
cb392cad
|
Scott Ullrich
|
gpart add -b 34 -s 128 -t freebsd-boot $MD
|
2208 |
|
|
gpart bootcode -p /boot/gptboot -i 1 $MD
|
2209 |
adbddb0e
|
Ermal
|
echo ">>> Setting up disk slices: ${MD}p2 (Size: ${OVA_FIRST_PART_SIZE})..." | tee -a ${LOGFILE}
|
2210 |
e73164e3
|
jim-p
|
gpart add -s $OVA_FIRST_PART_SIZE -t freebsd-ufs -i 2 $MD
|
2211 |
adbddb0e
|
Ermal
|
echo ">>> Setting up disk slices: ${MD}p3 (swap) (Size: ${OVA_SWAP_PART_SIZE})..." | tee -a ${LOGFILE}
|
2212 |
660de32f
|
Scott Ullrich
|
gpart add -s $OVA_SWAP_PART_SIZE -t freebsd-swap -i 3 $MD
|
2213 |
adbddb0e
|
Ermal
|
echo ">>> Running newfs..." | tee -a ${LOGFILE}
|
2214 |
24d31e82
|
Scott Ullrich
|
newfs -U /dev/${MD}p2
|
2215 |
20af348c
|
Scott Ullrich
|
sync ; sync ; sync ; sync
|
2216 |
adbddb0e
|
Ermal
|
echo ">>> Labeling partitions: ${MD}p2..." | tee -a ${LOGFILE}
|
2217 |
24d31e82
|
Scott Ullrich
|
glabel label ${PRODUCT_NAME} ${MD}p2
|
2218 |
462a98b4
|
Scott Ullrich
|
sync ; sync
|
2219 |
adbddb0e
|
Ermal
|
echo ">>> Labeling partitions: ${MD}p3..." | tee -a ${LOGFILE}
|
2220 |
ee0a4f5c
|
Scott Ullrich
|
glabel label swap0 ${MD}p3
|
2221 |
cdfcbc24
|
Scott Ullrich
|
sync ; sync
|
2222 |
692b4630
|
Scott Ullrich
|
}
|
2223 |
|
|
|
2224 |
ee0a4f5c
|
Scott Ullrich
|
# called from create_ova_image
|
2225 |
202c91a7
|
Scott Ullrich
|
# This routine will replace a string in a file
|
2226 |
10e48fd4
|
Scott Ullrich
|
file_search_replace() {
|
2227 |
|
|
SEARCH=$1
|
2228 |
|
|
REPLACE=$2
|
2229 |
|
|
FILENAME=$3
|
2230 |
16f00b88
|
Scott Ullrich
|
sed "s/${SEARCH}/${REPLACE}/g" $3 > $FILENAME.$$
|
2231 |
7996a5a6
|
Scott Ullrich
|
mv $FILENAME.$$ $FILENAME
|
2232 |
10e48fd4
|
Scott Ullrich
|
}
|
2233 |
|
|
|
2234 |
aa0bbaae
|
Scott Ullrich
|
# This routine installs pfSense packages into the staging area.
|
2235 |
|
|
# Packages such as squid, snort, autoconfigbackup, etc.
|
2236 |
c09562f1
|
Scott Ullrich
|
pfsense_install_custom_packages_exec() {
|
2237 |
fbfea02e
|
Scott Ullrich
|
# Function originally written by Daniel S. Haischt
|
2238 |
|
|
# Copyright (C) 2007 Daniel S. Haischt <me@daniel.stefan.haischt.name>
|
2239 |
6fa570fb
|
Scott Ullrich
|
# Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
|
2240 |
98b1c984
|
Renato Botelho
|
|
2241 |
adbddb0e
|
Ermal
|
if [ "${TARGET}" != "${BUILDER_HOST_TARGET}" ]; then
|
2242 |
|
|
echo ">>> WARNING: Cannot install pfSense packages since cross building!" | tee -a ${LOGFILE}
|
2243 |
|
|
return
|
2244 |
|
|
fi
|
2245 |
|
|
|
2246 |
6211d2fa
|
Ermal
|
if [ ${FREEBSD_VERSION} -ge 10 ]; then
|
2247 |
|
|
PFSDESTNAME="pkgnginstall.sh"
|
2248 |
|
|
else
|
2249 |
|
|
PFSDESTNAME="pkginstall.sh"
|
2250 |
|
|
fi
|
2251 |
adbddb0e
|
Ermal
|
PFSTODIR="${PFSENSEISODIR}"
|
2252 |
c09562f1
|
Scott Ullrich
|
|
2253 |
|
|
# Extra package list if defined.
|
2254 |
|
|
if [ ! -z "${custom_package_list:-}" ]; then
|
2255 |
|
|
# Notes:
|
2256 |
|
|
# ======
|
2257 |
|
|
# devfs mount is required cause PHP requires /dev/stdin
|
2258 |
|
|
# php.ini needed to make PHP argv capable
|
2259 |
|
|
#
|
2260 |
8b3e521b
|
Scott Ullrich
|
/bin/echo ">>> Installing custom packages to: ${PFSTODIR} ..."
|
2261 |
c09562f1
|
Scott Ullrich
|
|
2262 |
8b3e521b
|
Scott Ullrich
|
cp ${PFSTODIR}/etc/platform ${PFSTODIR}/tmp/
|
2263 |
c09562f1
|
Scott Ullrich
|
|
2264 |
8b3e521b
|
Scott Ullrich
|
/sbin/mount -t devfs devfs ${PFSTODIR}/dev
|
2265 |
c09562f1
|
Scott Ullrich
|
|
2266 |
8b3e521b
|
Scott Ullrich
|
/bin/mkdir -p ${PFSTODIR}/var/etc/
|
2267 |
|
|
/bin/cp /etc/resolv.conf ${PFSTODIR}/etc/
|
2268 |
98b1c984
|
Renato Botelho
|
|
2269 |
8b3e521b
|
Scott Ullrich
|
/bin/echo ${custom_package_list} > ${PFSTODIR}/tmp/pkgfile.lst
|
2270 |
c09562f1
|
Scott Ullrich
|
|
2271 |
ca18def5
|
Ermal
|
/bin/cp ${BUILDER_TOOLS}/builder_scripts/scripts/pfspkg_installer ${PFSTODIR}/tmp
|
2272 |
98a9301e
|
Ermal
|
/bin/chmod a+x ${PFSTODIR}/tmp/pfspkg_installer
|
2273 |
98b1c984
|
Renato Botelho
|
|
2274 |
b5b7f3ef
|
Ermal
|
cp ${PFSTODIR}/usr/local/lib/php.ini $SCRATCHDIR
|
2275 |
|
|
if [ -f $SCRATCHDIR/php.ini ]; then
|
2276 |
|
|
cat $SCRATCHDIR/php.ini | grep -v apc > ${PFSTODIR}/usr/local/lib/php.ini
|
2277 |
|
|
cat $SCRATCHDIR/php.ini | grep -v apc > ${PFSTODIR}/usr/local/etc/php.ini
|
2278 |
89b34627
|
Scott Ullrich
|
fi
|
2279 |
98b1c984
|
Renato Botelho
|
|
2280 |
c09562f1
|
Scott Ullrich
|
# setup script that will be run within the chroot env
|
2281 |
8b3e521b
|
Scott Ullrich
|
/bin/cat > ${PFSTODIR}/${PFSDESTNAME} <<EOF
|
2282 |
c09562f1
|
Scott Ullrich
|
#!/bin/sh
|
2283 |
|
|
#
|
2284 |
|
|
# ------------------------------------------------------------------------
|
2285 |
|
|
# ATTENTION: !!! This script is supposed to be run within a chroot env !!!
|
2286 |
|
|
# ------------------------------------------------------------------------
|
2287 |
|
|
#
|
2288 |
|
|
#
|
2289 |
|
|
# Setup
|
2290 |
|
|
#
|
2291 |
|
|
|
2292 |
76250646
|
Scott Ullrich
|
# Handle php.ini if /etc/rc.php_ini_setup exists
|
2293 |
|
|
if [ -f "/etc/rc.php_ini_setup" ]; then
|
2294 |
7f1882cf
|
Scott Ullrich
|
mkdir -p /usr/local/lib/ /usr/local/etc/
|
2295 |
e0f3489f
|
Scott Ullrich
|
/etc/rc.php_ini_setup 2>/dev/null
|
2296 |
76250646
|
Scott Ullrich
|
cat /usr/local/etc/php.ini | grep -v apc > /tmp/php.ini.new
|
2297 |
9a6938cb
|
Scott Ullrich
|
cp /tmp/php.ini.new /usr/local/etc/php.ini 2>/dev/null
|
2298 |
|
|
cp /tmp/php.ini.new /usr/local/lib/php.ini 2>/dev/null
|
2299 |
76250646
|
Scott Ullrich
|
fi
|
2300 |
|
|
|
2301 |
6dfbaac9
|
Scott Ullrich
|
if [ ! -f "/usr/local/bin/php" ]; then
|
2302 |
98b1c984
|
Renato Botelho
|
echo
|
2303 |
|
|
echo
|
2304 |
|
|
echo
|
2305 |
191f302d
|
Scott Ullrich
|
echo "ERROR. A copy of php does not exist in /usr/local/bin/"
|
2306 |
|
|
echo
|
2307 |
|
|
echo "This script cannot continue."
|
2308 |
98b1c984
|
Renato Botelho
|
echo
|
2309 |
191f302d
|
Scott Ullrich
|
while [ /bin/true ]; do
|
2310 |
2e38586f
|
Scott Ullrich
|
sleep 65535
|
2311 |
98b1c984
|
Renato Botelho
|
done
|
2312 |
191f302d
|
Scott Ullrich
|
fi
|
2313 |
|
|
|
2314 |
715fc3b0
|
Scott Ullrich
|
if [ ! -f "/COPYRIGHT" ]; then
|
2315 |
98b1c984
|
Renato Botelho
|
echo
|
2316 |
|
|
echo
|
2317 |
|
|
echo
|
2318 |
715fc3b0
|
Scott Ullrich
|
echo "ERROR. Could not detect the correct CHROOT environment (missing /COPYRIGHT)."
|
2319 |
|
|
echo
|
2320 |
|
|
echo "This script cannot continue."
|
2321 |
98b1c984
|
Renato Botelho
|
echo
|
2322 |
715fc3b0
|
Scott Ullrich
|
while [ /bin/true ]; do
|
2323 |
2e38586f
|
Scott Ullrich
|
sleep 65535
|
2324 |
715fc3b0
|
Scott Ullrich
|
done
|
2325 |
|
|
fi
|
2326 |
|
|
|
2327 |
c09562f1
|
Scott Ullrich
|
# backup original conf dir
|
2328 |
|
|
if [ -d /conf ]; then
|
2329 |
|
|
/bin/mv /conf /conf.org
|
2330 |
|
|
/usr/bin/touch /tmp/restore_conf_dir
|
2331 |
|
|
fi
|
2332 |
|
|
|
2333 |
|
|
# test whether conf dir is already a symlink
|
2334 |
33e2f319
|
Scott Ullrich
|
if [ ! -h /conf ]; then
|
2335 |
c09562f1
|
Scott Ullrich
|
# install the symlink as it would exist on a live system
|
2336 |
d1c73a5a
|
Renato Botelho
|
/bin/ln -s /cf/conf /conf 2>/dev/null
|
2337 |
c09562f1
|
Scott Ullrich
|
/usr/bin/touch /tmp/remove_conf_symlink
|
2338 |
|
|
fi
|
2339 |
|
|
|
2340 |
|
|
# now that we do have the symlink in place create
|
2341 |
|
|
# a backup dir if necessary.
|
2342 |
|
|
if [ ! -d /conf/backup ]; then
|
2343 |
|
|
/bin/mkdir -p /conf/backup
|
2344 |
|
|
/usr/bin/touch /tmp/remove_backup
|
2345 |
|
|
fi
|
2346 |
715fc3b0
|
Scott Ullrich
|
|
2347 |
c09562f1
|
Scott Ullrich
|
#
|
2348 |
|
|
# Assemble package list if necessary
|
2349 |
|
|
#
|
2350 |
365e663e
|
Scott Ullrich
|
(/tmp/pfspkg_installer -q -m config -l /tmp/pkgfile.lst -p .:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg) | egrep -wi '(^>>>|error)'
|
2351 |
715fc3b0
|
Scott Ullrich
|
|
2352 |
c09562f1
|
Scott Ullrich
|
#
|
2353 |
|
|
# Exec PHP script which installs pfSense packages in place
|
2354 |
|
|
#
|
2355 |
5f3f0437
|
Renato Botelho
|
(/tmp/pfspkg_installer -q -m install -l /tmp/pkgfile.lst -p .:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg) > /tmp/pfspkg_installer.out 2>&1
|
2356 |
|
|
|
2357 |
|
|
rc=\$?
|
2358 |
|
|
|
2359 |
|
|
egrep -wi '(^>>>|error)' /tmp/pfspkg_installer.out 2>/dev/null
|
2360 |
|
|
rm -f /tmp/pfspkg_installer.out
|
2361 |
|
|
|
2362 |
|
|
#
|
2363 |
|
|
# Check if pfspkg_installer returned 0
|
2364 |
|
|
#
|
2365 |
|
|
[ "\$rc" != "0" ] && exit 1
|
2366 |
c09562f1
|
Scott Ullrich
|
|
2367 |
2b1384df
|
Scott Ullrich
|
# Copy config.xml to conf.default/
|
2368 |
|
|
cp /conf/config.xml conf.default/
|
2369 |
|
|
|
2370 |
715fc3b0
|
Scott Ullrich
|
#
|
2371 |
|
|
# Cleanup, aisle 7!
|
2372 |
|
|
#
|
2373 |
|
|
if [ -f /tmp/remove_platform ]; then
|
2374 |
|
|
/bin/rm /etc/platform
|
2375 |
|
|
/bin/rm /tmp/remove_platform
|
2376 |
|
|
fi
|
2377 |
c09562f1
|
Scott Ullrich
|
|
2378 |
715fc3b0
|
Scott Ullrich
|
if [ -f /tmp/remove_backup ]; then
|
2379 |
|
|
/bin/rm -rf /conf/backup
|
2380 |
|
|
/bin/rm /tmp/remove_backup
|
2381 |
|
|
fi
|
2382 |
c09562f1
|
Scott Ullrich
|
|
2383 |
715fc3b0
|
Scott Ullrich
|
if [ -f /tmp/remove_conf_symlink ]; then
|
2384 |
|
|
/bin/rm /conf
|
2385 |
ec92d3ec
|
Scott Ullrich
|
if [ -h /cf ]; then
|
2386 |
|
|
/bin/rm /cf
|
2387 |
|
|
fi
|
2388 |
715fc3b0
|
Scott Ullrich
|
/bin/rm /tmp/remove_conf_symlink
|
2389 |
|
|
fi
|
2390 |
c09562f1
|
Scott Ullrich
|
|
2391 |
715fc3b0
|
Scott Ullrich
|
if [ -f /tmp/restore_conf_dir ]; then
|
2392 |
|
|
/bin/mv /conf.org /conf
|
2393 |
|
|
/bin/rm /tmp/restore_conf_dir
|
2394 |
|
|
fi
|
2395 |
c09562f1
|
Scott Ullrich
|
|
2396 |
5dac6788
|
Scott Ullrich
|
if [ -f /tmp/platform ]; then
|
2397 |
|
|
mv /tmp/platform /etc/platform
|
2398 |
|
|
fi
|
2399 |
c09562f1
|
Scott Ullrich
|
|
2400 |
715fc3b0
|
Scott Ullrich
|
/bin/rm /tmp/pfspkg_installer
|
2401 |
c09562f1
|
Scott Ullrich
|
|
2402 |
715fc3b0
|
Scott Ullrich
|
/bin/rm /tmp/pkgfile.lst
|
2403 |
c09562f1
|
Scott Ullrich
|
|
2404 |
82c141c3
|
Scott Ullrich
|
/bin/rm /tmp/*.log /tmp/*.tbz 2>/dev/null
|
2405 |
715fc3b0
|
Scott Ullrich
|
|
2406 |
82c141c3
|
Scott Ullrich
|
if [ -f /tmp/config.cache ]; then
|
2407 |
|
|
/bin/rm /tmp/config.cache
|
2408 |
|
|
fi
|
2409 |
715fc3b0
|
Scott Ullrich
|
|
2410 |
|
|
/bin/rm /etc/resolv.conf
|
2411 |
|
|
|
2412 |
8b3e521b
|
Scott Ullrich
|
/bin/rm /${PFSDESTNAME}
|
2413 |
c09562f1
|
Scott Ullrich
|
|
2414 |
98b1c984
|
Renato Botelho
|
if [ -f /tmp/php.ini ]; then
|
2415 |
|
|
cp /tmp/php.ini /usr/local/lib/php.ini
|
2416 |
76250646
|
Scott Ullrich
|
cp /tmp/php.ini /usr/local/etc/php.ini
|
2417 |
89b34627
|
Scott Ullrich
|
fi
|
2418 |
b7ce9945
|
Scott Ullrich
|
|
2419 |
c09562f1
|
Scott Ullrich
|
EOF
|
2420 |
|
|
|
2421 |
adbddb0e
|
Ermal
|
echo ">>> Installing custom pfSense-XML packages inside chroot ..." | tee -a ${LOGFILE}
|
2422 |
8b3e521b
|
Scott Ullrich
|
chmod a+rx ${PFSTODIR}/${PFSDESTNAME}
|
2423 |
|
|
chroot ${PFSTODIR} /bin/sh /${PFSDESTNAME}
|
2424 |
5f3f0437
|
Renato Botelho
|
rc=$?
|
2425 |
adbddb0e
|
Ermal
|
echo ">>> Unmounting ${PFSTODIR}/dev ..." | tee -a ${LOGFILE}
|
2426 |
8b3e521b
|
Scott Ullrich
|
umount -f ${PFSTODIR}/dev
|
2427 |
98b1c984
|
Renato Botelho
|
|
2428 |
5f3f0437
|
Renato Botelho
|
if [ "${rc}" != "0" ]; then
|
2429 |
adbddb0e
|
Ermal
|
echo ">>> ERROR: Error installing custom packages" | tee -a ${LOGFILE}
|
2430 |
|
|
print_error_pfS
|
2431 |
5f3f0437
|
Renato Botelho
|
fi
|
2432 |
98b1c984
|
Renato Botelho
|
fi
|
2433 |
c09562f1
|
Scott Ullrich
|
}
|
2434 |
b32ea4a0
|
Scott Ullrich
|
|
2435 |
aa0bbaae
|
Scott Ullrich
|
# Cleans up previous builds
|
2436 |
b32ea4a0
|
Scott Ullrich
|
pfSense_clean_obj_dir() {
|
2437 |
4de1dcf7
|
Scott Ullrich
|
# Clean out directories
|
2438 |
e32ec942
|
Ermal
|
echo ">>> Cleaning up previous build environment...Please wait!"
|
2439 |
|
|
|
2440 |
88138431
|
Ermal
|
staginareas_clean_each_run
|
2441 |
2c5ee627
|
Ermal
|
|
2442 |
f0854217
|
Ermal
|
if [ -d "${PFSENSESTAGEDIR}" ]; then
|
2443 |
|
|
BASENAME=`basename ${PFSENSESTAGEDIR}`
|
2444 |
b95b3cec
|
Ermal
|
echo -n ">>> Cleaning ${PFSENSESTAGEDIR} ..."
|
2445 |
5f4ee2ba
|
Renato Botelho
|
chflags -R noschg ${PFSENSESTAGEDIR} 2>&1 >/dev/null
|
2446 |
|
|
rm -rf ${PFSENSESTAGEDIR} 2>/dev/null
|
2447 |
b95b3cec
|
Ermal
|
echo "Done."
|
2448 |
f0854217
|
Ermal
|
fi
|
2449 |
2757de22
|
Ermal
|
mkdir -p ${PFSENSESTAGEDIR}
|
2450 |
f0854217
|
Ermal
|
|
2451 |
859b069b
|
Ermal
|
if [ -z "${NO_CLEANFREEBSDOBJDIR}" ]; then
|
2452 |
|
|
if [ -d "$MAKEOBJDIRPREFIX" ]; then
|
2453 |
adbddb0e
|
Ermal
|
echo -n ">>> Cleaning FreeBSD objects dir staging..."
|
2454 |
859b069b
|
Ermal
|
echo -n "."
|
2455 |
|
|
chflags -R noschg ${MAKEOBJDIRPREFIX} 2>&1 >/dev/null
|
2456 |
|
|
echo -n "."
|
2457 |
|
|
rm -rf ${MAKEOBJDIRPREFIX}/*
|
2458 |
adbddb0e
|
Ermal
|
echo "Done!"
|
2459 |
|
|
fi
|
2460 |
|
|
if [ -n "${KERNEL_DESTDIR}" -a -d "${KERNEL_BUILD_PATH}" ]; then
|
2461 |
|
|
echo -n ">>> Cleaning previously built kernel stage area..."
|
2462 |
|
|
rm -rf $KERNEL_BUILD_PATH/*
|
2463 |
|
|
echo "Done!"
|
2464 |
859b069b
|
Ermal
|
fi
|
2465 |
e32ec942
|
Ermal
|
fi
|
2466 |
2757de22
|
Ermal
|
mkdir -p $MAKEOBJDIRPREFIX
|
2467 |
|
|
mkdir -p $KERNEL_BUILD_PATH
|
2468 |
e32ec942
|
Ermal
|
|
2469 |
|
|
|
2470 |
9dc88cbb
|
Ermal
|
echo -n ">>> Cleaning previously built images..."
|
2471 |
|
|
rm -rf $MAKEOBJDIRPREFIXFINAL/*
|
2472 |
|
|
echo "Done!"
|
2473 |
|
|
|
2474 |
859b069b
|
Ermal
|
if [ -z "${NO_CLEANREPOS}" ]; then
|
2475 |
|
|
if [ -d "${GIT_REPO_DIR}/pfSenseGITREPO" ]; then
|
2476 |
adbddb0e
|
Ermal
|
echo -n ">>> Cleaning pfSense repo checkout..."
|
2477 |
859b069b
|
Ermal
|
echo -n "."
|
2478 |
|
|
rm -rf "${GIT_REPO_DIR}/pfSenseGITREPO"
|
2479 |
adbddb0e
|
Ermal
|
echo "Done!"
|
2480 |
859b069b
|
Ermal
|
fi
|
2481 |
e32ec942
|
Ermal
|
|
2482 |
859b069b
|
Ermal
|
if [ -d "$SRCDIR" ]; then
|
2483 |
adbddb0e
|
Ermal
|
echo -n ">>> Ensuring $SRCDIR is clean..."
|
2484 |
859b069b
|
Ermal
|
rm -rf ${SRCDIR}
|
2485 |
adbddb0e
|
Ermal
|
echo "Done!"
|
2486 |
859b069b
|
Ermal
|
fi
|
2487 |
e32ec942
|
Ermal
|
fi
|
2488 |
|
|
|
2489 |
|
|
echo -n ">>> Cleaning previous builder logs..."
|
2490 |
|
|
if [ -d "$BUILDER_LOGS" ]; then
|
2491 |
|
|
rm -rf ${BUILDER_LOGS}
|
2492 |
50b0396e
|
Ermal
|
fi
|
2493 |
2757de22
|
Ermal
|
mkdir -p ${BUILDER_LOGS}
|
2494 |
|
|
|
2495 |
81ea347c
|
Ermal
|
echo "Done!"
|
2496 |
|
|
|
2497 |
e32ec942
|
Ermal
|
echo ">>> Cleaning of builder environment has finished."
|
2498 |
b32ea4a0
|
Scott Ullrich
|
}
|
2499 |
cf000667
|
Scott Ullrich
|
|
2500 |
aa0bbaae
|
Scott Ullrich
|
# This copies the default config.xml to the location on
|
2501 |
|
|
# disk as the primary configuration file.
|
2502 |
cf000667
|
Scott Ullrich
|
copy_config_xml_from_conf_default() {
|
2503 |
adbddb0e
|
Ermal
|
# XXX: Wouldn't this overwrite any pre-installed pacakge info and customization as called so late today!!??
|
2504 |
|
|
if [ ! -f "${PFSENSEISODIR}/cf/conf/config.xml" ]; then
|
2505 |
|
|
if [ ! -f "${PFSENSEISODIR}/conf.default/config.xml" ]; then
|
2506 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: There is no config.xml in the stage area ${PFSENSEISODIR}...STOPPING!" | tee -a ${LOGFILE}
|
2507 |
aa156962
|
Ermal
|
print_error_pfS
|
2508 |
|
|
kill $$
|
2509 |
|
|
fi
|
2510 |
adbddb0e
|
Ermal
|
echo ">>> Copying config.xml from conf.default/ to cf/conf/" | tee -a ${LOGFILE}
|
2511 |
|
|
cp ${PFSENSEISODIR}/conf.default/config.xml ${PFSENSEISODIR}/cf/conf/
|
2512 |
cf000667
|
Scott Ullrich
|
fi
|
2513 |
|
|
}
|
2514 |
ac3c9345
|
Scott Ullrich
|
|
2515 |
aa0bbaae
|
Scott Ullrich
|
# Rebuilds and installs the BSDInstaller which populates
|
2516 |
|
|
# the Ports directory sysutils/bsdinstaller, etc.
|
2517 |
8d03860e
|
Ermal
|
rebuild_bsdinstaller() {
|
2518 |
107b1796
|
Scott Ullrich
|
# Add BSDInstaller
|
2519 |
4943b656
|
Ermal
|
cd ${BUILDER_SCRIPTS}
|
2520 |
adbddb0e
|
Ermal
|
BSDINSTALLPKG=$(make -C /usr/ports/sysutils/bsdinstaller -V PKGNAME)
|
2521 |
db8a0589
|
Ermal
|
if [ -f "/usr/ports/packages/All/$BSDINSTALLPKG.txz" -o -f "/usr/ports/packages/All/$BSDINSTALLPKG.tgz" -o -f "/usr/ports/packages/All/$BSDINSTALLPKG.tbz" ]; then
|
2522 |
adbddb0e
|
Ermal
|
echo ">>> Found $BSDINSTALLPKG pre-built package using that not rebuilding from source!"
|
2523 |
|
|
else
|
2524 |
|
|
${BUILDER_SCRIPTS}/scripts/rebuild_bsdinstaller.sh
|
2525 |
|
|
fi
|
2526 |
|
|
unset BSDINSTALLPKG
|
2527 |
107b1796
|
Scott Ullrich
|
}
|
2528 |
|
|
|
2529 |
aa0bbaae
|
Scott Ullrich
|
# This routine ensures that the $SRCDIR has sources
|
2530 |
|
|
# and is ready for action / building.
|
2531 |
107b1796
|
Scott Ullrich
|
ensure_source_directories_present() {
|
2532 |
|
|
# Sanity check
|
2533 |
|
|
if [ ! -d "${PFSPATCHDIR}" ]; then
|
2534 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: PFSPATCHDIR=${PFSPATCHDIR} is not a directory -- Please fix."
|
2535 |
dc311604
|
Scott Ullrich
|
print_error_pfS
|
2536 |
cc9f6cf9
|
Scott Ullrich
|
kill $$
|
2537 |
107b1796
|
Scott Ullrich
|
fi
|
2538 |
8d03860e
|
Ermal
|
|
2539 |
|
|
update_freebsd_sources_and_apply_patches
|
2540 |
|
|
|
2541 |
|
|
update_pfSense_repository
|
2542 |
|
|
|
2543 |
adbddb0e
|
Ermal
|
# BSDInstaller is treated when needed
|
2544 |
|
|
${BUILDER_SCRIPTS}/scripts/get_bsdinstaller.sh
|
2545 |
107b1796
|
Scott Ullrich
|
}
|
2546 |
|
|
|
2547 |
859b069b
|
Ermal
|
clone_directory_contents() {
|
2548 |
|
|
if [ ! -d $1 -o ! -d $2 ]; then
|
2549 |
|
|
if [ -z "${LOGFILE}" ]; then
|
2550 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Argument $1 supplied is not a directory!"
|
2551 |
859b069b
|
Ermal
|
else
|
2552 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Argument $1 supplied is not a directory!" | tee -a ${LOGFILE}
|
2553 |
859b069b
|
Ermal
|
fi
|
2554 |
|
|
print_error_pfS
|
2555 |
|
|
kill $$
|
2556 |
|
|
fi
|
2557 |
a3ada7df
|
Scott Ullrich
|
OLDPWD=`pwd`
|
2558 |
859b069b
|
Ermal
|
echo -n ">>> Using TAR to clone $1 to $2 ..."
|
2559 |
|
|
cd ${1}
|
2560 |
|
|
tar -c -f - * | ( cd $2; tar -x -p -f -)
|
2561 |
|
|
echo "Done!"
|
2562 |
a3ada7df
|
Scott Ullrich
|
cd $OLDPWD
|
2563 |
859b069b
|
Ermal
|
unset OLDPWD
|
2564 |
a3ada7df
|
Scott Ullrich
|
}
|
2565 |
|
|
|
2566 |
94985add
|
Ermal
|
clone_to_staging_area() {
|
2567 |
|
|
|
2568 |
|
|
OLDPWD=`pwd`
|
2569 |
|
|
# Clone everything to the final staging area
|
2570 |
|
|
echo -n ">>> Cloning everything to ${PFSENSESTAGEDIR} staging area..."
|
2571 |
9f2a340a
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/cloning.${TARGET}.log
|
2572 |
94985add
|
Ermal
|
|
2573 |
237b4cfc
|
Ermal
|
if [ ! -d ${GIT_REPO_DIR}/pfSenseGITREPO ]; then
|
2574 |
94985add
|
Ermal
|
echo "ERROR!"
|
2575 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: pfSense repository does not seem to be there please fix...STOPPING!" | tee -a ${LOGFILE}
|
2576 |
94985add
|
Ermal
|
print_error_pfS
|
2577 |
|
|
fi
|
2578 |
|
|
|
2579 |
a853e0b8
|
Ermal
|
cd ${GIT_REPO_DIR}/pfSenseGITREPO
|
2580 |
|
|
tar --exclude=\.git -c -f - * | ( cd $PFSENSESTAGEDIR; tar -x -p -f -)
|
2581 |
94985add
|
Ermal
|
|
2582 |
|
|
if [ -f ${PFSENSESTAGEDIR}/etc/master.passwd ]; then
|
2583 |
|
|
chroot ${PFSENSESTAGEDIR} cap_mkdb /etc/master.passwd
|
2584 |
|
|
chroot ${PFSENSESTAGEDIR} pwd_mkdb /etc/master.passwd
|
2585 |
|
|
fi
|
2586 |
|
|
cd $OLDPWD
|
2587 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/etc/mtree
|
2588 |
|
|
mtree -Pcp ${PFSENSESTAGEDIR}/root > ${PFSENSESTAGEDIR}/etc/mtree/root.dist
|
2589 |
|
|
mtree -Pcp ${PFSENSESTAGEDIR}/var > ${PFSENSESTAGEDIR}/etc/mtree/var.dist
|
2590 |
|
|
mtree -Pcp ${PFSENSESTAGEDIR}/etc > ${PFSENSESTAGEDIR}/etc/mtree/etc.dist
|
2591 |
|
|
if [ -d ${PFSENSESTAGEDIR}/usr/local/etc ]; then
|
2592 |
|
|
mtree -Pcp ${PFSENSESTAGEDIR}/usr/local/etc > ${PFSENSESTAGEDIR}/etc/mtree/localetc.dist
|
2593 |
|
|
fi
|
2594 |
|
|
echo "Done!"
|
2595 |
|
|
unset OLDPWD
|
2596 |
|
|
}
|
2597 |
|
|
|
2598 |
adbddb0e
|
Ermal
|
create_final_staging_area() {
|
2599 |
|
|
if [ -z "${PFSENSEISODIR}" ]; then
|
2600 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: PFSENSEISODIR is not set, cannot continue!" | tee -a ${LOGFILE}
|
2601 |
adbddb0e
|
Ermal
|
print_error_pfS
|
2602 |
|
|
fi
|
2603 |
|
|
|
2604 |
|
|
if [ -d "${PFSENSEISODIR}" ]; then
|
2605 |
|
|
echo -n ">>> Previous ${PFSENSEISODIR} detected cleaning up..." | tee -a ${LOGFILE}
|
2606 |
|
|
chflags -R noschg ${PFSENSEISODIR} 2>&1 1>/dev/null
|
2607 |
d13406a5
|
Ermal
|
rm -rf ${PFSENSEISODIR}/* 2>&1 1>/dev/null
|
2608 |
adbddb0e
|
Ermal
|
echo "Done." | tee -a ${LOGFILE}
|
2609 |
859b069b
|
Ermal
|
fi
|
2610 |
adbddb0e
|
Ermal
|
mkdir -p ${PFSENSEISODIR}
|
2611 |
9d8feb2c
|
jim-p
|
|
2612 |
adbddb0e
|
Ermal
|
echo ">>> Preparing Final image staging area: `LC_ALL=C date` - from ${PFSENSESTAGEDIR} to ${PFSENSEISODIR}" 2>&1 | tee -a ${LOGFILE}
|
2613 |
859b069b
|
Ermal
|
if [ -z "${NO_COMPRESSEDFS:-}" ]; then
|
2614 |
|
|
mkdir -p ${PFSENSEISODIR}/uzip
|
2615 |
|
|
mkdir -p ${PFSENSEISODIR}/usr
|
2616 |
|
|
DIRSIZE=$(($(du -kd 0 $PFSENSESTAGEDIR | cut -f 1)))
|
2617 |
|
|
FSSIZE=$(($DIRSIZE + ($DIRSIZE/5)))
|
2618 |
|
|
if [ -f ${PFSENSEISODIR}/uzip/usr.ufs ]; then
|
2619 |
|
|
rm -f ${PFSENSEISODIR}/uzip/usr.ufs
|
2620 |
|
|
fi
|
2621 |
|
|
dd if=/dev/zero of=${PFSENSEISODIR}/uzip/usr.ufs bs=1k count=1 seek=$((${FSSIZE} - 1)) 2>&1 | tee -a ${LOGFILE}
|
2622 |
|
|
MD=`mdconfig -a -t vnode -f ${PFSENSEISODIR}/uzip/usr.ufs`
|
2623 |
90fabf95
|
Ermal
|
# Just in case
|
2624 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}" 1 2 15 EXIT
|
2625 |
859b069b
|
Ermal
|
newfs -o space /dev/${MD} 2>&1 | tee -a ${LOGFILE}
|
2626 |
|
|
mount -o noatime /dev/${MD} ${PFSENSEISODIR}/usr 2>&1 | tee -a ${LOGFILE}
|
2627 |
d13406a5
|
Ermal
|
trap "umount -f ${PFSENSEISODIR}/usr; mdconfig -d -u ${MD}" 1 2 15 EXIT
|
2628 |
9d8feb2c
|
jim-p
|
fi
|
2629 |
|
|
|
2630 |
859b069b
|
Ermal
|
clone_directory_contents ${PFSENSESTAGEDIR} ${PFSENSEISODIR}
|
2631 |
|
|
|
2632 |
adbddb0e
|
Ermal
|
# Create a copy of this file just in case
|
2633 |
|
|
cp $PFSENSEISODIR/etc/gettytab $PFSENSEISODIR/etc/gettytab.bak
|
2634 |
|
|
|
2635 |
859b069b
|
Ermal
|
if [ ! -f $PFSENSEISODIR/sbin/init ]; then
|
2636 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something went wrong during cloning -- Please verify!" 2>&1 | tee -a ${LOGFILE}
|
2637 |
859b069b
|
Ermal
|
print_error_pfS
|
2638 |
|
|
kill $$
|
2639 |
|
|
fi
|
2640 |
|
|
|
2641 |
|
|
if [ -z "${NO_COMPRESSEDFS:-}" ]; then
|
2642 |
|
|
umount -f ${PFSENSEISODIR}/usr
|
2643 |
|
|
mdconfig -d -u ${MD}
|
2644 |
90fabf95
|
Ermal
|
# Restore functionality
|
2645 |
d13406a5
|
Ermal
|
trap "-" 1 2 15 EXIT
|
2646 |
859b069b
|
Ermal
|
|
2647 |
|
|
echo -n ">>> Compressing ${PFSENSEISODIR}/uzip/ufs.ufs ..."
|
2648 |
|
|
mkuzip -s 65536 -o ${PFSENSEISODIR}/uzip/usr.uzip ${PFSENSEISODIR}/uzip/usr.ufs 2>&1 | tee -a ${LOGFILE}
|
2649 |
|
|
if [ $? -ne 0 ]; then
|
2650 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something went wrong during compressing -- Please verify!" 2>&1 | tee -a ${LOGFILE}
|
2651 |
859b069b
|
Ermal
|
print_error_pfS
|
2652 |
|
|
kill $$
|
2653 |
|
|
fi
|
2654 |
|
|
echo "Done!"
|
2655 |
|
|
fi
|
2656 |
|
|
|
2657 |
|
|
echo -n ">>> Copying rc.d needed scripts..."
|
2658 |
|
|
# Copy file needed by iso image
|
2659 |
|
|
for file in uzip etcmfs varmfs rootmfs; do
|
2660 |
|
|
cp ${BUILDER_SCRIPTS}/scripts/rc.d/$file ${PFSENSEISODIR}/etc/rc.d/ 2>&1 | tee -a ${LOGFILE}
|
2661 |
|
|
chmod 555 ${PFSENSEISODIR}/etc/rc.d/$file 2>&1 | tee -a ${LOGFILE}
|
2662 |
|
|
done
|
2663 |
|
|
echo "Done!"
|
2664 |
|
|
|
2665 |
|
|
mkdir -p ${PFSENSEISODIR}/dist
|
2666 |
|
|
mtree -Pcp ${PFSENSEISODIR} | bzip2 -9 > ${PFSENSEISODIR}/dist/root.dist.bz2
|
2667 |
|
|
}
|
2668 |
|
|
|
2669 |
adbddb0e
|
Ermal
|
customize_stagearea_for_image() {
|
2670 |
|
|
# Prepare final stage area
|
2671 |
|
|
create_final_staging_area
|
2672 |
859b069b
|
Ermal
|
|
2673 |
adbddb0e
|
Ermal
|
# This check is for supporting create memstick/ova images
|
2674 |
|
|
if [ "${1}" = "iso" -o "${1}" = "memstick" -o "${1}" = "memstickserial" ]; then
|
2675 |
|
|
# Fetch BSDInstaller and rebuild
|
2676 |
|
|
rebuild_bsdinstaller
|
2677 |
|
|
|
2678 |
385877a8
|
Renato Botelho
|
echo ">>> Searching for BSDInstaller..." | tee -a ${LOGFILE}
|
2679 |
adbddb0e
|
Ermal
|
if [ "$PFSPKGFILE" = "" ]; then
|
2680 |
|
|
PFSPKGFILE=${SCRATCHDIR}/pfspackages
|
2681 |
|
|
echo ">> PFSPKGFILE is not defined. Setting to ${PFSPKGFILE}." | tee -a ${LOGFILE}
|
2682 |
|
|
fi
|
2683 |
|
|
(${PKG_INFO} | grep bsdinstaller) > $PFSPKGFILE
|
2684 |
|
|
(${PKG_INFO} | grep lua) >> $PFSPKGFILE
|
2685 |
|
|
|
2686 |
|
|
echo $PFSPKGFILE >> ${LOGFILE}
|
2687 |
|
|
echo ">>> Installing BSDInstaller: " | tee -a ${LOGFILE}
|
2688 |
|
|
if [ ${FREEBSD_VERSION} -ge 10 ]; then
|
2689 |
|
|
(${BUILDER_SCRIPTS}/scripts/pkgnginstall.sh)
|
2690 |
|
|
else
|
2691 |
|
|
(${BUILDER_SCRIPTS}/scripts/pkginstall.sh)
|
2692 |
|
|
fi
|
2693 |
|
|
|
2694 |
|
|
# Add installer bits
|
2695 |
|
|
cust_populate_installer_bits
|
2696 |
|
|
|
2697 |
|
|
# Check to see if we have a healthy installer
|
2698 |
|
|
ensure_healthy_installer
|
2699 |
|
|
else
|
2700 |
|
|
echo ">>> BSDInstaller not being put into image type: ${1}" | tee -a ${LOGFILE}
|
2701 |
|
|
fi
|
2702 |
859b069b
|
Ermal
|
|
2703 |
adbddb0e
|
Ermal
|
# Add extra files such as buildtime of version, bsnmpd, etc.
|
2704 |
|
|
cust_populate_extra
|
2705 |
|
|
|
2706 |
a21dfd04
|
Ermal
|
install_custom_overlay
|
2707 |
|
|
|
2708 |
adbddb0e
|
Ermal
|
# Check for custom config.xml
|
2709 |
|
|
cust_install_config_xml
|
2710 |
|
|
|
2711 |
|
|
# Install custom pfSense-XML packages from a chroot
|
2712 |
|
|
pfsense_install_custom_packages_exec
|
2713 |
|
|
|
2714 |
|
|
# Overlay final files
|
2715 |
|
|
install_custom_overlay_final
|
2716 |
|
|
|
2717 |
|
|
# Ensure config.xml exists
|
2718 |
|
|
copy_config_xml_from_conf_default
|
2719 |
|
|
|
2720 |
|
|
# Test PHP installation
|
2721 |
|
|
test_php_install
|
2722 |
|
|
|
2723 |
|
|
# Overlay any loader.conf customziations
|
2724 |
|
|
install_extra_loader_conf_options
|
2725 |
|
|
|
2726 |
|
|
# Create md5 summary file listing checksums
|
2727 |
|
|
create_md5_summary_file
|
2728 |
|
|
|
2729 |
|
|
# Create mtree summary file listing owner/permissions/sha256 and similar
|
2730 |
|
|
create_mtree_summary_file
|
2731 |
|
|
|
2732 |
|
|
# Setup serial port helper hints
|
2733 |
|
|
setup_serial_hints
|
2734 |
|
|
|
2735 |
|
|
# Allow a custom function to be called from pfsense-build.conf
|
2736 |
|
|
# example: disable_lan_disable_dhcpd_enable_sshd
|
2737 |
|
|
if [ -n "$CUSTOM_CALL_SHELL_FUNCTION" ]; then
|
2738 |
|
|
eval $CUSTOM_CALL_SHELL_FUNCTION
|
2739 |
|
|
fi
|
2740 |
|
|
|
2741 |
|
|
}
|
2742 |
|
|
|
2743 |
|
|
create_iso_image() {
|
2744 |
|
|
LOGFILE=${BUILDER_LOGS}/isoimage.${TARGET}
|
2745 |
9f2a340a
|
Ermal
|
echo ">>> Building bootable ISO image for ${TARGET}" | tee -a ${LOGFILE}
|
2746 |
adbddb0e
|
Ermal
|
if [ -z "${DEFAULT_KERNEL}" ]; then
|
2747 |
|
|
echo ">>> ERROR: Could not identify DEFAULT_KERNEL to install on image!" | tee -a ${LOGFILE}
|
2748 |
|
|
print_error_pfS
|
2749 |
|
|
fi
|
2750 |
|
|
|
2751 |
|
|
customize_stagearea_for_image "iso"
|
2752 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
2753 |
|
|
|
2754 |
|
|
echo cdrom > $PFSENSEISODIR/etc/platform
|
2755 |
859b069b
|
Ermal
|
|
2756 |
|
|
FSLABEL=`echo ${PRODUCT_NAME} | tr '[:lower:]' '[:upper:]'`
|
2757 |
|
|
echo "/dev/iso9660/${FSLABEL} / cd9660 ro 0 0" > ${PFSENSEISODIR}/etc/fstab
|
2758 |
|
|
|
2759 |
adbddb0e
|
Ermal
|
# This check is for supporting create memstick/ova images
|
2760 |
859b069b
|
Ermal
|
echo -n ">>> Running command: script -aq $LOGFILE makefs -t cd9660 -o bootimage=\"i386;${PFSENSEISODIR}/boot/cdboot \"-o no-emul-boot -o rockridge " | tee -a ${LOGFILE}
|
2761 |
|
|
echo "-o label=${FSLABEL} -o publisher=\"${PRODUCT_NAME} project.\" $ISOPATH ${PFSENSEISODIR}" | tee -a ${LOGFILE}
|
2762 |
7203485d
|
Ermal
|
makefs -t cd9660 -o bootimage="i386;${PFSENSEISODIR}/boot/cdboot" -o no-emul-boot -o rockridge \
|
2763 |
|
|
-o label=${FSLABEL} -o publisher="${PRODUCT_NAME} project." $ISOPATH ${PFSENSEISODIR} 2>&1 >> ${LOGFILE}
|
2764 |
859b069b
|
Ermal
|
if [ $? -ne 0 -o ! -f $ISOPATH ]; then
|
2765 |
7203485d
|
Ermal
|
if [ -f ${ISOPATH} ]; then
|
2766 |
|
|
rm -f $ISOPATH
|
2767 |
|
|
fi
|
2768 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something wrong happened during ISO image creation. STOPPING!" | tee -a ${LOGFILE}
|
2769 |
859b069b
|
Ermal
|
print_error_pfS
|
2770 |
|
|
kill $$
|
2771 |
|
|
fi
|
2772 |
d13406a5
|
Ermal
|
gzip -qf $ISOPATH &
|
2773 |
859b069b
|
Ermal
|
|
2774 |
|
|
echo ">>> ISO created: `LC_ALL=C date`" | tee -a ${LOGFILE}
|
2775 |
|
|
}
|
2776 |
|
|
|
2777 |
|
|
create_memstick_image() {
|
2778 |
|
|
|
2779 |
9f2a340a
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/memstick.${TARGET}
|
2780 |
859b069b
|
Ermal
|
if [ "${MEMSTICKPATH}" = "" ]; then
|
2781 |
|
|
echo ">>> MEMSTICKPATH is empty skipping generation of memstick image!" | tee -a ${LOGFILE}
|
2782 |
|
|
return
|
2783 |
|
|
fi
|
2784 |
|
|
|
2785 |
1d7418c0
|
Ermal
|
if [ ! -d ${PFSENSEISODIR}/boot ]; then
|
2786 |
adbddb0e
|
Ermal
|
customize_stagearea_for_image "memstick"
|
2787 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
2788 |
859b069b
|
Ermal
|
fi
|
2789 |
|
|
|
2790 |
adbddb0e
|
Ermal
|
echo cdrom > $PFSENSEISODIR/etc/platform
|
2791 |
|
|
|
2792 |
859b069b
|
Ermal
|
echo ">>> Creating memstick to ${MEMSTICKPATH}." 2>&1 | tee -a ${LOGFILE}
|
2793 |
1e2a00fd
|
Ermal
|
echo "/dev/ufs/${PRODUCT_NAME} / ufs ro 0 0" > ${PFSENSEISODIR}/etc/fstab
|
2794 |
859b069b
|
Ermal
|
echo "kern.cam.boot_delay=10000" >> ${PFSENSEISODIR}/boot/loader.conf.local
|
2795 |
7391ce79
|
Ermal
|
if [ $FREEBSD_VERSION -lt 10 ]; then
|
2796 |
|
|
makefs -B little ${MEMSTICKPATH} ${PFSENSEISODIR}
|
2797 |
|
|
else
|
2798 |
|
|
makefs -B little -o label=${PRODUCT_NAME} ${MEMSTICKPATH} ${PFSENSEISODIR}
|
2799 |
|
|
fi
|
2800 |
859b069b
|
Ermal
|
if [ $? -ne 0 ]; then
|
2801 |
7203485d
|
Ermal
|
if [ -f ${MEMSTICKPATH} ]; then
|
2802 |
|
|
rm -f $MEMSTICKPATH
|
2803 |
|
|
fi
|
2804 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something wrong happened during MEMSTICK image creation. STOPPING!" | tee -a ${LOGFILE}
|
2805 |
859b069b
|
Ermal
|
print_error_pfS
|
2806 |
|
|
kill $$
|
2807 |
|
|
fi
|
2808 |
8c67da63
|
Ermal
|
MD=$(mdconfig -a -t vnode -f $MEMSTICKPATH)
|
2809 |
90fabf95
|
Ermal
|
# Just in case
|
2810 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}" 1 2 15 EXIT
|
2811 |
7203485d
|
Ermal
|
gpart create -s BSD ${MD} 2>&1 >> ${LOGFILE}|
|
2812 |
|
|
gpart bootcode -b ${PFSENSEISODIR}/boot/boot ${MD} 2>&1 >> ${LOGFILE}
|
2813 |
|
|
gpart add -t freebsd-ufs ${MD} 2>&1 >> ${LOGFILE}
|
2814 |
7391ce79
|
Ermal
|
if [ $FREEBSD_VERSION -lt 10 ]; then
|
2815 |
|
|
tunefs -L ${PRODUCT_NAME} /dev/${MD}
|
2816 |
|
|
fi
|
2817 |
d13406a5
|
Ermal
|
trap "-" 1 2 15 EXIT
|
2818 |
859b069b
|
Ermal
|
mdconfig -d -u ${MD} 2>&1 | tee -a ${LOGFILE}
|
2819 |
d13406a5
|
Ermal
|
gzip -qf $MEMSTICKPATH &
|
2820 |
7203485d
|
Ermal
|
|
2821 |
|
|
echo ">>> MEMSTICK created: `LC_ALL=C date`" | tee -a ${LOGFILE}
|
2822 |
859b069b
|
Ermal
|
}
|
2823 |
|
|
|
2824 |
|
|
create_memstick_serial_image() {
|
2825 |
9f2a340a
|
Ermal
|
LOGFILE=${BUILDER_LOGS}/memstickserial.${TARGET}
|
2826 |
9d8feb2c
|
jim-p
|
if [ "${MEMSTICKSERIALPATH}" = "" ]; then
|
2827 |
859b069b
|
Ermal
|
echo ">>> MEMSTICKSERIALPATH is empty skipping generation of memstick image!" | tee -a ${LOGFILE}
|
2828 |
|
|
return
|
2829 |
9d8feb2c
|
jim-p
|
fi
|
2830 |
|
|
|
2831 |
1d7418c0
|
Ermal
|
if [ ! -d ${PFSENSEISODIR}/boot ]; then
|
2832 |
adbddb0e
|
Ermal
|
customize_stagearea_for_image "memstickserial"
|
2833 |
|
|
install_default_kernel ${DEFAULT_KERNEL}
|
2834 |
859b069b
|
Ermal
|
fi
|
2835 |
adbddb0e
|
Ermal
|
|
2836 |
|
|
echo cdrom > $PFSENSEISODIR/etc/platform
|
2837 |
|
|
|
2838 |
1e2a00fd
|
Ermal
|
echo "/dev/ufs/${PRODUCT_NAME} / ufs ro 0 0" > ${PFSENSEISODIR}/etc/fstab
|
2839 |
859b069b
|
Ermal
|
echo "kern.cam.boot_delay=10000" >> ${PFSENSEISODIR}/boot/loader.conf.local
|
2840 |
9d8feb2c
|
jim-p
|
|
2841 |
859b069b
|
Ermal
|
echo ">>> Creating serial memstick to ${MEMSTICKSERIALPATH}." 2>&1 | tee -a ${LOGFILE}
|
2842 |
|
|
|
2843 |
|
|
BOOTCONF=${PFSENSEISODIR}/boot.config
|
2844 |
|
|
LOADERCONF=${PFSENSEISODIR}/boot/loader.conf
|
2845 |
|
|
ACTIVECONF=${PFSENSEISODIR}/cf/conf/config.xml
|
2846 |
|
|
DEFAULTCONF=${PFSENSEISODIR}/conf.default/config.xml
|
2847 |
|
|
TTYS=${PFSENSEISODIR}/etc/ttys
|
2848 |
|
|
|
2849 |
|
|
echo ">>> Activating serial console..." 2>&1 | tee -a ${LOGFILE}
|
2850 |
9d8feb2c
|
jim-p
|
# Activate serial console in boot.config
|
2851 |
|
|
if [ -f ${BOOTCONF} ]; then
|
2852 |
|
|
sed -i "" '/^-D$/d' ${BOOTCONF}
|
2853 |
|
|
fi
|
2854 |
|
|
echo "-D" >> ${BOOTCONF}
|
2855 |
|
|
|
2856 |
|
|
# Activate serial console in config.xml
|
2857 |
|
|
# If it was there before, clear the setting to be sure we don't add it twice.
|
2858 |
|
|
sed -i "" -e "/ <enableserial\/>/d" ${ACTIVECONF}
|
2859 |
|
|
# Enable serial in the config
|
2860 |
|
|
sed -i "" -e "s/ <\/system>/ <enableserial\/>\\`echo -e \\\n` <\/system>/" ${ACTIVECONF}
|
2861 |
|
|
# Make sure to update the default config as well.
|
2862 |
|
|
cp ${ACTIVECONF} ${DEFAULTCONF}
|
2863 |
|
|
|
2864 |
|
|
# Remove old console options if present.
|
2865 |
|
|
sed -i "" -Ee "/(console|boot_multicons|boot_serial)/d" ${LOADERCONF}
|
2866 |
|
|
# Activate serial console+video console in loader.conf
|
2867 |
|
|
echo 'boot_multicons="YES"' >> ${LOADERCONF}
|
2868 |
|
|
echo 'boot_serial="YES"' >> ${LOADERCONF}
|
2869 |
|
|
echo 'console="comconsole,vidconsole"' >> ${LOADERCONF}
|
2870 |
|
|
|
2871 |
|
|
# Activate serial console TTY
|
2872 |
|
|
sed -i "" -Ee "s/^ttyu0.*$/ttyu0 \"\/usr\/libexec\/getty bootupcli\" cons25 on secure/" ${TTYS}
|
2873 |
|
|
|
2874 |
7391ce79
|
Ermal
|
if [ $FREEBSD_VERSION -lt 10 ]; then
|
2875 |
|
|
makefs -B little ${MEMSTICKSERIALPATH} ${PFSENSEISODIR}
|
2876 |
|
|
else
|
2877 |
|
|
makefs -B little -o label=${PRODUCT_NAME} ${MEMSTICKSERIALPATH} ${PFSENSEISODIR}
|
2878 |
|
|
fi
|
2879 |
859b069b
|
Ermal
|
if [ $? -ne 0 ]; then
|
2880 |
7203485d
|
Ermal
|
if [ -f ${MEMSTICKSERIALPATH} ]; then
|
2881 |
|
|
rm -f $MEMSTICKSERIALPATH
|
2882 |
|
|
fi
|
2883 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Something wrong happened during MEMSTICKSERIAL image creation. STOPPING!" | tee -a ${LOGFILE}
|
2884 |
859b069b
|
Ermal
|
print_error_pfS
|
2885 |
|
|
kill $$
|
2886 |
9d8feb2c
|
jim-p
|
fi
|
2887 |
8c67da63
|
Ermal
|
MD=$(mdconfig -a -t vnode -f $MEMSTICKSERIALPATH)
|
2888 |
90fabf95
|
Ermal
|
# Just in case
|
2889 |
d13406a5
|
Ermal
|
trap "mdconfig -d -u ${MD}" 1 2 15 EXIT
|
2890 |
7203485d
|
Ermal
|
gpart create -s BSD ${MD} 2>&1 >> ${LOGFILE}
|
2891 |
|
|
gpart bootcode -b ${PFSENSEISODIR}/boot/boot ${MD} 2>&1 >> ${LOGFILE}
|
2892 |
|
|
gpart add -t freebsd-ufs ${MD} 2>&1 >> ${LOGFILE}
|
2893 |
7391ce79
|
Ermal
|
if [ $FREEBSD_VERSION -lt 10 ]; then
|
2894 |
|
|
tunefs -L ${PRODUCT_NAME} /dev/${MD}
|
2895 |
|
|
fi
|
2896 |
d13406a5
|
Ermal
|
trap "-" 1 2 15 EXIT
|
2897 |
7203485d
|
Ermal
|
mdconfig -d -u ${MD} 2>&1 >> ${LOGFILE}
|
2898 |
d13406a5
|
Ermal
|
gzip -qf $MEMSTICKSERIALPATH &
|
2899 |
7203485d
|
Ermal
|
|
2900 |
|
|
echo ">>> MEMSTICKSERIAL created: `LC_ALL=C date`" | tee -a ${LOGFILE}
|
2901 |
9d8feb2c
|
jim-p
|
}
|
2902 |
|
|
|
2903 |
aa0bbaae
|
Scott Ullrich
|
# This routine ensures any ports / binaries that the builder
|
2904 |
|
|
# system needs are on disk and ready for execution.
|
2905 |
107b1796
|
Scott Ullrich
|
install_required_builder_system_ports() {
|
2906 |
|
|
# No ports exist, use portsnap to bootstrap.
|
2907 |
|
|
if [ ! -d "/usr/ports/" ]; then
|
2908 |
|
|
echo -n ">>> Grabbing FreeBSD port sources, please wait..."
|
2909 |
|
|
(/usr/sbin/portsnap fetch) 2>&1 | egrep -B3 -A3 -wi '(error)'
|
2910 |
|
|
(/usr/sbin/portsnap extract) 2>&1 | egrep -B3 -A3 -wi '(error)'
|
2911 |
|
|
echo "Done!"
|
2912 |
|
|
fi
|
2913 |
f0005be4
|
Ermal
|
|
2914 |
|
|
OIFS=$IFS
|
2915 |
30cf9c85
|
Scott Ullrich
|
IFS="
|
2916 |
|
|
"
|
2917 |
f0005be4
|
Ermal
|
|
2918 |
3b5d3287
|
Renato Botelho
|
for PKG_STRING in `cat ${PFSBUILDERREQUIREDPORTS} ${PFSBUILDERREQUIREDPORTS}.${FREEBSD_VERSION} 2>/dev/null`
|
2919 |
f0005be4
|
Ermal
|
do
|
2920 |
|
|
PKG_STRING_T=`echo $PKG_STRING | sed "s/[ ]+/ /g"`
|
2921 |
30cf9c85
|
Scott Ullrich
|
CHECK_ON_DISK=`echo $PKG_STRING_T | awk '{ print $1 }'`
|
2922 |
|
|
PORT_LOCATION=`echo $PKG_STRING_T | awk '{ print $2 }'`
|
2923 |
bf66ff0b
|
Ermal
|
UNSET_OPTS=`echo $PKG_STRING_T | awk '{ print $2 }' | sed 's/,/ /g'`
|
2924 |
107b1796
|
Scott Ullrich
|
if [ ! -f "$CHECK_ON_DISK" ]; then
|
2925 |
|
|
echo -n ">>> Building $PORT_LOCATION ..."
|
2926 |
e3ab69b2
|
Renato Botelho
|
(cd $PORT_LOCATION && env -u TARGET -u TARGET_ARCH make BATCH=yes deinstall clean) 2>&1 | egrep -B3 -A3 -wi '(error)'
|
2927 |
|
|
(cd $PORT_LOCATION && env -u TARGET -u TARGET_ARCH make ${MAKEJ_PORTS} WITHOUT="X11 DOCS EXAMPLES MAN INFO SDL ${UNSET_OPTS}" BATCH=yes FORCE_PKG_REGISTER=yes install clean) 2>&1 | egrep -B3 -A3 -wi '(error)'
|
2928 |
107b1796
|
Scott Ullrich
|
echo "Done!"
|
2929 |
|
|
fi
|
2930 |
|
|
done
|
2931 |
cc8b889e
|
Fernando Tarlá Cardoso Lemos
|
|
2932 |
f0005be4
|
Ermal
|
IFS=$OIFS
|
2933 |
107b1796
|
Scott Ullrich
|
}
|
2934 |
b3712708
|
Scott Ullrich
|
|
2935 |
aa0bbaae
|
Scott Ullrich
|
# Updates FreeBSD sources and applies any custom
|
2936 |
|
|
# patches that have been defined.
|
2937 |
107b1796
|
Scott Ullrich
|
update_freebsd_sources_and_apply_patches() {
|
2938 |
98b1c984
|
Renato Botelho
|
# No need to obtain sources or patch
|
2939 |
c9de5069
|
Scott Ullrich
|
# on subsequent build runs.
|
2940 |
98b1c984
|
Renato Botelho
|
|
2941 |
1c3c0d70
|
Renato Botelho
|
if [ ! -d "${SRCDIR}" ]; then
|
2942 |
|
|
mkdir -p ${SRCDIR}
|
2943 |
|
|
fi
|
2944 |
3efbed75
|
Ermal
|
|
2945 |
adbddb0e
|
Ermal
|
if [ -n "${NO_BUILDWORLD:-}" -a -n "${NO_BUILDKERNEL:-}" ]; then
|
2946 |
|
|
echo ">>> NO_BUILDWORLD and NO_BUILDKERNEL set, skipping update of freebsd sources and patch applying" | tee -a ${LOGFILE}
|
2947 |
|
|
return
|
2948 |
|
|
fi
|
2949 |
|
|
|
2950 |
ea3049df
|
Ermal
|
OLDPWD=`pwd`
|
2951 |
|
|
|
2952 |
bf8e515f
|
Ermal
|
echo -n ">>> Obtaining FreeBSD sources ${FREEBSD_BRANCH}..."
|
2953 |
b6d87d5c
|
Ermal
|
if [ -n "${USE_SVN}" ]; then
|
2954 |
1cf2f022
|
Renato Botelho
|
if [ -f /usr/bin/svnlite ]; then
|
2955 |
|
|
SVN_BIN=/usr/bin/svnlite
|
2956 |
|
|
else
|
2957 |
|
|
SVN_BIN=svn
|
2958 |
|
|
fi
|
2959 |
8a0399ca
|
Ermal
|
|
2960 |
1cf2f022
|
Renato Botelho
|
# If src is already there
|
2961 |
|
|
if [ -d "${SRCDIR}/.svn" ]; then
|
2962 |
|
|
# Remove orphan files
|
2963 |
|
|
(cd ${SRCDIR} && ${SVN_BIN} status --no-ignore | awk '{print $2}' | xargs rm -rf)
|
2964 |
|
|
# Revert possible changed files
|
2965 |
68011e86
|
Renato Botelho
|
(cd ${SRCDIR} && ${SVN_BIN} revert -R . 2>&1) | grep -i 'error'
|
2966 |
1cf2f022
|
Renato Botelho
|
# Update src
|
2967 |
68011e86
|
Renato Botelho
|
(cd ${SRCDIR} && ${SVN_BIN} up 2>&1) | grep -i 'error'
|
2968 |
1cf2f022
|
Renato Botelho
|
else
|
2969 |
93c1113d
|
Ermal
|
(${SVN_BIN} co ${FREEBSD_REPO_BASE}/${FREEBSD_BRANCH} ${SRCDIR} 2>&1) | grep -i 'error'
|
2970 |
1cf2f022
|
Renato Botelho
|
fi
|
2971 |
b6d87d5c
|
Ermal
|
else
|
2972 |
93c1113d
|
Ermal
|
local _FREEBSD_BRANCH=${FREEBSD_BRANCH:-"master"}
|
2973 |
d900912e
|
Renato Botelho
|
local _CLONE=1
|
2974 |
|
|
|
2975 |
6e585b45
|
Ermal
|
if [ -d "${SRCDIR}/.git" ]; then
|
2976 |
d900912e
|
Renato Botelho
|
CUR_BRANCH=$(cd ${SRCDIR} && git branch | grep '^\*' | cut -d' ' -f2)
|
2977 |
93c1113d
|
Ermal
|
if [ "${CUR_BRANCH}" = "${_FREEBSD_BRANCH}" ]; then
|
2978 |
d900912e
|
Renato Botelho
|
_CLONE=0
|
2979 |
93c1113d
|
Ermal
|
( cd ${SRCDIR} && git fetch origin; git reset --hard; git clean -fxd; git rebase origin/${_FREEBSD_BRANCH} ) 2>&1 | grep -C3 -i 'error'
|
2980 |
|
|
elif (cd ${SRCDIR} && git branch 2>&1 | grep -q "${_FREEBSD_BRANCH}"); then
|
2981 |
acf40ce4
|
Renato Botelho
|
_CLONE=0
|
2982 |
93c1113d
|
Ermal
|
( cd ${SRCDIR} && git fetch origin; git reset --hard; git clean -fxd; git checkout ${_FREEBSD_BRANCH}; git rebase origin/${_FREEBSD_BRANCH} ) 2>&1 | grep -C3 -i 'error'
|
2983 |
457e1519
|
Ermal
|
else
|
2984 |
f81d23c2
|
Renato Botelho
|
rm -rf ${SRCDIR}
|
2985 |
457e1519
|
Ermal
|
fi
|
2986 |
d900912e
|
Renato Botelho
|
fi
|
2987 |
|
|
|
2988 |
|
|
if [ ${_CLONE} -eq 1 ]; then
|
2989 |
93c1113d
|
Ermal
|
( git clone --branch ${_FREEBSD_BRANCH} --single-branch ${FREEBSD_REPO_BASE} ${SRCDIR} ) 2>&1 | grep -C3 -i 'error'
|
2990 |
308b49d2
|
Ermal
|
fi
|
2991 |
5917dc7d
|
Ermal
|
|
2992 |
37597a8d
|
Ermal
|
if [ -n "${GIT_FREEBSD_COSHA1}" ]; then
|
2993 |
9c70844f
|
Renato Botelho
|
( cd ${SRCDIR} && git checkout ${GIT_FREEBSD_COSHA1} ) 2>&1 | grep -C3 -i 'error'
|
2994 |
5917dc7d
|
Ermal
|
fi
|
2995 |
8a0399ca
|
Ermal
|
fi
|
2996 |
3efbed75
|
Ermal
|
echo "Done!"
|
2997 |
|
|
|
2998 |
107b1796
|
Scott Ullrich
|
# Loop through and remove files
|
2999 |
a17b784d
|
Renato Botelho
|
echo ">>> Removing files listed for FreeBSD version: ${FREEBSD_VERSION} file-name: ${PFSPATCHFILE}"
|
3000 |
107b1796
|
Scott Ullrich
|
for LINE in `cat ${PFSPATCHFILE}`
|
3001 |
|
|
do
|
3002 |
|
|
PATCH_RM=`echo $LINE | cut -d~ -f4`
|
3003 |
|
|
PATCH_RM_LENGTH=`echo $PATCH_RM | wc -c`
|
3004 |
|
|
DIR_CREATE=`echo $LINE | cut -d~ -f5`
|
3005 |
|
|
if [ $PATCH_RM_LENGTH -gt "2" ]; then
|
3006 |
|
|
rm -rf ${SRCDIR}${PATCH_RM}
|
3007 |
|
|
fi
|
3008 |
|
|
if [ "$DIR_CREATE" != "" ]; then
|
3009 |
|
|
mkdir -p ${SRCDIR}/${DIR_CREATE}
|
3010 |
|
|
fi
|
3011 |
|
|
done
|
3012 |
|
|
|
3013 |
3c981c83
|
Scott Ullrich
|
echo -n ">>> Applying patches from $PFSPATCHFILE please wait..."
|
3014 |
107b1796
|
Scott Ullrich
|
# Loop through and patch files
|
3015 |
5bca1650
|
Scott Ullrich
|
for LINE in `cat ${PFSPATCHFILE}`
|
3016 |
107b1796
|
Scott Ullrich
|
do
|
3017 |
|
|
PATCH_DEPTH=`echo $LINE | cut -d~ -f1`
|
3018 |
|
|
PATCH_DIRECTORY=`echo $LINE | cut -d~ -f2`
|
3019 |
|
|
PATCH_FILE=`echo $LINE | cut -d~ -f3`
|
3020 |
|
|
PATCH_FILE_LEN=`echo $PATCH_FILE | wc -c`
|
3021 |
|
|
MOVE_FILE=`echo $LINE | cut -d~ -f4`
|
3022 |
|
|
MOVE_FILE_LEN=`echo $MOVE_FILE | wc -c`
|
3023 |
|
|
IS_TGZ=`echo $LINE | grep -v grep | grep .tgz | wc -l`
|
3024 |
f53eb9f1
|
Ermal
|
if [ ${PATH_FILE} == ""]; then
|
3025 |
|
|
|
3026 |
|
|
elif [ ! -f "${PFSPATCHDIR}/${PATCH_FILE}" ]; then
|
3027 |
ee94f13b
|
Ermal
|
echo
|
3028 |
|
|
echo "ERROR! Patch file(${PATCH_FILE}) not found! Please fix before building!"
|
3029 |
|
|
echo
|
3030 |
|
|
print_error_pfS
|
3031 |
|
|
kill $$
|
3032 |
|
|
fi
|
3033 |
|
|
|
3034 |
107b1796
|
Scott Ullrich
|
if [ $PATCH_FILE_LEN -gt "2" ]; then
|
3035 |
98b1c984
|
Renato Botelho
|
if [ $IS_TGZ -gt "0" ]; then
|
3036 |
107b1796
|
Scott Ullrich
|
(cd ${SRCDIR}/${PATCH_DIRECTORY} && tar xzvpf ${PFSPATCHDIR}/${PATCH_FILE}) 2>&1 \
|
3037 |
|
|
| egrep -wi '(warning|error)'
|
3038 |
|
|
else
|
3039 |
3b80f86b
|
Seth Mos
|
(cd ${SRCDIR}/${PATCH_DIRECTORY} && patch --quiet -f ${PATCH_DEPTH} < ${PFSPATCHDIR}/${PATCH_FILE} 2>&1 );
|
3040 |
07cf56ae
|
Charlie Root
|
if [ "$?" != "0" ]; then
|
3041 |
|
|
echo "failed to apply ${PATCH_FILE}";
|
3042 |
|
|
fi
|
3043 |
107b1796
|
Scott Ullrich
|
fi
|
3044 |
|
|
fi
|
3045 |
|
|
if [ $MOVE_FILE_LEN -gt "2" ]; then
|
3046 |
|
|
#cp ${SRCDIR}/${MOVE_FILE} ${SRCDIR}/${PATCH_DIRECTORY}
|
3047 |
|
|
fi
|
3048 |
|
|
done
|
3049 |
|
|
echo "Done!"
|
3050 |
|
|
|
3051 |
|
|
echo ">>> Finding patch rejects..."
|
3052 |
|
|
REJECTED_PATCHES=`find $SRCDIR -name "*.rej" | wc -l`
|
3053 |
|
|
if [ $REJECTED_PATCHES -gt 0 ]; then
|
3054 |
|
|
echo
|
3055 |
|
|
echo "WARNING! Rejected patches found! Please fix before building!"
|
3056 |
98b1c984
|
Renato Botelho
|
echo
|
3057 |
|
|
find $SRCDIR -name "*.rej"
|
3058 |
107b1796
|
Scott Ullrich
|
echo
|
3059 |
859b069b
|
Ermal
|
if [ "$BUILD_ERROR_MAIL" != "" ]; then
|
3060 |
b5b7f3ef
|
Ermal
|
LOGFILE="$SCRATCHDIR/patches.failed.apply"
|
3061 |
107b1796
|
Scott Ullrich
|
find $SRCDIR -name "*.rej" > $LOGFILE
|
3062 |
4369d2c2
|
Scott Ullrich
|
print_error_pfS
|
3063 |
dc311604
|
Scott Ullrich
|
|
3064 |
107b1796
|
Scott Ullrich
|
fi
|
3065 |
dc311604
|
Scott Ullrich
|
print_error_pfS
|
3066 |
cc9f6cf9
|
Scott Ullrich
|
kill $$
|
3067 |
107b1796
|
Scott Ullrich
|
fi
|
3068 |
ea3049df
|
Ermal
|
|
3069 |
|
|
cd $OLDPWD
|
3070 |
|
|
unset OLDPWD
|
3071 |
107b1796
|
Scott Ullrich
|
}
|
3072 |
|
|
|
3073 |
859b069b
|
Ermal
|
# Email when an error has occured and BUILD_ERROR_MAIL is defined
|
3074 |
532c609b
|
Scott Ullrich
|
report_error_pfsense() {
|
3075 |
859b069b
|
Ermal
|
if [ ! -z ${BUILD_ERROR_MAIL:-} ]; then
|
3076 |
532c609b
|
Scott Ullrich
|
HOSTNAME=`hostname`
|
3077 |
|
|
IPADDRESS=`ifconfig | grep inet | grep netmask | grep broadcast | awk '{ print $2 }'`
|
3078 |
|
|
cat ${LOGFILE} | \
|
3079 |
859b069b
|
Ermal
|
mail -s "Builder (${PRODUCT_NAME}) build error in ${TARGET} phase ${IPADDRESS} - ${HOSTNAME} " \
|
3080 |
|
|
${BUILD_ERROR_MAIL}
|
3081 |
532c609b
|
Scott Ullrich
|
fi
|
3082 |
|
|
}
|
3083 |
|
|
|
3084 |
aa0bbaae
|
Scott Ullrich
|
# Email when an operation is completed IE build run
|
3085 |
ac3c9345
|
Scott Ullrich
|
email_operation_completed() {
|
3086 |
859b069b
|
Ermal
|
if [ ! -z ${BUILD_COMPLETED_MAIL:-} ]; then
|
3087 |
532c609b
|
Scott Ullrich
|
HOSTNAME=`hostname`
|
3088 |
|
|
IPADDRESS=`ifconfig | grep inet | grep netmask | grep broadcast | awk '{ print $2 }'`
|
3089 |
|
|
echo "Build / operation completed ${IPADDRESS} - ${HOSTNAME}" | \
|
3090 |
859b069b
|
Ermal
|
mail -s "Builder (${PRODUCT_NAME}) operation completed ${IPADDRESS} - ${HOSTNAME}" \
|
3091 |
|
|
${BUILD_COMPLETED_MAIL}
|
3092 |
98b1c984
|
Renato Botelho
|
fi
|
3093 |
ac3c9345
|
Scott Ullrich
|
}
|
3094 |
33e2f319
|
Scott Ullrich
|
|
3095 |
8ad11af8
|
Ermal
|
# This ensures installer is healthy.
|
3096 |
f6c6f34e
|
Scott Ullrich
|
ensure_healthy_installer() {
|
3097 |
adbddb0e
|
Ermal
|
echo -n ">>> Checking BSDInstaller health..." | tee -a ${LOGFILE}
|
3098 |
f6c6f34e
|
Scott Ullrich
|
INSTALLER_ERROR=0
|
3099 |
adbddb0e
|
Ermal
|
if [ ! -f "$PFSENSEISODIR/usr/local/sbin/dfuife_curses" ]; then
|
3100 |
f6c6f34e
|
Scott Ullrich
|
INSTALLER_ERROR=1
|
3101 |
adbddb0e
|
Ermal
|
echo -n " dfuife_curses missing " | tee -a ${LOGFILE}
|
3102 |
f6c6f34e
|
Scott Ullrich
|
fi
|
3103 |
adbddb0e
|
Ermal
|
if [ ! -d "$PFSENSEISODIR/usr/local/share/dfuibe_lua" ]; then
|
3104 |
f6c6f34e
|
Scott Ullrich
|
INSTALLER_ERROR=1
|
3105 |
adbddb0e
|
Ermal
|
echo -n " dfuibe_lua missing " | tee -a ${LOGFILE}
|
3106 |
f6c6f34e
|
Scott Ullrich
|
fi
|
3107 |
adbddb0e
|
Ermal
|
if [ ! -f "$PFSENSEISODIR/usr/local/share/dfuibe_lua/conf/pfSense.lua" ]; then
|
3108 |
f6c6f34e
|
Scott Ullrich
|
INSTALLER_ERROR=1
|
3109 |
adbddb0e
|
Ermal
|
echo " pfSense_lua missing " | tee -a ${LOGFILE}
|
3110 |
f6c6f34e
|
Scott Ullrich
|
fi
|
3111 |
98b1c984
|
Renato Botelho
|
if [ "$INSTALLER_ERROR" -gt 0 ]; then
|
3112 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: " | tee -a ${LOGFILE}
|
3113 |
f6c6f34e
|
Scott Ullrich
|
print_error_pfS
|
3114 |
dc311604
|
Scott Ullrich
|
kill $$
|
3115 |
126a9a2c
|
Scott Ullrich
|
else
|
3116 |
adbddb0e
|
Ermal
|
echo "[OK]" | tee -a ${LOGFILE}
|
3117 |
f6c6f34e
|
Scott Ullrich
|
fi
|
3118 |
|
|
}
|
3119 |
3700246c
|
Scott Ullrich
|
|
3120 |
aa0bbaae
|
Scott Ullrich
|
# Check to see if a forced pfPorts run has been requested.
|
3121 |
|
|
# If so, rebuild pfPorts. set_version.sh uses this.
|
3122 |
97dbb6c6
|
Scott Ullrich
|
check_for_forced_pfPorts_build() {
|
3123 |
b5b7f3ef
|
Ermal
|
if [ -f "$SCRATCHDIR/pfPorts_forced_build_required" ]; then
|
3124 |
aa0bbaae
|
Scott Ullrich
|
# Ensure that we build
|
3125 |
b5b7f3ef
|
Ermal
|
rm -f $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
3126 |
aa0bbaae
|
Scott Ullrich
|
recompile_pfPorts
|
3127 |
|
|
# Remove file that could trigger 2 pfPorts
|
3128 |
|
|
# builds in one run
|
3129 |
b5b7f3ef
|
Ermal
|
rm $SCRATCHDIR/pfPorts_forced_build_required
|
3130 |
97dbb6c6
|
Scott Ullrich
|
fi
|
3131 |
|
|
}
|
3132 |
aa0bbaae
|
Scott Ullrich
|
|
3133 |
36004c31
|
Scott Ullrich
|
# Print basenames
|
3134 |
|
|
print_basenames() {
|
3135 |
|
|
for NAME in "$1"; do
|
3136 |
|
|
echo `basename $NAME`
|
3137 |
|
|
done
|
3138 |
|
|
}
|
3139 |
|
|
|
3140 |
0ddf01de
|
Ermal
|
# Put extra options in loader.conf.local if needed
|
3141 |
|
|
install_extra_loader_conf_options() {
|
3142 |
5a89e410
|
Seth Mos
|
if [ ! -z ${LOADER_CONF_CUSTOM} ]; then
|
3143 |
8dd7ba53
|
Ermal
|
if [ -f ${LOADER_CONF_CUSTOM} ]; then
|
3144 |
e6c0e996
|
Ermal
|
echo -n ">>> loader.conf custom option addition..."
|
3145 |
2a633241
|
Matt Smith
|
cat ${LOADER_CONF_CUSTOM} >> $PFSENSEISODIR/boot/loader.conf.local
|
3146 |
e6c0e996
|
Ermal
|
echo "Done!"
|
3147 |
0ddf01de
|
Ermal
|
fi
|
3148 |
|
|
fi
|
3149 |
|
|
}
|
3150 |
|
|
|
3151 |
aa0bbaae
|
Scott Ullrich
|
# This routine assists with installing various
|
3152 |
|
|
# freebsd ports files into the pfsenese-fs staging
|
3153 |
96f5498d
|
Scott Ullrich
|
# area. The various ports are built prior to install.
|
3154 |
aa0bbaae
|
Scott Ullrich
|
install_pkg_install_ports() {
|
3155 |
695d6d85
|
Scott Ullrich
|
if [ "$PKG_INSTALL_PORTSPFS" = "" ]; then
|
3156 |
|
|
return
|
3157 |
|
|
fi
|
3158 |
859b069b
|
Ermal
|
OLDPWD=`pwd`
|
3159 |
dde34443
|
Ermal
|
# port build log files will be stored here
|
3160 |
|
|
mkdir -p ${BUILDER_LOGS}/pfPorts
|
3161 |
|
|
ALREADYBUILT="${BUILDER_LOGS}/pfPorts/install_pkg_install_ports"
|
3162 |
5eed85df
|
Scott Ullrich
|
if [ -d $ALREADYBUILT ]; then
|
3163 |
c527057d
|
Ermal
|
rm -rf $ALREADYBUILT
|
3164 |
5eed85df
|
Scott Ullrich
|
fi
|
3165 |
|
|
mkdir -p $ALREADYBUILT
|
3166 |
c8dfb1f7
|
jim-p
|
# Some ports are unhappy with cross building and fail spectacularly.
|
3167 |
|
|
OLDTGTARCH=${TARGET_ARCH}
|
3168 |
|
|
unset TARGET_ARCH
|
3169 |
49798929
|
Ermal
|
export PFS_PKG_ALL="/usr/ports/packages/All/"
|
3170 |
dde34443
|
Ermal
|
PFS_PKG_OLD="/usr/ports/packages/Old/"
|
3171 |
b5b7f3ef
|
Ermal
|
VAR_DB_PKG_TMP="$SCRATCHDIR/vardbpkg/"
|
3172 |
7892dc8a
|
Scott Ullrich
|
VAR_DB_PKG="/var/db/pkg/"
|
3173 |
dde34443
|
Ermal
|
mkdir -p ${PFS_PKG_ALL}
|
3174 |
af0a9c06
|
Scott Ullrich
|
mkdir -p ${PFS_PKG_OLD}
|
3175 |
7892dc8a
|
Scott Ullrich
|
mkdir -p ${VAR_DB_PKG_TMP}
|
3176 |
af0a9c06
|
Scott Ullrich
|
# Make a backup of existing packages so we can figure out
|
3177 |
|
|
# which packages need to be installed in pfsense-fs chroot.
|
3178 |
|
|
# otherwise you will get a bunch of extra pkgs that where
|
3179 |
|
|
# on the system prior to invoking this build run.
|
3180 |
609ef17d
|
Ermal
|
mv ${PFS_PKG_ALL}* ${PFS_PKG_OLD}/ 2>/dev/null
|
3181 |
af0a9c06
|
Scott Ullrich
|
mkdir -p ${PFS_PKG_ALL} 2>/dev/null
|
3182 |
5e3e2ada
|
Ermal
|
|
3183 |
dde34443
|
Ermal
|
echo ">>> Building ports: (starting)"
|
3184 |
830f86d7
|
Ermal
|
for PORTDIRPFS in $PKG_INSTALL_PORTSPFS; do
|
3185 |
0138fe72
|
Scott Ullrich
|
install_pkg_install_ports_build $PORTDIRPFS
|
3186 |
aa0bbaae
|
Scott Ullrich
|
done
|
3187 |
830f86d7
|
Ermal
|
|
3188 |
859b069b
|
Ermal
|
mkdir -p $PFSENSESTAGEDIR/tmp/pkg/
|
3189 |
|
|
cp ${PFS_PKG_ALL}/* $PFSENSESTAGEDIR/tmp/pkg/
|
3190 |
dde34443
|
Ermal
|
echo ">>> Building ports: (finished)"
|
3191 |
|
|
|
3192 |
859b069b
|
Ermal
|
echo ">>> Installing built ports (packages) in chroot (${PFSENSESTAGEDIR})... (starting)"
|
3193 |
a70a9018
|
Scott Ullrich
|
mv ${VAR_DB_PKG}/* ${VAR_DB_PKG_TMP} || true 2>/dev/null
|
3194 |
859b069b
|
Ermal
|
cp ${BUILDER_SCRIPTS}/scripts/install_tmp_pkgs_in_chroot.sh $PFSENSESTAGEDIR/pkg.sh
|
3195 |
|
|
chmod a+rx $PFSENSESTAGEDIR/pkg.sh
|
3196 |
f3a34aa8
|
Scott Ullrich
|
# chroot into staging area and pkg_add all of the packages
|
3197 |
859b069b
|
Ermal
|
script ${BUILDER_LOGS}/pfPorts/install_pkg_install_ports.txt /sbin/mount -t devfs devfs ${PFSENSESTAGEDIR}/dev
|
3198 |
|
|
script -a ${BUILDER_LOGS}/pfPorts/install_pkg_install_ports.txt chroot $PFSENSESTAGEDIR /pkg.sh
|
3199 |
|
|
script -a ${BUILDER_LOGS}/pfPorts/install_pkg_install_ports.txt /sbin/umount ${PFSENSESTAGEDIR}/dev
|
3200 |
dde34443
|
Ermal
|
echo ">>> Result of installing packages in the chroot is:"
|
3201 |
|
|
echo "--------------------------------------------------"
|
3202 |
|
|
cat ${BUILDER_LOGS}/pfPorts/install_pkg_install_ports.txt
|
3203 |
|
|
echo "--------------------------------------------------"
|
3204 |
859b069b
|
Ermal
|
echo ">>> Installing built ports (packages) in chroot (${PFSENSESTAGEDIR})... (finshied)"
|
3205 |
dde34443
|
Ermal
|
|
3206 |
c3071a31
|
Scott Ullrich
|
# Restore the previously backed up items
|
3207 |
609ef17d
|
Ermal
|
mv ${PFS_PKG_OLD}* ${PFS_PKG_ALL} || true 2>/dev/null
|
3208 |
f3a34aa8
|
Scott Ullrich
|
mv ${VAR_DB_PKG_TMP}/* ${VAR_DB_PKG} || true 2>/dev/null
|
3209 |
859b069b
|
Ermal
|
rm -rf $PFSENSESTAGEDIR/tmp/pkg
|
3210 |
|
|
rm -f $PFSENSESTAGEDIR/pkg.sh
|
3211 |
dde34443
|
Ermal
|
|
3212 |
|
|
echo ">>> Building ports: (Done)"
|
3213 |
c8dfb1f7
|
jim-p
|
TARGET_ARCH=${OLDTGTARCH}
|
3214 |
859b069b
|
Ermal
|
cd $OLDPWD
|
3215 |
|
|
unset OLDPWD
|
3216 |
9ea68155
|
Scott Ullrich
|
}
|
3217 |
|
|
|
3218 |
|
|
install_pkg_install_ports_build() {
|
3219 |
163b9283
|
Ermal
|
local PORTDIRPFSA
|
3220 |
|
|
local PORTNAME
|
3221 |
|
|
local _PORTNAME
|
3222 |
|
|
local BUILT_PKGNAME
|
3223 |
|
|
|
3224 |
9ea68155
|
Scott Ullrich
|
PORTDIRPFSA="$1"
|
3225 |
c527057d
|
Ermal
|
|
3226 |
|
|
# XXX: Maybe remove this code as its already done above!
|
3227 |
5eed85df
|
Scott Ullrich
|
PORTNAME="`basename $PORTDIRPFSA`"
|
3228 |
|
|
if [ "$PORTNAME" = "" ]; then
|
3229 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: PORTNAME is blank. Cannot continue."
|
3230 |
5eed85df
|
Scott Ullrich
|
print_error_pfS
|
3231 |
400f556b
|
Scott Ullrich
|
kill $$
|
3232 |
9ea68155
|
Scott Ullrich
|
fi
|
3233 |
3d15efe1
|
Ermal
|
|
3234 |
|
|
if [ -d $pfSPORTS_BASE_DIR/${PORTNAME} ]; then
|
3235 |
|
|
echo -n ">>> Overlaying port $PORTNAME from pfPorts..."
|
3236 |
|
|
# Cleanup to avoid issues with extra/different patches
|
3237 |
|
|
rm -rf $PORTDIRPFSA/*
|
3238 |
|
|
cp -R $pfSPORTS_BASE_DIR/${PORTNAME}/* $PORTDIRPFSA
|
3239 |
|
|
echo "Done!"
|
3240 |
|
|
fi
|
3241 |
dde34443
|
Ermal
|
ALREADYBUILT="${BUILDER_LOGS}/pfPorts/install_pkg_install_ports"
|
3242 |
49798929
|
Ermal
|
BUILT_PKGNAME="`make -C $PORTDIRPFSA -V PKGNAME`"
|
3243 |
c527057d
|
Ermal
|
if [ ! -f $ALREADYBUILT/$BUILT_PKGNAME ]; then
|
3244 |
1a54e52c
|
Ermal
|
|
3245 |
|
|
# Install the required port for the build environment
|
3246 |
|
|
for EXTRAPORT in `cd $PORTDIRPFSA && make build-depends-list | sort | uniq | xargs /bin/echo -n `; do
|
3247 |
|
|
_PORTNAME="`basename $EXTRAPORT`"
|
3248 |
|
|
if [ "$_PORTNAME" = "" ]; then
|
3249 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: _PORTNAME is blank. Cannot continue."
|
3250 |
1a54e52c
|
Ermal
|
print_error_pfS
|
3251 |
|
|
kill $$
|
3252 |
|
|
fi
|
3253 |
|
|
if [ -d $pfSPORTS_BASE_DIR/${_PORTNAME} ]; then
|
3254 |
|
|
echo -n ">>> Overlaying port $PORTNAME from pfPorts..."
|
3255 |
|
|
# Cleanup to avoid issues with extra/different patches
|
3256 |
|
|
rm -rf $EXTRAPORT/*
|
3257 |
|
|
cp -R $pfSPORTS_BASE_DIR/${_PORTNAME}/* $EXTRAPORT
|
3258 |
|
|
echo "Done!"
|
3259 |
|
|
fi
|
3260 |
|
|
_BUILT_PKGNAME="`make -C $EXTRAPORT -V PKGNAME`"
|
3261 |
b6b8541b
|
Ermal
|
${PKG_QUERY} $_BUILT_PKGNAME
|
3262 |
|
|
if [ $? -ne 0 ]; then
|
3263 |
540f426d
|
Renato Botelho
|
echo -n ">>> Building port $_PORTNAME($_BUILT_PKGNAME) as build dependency of ($PORTNAME)..."
|
3264 |
e3ab69b2
|
Renato Botelho
|
script ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt env -u TARGET -u TARGET_ARCH make -C $EXTRAPORT $PKG_INSTALL_PFSMAKEENV WITHOUT="X11 DOCS EXAMPLES MAN INFO SDL" BATCH=yes FORCE_PKG_REGISTER=yes clean install clean 2>&1 1>/dev/null || true 2>&1 >/dev/null
|
3265 |
540f426d
|
Renato Botelho
|
if [ "$?" != "0" ]; then
|
3266 |
|
|
echo
|
3267 |
|
|
echo
|
3268 |
|
|
echo "!!! Something went wrong while building ${EXTRAPORT}"
|
3269 |
|
|
echo " Press RETURN/ENTER to view the log from this build."
|
3270 |
|
|
read inputline
|
3271 |
41bff025
|
Ermal
|
more ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt
|
3272 |
916e8008
|
Ermal
|
else
|
3273 |
540f426d
|
Renato Botelho
|
echo "Done!"
|
3274 |
916e8008
|
Ermal
|
fi
|
3275 |
1a54e52c
|
Ermal
|
else
|
3276 |
540f426d
|
Renato Botelho
|
echo ">>> Port ${EXTRAPORT}($_BUILT_PKGNAME) as build dependency of ($PORTNAME)...already installed...skipping."
|
3277 |
|
|
fi
|
3278 |
1a54e52c
|
Ermal
|
done
|
3279 |
|
|
|
3280 |
830f86d7
|
Ermal
|
# Package up what's needed to execute and run
|
3281 |
1a54e52c
|
Ermal
|
for EXTRAPORT in `cd $PORTDIRPFSA && make run-depends-list | sort | uniq | xargs /bin/echo -n `; do
|
3282 |
163b9283
|
Ermal
|
_PORTNAME="`basename $EXTRAPORT`"
|
3283 |
|
|
if [ "$_PORTNAME" = "" ]; then
|
3284 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: Run list _PORTNAME is blank. Cannot continue."
|
3285 |
830f86d7
|
Ermal
|
print_error_pfS
|
3286 |
|
|
kill $$
|
3287 |
|
|
fi
|
3288 |
163b9283
|
Ermal
|
if [ -d $pfSPORTS_BASE_DIR/${_PORTNAME} ]; then
|
3289 |
|
|
echo -n ">>> Overlaying port $_PORTNAME from pfPorts..."
|
3290 |
830f86d7
|
Ermal
|
# Cleanup to avoid issues with extra/different patches
|
3291 |
|
|
rm -rf $EXTRAPORT/*
|
3292 |
163b9283
|
Ermal
|
cp -R $pfSPORTS_BASE_DIR/${_PORTNAME}/* $EXTRAPORT
|
3293 |
830f86d7
|
Ermal
|
echo "Done!"
|
3294 |
|
|
fi
|
3295 |
|
|
install_pkg_install_ports_build $EXTRAPORT
|
3296 |
b4eced02
|
Ermal
|
_BUILT_PKGNAME="`make -C $EXTRAPORT -V PKGNAME`"
|
3297 |
207acdf4
|
Ermal
|
echo ">>> Building port $_PORTNAME($_BUILT_PKGNAME) as runtime dependency of ($PORTNAME)...Done!"
|
3298 |
830f86d7
|
Ermal
|
done
|
3299 |
|
|
|
3300 |
799bb529
|
Ermal
|
echo -n ">>> Building package $PORTNAME($BUILT_PKGNAME)..."
|
3301 |
49798929
|
Ermal
|
if [ -f /usr/ports/packages/Old/${BUILT_PKGNAME}.tbz ]; then
|
3302 |
799bb529
|
Ermal
|
echo -n " Using already built port found in cache... "
|
3303 |
49798929
|
Ermal
|
cp -R /usr/ports/packages/Old/${BUILT_PKGNAME}.tbz \
|
3304 |
799bb529
|
Ermal
|
/usr/ports/packages/All/
|
3305 |
|
|
touch $ALREADYBUILT/$BUILT_PKGNAME
|
3306 |
|
|
echo "Done!"
|
3307 |
|
|
return;
|
3308 |
|
|
fi
|
3309 |
|
|
|
3310 |
e3ab69b2
|
Renato Botelho
|
script ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt env -u TARGET -u TARGET_ARCH make -C $PORTDIRPFSA ${MAKEJ_PORTS} $PKG_INSTALL_PFSMAKEENV WITHOUT="X11 DOCS EXAMPLES MAN INFO SDL LATEST_LINK" BATCH=yes FORCE_PKG_REGISTER=yes clean install clean 2>&1 1>/dev/null || true 2>&1 >/dev/null
|
3311 |
fc8c558c
|
Ermal
|
if [ "$?" != "0" ]; then
|
3312 |
|
|
echo
|
3313 |
|
|
echo
|
3314 |
|
|
echo "!!! Something went wrong while building ${PORTNAME}"
|
3315 |
|
|
echo " Press RETURN/ENTER to view the log from this build."
|
3316 |
|
|
read inputline
|
3317 |
41bff025
|
Ermal
|
more {$BUILDER_LOGS}/pfPorts/${PORTNAME}.txt
|
3318 |
49798929
|
Ermal
|
fi
|
3319 |
|
|
|
3320 |
fa6fb5dd
|
Ermal
|
if [ ${FREEBSD_VERSION} -gt 9 ]; then
|
3321 |
eb0f9135
|
Ermal
|
script -a ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt pkg create -f tbz -o $PFS_PKG_ALL $BUILT_PKGNAME
|
3322 |
fa6fb5dd
|
Ermal
|
else
|
3323 |
eb0f9135
|
Ermal
|
script -a ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt pkg_create -b $BUILT_PKGNAME $PFS_PKG_ALL/${BUILT_PKGNAME}.tbz
|
3324 |
fa6fb5dd
|
Ermal
|
fi
|
3325 |
5eed85df
|
Scott Ullrich
|
if [ "$?" != "0" ]; then
|
3326 |
43a5b6a1
|
Scott Ullrich
|
echo
|
3327 |
|
|
echo
|
3328 |
49798929
|
Ermal
|
echo "!!! Something went wrong while building package($BUILT_PKGNAME) for ${PORTNAME}"
|
3329 |
5eed85df
|
Scott Ullrich
|
echo " Press RETURN/ENTER to view the log from this build."
|
3330 |
|
|
read inputline
|
3331 |
41bff025
|
Ermal
|
more ${BUILDER_LOGS}/pfPorts/${PORTNAME}.txt
|
3332 |
5eed85df
|
Scott Ullrich
|
fi
|
3333 |
49798929
|
Ermal
|
echo "Done!"
|
3334 |
5eed85df
|
Scott Ullrich
|
fi
|
3335 |
c527057d
|
Ermal
|
touch $ALREADYBUILT/$BUILT_PKGNAME
|
3336 |
aa0bbaae
|
Scott Ullrich
|
}
|
3337 |
98b1c984
|
Renato Botelho
|
|
3338 |
88138431
|
Ermal
|
staginareas_clean_each_run() {
|
3339 |
859b069b
|
Ermal
|
if [ -f ${PFSPKGFILE} ]; then
|
3340 |
|
|
rm -f ${PFSPKGFILE}
|
3341 |
|
|
fi
|
3342 |
942bba7d
|
Scott Ullrich
|
echo -n ">>> Cleaning build directories: "
|
3343 |
859b069b
|
Ermal
|
if [ -d "${PFSENSEISODIR}" ]; then
|
3344 |
|
|
BASENAME=`basename ${PFSENSEISODIR}`
|
3345 |
1a92314a
|
Scott Ullrich
|
echo -n "$BASENAME "
|
3346 |
859b069b
|
Ermal
|
chflags -R noschg ${PFSENSEISODIR} 2>&1 >/dev/null
|
3347 |
|
|
rm -rf ${PFSENSEISODIR} 2>/dev/null
|
3348 |
73b22162
|
Scott Ullrich
|
fi
|
3349 |
|
|
echo "Done!"
|
3350 |
91fb191c
|
Scott Ullrich
|
}
|
3351 |
fa57644b
|
Scott Ullrich
|
|
3352 |
bac3084f
|
Scott Ullrich
|
# Imported from FreeSBIE
|
3353 |
859b069b
|
Ermal
|
buildkernel() {
|
3354 |
|
|
if [ -n "${NO_BUILDKERNEL:-}" ]; then
|
3355 |
|
|
echo ">>> NO_BUILDKERNEL set, skipping build" | tee -a ${LOGFILE}
|
3356 |
fa57644b
|
Scott Ullrich
|
return
|
3357 |
|
|
fi
|
3358 |
c5643146
|
Ermal
|
|
3359 |
859b069b
|
Ermal
|
if [ -z "${KERNCONF:-}" ]; then
|
3360 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: No kernel configuration defined probably this is not what you want! STOPPING!" | tee -a ${LOGFILE}
|
3361 |
859b069b
|
Ermal
|
print_error_pfS
|
3362 |
|
|
kill $$
|
3363 |
c5643146
|
Ermal
|
fi
|
3364 |
|
|
|
3365 |
fa57644b
|
Scott Ullrich
|
if [ -n "${KERNELCONF:-}" ]; then
|
3366 |
|
|
export KERNCONFDIR=$(dirname ${KERNELCONF})
|
3367 |
|
|
export KERNCONF=$(basename ${KERNELCONF})
|
3368 |
|
|
fi
|
3369 |
859b069b
|
Ermal
|
|
3370 |
fa57644b
|
Scott Ullrich
|
SRCCONFBASENAME=`basename ${SRC_CONF}`
|
3371 |
|
|
echo ">>> KERNCONFDIR: ${KERNCONFDIR}"
|
3372 |
9f2a340a
|
Ermal
|
echo ">>> ARCH: ${TARGET}"
|
3373 |
fa57644b
|
Scott Ullrich
|
echo ">>> SRC_CONF: ${SRCCONFBASENAME}"
|
3374 |
c5643146
|
Ermal
|
|
3375 |
9f2a340a
|
Ermal
|
makeargs="${MAKEOPT:-} ${MAKEJ_KERNEL:-} SRCCONF=${SRC_CONF} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}"
|
3376 |
859b069b
|
Ermal
|
echo ">>> Builder is running the command: env $MAKE_CONF script -aq $LOGFILE make $makeargs buildkernel KERNCONF=${KERNCONF} NO_KERNELCLEAN=yo" | tee -a $LOGFILE
|
3377 |
a3cd3fea
|
Ermal
|
(cd $SRCDIR; env $MAKE_CONF script -q $LOGFILE make $makeargs buildkernel KERNCONF=${KERNCONF} NO_KERNELCLEAN=yo || print_error_pfS;) | egrep '^>>>'
|
3378 |
92f65bac
|
Scott Ullrich
|
cd $BUILDER_SCRIPTS
|
3379 |
fa57644b
|
Scott Ullrich
|
|
3380 |
|
|
}
|
3381 |
|
|
|
3382 |
bac3084f
|
Scott Ullrich
|
# Imported from FreeSBIE
|
3383 |
fa57644b
|
Scott Ullrich
|
installkernel() {
|
3384 |
859b069b
|
Ermal
|
if [ -z "${KERNCONF:-}" ]; then
|
3385 |
0da88a9f
|
Ermal
|
echo ">>> ERROR: No kernel configuration defined probably this is not what you want! STOPPING!" | tee -a ${LOGFILE}
|
3386 |
859b069b
|
Ermal
|
print_error_pfS
|
3387 |
|
|
kill $$
|
3388 |
|
|
fi
|
3389 |
|
|
|
3390 |
fa57644b
|
Scott Ullrich
|
if [ -n "${KERNELCONF:-}" ]; then
|
3391 |
|
|
export KERNCONFDIR=$(dirname ${KERNELCONF})
|
3392 |
|
|
export KERNCONF=$(basename ${KERNELCONF})
|
3393 |
|
|
fi
|
3394 |
859b069b
|
Ermal
|
|
3395 |
|
|
mkdir -p ${PFSENSESTAGEDIR}/boot
|
3396 |
9f2a340a
|
Ermal
|
makeargs="${MAKEOPT:-} ${MAKEJ_KERNEL:-} SRCCONF=${SRC_CONF} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} DESTDIR=${KERNEL_DESTDIR}"
|
3397 |
859b069b
|
Ermal
|
echo ">>> Builder is running the command: env $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} installkernel KERNCONF=${KERNCONF}" | tee -a $LOGFILE
|
3398 |
c5643146
|
Ermal
|
cd ${SRCDIR}
|
3399 |
a3cd3fea
|
Ermal
|
(cd $SRCDIR; env $MAKE_CONF script -aq $LOGFILE make ${makeargs:-} installkernel KERNCONF=${KERNCONF} || print_error_pfS;) | egrep '^>>>'
|
3400 |
fa57644b
|
Scott Ullrich
|
gzip -f9 $KERNEL_DESTDIR/boot/kernel/kernel
|
3401 |
92f65bac
|
Scott Ullrich
|
cd $BUILDER_SCRIPTS
|
3402 |
fa57644b
|
Scott Ullrich
|
}
|
3403 |
b2434500
|
Scott Ullrich
|
|
3404 |
|
|
# Launch is ran first to setup a few variables that we need
|
3405 |
bac3084f
|
Scott Ullrich
|
# Imported from FreeSBIE
|
3406 |
b2434500
|
Scott Ullrich
|
launch() {
|
3407 |
98b1c984
|
Renato Botelho
|
|
3408 |
b5b7f3ef
|
Ermal
|
if [ ! -f $SCRATCHDIR/pfSense_builder_set_time ]; then
|
3409 |
eb284019
|
Scott Ullrich
|
echo ">>> Updating system clock..."
|
3410 |
|
|
ntpdate 0.pfsense.pool.ntp.org
|
3411 |
b5b7f3ef
|
Ermal
|
touch $SCRATCHDIR/pfSense_builder_set_time
|
3412 |
98b1c984
|
Renato Botelho
|
fi
|
3413 |
b2434500
|
Scott Ullrich
|
|
3414 |
bac3084f
|
Scott Ullrich
|
if [ "`id -u`" != "0" ]; then
|
3415 |
|
|
echo "Sorry, this must be done as root."
|
3416 |
cc9f6cf9
|
Scott Ullrich
|
kill $$
|
3417 |
bac3084f
|
Scott Ullrich
|
fi
|
3418 |
|
|
|
3419 |
9e180ac1
|
Scott Ullrich
|
echo ">>> Operation $0 has started at `date`"
|
3420 |
b2434500
|
Scott Ullrich
|
}
|
3421 |
f280f9e8
|
Scott Ullrich
|
|
3422 |
|
|
finish() {
|
3423 |
9e180ac1
|
Scott Ullrich
|
echo ">>> Operation $0 has ended at `date`"
|
3424 |
be61b681
|
Scott Ullrich
|
killall -9 check_reload_status 2>/dev/null
|
3425 |
f280f9e8
|
Scott Ullrich
|
}
|