-
Notifications
You must be signed in to change notification settings - Fork 74
/
install_dependencies.sh
executable file
·141 lines (124 loc) · 3.15 KB
/
install_dependencies.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2024 Tenstorrent, Inc. All rights reserved.
#
# This script is based on `xrtdeps.sh` from the Xilinx XRT project.
# Original source: https://github.com/Xilinx/XRT/blob/master/src/runtime_src/tools/scripts/xrtdeps.sh
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FLAVOR=`grep '^ID=' /etc/os-release | awk -F= '{print $2}' | tr -d '"'`
VERSION=`grep '^VERSION_ID=' /etc/os-release | awk -F= '{print $2}' | tr -d '"'`
MAJOR=${VERSION%.*}
ARCH=`uname -m`
usage()
{
echo "Usage: sudo ./install_dependencies.sh [options]"
echo
echo "[--help, -h] List this help"
echo "[--validate, -v] Validate that required packages are installed"
exit 1
}
validate=0
while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage
;;
--validate|-v)
validate=1
shift
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
ub_package_list()
{
UB_LIST=(\
git \
git-lfs \
build-essential \
cmake \
software-properties-common \
libhwloc-dev \
graphviz \
ninja-build \
libpython3-dev \
libcapstone-dev \
python3-pip \
python3-dev \
python3.8-venv \
libc++-17-dev \
libc++abi-17-dev \
)
}
update_package_list()
{
if [ $FLAVOR == "ubuntu" ]; then
ub_package_list
else
echo "unknown OS flavor $FLAVOR"
exit 1
fi
}
validate_packages()
{
if [ $FLAVOR == "ubuntu" ]; then
dpkg -l "${UB_LIST[@]}"
#dpkg -l "${UB_LIST[@]}" > /dev/null
else
echo "unknown OS flavor $FLAVOR"
exit 1
fi
}
prep_ubuntu()
{
echo "Preparing ubuntu ..."
# Update the list of available packages
apt-get update
}
install_llvm() {
LLVM_VERSION="17"
echo "Checking if LLVM $LLVM_VERSION is already installed..."
if command -v clang-$LLVM_VERSION &> /dev/null; then
echo "LLVM $LLVM_VERSION is already installed. Skipping installation."
else
echo "Installing LLVM $LLVM_VERSION..."
TEMP_DIR=$(mktemp -d)
wget -P $TEMP_DIR https://apt.llvm.org/llvm.sh
chmod u+x $TEMP_DIR/llvm.sh
$TEMP_DIR/llvm.sh $LLVM_VERSION
rm -rf "$TEMP_DIR"
fi
}
install()
{
if [ $FLAVOR == "ubuntu" ]; then
prep_ubuntu
echo "Installing packages..."
apt-get install -y "${UB_LIST[@]}"
fi
}
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root. Please use sudo."
usage
fi
install_llvm
update_package_list
if [ $validate == 1 ]; then
validate_packages
else
install
fi