tazpkg annotate modules/check @ rev 846

Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 09 13:14:01 2015 +0300 (2015-10-09)
parents d6cbd0c5f273
children 70ac720dba11
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@840 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 94 if [ ! -f "$PACKAGE/receipt" ]; then
al@840 95 print_pkgname
al@840 96 _ 'The package installation has not completed'
al@840 97 continue
al@840 98 fi
al@840 99
al@840 100 unset DEPENDS EXTRAVERSION
al@840 101 . "$PACKAGE/receipt"
al@840 102 if [ -s "$PACKAGE/modifiers" ]; then
al@840 103 print_pkgname
al@840 104 _ 'The package has been modified by:'
al@840 105 awk '{print " " $0}' "$PACKAGE/modifiers"
al@840 106 fi
al@840 107
al@840 108 MSG="$(_n 'Files lost from package:')\n"
al@840 109 while read file; do
al@840 110 [ -e "$file" ] && continue
al@840 111 if [ -L "$file" ]; then
al@840 112 MSG="$MSG $(_n 'target of symlink')"
al@840 113 fi
al@840 114 print_pkgname
al@840 115 echo -e "$MSG $file"
al@840 116 MSG=''
al@840 117 done < "$PACKAGE/files.list"
al@840 118
al@840 119 MSG="$(_n 'Missing dependencies for package:')\n"
al@840 120 for i in $DEPENDS; do
al@840 121 [ -d "$i" ] && continue
al@840 122 [ -d "$(equivalent_pkg "$i")" ] && continue
al@840 123 print_pkgname
al@840 124 echo -e "$MSG $i"
al@840 125 MSG=''
al@840 126 done
al@840 127
al@840 128 MSG="$(_n 'Dependencies loop between package and:')\n"
al@840 129 ALL_DEPS=''
al@840 130 check_for_deps_loop "$PACKAGE" "$DEPENDS"
al@840 131 done
al@840 132 [ -n "$PACKAGE_PRINTED" ] && footer
al@840 133
al@840 134 _ 'Looking for known bugs...'
al@840 135 if [ -z "$2" -o -n "$full" ]; then tazpkg bugs; else tazpkg bugs "$2"; fi
al@840 136
al@840 137
al@840 138 if [ -n "$full" ]; then
al@840 139 separator
al@840 140
al@840 141 title 'Mismatch checksum of installed files:'
al@840 142
al@840 143 for PACKAGE in $PACKAGES; do
al@840 144 file="$PACKAGE/$CHECKSUM"
al@840 145 CONFIG_FILES=''
al@840 146 . "$PACKAGE/receipt"
al@840 147 [ -s "$file" ] || continue
al@840 148 while read md5 f; do
al@840 149 [ -f "$f" ] || continue
al@840 150 for i in $CONFIG_FILES; do
al@840 151 case "$f" in
al@840 152 $i|$i/*) continue 2;;
al@840 153 esac
al@840 154 done
al@840 155 echo "$md5 $f"
al@846 156 done < "$file" | $CHECKSUM -c - 2>/dev/null | grep -v OK$ | sed "s/: FAILED$//"
al@840 157 done
al@840 158 footer
al@840 159
al@840 160 title 'Check file providers:'
al@840 161 FILES=' '
al@840 162 for PACKAGE in $PACKAGES; do
al@840 163 for file in $(cat "$PACKAGE/files.list"); do
al@840 164 [ -d "$file" ] && continue
al@840 165 case "$FILES" in
al@840 166 *\ $file\ *) continue;;
al@840 167 esac
al@840 168 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | wc -l) -gt 1 ] || continue
al@840 169 FILES="$FILES$file "
al@840 170 newline
al@840 171 _ 'The following packages provide file "%s":' "$file"
al@840 172 grep -l "^$(echo "$file" | grepesc)$" */files.list | \
al@840 173 while read f; do
al@840 174 pkg=${f%/files.list}
al@840 175 if [ -f "$pkg/modifiers" ]; then
al@840 176 overriders=$(_n '(overridden by %s)' "$(tr '\n' ' ' < $pkg/modifiers | sed 's| $||')")
al@840 177 else
al@840 178 overriders=''
al@840 179 fi
al@840 180 echo -n " * $pkg $overriders"
al@840 181 newline
al@840 182 done
al@840 183 done
al@840 184 done
al@840 185 footer
al@840 186
al@840 187 if [ -n "$full" ]; then
al@840 188 title 'Alien files:'
al@840 189 MSG="$(_n 'No package has installed the following files:')\n"
al@840 190 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
al@840 191 while read file; do
al@840 192 case "$file" in *\[*) continue;; esac
al@840 193 grep -q "^$(echo $file | grepesc)$" */files.list && continue
al@840 194 echo -e "$MSG $file"
al@840 195 MSG=''
al@840 196 done
al@840 197 footer
al@840 198 fi
al@840 199 fi
al@840 200 _ 'Check completed.'; newline