Skip to content

Commit

Permalink
Auto-commit: 0 added, 3 modified, 0 deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
4ndr0666 committed Jan 22, 2025
1 parent 15cd843 commit 39508f6
Show file tree
Hide file tree
Showing 3 changed files with 298 additions and 92 deletions.
103 changes: 56 additions & 47 deletions install/graphics/amdgpu/install_amdgpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ set -e
# =================== // INSTALL_AMDGPU.SH //
GRUB_CONFIG="/etc/default/grub"
WAYFIRE_CONFIG_DIR="$HOME/.config/wayfire"
XORG_CONFIG="/etc/X11/xorg.conf"
BACKUP_SUFFIX=".backup_$(date +%F_%T)"
AMDGPU_PACKAGES=("amdgpu" "mesa" "mesa-vulkan-radeon" "wayfire" "waybar" "pipewire" "pipewire-pulse" "wireplumber" "vulkan-tools" "linux-firmware" "wl-clipboard" "swaybg" "wlr-randr" "kanshi" "nwg-displays")
PACMAN_PACKAGES=("mesa" "vulkan-radeon" "vulkan-mesa-layers" "wayfire" "waybar" "pipewire" "pipewire-pulse" "wireplumber" "vulkan-tools" "linux-firmware" "wl-clipboard" "swaybg" "wlr-randr" "kanshi" "nwg-displays")
DEPENDENCIES=("yay" "git" "base-devel")
GRUB_PARAMETERS="amdgpu.si_support=1 radeon.si_support=0"
BLACKLIST_FILE="/etc/modprobe.d/blacklist-radeon.conf"
LOGFILE="/var/log/setup_amdgpu.log"

# Redirect all output to log file
# Redirect all output to log file with timestamps
exec > >(tee -a "$LOGFILE") 2>&1

# Functions

# Automatic Privilege Escalation
ensure_root() {
if [ "$(id -u)" -ne 0 ]; then
echo "Script is not running as root. Attempting to elevate privileges..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Script is not running as root. Attempting to elevate privileges..."
exec sudo bash "$0" "$@"
fi
}
Expand All @@ -39,7 +40,7 @@ show_help() {
echo "Options:"
echo " -h, --help Display this help message and exit."
echo " install-deps Install necessary dependencies (e.g., yay)."
echo " install Install amdgpu and related Mesa packages."
echo " install Install Mesa packages, Wayfire, Wayland tools, Vulkan support, and Vulkan Mesa layers."
echo " install-firmware Install required firmware for amdgpu."
echo " configure-grub Modify GRUB configuration to prefer amdgpu driver."
echo " blacklist-radeon Blacklist the radeon driver to prevent it from loading."
Expand All @@ -55,10 +56,10 @@ show_help() {

# Install Dependencies
install_dependencies() {
echo "Checking and installing necessary dependencies..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Checking and installing necessary dependencies..."
for dep in "${DEPENDENCIES[@]}"; do
if ! command -v "$dep" >/dev/null 2>&1; then
echo "Installing dependency: $dep"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing dependency: $dep"
if [ "$dep" == "yay" ]; then
pacman -S --needed git base-devel --noconfirm
git clone https://aur.archlinux.org/yay.git /tmp/yay
Expand All @@ -69,87 +70,87 @@ install_dependencies() {
pacman -S --needed "$dep" --noconfirm
fi
else
echo "Dependency '$dep' is already installed. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Dependency '$dep' is already installed. Skipping."
fi
done
echo "Dependency installation completed."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Dependency installation completed."
}

# Install amdgpu and related packages
# Install Official Repository Packages
install_packages() {
echo "Checking and installing necessary packages..."
for pkg in "${AMDGPU_PACKAGES[@]}"; do
echo "$(date '+%Y-%m-%d %H:%M:%S') - Checking and installing necessary official packages..."
for pkg in "${PACMAN_PACKAGES[@]}"; do
if ! pacman -Qs "^${pkg}$" > /dev/null ; then
echo "Installing package: $pkg"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing package: $pkg"
pacman -S --noconfirm "$pkg"
else
echo "Package '$pkg' is already installed. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Package '$pkg' is already installed. Skipping."
fi
done
echo "Package installation completed."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Official package installation completed."
}

# Install required firmware for amdgpu
install_firmware() {
echo "Installing required firmware for amdgpu..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing required firmware for amdgpu..."
if pacman -Qs "^linux-firmware$" > /dev/null ; then
echo "Package 'linux-firmware' is already installed. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Package 'linux-firmware' is already installed. Skipping."
else
echo "Installing 'linux-firmware'..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing 'linux-firmware'..."
pacman -S --noconfirm linux-firmware
fi
echo "Firmware installation completed."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Firmware installation completed."
}

# Modify GRUB configuration
configure_grub() {
echo "Configuring GRUB to prefer amdgpu driver..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Configuring GRUB to prefer amdgpu driver..."
if grep -q "$GRUB_PARAMETERS" "$GRUB_CONFIG"; then
echo "GRUB is already configured with the necessary parameters. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - GRUB is already configured with the necessary parameters. Skipping."
else
echo "Backing up existing GRUB configuration..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Backing up existing GRUB configuration..."
cp "$GRUB_CONFIG" "${GRUB_CONFIG}${BACKUP_SUFFIX}"
echo "Adding amdgpu parameters to GRUB_CMDLINE_LINUX..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Adding amdgpu parameters to GRUB_CMDLINE_LINUX..."
sed -i "s/^GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 $GRUB_PARAMETERS\"/" "$GRUB_CONFIG"
echo "Updating GRUB configuration..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Updating GRUB configuration..."
grub-mkconfig -o /boot/grub/grub.cfg
echo "GRUB configuration updated successfully."
echo "$(date '+%Y-%m-%d %H:%M:%S') - GRUB configuration updated successfully."
fi
}

# Blacklist the radeon driver
blacklist_radeon() {
echo "Blacklisting the radeon driver to prevent it from loading..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Blacklisting the radeon driver to prevent it from loading..."
if [ -f "$BLACKLIST_FILE" ]; then
if grep -q "blacklist radeon" "$BLACKLIST_FILE"; then
echo "The radeon driver is already blacklisted. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - The radeon driver is already blacklisted. Skipping."
else
echo "Adding blacklist entry for radeon driver."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Adding blacklist entry for radeon driver."
echo "blacklist radeon" >> "$BLACKLIST_FILE"
fi
else
echo "Creating blacklist configuration file and blacklisting radeon driver."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Creating blacklist configuration file and blacklisting radeon driver."
echo "blacklist radeon" | tee "$BLACKLIST_FILE" > /dev/null
fi
echo "Blacklisting completed."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Blacklisting completed."
}

# Rebuild initramfs
rebuild_initramfs() {
echo "Rebuilding initramfs to apply changes..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rebuilding initramfs to apply changes..."
mkinitcpio -P
echo "Initramfs rebuilt successfully."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Initramfs rebuilt successfully."
}

# Configure Wayfire settings
configure_wayfire() {
echo "Configuring Wayfire for optimal amdgpu performance..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Configuring Wayfire for optimal amdgpu performance..."
mkdir -p "$WAYFIRE_CONFIG_DIR"

WAYFIRE_CONFIG_FILE="$WAYFIRE_CONFIG_DIR/wayfire.ini"

if [ ! -f "$WAYFIRE_CONFIG_FILE" ]; then
echo "Creating default Wayfire configuration..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Creating default Wayfire configuration..."
cat <<EOF > "$WAYFIRE_CONFIG_FILE"
[core]
backend = wayland
Expand All @@ -160,9 +161,9 @@ disable-effects = none
[debug]
log-level = info
EOF
echo "Wayfire configuration created at $WAYFIRE_CONFIG_FILE"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Wayfire configuration created at $WAYFIRE_CONFIG_FILE"
else
echo "Wayfire configuration already exists. Skipping creation."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Wayfire configuration already exists. Skipping creation."
fi

# Additional Wayfire-specific configurations can be added here
Expand All @@ -171,28 +172,28 @@ EOF

# Install essential Wayland tools and libraries
install_wayland_tools() {
echo "Installing essential Wayland tools and libraries..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing essential Wayland tools and libraries..."
local wayland_tools=("wl-clipboard" "swaybg" "waybar" "wlr-randr" "kanshi" "nwg-displays")
for tool in "${wayland_tools[@]}"; do
if ! pacman -Qs "^${tool}$" > /dev/null ; then
echo "Installing Wayland tool: $tool"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing Wayland tool: $tool"
pacman -S --noconfirm "$tool"
else
echo "Wayland tool '$tool' is already installed. Skipping."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Wayland tool '$tool' is already installed. Skipping."
fi
done
echo "Wayland tools installation completed."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Wayland tools installation completed."
}

# Reboot the system
reboot_system() {
echo "Rebooting the system to apply changes..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rebooting the system to apply changes..."
reboot
}

# Verify driver usage and renderer
verify_setup() {
echo "Verifying driver usage and renderer..."
echo "$(date '+%Y-%m-%d %H:%M:%S') - Verifying driver usage and renderer..."

echo ""
echo "Checking active GPU drivers:"
Expand All @@ -205,9 +206,7 @@ verify_setup() {
else
echo "amdgpu module is not loaded. Attempting to load amdgpu..."
modprobe amdgpu || {
echo "Failed to load amdgpu module. Checking dmesg for errors..."
dmesg | grep amdgpu
echo "Please address the above errors before proceeding."
echo "Failed to load amdgpu module. Please check dmesg for errors."
exit 1
}
echo "amdgpu module loaded successfully."
Expand All @@ -233,6 +232,16 @@ verify_setup() {
vulkaninfo | grep "deviceName"
fi

echo ""
echo "Checking Vulkan Mesa layers:"
if pacman -Qs "^vulkan-mesa-layers$" > /dev/null ; then
echo "vulkan-mesa-layers is installed."
else
echo "vulkan-mesa-layers is not installed. Installing..."
pacman -S --noconfirm vulkan-mesa-layers
echo "vulkan-mesa-layers installed successfully."
fi

echo ""
echo "Checking Wayfire compositor status:"
if pgrep wayfire >/dev/null 2>&1; then
Expand Down Expand Up @@ -283,15 +292,15 @@ verify_setup() {

# Handle Unrecognized Commands
unrecognized_command() {
echo "Error: Unrecognized command '$1'"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Error: Unrecognized command '$1'"
echo ""
show_help
exit 1
}

# Enhanced Error Handling
handle_error() {
echo "An unexpected error occurred. Please check the log file at $LOGFILE for details."
echo "$(date '+%Y-%m-%d %H:%M:%S') - An unexpected error occurred. Please check the log file at $LOGFILE for details."
exit 1
}

Expand Down
3 changes: 1 addition & 2 deletions install/mpv/mpv-full-build-git/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Inochi Amaoto <[email protected]>

pkgname=mpv-full-build-git
pkgver=0.39.0.r619.gc438732b23
pkgver=0.39.0.r557.g1dd0e49f83
pkgrel=1
pkgdesc="Video player based on MPlayer/mplayer2 with all possible libs (uses statically linked ffmpeg with all possible libs). (GIT version )"
arch=('x86_64')
Expand Down Expand Up @@ -444,7 +444,6 @@ prepare() {
'-Dspirv-cross=disabled'
'-Dplain-gl=enabled'
'-Dvdpau=enabled'
'-Dvdpau-gl-x11=enabled'
'-Dvaapi=enabled'
'-Dvaapi-drm=enabled'
'-Dvaapi-wayland=enabled'
Expand Down
Loading

0 comments on commit 39508f6

Please sign in to comment.