rev |
line source |
pankso@3521
|
1 #!/bin/sh
|
pankso@3521
|
2 # Tiny CGI search engine for SliTaz packages on http://pkgs.slitaz.org/
|
pankso@3521
|
3 # Christophe Lincoln <pankso@slitaz.org>
|
pankso@3521
|
4 #
|
pankso@3521
|
5
|
pankso@3521
|
6 read QUERY_STRING
|
pankso@3521
|
7 for i in $(echo $QUERY_STRING | sed 's/&/ /g'); do
|
pankso@3521
|
8 eval $i
|
pankso@3521
|
9 done
|
pankso@3521
|
10 LANG=$lang
|
pankso@3521
|
11 SEARCH=$query
|
pankso@3521
|
12 SLITAZ_VERSION=$version
|
pankso@3521
|
13 OBJECT=$object
|
pankso@3521
|
14 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
|
pankso@3521
|
15 VERSION=cooking
|
pankso@3521
|
16 if [ "$REQUEST_METHOD" = "GET" ]; then
|
pankso@3521
|
17 SEARCH=""
|
pascal@4840
|
18 VERBOSE=0
|
pankso@3521
|
19 for i in $(echo $REQUEST_URI | sed 's/[?&]/ /g'); do
|
pankso@3521
|
20 SLITAZ_VERSION=cooking
|
pascal@6044
|
21 case "$(echo $i | tr [A-Z] [a-z])" in
|
pascal@6044
|
22 search=*)
|
pascal@6044
|
23 SEARCH=${i#*=};;
|
pascal@6044
|
24 object=*)
|
pascal@6044
|
25 OBJECT=${i#*=};;
|
pascal@4840
|
26 verbose=*)
|
pascal@4840
|
27 VERBOSE=${i#*=};;
|
pankso@3521
|
28 lang=*)
|
pankso@3521
|
29 LANG=${i#*=};;
|
pankso@3521
|
30 file=*)
|
pankso@3521
|
31 SEARCH=${i#*=}
|
pankso@3521
|
32 OBJECT=File;;
|
pankso@3521
|
33 desc=*)
|
pankso@3521
|
34 SEARCH=${i#*=}
|
pankso@3521
|
35 OBJECT=Desc;;
|
pankso@3521
|
36 tags=*)
|
pankso@3521
|
37 SEARCH=${i#*=}
|
pankso@3521
|
38 OBJECT=Tags;;
|
pankso@3521
|
39 receipt=*)
|
pankso@3521
|
40 SEARCH=${i#*=}
|
pankso@3521
|
41 OBJECT=Receipt;;
|
pankso@3521
|
42 filelist=*)
|
pankso@3521
|
43 SEARCH=${i#*=}
|
pankso@3521
|
44 OBJECT=File_list;;
|
pankso@3521
|
45 package=*)
|
pankso@3521
|
46 SEARCH=${i#*=}
|
pankso@3521
|
47 OBJECT=Package;;
|
pankso@3521
|
48 depends=*)
|
pankso@3521
|
49 SEARCH=${i#*=}
|
pankso@3521
|
50 OBJECT=Depends;;
|
pascal@6044
|
51 builddepends=*)
|
pascal@4840
|
52 SEARCH=${i#*=}
|
pascal@4840
|
53 OBJECT=BuildDepends;;
|
pascal@6044
|
54 fileoverlap=*)
|
pascal@4840
|
55 SEARCH=${i#*=}
|
pascal@4840
|
56 OBJECT=FileOverlap;;
|
pascal@5820
|
57 version=s*|version=3*)
|
pankso@3521
|
58 SLITAZ_VERSION=stable;;
|
pascal@6044
|
59 version=[1-9]*)
|
pascal@6044
|
60 i=${version%%.*}
|
pascal@6044
|
61 SLITAZ_VERSION=${i#*=}.0;;
|
pankso@3521
|
62 esac
|
pankso@3521
|
63 done
|
pankso@3521
|
64 [ -n "$SEARCH" ] && REQUEST_METHOD="POST"
|
pankso@3521
|
65 fi
|
pankso@3521
|
66
|
pankso@3521
|
67 case "$OBJECT" in
|
pankso@3521
|
68 File) selected_file="selected";;
|
pankso@3521
|
69 Desc) selected_desc="selected";;
|
pankso@3521
|
70 Tags) selected_tags="selected";;
|
pankso@3521
|
71 Receipt) selected_receipt="selected";;
|
pankso@3521
|
72 File_list) selected_file_list="selected";;
|
pankso@3521
|
73 Depends) selected_depends="selected";;
|
pascal@4840
|
74 BuildDepends) selected_build_depends="selected";;
|
pascal@4840
|
75 FileOverlap) selected_overlap="selected";;
|
pankso@3521
|
76 esac
|
pankso@3521
|
77
|
pankso@3521
|
78 case "$SLITAZ_VERSION" in
|
pankso@3521
|
79 1.0) selected_1="selected";;
|
pascal@5820
|
80 2.0) selected_2="selected";;
|
pankso@3521
|
81 stable) selected_stable="selected";;
|
pankso@3521
|
82 esac
|
pankso@3521
|
83
|
pankso@3521
|
84 # unescape query
|
pankso@3521
|
85 SEARCH="$(echo $SEARCH | sed 's/%2B/+/g' | sed 's/%3A/:/g' | sed 's|%2F|/|g')"
|
pankso@3521
|
86
|
pankso@3521
|
87 if [ -z "$LANG" ]; then
|
pankso@3521
|
88 for i in $(echo $HTTP_ACCEPT_LANGUAGE | sed 's/[,;]/ /g'); do
|
pankso@3521
|
89 case "$i" in
|
pankso@3521
|
90 fr|de|pt|cn)
|
pankso@3521
|
91 LANG=$i
|
pankso@3521
|
92 break;;
|
pankso@3521
|
93 esac
|
pankso@3521
|
94 done
|
pankso@3521
|
95 fi
|
pankso@3521
|
96
|
pankso@3521
|
97 package="Package"
|
pankso@3521
|
98 file="File"
|
pankso@3521
|
99 desc="Description"
|
pankso@3521
|
100 tags="Tags"
|
pankso@3521
|
101 receipt="Receipt"
|
pankso@3521
|
102 file_list="File list"
|
pankso@3521
|
103 depends="Depends"
|
pascal@4840
|
104 bdepends="Build depends"
|
pankso@3521
|
105 search="Search"
|
pankso@3521
|
106 cooking="cooking"
|
pankso@3521
|
107 stable="stable"
|
pankso@3521
|
108 result="Result for : $SEARCH"
|
pankso@3521
|
109 noresult="No package $SEARCH"
|
pankso@3521
|
110 deptree="Dependency tree for : $SEARCH"
|
pankso@3521
|
111 rdeptree="Reverse dependency tree for : $SEARCH"
|
pascal@4840
|
112 bdeplist="$SEARCH needs these packages to be built"
|
pascal@4840
|
113 rbdeplist="Packages who need $SEARCH to be built"
|
pascal@4840
|
114 overloading="Theses packages may overload files of "
|
pascal@4840
|
115 overlap="common files"
|
pankso@3521
|
116 charset="ISO-8859-1"
|
pankso@3521
|
117
|
pankso@3521
|
118 case "$LANG" in
|
pankso@3521
|
119
|
pankso@3521
|
120 fr) package="Paquet"
|
pankso@3521
|
121 receipt="Recette"
|
pankso@3521
|
122 depends="Dépendances"
|
pascal@4840
|
123 bdepends="Fabrication"
|
pankso@3521
|
124 search="Recherche"
|
pankso@3521
|
125 result="Recherche de : $SEARCH"
|
pankso@3521
|
126 noresult="Paquet $SEARCH introuvable"
|
pankso@3521
|
127 deptree="Arbre des dépendances de $SEARCH"
|
pankso@3521
|
128 rdeptree="Arbre inversé des dépendances de $SEARCH"
|
pascal@4840
|
129 bdeplist="$SEARCH a besion de ces paquets pour être fabriqué"
|
pascal@4840
|
130 rbdeplist="Paquets ayant besion de $SEARCH pour être fabriqués"
|
pascal@4840
|
131 overloading="Paquets pouvant écraser des fichiers de "
|
pascal@4840
|
132 overlap="Fichiers communs"
|
pankso@3521
|
133 file_list="Liste des fichiers"
|
pankso@3521
|
134 file="Fichier";;
|
pankso@3521
|
135
|
pankso@3521
|
136 de) package="Paket"
|
pankso@3521
|
137 depends="Abhängigkeiten"
|
pankso@3521
|
138 desc="Beschreibung"
|
pankso@3521
|
139 search="Suche"
|
pankso@3521
|
140 cooking="Cooking"
|
pankso@3521
|
141 stable="Stable"
|
pankso@3521
|
142 result="Resultate für : $SEARCH"
|
pankso@3521
|
143 noresult="Kein Paket für $SEARCH"
|
pankso@3521
|
144 deptree="Abhängigkeiten von: $SEARCH"
|
pankso@3521
|
145 rdeptree="Abhängigkeit für: $SEARCH"
|
pankso@3521
|
146 file_list="Datei liste"
|
pankso@3521
|
147 file="Datei";;
|
pankso@3521
|
148
|
pankso@3521
|
149 pt) package="Pacote"
|
pankso@3521
|
150 search="Buscar"
|
pankso@3521
|
151 cooking="cooking"
|
pankso@3521
|
152 stable="stable"
|
pankso@3521
|
153 result="Resultado para : $SEARCH"
|
pankso@3521
|
154 noresult="Sem resultado: $SEARCH"
|
pankso@3521
|
155 deptree="Árvore de dependências para: $SEARCH"
|
pankso@3521
|
156 rdeptree="Árvore de dependências reversa para: $SEARCH"
|
pankso@3521
|
157 depends="Dependências"
|
pankso@3521
|
158 desc="Descrição"
|
pankso@3521
|
159 file_list="Arquivo lista"
|
pankso@3521
|
160 file="Arquivo";;
|
pankso@3521
|
161
|
pankso@3521
|
162 cn) package="软件包:"
|
pankso@3521
|
163 cooking="å¼€å‘版"
|
pankso@3521
|
164 stable="稳定版"
|
pankso@3521
|
165 desc="æè¿°"
|
pankso@3521
|
166 tags="æ ‡ç¾"
|
pankso@3521
|
167 depends="ä¾èµ–"
|
pankso@3521
|
168 file="文件"
|
pankso@3521
|
169 file_list="文件列表"
|
pankso@3521
|
170 search="Search"
|
pankso@3521
|
171 result="Result for : $SEARCH"
|
pankso@3521
|
172 noresult="No package $SEARCH"
|
pankso@3521
|
173 deptree="Dependency tree for : $SEARCH"
|
pankso@3521
|
174 rdeptree="Reverse dependency tree for : $SEARCH"
|
pankso@3521
|
175 charset="UTF-8";;
|
pankso@3521
|
176
|
pankso@3521
|
177 *) LANG="en";;
|
pankso@3521
|
178
|
pankso@3521
|
179 esac
|
pankso@3521
|
180
|
pankso@3521
|
181 WOK=/home/slitaz/$SLITAZ_VERSION/wok
|
pascal@3551
|
182 PACKAGES_REPOSITORY=/home/slitaz/$SLITAZ_VERSION/packages
|
pankso@3521
|
183
|
pankso@3521
|
184 echo Content-type: text/html
|
pankso@3521
|
185 echo
|
pankso@3521
|
186
|
pankso@3521
|
187 # Search form
|
pankso@3521
|
188 search_form()
|
pankso@3521
|
189 {
|
pankso@3521
|
190 cat << _EOT_
|
pankso@3521
|
191
|
pankso@3521
|
192 <div style="text-align: center; padding: 20px;">
|
pankso@3521
|
193 <form method="post" action="search.cgi">
|
pankso@3521
|
194 <input type="hidden" name="lang" value="$LANG" />
|
pankso@3521
|
195 <select name="object">
|
pankso@3521
|
196 <option value="Package">$package</option>
|
pankso@3521
|
197 <option $selected_desc value="Desc">$desc</option>
|
pankso@3521
|
198 <option $selected_tags value="Tags">$tags</option>
|
pankso@3521
|
199 <option $selected_receipt value="Receipt">$receipt</option>
|
pankso@3521
|
200 <option $selected_depends value="Depends">$depends</option>
|
pascal@4840
|
201 <option $selected_build_depends value="BuildDepends">$bdepends</option>
|
pankso@3521
|
202 <option $selected_file value="File">$file</option>
|
pankso@3521
|
203 <option $selected_file_list value="File_list">$file_list</option>
|
pascal@4840
|
204 <option $selected_overlap value="FileOverlap">$overlap</option>
|
pankso@3521
|
205 </select>
|
pankso@3521
|
206 <strong>:</strong>
|
pascal@4840
|
207 <input type="text" name="query" size="20" value="$SEARCH" />
|
pankso@3521
|
208 <select name="version">
|
pankso@3521
|
209 <option value="cooking">$cooking</option>
|
pankso@3521
|
210 <option $selected_stable value="stable">$stable</option>
|
pankso@3521
|
211 <option $selected_1 value="1.0">1.0</option>
|
pascal@5820
|
212 <option $selected_2 value="2.0">2.0</option>
|
pankso@3521
|
213 </select>
|
pankso@3521
|
214 <input type="submit" name="search" value="$search" />
|
pankso@3521
|
215 </form>
|
pankso@3521
|
216 </div>
|
pankso@3521
|
217 _EOT_
|
pankso@3521
|
218 }
|
pankso@3521
|
219
|
pankso@3521
|
220 # xHTML Header.
|
pankso@3521
|
221 xhtml_header()
|
pankso@3521
|
222 {
|
pankso@3521
|
223 cat << _EOF_
|
pankso@3521
|
224 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
pankso@3521
|
225 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
pankso@3521
|
226 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$LANG" lang="$LANG">
|
pankso@3521
|
227 <head>
|
pankso@3521
|
228 <title>SliTaz Packages - Search $SEARCH</title>
|
pankso@3521
|
229 <meta http-equiv="content-type" content="text/html; charset=$charset" />
|
pankso@3521
|
230 <meta name="description" content="Au sujet de SliTaz GNU/Linux mini système d'exploitation" />
|
pankso@3521
|
231 <meta name="keywords" lang="fr" content="Système, libre, gnu, linux, opensource, livecd" />
|
pankso@3521
|
232 <meta name="robots" content="index, follow, all" />
|
pankso@3521
|
233 <meta name="revisit-after" content="7 days" />
|
pankso@3521
|
234 <meta name="expires" content="never" />
|
pankso@3521
|
235 <meta name="modified" content="$DATE" />
|
pankso@3521
|
236 <meta name="author" content="ash, awk, grep, sed and cat"/>
|
pankso@3521
|
237 <meta name="publisher" content="www.slitaz.org" />
|
pascal@5822
|
238 <link rel="shortcut icon" href="/favicon.ico" />
|
pascal@5822
|
239 <link rel="stylesheet" type="text/css" href="/slitaz.css" />
|
pankso@3521
|
240 </head>
|
pankso@7932
|
241 <body>
|
pankso@3521
|
242
|
pankso@3521
|
243 <!-- Header -->
|
pankso@3521
|
244 <div id="header">
|
pankso@7932
|
245 <!-- Logo -->
|
pankso@3521
|
246 <a href="http://pkgs.slitaz.org/"><img id="logo"
|
pankso@7932
|
247 src="/pics/website/logo.png"
|
pankso@7932
|
248 title="pkgs.slitaz.org" alt="pkgs.slitaz.org" /></a>
|
pankso@7932
|
249 <p id="titre">#!/Packages</p>
|
pankso@3521
|
250 </div>
|
pankso@3521
|
251 _EOF_
|
pankso@3521
|
252 }
|
pankso@3521
|
253
|
pankso@3521
|
254 # xHTML Footer.
|
pankso@3521
|
255 xhtml_footer()
|
pankso@3521
|
256 {
|
pankso@3521
|
257 cat << _EOT_
|
pankso@3521
|
258 <center>
|
pascal@3551
|
259 <i>$(ls $WOK/ | wc -l) packages and $(unlzma -c $PACKAGES_REPOSITORY/files.list.lzma | wc -l) files in $SLITAZ_VERSION database</i>
|
pankso@3521
|
260 </center>
|
pankso@3521
|
261
|
pankso@7932
|
262 <!-- End of content -->
|
pankso@3521
|
263 </div>
|
pankso@3521
|
264
|
pankso@7932
|
265 <!-- Footer -->
|
pankso@7932
|
266 <div id="footer">
|
pankso@7932
|
267 <div class="right_box">
|
pankso@7932
|
268 <h4>SliTaz Network</h4>
|
pankso@7932
|
269 <ul>
|
pankso@7932
|
270 <li><a href="http://www.slitaz.org/">Main Website</a></li>
|
pankso@7932
|
271 <li><a href="http://doc.slitaz.org/">Documentation</a></li>
|
pankso@7932
|
272 <li><a href="http://forum.slitaz.org/">Support Forum</a></li>
|
pankso@7932
|
273 <li><a href="http://scn.slitaz.org/">Community Network</a></li>
|
pankso@7932
|
274 <li><a href="http://twitter.com/slitaz">SliTaz on Twitter</a></li>
|
pankso@7932
|
275 <li><a href="http://distrowatch.com/slitaz">SliTaz on DistroWatch</a></li>
|
pankso@7932
|
276 </ul>
|
pankso@7932
|
277 </div>
|
pankso@7932
|
278 <h4>SliTaz Packages</h4>
|
pankso@7932
|
279 <ul>
|
pankso@7932
|
280 <li><a href="#header">Top of the page</a></li>
|
pankso@7932
|
281 <li>Copyright © <span class="year"></span>
|
pankso@7932
|
282 <a href="http://www.slitaz.org/">SliTaz</a></li>
|
pankso@7932
|
283 <li><a href="http://www.slitaz.org/en/about/">About the project</a></li>
|
pankso@7932
|
284 <li><a href="http://pkgs.slitaz.org/search.cgi">Search packages</a></li>
|
pankso@7932
|
285 <li>Page modified the _DATE_</li>
|
pankso@7932
|
286 <li><a href="http://validator.w3.org/check?uri=referer"><img
|
pankso@7932
|
287 src="http://pkgs.slitaz.org/pics/website/xhtml10.png"
|
pankso@7932
|
288 title="Code validé XHTML 1.0" alt="Valid XHTML 1.0"
|
pankso@7932
|
289 style="width: 80px; height: 15px; vertical-align: middle;" /></a></li>
|
pankso@7932
|
290 </ul>
|
pankso@3521
|
291 </div>
|
pankso@3521
|
292
|
pankso@3521
|
293 </body>
|
pankso@3521
|
294 </html>
|
pankso@3521
|
295 _EOT_
|
pankso@3521
|
296 }
|
pankso@3521
|
297
|
pascal@4840
|
298 installed_size()
|
pascal@4840
|
299 {
|
pascal@4840
|
300 [ $VERBOSE -gt 0 ] &&
|
pascal@4840
|
301 grep -A 3 "^$1\$" /home/slitaz/$SLITAZ_VERSION/packages/packages.txt | \
|
pascal@4840
|
302 grep installed | sed 's/.*(\(.*\) installed.*/(\1) /'
|
pascal@4840
|
303 }
|
pascal@4840
|
304
|
pascal@5822
|
305 package_entry()
|
pascal@5822
|
306 {
|
pascal@5822
|
307 if [ -s "$(dirname $0)/$SLITAZ_VERSION/$CATEGORY.html" ]; then
|
pascal@5822
|
308 cat << _EOT_
|
pascal@5822
|
309 <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
|
pascal@5822
|
310 _EOT_
|
pascal@5822
|
311 else
|
pascal@5822
|
312 cat << _EOT_
|
pascal@5822
|
313 <a href="http://mirror.slitaz.org/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION$EXTRA_VERSION.tazpkg">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
|
pascal@5822
|
314 _EOT_
|
pascal@5822
|
315 fi
|
pascal@5822
|
316 }
|
pascal@5822
|
317
|
pascal@3780
|
318 # recursive dependencies scan
|
pascal@3780
|
319 dep_scan()
|
pascal@3780
|
320 {
|
pankso@3521
|
321 for i in $1; do
|
pankso@3521
|
322 case " $ALL_DEPS " in
|
pankso@3521
|
323 *\ $i\ *) continue;;
|
pankso@3521
|
324 esac
|
pankso@3521
|
325 ALL_DEPS="$ALL_DEPS $i"
|
pankso@3521
|
326 if [ -n "$2" ]; then
|
pankso@3521
|
327 echo -n "$2"
|
pankso@3521
|
328 (
|
pankso@3521
|
329 . $WOK/$i/receipt
|
pascal@5822
|
330 package_entry
|
pankso@3521
|
331 )
|
pankso@3521
|
332 fi
|
pankso@3521
|
333 [ -f $WOK/$i/receipt ] || continue
|
pankso@3521
|
334 DEPENDS=""
|
pankso@3521
|
335 . $WOK/$i/receipt
|
pankso@3521
|
336 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
|
pankso@3521
|
337 done
|
pankso@3521
|
338 }
|
pankso@3521
|
339
|
pascal@3780
|
340 # recursive reverse dependencies scan
|
pascal@3780
|
341 rdep_scan()
|
pascal@3780
|
342 {
|
pankso@3521
|
343 SEARCH=$1
|
pankso@3521
|
344 case "$SEARCH" in
|
pankso@3521
|
345 glibc-base|gcc-lib-base) cat <<EOT
|
paul@3528
|
346 glibc-base and gcc-lib-base are implicit dependencies,
|
paul@3528
|
347 <b>every</b> package is supposed to depend on them.
|
pankso@3521
|
348 EOT
|
pankso@3521
|
349 return;;
|
pankso@3521
|
350 esac
|
pankso@3521
|
351 for i in $WOK/* ; do
|
pankso@3521
|
352 DEPENDS=""
|
pankso@3521
|
353 . $i/receipt
|
pankso@3521
|
354 echo "$(basename $i) $(echo $DEPENDS)"
|
pankso@3521
|
355 done | awk -v search=$SEARCH '
|
pankso@3521
|
356 function show_deps(deps, all_deps, pkg, space)
|
pankso@3521
|
357 {
|
pankso@3521
|
358 if (all_deps[pkg] == 1) return
|
pankso@3521
|
359 all_deps[pkg] = 1
|
pankso@3521
|
360 if (space != "") printf "%s%s\n",space,pkg
|
pankso@3521
|
361 for (i = 1; i <= split(deps[pkg], mydeps, " "); i++) {
|
pankso@3521
|
362 show_deps(deps, all_deps, mydeps[i],"////" space)
|
pankso@3521
|
363 }
|
pankso@3521
|
364 }
|
pankso@3521
|
365
|
pankso@3521
|
366 {
|
pankso@3521
|
367 all_deps[$1] = 0
|
pankso@3521
|
368 for (i = 2; i <= NF; i++)
|
pankso@3521
|
369 deps[$i] = deps[$i] " " $1
|
pankso@3521
|
370 }
|
pankso@3521
|
371
|
pankso@3521
|
372 END {
|
pankso@3521
|
373 show_deps(deps, all_deps, search, "")
|
pankso@3521
|
374 }
|
pankso@3521
|
375 ' | while read pkg; do
|
pankso@3521
|
376 . $WOK/${pkg##*/}/receipt
|
pankso@3521
|
377 cat << _EOT_
|
pascal@5822
|
378 $(echo ${pkg%/*} | sed 's|/| |g') $(package_entry)
|
pankso@3521
|
379 _EOT_
|
pankso@3521
|
380 done
|
pankso@3521
|
381 }
|
pankso@3521
|
382
|
pankso@3521
|
383 # Check package exists
|
pankso@3521
|
384 package_exist()
|
pankso@3521
|
385 {
|
pankso@3521
|
386 [ -f $WOK/$1/receipt ] && return 0
|
pankso@3521
|
387 cat << _EOT_
|
pankso@3521
|
388
|
pankso@3521
|
389 <h3>$noresult</h3>
|
pankso@3521
|
390 <pre class="package">
|
pankso@3521
|
391 _EOT_
|
pankso@3521
|
392 return 1
|
pankso@3521
|
393 }
|
pankso@3521
|
394
|
pascal@3780
|
395 # Display < > &
|
pascal@3780
|
396 htmlize()
|
pascal@3780
|
397 {
|
pascal@3780
|
398 sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'
|
pascal@3780
|
399 }
|
pascal@3780
|
400
|
pascal@4840
|
401 display_packages_and_files()
|
pascal@4840
|
402 {
|
pascal@4840
|
403 last=""
|
pascal@4840
|
404 while read pkg file; do
|
pascal@4840
|
405 pkg=${pkg%:}
|
pascal@4840
|
406 if [ "$pkg" != "$last" ]; then
|
pascal@4840
|
407 . $WOK/$pkg/receipt
|
pascal@5822
|
408
|
pascal@5822
|
409 package_entry
|
pascal@4840
|
410 last=$pkg
|
pascal@4840
|
411 fi
|
pascal@4840
|
412 echo " $file"
|
pascal@4840
|
413 done
|
pascal@4840
|
414 }
|
pascal@4840
|
415
|
pankso@3521
|
416 # Display search form and result if requested.
|
pankso@3521
|
417 if [ "$REQUEST_METHOD" != "POST" ]; then
|
pankso@3521
|
418 xhtml_header
|
pankso@3521
|
419 cat << _EOT_
|
pankso@3521
|
420
|
pankso@3521
|
421 <!-- Content -->
|
pankso@3521
|
422 <div id="content">
|
pankso@3521
|
423
|
pankso@7932
|
424 <h1>$package</h1>
|
pankso@7932
|
425 <h2>$search</h2>
|
pankso@3521
|
426 _EOT_
|
pankso@3521
|
427 search_form
|
pankso@3521
|
428 xhtml_footer
|
pankso@3521
|
429 else
|
pankso@3521
|
430 xhtml_header
|
pankso@3521
|
431 cat << _EOT_
|
pankso@3521
|
432
|
pankso@3521
|
433 <!-- Content -->
|
pankso@3521
|
434 <div id="content">
|
pankso@3521
|
435
|
pankso@7932
|
436 <h1>$package</h1>
|
pankso@7932
|
437 <h2>$search</h2>
|
pankso@3521
|
438 _EOT_
|
pankso@3521
|
439 search_form
|
pankso@3521
|
440 if [ "$OBJECT" = "Depends" ]; then
|
pankso@3521
|
441 if package_exist $SEARCH ; then
|
pankso@3521
|
442 cat << _EOT_
|
pankso@3521
|
443
|
pankso@3521
|
444 <h3>$deptree</h3>
|
pankso@3521
|
445 <pre class="package">
|
pankso@3521
|
446 _EOT_
|
pankso@3521
|
447 ALL_DEPS=""
|
pankso@3521
|
448 dep_scan $SEARCH ""
|
pankso@3521
|
449 SUGGESTED=""
|
pankso@3521
|
450 . $WOK/$SEARCH/receipt
|
pankso@3521
|
451 if [ -n "$SUGGESTED" ]; then
|
pankso@3521
|
452 cat << _EOT_
|
pankso@3521
|
453 </pre>
|
pankso@3521
|
454
|
pankso@3521
|
455 <h3>$deptree (SUGGESTED)</h3>
|
pankso@3521
|
456 <pre class="package">
|
pankso@3521
|
457 _EOT_
|
pankso@3521
|
458 ALL_DEPS=""
|
pankso@3521
|
459 dep_scan "$SUGGESTED" " "
|
pankso@3521
|
460 fi
|
pankso@3521
|
461 cat << _EOT_
|
pankso@3521
|
462 </pre>
|
pankso@3521
|
463
|
pankso@3521
|
464 <h3>$rdeptree</h3>
|
pankso@3521
|
465 <pre class="package">
|
pankso@3521
|
466 _EOT_
|
pankso@3521
|
467 ALL_DEPS=""
|
pankso@3521
|
468 rdep_scan $SEARCH
|
pascal@4840
|
469 cat << _EOT_
|
pascal@4840
|
470 </pre>
|
pascal@4840
|
471 _EOT_
|
pascal@4840
|
472 fi
|
pascal@4840
|
473 elif [ "$OBJECT" = "BuildDepends" ]; then
|
pascal@4840
|
474 if package_exist $SEARCH ; then
|
pascal@4840
|
475 cat << _EOT_
|
pascal@4840
|
476
|
pascal@4840
|
477 <h3>$bdeplist</h3>
|
pascal@4840
|
478 <pre class="package">
|
pascal@4840
|
479 _EOT_
|
pascal@4840
|
480 BUILD_DEPENDS=""
|
pascal@4840
|
481 . $WOK/$SEARCH/receipt
|
pascal@4840
|
482 [ -n "$BUILD_DEPENDS" ] && for dep in $BUILD_DEPENDS ; do
|
pascal@4840
|
483 if [ ! -s $WOK/$dep/receipt ]; then
|
pascal@4840
|
484 cat << _EOT_
|
pascal@4840
|
485 $dep: not found !
|
pascal@4840
|
486 _EOT_
|
pascal@4840
|
487 continue
|
pascal@4840
|
488 fi
|
pascal@4840
|
489 . $WOK/$dep/receipt
|
pascal@5822
|
490 package_entry
|
pascal@4840
|
491 done
|
pascal@4840
|
492 cat << _EOT_
|
pascal@4840
|
493 </pre>
|
pascal@4840
|
494
|
pascal@4840
|
495 <h3>$rbdeplist</h3>
|
pascal@4840
|
496 <pre class="package">
|
pascal@4840
|
497 _EOT_
|
pascal@4840
|
498 for dep in $(grep -l $SEARCH $WOK/*/receipt); do
|
pascal@4840
|
499 BUILD_DEPENDS=""
|
pascal@4840
|
500 . $dep
|
pascal@4840
|
501 echo " $BUILD_DEPENDS " | grep -q " $SEARCH " &&
|
pascal@5822
|
502 package_entry
|
pascal@4840
|
503 done
|
pascal@4840
|
504 cat << _EOT_
|
pascal@4840
|
505 </pre>
|
pascal@4840
|
506 _EOT_
|
pascal@4840
|
507 fi
|
pascal@4840
|
508 elif [ "$OBJECT" = "FileOverlap" ]; then
|
pascal@4840
|
509 if package_exist $SEARCH ; then
|
pascal@4840
|
510 cat << _EOT_
|
pascal@4840
|
511
|
pascal@4840
|
512 <h3>$overloading $SEARCH</h3>
|
pascal@4840
|
513 <pre class="package">
|
pascal@4840
|
514 _EOT_
|
pascal@4840
|
515 ( unlzma -c $PACKAGES_REPOSITORY/files.list.lzma | grep ^$SEARCH: ;
|
pascal@4840
|
516 unlzma -c $PACKAGES_REPOSITORY/files.list.lzma | grep -v ^$SEARCH: ) | awk '
|
pascal@7862
|
517 BEGIN { pkg=""; last="x" }
|
pascal@4840
|
518 {
|
pascal@7862
|
519 if ($2 == "") next
|
pascal@7863
|
520 if (index($2,last) == 1 && substr($2,1+length(last),1) == "/")
|
pascal@7863
|
521 delete file[last]
|
pascal@7862
|
522 last=$2
|
pascal@4840
|
523 if (pkg == "") pkg=$1
|
pascal@4840
|
524 if ($1 == pkg) file[$2]=$1
|
pascal@4840
|
525 else if (file[$2] == pkg) print
|
pascal@4840
|
526 }
|
pascal@4840
|
527 ' | display_packages_and_files
|
pascal@4840
|
528 cat << _EOT_
|
pascal@4840
|
529 </pre>
|
pascal@4840
|
530 _EOT_
|
pankso@3521
|
531 fi
|
pankso@3521
|
532 elif [ "$OBJECT" = "File" ]; then
|
pankso@3521
|
533 cat << _EOT_
|
pankso@3521
|
534
|
pankso@3521
|
535 <h3>$result</h3>
|
pankso@3521
|
536 <pre class="package">
|
pankso@3521
|
537 _EOT_
|
pankso@3521
|
538 last=""
|
pascal@3551
|
539 unlzma -c $PACKAGES_REPOSITORY/files.list.lzma \
|
pankso@3521
|
540 | grep $SEARCH | while read pkg file; do
|
pankso@3521
|
541 echo "$file" | grep -q $SEARCH || continue
|
pankso@3521
|
542 if [ "$last" != "${pkg%:}" ]; then
|
pankso@3521
|
543 last=${pkg%:}
|
pankso@3521
|
544 (
|
pankso@3521
|
545 . $WOK/$last/receipt
|
pankso@3521
|
546 cat << _EOT_
|
pankso@3521
|
547
|
pascal@5822
|
548 <i>$(package_entry)</i>
|
pankso@3521
|
549 _EOT_
|
pankso@3521
|
550 )
|
pankso@3521
|
551 fi
|
pankso@3521
|
552 echo " $file"
|
pankso@3521
|
553 done
|
pankso@3521
|
554 elif [ "$OBJECT" = "File_list" ]; then
|
pankso@3521
|
555 package_exist $SEARCH && cat << _EOT_
|
pankso@3521
|
556
|
pankso@3521
|
557 <h3>$result</h3>
|
pankso@3521
|
558 <pre class="package">
|
pankso@3521
|
559 _EOT_
|
pankso@3521
|
560 last=""
|
pascal@3551
|
561 unlzma -c $PACKAGES_REPOSITORY/files.list.lzma \
|
pankso@3521
|
562 | grep ^$SEARCH: | sed 's/.*: / /' | sort
|
pankso@3521
|
563 elif [ "$OBJECT" = "Desc" ]; then
|
pascal@3780
|
564 if [ -f $WOK/$SEARCH/description.txt ]; then
|
pascal@3780
|
565 cat << _EOT_
|
pascal@3780
|
566
|
pascal@3780
|
567 <h3>$result</h3>
|
pascal@3780
|
568 <pre class="package">
|
pascal@3780
|
569 <pre>
|
pascal@3780
|
570 $(htmlize < $WOK/$SEARCH/description.txt)
|
pascal@3780
|
571 </pre>
|
pascal@3780
|
572 _EOT_
|
pascal@3780
|
573 else
|
pascal@3780
|
574 cat << _EOT_
|
pankso@3521
|
575
|
pankso@3521
|
576 <h3>$result</h3>
|
pankso@3521
|
577 <pre class="package">
|
pankso@3521
|
578 _EOT_
|
pascal@3780
|
579 last=""
|
pascal@3780
|
580 grep -i $SEARCH $PACKAGES_REPOSITORY/packages.desc | \
|
pascal@3780
|
581 sort | while read pkg extras ; do
|
pankso@3521
|
582 . $WOK/$pkg/receipt
|
pascal@5822
|
583 package_entry
|
pankso@3521
|
584 done
|
pascal@3780
|
585 fi
|
pankso@3521
|
586 elif [ "$OBJECT" = "Tags" ]; then
|
pankso@3521
|
587 cat << _EOT_
|
pankso@3521
|
588
|
pankso@3521
|
589 <h3>$result</h3>
|
pankso@3521
|
590 <pre class="package">
|
pankso@3521
|
591 _EOT_
|
pankso@3521
|
592 last=""
|
pankso@3521
|
593 grep ^TAGS= $WOK/*/receipt | grep -i $SEARCH | \
|
pankso@3521
|
594 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
pankso@3521
|
595 . $WOK/$pkg/receipt
|
pascal@5822
|
596 package_entry
|
pankso@3521
|
597 done
|
pankso@3521
|
598 elif [ "$OBJECT" = "Receipt" ]; then
|
pankso@3521
|
599 package_exist $SEARCH && cat << _EOT_
|
pankso@3521
|
600
|
pankso@3521
|
601 <h3>$result</h3>
|
pankso@3521
|
602 <pre class="package">
|
pankso@3521
|
603 <pre>
|
pankso@3521
|
604 $(if [ -f $WOK/$SEARCH/taz/*/receipt ]; then
|
pankso@3521
|
605 cat $WOK/$SEARCH/taz/*/receipt
|
pankso@3521
|
606 else
|
pascal@3780
|
607 cat $WOK/$SEARCH/receipt
|
pascal@3780
|
608 fi | htmlize)
|
pankso@3521
|
609 </pre>
|
pankso@3521
|
610 _EOT_
|
pankso@3521
|
611 else
|
pankso@3521
|
612 cat << _EOT_
|
pankso@3521
|
613
|
pankso@3521
|
614 <h3>$result</h3>
|
pankso@3521
|
615 <pre class="package">
|
pankso@3521
|
616 _EOT_
|
pascal@4840
|
617 for pkg in `ls $WOK/ | grep $SEARCH`
|
pankso@3521
|
618 do
|
pankso@3521
|
619 . $WOK/$pkg/receipt
|
pascal@3780
|
620 DESC=" <a href=\"?desc=$pkg\">description</a>"
|
pascal@3780
|
621 [ -f $WOK/$pkg/description.txt ] || DESC=""
|
pankso@3521
|
622 cat << _EOT_
|
pascal@5822
|
623 $(package_entry)$DESC
|
pankso@3521
|
624 _EOT_
|
pankso@3521
|
625 done
|
pascal@3551
|
626 equiv=$PACKAGES_REPOSITORY/packages.equiv
|
pankso@3521
|
627 vpkgs="$(cat $equiv | cut -d= -f1 | grep $SEARCH)"
|
pankso@3521
|
628 for vpkg in $vpkgs ; do
|
pankso@3521
|
629 cat << _EOT_
|
pankso@3521
|
630 </pre>
|
pankso@3521
|
631
|
pankso@3521
|
632 <h3>$result (package providing $vpkg)</h3>
|
pankso@3521
|
633 <pre class="package">
|
pankso@3521
|
634 _EOT_
|
pankso@3521
|
635 for pkg in $(grep $vpkg= $equiv | sed "s/$vpkg=//"); do
|
pankso@3521
|
636 . $WOK/${pkg#*:}/receipt
|
pascal@5822
|
637 package_entry
|
pankso@3521
|
638 done
|
pankso@3521
|
639 done
|
pankso@3521
|
640 fi
|
pankso@3521
|
641 cat << _EOT_
|
pankso@3521
|
642 </pre>
|
pankso@3521
|
643 _EOT_
|
pankso@3521
|
644 xhtml_footer
|
pankso@3521
|
645 fi
|
pankso@3521
|
646
|
pankso@3521
|
647 exit 0
|