1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

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
This commit is contained in:
matejcik 2023-06-12 10:45:49 +02:00
parent d8cd298cd6
commit ddd974b56a

View File

@ -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,16 +259,18 @@ DIR=$(pwd)
# build core
for TREZOR_MODEL in ${MODELS[@]}; do
for BITCOIN_ONLY in ${VARIANTS_core[@]}; do
DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly}
DIRSUFFIX=${DIRSUFFIX/0/}
DIRSUFFIX="-${TREZOR_MODEL}${DIRSUFFIX}"
SCRIPT_NAME=".build_core_$BITCOIN_ONLY.sh"
SCRIPT_NAME=".build_core_${TREZOR_MODEL}_${BITCOIN_ONLY}.sh"
cat <<EOF > "build/$SCRIPT_NAME"
# DO NOT MODIFY!
# this file was generated by ${BASH_SOURCE[0]}
# variant: core build BITCOIN_ONLY=$BITCOIN_ONLY
# variant: core build BITCOIN_ONLY=$BITCOIN_ONLY TREZOR_MODEL=$TREZOR_MODEL
set -e -o pipefail
cd /reproducible-build/trezor-firmware/core
$GIT_CLEAN_REPO
@ -277,7 +286,7 @@ for BITCOIN_ONLY in ${VARIANTS_core[@]}; do
EOF
echo
echo ">>> DOCKER RUN core BITCOIN_ONLY=$BITCOIN_ONLY PRODUCTION=$PRODUCTION"
echo ">>> DOCKER RUN core BITCOIN_ONLY=$BITCOIN_ONLY TREZOR_MODEL=$TREZOR_MODEL PRODUCTION=$PRODUCTION"
echo
$DOCKER run \
@ -287,11 +296,13 @@ EOF
-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,8 +398,9 @@ echo "Built from commit $COMMIT_HASH"
echo
echo "Fingerprints:"
for VARIANT in core legacy; do
for MODEL in "R" "T"; do
for DIRSUFFIX in "" "-bitcoinonly" "-prodtest"; do
BUILD_DIR=build/${VARIANT}${DIRSUFFIX}
BUILD_DIR=build/${VARIANT}-${MODEL}${DIRSUFFIX}
for file in $BUILD_DIR/*/*.fingerprint; do
if [ -f "$file" ]; then
origfile="${file%.fingerprint}"
@ -398,3 +410,4 @@ for VARIANT in core legacy; do
done
done
done
done