-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change docker configuration to native setup without nix-shell a…
…nd download latest arm builds from data.trezor.io
- Loading branch information
1 parent
5323c4d
commit 84d503a
Showing
9 changed files
with
131 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Start with a base Debian image | ||
FROM debian:bookworm-slim | ||
|
||
# Set environment variables | ||
ENV TERM=xterm \ | ||
XDG_RUNTIME_DIR="/var/tmp" \ | ||
LC_ALL=C.UTF-8 \ | ||
LANG=C.UTF-8 \ | ||
GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt \ | ||
NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
# Install required packages | ||
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash - | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
openssl \ | ||
bash \ | ||
git \ | ||
nodejs \ | ||
python3 \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-venv \ | ||
python3-poetry \ | ||
libsdl2-2.0-0 \ | ||
libsdl2-image-2.0-0 \ | ||
x11-xserver-utils \ | ||
wget \ | ||
unzip \ | ||
curl \ | ||
procps \ | ||
build-essential \ | ||
g++ \ | ||
libc6 \ | ||
libc6-dev \ | ||
patchelf \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# Add basic trezor-user-env files | ||
COPY ./ /trezor-user-env | ||
WORKDIR /trezor-user-env | ||
|
||
# Install Python dependencies using poetry | ||
RUN poetry cache clear --all pypi | ||
RUN poetry install --no-dev --no-root | ||
|
||
# Execute scripts and clean up | ||
RUN ./src/binaries/firmware/bin/download.sh | ||
RUN ./src/binaries/trezord-go/bin/download.sh | ||
# Patch emulator binaries | ||
RUN cd src/binaries/firmware/bin && ./patch-bin.sh | ||
|
||
# Command to run on container start | ||
CMD poetry run python src/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
version: '3' | ||
services: | ||
trezor-user-env-unix: | ||
container_name: trezor-user-env.unix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ stdenv.mkDerivation { | |
xorg.xhost | ||
wget | ||
git | ||
unzip | ||
curl | ||
procps | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
INTERPRETER_X86_64="/lib64/ld-linux-x86-64.so.2" | ||
INTERPRETER_ARM64="/lib/ld-linux-aarch64.so.1" | ||
BINARY_DIR="./" | ||
|
||
get_interpreter() { | ||
local arch="$1" | ||
case "$arch" in | ||
"Advanced Micro Devices X86-64") | ||
echo "$INTERPRETER_X86_64" | ||
;; | ||
"AArch64") | ||
echo "$INTERPRETER_ARM64" | ||
;; | ||
*) | ||
echo "Unknown architecture: $arch" | ||
return 1 | ||
;; | ||
esac | ||
} | ||
|
||
change_interpreter() { | ||
local binary="$1" | ||
local arch current_interpreter new_interpreter | ||
|
||
if ! readelf -h "$binary" &>/dev/null; then | ||
echo "Skipping $binary: Not an ELF file." | ||
return | ||
fi | ||
|
||
arch=$(readelf -h "$binary" | grep 'Machine:' | awk '{print $2}') | ||
echo "Detected architecture for $binary: $arch" | ||
|
||
new_interpreter=$(get_interpreter "$arch") | ||
|
||
if [[ $? -ne 0 || -z "$new_interpreter" ]]; then | ||
echo "Skipping $binary: Unsupported or unknown architecture." | ||
return | ||
fi | ||
|
||
current_interpreter=$(patchelf --print-interpreter "$binary" 2>/dev/null) | ||
echo "Current interpreter for $binary: $current_interpreter" | ||
|
||
if [[ $? -eq 0 && "$current_interpreter" != "$new_interpreter" ]]; then | ||
echo "Patching $binary (arch: $arch, old: $current_interpreter, new: $new_interpreter)" | ||
patchelf --set-interpreter "$new_interpreter" "$binary" | ||
else | ||
echo "No need to patch $binary." | ||
fi | ||
} | ||
|
||
export -f change_interpreter | ||
export -f get_interpreter | ||
export INTERPRETER_X86_64 | ||
export INTERPRETER_ARM64 | ||
|
||
find "$BINARY_DIR" -type f -executable -exec bash -c 'change_interpreter "$0"' {} \; | ||
|
||
echo "All binaries patched." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters