spk view spk-find @ rev 137

spk-find: fix count
author Christophe Lincoln <pankso@slitaz.org>
date Sun Mar 30 18:34:55 2014 +0200 (2014-03-30)
parents aded92d8f7bf
children aeb1c73f12f3
line source
1 #!/bin/sh
2 #
3 # Spk-find - Find/search SliTaz packages and files. Read the README before
4 # adding or modifying any code in spk!
5 #
6 # Copyright (C) SliTaz GNU/Linux - BSD License
7 # Author: See AUTHORS files
8 #
9 . /usr/lib/slitaz/libspk.sh
11 #
12 # Quick coded tool to have a simple find/search packages tool for people
13 # using spk toolkit. TODO: find files, find in pkg desc for pattern, display
14 # status (installed or not).
15 #
17 find="$1"
18 count="/tmp/spk/count"
19 mkdir -p $(dirname $count)
21 #
22 # Functions
23 #
25 # Help and usage
26 usage() {
27 name=$(basename $0)
28 cat << EOT
30 $(boldify $(gettext "Usage:")) $name [package]
32 EOT
33 exit 0
34 }
36 case "$1" in
37 *help|usage) usage && exit 0 ;;
38 esac
40 newline
41 boldify $(gettext "Spk find: $find")
42 separator
44 IFS="|"
45 grep "$find" $pkgsdesc | while read pkg vers desc null
46 do
47 echo "$pkg" >> $count
48 echo -n "$pkg"; indent 16 "$desc"
49 done
50 unset IFS
52 if [ -f "$count" ]; then
53 count=$(cat $count | wc -l)
54 color=32
55 else
56 count=0
57 color=31
58 fi
59 separator
60 boldify "Packages found: $(colorize $color $count)" && newline
61 rm -rf $count
62 exit 0