From 4974d6710103d2c5c0b61817b29739b5f8fbc4be Mon Sep 17 00:00:00 2001 From: sev Date: Fri, 2 Jul 2021 12:37:08 -0500 Subject: [PATCH] apkv: update doc, refine parsing, fix world check --- bin/apkv | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/apkv b/bin/apkv index 5e586a2..012d8e2 100755 --- a/bin/apkv +++ b/bin/apkv @@ -84,8 +84,6 @@ if [ "$method" = list ]; then # ignore getopt's --, we don't care if an arg begins with - anyway [ "$1" = '--' ] && switch >/dev/null - # OPTIMIZE: getting deps of virtual packages is slow, it would be - # great to use apk info -R from show_reqs in orphan loop all=$(apk info) # show packages if no args if [ $# -eq 0 ]; then @@ -94,22 +92,26 @@ if [ "$method" = list ]; then done fi # set all child packages of virtual packages as owned + # OPTIMIZE: getting deps of virtual packages is slow, it would be + # great to use apk info -R from show_reqs in orphan loop + # NOTE: since we don't have arrays in sh, set individual vars instead for v in $(echo "$all" | grep '^\.'); do for c in $(apk info -R $v | tail +2 | grep -v '^\.'); do # NOTE: use tr because shell may not have ksh-derived ${c//} - # XXX: package name may have illegal chars for variable name - # past those already replaced, and replacing chars may - # result in variable collision—but official apk repos do - # not have any packages that would cause issues + # XXX: have not verified if package name may have more illegal + # chars for variable name past those already replaced, and + # 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" done done # check world against owned packages - # TODO: notify user if package is in world and also a virtual package + # TODO: notify user if package is both in world and virtual package 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 ) @@ -186,7 +188,8 @@ else # remove packages from world if they are being moved to a virtual one del= for x in $pkgs; do - if apk info -e "$x" >/dev/null 2>&1; then + #apk_adb.c: [!]name[<,<=,<~,=,~,>~,>=,>,><]ver, @ for pinning + if grep -qE "^$x($|[<=~>@])" /etc/apk/world; then del="$del $x" fi done -- 2.47.0