tazpkg view lib/tazpkgbox/package_infos @ rev 150

tazpkgbox: add SHORT_DESC in package_info
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 06 10:56:45 2008 +0000 (2008-08-06)
parents 4a9cd626159b
children ab6c73d00680
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 if [ -L "$file" ]; then
22 echo -n "$(readlink "$file")"
23 elif [ -f "$file" ]; then
24 case "$CONF_FILES" in
25 *$file*)
26 if cmp $file $TMP_DIR$file > /dev/null 2>&1; then
27 echo -n "[configuration]"
28 else
29 echo -n "$(stat -c "[configuration: %.16y]" $file)"
30 fi;;
31 esac
32 fi
33 echo ""
34 done
35 [ -n "$CONF_FILES" ] && rm -rf $TMP_DIR
36 exit 0
37 fi
39 if [ "$1" = "list_files_mirror" ]; then
40 unlzma -c /var/lib/tazpkg/files.list.lzma | grep -- "^$2:" | \
41 awk '{ print substr($0,index($0,":")+2) }'
42 exit 0
43 fi
45 export LIST_FILES="
46 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
47 <vbox>
48 <tree exported_column=\"4\">
49 <variable>FILE</variable>
50 <width>600</width><height>160</height>
51 <label>Access | User | Group | Size | Name | Target</label>
52 <input> $0 list_files $PKG </input>
53 <action>tazpkg list-config $PKG | grep -q ^\$FILE$ && leafpad \$FILE</action>
54 </tree>
55 <hbox>
56 <button>
57 <input file icon=\"gtk-close\"></input>
58 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
59 </button>
60 </hbox>
61 </vbox>
62 </window>
63 "
65 export LIST_FILES_MIRROR="
66 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
67 <vbox>
68 <tree>
69 <width>300</width><height>160</height>
70 <label>File Name</label>
71 <input> $0 list_files_mirror $PKG </input>
72 </tree>
73 <hbox>
74 <button>
75 <input file icon=\"gtk-close\"></input>
76 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
77 </button>
78 </hbox>
79 </vbox>
80 </window>
81 "
83 # Installed or not installed, that the question.
84 if [ -d /var/lib/tazpkg/installed/$PKG ]; then
85 PACKED_SIZE=""
86 DEPENDS=""
87 MAINTAINER=""
88 . /var/lib/tazpkg/installed/$PKG/receipt
89 MAINTAINER=$(echo "$MAINTAINER" | sed 's/[<>|]/ /g')
90 PACKAGE_INFOS="
91 <window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
92 <vbox>
94 <tree>
95 <width>460</width><height>160</height>
96 <label>$PKG|$SHORT_DESC</label>
97 <variable>FIELD</variable>
98 <item icon=\"tazpkg\">Version: | $VERSION</item>
99 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
100 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
101 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
102 [ -n "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
103 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
104 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
105 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
106 PACKAGE_INFOS="$PACKAGE_INFOS
107 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
108 <action>case \$FIELD in Web*) firefox $WEB_SITE &;; esac</action>
109 </tree>
111 <hbox>"
112 [ $CATEGORY = non-free -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
113 <button>
114 <label>Install</label>
115 <input file icon=\"go-next\"></input>
116 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
117 $PKG; sleep 5\"</action>
118 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
119 </button>"
120 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
121 <button>
122 <label>Reconfigure</label>
123 <input file icon=\"reload\"></input>
124 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
125 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
126 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
127 </button>"
128 if grep -q ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
129 PACKAGE_INFOS="$PACKAGE_INFOS
130 <button>
131 <label>Unblock</label>
132 <input file icon=\"up\"></input>
133 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
134 tazpkg unblock $PACKAGE; sleep 2\"</action>
135 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
136 </button>"
137 else
138 PACKAGE_INFOS="$PACKAGE_INFOS
139 <button>
140 <label>Block</label>
141 <input file icon=\"down\"></input>
142 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
143 tazpkg block $PACKAGE; sleep 2\"</action>
144 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
145 </button>"
146 fi
147 PACKAGE_INFOS="$PACKAGE_INFOS
148 <button>
149 <label>Remove</label>
150 <input file icon=\"edit-delete\"></input>
151 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
152 tazpkg remove $PACKAGE; sleep 2\"</action>
153 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
154 </button>
155 <button>
156 <label>Repack</label>
157 <input file icon=\"edit-redo\"></input>
158 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
159 cd /var/cache/tazpkg; \
160 tazpkg repack $PACKAGE; sleep 2\"</action>
161 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
162 </button>
163 <button>
164 <label>Files</label>
165 <input file icon=\"tazpkg\"></input>
166 <action type=\"launch\">LIST_FILES</action>
167 </button>
168 <button>
169 <input file icon=\"gtk-close\"></input>
170 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
171 </button>
172 </hbox>
174 </vbox>
175 </window>
176 "
177 export PACKAGE_INFOS
178 else
179 RES=`grep "^$PKG" /var/lib/tazpkg/packages.desc | head -n 1`
180 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
181 VERSION=`echo "$RES" | cut -d "|" -f 2`
182 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
183 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
184 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
185 SIZES=`grep -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt | tail -1`
186 PACKAGE_INFOS="
187 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
188 <vbox>
190 <tree>
191 <width>460</width><height>140</height>
192 <label>$PKG|$SHORT_DESC</label>
193 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
194 <item icon=\"tazpkg\">Version: | $VERSION</item>
195 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
196 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
197 <item icon=\"tazpkg\">Size: | $SIZES</item>"
198 PACKAGE_INFOS="$PACKAGE_INFOS
199 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
200 </tree>
202 <hbox>"
203 [ $CATEGORY = non-free ] && PACKAGE_INFOS="$PACKAGE_INFOS
204 <checkbox>
205 <label>Auto exec</label>
206 <variable>AUTO_EXEC</variable>
207 <default>true</default>
208 </checkbox>"
209 PACKAGE_INFOS="$PACKAGE_INFOS
210 <checkbox>
211 <label>Auto install depends</label>
212 <variable>AUTO_DEPENDS</variable>
213 <default>true</default>
214 </checkbox>
215 <button>
216 <label>Get-install</label>
217 <input file icon=\"go-next\"></input>
218 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
219 if [ \$AUTO_DEPENDS != true ]; then tazpkg get-install $PACKAGE;\
220 else yes y | tazpkg get-install $PACKAGE; fi; \
221 [ \${AUTO_EXEC}$CATEGORY = truenon-free ] && $PACKAGE; \
222 sleep 2\"</action>
223 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
224 </button>
225 <button>
226 <label>Get</label>
227 <input file icon=\"go-next\"></input>
228 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
229 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
230 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
231 </button>
232 <button>
233 <label>Files</label>
234 <input file icon=\"tazpkg\"></input>
235 <action type=\"launch\">LIST_FILES_MIRROR</action>
236 </button>
237 <button>
238 <input file icon=\"gtk-close\"></input>
239 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
240 </button>
241 </hbox>
243 </vbox>
244 </window>
245 "
246 export PACKAGE_INFOS
247 fi
249 gtkdialog --center --program=PACKAGE_INFOS
251 exit 0