spk view spk-ls @ rev 16

Improve Makefile, use lib in /usr/lib/slitaz
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 15 12:08:23 2012 +0200 (2012-05-15)
parents a1d998d5f6aa
children e5d4c5d3ccf4
line source
1 #!/bin/sh
2 #
3 # Spk-ls - List SliTaz packages and files. Read the README before adding or
4 # modifing 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 # Functions
13 #
15 # Help and usage
16 usage() {
17 name=$(basename $0)
18 cat << EOT
20 $(boldify $(gettext "Usage:")) $name [packages|--options]
22 $(gettext "List packages or installed files by packages")
24 $(boldify $(gettext "Options:"))
25 --count $(gettext "Display the number of installed packages")
26 --mirror $(gettext "List all the packages on mirror")
27 --blocked $(gettext "List all blocked packages")
28 --short ls: $(gettext "Short list of installed packages")
29 --debug $(gettext "Display some usefull debug information")
31 $(boldify $(gettext "Examples:"))
32 $name package1 package2 packageN
33 $name --count
35 EOT
36 exit 0
37 }
39 #
40 # Handle --options
41 #
43 for opt in $@
44 do
45 case "$opt" in
46 *usage|*help) usage ;;
47 --count)
48 count_installed
49 count_mirrored
50 exit 0 ;;
51 --mirror)
52 IFS="|"
53 cat $pkgsdesc | while read package version desc category
54 do
55 echo ""
56 gettext "Package :"; echo " $package"
57 gettext "Version :"; echo "$version"
58 gettext "Short desc :"; echo "$desc"
59 done && unset IFS
60 separator
61 count_mirrored
62 echo "" && exit 0 ;;
63 --blocked)
64 if [ -f "$blocked" ]; then
65 cat $blocked
66 else
67 gettext "No blocked packages"; echo ""
68 fi && exit 0 ;;
69 --short)
70 ls -1 $installed
71 boldify $(count_installed)
72 exit 0 ;;
73 --*) continue ;;
74 *)
75 # List installed files by the package.
76 count=0
77 for pkg in $@
78 do
79 [ -f "$installed/$pkg/files.list" ] || continue
80 count=$(($count + 1))
81 [ "$count" == 1 ] && newline
82 boldify $(gettext "Installed files by"; echo " $pkg")
83 separator
84 cat $installed/$pkg/files.list
85 files=$(wc -l $installed/$pkg/files.list | cut -d " " -f 1)
86 separator
87 gettext "Installed files by"; echo " $pkg : $files"
88 newline
89 done && exit 0 ;;
90 esac
91 done
93 #
94 # Parse all installed pkgs receipt.
95 #
97 boldify "$(gettext "Installed packages")"
98 separator
99 for pkg in $installed/*
100 do
101 unset_receipt
102 . $pkg/receipt
103 newline
104 receipt_info
105 done
106 separator
107 count_installed && newline
108 exit 0