-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathinstall_build_deps.sh
More file actions
executable file
·62 lines (49 loc) · 1.76 KB
/
install_build_deps.sh
File metadata and controls
executable file
·62 lines (49 loc) · 1.76 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
#!/bin/bash
set -euo pipefail
# Functions
error() {
echo "Error: $*" >&2
exit 1
}
info() {
echo "[INFO] $*"
}
require_command() {
command -v "$1" >/dev/null 2>&1 || error "Required command '$1' not found. Please install it."
}
run_as_root() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
else
sudo "$@"
fi
}
# Check for required commands
for cmd in tee dpkg apt-get; do
require_command "$cmd"
done
# Check for permission to run apt-get update/install
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
if ! sudo -n true 2>/dev/null; then
error "This script requires permission to run 'apt-get update/install'. Please run as root or ensure you have passwordless sudo access."
fi
SUDO="sudo"
else
error "This script requires root or sudo privileges to run 'apt-get update/install'."
fi
export DEBIAN_FRONTEND=noninteractive
info "Updating package lists and installing gpg..."
$SUDO apt-get update -y
$SUDO apt-get install -y gpg
info "Adding Intel SGX package repository key..."
cat intel-sgx-deb.key | gpg --dearmor | $SUDO tee /usr/share/keyrings/intel-sgx-deb.gpg > /dev/null
info "Adding Intel SGX repository to sources.list.d..."
ARCH=$(dpkg --print-architecture)
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/intel-sgx-deb.gpg] https://download.01.org/intel-sgx/sgx_repo/ubuntu noble main" | $SUDO tee /etc/apt/sources.list.d/intel-sgx-deb.list > /dev/null
info "Updating package lists..."
$SUDO apt-get update -y
info "Installing build dependencies: faketime protobuf-compiler libsgx-dcap-ql-dev clang-18 musl-tools gcc-multilib"
$SUDO apt-get install -y faketime protobuf-compiler libsgx-dcap-ql-dev clang-18 musl-tools gcc-multilib
info "All dependencies installed successfully."