tazpkg annotate lib/tazpkgbox/search @ rev 169
tazpkgbox: search-file show package version
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Oct 17 11:10:56 2008 +0000 (2008-10-17) |
parents | d5a396f43942 |
children | 6a18ba183660 |
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@81 | 7 rm -f /tmp/tazpkgbox/search-installed |
pankso@81 | 8 touch /tmp/tazpkgbox/search-installed |
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@169 | 18 version=$(grep "^$pkg " /var/lib/tazpkg/packages.desc | \ |
pascal@169 | 19 awk '{ print $3 }' ) |
pascal@169 | 20 echo "$pkg|$version|$file" |
pascal@169 | 21 done |
pascal@100 | 22 } |
pascal@100 | 23 |
pascal@100 | 24 if [ "$1" = "--files" ]; then |
pascal@100 | 25 tazpkg search-file "$SEARCH" | list_files > \ |
pascal@100 | 26 /tmp/tazpkgbox/search-installed |
pascal@101 | 27 tazpkg search-file "$SEARCH" --mirror | list_files > \ |
pascal@100 | 28 /tmp/tazpkgbox/search-mirrored |
pascal@100 | 29 exit 0 |
pascal@100 | 30 fi |
pascal@100 | 31 |
pankso@81 | 32 # Search installed. |
pankso@81 | 33 for i in `ls /var/lib/tazpkg/installed` |
pankso@81 | 34 do |
pankso@81 | 35 . /var/lib/tazpkg/installed/$i/receipt |
pankso@81 | 36 if echo "$PACKAGE $SHORT_DESC" | grep -q "$SEARCH"; then |
pankso@81 | 37 echo "$PACKAGE|$VERSION|$SHORT_DESC" >> /tmp/tazpkgbox/search-installed |
pankso@81 | 38 fi |
pankso@81 | 39 done |
pankso@81 | 40 |
pankso@81 | 41 # Search mirrored. |
pankso@81 | 42 grep "$SEARCH" /var/lib/tazpkg/packages.desc > /tmp/tazpkgbox/search-mirrored |
pankso@81 | 43 |
pankso@81 | 44 exit 0 |