diff --git a/build.sh b/build.sh index 0c980e3619e..5ed6eefc916 100755 --- a/build.sh +++ b/build.sh @@ -30,7 +30,8 @@ usage() { } SDKVER="2024-02-18_732134932b" - +DASHARO_SDK=${DASHARO_SDK:-"ghcr.io/dasharo/dasharo-sdk:latest"} +BUILD_TIMELESS=${BUILD_TIMELESS:-0} function build_optiplex_9010 { DEFCONFIG=$1 @@ -43,13 +44,13 @@ function build_optiplex_9010 { # Get FW version FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - + # Combine FW flavor with version FW_VERSION="${FW_FLAVOR}_${FW_VERSION}" docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make distclean" cp "${DEFCONFIG}" .config @@ -60,7 +61,7 @@ function build_optiplex_9010 { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom ${BOARD}_${FW_VERSION}.rom @@ -79,7 +80,7 @@ function build_msi { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make distclean" cp "${DEFCONFIG}" .config @@ -90,7 +91,7 @@ function build_msi { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom ${BOARD}_${FW_VERSION}_$1.rom @@ -122,7 +123,7 @@ function build_protectli_vault { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom protectli_${BOARD}_${FW_VERSION}.rom @@ -145,7 +146,7 @@ function build_v1x10 { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make distclean" cp $DEFCONFIG .config @@ -154,7 +155,7 @@ function build_v1x10 { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom protectli_$1_${FW_VERSION}.rom @@ -180,7 +181,7 @@ function build_pcengines { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make distclean" cp $DEFCONFIG .config @@ -189,7 +190,8 @@ function build_pcengines { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -e BUILD_TIMELESS=${BUILD_TIMELESS} \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom pcengines_${VARIANT}_${FW_VERSION}.rom @@ -213,7 +215,7 @@ function build_qemu { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make distclean" cp $DEFCONFIG .config @@ -222,7 +224,8 @@ function build_qemu { docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + -e BUILD_TIMELESS=${BUILD_TIMELESS} \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ /bin/bash -c "make olddefconfig && make -j$(nproc)" cp build/coreboot.rom qemu_q35_${FW_VERSION}.rom @@ -236,7 +239,7 @@ function build_qemu { } function build_odroid_h4 { - DEFCONFIG="configs/config.hardkernel_odroid_h4" + DEFCONFIG=$1 FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') # checkout several submodules needed by these boards (some others are checked @@ -244,19 +247,52 @@ function build_odroid_h4 { git submodule update --init --force --checkout \ 3rdparty/dasharo-blobs - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" + if [ "${AIRGAP}" -eq 1 ]; then + docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ + -v $HOME/.ssh:/home/coreboot/.ssh \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ + /bin/bash -c "make clean" + else + docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ + -v $HOME/.ssh:/home/coreboot/.ssh \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ + /bin/bash -c "make distclean" + fi cp $DEFCONFIG .config echo "Building Dasharo compatbile with Hardkernel ODROID H4 (version $FW_VERSION)" - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" + if [ "${AIRGAP}" -eq 1 ]; then + + # In this situation we assume that provided repository is ready to be used + # and nothing should be downloaded during build process. + + if [ -d "${EDK2_REPO_PATH}" ]; then + # Without following sequence workspce would be created by docker with root + # privilidges and build will fail. + # Target directory + TARGET_DIR="payloads/external/edk2/workspace/Dasharo" + mkdir -p "$TARGET_DIR" + chown -R $(id -u):$(id -g) "$TARGET_DIR" + chmod -R 755 "$TARGET_DIR" + docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ + -v $HOME/.ssh:/home/coreboot/.ssh \ + --network none \ + ${EDK2_REPO_PATH:+-v $EDK2_REPO_PATH:/home/coreboot/coreboot/payloads/external/edk2/workspace/Dasharo} \ + -e BUILD_TIMELESS=${BUILD_TIMELESS} \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ + /bin/bash -c "make olddefconfig && make -j$(nproc)" + else + echo "EDK2_REPO_PATH is not defined in AIRGAP!" + exit 1 + fi + else + docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ + -v $HOME/.ssh:/home/coreboot/.ssh \ + -w /home/coreboot/coreboot ${DASHARO_SDK} \ + /bin/bash -c "make olddefconfig && make -j$(nproc)" + fi cp build/coreboot.rom hardkernel_odroid_h4_${FW_VERSION}.rom if [ $? -eq 0 ]; then @@ -350,7 +386,12 @@ case "$CMD" in build_qemu "_all_menus" ;; "odroid_h4" | "odroid_H4" | "ODROID_H4" ) - build_odroid_h4 + BOARD="odroid_h4" + build_odroid_h4 "configs/config.hardkernel_odroid_h4" + ;; + "odroid_h4_btg" ) + BOARD="odroid_h4" + build_odroid_h4 "configs/config.hardkernel_odroid_h4_btg" ;; *) echo "Invalid command: \"$CMD\""