tazpkg view lib/tazpkgbox/package_infos @ rev 162

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