Skip to content

Instantly share code, notes, and snippets.

@dan0v
Last active January 19, 2026 22:57
Show Gist options
  • Select an option

  • Save dan0v/bea15a7ade05e3a40eadce6e8504a52c to your computer and use it in GitHub Desktop.

Select an option

Save dan0v/bea15a7ade05e3a40eadce6e8504a52c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
echo "============================================================"
echo " Bleeding-Edge Mesa Installer (Fedora)"
echo "============================================================"
echo
echo "This script will build Mesa from source and install it into:"
echo " /opt/mesa-git"
echo
echo "Your system Mesa packages will NOT be replaced."
echo "For transparency, this is AI slop, based on https://gist.github.com/craimasjien/4519283aa2c170b93aff00b9f75aa7bf"
echo
# -----------------------------
# Step 1: Ask clone location
# -----------------------------
read -rp "Where should the Mesa repository be located? (e.g. ~/dev/mesa): " MESA_DIR
MESA_DIR=$(eval echo "$MESA_DIR")
echo
echo "Using Mesa directory: $MESA_DIR"
echo
# -----------------------------
# Step 2: Install build deps
# -----------------------------
echo "Installing Mesa build dependencies via dnf..."
echo "You may be prompted for your sudo password."
echo
sudo dnf builddep mesa -y
echo
# -----------------------------
# Step 3: Clone or update Mesa
# -----------------------------
if [[ -d "$MESA_DIR/.git" ]]; then
echo "Mesa repository already exists."
echo "Fetching latest changes..."
cd "$MESA_DIR"
git fetch --tags
else
echo "Cloning Mesa repository..."
git clone https://gitlab.freedesktop.org/mesa/mesa.git "$MESA_DIR"
cd "$MESA_DIR"
fi
echo
# -----------------------------
# Step 4: Show latest tags
# -----------------------------
echo "Latest 5 Mesa tags:"
echo "-------------------"
git tag --sort=-creatordate | head -n 5
echo
read -rp "Enter the Mesa tag you want to use (e.g. mesa-25.3.3): " MESA_TAG
echo
echo "Checking out Mesa version: $MESA_TAG"
git checkout "$MESA_TAG"
echo
# -----------------------------
# Step 5: Vulkan driver choice
# -----------------------------
echo "Select Vulkan driver to build:"
echo " 1) amd"
echo " 2) intel"
echo " 3) nouveau"
echo " 4) swrast"
echo " 5) auto"
echo " 6) all"
echo
read -rp "Enter choice [1-6]: " VK_CHOICE
case "$VK_CHOICE" in
1) VK_DRIVER="amd" ;;
2) VK_DRIVER="intel" ;;
3) VK_DRIVER="nouveau" ;;
4) VK_DRIVER="swrast" ;;
5) VK_DRIVER="auto" ;;
6) VK_DRIVER="all" ;;
*) echo "Invalid choice"; exit 1 ;;
esac
echo
echo "Using Vulkan driver(s): $VK_DRIVER"
echo
# -----------------------------
# Step 6: Configure build
# -----------------------------
echo "Configuring Mesa build with Meson..."
echo
meson setup build/ \
-Dprefix=/opt/mesa-git \
-Dplatforms=x11,wayland \
-Dvulkan-drivers="$VK_DRIVER" \
-Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec,av1dec,av1enc,vp9dec
echo
echo "Building Mesa (this may take a while)..."
echo
meson compile -C build/
echo
# -----------------------------
# Step 7: Install Mesa
# -----------------------------
echo "Installing Mesa into /opt/mesa-git..."
echo "This requires sudo."
echo
sudo meson install -C build/
echo
# -----------------------------
# Step 8: Vulkan ICD selection
# -----------------------------
echo "Available Vulkan ICD files:"
echo
ls /opt/mesa-git/share/vulkan/icd.d/
echo
read -rp "Enter the Vulkan ICD filename to use (exact name): " VK_ICD
VK_ICD_PATH="/opt/mesa-git/share/vulkan/icd.d/$VK_ICD"
if [[ ! -f "$VK_ICD_PATH" ]]; then
echo "ERROR: Selected ICD file does not exist."
exit 1
fi
# -----------------------------
# Step 9: System-wide or session-only
# -----------------------------
echo
echo "Mesa installation complete."
echo
read -rp "Apply this Mesa version system-wide? (y/N): " APPLY_SYSTEM
if [[ "$APPLY_SYSTEM" =~ ^[Yy]$ ]]; then
echo
echo "Applying system-wide environment configuration..."
echo "Backing up /etc/environment to /etc/environment.bak"
echo
sudo cp /etc/environment /etc/environment.bak
sudo bash -c "cat > /etc/environment <<EOF
LD_LIBRARY_PATH=\"/opt/mesa-git/lib64\"
OCL_ICD_VENDORS=\"/opt/mesa-git/etc/OpenCL/vendors\"
VK_DRIVER_FILES=\"$VK_ICD_PATH\"
LIBVA_DRIVERS_PATH=\"/opt/mesa-git/lib64/dri\"
EOF"
echo
echo "System-wide configuration applied."
echo "Reboot will be required to take effect."
else
echo
echo "System-wide changes NOT applied."
echo
echo "To use Mesa in your current session, run:"
echo
echo "export LD_LIBRARY_PATH=\"/opt/mesa-git/lib64:\$LD_LIBRARY_PATH\""
echo "export OCL_ICD_VENDORS=\"/opt/mesa-git/etc/OpenCL/vendors\""
echo "export VK_DRIVER_FILES=\"$VK_ICD_PATH\""
echo "export LIBVA_DRIVERS_PATH=\"/opt/mesa-git/lib64/dri\""
fi
echo
echo "============================================================"
echo " Installation Finished"
echo "============================================================"
echo
echo "Test with:"
echo " vulkaninfo | grep \"Vulkan Instance Version\""
echo " glxinfo | grep \"OpenGL version\""
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment