tazpkg diff modules/remove @ rev 887
module get: fix virtual packages support; module remove: provide virt. pkg. support, update system DBs; add test06 for virt. packages
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Dec 11 01:32:39 2015 +0200 (2015-12-11) |
parents | b278bf56267b |
children | d034a2d99e3a |
line diff
1.1 --- a/modules/remove Sat Nov 14 14:41:30 2015 +0200 1.2 +++ b/modules/remove Fri Dec 11 01:32:39 2015 +0200 1.3 @@ -59,9 +59,43 @@ 1.4 } 1.5 1.6 1.7 +# return possible name for a virtual package name 1.8 1.9 +virtual_pkg() { 1.10 + # input: $1 virtual package name 1.11 + # $2 repository db directory 1.12 + # output: display possible package name 1.13 1.14 -PACKAGE="$1" 1.15 + debug "\nvirtual_pkg('$1', '$2')" 1.16 + local i 1.17 + unset IFS 1.18 + for i in $(grep -hs "^$1=" "$2/packages.equiv" | sed "s/^$1=//"); do 1.19 + if echo $i | fgrep -q : ; then 1.20 + # format 'alternative:newname' 1.21 + # if alternative is installed then substitute newname 1.22 + if [ -f $INSTALLED/${i%:*}/receipt ]; then 1.23 + # substitute package dependency 1.24 + echo ${i#*:} 1.25 + return 1.26 + fi 1.27 + elif ! grep -q "^$1 " "$2/packages.info" || [ -f "$INSTALLED/$i/receipt" ]; then 1.28 + # unconditional substitution 1.29 + echo $i 1.30 + return 1.31 + fi 1.32 + done 1.33 + # the real package name 1.34 + echo $1 1.35 +} 1.36 + 1.37 + 1.38 + 1.39 + 1.40 +for rep in $PRIORITY; do 1.41 + [ ! -f "$rep/packages.info" ] && continue 1.42 + PACKAGE="$(virtual_pkg "$1" "$rep")" 1.43 + [ "$PACKAGE" != "$1" ] && break 1.44 +done 1.45 1.46 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then 1.47 newline; _ 'Package "%s" is not installed.' "$PACKAGE" 1.48 @@ -101,11 +135,11 @@ 1.49 # Removing package 1.50 title 'Removing package "%s"' "$PACKAGE" 1.51 1.52 -# [1/4] Pre-remove commands 1.53 +# [1/5] Pre-remove commands 1.54 call_pre_remove "$INSTALLED/$PACKAGE/receipt" 1.55 1.56 1.57 -# [2/4] Removing files 1.58 +# [2/5] Removing files 1.59 action 'Removing all files installed...' 1.60 1.61 # NOTE: package 'faenza-icon-theme' install time: 12s; removing time ~ 11min on my system o_O 1.62 @@ -168,10 +202,41 @@ 1.63 1.64 status 1.65 1.66 -# [3/4] Post-remove commands 1.67 +# [3/5] Post-remove commands 1.68 call_post_remove "$INSTALLED/$PACKAGE/receipt" 1.69 1.70 -# [4/4] Remove package receipt and remove it from databases 1.71 +# [4/5] Update system databases 1.72 +local fl="$INSTALLED/$PACKAGE/files.list" upd=0 udesk umime uicon uschm ukrnl 1.73 + 1.74 +fgrep /usr/share/applications/ "$fl" | fgrep -q .desktop && udesk='yes' 1.75 +fgrep -q /usr/share/mime "$fl" && umime='yes' 1.76 +fgrep -q /usr/share/icon/hicolor "$fl" && uicon='yes' 1.77 +fgrep -q /usr/share/glib-2.0/schemas "$fl" && uschm='yes' 1.78 +fgrep /usr/lib/gdk-pixbuf "$fl" | fgrep -q .so && upixb='yes' 1.79 +fgrep -q /lib/modules "$fl" && ukrnl='yes' 1.80 + 1.81 +if [ -n "$udesk$umime$uicon$uschm$upixb$ukrnl" ]; then 1.82 + action 'Update system databases...' 1.83 + upd=1 1.84 +fi 1.85 + 1.86 +# package 'desktop-file-utils' 1.87 +[ -n "$udesk" ] && chroot "$root/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null 1.88 +# package 'shared-mime-info' 1.89 +[ -n "$umime" ] && chroot "$root/" /usr/bin/update-mime-database /usr/share/mime 1.90 +# packages 'gtk+', 'gtk+3' 1.91 +[ -n "$uicon" ] && chroot "$root/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor 1.92 +# package 'glib' 1.93 +[ -n "$uschm" ] && chroot "$root/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 1.94 +# package 'gdk-pixbuf' 1.95 +[ -n "$upixb" ] && chroot "$root/" /usr/bin/gdk-pixbuf-query-loaders --update-cache 1.96 +# packages 'busybox', 'kmod', 'depmod' 1.97 +[ -n "$ukrnl" ] && grep '/lib/modules' "$fl" | cut -d'/' -f4 | uniq | xargs chroot "$root/" /sbin/depmod -a 1.98 + 1.99 +[ "$upd" -eq 1 ] && status 1.100 + 1.101 + 1.102 +# [5/5] Remove package receipt and remove it from databases 1.103 action 'Removing package receipt...' 1.104 rm -rf "$INSTALLED/$PACKAGE" 1.105 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg$/d" "$PKGS_DB/installed.$SUM"