getpackages now works with multiple package managers at once

This commit is contained in:
Dylan 2016-04-26 16:39:22 +10:00
parent 6c29941b89
commit 2d59b695fa
1 changed files with 24 additions and 27 deletions

View File

@ -649,44 +649,41 @@ getpackages () {
type -p pacman >/dev/null 2>&1 && \ type -p pacman >/dev/null 2>&1 && \
packages="$(pacman -Qq --color never | wc -l)" packages="$(pacman -Qq --color never | wc -l)"
[ -z "$packages" ] && type -p dpkg >/dev/null 2>&1 && \ type -p dpkg >/dev/null 2>&1 && \
packages="$(dpkg --get-selections | grep -cv deinstall$)" let packages+="$(dpkg --get-selections | grep -cv deinstall$)"
[ -z "$packages" ] && type -p /sbin/pkgtool >/dev/null 2>&1 && \ type -p /sbin/pkgtool >/dev/null 2>&1 && \
packages="$(ls -1 /var/log/packages | wc -l)" let packages+="$(ls -1 /var/log/packages | wc -l)"
[ -z "$packages" ] && type -p rpm >/dev/null 2>&1 && \ type -p rpm >/dev/null 2>&1 && \
packages="$(rpm -qa | wc -l)" let packages+="$(rpm -qa | wc -l)"
[ -z "$packages" ] && type -p xbps-query >/dev/null 2>&1 && \ type -p xbps-query >/dev/null 2>&1 && \
packages="$(xbps-query -l | wc -l)" let packages+="$(xbps-query -l | wc -l)"
[ -z "$packages" ] && type -p pkginfo >/dev/null 2>&1 && \ type -p pkginfo >/dev/null 2>&1 && \
packages="$(pkginfo -i | wc -l)" let packages+="$(pkginfo -i | wc -l)"
[ -z "$packages" ] && type -p pisi >/dev/null 2>&1 && \ type -p pisi >/dev/null 2>&1 && \
packages="$(pisi list-installed | wc -l)" let packages+="$(pisi list-installed | wc -l)"
[ -z "$packages" ] && type -p pkg >/dev/null 2>&1 && \ type -p pkg >/dev/null 2>&1 && \
packages="$(ls -1 /var/db/pkg | wc -l)" let packages+="$(ls -1 /var/db/pkg | wc -l)"
[ -z "$packages" ] && type -p emerge >/dev/null 2>&1 && \ type -p emerge >/dev/null 2>&1 && \
packages="$(ls -d /var/db/pkg/*/* | wc -l)" let packages+="$(ls -d /var/db/pkg/*/* | wc -l)"
[ -z "$packages" ] && type -p nix-env >/dev/null 2>&1 && \ type -p nix-env >/dev/null 2>&1 && \
packages="$(ls -d -1 /nix/store/*/ | wc -l)" let packages+="$(ls -d -1 /nix/store/*/ | wc -l)"
[ -z "$packages" ] && type -p apk >/dev/null 2>&1 && \ type -p apk >/dev/null 2>&1 && \
packages="$(apk info | wc -l)" let packages+="$(apk info | wc -l)"
[ -z "$packages" ] && type -p pacman-g2 >/dev/null 2>&1 && \ type -p pacman-g2 >/dev/null 2>&1 && \
packages="$(pacman-g2 -Q | wc -l)" let packages+="$(pacman-g2 -Q | wc -l)"
if [ -z "$packages" ] && type -p cave >/dev/null 2>&1; then type -p cave >/dev/null 2>&1 && \
cross_packages=$(ls -d -1 /var/db/paludis/repositories/cross-installed/*/data/* | wc -l) let packages+=$(ls -d -1 /var/db/paludis/repositories/cross-installed/*/data/* /var/db/paludis/repositories/installed/data/* | wc -l)
packages=$(ls -d -1 /var/db/paludis/repositories/installed/data/* | wc -l)
packages=$((packages + cross_packages))
fi
;; ;;
"Mac OS X") "Mac OS X")