-
Notifications
You must be signed in to change notification settings - Fork 21
/
prepare-devenv.sh
87 lines (69 loc) · 3.07 KB
/
prepare-devenv.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# 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
export NANO_MODEL="nano$1"
if [[ $(dpkg-query -s python3-venv 2>&1) == *'is not installed'* ]]; then
printf "\nPackage python3-venv is missing.\nOn Debian-like distros, run:\n\napt install python3-venv\n\n"
return
fi
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/SDK ] ; then
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
cp -r gcc-arm-none-eabi-10-2020-q4-major dev-env/CC/nanox/
mv gcc-arm-none-eabi-10-2020-q4-major dev-env/CC/others/
wget http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.10.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 http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.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/nanox/clang-arm-fropi
wget https://github.com/LedgerHQ/blue-secure-sdk/archive/blue-r21.1.tar.gz -O blue-secure-sdk.tar.gz
tar xf blue-secure-sdk.tar.gz
rm blue-secure-sdk.tar.gz
mv blue-secure-sdk* dev-env/SDK/blue-secure-sdk
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
wget https://github.com/LedgerHQ/nanox-secure-sdk/archive/1.2.4-5.1.tar.gz -O nanox-secure-sdk.tar.gz
tar xf nanox-secure-sdk.tar.gz
rm nanox-secure-sdk.tar.gz
mv nanox-secure-sdk* dev-env/SDK/nanox-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
if [[ $1 == "blue" ]]; then
export BOLOS_SDK=$(pwd)/dev-env/SDK/blue-secure-sdk
export BOLOS_ENV=$(pwd)/dev-env/CC/others
elif [[ $1 == "s" ]]; then
export BOLOS_SDK=$(pwd)/dev-env/SDK/nanos-secure-sdk
export BOLOS_ENV=$(pwd)/dev-env/CC/others
elif [[ $1 == "x" ]]; then
export BOLOS_SDK=$(pwd)/dev-env/SDK/nanox-secure-sdk
export BOLOS_ENV=$(pwd)/dev-env/CC/nanox
fi
export PS1="$(echo $PS1 | sed 's/ledger_py3/ledger_py3, ${NANO_MODEL}/g') "