Project

General

Profile

Download (12.9 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# build.sh
4
#
5
# Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
6
#
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions are met:
9
#
10
# 1. Redistributions of source code must retain the above copyright notice,
11
#    this list of conditions and the following disclaimer.
12
#
13
# 2. Redistributions in binary form must reproduce the above copyright
14
#    notice, this list of conditions and the following disclaimer in
15
#    the documentation and/or other materials provided with the
16
#    distribution.
17
#
18
# 3. All advertising materials mentioning features or use of this software
19
#    must display the following acknowledgment:
20
#    "This product includes software developed by the pfSense Project
21
#    for use in the pfSense® software distribution. (http://www.pfsense.org/).
22
#
23
# 4. The names "pfSense" and "pfSense Project" must not be used to
24
#    endorse or promote products derived from this software without
25
#    prior written permission. For written permission, please contact
26
#    coreteam@pfsense.org.
27
#
28
# 5. Products derived from this software may not be called "pfSense"
29
#    nor may "pfSense" appear in their names without prior written
30
#    permission of the Electric Sheep Fencing, LLC.
31
#
32
# 6. Redistributions of any form whatsoever must retain the following
33
#    acknowledgment:
34
#
35
# "This product includes software developed by the pfSense Project
36
# for use in the pfSense software distribution (http://www.pfsense.org/).
37
#
38
# THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
39
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
42
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49
# OF THE POSSIBILITY OF SUCH DAMAGE.
50
#
51

    
52
###########################################
53
# Product builder configuration file      #
54
# Please don't modify this file, you      #
55
# can put your settings and options       #
56
# in build.conf, which is sourced at the  #
57
# beginning of this file                  #
58
###########################################
59

    
60
if [ -z "${BUILDER_ROOT}" ]; then
61
	echo ">>> ERROR: BUILDER_ROOT must be defined by script that includes builder_defaults.sh"
62
	exit 1
63
fi
64

    
65
if [ ! -d "${BUILDER_ROOT}" ]; then
66
	echo ">>> ERROR: BUILDER_ROOT is invalid"
67
	exit 1
68
fi
69

    
70
export BUILDER_TOOLS=${BUILDER_TOOLS:-"${BUILDER_ROOT}/tools"}
71

    
72
if [ ! -d "${BUILDER_TOOLS}" ]; then
73
	echo ">>> ERROR: BUILDER_TOOLS is invalid"
74
	exit 1
75
fi
76

    
77
BUILD_CONF="${BUILDER_ROOT}/build.conf"
78

    
79
# Ensure file exists
80
if [ -f ${BUILD_CONF} ]; then
81
	. ${BUILD_CONF}
82
fi
83

    
84
# Make sure pkg will not be interactive
85
export ASSUME_ALWAYS_YES=true
86

    
87
# Architecture, supported ARCH values are: 
88
#  Tier 1: i386, AMD64, and PC98
89
#  Tier 2: ARM, PowerPC, ia64, Sparc64 and sun4v
90
#  Tier 3: MIPS and S/390
91
#  Tier 4: None at the moment
92
#  Source: http://www.freebsd.org/doc/en/articles/committers-guide/archs.html
93
export TARGET=${TARGET:-"`uname -m`"}
94
export TARGET_ARCH=${TARGET_ARCH:-${TARGET}}
95
# Set TARGET_ARCH_CONF_DIR
96
if [ "$TARGET_ARCH" = "" ]; then
97
        export TARGET_ARCH=`uname -p`
98
fi
99

    
100
# Directory to be used for writing temporary information
101
export SCRATCHDIR=${SCRATCHDIR:-"${BUILDER_ROOT}/tmp"}
102
if [ ! -d ${SCRATCHDIR} ]; then
103
	mkdir -p ${SCRATCHDIR}
104
fi
105

    
106
# Product details
107
export PRODUCT_NAME=${PRODUCT_NAME:-"nonSense"}
108
export PRODUCT_URL=${PRODUCT_URL:-""}
109
export PRODUCT_SRC=${PRODUCT_SRC:-"${BUILDER_ROOT}/src"}
110

    
111
if [ "${PRODUCT_NAME}" = "pfSense" -a "${BUILD_AUTHORIZED_BY_ELECTRIC_SHEEP_FENCING}" != "yes" ]; then
112
	echo ">>>ERROR: According the following license, only Electric Sheep Fencing can build genuine pfSense® software"
113
	echo ""
114
	cat ${BUILDER_ROOT}/license.txt
115
	exit 1
116
fi
117

    
118
if [ -z "${PRODUCT_VERSION}" ]; then
119
	if [ ! -f ${PRODUCT_SRC}/etc/version ]; then
120
		echo ">>> ERROR: PRODUCT_VERSION is not defined and ${PRODUCT_SRC}/etc/version was not found"
121
		print_error_pfS
122
	fi
123

    
124
	export PRODUCT_VERSION=$(head -n 1 ${PRODUCT_SRC}/etc/version)
125
fi
126

    
127
# Product repository tag to build
128
_cur_git_repo_branch_or_tag=$(git -C ${BUILDER_ROOT} rev-parse --abbrev-ref HEAD)
129
if [ "${_cur_git_repo_branch_or_tag}" = "HEAD" ]; then
130
	# We are on a tag, lets find out its name
131
	export GIT_REPO_BRANCH_OR_TAG=$(git -C ${BUILDER_ROOT} describe --tags)
132
else
133
	export GIT_REPO_BRANCH_OR_TAG="${_cur_git_repo_branch_or_tag}"
134
fi
135

    
136
# This is used for using svn for retrieving src
137
export FREEBSD_REPO_BASE=${FREEBSD_REPO_BASE:-"git@git.pfmechanics.com:pfsense/freebsd-src.git"}
138
export FREEBSD_BRANCH=${FREEBSD_BRANCH:-"devel"}
139
export FREEBSD_PARENT_BRANCH=${FREEBSD_PARENT_BRANCH:-"stable/10"}
140
export FREEBSD_SRC_DIR=${FREEBSD_SRC_DIR:-"${SCRATCHDIR}/FreeBSD-src"}
141

    
142
if [ "${TARGET}" = "i386" ]; then
143
	export BUILD_KERNELS=${BUILD_KERNELS:-"${PRODUCT_NAME} ${PRODUCT_NAME}_wrap ${PRODUCT_NAME}_wrap_vga"}
144
else
145
	export BUILD_KERNELS=${BUILD_KERNELS:-"${PRODUCT_NAME}"}
146
fi
147

    
148
# Leave this alone.
149
export SRC_CONF=${SRC_CONF:-"${FREEBSD_SRC_DIR}/release/conf/${PRODUCT_NAME}_src.conf"}
150
export MAKE_CONF=${MAKE_CONF:-"${FREEBSD_SRC_DIR}/release/conf/${PRODUCT_NAME}_make.conf"}
151

    
152
# Extra tools to be added to ITOOLS
153
export EXTRA_TOOLS=${EXTRA_TOOLS:-"uuencode uudecode ex"}
154

    
155
# Path to kernel files being built
156
export KERNEL_BUILD_PATH=${KERNEL_BUILD_PATH:-"${SCRATCHDIR}/kernels"}
157

    
158
# Do not touch builder /usr/obj
159
export MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX:-"${SCRATCHDIR}/obj"}
160

    
161
# Controls how many concurrent make processes are run for each stage
162
_CPUS=""
163
if [ -z "${NO_MAKEJ}" ]; then
164
	_CPUS=$(expr $(sysctl -n kern.smp.cpus) '*' 2)
165
	if [ -n "${_CPUS}" ]; then
166
		_CPUS="-j${_CPUS}"
167
	fi
168
fi
169

    
170
export MAKEJ_WORLD=${MAKEJ_WORLD:-"${_CPUS}"}
171
export MAKEJ_KERNEL=${MAKEJ_KERNEL:-"${_CPUS}"}
172

    
173
if [ "${TARGET}" = "i386" ]; then
174
	export MODULES_OVERRIDE=${MODULES_OVERRIDE:-"i2c ipmi ndis ipfw ipdivert dummynet fdescfs opensolaris zfs glxsb if_stf coretemp amdtemp hwpmc"}
175
else
176
	export MODULES_OVERRIDE=${MODULES_OVERRIDE:-"i2c ipmi ndis ipfw ipdivert dummynet fdescfs opensolaris zfs glxsb if_stf coretemp amdtemp aesni sfxge hwpmc"}
177
fi
178

    
179
# Area that the final image will appear in
180
export IMAGES_FINAL_DIR=${IMAGES_FINAL_DIR:-"${SCRATCHDIR}/${PRODUCT_NAME}/"}
181

    
182
export BUILDER_LOGS=${BUILDER_LOGS:-"${BUILDER_ROOT}/logs"}
183
if [ ! -d ${BUILDER_LOGS} ]; then
184
	mkdir -p ${BUILDER_LOGS}
185
fi
186

    
187
# This is where files will be staged
188
export STAGE_CHROOT_DIR=${STAGE_CHROOT_DIR:-"${SCRATCHDIR}/stage-dir"}
189

    
190
# Directory that will clone to in order to create
191
# iso staging area.
192
export FINAL_CHROOT_DIR=${FINAL_CHROOT_DIR:-"${SCRATCHDIR}/final-dir"}
193

    
194
# 400M is not enough for amd64
195
export MEMORYDISK_SIZE=${MEMORYDISK_SIZE:-"768M"}
196

    
197
# OVF/vmdk parms
198
# Name of ovf file included inside OVA archive
199
export OVFTEMPLATE=${OVFTEMPLATE:-"${BUILDER_TOOLS}/templates/ovf/${PRODUCT_NAME}.ovf"}
200
# / partition to be used by mkimg
201
export OVFUFS=${OVFUFS:-"${PRODUCT_NAME}-disk1.ufs"}
202
# Raw disk to be converted to vmdk
203
export OVFRAW=${OVFRAW:-"${PRODUCT_NAME}-disk1.raw"}
204
# On disk name of VMDK file included in OVA
205
export OVFVMDK=${OVFVMDK:-"${PRODUCT_NAME}-disk1.vmdk"}
206
# 8 gigabyte on disk VMDK size
207
export VMDK_DISK_CAPACITY_IN_GB=${VMDK_DISK_CAPACITY_IN_GB:-"8"}
208
# first partition size (freebsd-ufs)
209
export OVA_FIRST_PART_SIZE_IN_GB=${OVA_FIRST_PART_SIZE_IN_GB:-"6"}
210
# swap partition size (freebsd-swap)
211
export OVA_SWAP_PART_SIZE_IN_GB=${OVA_SWAP_PART_SIZE_IN_GB:-"2"}
212
# Calculate real swap size, removing 128 blocks (65536 bytes) beggining/loader
213
export OVA_SWAP_PART_SIZE=$((${OVA_SWAP_PART_SIZE_IN_GB}*1024*1024*1024-65536))
214
# Temporary place to save files
215
export OVA_TMP=${OVA_TMP:-"${SCRATCHDIR}/ova_tmp"}
216
# end of OVF
217

    
218
# Number of code images on media (1 or 2)
219
export NANO_IMAGES=2
220
# 0 -> Leave second image all zeroes so it compresses better.
221
# 1 -> Initialize second image with a copy of the first
222
export NANO_INIT_IMG2=1
223
export NANO_NEWFS="-b 4096 -f 512 -i 8192 -O1"
224
export FLASH_SIZE=${FLASH_SIZE:-"1g"}
225
# Size of code file system in 512 bytes sectors
226
# If zero, size will be as large as possible.
227
export NANO_CODESIZE=0
228
# Size of data file system in 512 bytes sectors
229
# If zero: no partition configured.
230
# If negative: max size possible
231
export NANO_DATASIZE=0
232
# Size of Product /conf partition  # 102400 = 50 megabytes.
233
export NANO_CONFSIZE=102400
234
# packet is OK for 90% of embedded
235
export NANO_BOOT0CFG="-o packet -s 1 -m 3"
236

    
237
# NOTE: Date string is used for creating file names of images
238
#       The file is used for sharing the same value with build_snapshots.sh
239
export DATESTRINGFILE=${DATESTRINGFILE:-"$SCRATCHDIR/version.snapshots"}
240
if [ -z "${DATESTRING}" ]; then
241
	if [ -f "${DATESTRINGFILE}" -a -n "${_USE_OLD_DATESTRING}" ]; then
242
		export DATESTRING=$(cat $DATESTRINGFILE)
243
	else
244
		export DATESTRING=$(date "+%Y%m%d-%H%M")
245
	fi
246
fi
247
echo "$DATESTRING" > $DATESTRINGFILE
248

    
249
# NOTE: Date string is placed on the final image etc folder to help detect new updates
250
#       The file is used for sharing the same value with build_snapshots.sh
251
export BUILTDATESTRINGFILE=${BUILTDATESTRINGFILE:-"$SCRATCHDIR/version.buildtime"}
252
if [ -z "${BUILTDATESTRING}" ]; then
253
	if [ -f "${BUILTDATESTRINGFILE}" -a -n "${_USE_OLD_DATESTRING}" ]; then
254
		export BUILTDATESTRING=$(cat $BUILTDATESTRINGFILE)
255
	else
256
		export BUILTDATESTRING=$(date "+%a %b %d %T %Z %Y")
257
	fi
258
fi
259
echo "$BUILTDATESTRING" > $BUILTDATESTRINGFILE
260

    
261
# Poudriere
262
export ZFS_TANK=${ZFS_TANK:-"tank"}
263
export ZFS_ROOT=${ZFS_ROOT:-"/poudriere"}
264
export POUDRIERE_PORTS_NAME=${POUDRIERE_PORTS_NAME:-"${PRODUCT_NAME}_${GIT_REPO_BRANCH_OR_TAG}"}
265

    
266
export POUDRIERE_BULK=${POUDRIERE_BULK:-"${BUILDER_TOOLS}/conf/pfPorts/poudriere_bulk"}
267
export POUDRIERE_PORTS_GIT_URL=${POUDRIERE_PORTS_GIT_URL:-"git@git.pfmechanics.com:pfsense/freebsd-ports.git"}
268
export POUDRIERE_PORTS_GIT_BRANCH=${POUDRIERE_PORTS_GIT_BRANCH:-"devel"}
269

    
270
# Host to rsync pkg repos from poudriere
271
export PKG_RSYNC_USERNAME=${PKG_RSYNC_USERNAME:-"wwwsync"}
272
export PKG_RSYNC_SSH_PORT=${PKG_RSYNC_SSH_PORT:-"22"}
273
export PKG_RSYNC_DESTDIR=${PKG_RSYNC_DESTDIR:-"/usr/local/www/beta/packages"}
274
export PKG_REPO_SERVER=${PKG_REPO_SERVER:-"pkg+http://beta.pfsense.org/packages"}
275
export PKG_REPO_CONF_BRANCH=${PKG_REPO_CONF_BRANCH:-"${GIT_REPO_BRANCH_OR_TAG}"}
276

    
277
if echo "${PRODUCT_VERSION}" | grep -q -- '-RELEASE'; then
278
	export _IS_RELEASE=yes
279
else
280
	unset _IS_RELEASE
281
fi
282

    
283
# Define base package version, based on date for snaps
284
CORE_PKG_VERSION=${PRODUCT_VERSION%%-*}
285
if [ -n "${_IS_RELEASE}" ]; then
286
	CORE_PKG_VERSION="${CORE_PKG_VERSION}.${DATESTRING}"
287
fi
288
export CORE_PKG_PATH=${CORE_PKG_PATH:-"${SCRATCHDIR}/${PRODUCT_NAME}_${GIT_REPO_BRANCH_OR_TAG}_${TARGET}_${TARGET_ARCH}-core"}
289
export CORE_PKG_TMP=${CORE_PKG_TMP:-"${SCRATCHDIR}/core_pkg_tmp"}
290

    
291
# Package overlay. This gives people a chance to build product
292
# installable image that already contains certain extra packages.
293
#
294
# Needs to contain comma separated package names. Of course
295
# package names must be valid. Using non existent
296
# package name would yield an error.
297
#
298
#export custom_package_list=""
299

    
300
# General builder output filenames
301
if [ -n "${_IS_RELEASE}" ]; then
302
	export TIMESTAMP_SUFFIX=""
303
else
304
	export TIMESTAMP_SUFFIX="-${DATESTRING}"
305
fi
306

    
307
export UPDATESDIR=${UPDATESDIR:-"${IMAGES_FINAL_DIR}/updates"}
308
export ISOPATH=${ISOPATH:-"${IMAGES_FINAL_DIR}/${PRODUCT_NAME}-LiveCD-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.iso"}
309
export MEMSTICKPATH=${MEMSTICKPATH:-"${IMAGES_FINAL_DIR}/${PRODUCT_NAME}-memstick-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.img"}
310
export MEMSTICKSERIALPATH=${MEMSTICKSERIALPATH:-"${IMAGES_FINAL_DIR}/${PRODUCT_NAME}-memstick-serial-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.img"}
311
export MEMSTICKADIPATH=${MEMSTICKADIPATH:-"${IMAGES_FINAL_DIR}/${PRODUCT_NAME}-memstick-ADI-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.img"}
312
export OVAPATH=${OVAPATH:-"${IMAGES_FINAL_DIR}/${PRODUCT_NAME}-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.ova"}
313

    
314
# set full-update update filename
315
export UPDATES_TARBALL_FILENAME=${UPDATES_TARBALL_FILENAME:-"${UPDATESDIR}/${PRODUCT_NAME}-Full-Update-${PRODUCT_VERSION}-${TARGET}${TIMESTAMP_SUFFIX}.tgz"}
316

    
317
# Rsync data to send snapshots
318
export RSYNCUSER=${RSYNCUSER:-"snapshots"}
319
export RSYNCPATH=${RSYNCPATH:-"/usr/local/www/snapshots/${TARGET}/${PRODUCT_NAME}_${GIT_REPO_BRANCH_OR_TAG}"}
320
export RSYNCLOGS=${RSYNCLOGS:-"/usr/local/www/snapshots/logs/${PRODUCT_NAME}_${GIT_REPO_BRANCH_OR_TAG}/${TARGET}"}
321
export RSYNCKBYTELIMIT=${RSYNCKBYTELIMIT:-"248000"}
322

    
323
# staging area used on snapshots build
324
STAGINGAREA=${STAGINGAREA:-"${SCRATCHDIR}/staging"}
325
mkdir -p ${STAGINGAREA}
326

    
327
export SNAPSHOTSLOGFILE=${SNAPSHOTSLOGFILE:-"${SCRATCHDIR}/snapshots-build.log"}
328
export SNAPSHOTSLASTUPDATE=${SNAPSHOTSLASTUPDATE:-"${SCRATCHDIR}/snapshots-lastupdate.log"}
(3-3/3)