-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_dependencies.sh
More file actions
86 lines (76 loc) · 2.48 KB
/
install_dependencies.sh
File metadata and controls
86 lines (76 loc) · 2.48 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
#!/bin/bash
# Exit on any error
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Function to print error and exit
error_exit() {
echo -e "${RED}Error: $1${NC}" >&2
exit 1
}
# Function to print success message
success() {
echo -e "${GREEN}$1${NC}"
}
# Check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Detect OS
OS="unknown"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
if command_exists apt-get; then
PKG_MANAGER="apt"
elif command_exists yum; then
PKG_MANAGER="yum"
elif command_exists dnf; then
PKG_MANAGER="dnf"
else
error_exit "No supported package manager found (apt, yum, dnf)."
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
if ! command_exists brew; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
PKG_MANAGER="brew"
else
error_exit "Unsupported OS: $OSTYPE"
fi
# Update package manager
echo "Updating package manager..."
if [ "$PKG_MANAGER" == "apt" ]; then
sudo apt-get update -y || error_exit "Failed to update apt."
elif [ "$PKG_MANAGER" == "yum" ]; then
sudo yum update -y || error_exit "Failed to update yum."
elif [ "$PKG_MANAGER" == "dnf" ]; then
sudo dnf update -y || error_exit "Failed to update dnf."
elif [ "$PKG_MANAGER" == "brew" ]; then
brew update || error_exit "Failed to update Homebrew."
fi
success "Package manager updated."
# List of dependencies to install
DEPENDENCIES=("cmake" "libwayland-dev" "libasound2-dev" "libx11-xcb-dev" "libvulkan-dev" "vulkan-tools" "vulkan-validationlayers")
# Check and install dependencies
for dep in "${DEPENDENCIES[@]}"; do
if ! command_exists "$dep"; then
echo "Installing $dep..."
if [ "$PKG_MANAGER" == "apt" ]; then
sudo apt-get install -y "$dep" || error_exit "Failed to install $dep."
elif [ "$PKG_MANAGER" == "yum" ]; then
sudo yum install -y "$dep" || error_exit "Failed to install $dep."
elif [ "$PKG_MANAGER" == "dnf" ]; then
sudo dnf install -y "$dep" || error_exit "Failed to install $dep."
elif [ "$PKG_MANAGER" == "brew" ]; then
brew install "$dep" || error_exit "Failed to install $dep."
fi
success "$dep installed."
else
success "$dep is already installed."
fi
done
success "All dependencies installed successfully!"