# HG changeset patch # User Aleksej Bobylev # Date 1496667063 -10800 # Node ID dbf40347342acce4a2512103455fa203a7273596 # Parent f2c91eb0a058f3507a9d8a3f7edfeb38271d7f31 modules/get, modules/install: improve cookmode diff -r f2c91eb0a058 -r dbf40347342a modules/get --- a/modules/get Fri May 26 16:18:57 2017 +0300 +++ b/modules/get Mon Jun 05 15:51:03 2017 +0300 @@ -428,27 +428,20 @@ [ -e "/etc/slitaz/cook.conf" ] && . "/etc/slitaz/cook.conf" # Find local package - tempd="$(mktemp -d)"; cd "$tempd" + pkgfile="$(awk -F$'\t' -vpkg="$1" -vbase="$PKGS" '{ + if ($1 == pkg) { printf("%s/%s-%s.tazpkg", base, $1, $2); exit; } + }' $PKGS/packages.info)" - for pkgfile in $PKGS/$1-*.tazpkg; do - [ -e "$pkgfile" ] || continue - # Extract receipt from each matched package - cpio -F "$pkgfile" -i receipt >/dev/null 2>&1 - name=$(. receipt; echo $PACKAGE) - rm receipt - if [ "$name" == "$1" ]; then - # Use the first matched package: normally there is only one package - # with the $PACKAGE matched in the receipt - found='1' - # Output: path to found package and exit loop - echo "$pkgfile" - break - fi - done - rm -r "$tempd" + # Find local provided package + [ -n "$pkgfile" ] || + pkgfile="$(awk -F$'\t' -vpkg="$1" -vbase="$PKGS" '{ + if (index(" " $10 " ", " " pkg " ")) { printf("%s/%s-%s.tazpkg", base, $1, $2); exit; } + }' $PKGS/packages.info)" - # Proceed to get package as usual (non-local) - if [ "$found" -eq 0 ]; then + if [ -n "$pkgfile" ]; then + echo "$pkgfile" + else + # Proceed to get package as usual (non-local) get_pkg "$1" fi } diff -r f2c91eb0a058 -r dbf40347342a modules/install --- a/modules/install Fri May 26 16:18:57 2017 +0300 +++ b/modules/install Mon Jun 05 15:51:03 2017 +0300 @@ -181,13 +181,15 @@ # Prefer local packages if [ -n "$local" ]; then [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" + [ -n "$cookmode" ] && dir='/home/slitaz/packages' + pi="$dir/packages.info" # Find local package - if [ -f "$dir/packages.info" ]; then + if [ -f "$pi" ]; 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") # = - + }' "$pi") # = - # Package file may be in form .tazpkg or -.tazpkg, so find one [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg") [ -n "$pkgfile" ] && found='1'