tazpkg annotate lib/tazpkgbox/search @ rev 189
Add undigest support for tazpkgbox/search
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Oct 28 12:32:30 2008 +0000 (2008-10-28) |
parents | 6b1ec4c465a7 |
children | d689a99ecd2d |
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@189 | 18 version=$(grep -hs "^$pkg " /var/lib/tazpkg/packages.desc \ |
pascal@189 | 19 /var/lib/tazpkg/undigest/*/packages.desc | 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. |
pascal@189 | 42 grep -sh "$SEARCH" /var/lib/tazpkg/packages.desc \ |
pascal@189 | 43 /var/lib/tazpkg/undigest/*/packages.desc | sort > /tmp/tazpkgbox/search-mirrored |
pankso@81 | 44 |
pankso@81 | 45 exit 0 |