tazpkg annotate lib/tazpkgbox/search @ rev 233
tazpkgbox: improved search tab and engine and add new tazpkg-installed icon
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 25 22:03:25 2009 +0100 (2009-02-25) |
parents | 6a18ba183660 |
children | 690b91307c07 |
rev | line source |
---|---|
pankso@81 | 1 #!/bin/sh |
pankso@81 | 2 # |
MikeDSmith25@135 | 3 # This script provides a suitable output for the search results. |
pankso@81 | 4 # |
pankso@81 | 5 |
pankso@81 | 6 # Clean preview results. |
pankso@233 | 7 rm -f /tmp/tazpkgbox/search |
pankso@233 | 8 touch /tmp/tazpkgbox/search |
pankso@81 | 9 |
pascal@100 | 10 list_files() |
pascal@100 | 11 { |
pascal@100 | 12 sed 's/.\[[01]m//g' | awk 'BEGIN { show=0 } { |
pascal@100 | 13 if (/^===/) show=1-show; |
pascal@100 | 14 else if (/^Package/) pkg=$2; |
pascal@169 | 15 else if ($0 != "" && show != 0) printf("%s %s\n",pkg,$0); |
pascal@169 | 16 }' | while read pkg file; do |
pascal@169 | 17 [ "$pkg" = "0" ] && continue |
pascal@189 | 18 version=$(grep -hs "^$pkg " /var/lib/tazpkg/packages.desc \ |
pascal@189 | 19 /var/lib/tazpkg/undigest/*/packages.desc | awk '{ print $3 }') |
pankso@233 | 20 if [ -d /var/lib/tazpkg/installed/$pkg ]; then |
pankso@233 | 21 if [ -f $file ]; then |
pankso@233 | 22 echo "txt|$pkg|$version|$file" |
pankso@233 | 23 elif [ -d $file ] ; then |
pankso@233 | 24 echo "folder|$pkg|$version|$file" |
pankso@233 | 25 elif [ -x $file ]; then |
pankso@233 | 26 echo "exec|$pkg|$version|$file" |
pankso@233 | 27 else |
pankso@233 | 28 # Missing installed file. |
pankso@233 | 29 echo "dialog-warning|$pkg|$version|$file" |
pankso@233 | 30 fi |
pankso@233 | 31 else |
pankso@233 | 32 echo "tazpkg|$pkg|$version|$file" |
pankso@233 | 33 fi |
pascal@169 | 34 done |
pascal@100 | 35 } |
pascal@100 | 36 |
pankso@233 | 37 search_package() |
pankso@233 | 38 { |
pankso@233 | 39 IFS="|" |
pankso@233 | 40 cat /var/lib/tazpkg/packages.desc \ |
pankso@233 | 41 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | sort | \ |
pankso@233 | 42 while read PACKAGE VERSION SHORT_DESC; do |
pankso@233 | 43 if echo "$PACKAGE $SHORT_DESC" | grep -q "$SEARCH"; then |
pankso@233 | 44 if [ -d /var/lib/tazpkg/installed/${PACKAGE%% *} ]; then |
pankso@233 | 45 . /var/lib/tazpkg/installed/${PACKAGE%% *}/receipt |
pankso@233 | 46 echo "tazpkg-installed|$PACKAGE|$VERSION|$SHORT_DESC" |
pankso@233 | 47 else |
pankso@233 | 48 echo "tazpkg|$PACKAGE|$VERSION|$SHORT_DESC" |
pankso@233 | 49 fi |
pankso@233 | 50 fi |
pankso@233 | 51 done |
pankso@233 | 52 unset IFS |
pankso@233 | 53 } |
pascal@100 | 54 |
pankso@233 | 55 case "$1" in |
pankso@233 | 56 files) |
pankso@233 | 57 tazpkg search-file "$SEARCH" --mirror | list_files > \ |
pankso@233 | 58 /tmp/tazpkgbox/search ;; |
pankso@233 | 59 packages) |
pankso@233 | 60 search_package > /tmp/tazpkgbox/search ;; |
pankso@233 | 61 *) |
pankso@233 | 62 echo "Usage: $0 [packages|files]" ;; |
pankso@233 | 63 esac |
pankso@81 | 64 |
pankso@81 | 65 |
pankso@81 | 66 exit 0 |