spk view spk-ls @ rev 58

spk: show package log with --log
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 17 15:49:44 2012 +0200 (2012-05-17)
parents c067cf3860e1
children 36c7fb7707d0
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 $(gettext "Short list of installed packages")
29 --root= $(gettext "Set the root file system path")
30 --color=NB $(gettext "Set package name color in list")
31 --debug $(gettext "Display some usefull debug information")
33 $(boldify $(gettext "Examples:"))
34 $name package1 package2 packageN
35 $name --short --color=33
37 EOT
38 exit 0
39 }
41 #
42 # Handle --options
43 #
45 for opt in $@
46 do
47 case "$opt" in
48 *usage|*help) usage ;;
49 --count)
50 count_installed
51 count_mirrored
52 exit 0 ;;
53 --mirror)
54 IFS="|"
55 cat $pkgsdesc | while read package version desc category
56 do
57 newline
58 gettext "Package :"; colorize " $package" 32
59 gettext "Version :"; echo "$version"
60 gettext "Short desc :"; echo "$desc"
61 done && unset IFS
62 separator
63 boldify $(count_mirrored)
64 echo "" && exit 0 ;;
65 --blocked)
66 if [ -f "$blocked" ]; then
67 cat $blocked
68 else
69 gettext "No blocked packages"; echo ""
70 fi && exit 0 ;;
71 --short)
72 newline
73 boldify "$(gettext "Installed packages")"
74 separator
75 for pkg in $(ls -1 $installed)
76 do
77 . $installed/$pkg/receipt
78 echo -n "$(colorize "$pkg" 32)"; indent 28 " $VERSION"
79 done
80 separator
81 boldify $(count_installed)
82 newline && exit 0 ;;
83 --*) continue ;;
84 *)
85 # List installed files by the package.
86 count=0
87 for pkg in $@
88 do
89 [ -f "$installed/$pkg/files.list" ] || continue
90 count=$(($count + 1))
91 [ "$count" == 1 ] && newline
92 boldify $(gettext "Installed files by"; echo " $pkg")
93 separator
94 cat $installed/$pkg/files.list
95 files=$(wc -l $installed/$pkg/files.list | cut -d " " -f 1)
96 separator
97 gettext "Installed files by"; echo " $pkg : $files"
98 newline
99 done && exit 0 ;;
100 esac
101 done
103 #
104 # Parse all installed pkgs receipt.
105 #
107 count=0
109 newline
110 boldify "$(gettext "Installed packages")"
111 separator
112 for pkg in $installed/*
113 do
114 unset_receipt
115 . $pkg/receipt
116 count=$(($count + 1))
117 [ "$count" != 1 ] && newline
118 gettext "Package :"; colorize " $PACKAGE" 32
119 receipt_info
120 done
121 separator
122 boldify $(count_installed) && newline
123 exit 0