# HG changeset patch # User Aleksej Bobylev # Date 1495804737 -10800 # Node ID f2c91eb0a058f3507a9d8a3f7edfeb38271d7f31 # Parent 24e5d2229a915422fdaeb2f4779ea6939e2099bf modules/install: equivalent_pkg(): fix for --cookmode and --local diff -r 24e5d2229a91 -r f2c91eb0a058 modules/install --- a/modules/install Wed Feb 22 04:05:32 2017 +0200 +++ b/modules/install Fri May 26 16:18:57 2017 +0300 @@ -39,35 +39,55 @@ # get an already installed package from packages.equiv equivalent_pkg() { - # input: $1 = package name (like "nano") + # input: $1 = dependency package name (like "nano"); + # $2 = package path/name for which dependency tested local i rep rules rule out - rules=$(for rep in $PRIORITY; do - grep -hs "^$1=" "$rep/packages.equiv" - done | sed "s|^$1=||") - debug " >rules='$rules'" + if [ -n "$local" ]; then + # Search for virtual packages + if [ -n "$cookmode" ]; then + pi='/home/slitaz/packages/packages.info' + else + pi="$(dirname "$2")/packages.info" + fi + [ -f "$pi" ] && + out=$(awk -F$'\t' -vpkg="$1" '{ + # if package name or provided package name matched + if ($1 == pkg || index(" " $10 " ", " " pkg " ")) { print $1 } + }' "$pi") + for i in $out; do + # If package installed + [ -f "$PKGS_DB/installed/$i/receipt" ] && out="$i" && break + unset out + done + else + rules=$(for rep in $PRIORITY; do + grep -hs "^$1=" "$rep/packages.equiv" + done | sed "s|^$1=||") + debug " >rules='$rules'" - for rule in $rules; do - debug " >rule='$rule'" - case $rule in - *:*) - debug '-- x:x' - # format 'alternative:newname' - # if alternative is installed then substitute newname - out="${rule#*:}" - awk -F$'\t' -vp="${rule%:*}" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break - debug '-- x:x /' - ;; - *) - debug '-- x' - # unconditional substitution - out="$rule" - awk -F$'\t' -vp="$rule" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break - debug '-- x /' - ;; - esac - unset out - done + for rule in $rules; do + debug " >rule='$rule'" + case $rule in + *:*) + debug '-- x:x' + # format 'alternative:newname' + # if alternative is installed then substitute newname + out="${rule#*:}" + awk -F$'\t' -vp="${rule%:*}" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break + debug '-- x:x /' + ;; + *) + debug '-- x' + # unconditional substitution + out="$rule" + awk -F$'\t' -vp="$rule" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break + debug '-- x /' + ;; + esac + unset out + done + fi debug '--' # if not found in packages.equiv then no substitution echo "${out:-$1}" @@ -100,7 +120,7 @@ unset num missing_packages for depend in $DEPENDS; do debug " depend='$depend'" - equiv=$(equivalent_pkg $depend) + equiv=$(equivalent_pkg $depend "$1") debug " equiv='$equiv'\n" if [ ! -d "$INSTALLED/$equiv" ]; then missing_packages="$missing_packages $equiv" @@ -154,34 +174,44 @@ debug " let's install missing packages" for pkg in $missing_packages; do debug " pkg='$pkg'" - if [ ! -d "$INSTALLED/$pkg" ]; then - # Package not installed + [ -d "$INSTALLED/$pkg" ] && continue + # Package not installed - found='0' - # Prefer local packages - if [ -n "$local" ]; then - [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" - # Find local package + found='0'; namever=''; pkgfile='' + # Prefer local packages + if [ -n "$local" ]; then + [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" + # Find local package + if [ -f "$dir/packages.info" ]; then + # Packages database exists (should be everfresh!) + namever=$(awk -F$'\t' -vpkg="$pkg" '{ + # if package name or provided package name matched + if (index(" " $1 " " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; } + }' "$dir/packages.info") # = - + # Package file may be in form .tazpkg or -.tazpkg, so find one + [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg") + [ -n "$pkgfile" ] && found='1' + else + # Packages DB missing, proceed to sniff packages tempd="$(mktemp -d)"; cd "$tempd" for pkgfile in $dir/$pkg-*.tazpkg; do [ -e "$pkgfile" ] || continue # Extract receipt from each matched package cpio -F "$pkgfile" -i receipt >/dev/null 2>&1 name=$(. receipt; echo $PACKAGE) + [ "$name" == "$pkg" ] && found='1' && break + # Install the first matched package: normally there is only one package + # with the $PACKAGE matched in the receipt rm receipt - if [ "$name" == "$pkg" ]; then - found='1' - # Install the first matched package: normally there is only one package - # with the $PACKAGE matched in the receipt - tazpkg install "$pkgfile" - fi done rm -r "$tempd" fi - debug " found='$found'" + fi + debug " found='$found'" - # Install package from the mirror - [ "$found" -eq 0 ] && tazpkg get-install "$pkg" + if [ "$found" -eq 1 ] + then tazpkg install "$pkgfile" + else tazpkg get-install "$pkg" fi done else @@ -309,7 +339,7 @@ VERSION="$VERSION" EXTRAVERSION="$EXTRAVERSION" CATEGORY="$CATEGORY" -SHORT_DESC="$SHORT_DESC" +SHORT_DESC="${SHORT_DESC//\"/\"}" WEB_SITE="$WEB_SITE" TAGS="$TAGS" DEPENDS="$DEPENDS"