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

build: add support for prodtest into build-docker

This commit is contained in:
matejcik 2023-04-14 16:39:43 +02:00
parent fa1925a9d8
commit 3d73ca957c

View File

@ -52,6 +52,7 @@ function help_and_die() {
echo " --skip-normal - do not build regular firmwares" echo " --skip-normal - do not build regular firmwares"
echo " --skip-core - do not build core" echo " --skip-core - do not build core"
echo " --skip-legacy - do not build legacy" echo " --skip-legacy - do not build legacy"
echo " --prodtest - build core prodtest"
echo " --repository path/to/repo - checkout the repository from the given path/url" echo " --repository path/to/repo - checkout the repository from the given path/url"
echo " --no-init - do not recreate docker environments" echo " --no-init - do not recreate docker environments"
echo " --help" echo " --help"
@ -64,6 +65,7 @@ OPT_BUILD_CORE=1
OPT_BUILD_LEGACY=1 OPT_BUILD_LEGACY=1
OPT_BUILD_NORMAL=1 OPT_BUILD_NORMAL=1
OPT_BUILD_BITCOINONLY=1 OPT_BUILD_BITCOINONLY=1
OPT_BUILD_PRODTEST=0
INIT=1 INIT=1
REPOSITORY="/local" REPOSITORY="/local"
@ -89,6 +91,10 @@ while true; do
OPT_BUILD_LEGACY=0 OPT_BUILD_LEGACY=0
shift shift
;; ;;
--prodtest)
OPT_BUILD_PRODTEST=1
shift
;;
--repository) --repository)
REPOSITORY="$2" REPOSITORY="$2"
shift 2 shift 2
@ -333,6 +339,42 @@ EOF
/nix/var/nix/profiles/default/bin/nix-shell --run "bash /local/build/$SCRIPT_NAME" /nix/var/nix/profiles/default/bin/nix-shell --run "bash /local/build/$SCRIPT_NAME"
done done
if [ "$OPT_BUILD_PRODTEST" -eq "1" ]; then
DIRSUFFIX="-prodtest"
SCRIPT_NAME=".build_prodtest.sh"
cat <<EOF > "build/$SCRIPT_NAME"
# DO NOT MODIFY!
# this file was generated by ${BASH_SOURCE[0]}
# variant: core build prodtest
set -e -o pipefail
cd /reproducible-build/trezor-firmware/core
$GIT_CLEAN_REPO
poetry run make clean vendor build_prodtest
poetry run ../python/tools/firmware-fingerprint.py \
-o build/prodtest/prodtest.bin.fingerprint \
build/prodtest/prodtest.bin
rm -rf /build/*
cp -r build/* /build
chown -R $USER:$GROUP /build
EOF
echo
echo ">>> DOCKER RUN core prodtest PRODUCTION=$PRODUCTION"
echo
$DOCKER run \
--network=host \
-it \
--rm \
-v "$DIR:/local" \
-v "$DIR/build/core$DIRSUFFIX":/build:z \
--env PRODUCTION="$PRODUCTION" \
--init \
"$SNAPSHOT_NAME" \
/nix/var/nix/profiles/default/bin/nix-shell --run "bash /local/build/$SCRIPT_NAME"
fi
echo echo
echo "Docker image retained as $SNAPSHOT_NAME" echo "Docker image retained as $SNAPSHOT_NAME"
echo "To remove it, run:" echo "To remove it, run:"
@ -345,19 +387,13 @@ echo "Built from commit $COMMIT_HASH"
echo echo
echo "Fingerprints:" echo "Fingerprints:"
for VARIANT in core legacy; do for VARIANT in core legacy; do
for DIRSUFFIX in "" "-bitcoinonly" "-prodtest"; do
VARIANTS="VARIANTS_$VARIANT[@]" BUILD_DIR=build/${VARIANT}${DIRSUFFIX}
for file in $BUILD_DIR/*/*.fingerprint; do
for BITCOIN_ONLY in ${!VARIANTS}; do if [ -f "$file" ]; then
origfile="${file%.fingerprint}"
DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} fingerprint=$(tr -d '\n' < $file)
DIRSUFFIX=${DIRSUFFIX/0/} echo "$fingerprint $origfile"
for item in bootloader firmware; do
FWPATH=build/${VARIANT}${DIRSUFFIX}/${item}/${item}.bin
if [ -f $FWPATH -a -f "$FWPATH.fingerprint" ]; then
FINGERPRINT=$(tr -d '\n' < $FWPATH.fingerprint)
echo "$FINGERPRINT $FWPATH"
fi fi
done done
done done