Skip to content

Commit

Permalink
feat: download and update node bridge from Suite dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
grdddj committed Oct 1, 2024
1 parent a39680f commit 43598b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/binaries/firmware/bin/*
!src/binaries/firmware/bin/patch-bin.sh
!src/binaries/firmware/bin/arm
!src/binaries/trezord-go/bin/download.sh
src/binaries/node-bridge/bin.js
emulator.img
.vscode
.mypy_cache
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile-debian
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ 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
RUN ./src/binaries/node-bridge/download.sh
# Patch emulator binaries
RUN cd src/binaries/firmware/bin && ./patch-bin.sh

Expand Down
14 changes: 14 additions & 0 deletions src/binaries/node-bridge/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e

HERE=$(dirname $(readlink -f $0))

FILE_NAME="bin.js"
FILE_LOCATION="$HERE/$FILE_NAME"
# BRANCH="develop"
BRANCH="grdddj/ci_node_bridge_build"
URL="https://dev.suite.sldev.cz/transport-bridge/$BRANCH/dist/$FILE_NAME"

# Downloading and modifying node bridge bin.js file
nix-shell --run "curl -L $URL -o $FILE_LOCATION" || echo "Failed to download $FILE_NAME"
nix-shell --run "$HERE/modify_node_bin_js.sh $FILE_LOCATION" || echo "Failed to modify $FILE_NAME"
21 changes: 21 additions & 0 deletions src/binaries/node-bridge/modify_node_bin_js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Please supply the path to the file to modify"
exit 1
fi

if [ ! -f "$1" ]; then
echo "Error: File '$1' not found."
exit 1
fi

# Getting rid of USB import, which is not needed when we will spawn in with UDP argument
string_to_comment='^var import_usb ='
if grep -q "$string_to_comment" "$1"; then
sed -i "/$string_to_comment/ s/^/\/\//" "$1"
echo "Success: line matching '$string_to_comment' was commented out."
else
echo "Error: no line matching '$string_to_comment' found in '$1'."
exit 1
fi

0 comments on commit 43598b5

Please sign in to comment.