tazpkg rev 941
modules/get: add get_pkg_cookmode() to co-work with the cookutils.
Found package in the local repo /home/slitaz/packages when --cookmode option provided.
Found package in the local repo /home/slitaz/packages when --cookmode option provided.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Feb 10 00:44:26 2017 +0200 (2017-02-10) |
parents | 9e271be1090b |
children | d3dbbb43ec78 |
files | modules/get |
line diff
1.1 --- a/modules/get Wed Feb 08 05:32:39 2017 +0200 1.2 +++ b/modules/get Fri Feb 10 00:44:26 2017 +0200 1.3 @@ -416,6 +416,44 @@ 1.4 } 1.5 1.6 1.7 +# Get local package from /home/slitaz/packages to co-work with the cookutils 1.8 + 1.9 +get_pkg_cookmode() { 1.10 + # input: $1 package name (like 'advancecomp') 1.11 + # action: find package in /home/slitaz/packages (or where defined in the cook.conf) 1.12 + # output: full path to the found package 1.13 + # ROOT NOT USED 1.14 + 1.15 + local PKGS='/home/slitaz/packages' found='0' 1.16 + [ -e "/etc/slitaz/cook.conf" ] && . "/etc/slitaz/cook.conf" 1.17 + 1.18 + # Find local package 1.19 + tempd="$(mktemp -d)"; cd "$tempd" 1.20 + 1.21 + for pkgfile in $PKGS/$1-*.tazpkg; do 1.22 + [ -e "$pkgfile" ] || continue 1.23 + # Extract receipt from each matched package 1.24 + cpio -F "$pkgfile" -i receipt >/dev/null 2>&1 1.25 + name=$(. receipt; echo $PACKAGE) 1.26 + rm receipt 1.27 + if [ "$name" == "$1" ]; then 1.28 + # Use the first matched package: normally there is only one package 1.29 + # with the $PACKAGE matched in the receipt 1.30 + found='1' 1.31 + # Output: path to found package and exit loop 1.32 + echo "$pkgfile" 1.33 + break 1.34 + fi 1.35 + done 1.36 + rm -r "$tempd" 1.37 + 1.38 + # Proceed to get package as usual (non-local) 1.39 + if [ "$found" -eq 0 ]; then 1.40 + get_pkg "$1" 1.41 + fi 1.42 +} 1.43 + 1.44 + 1.45 1.46 1.47 # Command 'get-install' calls 'get', then 'install' modules. Check package presence here, on the 1.48 @@ -441,7 +479,11 @@ 1.49 fi 1.50 fi 1.51 1.52 -if [ -n "$extra" ]; then 1.53 +if [ -n "$cookmode" ]; then 1.54 + # When '--cookmode' option given, try to find package in the local cook repository, 1.55 + # then, if fails, try to get the package as usual 1.56 + get_pkg_cookmode "$1" 1.57 +elif [ -n "$extra" ]; then 1.58 # When '--extra' option given, extra-package has priority over 'regular' packages 1.59 get_pkg_extra "$1" 1.60 else