tazpkg rev 873
modules/get: restore virtual packages support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Nov 28 11:35:12 2015 +0100 (2015-11-28) |
parents | 777cd60551cc |
children | 94233466b80c |
files | modules/get |
line diff
1.1 --- a/modules/get Mon Nov 23 12:23:15 2015 +0100 1.2 +++ b/modules/get Sat Nov 28 11:35:12 2015 +0100 1.3 @@ -278,6 +278,31 @@ 1.4 } 1.5 1.6 1.7 +# return possible name for a virtual package name 1.8 + 1.9 +virtual_pkg() { 1.10 + # input: $1 virtual package name 1.11 + # $2 repository db directory 1.12 + # outout: display possible package name 1.13 + 1.14 + local i 1.15 + for i in $(grep -hs "^$1=" "$2/packages.equiv" | sed "s/^$1=//"); do 1.16 + if echo $i | fgrep -q : ; then 1.17 + # format 'alternative:newname' 1.18 + # if alternative is installed then substitute newname 1.19 + if [ -f $2/installed/${i%:*}/receipt ]; then 1.20 + # substitute package dependency 1.21 + echo ${i#*:} 1.22 + return 1.23 + fi 1.24 + else 1.25 + # unconditional substitution 1.26 + echo $i 1.27 + return 1.28 + fi 1.29 + done 1.30 +} 1.31 + 1.32 # Download package file to the cache 1.33 1.34 get_pkg() { 1.35 @@ -293,8 +318,8 @@ 1.36 for rep in $PRIORITY; do 1.37 [ ! -f "$rep/packages.info" ] && continue 1.38 # If found, output string "<name>-<ver>:<sum>" 1.39 - line=$(awk -F$'\t' -vpkg="$1" \ 1.40 - '$1==pkg || $1"-"$2==pkg {printf "%s-%s:%s", $1, $2, $9; exit}' "$rep/packages.info") 1.41 + line=$(awk -F$'\t' -vpkg="$1" -vvpkg="$(virtual_pkg "$1" "$rep")" \ 1.42 + '$1==pkg || $1"-"$2==pkg || $1==vpkg || $1"-"$2==vpkg {printf "%s-%s:%s", $1, $2, $9; exit}' "$rep/packages.info") 1.43 if [ -n "$line" ]; then 1.44 namever=${line%:*}; pkgsum=${line#*:} 1.45 break