tazpkg view lib/tazpkgbox/package_infos @ rev 187

Add undigest support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Oct 27 23:12:36 2008 +0000 (2008-10-27)
parents 2cd2f9f2f053
children 86f8433a56bf
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 PACKAGE_INFOS="$PACKAGE_INFOS
175 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
176 <action>case \$FIELD in Web*) firefox $WEB_SITE &;; Sug*) $0 list_packages $SUGGESTED;; Dep*) $0 list_packages $DEPENDS;; esac</action>
177 </tree>
179 <hbox>"
180 [ $CATEGORY = non-free -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
181 <button>
182 <label>Install</label>
183 <input file icon=\"go-next\"></input>
184 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
185 $PKG; sleep 5\"</action>
186 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
187 </button>"
188 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
189 <button>
190 <label>Reconfigure</label>
191 <input file icon=\"reload\"></input>
192 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
193 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
194 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
195 </button>"
196 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
197 PACKAGE_INFOS="$PACKAGE_INFOS
198 <button>
199 <label>Unblock</label>
200 <input file icon=\"up\"></input>
201 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
202 tazpkg unblock $PACKAGE; sleep 2\"</action>
203 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
204 </button>"
205 else
206 PACKAGE_INFOS="$PACKAGE_INFOS
207 <button>
208 <label>Block</label>
209 <input file icon=\"down\"></input>
210 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
211 tazpkg block $PACKAGE; sleep 2\"</action>
212 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
213 </button>"
214 fi
215 PACKAGE_INFOS="$PACKAGE_INFOS
216 <button>
217 <label>Remove</label>
218 <input file icon=\"edit-delete\"></input>
219 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
220 tazpkg remove $PACKAGE; sleep 2\"</action>
221 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
222 </button>
223 <button>
224 <label>Repack</label>
225 <input file icon=\"edit-redo\"></input>
226 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
227 cd /var/cache/tazpkg; \
228 tazpkg repack $PACKAGE; sleep 2\"</action>
229 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
230 </button>
231 <button>
232 <label>Files</label>
233 <input file icon=\"tazpkg\"></input>
234 <action type=\"launch\">LIST_FILES</action>
235 </button>
236 <button>
237 <input file icon=\"gtk-close\"></input>
238 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
239 </button>
240 </hbox>
242 </vbox>
243 </window>
244 "
245 export PACKAGE_INFOS
246 else
247 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
248 /var/lib/tazpkg/undigest/*/packages.desc`
249 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
250 VERSION=`echo "$RES" | cut -d "|" -f 2`
251 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
252 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
253 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
254 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
255 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
256 PACKAGE_INFOS="
257 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
258 <vbox>
260 <tree>
261 <width>460</width><height>160</height>
262 <label>$PKG|$SHORT_DESC</label>
263 <variable>FIELD2</variable>
264 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
265 <item icon=\"tazpkg\">Version: | $VERSION</item>
266 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
267 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
268 <item icon=\"tazpkg\">Size: | $SIZES</item>"
269 PACKAGE_INFOS="$PACKAGE_INFOS
270 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
271 <action>case \$FIELD2 in Web*) firefox $WEB_SITE &;; esac</action>
272 </tree>
274 <hbox>"
275 [ $CATEGORY = non-free ] && PACKAGE_INFOS="$PACKAGE_INFOS
276 <checkbox>
277 <label>Auto exec</label>
278 <variable>AUTO_EXEC</variable>
279 <default>true</default>
280 </checkbox>"
281 PACKAGE_INFOS="$PACKAGE_INFOS
282 <checkbox>
283 <label>Auto install depends</label>
284 <variable>AUTO_DEPENDS</variable>
285 <default>true</default>
286 </checkbox>
287 <button>
288 <label>Get-install</label>
289 <input file icon=\"go-next\"></input>
290 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
291 if [ \$AUTO_DEPENDS != true ]; then tazpkg get-install $PACKAGE;\
292 else yes y | tazpkg get-install $PACKAGE; fi; \
293 [ \${AUTO_EXEC} = true -a $CATEGORY = non-free ] && $PACKAGE; \
294 sleep 2\"</action>
295 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
296 </button>
297 <button>
298 <label>Get</label>
299 <input file icon=\"go-next\"></input>
300 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
301 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
302 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
303 </button>
304 <button>
305 <label>Files</label>
306 <input file icon=\"tazpkg\"></input>
307 <action type=\"launch\">LIST_FILES_MIRROR</action>
308 </button>
309 <button>
310 <input file icon=\"gtk-close\"></input>
311 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
312 </button>
313 </hbox>
315 </vbox>
316 </window>
317 "
318 export PACKAGE_INFOS
319 fi
321 gtkdialog --center --program=PACKAGE_INFOS
323 exit 0