Skip to content

Commit 9d6d9c2

Browse files
committed
build.sh: add backward compatible AIRGAP build
This change look for AIRGAP environment variable and if it is set it perform airgap build of Dasharo for Odroid H4 and its version for Intel Boot Guard. This is required for security, privacy and trainers who would like to perform 100% offline build. To make that possible couple requirements have to be fulfilled: - repository cannot be distcleaned, because it remove all artifacts, the assumption is that provided repository already has all dependencies fetched, so only make clean is made before proceeding - since whole process rely on mounting edk2 as volume inside Dasharo SDK container, workspace directory to which it would be mount needs proper permissions otherwise docker will create mountpoint with root privileges, what cause issues in further use and build process - finally we take into consideration BUILD_TIMELESS environment variable, which improve testability of build process and toolchain change This change was tested by: 1. cloning relevant version of edk2 2. cloning coreboot, cd coreboot 3. running checkout on ipxe: docker run --rm --user $(id -u):$(id -g) -v $PWD:/home/coreboot/coreboot \ ${DASHARO_SDK} \ make -C /home/coreboot/coreboot/payloads/external/iPXE checkout 4. Build EDK2_REPO_PATH="${PWD}/../edk2" AIRGAP=1 BUILD_TIMELESS=1 ./build.sh odroid_h4_btg EDK2_REPO_PATH="${PWD}/../edk2" AIRGAP=1 BUILD_TIMELESS=1 ./build.sh odroid_h4 Signed-off-by: Piotr Król <[email protected]>
1 parent 7aafa91 commit 9d6d9c2

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

build.sh

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,52 @@ function build_odroid_h4 {
244244
git submodule update --init --force --checkout \
245245
3rdparty/dasharo-blobs
246246

247-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
248-
-v $HOME/.ssh:/home/coreboot/.ssh \
249-
-w /home/coreboot/coreboot ${DASHARO_SDK} \
250-
/bin/bash -c "make distclean"
247+
if [ "${AIRGAP}" -eq 1 ]; then
248+
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
249+
-v $HOME/.ssh:/home/coreboot/.ssh \
250+
-w /home/coreboot/coreboot ${DASHARO_SDK} \
251+
/bin/bash -c "make clean"
252+
else
253+
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
254+
-v $HOME/.ssh:/home/coreboot/.ssh \
255+
-w /home/coreboot/coreboot ${DASHARO_SDK} \
256+
/bin/bash -c "make distclean"
257+
fi
251258

252259
cp $DEFCONFIG .config
253260

254261
echo "Building Dasharo compatbile with Hardkernel ODROID H4 (version $FW_VERSION)"
255262

256-
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
257-
-v $HOME/.ssh:/home/coreboot/.ssh \
258-
-w /home/coreboot/coreboot ${DASHARO_SDK} \
259-
/bin/bash -c "make olddefconfig && make -j$(nproc)"
263+
if [ "${AIRGAP}" -eq 1 ]; then
264+
265+
# In this situation we assume that provided repository is ready to be used
266+
# and nothing should be downloaded during build process.
267+
268+
if [ -d "${EDK2_REPO_PATH}" ]; then
269+
# Without following sequence workspce would be created by docker with root
270+
# privilidges and build will fail.
271+
# Target directory
272+
TARGET_DIR="payloads/external/edk2/workspace/Dasharo"
273+
mkdir -p "$TARGET_DIR"
274+
chown -R $(id -u):$(id -g) "$TARGET_DIR"
275+
chmod -R 755 "$TARGET_DIR"
276+
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
277+
-v $HOME/.ssh:/home/coreboot/.ssh \
278+
--network none \
279+
${EDK2_REPO_PATH:+-v $EDK2_REPO_PATH:/home/coreboot/coreboot/payloads/external/edk2/workspace/Dasharo} \
280+
-e BUILD_TIMELESS=${BUILD_TIMELESS} \
281+
-w /home/coreboot/coreboot ${DASHARO_SDK} \
282+
/bin/bash -c "make olddefconfig && make -j$(nproc)"
283+
else
284+
echo "EDK2_REPO_PATH is not defined in AIRGAP!"
285+
exit 1
286+
fi
287+
else
288+
docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \
289+
-v $HOME/.ssh:/home/coreboot/.ssh \
290+
-w /home/coreboot/coreboot ${DASHARO_SDK} \
291+
/bin/bash -c "make olddefconfig && make -j$(nproc)"
292+
fi
260293

261294
cp build/coreboot.rom hardkernel_odroid_h4_${FW_VERSION}.rom
262295
if [ $? -eq 0 ]; then

0 commit comments

Comments
 (0)