2019-09-12 13:42:04 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-09-08 15:16:53 +00:00
|
|
|
set -e
|
|
|
|
|
2020-06-07 19:49:06 +00:00
|
|
|
CONTAINER_NAME=trezor-firmware-env.nix
|
2019-09-08 15:16:53 +00:00
|
|
|
|
|
|
|
TAG=${1:-master}
|
|
|
|
REPOSITORY=${2:-local}
|
|
|
|
PRODUCTION=${PRODUCTION:-1}
|
|
|
|
MEMORY_PROTECT=${MEMORY_PROTECT:-1}
|
|
|
|
|
|
|
|
if [ "$REPOSITORY" = "local" ]; then
|
|
|
|
REPOSITORY=file:///local/
|
|
|
|
else
|
|
|
|
REPOSITORY=https://github.com/$REPOSITORY/trezor-firmware.git
|
|
|
|
fi
|
|
|
|
|
2020-06-07 10:01:42 +00:00
|
|
|
wget -nc -P ci/ http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-minirootfs-3.12.0-x86_64.tar.gz
|
2020-06-07 12:11:03 +00:00
|
|
|
docker build -t "$CONTAINER_NAME" ci/
|
2019-09-08 15:16:53 +00:00
|
|
|
|
|
|
|
USER=$(ls -lnd . | awk '{ print $3 }')
|
|
|
|
GROUP=$(ls -lnd . | awk '{ print $4 }')
|
|
|
|
|
|
|
|
mkdir -p $(pwd)/build/core $(pwd)/build/legacy
|
|
|
|
mkdir -p $(pwd)/build/core-bitcoinonly $(pwd)/build/legacy-bitcoinonly
|
|
|
|
|
|
|
|
# build core
|
|
|
|
|
|
|
|
for BITCOIN_ONLY in 0 1; do
|
|
|
|
|
|
|
|
DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly}
|
|
|
|
DIRSUFFIX=${DIRSUFFIX/0/}
|
|
|
|
|
2019-12-11 13:20:31 +00:00
|
|
|
docker run -it --rm \
|
2019-09-08 15:16:53 +00:00
|
|
|
-v $(pwd):/local \
|
|
|
|
-v $(pwd)/build/core"${DIRSUFFIX}":/build:z \
|
|
|
|
--env BITCOIN_ONLY="$BITCOIN_ONLY" \
|
|
|
|
--env PRODUCTION="$PRODUCTION" \
|
2020-06-07 12:11:03 +00:00
|
|
|
"$CONTAINER_NAME" \
|
2020-05-03 17:00:57 +00:00
|
|
|
/nix/var/nix/profiles/default/bin/nix-shell --run "\
|
2019-09-08 15:16:53 +00:00
|
|
|
cd /tmp && \
|
|
|
|
git clone $REPOSITORY trezor-firmware && \
|
|
|
|
cd trezor-firmware/core && \
|
|
|
|
ln -s /build build &&
|
|
|
|
git checkout $TAG && \
|
|
|
|
git submodule update --init --recursive && \
|
|
|
|
pipenv install && \
|
2020-06-03 21:45:53 +00:00
|
|
|
pipenv run make clean vendor build_firmware && \
|
|
|
|
chown -R $USER:$GROUP /build"
|
2019-09-08 15:16:53 +00:00
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
# build legacy
|
|
|
|
|
|
|
|
for BITCOIN_ONLY in 0 1; do
|
|
|
|
|
|
|
|
DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly}
|
|
|
|
DIRSUFFIX=${DIRSUFFIX/0/}
|
|
|
|
|
2019-12-11 13:20:31 +00:00
|
|
|
docker run -it --rm \
|
2019-09-08 15:16:53 +00:00
|
|
|
-v $(pwd):/local \
|
|
|
|
-v $(pwd)/build/legacy"${DIRSUFFIX}":/build:z \
|
|
|
|
--env BITCOIN_ONLY="$BITCOIN_ONLY" \
|
|
|
|
--env MEMORY_PROTECT="$MEMORY_PROTECT" \
|
2020-06-07 12:11:03 +00:00
|
|
|
"$CONTAINER_NAME" \
|
2020-05-03 17:00:57 +00:00
|
|
|
/nix/var/nix/profiles/default/bin/nix-shell --run "\
|
2019-09-08 15:16:53 +00:00
|
|
|
cd /tmp && \
|
|
|
|
git clone $REPOSITORY trezor-firmware && \
|
|
|
|
cd trezor-firmware/legacy && \
|
|
|
|
ln -s /build build &&
|
|
|
|
git checkout $TAG && \
|
|
|
|
git submodule update --init --recursive && \
|
|
|
|
pipenv install && \
|
|
|
|
pipenv run script/cibuild && \
|
|
|
|
mkdir -p build/firmware && \
|
|
|
|
cp firmware/trezor.bin build/firmware/firmware.bin && \
|
2020-06-03 21:45:53 +00:00
|
|
|
cp firmware/trezor.elf build/firmware/firmware.elf && \
|
|
|
|
chown -R $USER:$GROUP /build"
|
2019-09-08 15:16:53 +00:00
|
|
|
|
|
|
|
done
|