tazpkg view lib/tazpkgbox/search @ rev 239

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