spk view spk-ls @ rev 18

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