tazpkg view lib/tazpkgbox/package_infos @ rev 239

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