Skip to content

Commit 244a6d3

Browse files
LynndoxAndy-Python-Programmer
authored andcommitted
Improve package manager detection
Check for existence of `apt`/`pacman` rather than relying on /etc/os-release, which can be [problematic](#101 (comment))
1 parent 9b0049d commit 244a6d3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tools/deps/deps_linux

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/bash
22

3-
# We are going to use /etc/os-release to identify which
4-
# Linux distribution we are currently running.
5-
. /etc/os-release
6-
7-
if [[ $ID_LIKE == "debian" ]]; then
3+
if [ -x "$(command -v apt)" ]; then
84
PKGMAN="apt"
95

106
packages=(
@@ -48,7 +44,7 @@ packages=(
4844

4945
function install_package() { apt-get install -y $1; }
5046
function query_package() { dpkg -l | grep -q $1; }
51-
elif [[ $ID == "arch" ]]; then # if [[ $ID_LIKE == "debian" ]]; then
47+
elif [ -x "$(command -v pacman)" ]; then # if [ -x "$(command -v apt)" ]; then
5248
PKGMAN="pacman"
5349

5450
packages=(
@@ -94,4 +90,4 @@ packages=(
9490

9591
function install_package() { pacman -S $1 --noconfirm; }
9692
function query_package() { pacman -Q | grep -q $1; }
97-
fi # elif [[ $ID == "arch" ]]; then
93+
fi # elif [ -x "$(command -v pacman)" ]; then

0 commit comments

Comments
 (0)