Skip to content

Commit e92f56e

Browse files
committed
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
1 parent 3a19a68 commit e92f56e

File tree

1 file changed

+63
-15
lines changed

1 file changed

+63
-15
lines changed

compile.sh

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
# Check distro
43
os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"')
54

65

@@ -17,24 +16,73 @@ rm Skia-Linux-Release-x64-libc++.zip
1716

1817
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."
1918

19+
# Check distro
20+
os_name=$(grep '^ID=' /etc/os-release --max-count 1 | cut -c4-)
21+
os_like=$(grep '^ID_LIKE=' /etc/os-release --max-count 1 | cut -c9-)
22+
os_variant=$(grep '^VARIANT_ID=' /etc/os-release --max-count 1 | cut -c12-)
2023

21-
# Assign package manager to a variable
22-
if [[ "$os_name" == *"Fedora"* ]]; then
23-
package_man="dnf"
24-
elif [[ $os_name == *"Debian"* ]] || [[ $os_name == *"Ubuntu"* ]] || [[ $os_name == *"Mint"* ]]; then
25-
package_man="apt"
26-
else
27-
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."
28-
echo "Stopped installation! Please remove ~/deps."
29-
exit 1
24+
# replace 'ubuntu' with 'debian' and 'rhel' with 'fedora' (among others)
25+
# this has some weird issues on some distros where they list multiple possibilities
26+
# https://github.com/which-distro/os-release/
27+
[[ "$os_like" =~ [[:space:]]+ ]] && os_like=''
28+
[[ "$os_like" != '' ]] && os_name="$os_like"
29+
30+
case "$os_name" in
31+
'debian' | 'ubuntu' | 'linuxmint')
32+
package_man='apt'
33+
;;
34+
'fedora')
35+
case "$os_variant" in
36+
'kinoite' | 'silverblue')
37+
package_man='unsupported'
38+
;;
39+
*)
40+
package_man='dnf'
41+
;;
42+
esac
43+
;;
44+
'arch')
45+
package_man='unsupported' # for now
46+
;;
47+
*)
48+
package_man="unknown"
49+
;;
50+
esac
51+
52+
# user override
53+
if [[ "$PACKAGE_MANAGER" != "" ]] ; then
54+
package_man="$PACKAGE_MANAGER"
3055
fi
3156

57+
package_manager_text="Currently this script only supports apt and dnf, and it appears that your system is unsupported.
58+
If you believe this is a mistake, please re-run this script with environmental variable 'PACKAGE_MANAGER=apt' or 'PACKAGE_MANAGER=dnf'.
59+
You can also open an issue ticket."
60+
3261
# Install dependencies
33-
if [[ $package_man == "dnf" ]]; then
34-
sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git
35-
elif [[ $package_man == "apt" ]]; then
36-
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
37-
fi
62+
case "$package_man" in
63+
'dnf')
64+
sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git
65+
;;
66+
'apt')
67+
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
68+
;;
69+
'pacman') # untested
70+
sudo pacman -S gcc clang libc++ cmake ninja libx11 libxcursor mesa-libgl fontconfig libwebp
71+
;;
72+
'zypper') # untested
73+
sudo zypper install gcc-c++ clang libc++-devel libc++abi-devel cmake ninja libX11-devel libXcursor-devel libXi-devel Mesa-libGL-devel fontconfig-devel
74+
;;
75+
'unsupported')
76+
echo "Unsupported distro!"
77+
echo "$package_manager_text"
78+
exit 1
79+
;;
80+
*)
81+
echo "Unknown distro!"
82+
echo "$package_manager_text"
83+
exit 1
84+
;;
85+
esac
3886

3987
# Clone aseprite
4088
git clone --recursive https://github.com/aseprite/aseprite.git --depth=1

0 commit comments

Comments
 (0)