forked from khadas/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
executable file
·62 lines (49 loc) · 1.9 KB
/
INSTALL
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
#!/bin/bash
set -e -o pipefail
BASE=$(dirname "$(readlink -fm "$0")")
AML_FLASH_TOOL_DIR="$BASE/aml-flash-tool"
RK_FLASH_TOOL_DIR="$BASE/rk-flash-tool"
TB_FLASH_TOOL_DIR="$BASE/tone-dfu-tool"
AML_BURN_TOOL="$AML_FLASH_TOOL_DIR/aml-burn-tool"
RK_BURN_TOOL="$RK_FLASH_TOOL_DIR/rk-burn-tool"
TB_BURN_TOOL="$TB_FLASH_TOOL_DIR/tone-burn-tool"
KHADAS_BURN_TOOL="$BASE/burn-tool"
INSTALL_DIR="/usr/local/bin"
DISTRIB=$(cat /etc/lsb-release | grep "DISTRIB_ID" | awk -F "=" '{print $2}')
DISTRIB_RELEASE=$(cat /etc/lsb-release | grep "DISTRIB_RELEASE" | awk -F "=" '{print $2}')
RED='\033[0;31m'
RESET='\033[m'
error_msg() {
echo -e ${RED}Error:${RESET} $1
}
prepare_host() {
local hostdeps="libusb-dev git parted lib32z1 lib32stdc++6 libusb-0.1-4 libusb-1.0-0-dev libusb-1.0-0 ccache libncurses5 pv base-files linux-base"
local deps=()
local installed=$(dpkg-query -W -f '${db:Status-Abbrev}|${binary:Package}\n' '*' 2>/dev/null | grep '^ii' | awk -F '|' '{print $2}' | cut -d ':' -f 1)
if [[ "$DISTRIB" == "Ubuntu" ]] && [[ "$DISTRIB_RELEASE" == "18.10" || "$DISTRIB_RELEASE" =~ "20" || "$DISTRIB_RELEASE" =~ "21" ]]; then
hostdeps="$hostdeps lib32ncurses6"
else
hostdeps="$hostdeps lib32ncurses5"
fi
for packet in $hostdeps; do
if ! grep -q -x -e "$packet" <<< "$installed"; then deps+=("$packet"); fi
done
if [[ ${#deps[@]} -gt 0 ]]; then
echo "Installing dependencies"
echo "Requires root privileges, please enter your passowrd!"
sudo apt update
sudo apt -y --no-install-recommends install "${deps[@]}"
sudo update-ccache-symlinks
fi
}
prepare_host
echo -e "Installing Amlogic flash-tool..."
$AML_FLASH_TOOL_DIR/INSTALL
echo -e "\nInstalling Rockchip flash-tool..."
$RK_FLASH_TOOL_DIR/INSTALL
echo -e "\nInstalling Tone burn-tool..."
$TB_FLASH_TOOL_DIR/INSTALL
echo -e "Installing Khadas burn-tool..."
mkdir -p $INSTALL_DIR
sudo ln -fs $KHADAS_BURN_TOOL $INSTALL_DIR/$(basename $KHADAS_BURN_TOOL)
echo "Done!"