-
Notifications
You must be signed in to change notification settings - Fork 10
Modified os detection refer to ID and VARIANT_ID instead of NAME #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# Check distro | ||
os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"') | ||
|
||
|
||
# Return to home directory | ||
cd | ||
|
||
|
@@ -17,24 +13,74 @@ 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 | ||
# 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" | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just thinking about this, should we do a sudo apt update so that the package lists aren't outdated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should for two (albeit weak) reasons:
Instead, thoughts on checking the exit code of the install and giving There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good |
||
;; | ||
'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 | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of issues does this cause? Does it extract the name weirdly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ubuntu is a derivative of Debian, so the ID_LIKE has Debian in to. Basically saying "Treat me like debian, if you don't care I'm actually ubuntu". RHEL points to Fedora, Manjaro and steamOS point to Arch. This simplifies the script, because we don't have to have a bunch of cases if we don't care about specifics.
Bazzite (and some others) are weird, and have a bunch of ids here. It lists
rhel centos fedora bluefin aurora nobara ultramarine
. If the goal is to not have a giant list of distros and their package managers, how do we figure out that this distro uses dnf as its package manager?We could iterate until we find something we recognize, but that has some questions about multiple matches and match precedence.
In the end, I ended up dropping the ID_LIKE if it has multiple values. I think this is a decent solution.
I will update the comment to reflect that it just drops it if there are multiple values.