Created
February 18, 2025 06:14
-
-
Save larkinwc/89d46a0b60609c56e42b6cc302ec91c1 to your computer and use it in GitHub Desktop.
Script to install and build crosvm (with gpu mode) on a fresh install of debian 12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit on any error | |
set -e | |
# Function to print status messages | |
print_status() { | |
echo "===> $1" | |
} | |
# Check if running as root | |
if [ "$EUID" -eq 0 ]; then | |
echo "Please do not run as root. The script will use sudo when needed." | |
exit 1 | |
fi | |
# Update system and install dependencies | |
print_status "Updating system and installing dependencies..." | |
sudo apt update | |
sudo apt upgrade -y | |
sudo apt install -y git build-essential pkg-config libwayland-dev libdrm-dev \ | |
libgbm-dev libvirglrenderer-dev libepoxy-dev libx11-dev libgles2-mesa-dev \ | |
libegl1-mesa-dev libcap-dev clang libclang-dev llvm-dev \ | |
wayland-protocols libwayland-bin curl | |
# Install Rust if not already installed | |
if ! command -v rustc &> /dev/null; then | |
print_status "Installing Rust..." | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
else | |
print_status "Rust is already installed" | |
fi | |
# Create working directory | |
WORK_DIR="$HOME/crosvm-build" | |
mkdir -p "$WORK_DIR" | |
cd "$WORK_DIR" | |
# Clone and setup crosvm | |
print_status "Cloning crosvm repository..." | |
if [ ! -d "crosvm" ]; then | |
git clone https://chromium.googlesource.com/chromiumos/platform/crosvm | |
cd crosvm | |
else | |
cd crosvm | |
git pull | |
fi | |
print_status "Initializing submodules..." | |
git submodule update --init --recursive | |
# Set Wayland protocols path | |
export WAYLAND_PROTOCOLS_PATH=/usr/share/wayland-protocols | |
# Build crosvm | |
print_status "Building crosvm (this may take a while)..." | |
cargo build --features 'default-no-sandbox gpu' | |
# Setup system configurations | |
print_status "Setting up system configurations..." | |
sudo groupadd -f crosvm | |
sudo usermod -a -G crosvm $USER | |
sudo mkdir -p /etc/crosvm | |
sudo mkdir -p /var/log/crosvm | |
sudo chown -R $USER:crosvm /etc/crosvm | |
sudo chmod 750 /etc/crosvm | |
print_status "CrosVM setup completed successfully!" | |
print_status "You will need to log out and back in for the group changes to take effect." | |
print_status "CrosVM binary is located at: $WORK_DIR/crosvm/target/debug/crosvm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment