tazpkg annotate modules/check @ rev 955

modules/search: allow search file with dash at start: tazpkg -sf "-spi"
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 22 00:02:54 2017 +0200 (2017-12-22)
parents 70ac720dba11
children
rev   line source
al@840 1 #!/bin/sh
al@840 2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
al@840 3 # check - TazPkg module
al@840 4 # Check installed packages set
al@840 5
al@840 6
al@840 7 # Connect function libraries
al@840 8 . /lib/libtaz.sh
al@840 9
al@840 10 # Get TazPkg working environment
al@840 11 . @@MODULES@@/getenv
al@840 12
al@840 13
al@840 14
al@840 15
al@840 16 # Print package name if not printed yet
al@840 17 print_pkgname() {
al@840 18 if [ "$PACKAGE" != "$PACKAGE_PRINTED" ]; then
al@840 19 [ -n "$PACKAGE_PRINTED" ] && footer
al@840 20 title 'Package %s' "$PACKAGE-$VERSION$EXTRAVERSION"
al@840 21 PACKAGE_PRINTED="$PACKAGE"
al@840 22 fi
al@840 23 }
al@840 24
al@840 25
al@840 26 # get an already installed package from packages.equiv
al@840 27
al@840 28 equivalent_pkg() {
al@840 29 for i in $(grep -hs "^$1=" "$PKGS_DB/packages.equiv" \
al@840 30 "$PKGS_DB"/undigest/*/packages.equiv | sed "s/^$1=//"); do
al@840 31 if echo $i | fgrep -q : ; then
al@840 32 # format 'alternative:newname'
al@840 33 # if alternative is installed then substitute newname
al@840 34 if [ -f "$INSTALLED/${i%:*}/receipt" ]; then
al@840 35 # substitute package dependency
al@840 36 echo "${i#*:}"
al@840 37 return
al@840 38 fi
al@840 39 else
al@840 40 # if alternative is installed then nothing to install
al@840 41 if [ -f "$INSTALLED/$i/receipt" ]; then
al@840 42 # substitute installed package
al@840 43 echo "$i"
al@840 44 return
al@840 45 fi
al@840 46 fi
al@840 47 done
al@840 48 # if not found in packages.equiv then no substitution
al@840 49 echo "$1"
al@840 50 }
al@840 51
al@840 52
al@840 53 # Check for loop in deps tree.
al@840 54
al@840 55 check_for_deps_loop() {
al@840 56 local list pkg="$1" deps
al@840 57 shift
al@840 58 [ -n "$1" ] || return
al@840 59 list=''
al@840 60
al@840 61 # Filter out already processed deps
al@840 62 for i in $@; do
al@840 63 case " $ALL_DEPS" in
al@840 64 *\ $i\ *) ;;
al@840 65 *) list="$list $i";;
al@840 66 esac
al@840 67 done
al@840 68 ALL_DEPS="$ALL_DEPS$list "
al@840 69 for i in $list; do
al@840 70 [ -f "$i/receipt" ] || continue
al@950 71 deps="$(unset DEPENDS; . ./$i/receipt; echo $DEPENDS)"
al@840 72 case " $deps " in
al@840 73 *\ $pkg\ *)
al@840 74 print_pkgname
al@840 75 echo -e "$MSG $i"; MSG='';;
al@840 76 *)
al@840 77 check_for_deps_loop "$pkg" "$deps";;
al@840 78 esac
al@840 79 done
al@840 80 }
al@840 81
al@840 82
al@840 83 grepesc() { sed 's/\[/\\[/g'; }
al@840 84
al@840 85
al@840 86
al@840 87
al@840 88 cd "$INSTALLED"
al@840 89 if [ -z "$2" -o -n "$full" ]; then PACKAGES="$(ls)"; else PACKAGES="$2"; fi
al@840 90 PACKAGE_PRINTED=''
al@840 91
al@840 92 for PACKAGE in $PACKAGES; do
al@840 93
al@840