From ddd974b56aa9d8a80591342f2dd037376262556e Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 12 Jun 2023 10:45:49 +0200 Subject: [PATCH] build: add support for model R to build-docker provisional, we will want to use the internal model names here too, but that's gonna need to wait for the change of the TREZOR_MODEL env vars --- build-docker.sh | 97 ++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index d58e5f563b..8dedd523e9 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -55,6 +55,7 @@ function help_and_die() { echo " --prodtest - build core prodtest" echo " --repository path/to/repo - checkout the repository from the given path/url" echo " --no-init - do not recreate docker environments" + echo " --models - comma-separated list of models. default: --models R,T" echo " --help" echo echo "Set PRODUCTION=0 to run non-production builds." @@ -67,6 +68,7 @@ OPT_BUILD_NORMAL=1 OPT_BUILD_BITCOINONLY=1 OPT_BUILD_PRODTEST=0 INIT=1 +MODELS=(R T) REPOSITORY="/local" @@ -103,6 +105,11 @@ while true; do INIT=0 shift ;; + --models) + # take comma-separated next argument and turn it into an array + IFS=',' read -r -a MODELS <<< "$2" + shift 2 + ;; *) break ;; @@ -252,45 +259,49 @@ DIR=$(pwd) # build core -for BITCOIN_ONLY in ${VARIANTS_core[@]}; do +for TREZOR_MODEL in ${MODELS[@]}; do + for BITCOIN_ONLY in ${VARIANTS_core[@]}; do - DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} - DIRSUFFIX=${DIRSUFFIX/0/} + DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} + DIRSUFFIX=${DIRSUFFIX/0/} + DIRSUFFIX="-${TREZOR_MODEL}${DIRSUFFIX}" - SCRIPT_NAME=".build_core_$BITCOIN_ONLY.sh" - cat < "build/$SCRIPT_NAME" - # DO NOT MODIFY! - # this file was generated by ${BASH_SOURCE[0]} - # variant: core build BITCOIN_ONLY=$BITCOIN_ONLY - set -e -o pipefail - cd /reproducible-build/trezor-firmware/core - $GIT_CLEAN_REPO - poetry run make clean vendor build_bootloader build_firmware - for item in bootloader firmware; do - poetry run ../python/tools/firmware-fingerprint.py \ - -o build/\$item/\$item.bin.fingerprint \ - build/\$item/\$item.bin - done - rm -rf /build/* - cp -r build/* /build - chown -R $USER:$GROUP /build + SCRIPT_NAME=".build_core_${TREZOR_MODEL}_${BITCOIN_ONLY}.sh" + cat < "build/$SCRIPT_NAME" + # DO NOT MODIFY! + # this file was generated by ${BASH_SOURCE[0]} + # variant: core build BITCOIN_ONLY=$BITCOIN_ONLY TREZOR_MODEL=$TREZOR_MODEL + set -e -o pipefail + cd /reproducible-build/trezor-firmware/core + $GIT_CLEAN_REPO + poetry run make clean vendor build_bootloader build_firmware + for item in bootloader firmware; do + poetry run ../python/tools/firmware-fingerprint.py \ + -o build/\$item/\$item.bin.fingerprint \ + build/\$item/\$item.bin + done + rm -rf /build/* + cp -r build/* /build + chown -R $USER:$GROUP /build EOF - echo - echo ">>> DOCKER RUN core BITCOIN_ONLY=$BITCOIN_ONLY PRODUCTION=$PRODUCTION" - echo + echo + echo ">>> DOCKER RUN core BITCOIN_ONLY=$BITCOIN_ONLY TREZOR_MODEL=$TREZOR_MODEL PRODUCTION=$PRODUCTION" + echo - $DOCKER run \ - --network=host \ - -it \ - --rm \ - -v "$DIR:/local" \ - -v "$DIR/build/core$DIRSUFFIX":/build:z \ - --env BITCOIN_ONLY="$BITCOIN_ONLY" \ - --env PRODUCTION="$PRODUCTION" \ - --init \ - "$SNAPSHOT_NAME" \ - /nix/var/nix/profiles/default/bin/nix-shell --run "bash /local/build/$SCRIPT_NAME" + $DOCKER run \ + --network=host \ + -it \ + --rm \ + -v "$DIR:/local" \ + -v "$DIR/build/core$DIRSUFFIX":/build:z \ + --env BITCOIN_ONLY="$BITCOIN_ONLY" \ + --env TREZOR_MODEL="$TREZOR_MODEL" \ + --env PRODUCTION="$PRODUCTION" \ + --init \ + "$SNAPSHOT_NAME" \ + /nix/var/nix/profiles/default/bin/nix-shell --run "bash /local/build/$SCRIPT_NAME" + done done # build legacy @@ -387,14 +398,16 @@ echo "Built from commit $COMMIT_HASH" echo echo "Fingerprints:" for VARIANT in core legacy; do - for DIRSUFFIX in "" "-bitcoinonly" "-prodtest"; do - BUILD_DIR=build/${VARIANT}${DIRSUFFIX} - for file in $BUILD_DIR/*/*.fingerprint; do - if [ -f "$file" ]; then - origfile="${file%.fingerprint}" - fingerprint=$(tr -d '\n' < $file) - echo "$fingerprint $origfile" - fi + for MODEL in "R" "T"; do + for DIRSUFFIX in "" "-bitcoinonly" "-prodtest"; do + BUILD_DIR=build/${VARIANT}-${MODEL}${DIRSUFFIX} + for file in $BUILD_DIR/*/*.fingerprint; do + if [ -f "$file" ]; then + origfile="${file%.fingerprint}" + fingerprint=$(tr -d '\n' < $file) + echo "$fingerprint $origfile" + fi + done done done done