tazpkg rev 945
modules/install: equivalent_pkg(): fix for --cookmode and --local
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri May 26 16:18:57 2017 +0300 (2017-05-26) |
parents | 24e5d2229a91 |
children | dbf40347342a |
files | modules/install |
line diff
1.1 --- a/modules/install Wed Feb 22 04:05:32 2017 +0200 1.2 +++ b/modules/install Fri May 26 16:18:57 2017 +0300 1.3 @@ -39,35 +39,55 @@ 1.4 # get an already installed package from packages.equiv 1.5 1.6 equivalent_pkg() { 1.7 - # input: $1 = package name (like "nano") 1.8 + # input: $1 = dependency package name (like "nano"); 1.9 + # $2 = package path/name for which dependency tested 1.10 local i rep rules rule out 1.11 1.12 - rules=$(for rep in $PRIORITY; do 1.13 - grep -hs "^$1=" "$rep/packages.equiv" 1.14 - done | sed "s|^$1=||") 1.15 - debug " >rules='$rules'" 1.16 + if [ -n "$local" ]; then 1.17 + # Search for virtual packages 1.18 + if [ -n "$cookmode" ]; then 1.19 + pi='/home/slitaz/packages/packages.info' 1.20 + else 1.21 + pi="$(dirname "$2")/packages.info" 1.22 + fi 1.23 + [ -f "$pi" ] && 1.24 + out=$(awk -F$'\t' -vpkg="$1" '{ 1.25 + # if package name or provided package name matched 1.26 + if ($1 == pkg || index(" " $10 " ", " " pkg " ")) { print $1 } 1.27 + }' "$pi") 1.28 + for i in $out; do 1.29 + # If package installed 1.30 + [ -f "$PKGS_DB/installed/$i/receipt" ] && out="$i" && break 1.31 + unset out 1.32 + done 1.33 + else 1.34 + rules=$(for rep in $PRIORITY; do 1.35 + grep -hs "^$1=" "$rep/packages.equiv" 1.36 + done | sed "s|^$1=||") 1.37 + debug " >rules='$rules'" 1.38 1.39 - for rule in $rules; do 1.40 - debug " >rule='$rule'" 1.41 - case $rule in 1.42 - *:*) 1.43 - debug '-- x:x' 1.44 - # format 'alternative:newname' 1.45 - # if alternative is installed then substitute newname 1.46 - out="${rule#*:}" 1.47 - awk -F$'\t' -vp="${rule%:*}" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break 1.48 - debug '-- x:x /' 1.49 - ;; 1.50 - *) 1.51 - debug '-- x' 1.52 - # unconditional substitution 1.53 - out="$rule" 1.54 - awk -F$'\t' -vp="$rule" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break 1.55 - debug '-- x /' 1.56 - ;; 1.57 - esac 1.58 - unset out 1.59 - done 1.60 + for rule in $rules; do 1.61 + debug " >rule='$rule'" 1.62 + case $rule in 1.63 + *:*) 1.64 + debug '-- x:x' 1.65 + # format 'alternative:newname' 1.66 + # if alternative is installed then substitute newname 1.67 + out="${rule#*:}" 1.68 + awk -F$'\t' -vp="${rule%:*}" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break 1.69 + debug '-- x:x /' 1.70 + ;; 1.71 + *) 1.72 + debug '-- x' 1.73 + # unconditional substitution 1.74 + out="$rule" 1.75 + awk -F$'\t' -vp="$rule" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break 1.76 + debug '-- x /' 1.77 + ;; 1.78 + esac 1.79 + unset out 1.80 + done 1.81 + fi 1.82 debug '--' 1.83 # if not found in packages.equiv then no substitution 1.84 echo "${out:-$1}" 1.85 @@ -100,7 +120,7 @@ 1.86 unset num missing_packages 1.87 for depend in $DEPENDS; do 1.88 debug " depend='$depend'" 1.89 - equiv=$(equivalent_pkg $depend) 1.90 + equiv=$(equivalent_pkg $depend "$1") 1.91 debug " equiv='$equiv'\n" 1.92 if [ ! -d "$INSTALLED/$equiv" ]; then 1.93 missing_packages="$missing_packages $equiv" 1.94 @@ -154,34 +174,44 @@ 1.95 debug " let's install missing packages" 1.96 for pkg in $missing_packages; do 1.97 debug " pkg='$pkg'" 1.98 - if [ ! -d "$INSTALLED/$pkg" ]; then 1.99 - # Package not installed 1.100 + [ -d "$INSTALLED/$pkg" ] && continue 1.101 + # Package not installed 1.102 1.103 - found='0' 1.104 - # Prefer local packages 1.105 - if [ -n "$local" ]; then 1.106 - [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" 1.107 - # Find local package 1.108 + found='0'; namever=''; pkgfile='' 1.109 + # Prefer local packages 1.110 + if [ -n "$local" ]; then 1.111 + [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg" 1.112 + # Find local package 1.113 + if [ -f "$dir/packages.info" ]; then 1.114 + # Packages database exists (should be everfresh!) 1.115 + namever=$(awk -F$'\t' -vpkg="$pkg" '{ 1.116 + # if package name or provided package name matched 1.117 + if (index(" " $1 " " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; } 1.118 + }' "$dir/packages.info") # <namever> = <package_name>-<package_version> 1.119 + # Package file may be in form <namever>.tazpkg or <namever>-<arch>.tazpkg, so find one 1.120 + [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg") 1.121 + [ -n "$pkgfile" ] && found='1' 1.122 + else 1.123 + # Packages DB missing, proceed to sniff packages 1.124 tempd="$(mktemp -d)"; cd "$tempd" 1.125 for pkgfile in $dir/$pkg-*.tazpkg; do 1.126 [ -e "$pkgfile" ] || continue 1.127 # Extract receipt from each matched package 1.128 cpio -F "$pkgfile" -i receipt >/dev/null 2>&1 1.129 name=$(. receipt; echo $PACKAGE) 1.130 + [ "$name" == "$pkg" ] && found='1' && break 1.131 + # Install the first matched package: normally there is only one package 1.132 + # with the $PACKAGE matched in the receipt 1.133 rm receipt 1.134 - if [ "$name" == "$pkg" ]; then 1.135 - found='1' 1.136 - # Install the first matched package: normally there is only one package 1.137 - # with the $PACKAGE matched in the receipt 1.138 - tazpkg install "$pkgfile" 1.139 - fi 1.140 done 1.141 rm -r "$tempd" 1.142 fi 1.143 - debug " found='$found'" 1.144 + fi 1.145 + debug " found='$found'" 1.146 1.147 - # Install package from the mirror 1.148 - [ "$found" -eq 0 ] && tazpkg get-install "$pkg" 1.149 + if [ "$found" -eq 1 ] 1.150 + then tazpkg install "$pkgfile" 1.151 + else tazpkg get-install "$pkg" 1.152 fi 1.153 done 1.154 else 1.155 @@ -309,7 +339,7 @@ 1.156 VERSION="$VERSION" 1.157 EXTRAVERSION="$EXTRAVERSION" 1.158 CATEGORY="$CATEGORY" 1.159 -SHORT_DESC="$SHORT_DESC" 1.160 +SHORT_DESC="${SHORT_DESC//\"/\"}" 1.161 WEB_SITE="$WEB_SITE" 1.162 TAGS="$TAGS" 1.163 DEPENDS="$DEPENDS"