tazpkg view lib/tazpkgbox/package_infos @ rev 326

tazpkgbox: add link support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 03 15:19:29 2010 +0100 (2010-03-03)
parents 8bdf4568fdb5
children dc03e5ec0773
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 ROOT=/var/lib/tazpkg
10 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
11 ROOT=$(readlink /var/lib/tazpkg/fslink)$ROOT
12 fi
13 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
15 if [ "$1" = "sizes" ]; then
16 cat <<EOT
17 Dependancies for $2:
18 $(tazpkg depends $2)
20 Reverse dependancies for $2:
21 $(tazpkg rdepends $2)
22 EOT
23 exit 0
24 fi
25 if [ "$1" = "info" ]; then
26 RECEIPT=$ROOT/installed/$3/receipt
27 . $RECEIPT
28 case "$2" in
29 Web*) firefox $WEB_SITE &;;
30 Siz*) xterm -T "$3 depends (q to quit)" -e "$0 sizes $3 | less";;
31 Upg*) xterm -T "$3 upgrade" -e "tazpkg get-install $3 --forced ; sleep 2";;
32 Hand*) firefox $HANDBOOK_URL &;;
33 Sug*) $0 list_packages $SUGGESTED;;
34 Dep*) $0 list_packages $DEPENDS;;
35 Mod*) $0 list_packages $(xargs echo < $ROOT/installed/$3/modifiers);;
36 Con*) tazpkgbox list_config $3;;
37 Ver*) xterm -T "$3 receipt (q to quit)" -e "cat $RECEIPT | less";;
38 esac
39 exit 0
40 fi
42 if [ "$1" = "list_files" ]; then
43 CONF_FILES="$(tazpkg list-config $2 | awk "$AWK_FILTER")"
44 if [ -n "$CONF_FILES" ]; then
45 mkdir $TMP_DIR
46 zcat $ROOT/installed/$2/volatile.cpio.gz | \
47 ( cd $TMP_DIR ; cpio -id > /dev/null )
48 fi
49 cat $ROOT/installed/$2/files.list | grep ^/ | while read file; do
50 realfile="$file"
51 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
52 realfile="$(readlink /var/lib/tazpkg/fslink)$file"
53 fi
54 echo -n "$(stat -c "%A|%U|%G|%s|$file|" "$realfile" || \
55 echo "File lost !||||$file|")"
56 if [ -L "$realfile" ]; then
57 echo -n "$(readlink "$realfile")"
58 elif [ -f "$file" ]; then
59 case "$CONF_FILES" in
60 *$file*)
61 if cmp $file $TMP_DIR$file > /dev/null 2>&1; then
62 echo -n "[configuration]"
63 else
64 echo -n "$(stat -c "[configuration: %.16y]" $file)"
65 fi;;
66 #* if [ "$(tazpkg check-file $file $2)" = "failure" ]; then
67 # echo -n "Invalid md5"
68 # fi;;
69 esac
70 fi
71 echo ""
72 done
73 [ -n "$CONF_FILES" ] && rm -rf $TMP_DIR
74 exit 0
75 fi
77 if [ "$1" = "list_files_mirror" ]; then
78 for i in /var/lib/tazpkg/files.list.lzma \
79 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
80 [ -f $i ] || continue
81 unlzma -c $i
82 done | grep -- "^$2:" | awk '{ print substr($0,index($0,":")+2) }'
83 exit 0
84 fi
86 if [ "$1" = "list_packages" ]; then
87 PKG="$2"
88 if [ -n "$3" ]; then
89 shift
90 export LIST_PKGS='
91 <window title="Packages" icon-name="tazpkg">
92 <vbox>
93 <tree>
94 <width>600</width><height>160</height>
95 <label>Package|Version|Size|Description</label>
96 <variable>PKG</variable>
97 '
98 for i in "$@"; do
99 if [ -d $ROOT/installed/$i ]; then
100 . $ROOT/installed/$i/receipt
101 LIST_PKGS="$LIST_PKGS
102 <item icon=\"tazpkg\">$i|$VERSION|Installed|$SHORT_DESC</item>
103 "
104 else
105 RES=`grep -sh "^$i " \
106 /var/lib/tazpkg/packages.desc \
107 /var/lib/tazpkg/undigest/*/packages.desc`
108 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
109 VERSION=`echo "$RES" | cut -d "|" -f 2`
110 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
111 SIZE=`grep -sh -A 3 "^$(echo $PACKAGE)$" \
112 /var/lib/tazpkg/packages.txt \
113 /var/lib/tazpkg/undigest/*/packages.txt | \
114 tail -1 | sed 's/.*(\(.*\) .*/\1/'`
115 LIST_PKGS="$LIST_PKGS
116 <item icon=\"tazpkg\">$i|$VERSION|$SIZE|$SHORT_DESC</item>
117 "
118 fi
119 done
120 LIST_PKGS="$LIST_PKGS
121 <action>echo "\$PKG" > /tmp/tazpkgbox/pkg</action>
122 <action>/usr/lib/slitaz/tazpkgbox/package_infos</action>
123 <action>refresh:PKG</action>
124 <action>refresh:PKG_STATS</action>
125 <action>refresh:CACHE_STATS</action>
126 </tree>
127 <hbox>
128 <button ok>
129 </button>
130 <button cancel>
131 <action type=\"closewindow\">LIST_PKGS</action>
132 </button>
133 </hbox>
134 </vbox>
135 </window>
136 "
137 eval `gtkdialog --center --program=LIST_PKGS`
138 [ "$EXIT" = "OK" ] || exit 0
139 fi
140 fi
142 export LIST_FILES="
143 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
144 <vbox>
145 <tree exported_column=\"4\">
146 <variable>FILE</variable>
147 <width>600</width><height>160</height>
148 <label>Access | User | Group | Size | Name | Target</label>
149 <input> $0 list_files $PKG </input>
150 <action>tazpkg list-config $PKG | grep -q ^\$FILE$ && leafpad \$FILE</action>
151 </tree>
152 <hbox>
153 <button>
154 <input file icon=\"gtk-close\"></input>
155 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
156 </button>
157 </hbox>
158 </vbox>
159 </window>
160 "
162 export LIST_FILES_MIRROR="
163 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
164 <vbox>
165 <tree>
166 <width>300</width><height>160</height>
167 <label>File Name</label>
168 <input> $0 list_files_mirror $PKG </input>
169 </tree>
170 <hbox>
171 <button>
172 <input file icon=\"gtk-close\"></input>
173 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
174 </button>
175 </hbox>
176 </vbox>
177 </window>
178 "
180 # Installed or not installed, that is the question!
181 if [ -d $ROOT/installed/$PKG ]; then
182 PACKED_SIZE=""
183 DEPENDS=""
184 MAINTAINER=""
185 BUGS=""
186 TAGS=""
187 . $ROOT/installed/$PKG/receipt
188 MAINTAINER=$(echo "$MAINTAINER" | sed 's/[<>|]/ /g')
189 upgrade_version="$(cat /var/lib/tazpkg/packages.desc \
190 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | \
191 awk "/^$PACKAGE / { print \$3 }" | head -1 )"
192 UPGRADE=""
193 if [ -n "$upgrade_version" ]; then
194 if [ "$upgrade_version" != "$VERSION" ]; then
195 UPGRADE="$upgrade_version"
196 else
197 cur_md5="$(awk "/ $PACKAGE-$VERSION/ { print \$1 }" \
198 $ROOT/installed.md5)"
199 new_md5="$(cat /var/lib/tazpkg/packages.md5 \
200 /var/lib/tazpkg/undigest/*/packages.md5 \
201 2> /dev/null | awk "/ $PACKAGE-$VERSION/ { print \$1 }")"
202 if [ -n "$cur_md5" -a -n "$new_md5" -a \
203 "$cur_md5" != "$new_md5" ]; then
204 UPGRADE="build"
205 fi
206 fi
207 fi
208 PACKAGE_INFOS="
209 <window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
210 <vbox>
212 <tree>
213 <width>460</width><height>200</height>
214 <label>$PKG|$SHORT_DESC</label>
215 <variable>FIELD</variable>
216 <item icon=\"tazpkg\">Version: | $VERSION</item>
217 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
218 [ -n "$UPGRADE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
219 <item icon=\"tazpkg\">Upgrade: | $(echo $UPGRADE)</item>"
220 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
221 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
222 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
223 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
224 [ -n "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
225 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
226 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
227 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
228 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
229 <item icon=\"important\">Bugs: | $BUGS</item>"
230 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
231 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
232 [ -n "$TAGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
233 <item icon=\"tazpkg\">Tags: | $TAGS</item>"
234 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
235 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
236 [ -f $ROOT/installed/$PKG/modifiers ] &&
237 PACKAGE_INFOS="$PACKAGE_INFOS
238 <item icon=\"tazpkg\">Modified by: | $(xargs echo < $ROOT/installed/$PKG/modifiers)</item>"
239 PACKAGE_INFOS="$PACKAGE_INFOS
240 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
241 <action> $0 info \"\$FIELD\" $PKG </action>
242 </tree>
244 <hbox>"
245 [ -s $ROOT/installed/$PACKAGE/description.txt ] &&
246 PACKAGE_INFOS="$PACKAGE_INFOS
247 <button>
248 <label>Description</label>
249 <input file icon=\"help\"></input>
250 <action>xterm -T \"$PKG description (q to quit)\" $XTERM_OPTS \
251 -e \"less $ROOT/installed/$PKG/description.txt\"</action>
252 </button>"
253 if [ ! -d /var/lib/tazpkg/fslink ]; then
254 [ ${PKG%%-*} = get -a ! -d $ROOT/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
255 <button>
256 <label>Install</label>
257 <input file icon=\"go-next\"></input>
258 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
259 $PKG; sleep 5\"</action>
260 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
261 </button>"
262 [ -n "$UPGRADE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
263 <button>
264 <label>Upgrade</label>
265 <input file icon=\"go-next\"></input>
266 <action>xterm -T \"Install $PKG\" $XTERM_OPTS -e \"\
267 tazpkg get-install $PKG --forced ; sleep 5\"</action>
268 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
269 </button>"
270 grep -q post_install $ROOT/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
271 <button>
272 <label>Reconfigure</label>
273 <input file icon=\"reload\"></input>
274 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
275 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
276 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
277 </button>"
278 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
279 PACKAGE_INFOS="$PACKAGE_INFOS
280 <button>
281 <label>Unblock</label>
282 <input file icon=\"up\"></input>
283 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
284 tazpkg unblock $PACKAGE; sleep 2\"</action>
285 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
286 </button>"
287 else
288 PACKAGE_INFOS="$PACKAGE_INFOS
289 <button>
290 <label>Block</label>
291 <input file icon=\"down\"></input>
292 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
293 tazpkg block $PACKAGE; sleep 2\"</action>
294 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
295 </button>"
296 fi
297 fi
298 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
299 PACKAGE_INFOS="$PACKAGE_INFOS
300 <button>
301 <label>Link</label>
302 <input file icon=\"edit-redo\"></input>
303 <action>xterm -T \"Link $PACKAGE\" $XTERM_OPTS -e \"\
304 tazpkg link $PACKAGE $(readlink /var/lib/tazpkg/fslink); sleep 2\"</action>
305 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
306 </button>"
307 elif [ ! -s $ROOT/installed/$PKG/modifiers ]; then
308 [ -L $ROOT/installed/$PKG ] || PACKAGE_INFOS="$PACKAGE_INFOS
309 <button>
310 <label>Repack</label>
311 <input file icon=\"edit-redo\"></input>
312 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
313 cd /var/cache/tazpkg; \
314 tazpkg repack $PACKAGE; sleep 2\"</action>
315 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
316 </button>
317 "
318 PACKAGE_INFOS="$PACKAGE_INFOS
319 <button>
320 <label>Remove</label>
321 <input file icon=\"edit-delete\"></input>
322 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
323 tazpkg remove $PACKAGE; sleep 2\"</action>
324 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
325 </button>
326 "
327 else
328 PACKAGE_INFOS="$PACKAGE_INFOS
329 <button>
330 <label>Re-install</label>
331 <input file icon=\"edit-redo\"></input>
332 <action>xterm -T \"Re-install $PACKAGE\" $XTERM_OPTS -e \"\
333 tazpkg get-install $PACKAGE --forced; sleep 2\"</action>
334 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
335 </button>
336 <button>
337 <label>Remove</label>
338 <input file icon=\"edit-delete\"></input>
339 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
340 tazpkg remove $PACKAGE; sleep 2\"</action>
341 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
342 </button>
343 "
344 fi
345 PACKAGE_INFOS="$PACKAGE_INFOS
346 <button>
347 <label>Files</label>
348 <input file icon=\"tazpkg\"></input>
349 <action type=\"launch\">LIST_FILES</action>
350 </button>
351 <button>
352 <input file icon=\"gtk-close\"></input>
353 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
354 </button>
355 </hbox>
357 </vbox>
358 </window>
359 "
360 export PACKAGE_INFOS
361 else
362 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
363 /var/lib/tazpkg/undigest/*/packages.desc`
364 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
365 VERSION=`echo "$RES" | cut -d "|" -f 2`
366 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
367 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
368 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
369 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
370 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
371 DEPENDS=""
372 SUGGESTED=""
373 MAINTAINER=""
374 BUGS=""
375 HANDBOOK_URL=""
376 TAGS=""
377 CONFIG_FILES=""
378 height=160
379 if [ -s /home/slitaz/wok/$PKG/receipt ]; then
380 . /home/slitaz/wok/$PKG/receipt
381 height=200
382 fi
383 PACKAGE_INFOS="
384 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
385 <vbox>
387 <tree>
388 <width>460</width><height>$height</height>
389 <label>$PKG|$SHORT_DESC</label>
390 <variable>FIELD2</variable>
391 <item icon=\"tazpkg\">Version: | $VERSION</item>
392 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
393 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
394 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
395 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
396 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
397 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
398 <item icon=\"tazpkg\">Size: | $SIZES</item>"
399 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
400 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
401 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
402 <item icon=\"important\">Bugs: | $BUGS</item>"
403 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
404 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
405 [ -n "$TAGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
406 <item icon=\"tazpkg\">Tags: | $TAGS</item>"
407 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
408 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
409 PACKAGE_INFOS="$PACKAGE_INFOS
410 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
411 <action>case \$FIELD2 in Web*) firefox $WEB_SITE &;; esac</action>
412 </tree>
414 <hbox>"
415 [ ${PACKAGE%%-*} = get ] && PACKAGE_INFOS="$PACKAGE_INFOS
416 <checkbox>
417 <label>Auto exec</label>
418 <variable>AUTO_EXEC</variable>
419 <default>true</default>
420 </checkbox>"
421 PACKAGE_INFOS="$PACKAGE_INFOS
422 <checkbox>
423 <label>Auto install depends</label>
424 <variable>AUTO_DEPENDS</variable>
425 <default>true</default>
426 </checkbox>
427 <button>
428 <label>Get-install</label>
429 <input file icon=\"go-next\"></input>
430 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
431 if [ x\$AUTO_DEPENDS != xtrue ]; then script -c \\\"tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log;\
432 else script -c \\\"yes y | tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log; fi; \
433 [ x\${AUTO_EXEC} = xtrue ] && $PACKAGE; \
434 sleep 2\"</action>
435 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
436 </button>
437 <button>
438 <label>Get</label>
439 <input file icon=\"go-next\"></input>
440 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
441 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
442 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
443 </button>
444 <button>
445 <label>Files</label>
446 <input file icon=\"tazpkg\"></input>
447 <action type=\"launch\">LIST_FILES_MIRROR</action>
448 </button>
449 <button>
450 <input file icon=\"gtk-close\"></input>
451 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
452 </button>
453 </hbox>
455 </vbox>
456 </window>
457 "
458 export PACKAGE_INFOS
459 fi
461 gtkdialog --center --program=PACKAGE_INFOS
463 exit 0