spk view spk-ls @ rev 64
spk-archive: be busybox ash compatible
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri May 18 03:19:51 2012 +0200 (2012-05-18) |
parents | daf5adaaa87b |
children | 0cb21eb5cf20 |
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 --extra $(gettext "List packages on extra mirrors ")
28 --blocked $(gettext "List all blocked packages")
29 --short $(gettext "Short packages list format")
30 --modifiers $(gettext "List package modifiers")
31 --root= $(gettext "Set the root file system path")
32 --color=NB $(gettext "Set package name color in list")
33 --debug $(gettext "Display some usefull debug information")
35 $(boldify $(gettext "Examples:"))
36 $name package1 package2 packageN
37 $name --short --color=33
39 EOT
40 exit 0
41 }
43 #
44 # Handle --options
45 #
47 for opt in $@
48 do
49 case "$opt" in
50 *usage|*help) usage ;;
51 --count)
52 count_installed
53 count_mirrored
54 exit 0 ;;
55 --mirror)
56 newline
57 boldify "$(gettext "Mirror") $(cat $mirrorurl)"
58 read_pkgsdesc $pkgsdesc
59 separator
60 boldify $(count_mirrored)
61 newline && exit 0 ;;
62 --extra)
63 [ -d "$extradb" ] || exit 1
64 for extra in $extradb/*
65 do
66 newline
67 boldify "$(gettext "Extra mirror")"
68 if [ ! -f "$extra/packages.desc" ]; then
69 echo "URL: $(cat $extra/mirror)"
70 gettext "Missing:"; colorize " packages.desc" 31
71 continue
72 fi
73 separator
74 read_pkgsdesc $extra/packages.desc
75 separator
76 boldify $(echo -n "$(cat $extra/packages.$SUM | wc -l) "
77 gettext "packages in:"; echo " $(basename $extra)")
78 newline
79 done
80 exit 0 ;;
81 --blocked)
82 if [ -s "$blocked" ]; then
83 cat $blocked
84 else
85 gettext "No blocked packages"; echo ""
86 fi && exit 0 ;;
87 --short)
88 newline
89 boldify "$(gettext "Installed packages")"
90 separator
91 for pkg in $(ls -1 $installed)
92 do
93 . $installed/$pkg/receipt
94 echo -n "$(colorize "$pkg" 32)"; indent 28 " $VERSION"
95 done
96 separator
97 boldify $(count_installed)
98 newline && exit 0 ;;
99 --*) continue ;;
100 *)
101 # List installed files by the package.
102 count=0
103 for pkg in $@
104 do
105 [ -f "$installed/$pkg/files.list" ] || continue
106 nb=$(cat $installed/$pkg/files.list | wc -l)
107 count=$(($count + 1))
108 [ "$count" == 1 ] && newline
109 # List modifiers
110 if [ "$modifiers" ]; then
111 modifiers=$installed/$pkg/modifiers
112 if [ -f "$modifiers" ]; then
113 boldify "$(gettext "Modifiers for") $pkg"
114 separator
115 cat $modifiers
116 separator && newline
117 else
118 echo -n "$(boldify "$pkg") "
119 gettext "package was not modified"; newline
120 fi
121 continue
122 fi
123 boldify $(gettext "Installed files by"; echo " $pkg")
124 separator
125 cat $installed/$pkg/files.list
126 separator
127 gettext "Installed files by"; echo -n " $pkg: "
128 colorize "$nb" 32 && newline
129 done && exit 0 ;;
130 esac
131 done
133 #
134 # Parse all installed pkgs receipt.
135 #
137 count=0
139 newline
140 boldify "$(gettext "Installed packages")"
141 separator
142 for pkg in $installed/*
143 do
144 unset_receipt
145 . $pkg/receipt
146 count=$(($count + 1))
147 [ "$count" != 1 ] && newline
148 gettext "Package :"; colorize " $PACKAGE" 32
149 receipt_info
150 done
151 separator
152 boldify $(count_installed) && newline
153 exit 0