diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 4d126d1886..6f5c7a4d34 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -139,7 +139,7 @@ jobs: with: fetch-depth: 0 - run: git checkout ${{ github.head_ref || github.ref_name }} - - run: ./build-docker.sh ${{ matrix.model == 'T1B1' && '--skip-core' || '--skip-legacy' }} --models ${{ matrix.model }} --targets bootloader,firmware,prodtest ${{ github.head_ref || github.ref_name }} + - run: ./build-docker.sh --models ${{ matrix.model }} --targets bootloader,firmware,prodtest ${{ github.head_ref || github.ref_name }} - name: Show fingerprints run: | for file in build/*/*/*.fingerprint; do diff --git a/build-docker.sh b/build-docker.sh index e0c7338250..1fdd020f40 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -50,11 +50,9 @@ function help_and_die() { echo "Options:" echo " --skip-bitcoinonly - do not build bitcoin-only firmwares" echo " --skip-normal - do not build regular firmwares" - echo " --skip-core - do not build core" - echo " --skip-legacy - do not build legacy" 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 T2B1,T2T1,T3T1" + echo " --models - comma-separated list of models. default: --models T1B1,T2B1,T2T1,T3T1" echo " --targets - comma-separated list of targets for core build. default: --targets boardloader,bootloader,firmware" echo " --help" echo @@ -64,12 +62,10 @@ function help_and_die() { exit 0 } -OPT_BUILD_CORE=1 -OPT_BUILD_LEGACY=1 OPT_BUILD_NORMAL=1 OPT_BUILD_BITCOINONLY=1 INIT=1 -MODELS=(T2B1 T2T1 T3T1) +MODELS=(T1B1 T2B1 T2T1 T3T1) CORE_TARGETS=(boardloader bootloader firmware) REPOSITORY="file:///local" @@ -87,14 +83,6 @@ while true; do OPT_BUILD_NORMAL=0 shift ;; - --skip-core) - OPT_BUILD_CORE=0 - shift - ;; - --skip-legacy) - OPT_BUILD_LEGACY=0 - shift - ;; --repository) REPOSITORY="$2" shift 2 @@ -133,15 +121,7 @@ if [ "$OPT_BUILD_BITCOINONLY" -eq 1 ]; then variants+=(1) fi -VARIANTS_core=() -VARIANTS_legacy=() - -if [ "$OPT_BUILD_CORE" -eq 1 ]; then - VARIANTS_core=("${variants[@]}") -fi -if [ "$OPT_BUILD_LEGACY" -eq 1 ]; then - VARIANTS_legacy=("${variants[@]}") -fi +VARIANTS=("${variants[@]}") TAG="$1" COMMIT_HASH="$(git rev-parse "$TAG")" @@ -266,7 +246,10 @@ DIR=$(pwd) # build core for TREZOR_MODEL in ${MODELS[@]}; do - for BITCOIN_ONLY in ${VARIANTS_core[@]}; do + if [ "$TREZOR_MODEL" = "T1B1" ]; then + continue + fi + for BITCOIN_ONLY in ${VARIANTS[@]}; do DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} DIRSUFFIX=${DIRSUFFIX/0/} @@ -320,49 +303,51 @@ done # build legacy -for BITCOIN_ONLY in ${VARIANTS_legacy[@]}; do +if echo "${MODELS[@]}" | grep -q T1B1 ; then + for BITCOIN_ONLY in ${VARIANTS[@]}; do - DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} - DIRSUFFIX=${DIRSUFFIX/0/} - DIRSUFFIX="-T1B1${DIRSUFFIX}" + DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} + DIRSUFFIX=${DIRSUFFIX/0/} + DIRSUFFIX="-T1B1${DIRSUFFIX}" - SCRIPT_NAME=".build_legacy_$BITCOIN_ONLY.sh" - cat < "build/$SCRIPT_NAME" - # DO NOT MODIFY! - # this file was generated by ${BASH_SOURCE[0]} - # variant: legacy build BITCOIN_ONLY=$BITCOIN_ONLY - set -e -o pipefail - cd /reproducible-build/trezor-firmware/legacy - $GIT_CLEAN_REPO - ln -s /build build - poetry run script/cibuild - mkdir -p build/bootloader build/firmware build/intermediate_fw - cp bootloader/bootloader.bin build/bootloader/bootloader.bin - cp intermediate_fw/trezor.bin build/intermediate_fw/inter.bin - cp firmware/trezor.bin build/firmware/firmware.bin - cp firmware/firmware*.bin build/firmware/ || true # ignore missing file as it will not be present in old tags - cp firmware/trezor.elf build/firmware/firmware.elf - poetry run ../python/tools/firmware-fingerprint.py \ - -o build/firmware/firmware.bin.fingerprint \ - build/firmware/firmware.bin - chown -R $USER:$GROUP /build + SCRIPT_NAME=".build_legacy_$BITCOIN_ONLY.sh" + cat < "build/$SCRIPT_NAME" + # DO NOT MODIFY! + # this file was generated by ${BASH_SOURCE[0]} + # variant: legacy build BITCOIN_ONLY=$BITCOIN_ONLY + set -e -o pipefail + cd /reproducible-build/trezor-firmware/legacy + $GIT_CLEAN_REPO + ln -s /build build + poetry run script/cibuild + mkdir -p build/bootloader build/firmware build/intermediate_fw + cp bootloader/bootloader.bin build/bootloader/bootloader.bin + cp intermediate_fw/trezor.bin build/intermediate_fw/inter.bin + cp firmware/trezor.bin build/firmware/firmware.bin + cp firmware/firmware*.bin build/firmware/ || true # ignore missing file as it will not be present in old tags + cp firmware/trezor.elf build/firmware/firmware.elf + poetry run ../python/tools/firmware-fingerprint.py \ + -o build/firmware/firmware.bin.fingerprint \ + build/firmware/firmware.bin + chown -R $USER:$GROUP /build EOF - echo - echo ">>> DOCKER RUN legacy BITCOIN_ONLY=$BITCOIN_ONLY PRODUCTION=$PRODUCTION" - echo + echo + echo ">>> DOCKER RUN legacy BITCOIN_ONLY=$BITCOIN_ONLY PRODUCTION=$PRODUCTION" + echo - $DOCKER run \ - --network=host \ - --rm \ - -v "$DIR:/local" \ - -v "$DIR/build/legacy$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" -done + $DOCKER run \ + --network=host \ + --rm \ + -v "$DIR:/local" \ + -v "$DIR/build/legacy$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" + done +fi echo echo "Docker image retained as $SNAPSHOT_NAME" diff --git a/docs/common/reproducible-build.md b/docs/common/reproducible-build.md index 8db6b09d5d..d1bdc23026 100644 --- a/docs/common/reproducible-build.md +++ b/docs/common/reproducible-build.md @@ -31,21 +31,21 @@ After the build finishes the firmware images are located in: You can speed up the build process by adding options to the script: -* `--skip-core` if you are only building for Trezor One, -* `--skip-legacy --models=A,B,C` to only build for specific model(s) which are not Trezor One. +* `--models=A,B,C` to only build for specific model(s) which are not Trezor One. The following models are supported: -* **`T`** - Trezor Model T -* **`R`** - Trezor Safe 3 rev.A +* **`T1B1`** - Trezor One +* **`T2T1`** - Trezor Model T +* **`T2B1`** - Trezor Safe 3 rev.A * **`T3B1`** - Trezor Safe 3 rev.B * **`T3T1`** - Trezor Safe 5 Examples: ```sh -bash build-docker.sh --skip-core legacy/v1.10.3 # build only for Trezor One -bash build-docker.sh --skip-legacy --models=T3T1 core/v2.8.3 # build only for Trezor Safe 5 +bash build-docker.sh --models=T1B1 legacy/v1.10.3 # build only for Trezor One +bash build-docker.sh --models=T3T1 core/v2.8.3 # build only for Trezor Safe 5 ``` ## Verifying