-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_linux.sh
More file actions
126 lines (111 loc) · 4.4 KB
/
setup_linux.sh
File metadata and controls
126 lines (111 loc) · 4.4 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# This sets up an EVT Development Environment from scratch for a Linux System.
bold=$(tput bold)
normal=$(tput sgr0)
echo "========================================================="
echo "${bold}This script will set up all of the required packages and environment vairables that are used by an RIT-EVT Firmware developer.${normal}"
echo "1. This script will create an EVT directory for you."
echo "2. The ARM GNU Toolchain will be installed. Either the aarch64 or amd64 version depending on your system."
echo "3. EVT's custom variable (GCC_ARM_TOOLS_PATH) will be added to your path."
echo "4. cmake will be installed if it is not available using your default package manager."
echo "========================================================="
echo ""
echo "${bold}Creating a default directory ~/.EVT${normal}"
arch=$(uname -m)
install_dir=~/.EVT
mkdir -p $install_dir
mkdir -p $install_dir/arm_tools
if [[ $arch == "aarch64" ]]; then
# We are on an ARM device
gcc_tools_download_link="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi.tar.xz"
else
# We are on an x86_64 Device
gcc_tools_download_link="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi.tar.xz"
fi
if ! -d "$install_dir/arm_tools/bin"; then
echo "${bold}Installing ARM toolchain${normal}"
installed=0
if command -v curl >/dev/null 2>&1; then
# Curl is installed
curl -o arm_tools.tar.xz $gcc_tools_download_link
tar -xvf arm_tools.tar.xz -C $install_dir/arm_tools --strip-components 1
rm arm_tools.tar.xz
installed=1
fi
if ! installed; then
if command -v wget >/dev/null 2>&1; then
# Wget is installed
wget -O arm_tools.tar.xz $gcc_tools_download_link
tar -xvf arm_tools.tar.xz -C $install_dir/arm_tools --strip-components 1
rm arm_tools.tar.xz
installed=1
fi
fi
if $installed -eq 0; then
echo "Error: Neither curl nor wget is installed. Please install one of them."
exit 1
fi
echo "${bold}Setting GCC_ARM_TOOLS_PATH${normal}"
if $SHELL = "/bin/zsh"; then
echo "You may receieve a warning on the next command, that is expected and okay."
echo 'export GCC_ARM_TOOLS_PATH="${HOME}/.EVT/arm_tools/bin"' >> ~/.zshrc
source ~/.zshrc
elif $SHELL == "/bin/bash" ; then
echo 'export GCC_ARM_TOOLS_PATH="${HOME}/.EVT/arm_tools/bin"' >> ~/.bash_profile
echo 'export GCC_ARM_TOOLS_PATH="${HOME}/.EVT/arm_tools/bin"' >> ~/.bashrc
source ~/.bash_profile
elif $SHELL == "/bin/fish"; then
echo 'set -gx GCC_ARM_TOOLS_PATH ${HOME}.EVT/arm_tools/bin' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fish
else
echo 'Shell, not recognized. Please add export GCC_ARM_TOOLS_PATH="~/.EVT/arm_tools/bin to your shell config file.'
fi
else
echo "${bold}ARM toolchain already installed${normal}"
fi
echo "${bold}Installing CMAKE${normal}"
if ! command -v cmake >/dev/null 2>&1; then
if command -v apt >/dev/null 2>&1; then
echo "Installing using apt..."
if [[ $EUID -ne 0 ]]; then
sudo apt install cmake
else
apt install cmake
fi
elif command -v pacman >/dev/null 2>&1; then
echo "Installing using pacman..."
if [[ $EUID -ne 0 ]]; then
sudo pacman -Syu cmake
else
pacman -Syu cmake
fi
else
echo "Could not identify the package manager. Please manually install CMAKE."
exit 0
fi
else
echo "cmake has been detected as already installed."
fi
if ! command -v clang-format --version >/dev/null 2>&1; then
if command -v apt >/dev/null 2>&1; then
echo "Installing using apt..."
if $EUID -ne 0; then
sudo apt install clang-format
else
apt install clang-format
fi
elif command -v pacman >/dev/null 2>&1; then
echo "Installing using pacman..."
if $EUID -ne 0; then
sudo pacman -Syu clang
else
pacman -Syu clang
fi
else
echo "Could not identify the package manager. Please manually install LLVM / Clang Tools."
exit 0
fi
else
echo "clang-format has been detected as already installed."
fi
echo "${bold}Finished installing an EVT environment to your computer.${normal}"