tazpkg view lib/tazpkgbox/package_infos @ rev 216

tazpkgbox: fix repack/re-install button
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Dec 04 09:01:55 2008 +0000 (2008-12-04)
parents 39ff491d6b0c
children 2ae69f8e0c8d
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 [ ${PKG%%-*} = get -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
236 <button>
237 <label>Install</label>
238 <input file icon=\"go-next\"></input>
239 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
240 $PKG; sleep 5\"</action>
241 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
242 </button>"
243 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
244 <button>
245 <label>Reconfigure</label>
246 <input file icon=\"reload\"></input>
247 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
248 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
249 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
250 </button>"
251 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
252 PACKAGE_INFOS="$PACKAGE_INFOS
253 <button>
254 <label>Unblock</label>
255 <input file icon=\"up\"></input>
256 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
257 tazpkg unblock $PACKAGE; sleep 2\"</action>
258 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
259 </button>"
260 else
261 PACKAGE_INFOS="$PACKAGE_INFOS
262 <button>
263 <label>Block</label>
264 <input file icon=\"down\"></input>
265 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
266 tazpkg block $PACKAGE; sleep 2\"</action>
267 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
268 </button>"
269 fi
270 if [ ! -s /var/lib/tazpkg/installed/$PKG/modifiers ]; then
271 PACKAGE_INFOS="$PACKAGE_INFOS
272 <button>
273 <label>Repack</label>
274 <input file icon=\"edit-redo\"></input>
275 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
276 cd /var/cache/tazpkg; \
277 tazpkg repack $PACKAGE; sleep 2\"</action>
278 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
279 </button>
280 "
281 else
282 PACKAGE_INFOS="$PACKAGE_INFOS
283 <button>
284 <label>Re-install</label>
285 <input file icon=\"edit-redo\"></input>
286 <action>xterm -T \"Re-install $PACKAGE\" $XTERM_OPTS -e \"\
287 tazpkg get-install $PACKAGE --forced; sleep 2\"</action>
288 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
289 </button>
290 "
291 fi
292 PACKAGE_INFOS="$PACKAGE_INFOS
293 <button>
294 <label>Remove</label>
295 <input file icon=\"edit-delete\"></input>
296 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
297 tazpkg remove $PACKAGE; sleep 2\"</action>
298 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
299 </button>
300 <button>
301 <label>Files</label>
302 <input file icon=\"tazpkg\"></input>
303 <action type=\"launch\">LIST_FILES</action>
304 </button>
305 <button>
306 <input file icon=\"gtk-close\"></input>
307 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
308 </button>
309 </hbox>
311 </vbox>
312 </window>
313 "
314 export PACKAGE_INFOS
315 else
316 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
317 /var/lib/tazpkg/undigest/*/packages.desc`
318 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
319 VERSION=`echo "$RES" | cut -d "|" -f 2`
320 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
321 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
322 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
323 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
324 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
325 PACKAGE_INFOS="
326 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
327 <vbox>
329 <tree>
330 <width>460</width><height>160</height>
331 <label>$PKG|$SHORT_DESC</label>
332 <variable>FIELD2</variable>
333 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
334 <item icon=\"tazpkg\">Version: | $VERSION</item>
335 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
336 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
337 <item icon=\"tazpkg\">Size: | $SIZES</item>"
338 PACKAGE_INFOS="$PACKAGE_INFOS
339 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
340 <action>case \$FIELD2 in Web*) firefox $WEB_SITE &;; esac</action>
341 </tree>
343 <hbox>"
344 [ ${PACKAGE%%-*} = get ] && PACKAGE_INFOS="$PACKAGE_INFOS
345 <checkbox>
346 <label>Auto exec</label>
347 <variable>AUTO_EXEC</variable>
348 <default>true</default>
349 </checkbox>"
350 PACKAGE_INFOS="$PACKAGE_INFOS
351 <checkbox>
352 <label>Auto install depends</label>
353 <variable>AUTO_DEPENDS</variable>
354 <default>true</default>
355 </checkbox>
356 <button>
357 <label>Get-install</label>
358 <input file icon=\"go-next\"></input>
359 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
360 if [ x\$AUTO_DEPENDS != xtrue ]; then script -c \\\"tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log;\
361 else script -c \\\"yes y | tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log; fi; \
362 [ x\${AUTO_EXEC} = xtrue ] && $PACKAGE; \
363 sleep 2\"</action>
364 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
365 </button>
366 <button>
367 <label>Get</label>
368 <input file icon=\"go-next\"></input>
369 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
370 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
371 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
372 </button>
373 <button>
374 <label>Files</label>
375 <input file icon=\"tazpkg\"></input>
376 <action type=\"launch\">LIST_FILES_MIRROR</action>
377 </button>
378 <button>
379 <input file icon=\"gtk-close\"></input>
380 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
381 </button>
382 </hbox>
384 </vbox>
385 </window>
386 "
387 export PACKAGE_INFOS
388 fi
390 gtkdialog --center --program=PACKAGE_INFOS
392 exit 0