Commit 9bcc1c5d authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info pkgmanager: detect package manager by commands in the system

parent 14571dae
...@@ -29,7 +29,7 @@ has() ...@@ -29,7 +29,7 @@ has()
# Has a system the specified command? # Has a system the specified command?
hascommand() hascommand()
{ {
which $1 2>/dev/null >/dev/null which "$1" 2>/dev/null >/dev/null
} }
firstupper() firstupper()
...@@ -94,7 +94,7 @@ case $DISTRIB_ID in ...@@ -94,7 +94,7 @@ case $DISTRIB_ID in
Ubuntu|Debian|Mint|AstraLinux|Elbrus) Ubuntu|Debian|Mint|AstraLinux|Elbrus)
CMD="apt-dpkg" CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg #which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
which snappy 2>/dev/null >/dev/null && CMD=snappy hascommand snappy && CMD=snappy
;; ;;
Mandriva|ROSA) Mandriva|ROSA)
CMD="urpm-rpm" CMD="urpm-rpm"
...@@ -111,7 +111,7 @@ case $DISTRIB_ID in ...@@ -111,7 +111,7 @@ case $DISTRIB_ID in
;; ;;
Fedora|FedoraLinux|LinuxXP|ASPLinux|CentOS|OracleLinux|RockyLinux|RHEL|Scientific|GosLinux|Amzn|RedOS) Fedora|FedoraLinux|LinuxXP|ASPLinux|CentOS|OracleLinux|RockyLinux|RHEL|Scientific|GosLinux|Amzn|RedOS)
CMD="dnf-rpm" CMD="dnf-rpm"
which dnf 2>/dev/null >/dev/null || CMD=yum-rpm hascommand dnf || CMD=yum-rpm
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "CentOS/7" ] && CMD=yum-rpm [ "$DISTRIB_ID/$DISTRIB_RELEASE" = "CentOS/7" ] && CMD=yum-rpm
;; ;;
Slackware) Slackware)
...@@ -125,8 +125,8 @@ case $DISTRIB_ID in ...@@ -125,8 +125,8 @@ case $DISTRIB_ID in
;; ;;
Windows) Windows)
CMD="appget" CMD="appget"
which $CMD 2>/dev/null >/dev/null || CMD="chocolatey" hascommand $CMD || CMD="chocolatey"
which $CMD 2>/dev/null >/dev/null || CMD="winget" hascommand $CMD || CMD="winget"
;; ;;
MacOS) MacOS)
CMD="homebrew" CMD="homebrew"
...@@ -153,6 +153,16 @@ case $DISTRIB_ID in ...@@ -153,6 +153,16 @@ case $DISTRIB_ID in
CMD="xbps" CMD="xbps"
;; ;;
*) *)
# try detect firstly
if hascommand "rpm" ; then
hascommand "urpmi" && echo "urpmi-rpm" && return
hascommand "zypper" && echo "zypper-rpm" && return
hascommand "dnf" && echo "dnf-rpm" && return
fi
if hascommand "dpkg" ; then
hascommand "apt" && echo "apt-dpkg" && return
hascommand "apt-get" && echo "apt-dpkg" && return
fi
echo "We don't support yet DISTRIB_ID $DISTRIB_ID" >&2 echo "We don't support yet DISTRIB_ID $DISTRIB_ID" >&2
;; ;;
esac esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment