tazpkg view lib/tazpkgbox/package_infos @ rev 156

tazpkgbox: show lost files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Sep 04 10:16:00 2008 +0000 (2008-09-04)
parents ab6c73d00680
children bfbd3b3a28b4
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 "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
104 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
105 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
106 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
107 PACKAGE_INFOS="$PACKAGE_INFOS
108 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
109 <action>case \$FIELD in Web*) firefox $WEB_SITE &;; esac</action>
110 </tree>
112 <hbox>"
113 [ $CATEGORY = non-free -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
114 <button>
115 <label>Install</label>
116 <input file icon=\"go-next\"></input>
117 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
118 $PKG; sleep 5\"</action>
119 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
120 </button>"
121 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
122 <button>
123 <label>Reconfigure</label>
124 <input file icon=\"reload\"></input>
125 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
126 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
127 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
128 </button>"
129 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
130 PACKAGE_INFOS="$PACKAGE_INFOS
131 <button>
132 <label>Unblock</label>
133 <input file icon=\"up\"></input>
134 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
135 tazpkg unblock $PACKAGE; sleep 2\"</action>
136 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
137 </button>"
138 else
139 PACKAGE_INFOS="$PACKAGE_INFOS
140 <button>
141 <label>Block</label>
142 <input file icon=\"down\"></input>
143 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
144 tazpkg block $PACKAGE; sleep 2\"</action>
145 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
146 </button>"
147 fi
148 PACKAGE_INFOS="$PACKAGE_INFOS
149 <button>
150 <label>Remove</label>
151 <input file icon=\"edit-delete\"></input>
152 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
153 tazpkg remove $PACKAGE; sleep 2\"</action>
154 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
155 </button>
156 <button>
157 <label>Repack</label>
158 <input file icon=\"edit-redo\"></input>
159 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
160 cd /var/cache/tazpkg; \
161 tazpkg repack $PACKAGE; sleep 2\"</action>
162 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
163 </button>
164 <button>
165 <label>Files</label>
166 <input file icon=\"tazpkg\"></input>
167 <action type=\"launch\">LIST_FILES</action>
168 </button>
169 <button>
170 <input file icon=\"gtk-close\"></input>
171 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
172 </button>
173 </hbox>
175 </vbox>
176 </window>
177 "
178 export PACKAGE_INFOS
179 else
180 RES=`grep "^$PKG" /var/lib/tazpkg/packages.desc | head -n 1`
181 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
182 VERSION=`echo "$RES" | cut -d "|" -f 2`
183 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
184 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
185 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
186 SIZES=`grep -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt | tail -1`
187 PACKAGE_INFOS="
188 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
189 <vbox>
191 <tree>
192 <width>460</width><height>140</height>
193 <label>$PKG|$SHORT_DESC</label>
194 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
195 <item icon=\"tazpkg\">Version: | $VERSION</item>
196 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
197 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
198 <item icon=\"tazpkg\">Size: | $SIZES</item>"
199 PACKAGE_INFOS="$PACKAGE_INFOS
200 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
201 </tree>
203 <hbox>"
204 [ $CATEGORY = non-free ] && PACKAGE_INFOS="$PACKAGE_INFOS
205 <checkbox>
206 <label>Auto exec</label>
207 <variable>AUTO_EXEC</variable>
208 <default>true</default>
209 </checkbox>"
210 PACKAGE_INFOS="$PACKAGE_INFOS
211 <checkbox>
212 <label>Auto install depends</label>
213 <variable>AUTO_DEPENDS</variable>
214 <default>true</default>
215 </checkbox>
216 <button>
217 <label>Get-install</label>
218 <input file icon=\"go-next\"></input>
219 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
220 if [ \$AUTO_DEPENDS != true ]; then tazpkg get-install $PACKAGE;\
221 else yes y | tazpkg get-install $PACKAGE; fi; \
222 [ \${AUTO_EXEC}$CATEGORY = truenon-free ] && $PACKAGE; \
223 sleep 2\"</action>
224 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
225 </button>
226 <button>
227 <label>Get</label>
228 <input file icon=\"go-next\"></input>
229 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
230 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
231 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
232 </button>
233 <button>
234 <label>Files</label>
235 <input file icon=\"tazpkg\"></input>
236 <action type=\"launch\">LIST_FILES_MIRROR</action>
237 </button>
238 <button>
239 <input file icon=\"gtk-close\"></input>
240 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
241 </button>
242 </hbox>
244 </vbox>
245 </window>
246 "
247 export PACKAGE_INFOS
248 fi
250 gtkdialog --center --program=PACKAGE_INFOS
252 exit 0