X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/4974d6710103d2c5c0b61817b29739b5f8fbc4be..4fa653d992e741dd96b3c58a265b2fb71cd8b0b7:/bin/apkv diff --git a/bin/apkv b/bin/apkv index 012d8e2..2a4d342 100755 --- a/bin/apkv +++ b/bin/apkv @@ -1,5 +1,5 @@ #!/bin/sh -# TODO: add duplicate checker to seeif a pkg is in multiple virtual pkgs +# TODO: add duplicate checker to see if a pkg is in multiple virtual pkgs prog=$(basename $0) usage() { @@ -13,8 +13,9 @@ Usage: $prog del Remove from virtual package . Empty virtual - packages are removed from world. The shorthand '$prog del * ' can - be used to empty . + packages are removed from world. The shorthand '$prog del * ' + can be used to empty , which is equivalent to + 'apk del ', though with special handling of leading dots. $prog list [-o | packages] List virtual packages and their contents. @@ -84,7 +85,7 @@ if [ "$method" = list ]; then # ignore getopt's --, we don't care if an arg begins with - anyway [ "$1" = '--' ] && switch >/dev/null - all=$(apk info) + all=$(apk info | sort) # show packages if no args if [ $# -eq 0 ]; then for x in $(echo "$all" | grep '^\.'); do @@ -103,7 +104,7 @@ if [ "$method" = list ]; then # replacing chars may result in variable collision—but # official apk repos do not have any package names that # would cause issues - eval "__$(echo $c | tr -s '.:-' _)=1" + eval "__$(echo $c | tr -s '.:+-' _ | tr -s '<=~>@' "\n" | head -1)=1" done done # check world against owned packages @@ -111,7 +112,7 @@ if [ "$method" = list ]; then orphans=$( for x in $(cat /etc/apk/world | grep -v '^\.'); do eval "[ \${__$( - echo $x | tr -s '.:-' _ | tr -s '<=~>@' "\n" | head -1 + echo $x | tr -s '.:+-' _ | tr -s '<=~>@' "\n" | head -1 )-0} -eq 0 ]" && echo $x done )