tazpkg view lib/tazpkgbox/package_infos @ rev 210

tazpkgbox: display package config files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 23 20:44:37 2008 +0000 (2008-11-23)
parents 7b6eebb50244
children 2f8faaf570c5
line source
1 #!/bin/sh
2 #
3 # Dialog box to provide package info and actions
4 #
6 XTERM_OPTS="-geometry 80x16+120+120"
8 PKG=`cat /tmp/tazpkgbox/pkg | sed s/" "/""/g`
9 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
11 if [ "$1" = "info" ]; then
12 RECEIPT=/var/lib/tazpkg/installed/$3/receipt
13 . $RECEIPT
14 case "$2" in
15 Web*) firefox $WEB_SITE &;;
16 Hand*) firefox $HANDBOOK_URL &;;
17 Sug*) $0 list_packages $SUGGESTED;;
18 Dep*) $0 list_packages $DEPENDS;;
19 Mod*) $0 list_packages $(xargs echo < /var/lib/tazpkg/installed/$3/modifiers);;
20 Con*) tazpkgbox list_config $3;;
21 Ver*) xterm -T "$3 receipt (q to quit)" -e "cat $RECEIPT | less";;
22 esac
23 exit 0
24 fi
26 if [ "$1" = "list_files" ]; then
27 AWK_FILTER='BEGIN { ls=0 } { if (/^===/) ls=1-ls; else if (ls) print; }'
28 CONF_FILES="$(tazpkg list-config $2 | awk "$AWK_FILTER")"
29 if [ -n "$CONF_FILES" ]; then
30 mkdir $TMP_DIR
31 zcat /var/lib/tazpkg/installed/$2/volatile.cpio.gz | \
32 ( cd $TMP_DIR ; cpio -id > /dev/null )
33 fi
34 tazpkg list-files $2 | awk "$AWK_FILTER" | while read file; do
35 echo -n "$(stat -c "%A|%U|%G|%s|%n|" "$file" || \
36 echo "File lost !||||$file|")"
37 if [ -L "$file" ]; then
38 echo -n "$(readlink "$file")"
39 elif [ -f "$file" ]; then
40 case "$CONF_FILES" in
41 *$file*)
42 if cmp $file $TMP_DIR$file > /dev/null 2>&1; then
43 echo -n "[configuration]"
44 else
45 echo -n "$(stat -c "[configuration: %.16y]" $file)"
46 fi;;
47 #* if [ "$(tazpkg check-file $file $2)" = "failure" ]; then
48 # echo -n "Invalid md5"
49 # fi;;
50 esac
51 fi
52 echo ""
53 done
54 [ -n "$CONF_FILES" ] && rm -rf $TMP_DIR
55 exit 0
56 fi
58 if [ "$1" = "list_files_mirror" ]; then
59 for i in /var/lib/tazpkg/files.list.lzma \
60 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
61 [ -f $i ] || continue
62 unlzma -c $i
63 done | grep -- "^$2:" | awk '{ print substr($0,index($0,":")+2) }'
64 exit 0
65 fi
67 if [ "$1" = "list_packages" ]; then
68 PKG="$2"
69 if [ -n "$3" ]; then
70 shift
71 export LIST_PKGS='
72 <window title="Packages" icon-name="tazpkg">
73 <vbox>
74 <tree>
75 <width>600</width><height>160</height>
76 <label>Package|Version|Size|Description</label>
77 <variable>PKG</variable>
78 '
79 for i in "$@"; do
80 if [ -d /var/lib/tazpkg/installed/$i ]; then
81 . /var/lib/tazpkg/installed/$i/receipt
82 LIST_PKGS="$LIST_PKGS
83 <item icon=\"tazpkg\">$i|$VERSION|Installed|$SHORT_DESC</item>
84 "
85 else
86 RES=`grep -sh "^$i " \
87 /var/lib/tazpkg/packages.desc \
88 /var/lib/tazpkg/undigest/*/packages.desc`
89 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
90 VERSION=`echo "$RES" | cut -d "|" -f 2`
91 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
92 SIZE=`grep -sh -A 3 "^$(echo $PACKAGE)$" \
93 /var/lib/tazpkg/packages.txt \
94 /var/lib/tazpkg/undigest/*/packages.txt | \
95 tail -1 | sed 's/.*(\(.*\) .*/\1/'`
96 LIST_PKGS="$LIST_PKGS
97 <item icon=\"tazpkg\">$i|$VERSION|$SIZE|$SHORT_DESC</item>
98 "
99 fi
100 done
101 LIST_PKGS="$LIST_PKGS
102 <action>echo "\$PKG" > /tmp/tazpkgbox/pkg</action>
103 <action>/usr/lib/slitaz/tazpkgbox/package_infos</action>
104 <action>refresh:PKG</action>
105 <action>refresh:PKG_STATS</action>
106 <action>refresh:CACHE_STATS</action>
107 </tree>
108 <hbox>
109 <button ok>
110 </button>
111 <button cancel>
112 <action type=\"closewindow\">LIST_PKGS</action>
113 </button>
114 </hbox>
115 </vbox>
116 </window>
117 "
118 eval `gtkdialog --center --program=LIST_PKGS`
119 [ "$EXIT" = "OK" ] || exit 0
120 fi
121 fi
123 export LIST_FILES="
124 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
125 <vbox>
126 <tree exported_column=\"4\">
127 <variable>FILE</variable>
128 <width>600</width><height>160</height>
129 <label>Access | User | Group | Size | Name | Target</label>
130 <input> $0 list_files $PKG </input>
131 <action>tazpkg list-config $PKG | grep -q ^\$FILE$ && leafpad \$FILE</action>
132 </tree>
133 <hbox>
134 <button>
135 <input file icon=\"gtk-close\"></input>
136 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
137 </button>
138 </hbox>
139 </vbox>
140 </window>
141 "
143 export LIST_FILES_MIRROR="
144 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
145 <vbox>
146 <tree>
147 <width>300</width><height>160</height>
148 <label>File Name</label>
149 <input> $0 list_files_mirror $PKG </input>
150 </tree>
151 <hbox>
152 <button>
153 <input file icon=\"gtk-close\"></input>
154 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
155 </button>
156 </hbox>
157 </vbox>
158 </window>
159 "
161 # Installed or not installed, that the question.
162 if [ -d /var/lib/tazpkg/installed/$PKG ]; then
163 PACKED_SIZE=""
164 DEPENDS=""
165 MAINTAINER=""
166 BUGS=""
167 . /var/lib/tazpkg/installed/$PKG/receipt
168 MAINTAINER=$(echo "$MAINTAINER" | sed 's/[<>|]/ /g')
169 PACKAGE_INFOS="
170 <window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
171 <vbox>
173 <tree>
174 <width>460</width><height>200</height>
175 <label>$PKG|$SHORT_DESC</label>
176 <variable>FIELD</variable>
177 <item icon=\"tazpkg\">Version: | $VERSION</item>
178 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
179 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
180 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
181 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
182 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
183 [ -n "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
184 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
185 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
186 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
187 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
188 <item icon=\"error\">Bugs: | $BUGS</item>"
189 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
190 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
191 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
192 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
193 [ -f /var/lib/tazpkg/installed/$PKG/modifiers ] &&
194 PACKAGE_INFOS="$PACKAGE_INFOS
195 <item icon=\"tazpkg\">Modified by: | $(xargs echo < /var/lib/tazpkg/installed/$PKG/modifiers)</item>"
196 PACKAGE_INFOS="$PACKAGE_INFOS
197 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
198 <action> $0 info \"\$FIELD\" $PKG </action>
199 </tree>
201 <hbox>"
202 [ ${PKG%%-*} = get -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
203 <button>
204 <label>Install</label>
205 <input file icon=\"go-next\"></input>
206 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
207 $PKG; sleep 5\"</action>
208 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
209 </button>"
210 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
211 <button>
212 <label>Reconfigure</label>
213 <input file icon=\"reload\"></input>
214 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
215 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
216 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
217 </button>"
218 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
219 PACKAGE_INFOS="$PACKAGE_INFOS
220 <button>
221 <label>Unblock</label>
222 <input file icon=\"up\"></input>
223 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
224 tazpkg unblock $PACKAGE; sleep 2\"</action>
225 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
226 </button>"
227 else
228 PACKAGE_INFOS="$PACKAGE_INFOS
229 <button>
230 <label>Block</label>
231 <input file icon=\"down\"></input>
232 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
233 tazpkg block $PACKAGE; sleep 2\"</action>
234 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
235 </button>"
236 fi
237 PACKAGE_INFOS="$PACKAGE_INFOS
238 <button>
239 <label>Remove</label>
240 <input file icon=\"edit-delete\"></input>
241 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
242 tazpkg remove $PACKAGE; sleep 2\"</action>
243 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
244 </button>
245 <button>
246 <label>Repack</label>
247 <input file icon=\"edit-redo\"></input>
248 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
249 cd /var/cache/tazpkg; \
250 tazpkg repack $PACKAGE; sleep 2\"</action>
251 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
252 </button>
253 <button>
254 <label>Files</label>
255 <input file icon=\"tazpkg\"></input>
256 <action type=\"launch\">LIST_FILES</action>
257 </button>
258 <button>
259 <input file icon=\"gtk-close\"></input>
260 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
261 </button>
262 </hbox>
264 </vbox>
265 </window>
266 "
267 export PACKAGE_INFOS
268 else
269 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
270 /var/lib/tazpkg/undigest/*/packages.desc`
271 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
272 VERSION=`echo "$RES" | cut -d "|" -f 2`
273 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
274 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
275 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
276 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
277 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
278 PACKAGE_INFOS="
279 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
280 <vbox>
282 <tree>
283 <width>460</width><height>160</height>
284 <label>$PKG|$SHORT_DESC</label>
285 <variable>FIELD2</variable>
286 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
287 <item icon=\"tazpkg\">Version: | $VERSION</item>
288 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
289 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
290 <item icon=\"tazpkg\">Size: | $SIZES</item>"
291 PACKAGE_INFOS="$PACKAGE_INFOS
292 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
293 <action>case \$FIELD2 in Web*) firefox $WEB_SITE &;; esac</action>
294 </tree>
296 <hbox>"
297 [ ${PACKAGE%%-*} = get ] && PACKAGE_INFOS="$PACKAGE_INFOS
298 <checkbox>
299 <label>Auto exec</label>
300 <variable>AUTO_EXEC</variable>
301 <default>true</default>
302 </checkbox>"
303 PACKAGE_INFOS="$PACKAGE_INFOS
304 <checkbox>
305 <label>Auto install depends</label>
306 <variable>AUTO_DEPENDS</variable>
307 <default>true</default>
308 </checkbox>
309 <button>
310 <label>Get-install</label>
311 <input file icon=\"go-next\"></input>
312 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
313 if [ x\$AUTO_DEPENDS != xtrue ]; then script -c \\\"tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log;\
314 else script -c \\\"yes y | tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log; fi; \
315 [ x\${AUTO_EXEC} = xtrue ] && $PACKAGE; \
316 sleep 2\"</action>
317 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
318 </button>
319 <button>
320 <label>Get</label>
321 <input file icon=\"go-next\"></input>
322 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
323 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
324 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
325 </button>
326 <button>
327 <label>Files</label>
328 <input file icon=\"tazpkg\"></input>
329 <action type=\"launch\">LIST_FILES_MIRROR</action>
330 </button>
331 <button>
332 <input file icon=\"gtk-close\"></input>
333 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
334 </button>
335 </hbox>
337 </vbox>
338 </window>
339 "
340 export PACKAGE_INFOS
341 fi
343 gtkdialog --center --program=PACKAGE_INFOS
345 exit 0