tazpkg view lib/tazpkgbox/package_infos @ rev 184

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