tazpkg rev 946
modules/get, modules/install: improve cookmode
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Jun 05 15:51:03 2017 +0300 (2017-06-05) |
parents | f2c91eb0a058 |
children | a088eca9e183 |
files | modules/get modules/install |
line diff
1.1 --- a/modules/get Fri May 26 16:18:57 2017 +0300 1.2 +++ b/modules/get Mon Jun 05 15:51:03 2017 +0300 1.3 @@ -428,27 +428,20 @@ 1.4 [ -e "/etc/slitaz/cook.conf" ] && . "/etc/slitaz/cook.conf" 1.5 1.6 # Find local package 1.7 - tempd="$(mktemp -d)"; cd "$tempd" 1.8 + pkgfile="$(awk -F$'\t' -vpkg="$1" -vbase="$PKGS" '{ 1.9 + if ($1 == pkg) { printf("%s/%s-%s.tazpkg", base, $1, $2); exit; } 1.10 + }' $PKGS/packages.info)" 1.11 1.12 - for pkgfile in $PKGS/$1-*.tazpkg; do 1.13 - [ -e "$pkgfile" ] || continue 1.14 - # Extract receipt from each matched package 1.15 - cpio -F "$pkgfile" -i receipt >/dev/null 2>&1 1.16 - name=$(. receipt; echo $PACKAGE) 1.17 - rm receipt 1.18 - if [ "$name" == "$1" ]; then 1.19 - # Use the first matched package: normally there is only one package 1.20 - # with the $PACKAGE matched in the receipt 1.21 - found='1' 1.22 - # Output: path to found package and exit loop 1.23 - echo "$pkgfile" 1.24 - break 1.25 - fi 1.26 - done 1.27 - rm -r "$tempd" 1.28 + # Find local provided package 1.29 + [ -n "$pkgfile" ] || 1.30 + pkgfile="$(awk -F$'\t' -vpkg="$1" -vbase="$PKGS" '{ 1.31 + if (index(" " $10 " ", " " pkg " ")) { printf("%s/%s-%s.tazpkg", base, $1, $2); exit; } 1.32 + }' $PKGS/packages.info)" 1.33 1.34 - # Proceed to get package as usual (non-local) 1.35 - if [ "$found" -eq 0 ]; then 1.36 + if [ -n "$pkgfile" ]; then 1.37 + echo "$pkgfile" 1.38 + else 1.39 + # Proceed to get package as usual (non-local) 1.40 get_pkg "$1" 1.41 fi 1.42 }
2.1 --- a/modules/install Fri May 26 16:18:57 2017 +0300 2.2 +++ b/modules/install Mon Jun 05 15:51:03 2017 +0300 2.3 @@ -181,13 +181,15 @@ 2.4 # Prefer local packages 2.5 if [ -n "$local" ]; then 2.6 [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" 2.7 + [ -n "$cookmode" ] && dir='/home/slitaz/packages' 2.8 + pi="$dir/packages.info" 2.9 # Find local package 2.10 - if [ -f "$dir/packages.info" ]; then 2.11 + if [ -f "$pi" ]; then 2.12 # Packages database exists (should be everfresh!) 2.13 namever=$(awk -F$'\t' -vpkg="$pkg" '{ 2.14 # if package name or provided package name matched 2.15 if (index(" " $1 " " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; } 2.16 - }' "$dir/packages.info") # <namever> = <package_name>-<package_version> 2.17 + }' "$pi") # <namever> = <package_name>-<package_version> 2.18 # Package file may be in form <namever>.tazpkg or <namever>-<arch>.tazpkg, so find one 2.19 [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg") 2.20 [ -n "$pkgfile" ] && found='1'