Skip to content

Commit 961fd57

Browse files
committed
build.sh: Move common build steps to functions
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
1 parent becd33b commit 961fd57

File tree

1 file changed

+130
-135
lines changed

1 file changed

+130
-135
lines changed

build.sh

Lines changed: 130 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -9,216 +9,208 @@ usage() {
99
echo -e "\tz690a_ddr5 - build Dasharo image compatible with MSI PRO Z690-A (WIFI)"
1010
echo -e "\tz790p_ddr4 - build Dasharo image compatible with MSI PRO Z790-P (WIFI) DDR4"
1111
echo -e "\tz790p_ddr5 - build Dasharo image compatible with MSI PRO Z790-P (WIFI)"
12+
1213
echo -e "\tvp66xx - build Dasharo for Protectli VP66xx"
1314
echo -e "\tvp46xx - build Dasharo for Protectli VP46xx"
1415
echo -e "\tvp2420 - build Dasharo for Protectli VP2420"
1516
echo -e "\tvp2410 - build Dasharo for Protectli VP2410"
1617
echo -e "\tV1210 - build Dasharo for Protectli V1210"
1718
echo -e "\tV1410 - build Dasharo for Protectli V1410"
1819
echo -e "\tV1610 - build Dasharo for Protectli V1610"
20+
1921
echo -e "\tapu2 - build Dasharo for PC Engines APU2"
2022
echo -e "\tapu3 - build Dasharo for PC Engines APU3"
2123
echo -e "\tapu4 - build Dasharo for PC Engines APU4"
2224
echo -e "\tapu6 - build Dasharo for PC Engines APU6"
25+
2326
echo -e "\toptiplex_9010 - build Dasharo compatible with Dell OptiPlex 7010/9010"
27+
2428
echo -e "\tqemu - build Dasharo for QEMU Q35"
2529
echo -e "\tqemu_full - build Dasharo for QEMU Q35 with all menus available"
30+
31+
echo -e "\tv540tu - build Dasharo for Novacustom V540TU"
32+
echo -e "\tv560tu - build Dasharo for Novacustom V560TU"
33+
echo -e "\tns5x7x - build Dasharo for Novacustom NS5x/NS7x"
34+
echo -e "\tnv4x_adl - build Dasharo for Novacustom NV4x 12 gen"
35+
echo -e "\tnx5x7x - build Dasharo for Novacustom Nx5x/Nx7x"
36+
echo -e "\tnv4x_tgl - build Dasharo for Novacustom NV4x 11 gen"
2637
}
2738

2839
SDKVER="2023-11-24_2731fa619b"
2940

3041

31-
function build_optiplex_9010 {
32-
DEFCONFIG="configs/config.dell_optiplex_9010_sff_uefi_txt"
33-
FW_VERSION=v0.1.0-rc1
3442

35-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
36-
-v $HOME/.ssh:/home/coreboot/.ssh \
37-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
38-
/bin/bash -c "make distclean"
43+
function prepare_for_build {
44+
if [[ -v CB_REVISION ]]; then
45+
git checkout $CB_REVISION
46+
fi
3947

40-
cp "${DEFCONFIG}" .config
48+
if [[ ! -v NO_DISTCLEAN ]]; then
49+
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
50+
-v $HOME/.ssh:/home/coreboot/.ssh \
51+
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
52+
/bin/bash -c "make distclean"
53+
fi
4154

42-
git submodule update --init --checkout
55+
if [[ ! -v NO_CONFIG_OVERRIDE ]]; then
56+
cp "${DEFCONFIG}" .config
57+
fi
58+
}
4359

44-
echo "Building Dasharo compatible with Dell OptiPlex 7010/9010 (version $FW_VERSION)"
60+
function build_coreboot {
61+
TARGET_BINARY=$1
62+
prepare_for_build
4563

4664
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
4765
-v $HOME/.ssh:/home/coreboot/.ssh \
4866
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
4967
/bin/bash -c "make olddefconfig && make -j$(nproc)"
50-
51-
cp build/coreboot.rom ${BOARD}_${FW_VERSION}.rom
68+
69+
cp build/coreboot.rom $TARGET_BINARY
5270
if [ $? -eq 0 ]; then
53-
echo "Result binary placed in $PWD/${BOARD}_${FW_VERSION}.rom"
54-
sha256sum ${BOARD}_${FW_VERSION}.rom > ${BOARD}_${FW_VERSION}.rom.sha256
71+
echo "Result binary placed in $PWD/$TARGET_BINARY"
72+
sha256sum $TARGET_BINARY > $TARGET_BINARY.sha256
5573
else
5674
echo "Build failed!"
5775
exit 1
5876
fi
5977
}
6078

61-
function build_msi {
62-
DEFCONFIG="configs/config.${BOARD}_$1"
63-
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
64-
65-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
66-
-v $HOME/.ssh:/home/coreboot/.ssh \
67-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
68-
/bin/bash -c "make distclean"
69-
70-
cp "${DEFCONFIG}" .config
71-
72-
git submodule update --init --checkout
73-
74-
echo "Building Dasharo compatible with MSI PRO $2(WIFI) (version $FW_VERSION)"
79+
function build_ec {
80+
EC_BOARD_VENDOR=$1
81+
EC_BOARD_MODEL=$2
82+
if [[ ! -v EC_REVISION ]]; then
83+
echo "EC_REVISION environmental variable is not set. Please provide an EC revision."
84+
exit 1;
85+
fi
86+
87+
echo "Building EC for $EC_BOARD_VENDOR $EC_BOARD_MODEL from branch $EC_REVISION"
88+
git clone https://github.com/Dasharo/ec.git &> /dev/null || true
89+
cd ec
90+
git checkout $EC_REVISION
91+
git submodule update --init --recursive --checkout
92+
EC_BOARD_VENDOR=novacustom EC_BOARD_MODEL=nv4x_adl ./build.sh || true
93+
cd ..
94+
cp "ec/${EC_BOARD_VENDOR}_${EC_BOARD_MODEL}_ec.rom" ec.rom
95+
}
7596

76-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
77-
-v $HOME/.ssh:/home/coreboot/.ssh \
78-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
79-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
97+
function generic_submodules {
98+
if [[ ! -v NO_SUBMODULE_UPDATE ]]; then
99+
git submodule update --init --checkout
100+
fi
101+
}
80102

81-
cp build/coreboot.rom ${BOARD}_${FW_VERSION}_$1.rom
82-
if [ $? -eq 0 ]; then
83-
echo "Result binary placed in $PWD/${BOARD}_${FW_VERSION}_$1.rom"
84-
sha256sum ${BOARD}_${FW_VERSION}_$1.rom > ${BOARD}_${FW_VERSION}_$1.rom.sha256
103+
function protectli_submodules {
104+
if [[ ! -d 3rdparty/dasharo-blobs/protectli ]]; then
105+
NO_SUBMODULE_UPDATE="true"
85106
else
86-
echo "Build failed!"
87-
exit 1
107+
unset NO_SUBMODULE_UPDATE
88108
fi
109+
generic_submodules
89110
}
90111

91-
function build_protectli_vault {
92-
DEFCONFIG="configs/config.protectli_${BOARD}"
93-
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
112+
function pcengines_submodules {
113+
if [[ ! -v NO_SUBMODULE_UPDATE ]]; then
114+
# checkout several submodules needed by these boards (some others are checked
115+
# out by coreboot's Makefile)
116+
git submodule update --init --force --checkout \
117+
3rdparty/dasharo-blobs \
118+
3rdparty/vboot
119+
fi
120+
}
94121

95-
if [ ! -d 3rdparty/dasharo-blobs/protectli ]; then
96-
git submodule update --init --checkout
122+
function qemu_submodules {
123+
if [[ ! -v NO_SUBMODULE_UPDATE ]]; then
124+
# checkout several submodules needed by these boards (some others are checked
125+
# out by coreboot's Makefile)
126+
git submodule update --init --force --checkout \
127+
3rdparty/dasharo-blobs
97128
fi
129+
}
98130

99-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
100-
-v $HOME/.ssh:/home/coreboot/.ssh \
101-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:2021-09-23_b0d87f753c \
102-
/bin/bash -c "make distclean"
131+
function build_optiplex_9010 {
132+
DEFCONFIG="configs/config.dell_optiplex_9010_sff_uefi_txt"
133+
FW_VERSION=v0.1.0-rc1
103134

104-
cp $DEFCONFIG .config
135+
generic_submodules
136+
TARGET_BINARY="${BOARD}_${FW_VERSION}"
137+
echo "Building Dasharo compatible with Dell OptiPlex 7010/9010 (version $FW_VERSION)"
138+
build_coreboot $TARGET_BINARY
139+
}
105140

106-
echo "Building Dasharo for Protectli $BOARD (version $FW_VERSION)"
141+
function build_msi {
142+
DEFCONFIG="configs/config.${BOARD}_$1"
143+
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
107144

108-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
109-
-v $HOME/.ssh:/home/coreboot/.ssh \
110-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
111-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
145+
generic_submodules
146+
TARGET_BINARY= ${BOARD}_${FW_VERSION}_$1.rom
147+
echo "Building Dasharo compatible with MSI PRO $2(WIFI) (version $FW_VERSION)"
148+
build_coreboot $TARGET_BINARY
149+
}
112150

113-
cp build/coreboot.rom protectli_${BOARD}_${FW_VERSION}.rom
114-
if [ $? -eq 0 ]; then
115-
echo "Result binary placed in $PWD/protectli_${BOARD}_${FW_VERSION}.rom"
116-
sha256sum protectli_${BOARD}_${FW_VERSION}.rom > protectli_${BOARD}_${FW_VERSION}.rom.sha256
117-
else
118-
echo "Build failed!"
119-
exit 1
120-
fi
151+
function build_protectli_vault {
152+
DEFCONFIG="configs/config.protectli_${BOARD}"
153+
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
154+
155+
protectli_submodules
156+
TARGET_BINARY=protectli_${BOARD}_${FW_VERSION}.rom
157+
echo "Building Dasharo for Protectli $BOARD (version $FW_VERSION)"
158+
build_coreboot $TARGET_BINARY
121159
}
122160

123161
function build_v1x10 {
124162
DEFCONFIG="configs/config.protectli_vault_jsl_$1"
125163
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
126164

127-
if [ ! -d 3rdparty/dasharo-blobs/protectli ]; then
128-
git submodule update --init --checkout
129-
fi
130-
131-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
132-
-v $HOME/.ssh:/home/coreboot/.ssh \
133-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
134-
/bin/bash -c "make distclean"
135-
136-
cp $DEFCONFIG .config
137-
165+
protectli_submodules
166+
TARGET_BINARY=protectli_$1_${FW_VERSION}.rom
138167
echo "Building Dasharo for Protectli $1 (version $FW_VERSION)"
139-
140-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
141-
-v $HOME/.ssh:/home/coreboot/.ssh \
142-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
143-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
144-
145-
cp build/coreboot.rom protectli_$1_${FW_VERSION}.rom
146-
if [ $? -eq 0 ]; then
147-
echo "Result binary placed in $PWD/protectli_$1_${FW_VERSION}.rom"
148-
sha256sum protectli_$1_${FW_VERSION}.rom > protectli_$1_${FW_VERSION}.rom.sha256
149-
else
150-
echo "Build failed!"
151-
exit 1
152-
fi
168+
build_coreboot $TARGET_BINARY
153169
}
154170

155171
function build_pcengines {
156172
VARIANT=$1
157173
DEFCONFIG="configs/config.pcengines_uefi_${VARIANT}"
158174
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
159175

160-
# checkout several submodules needed by these boards (some others are checked
161-
# out by coreboot's Makefile)
162-
git submodule update --init --force --checkout \
163-
3rdparty/dasharo-blobs \
164-
3rdparty/vboot
165-
166-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
167-
-v $HOME/.ssh:/home/coreboot/.ssh \
168-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
169-
/bin/bash -c "make distclean"
170-
171-
cp $DEFCONFIG .config
172-
176+
pcengines_submodules
177+
TARGET_BINARY=pcengines_${VARIANT}_${FW_VERSION}.rom
173178
echo "Building Dasharo for PC Engines ${VARIANT^^*} (version $FW_VERSION)"
174-
175-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
176-
-v $HOME/.ssh:/home/coreboot/.ssh \
177-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
178-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
179-
180-
cp build/coreboot.rom pcengines_${VARIANT}_${FW_VERSION}.rom
181-
if [ $? -eq 0 ]; then
182-
echo "Result binary placed in $PWD/pcengines_${VARIANT}_${FW_VERSION}.rom"
183-
sha256sum pcengines_${VARIANT}_${FW_VERSION}.rom > pcengines_${VARIANT}_${FW_VERSION}.rom.sha256
184-
else
185-
echo "Build failed!"
186-
exit 1
187-
fi
179+
build_coreboot $TARGET_BINARY
188180
}
189181

190182
function build_qemu {
191183
DEFCONFIG="configs/config.emulation_qemu_x86_q35_uefi${1:-}"
192184
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
193185

194-
# checkout several submodules needed by these boards (some others are checked
195-
# out by coreboot's Makefile)
196-
git submodule update --init --force --checkout \
197-
3rdparty/dasharo-blobs
198-
199-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
200-
-v $HOME/.ssh:/home/coreboot/.ssh \
201-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
202-
/bin/bash -c "make distclean"
203-
204-
cp $DEFCONFIG .config
205-
186+
qemu_submodules
187+
TARGET_BINARY=qemu_q35_${FW_VERSION}.rom
206188
echo "Building Dasharo for QEMU Q35 (version $FW_VERSION)"
189+
build_coreboot $TARGET_BINARY
190+
}
207191

208-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
209-
-v $HOME/.ssh:/home/coreboot/.ssh \
210-
-w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \
211-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
192+
function build_nv4x_adl {
193+
DEFCONFIG="configs/config.novacustom_nv4x_adl"
194+
FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"')
212195

213-
cp build/coreboot.rom qemu_q35_${FW_VERSION}.rom
214-
if [ $? -eq 0 ]; then
215-
echo "Result binary placed in $PWD/qemu_q35_${FW_VERSION}.rom"
216-
sha256sum qemu_q35_${FW_VERSION}.rom > qemu_q35_${FW_VERSION}.rom.sha256
196+
if [[ -v EC_REVISION ]]; then
197+
build_ec novacustom nv4x_adl
217198
else
218-
echo "Build failed!"
219-
exit 1
199+
echo "No EC revision provided. Set EC_REVISION environmental variable
200+
#build_ec novacustom_nv4x_adl_v1.7.2 novacustom nv4x_adl
220201
fi
202+
203+
generic_submodules
204+
TARGET_BINARY=novacustom_nv4x_adl_$FW_VERSION
205+
echo "Building Dasharo for Novacustom NV4x Adl (version $FW_VERSION)"
206+
build_coreboot $TARGET_BINARY
221207
}
208+
# echo -3 "\tv540tu - build Dasharo for Novacustom V540TU"
209+
# echo -3 "\tv560tu - build Dasharo for Novacustom V560TU"
210+
# echo -3 "\tns5x7x - build Dasharo for Novacustom NS5x/NS7x"
211+
# echo -3 "\tnv4x - build Dasharo for Novacustom NV4x"
212+
# echo -3 "\tnx5x7x - build Dasharo for Novacustom Nx5x/Nx7x"
213+
# echo -3 "\tnv4x - build Dasharo for Novacustom NV4x"
222214
223215
CMD="$1"
224216
@@ -289,6 +281,9 @@ case "$CMD" in
289281
"qemu_full" | "QEMU_full" | "q35_full" | "Q35_full" )
290282
build_qemu "_all_menus"
291283
;;
284+
"nv4x_adl" )
285+
build_nv4x_adl
286+
;;
292287
*)
293288
echo "Invalid command: \"$CMD\""
294289
usage

0 commit comments

Comments
 (0)