Skip to content

Commit c5fa3c9

Browse files
committed
Add source of truth for OS dependencies
1 parent 3cf42fb commit c5fa3c9

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

install_deps.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
fail() {
6+
echo "Error: $1" 1>&2
7+
exit 1
8+
}
9+
10+
# Check for --no-cpu-gov flag
11+
NO_CPU_GOV=0
12+
if [ "$1" = "--no-cpu-gov" ]; then
13+
NO_CPU_GOV=1
14+
fi
15+
16+
# Detect distro and set commands
17+
if [ -f /etc/debian_version ]; then
18+
DISTRO=debian
19+
PKG_FILE="packages-debian.txt"
20+
elif [ -f /etc/arch-release ]; then
21+
DISTRO=arch
22+
PKG_FILE="packages-arch.txt"
23+
else
24+
fail "Unsupported or unrecognized Linux distribution."
25+
fi
26+
27+
# Check for package file
28+
if [ ! -f "$PKG_FILE" ]; then
29+
fail "Package list file '$PKG_FILE' not found."
30+
fi
31+
32+
echo "Detected Linux distribution: $DISTRO"
33+
echo "Checking for missing packages..."
34+
35+
# Read package list
36+
PKGS=""
37+
for pkg in $(grep -v '^[[:space:]]*#' "$PKG_FILE" | grep -v '^[[:space:]]*$'); do
38+
PKGS="$PKGS $pkg"
39+
done
40+
41+
MISSING_PKGS=""
42+
for pkg in $PKGS; do
43+
if [ "$DISTRO" = "debian" ]; then
44+
if ! dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then
45+
MISSING_PKGS="$MISSING_PKGS $pkg"
46+
fi
47+
elif [ "$DISTRO" = "arch" ]; then
48+
if ! pacman -Q "$pkg" >/dev/null 2>&1; then
49+
MISSING_PKGS="$MISSING_PKGS $pkg"
50+
fi
51+
fi
52+
done
53+
54+
if [ -z "$MISSING_PKGS" ]; then
55+
echo "All listed packages are already installed."
56+
else
57+
echo "The following packages are missing and will be installed:"
58+
for pkg in $MISSING_PKGS; do
59+
echo " $pkg"
60+
done
61+
echo
62+
63+
# Install missing packages
64+
if [ "$DISTRO" = "debian" ]; then
65+
sudo apt-get update
66+
echo "$MISSING_PKGS" | xargs sudo apt-get install -y
67+
elif [ "$DISTRO" = "arch" ]; then
68+
sudo pacman -Sy --needed --noconfirm $MISSING_PKGS
69+
fi
70+
fi
71+
72+
echo "System dependencies installed successfully."
73+
74+
# CPU frequency governor logic
75+
if [ "$NO_CPU_GOV" -eq 0 ] && [ -d /sys/devices/system/cpu ]; then
76+
echo "Do you want to set the CPU frequency governor to 'performance'? [y/N]"
77+
printf "> "
78+
read ans
79+
case "$ans" in
80+
y|Y|yes|YES)
81+
echo "Setting CPU frequency governor to performance..."
82+
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
83+
if [ -f "$cpu" ]; then
84+
echo "performance" | sudo tee "$cpu" >/dev/null
85+
fi
86+
done
87+
echo "CPU governor set to performance."
88+
;;
89+
*)
90+
echo "Skipping CPU governor change."
91+
;;
92+
esac
93+
else
94+
echo "Skipping CPU governor change."
95+
fi
96+
97+
# Install rustup and Rust nightly
98+
if ! command -v rustup >/dev/null 2>&1; then
99+
echo "rustup not found. Installing rustup..."
100+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
101+
sh -s -- --profile minimal --default-toolchain nightly -y
102+
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
103+
else
104+
echo "rustup already installed."
105+
fi
106+
107+
echo "Installing and setting Rust nightly as default..."
108+
rustup toolchain install nightly
109+
rustup default nightly
110+
111+
echo "Rust nightly installed and set as default."
112+
echo "All dependencies installed successfully."
113+
114+
echo
115+
echo "===================================================================="
116+
echo "IMPORTANT:"
117+
echo "Before running experiments, you must have \$HOME/.cargo/bin in your PATH."
118+
echo "You can add this to your shell profile with:"
119+
echo ' export PATH="$HOME/.cargo/bin:$PATH"'
120+
echo
121+
echo "If you encounter issues, also check that \$HOME/.rustup exists."
122+
echo "===================================================================="
123+
echo
124+

packages-arch.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
autoconf # Part of base-devel
2+
automake # Part of base-devel
3+
bison
4+
clang
5+
cmake
6+
curl
7+
elfutils
8+
flex
9+
gdb
10+
git
11+
gperf
12+
boost
13+
boost-libs
14+
libdwarf
15+
libedit
16+
libffi
17+
xz # Provides liblzma
18+
openssl
19+
ncurses # Provides libtinfo
20+
libunwind
21+
libzip
22+
llvm
23+
make # Part of base-devel
24+
ninja
25+
pkgconf # pkg-config equivalent
26+
pipx
27+
procps-ng # procps equivalent
28+
python
29+
rsync
30+
xorg-server-xvfb # xvfb
31+
zlib
32+
zstd

packages-debian.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
autotools-dev
2+
bison
3+
build-essential
4+
clang
5+
cmake
6+
curl
7+
elfutils
8+
flex
9+
gdb
10+
git
11+
gperf
12+
libboost-dev
13+
libboost-iostreams-dev
14+
libboost-program-options-dev
15+
libdwarf-dev
16+
libedit-dev
17+
libffi-dev
18+
liblzma-dev
19+
libssl-dev
20+
libtinfo-dev
21+
libunwind-dev
22+
libzip-dev
23+
llvm-dev
24+
make
25+
ninja-build
26+
pkg-config
27+
pipx
28+
procps
29+
python3
30+
rsync
31+
xvfb
32+
zlib1g-dev
33+
zstd

0 commit comments

Comments
 (0)