tazpkg view lib/tazpkgbox/package_infos @ rev 143

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