xpm

x package manager, a uniform interface to various POSIX package managers
git clone git://src.gearsix.net/xpm
Log | Files | Refs | Atom | README

commit e9a3f50f74f15d625a3c5ef1cc9cacf26b122446
parent 8362ef88c9c9e3f69db7b3e6ded86e7fda597211
Author: gearsix <gearsix@tuta.io>
Date:   Tue, 15 Mar 2022 15:22:10 +0000

added TRACK_INSTALLED and set_xpm_query; renamed pm->xpm

Diffstat:
Mxpm.sh | 58+++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 47 insertions(+), 11 deletions(-)

diff --git a/xpm.sh b/xpm.sh @@ -1,26 +1,62 @@ #!/usr/bin/env sh -pm="" +xpm="" +TRACK_INSTALLED=1TRACK_INSTALLED_FILE=~/.local/share/xxpm/installed.txt +TRACK_INSTALLED_FILE=~/.local/share/xxpm/installed.txt -set_cmd_install() { - if [ $(command -v apt) ]; then pm="apt install" - elif [ $(command -v zypper) ]; then pm="zypper install" - elif [ $(command -v xbps-install" ]; then pm="xbps-install" +# track installed +track_installed_add() { + set_xpm_query + for pkg in $@; do + if [ -z $(xpm $pkg) ]; then + echo "$pkg was not installed" + else + echo "$pkg" >> "$TRACK_INSTALLED_FILE" + done +} + +track_installed_rm() { + for pkg in $@; do + if [ -z $(command -v "$pkg") ]; then + sed -i "/$pkg/d" "$TRACK_INSTALLED_FILE" + fi + done +} + +# x package manager +set_xpm_install() { + if [ $(command -v apt) ]; then xpm="apt install" + elif [ $(command -v zypper) ]; then xpm="zypper install" + elif [ $(command -v xbps-install) ]; then xpm="xbps-install -Rs" fi } -set_cmd_remove() { - if [ $(command -v apt) ]; then pm="apt purge" - elif [ $(command -v zypper) ]; then pm="zypper remove" - elif [ $(command -v xbps-remove ]; then pm="xbps-remove -R" +set_xpm_remove() { + if [ $(command -v apt) ]; then xpm="apt purge" + elif [ $(command -v zypper) ]; then xpm="zypper remove" + elif [ $(command -v xbps-remove ]; then xpm="xbps-remove -R" fi } +set_xpm_query() { + if [ $(command -v apt) ]; then xpm="apt list --installed" + elif [ $(command -v zypper) ]; then xpm="zypper search --installed-only" + elif [ $(command -v xbps-query) ]; then xpm="xbps-query -S" + fi +} + +# main case "$1") "i"|"in"|"install") - set_pm_install + shift + set_xpm_install ;; "r"|"rm"|"remove") - set_pm_remove + shift + set_xpm_remove + ;; + "q"|"qry"|"query") + shift + set_xpm_query ;; esac