This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
preinstall.sh
executable file
·63 lines (51 loc) · 1.89 KB
/
preinstall.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
#!/bin/bash
# shellcheck disable=SC2155
# lib-ledger-core-react-native-bindings
# =====================================
# Preinstall script
#
LIB_CORE_VERSION="4.2.0-rc-415179"
BASE_URL="https://s3-eu-west-1.amazonaws.com/ledger-lib-ledger-core"
function main() {
# lib file architecture destination arch override
# ---------------------------------------------------------------------------------------------
dl "libledger-core.so" "android/x86" "android/libs"
dl "libledger-core.so" "android/x86_64" "android/libs"
dl "libledger-core.so" "android/armeabi-v7a" "android/libs"
dl "libledger-core.so" "android/arm64-v8a" "android/libs"
if [[ $(uname) == "Darwin" ]]; then
dl "ledger-core.framework/ledger-core" "ios/universal" "ios/Frameworks"
dl "ledger-core.framework/Info.plist" "ios/universal" "ios/Frameworks"
fi
}
function dl() {
local libFile=$1
local fullArchitecture=$2
local architecture=$(echo "$fullArchitecture" | sed 's/.*\///g')
local destination="$3"
local archOverride="$4"
if [[ $archOverride != "" ]]; then
architecture=$archOverride
fi
local url="$BASE_URL/$LIB_CORE_VERSION/$fullArchitecture/$libFile"
local outputFolder="$destination/$architecture"
mkdir -p "$outputFolder"
if [[ "$fullArchitecture" =~ "ios" ]]; then
mkdir -p "$outputFolder/ledger-core.framework"
fi
local outputFile="$outputFolder/$libFile"
echo -e "\\e[32m>> \\e[34m$fullArchitecture\\e[0m - \\e[35m$url\\e[0m"
if ! curl \
--fail \
--max-time 600 \
--output "$outputFile" \
"$url"; \
then
echo "[x] Failed to download $url"
exit 1
fi
if [[ ! "$outputFile" =~ Info.plist ]]; then
chmod +x "$outputFile"
fi
}
main