tazpkg view lib/tazpkgbox/search @ rev 200

tazpkgbox: extend get-* autoexec support to non-free
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 12 16:44:21 2008 +0000 (2008-11-12)
parents 6b1ec4c465a7
children d689a99ecd2d
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-installed
8 touch /tmp/tazpkgbox/search-installed
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 echo "$pkg|$version|$file"
21 done
22 }
24 if [ "$1" = "--files" ]; then
25 tazpkg search-file "$SEARCH" | list_files > \
26 /tmp/tazpkgbox/search-installed
27 tazpkg search-file "$SEARCH" --mirror | list_files > \
28 /tmp/tazpkgbox/search-mirrored
29 exit 0
30 fi
32 # Search installed.
33 for i in `ls /var/lib/tazpkg/installed`
34 do
35 . /var/lib/tazpkg/installed/$i/receipt
36 if echo "$PACKAGE $SHORT_DESC" | grep -q "$SEARCH"; then
37 echo "$PACKAGE|$VERSION|$SHORT_DESC" >> /tmp/tazpkgbox/search-installed
38 fi
39 done
41 # Search mirrored.
42 grep -sh "$SEARCH" /var/lib/tazpkg/packages.desc \
43 /var/lib/tazpkg/undigest/*/packages.desc | sort > /tmp/tazpkgbox/search-mirrored
45 exit 0