forked from ocochard/BSDRP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·110 lines (96 loc) · 4.53 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#
# New (experimental) Build script for BSD Router Project
# https://bsdrp.net
#
# Copyright (c) 2009-2023, The BSDRP Development Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
set -eu
echo "******** EXPERIMENTAL ********"
echo "WARNING: Need patched poudriere"
echo "https://github.com/freebsd/poudriere/pull/1038"
gen_pkg_list () {
# Extract list of packages from BSDRP.nano
# XXX need to convert FLAVOR to @
grep '^add_port "' BSDRP/BSDRP.nano | cut -d '"' -f 2 | sort > poudriere.etc/poudriere.d/BSDRP-pkglist
}
gen_pkg_options () {
# Extract all ports for specific options to set
# Need to translate into some category_port_SET/UNSET in jail-specific make.conf
# grep 'add_port.*WITH' BSDRP/BSDRP.nano
echo XXX
grep 'add_port' | sort > ports_custom_options
}
gen_kernel_modules () {
# Extract all kernel module for arch
. "${SCRIPT_DIR}"/${PROJECT}/make.conf
echo "MODULES_OVERRIDE to put in poudriere.etc/poudriere.d/BSDRPj-src.conf:"
echo ${NANO_MODULES_amd64}
}
# Update pkglist file
# Commented because need manual review until automatic FLAVOR is managed
#gen_pkg_list
#gen_pkg_option
# Download and patches sources, install custom kernel (amd64)
echo "[DEBUG] Skip make -U"
#./make.sh -U
# XXX we have a problem if user have custom generic poudirere
# Need to use custom etc dir for poudriere, but need to reuse already local configuration
cp /usr/local/etc/poudriere.conf poudriere.etc/
# Create, or update the builder jail
if poudriere -e poudriere.etc jail -ln | grep -q BSDRPj; then
path_of_the_jail=$(poudriere -e poudriere.etc/ jail -j BSDRPj -l | tail -1 | cut -d ' ' -f 10)
if [ -n "$(find /usr/local/BSDRP/BSDRP/FreeBSD/src -type f -newer ${path_of_the_jail}/boot/kernel/kernel)" ]; then
echo "Find sources newer than kernel, updating poudriere jail (build_jail.log)"
poudriere -e poudriere.etc jail -u -j BSDRPj -b -m src=/usr/local/BSDRP/BSDRP/FreeBSD/src -K amd64 > build_jail.log
fi
else
echo "Creating poudriere jail (build_jail.log)"
poudriere -e poudriere.etc jail -c -j BSDRPj -b -m src=/usr/local/BSDRP/BSDRP/FreeBSD/src -K amd64 > build_jail.log
fi
# Create or update port tree
# XXX Regression: latest modifications time of dependencies are ignored
if poudriere -e poudriere.etc ports -ln | grep -q BSDRPp; then
echo "Updating poudriere port tree (build_ports.log)"
poudriere -e poudriere.etc ports -u -p BSDRPp -m null -M /usr/local/BSDRP/BSDRP/FreeBSD/ports > build_ports.log
else
echo "Creating poudriere port tree (build_ports.log)"
poudriere -e poudriere.etc ports -c -p BSDRPp -m null -M /usr/local/BSDRP/BSDRP/FreeBSD/ports > build_ports.log
fi
# Build the packages
echo "Building packages (build_ports.log)"
poudriere -e poudriere.etc bulk -j BSDRPj -p BSDRPp -f poudriere.etc/poudriere.d/BSDRP-pkglist >> build_ports.log
# Build the firmware image
# size in bytes
# Notice that we are using a custom pkg.conf files preventing to install useless files
echo "Generating disk image (build_image.log)"
poudriere -e poudriere.etc image -t firmware -s 2g \
-j BSDRPj -p BSDRPp -n BSDRP -h router.bsdrp.net \
-c BSDRP/Files/ \
-f poudriere.etc/poudriere.d/BSDRP-pkglist \
-X poudriere.etc/poudriere.d/excluded.files \
-A poudriere.etc/poudriere.d/post-script.sh > build_image.log
# Convert image to VHD
# qemu-img convert -f raw -O vpc /usr/local/poudriere/data/images/BSDRP.img BSDRP.vhd