packages: Use dnf cache if available. Closes #1730

This commit is contained in:
Dylan Araps 2021-06-11 05:02:17 +00:00
parent 41f75b7b48
commit 50a8bd285d
1 changed files with 7 additions and 1 deletions

View File

@ -1523,7 +1523,6 @@ get_packages() {
has cpt-list && tot cpt-list has cpt-list && tot cpt-list
has pacman-key && tot pacman -Qq --color never has pacman-key && tot pacman -Qq --color never
has apt && tot apt list --installed && ((packages-=1)) has apt && tot apt list --installed && ((packages-=1))
has rpm && tot rpm -qa
has xbps-query && tot xbps-query -l has xbps-query && tot xbps-query -l
has apk && tot apk info has apk && tot apk info
has opkg && tot opkg list-installed has opkg && tot opkg list-installed
@ -1537,6 +1536,13 @@ get_packages() {
has butch && tot butch list has butch && tot butch list
has swupd && tot swupd bundle-list --quiet has swupd && tot swupd bundle-list --quiet
# Using the dnf package cache is much faster than rpm.
if has dnf && type -p sqlite3 >/dev/null && [[ -f /var/cache/dnf/packages.db ]]; then
pac "$(sqlite3 /var/cache/dnf/packages.db "SELECT count(pkg) FROM installed")"
else
has rpm && tot rpm -qa
fi
# 'mine' conflicts with minesweeper games. # 'mine' conflicts with minesweeper games.
[[ -f /etc/SDE-VERSION ]] && [[ -f /etc/SDE-VERSION ]] &&
has mine && tot mine -q has mine && tot mine -q