-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathprepare-devenv
72 lines (59 loc) · 2.42 KB
/
prepare-devenv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# shellcheck disable=SC1091,SC2155
# SOURCE THIS FILE
# . prepare-devenv blue|s|x
if [ $# -ne 1 ]; then
echo "Possible options: blue, s or x"
return
elif [[ $1 == "-h" ]]; then
echo "Possible options: blue, s or x"
return
elif [[ $1 != "blue" ]] && [[ $1 != "s" ]] && [[ $1 != "x" ]]; then
echo "Possible options: blue, s or x"
return
fi
sudo apt install python3-pip python3-venv gcc-multilib g++-multilib libudev-dev libusb-1.0-0-dev libncurses5 -y
pip3 install hidapi==0.7.99.post14
pip3 install ledgerblue --user
sudo cp 20-hw1.rules /etc/udev/rules.d/
if [[ $(cat /etc/udev/rules.d/20-hw1.rules) == *'ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004"'* ]]; then
printf "\nMissing udev rules. Please refer to https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues\n\n"
return
fi
if [ ! -d dev-env ]; then
mkdir dev-env
mkdir dev-env/SDK
mkdir dev-env/CC
mkdir dev-env/CC/others
mkdir dev-env/CC/nanox
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
tar xf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
rm gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
mv gcc-arm-none-eabi-10-2020-q4-major dev-env/CC/others/
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -O clang+llvm.tar.xz
tar xf clang+llvm.tar.xz
rm clang+llvm.tar.xz
mv clang+llvm* dev-env/CC/others/clang-arm-fropi
wget https://github.com/LedgerHQ/nanos-secure-sdk/archive/refs/tags/2.0.0-1.tar.gz -O nanos-secure-sdk.tar.gz
tar xf nanos-secure-sdk.tar.gz
rm nanos-secure-sdk.tar.gz
mv nanos-secure-sdk* dev-env/SDK/nanos-secure-sdk
python3 -m venv dev-env/ledger_py3
source dev-env/ledger_py3/bin/activate
pip install wheel
pip install ledgerblue
fi
source dev-env/ledger_py3/bin/activate
INP=$(pwd)
if [[ $1 == "blue" ]]; then
SDK="export BOLOS_SDK=$INP/dev-env/SDK/blue-secure-sdk"
ENV="export BOLOS_ENV=$INP/dev-env/CC/others"
elif [[ $1 == "s" ]]; then
SDK="export BOLOS_SDK=$INP/dev-env/SDK/nanos-secure-sdk"
ENV="export BOLOS_ENV=$INP/dev-env/CC/others"
elif [[ $1 == "x" ]]; then
SDK="export BOLOS_SDK=$INP/dev-env/SDK/nanox-secure-sdk"
ENV="export BOLOS_ENV=$INP/dev-env/CC/nanox"
fi
echo "$SDK" >> ~/.bashrc
echo "$ENV" >> ~/.bashrc
source ~/.bashrc