This repository has been archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions
executable file
·75 lines (62 loc) · 1.67 KB
/
functions
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
#!/bin/bash
# Copyright (c) 2017 The Open-Transactions developers
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
clean_directories() {
local LOCAL_BUILD_DIR="${1}"
local LOCAL_SOURCE_DIR="${2}"
local ARCHIVE_FILE="${3}"
if [ -e "${LOCAL_BUILD_DIR}" ] ; then
cd "${LOCAL_BUILD_DIR}" &&
make uninstall
rm -rf "${LOCAL_BUILD_DIR}"
fi
if [ -e "${LOCAL_SOURCE_DIR}" ] ; then
rm -rf "${LOCAL_SOURCE_DIR}"
fi
if [ -e "${ARCHIVE_FILE}" ] ; then
rm -rf "${ARCHIVE_FILE}"
fi
}
create_directories() {
local LOCAL_BUILD_DIR="${1}"
local LOCAL_SOURCE_DIR="${2}"
local FINAL_OUTPUT_DIR_LIB_OT="${3}"
if [ -n "${LOCAL_SOURCE_DIR}" ] ; then
mkdir -p "${LOCAL_SOURCE_DIR}"
fi
if [ -n "${LOCAL_BUILD_DIR}" ] ; then
mkdir -p "${LOCAL_BUILD_DIR}"
fi
if [ -n "${FINAL_OUTPUT_DIR_LIB_OT}" ] ; then
mkdir -p "${FINAL_OUTPUT_DIR_LIB_OT}"
fi
}
wget_source() {
local ARCHIVE_FILE="${1}"
local WGET_URL="${2}"
local LOCAL_SOURCE_DIR="${3}"
wget --output-document="${ARCHIVE_FILE}" "${WGET_URL}"
tar -xzvf "${ARCHIVE_FILE}" -C "${LOCAL_SOURCE_DIR}" --strip-components=1
}
git_clone_source() {
local VERSION="${1}"
local GIT_URL="${2}"
local LOCAL_SOURCE_DIR="${3}"
cd "${HOME}"
git clone --branch "${VERSION}" "${GIT_URL}" "${LOCAL_SOURCE_DIR}"
git -C "${LOCAL_SOURCE_DIR}" submodule init
git -C "${LOCAL_SOURCE_DIR}" submodule update
}
check_arch() {
case "${1}" in
"arm")
export OT_ARCH="armv7a";;
"x86")
export OT_ARCH="x86";;
*)
echo "Unknown architecture"
exit 1;;
esac
}