Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- if [ $(id -u) -ne 0 ]; then
- echo "This script requires sudo privileges to run."
- exit 1
- fi
- function show_menu {
- echo "Choose an option:"
- echo "1. Build Vulkan"
- echo "2. Build Libdrm"
- echo "3. Build Mesa"
- echo "4. Build Virglrenderer"
- echo "5. Build QEMU"
- echo "6. Build DXVK"
- echo "7. Build Vkd3d-proton"
- echo "8. Build Proton"
- echo "9. Build or Install Linux Kernel (newest)"
- echo "10. Reboot"
- echo "0. Exit"
- read -p "Enter your choice: " choice
- }
- function show_mesa_menu {
- echo "Choose an option for Mesa:"
- echo "1. Build from source"
- echo "2. Install from PPA"
- echo "0. Back to main menu"
- read -p "Enter your choice: " mesa_choice
- }
- function run_command {
- if ! "$@"; then
- echo "Command failed. Returning to menu."
- sleep 3
- else
- echo "Command completed. Returning to menu."
- sleep 3
- fi
- }
- function build_vulkan {
- echo "Building Vulkan..."
- ###################################################################################################################
- if [ ! -d "vulkan-loader" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/KhronosGroup/Vulkan-Loader.git vulkan-loader
- fi
- if [ ! -d "vulkan-headers" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/KhronosGroup/Vulkan-Headers.git vulkan-headers
- fi
- cd vulkan-headers
- git config --global --add safe.directory /tools/virtualization/venus/vulkan-headers
- git rebase
- git pull --recurse-submodules
- cd ..
- cd vulkan-loader
- git config --global --add safe.directory /tools/virtualization/venus/vulkan-loader
- git rebase
- git pull --recurse-submodules
- cd ..
- ###################################################################################################################
- cd vulkan-headers
- rm -rf build
- mkdir build
- cd build
- cmake -D CMAKE_INSTALL_PREFIX=/usr ..
- cmake --build . --target install
- cd ../..
- ###################################################################################################################
- cd vulkan-loader
- rm -rf build
- mkdir build
- cd build
- cmake -D CMAKE_INSTALL_PREFIX=/usr \
- -D CMAKE_BUILD_TYPE=Release \
- -D CMAKE_SKIP_INSTALL_RPATH=ON \
- -G Ninja ..
- sudo ninja
- sudo ninja install
- cd ../..
- ###################################################################################################################
- sudo rm -rf vulkan-loader
- sudo rm -rf vulkan-headers
- }
- function build_libdrm {
- echo "Building libdrm..."
- if [ ! -d "libdrm" ]; then
- git clone --recurse-submodules --depth=1 https://gitlab.freedesktop.org/mesa/drm.git libdrm
- fi
- cd libdrm
- rm -rf build
- git config --global --add safe.directory /tools/virtualization/venus/libdrm
- git rebase
- git pull --recurse-submodules
- mkdir build
- cd build
- ninja -C build uninstall
- meson setup --wipe \
- --buildtype=release \
- -Dudev=true \
- -Dvalgrind=disabled \
- -Dintel=enabled \
- -Dradeon=enabled \
- -Damdgpu=enabled \
- -Dnouveau=enabled \
- -Dvmwgfx=enabled \
- -Domap=enabled \
- -Dexynos=enabled \
- -Dfreedreno=enabled \
- -Dtegra=enabled \
- -Dvc4=enabled \
- -Detnaviv=enabled \
- ..
- ninja
- ninja install
- cd ../..
- rm -rf libdrm
- }
- function build_mesa {
- show_mesa_menu
- case $mesa_choice in
- 1)
- echo "Building Mesa from source..."
- export RUSTFLAGS=""
- export CLANG_PATH=`which clang-19`
- export LLVM_CONFIG=/usr/bin/llvm-config
- export CC=clang
- export CXX=clang++
- export PATH=/lib/llvm-19/bin:$PATH
- if [ ! -d "mesa" ]; then
- git clone --recurse-submodules --depth=1 https://gitlab.freedesktop.org/mesa/mesa.git mesa
- fi
- cd mesa
- git config --global --add safe.directory /tools/virtualization/venus/mesa
- git rebase
- git pull --recurse-submodules
- mkdir build
- cd build
- apt install rustc-1.80 rust-1.80-all rustup -y
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y
- . "$HOME/.cargo/env"
- rustup update stable
- meson setup --wipe .. \
- -Dsplit-debug=disabled \
- -Dplatforms=auto \
- -Degl-native-platform=auto \
- -Dandroid-stub=false \
- -Dandroid-strict=true \
- -Dexpat=auto \
- -Dgallium-drivers=all \
- -Dgallium-extra-hud=false \
- -Dgallium-d3d10umd=false \
- -Dgallium-rusticl=false \
- -Dlibunwind=disabled \
- -Dlmsensors=disabled \
- -Dlmsensors=disabled \
- -Dvulkan-drivers=all \
- -Dshader-cache=enabled \
- -Dshader-cache-default=true \
- -Dgles1=disabled \
- -Damdgpu-virtio=true \
- -Dgles2=enabled \
- -Dopengl=true \
- -Dgbm=enabled \
- -Dglx=auto \
- -Degl=enabled \
- -Dglvnd=enabled \
- -Dllvm=enabled \
- -Dshared-llvm=enabled \
- -Dvalgrind=disabled \
- -Dgallium-vdpau=disabled \
- -Dgallium-va=disabled \
- -Dgallium-extra-hud=false \
- -Dgallium-vdpau=disabled \
- -Dtools=all \
- -Dvulkan-layers=device-select,intel-nullhw,overlay,screenshot,vram-report-limit \
- -Dxmlconfig=auto
- ninja install
- cd ../..
- rm -rf mesa
- ;;
- 2)
- echo "Installing Mesa from PPA..."
- sudo add-apt-repository ppa:oibaf/graphics-drivers -y
- sudo apt update
- sudo apt upgrade -y
- sudo apt full-upgrade -y
- ;;
- 0)
- return
- ;;
- *)
- echo "Invalid choice. Returning to main menu."
- sleep 3
- ;;
- esac
- }
- function build_virglrenderer {
- echo "Building virglrenderer..."
- if [ ! -d "virglrenderer" ]; then
- git clone --recurse-submodules --depth=1 https://gitlab.freedesktop.org/virgl/virglrenderer.git virglrenderer
- fi
- cd virglrenderer
- git config --global --add safe.directory /tools/virtualization/venus/virglrenderer
- git rebase
- git pull --recurse-submodules
- ninja -C build uninstall
- meson setup build --wipe \
- -Dplatforms=auto \
- -Dminigbm_allocation=false \
- -Dvenus=true \
- -Dvenus-validate=true \
- -Dcheck-gl-errors=true \
- -Ddrm-renderers=amdgpu-experimental \
- -Drender-server=true \
- -Drender-server-worker=process \
- -Dvideo=true \
- -Dtests=false \
- -Dfuzzer=false \
- -Dvalgrind=false \
- -Dtracing=none \
- -Dunstable-apis=false \
- -Dbuildtype=release
- ninja -C build install
- cd ..
- rm -rf virglrenderer
- }
- function build_qemu {
- echo "Building QEMU..."
- if [ ! -d "qemu" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/qemu/qemu.git qemu
- fi
- cd qemu
- PATCH_DIR="/tools/virtualization/venus/patch/qemu"
- for i in {1,2,3,4,5,6,7,8,9,10}; do
- PATCH_FILE="$PATCH_DIR/$i.patch"
- if [ -f "$PATCH_FILE" ]; then
- echo "Applying patch: $PATCH_FILE"
- patch -p1 < "$PATCH_FILE"
- if [ $? -ne 0 ]; then
- echo "Failed to apply patch: $PATCH_FILE"
- exit 1
- fi
- else
- echo "Patch file not found: $PATCH_FILE"
- fi
- done
- git config --global --add safe.directory /tools/virtualization/venus/qemu
- git stash -u
- git rebase
- git pull --recurse-submodules
- git stash pop
- rm -rf build
- mkdir build
- cd build
- ninja uninstall
- ../configure \
- --cpu=x86_64 \
- --audio-drv-list=alsa,default,oss,pa,sdl,sndio,pipewire \
- --disable-werror \
- --enable-vnc \
- --enable-opengl \
- --enable-xen \
- --enable-xen-pci-passthrough \
- --enable-vdi \
- --enable-vde \
- --enable-tpm \
- --enable-spice \
- --enable-qcow1 \
- --enable-libusb \
- --enable-virglrenderer \
- --enable-system \
- --enable-modules \
- --enable-gtk \
- --enable-usb-redir \
- --enable-kvm \
- --enable-sdl \
- --enable-vte \
- --enable-bzip2 \
- --enable-linux-user \
- --enable-docs \
- --enable-gnutls \
- --enable-nettle \
- --enable-curses \
- --enable-virtfs \
- --enable-curl \
- --enable-fdt \
- --enable-rdma \
- --enable-vde \
- --enable-linux-aio \
- --enable-cap-ng \
- --enable-attr \
- --enable-vhost-net \
- --enable-rbd \
- --enable-libiscsi \
- --enable-libnfs \
- --enable-smartcard \
- --enable-lzo \
- --enable-snappy \
- --enable-seccomp \
- --enable-coroutine-pool \
- --enable-glusterfs \
- --enable-tpm \
- --enable-numa \
- --enable-slirp
- ninja install
- cd ../..
- rm -rf qemu
- }
- function build_dxvk {
- echo "Building DXVK..."
- if [ ! -d "dxvk" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/doitsujin/dxvk.git dxvk
- fi
- cd dxvk
- git config --global --add safe.directory /tools/virtualization/venus/dxvk
- git rebase
- git pull --recurse-submodules
- ninja -C build uninstall
- rm -rf build
- mkdir build
- ./package-release.sh master /tools/virtualization/venus/dxvk/build --no-package
- ninja -C build/dxvk-master/build.64/ install
- ninja -C build/dxvk-master/build.32/ install
- cd ..
- rm -rf dxvk
- }
- function build_vkd3d_proton {
- echo "Building vkd3d-proton..."
- if [ ! -d "vkd3d-proton" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/HansKristian-Work/vkd3d-proton.git vkd3d-proton
- fi
- cd vkd3d-proton
- git config --global --add safe.directory /tools/virtualization/venus/vkd3d-proton
- git rebase
- git pull --recurse-submodules
- rm -rf build
- mkdir build
- ./package-release.sh master /tools/virtualization/venus/vkd3d-proton/build --no-package
- cd build/vkd3d-proton-master/
- sudo -u "#$SUDO_UID" ./setup_vkd3d_proton.sh install
- cd ../../..
- rm -rf vkd3d-proton
- }
- function build_proton {
- echo "Building Proton..."
- if [ ! -d "proton" ]; then
- git clone --recurse-submodules --depth=1 https://github.com/ValveSoftware/Proton.git proton
- fi
- cd proton
- git config --global --add safe.directory /tools/virtualization/venus/proton
- git rebase
- git pull --recurse-submodules
- make clean
- make
- make dxvk
- make vkd3d-proton
- make install
- cd ..
- rm -rf proton
- }
- function build_kernel_new {
- echo "Building or Installing Linux Kernel (newest)..."
- read -p "The kernel is already built. Rebuild or just install linux kernel? (build/install): " response
- if [ "$response" = "build" ]; then
- read -p "Are you sure you want to rebuild the kernel? It will take a long time to rebuild. (yes/no): " confirm
- if [ "$confirm" = "yes" ]; then
- echo "Building linux kernel. This will take a long time!"
- echo "Speeds will vary depending on your CPU."
- export CC="ccache clang"
- export CXX="ccache clang++"
- export CFLAGS="-O2 -pipe"
- export CXXFLAGS="-O2 -pipe"
- rm -rf linux-kernel
- KERNEL_DIR="linux-kernel"
- if [ -d "$KERNEL_DIR" ]; then
- cd "$KERNEL_DIR" && git pull
- else
- git clone --recurse-submodules --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git "$KERNEL_DIR"
- cd "$KERNEL_DIR"
- fi
- git fetch --tags
- LATEST_STABLE_TAG=$(git tag -l | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort --version-sort | tail -n1)
- git checkout "$LATEST_STABLE_TAG"
- patch -p1 < /tools/virtualization/venus/patch/kernel/1.patch
- rm -rf .config
- make menuconfig
- scripts/config --enable CONFIG_KERNEL_XZ
- scripts/config --enable CONFIG_PREEMPT_RT
- scripts/config --enable CONFIG_DRM_VIRTIO_GPU
- scripts/config --disable CONFIG_TRANSPARENT_HUGEPAGE
- scripts/config --disable SYSTEM_TRUSTED_KEYS
- scripts/config --disable SYSTEM_REVOCATION_KEYS
- ccache -C
- ccache -M 100G
- make -j$(($(nproc)*2))
- make modules_install
- make install
- sudo update-grub
- sudo update-grub2
- cd ..
- else
- echo "Kernel rebuild aborted."
- fi
- read -p "Do you wanna remove the kernel? It could take just as long to build again. (yes/no): " remove
- if [ "$remove" = "yes" ]; then
- rm -rf linux-kernel
- fi
- elif [ "$response" = "install" ]; then
- cd linux
- make install
- update-grub
- update-grub2
- cd ..
- fi
- }
- function reboot_system {
- read -p "Reboot now? (yes/no): " response
- if [ "$response" = "yes" ]; then
- reboot
- fi
- }
- while true; do
- show_menu
- case $choice in
- 1)
- run_command build_vulkan
- ;;
- 2)
- run_command build_libdrm
- ;;
- 3)
- build_mesa
- ;;
- 4)
- run_command build_virglrenderer
- ;;
- 5)
- run_command build_qemu
- ;;
- 6)
- run_command build_dxvk
- ;;
- 7)
- run_command build_vkd3d_proton
- ;;
- 8)
- run_command build_proton
- ;;
- 9)
- run_command build_kernel_new
- ;;
- 10)
- reboot_system
- ;;
- 0)
- echo "Exiting..."
- exit 0
- ;;
- *)
- echo "Invalid choice. Please try again."
- sleep 3
- ;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement