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