From c61b4cdc86b79b88d53311851b41164b20b388b8 Mon Sep 17 00:00:00 2001 From: Marcus Minhorst Date: Sun, 6 Apr 2025 22:33:49 -0400 Subject: [PATCH 1/3] Modified os detection refer to ID and VARIANT_ID instead of NAME Also added exceptions for know atomic distros. Also added PACKAGE_MANAGER env var --- compile.sh | 78 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/compile.sh b/compile.sh index ad34502..0b95c9f 100644 --- a/compile.sh +++ b/compile.sh @@ -1,6 +1,5 @@ #!/bin/bash -# Check distro os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"') @@ -17,24 +16,73 @@ rm Skia-Linux-Release-x64-libc++.zip echo "Enter sudo password to install dependencies. This is also a good time to plug in your computer, since compiling will take a long time." +# Check distro +os_name=$(grep '^ID=' /etc/os-release --max-count 1 | cut -c4-) +os_like=$(grep '^ID_LIKE=' /etc/os-release --max-count 1 | cut -c9-) +os_variant=$(grep '^VARIANT_ID=' /etc/os-release --max-count 1 | cut -c12-) -# Assign package manager to a variable -if [[ "$os_name" == *"Fedora"* ]]; then - package_man="dnf" -elif [[ $os_name == *"Debian"* ]] || [[ $os_name == *"Ubuntu"* ]] || [[ $os_name == *"Mint"* ]]; then - package_man="apt" -else - echo "Unsupported distro! If your distro supports APT or DNF, please manually set os_name='Ubuntu' for apt, or os_name='Fedora' at the top of the file. Copy the appropriate command and replace the 'os_name=' with the proper command. You can also open an issue ticket." - echo "Stopped installation! Please remove ~/deps." - exit 1 +# replace 'ubuntu' with 'debian' and 'rhel' with 'fedora' (among others) +# this has some weird issues on some distros where they list multiple possibilities +# https://github.com/which-distro/os-release/ +[[ "$os_like" =~ [[:space:]]+ ]] && os_like='' +[[ "$os_like" != '' ]] && os_name="$os_like" + +case "$os_name" in +'debian' | 'ubuntu' | 'linuxmint') + package_man='apt' + ;; +'fedora') + case "$os_variant" in + 'kinoite' | 'silverblue') + package_man='unsupported' + ;; + *) + package_man='dnf' + ;; + esac + ;; +'arch') + package_man='unsupported' # for now + ;; +*) + package_man="unknown" + ;; +esac + +# user override +if [[ "$PACKAGE_MANAGER" != "" ]] ; then + package_man="$PACKAGE_MANAGER" fi +package_manager_text="Currently this script only supports apt and dnf, and it appears that your system is unsupported. +If you believe this is a mistake, please re-run this script with environmental variable 'PACKAGE_MANAGER=apt' or 'PACKAGE_MANAGER=dnf'. +You can also open an issue ticket." + # Install dependencies -if [[ $package_man == "dnf" ]]; then - sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git -elif [[ $package_man == "apt" ]]; then - sudo apt-get install -y g++ clang libc++-dev libc++abi-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev git -fi +case "$package_man" in +'dnf') + sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git + ;; +'apt') + sudo apt-get install -y g++ clang libc++-dev libc++abi-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev git + ;; +'pacman') # untested + sudo pacman -S gcc clang libc++ cmake ninja libx11 libxcursor mesa-libgl fontconfig libwebp + ;; +'zypper') # untested + sudo zypper install gcc-c++ clang libc++-devel libc++abi-devel cmake ninja libX11-devel libXcursor-devel libXi-devel Mesa-libGL-devel fontconfig-devel + ;; +'unsupported') + echo "Unsupported distro!" + echo "$package_manager_text" + exit 1 + ;; +*) + echo "Unknown distro!" + echo "$package_manager_text" + exit 1 + ;; +esac # Clone aseprite git clone --recursive https://github.com/aseprite/aseprite.git --depth=1 From dfc50e9e8b9bca53b5c65a7f9be9b6d6ab3db975 Mon Sep 17 00:00:00 2001 From: Marcus Minhorst Date: Sun, 6 Apr 2025 22:38:56 -0400 Subject: [PATCH 2/3] Removed missed line of code --- compile.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/compile.sh b/compile.sh index 0b95c9f..39dea83 100644 --- a/compile.sh +++ b/compile.sh @@ -1,8 +1,5 @@ #!/bin/bash -os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"') - - # Return to home directory cd From 8dcd0f2801659a80f934620672720ae0197b46af Mon Sep 17 00:00:00 2001 From: Marcus Minhorst Date: Thu, 17 Apr 2025 15:20:36 -0400 Subject: [PATCH 3/3] Update comment for clarity --- compile.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/compile.sh b/compile.sh index 39dea83..1dfb7c3 100644 --- a/compile.sh +++ b/compile.sh @@ -20,6 +20,7 @@ os_variant=$(grep '^VARIANT_ID=' /etc/os-release --max-count 1 | cut -c12-) # replace 'ubuntu' with 'debian' and 'rhel' with 'fedora' (among others) # this has some weird issues on some distros where they list multiple possibilities +# in case of multiple possiblilities, drop the declaration altogether # https://github.com/which-distro/os-release/ [[ "$os_like" =~ [[:space:]]+ ]] && os_like='' [[ "$os_like" != '' ]] && os_name="$os_like"