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