tazpkg view lib/tazpkgbox/package_infos @ rev 208

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