spk rev 52
libspk.sh: full_package can be more efficient
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 17 10:07:40 2012 +0200 (2012-05-17) |
parents | 1d9559a4f75b |
children | 917a909ee92b |
files | lib/libspk.sh |
line diff
1.1 --- a/lib/libspk.sh Thu May 17 09:32:47 2012 +0200 1.2 +++ b/lib/libspk.sh Thu May 17 10:07:40 2012 +0200 1.3 @@ -65,7 +65,7 @@ 1.4 1.5 is_package_mirrored() { 1.6 local name=$1 1.7 - local occurance=$(cat $pkgsdesc | grep "$name ") 1.8 + local occurance=$(fgrep "$name |" $pkgsdesc) 1.9 [ -n "$occurance" ] 1.10 } 1.11 1.12 @@ -80,23 +80,17 @@ 1.13 wget -c ${mirror%/}/$package ;; 1.14 esac 1.15 if [ ! -f "$package" ]; then 1.16 - echo "ERROR: Missing package $package" 1.17 - exit 1 1.18 + gettext "ERROR: Missing package $package"; newline 1.19 + newline && exit 1 1.20 fi 1.21 } 1.22 1.23 # Assume package name is valid 1.24 -# There may be a more efficient way to do this... 1.25 full_package() { 1.26 - local name=$1 1.27 - local occurance=$(cat $pkgsdesc | grep "$name ") 1.28 - local count=0 1.29 - for i in $(echo $occurance | tr "|" "\n"); do 1.30 - if [ $count -eq 1 ]; then 1.31 - echo $name-$i && return 1.32 - fi 1.33 - count=$(($count+1)) 1.34 - done 1.35 + IFS="|" 1.36 + local line="$(grep "^$1 |" $pkgsdesc)" 1.37 + echo $line | busybox awk '{print $1 "-" $2}' 1.38 + unset IFS 1.39 } 1.40 1.41 # Check if a package is already installed.