rev |
line source |
al@603
|
1 #!/bin/sh -v
|
pankso@449
|
2 #
|
pankso@230
|
3 # Tiny CGI search engine for SliTaz packages on http://pkgs.slitaz.org/
|
pankso@230
|
4 # Christophe Lincoln <pankso@slitaz.org>
|
al@284
|
5 # Aleksej Bobylev <al.bobylev@gmail.com>
|
pankso@230
|
6 #
|
al@284
|
7
|
al@603
|
8 date_start="$(date -u +%s)"
|
al@603
|
9
|
slaxemulator@336
|
10 renice -n 19 $$
|
slaxemulator@336
|
11
|
al@603
|
12
|
al@284
|
13 # Parse query string
|
al@603
|
14
|
slaxemulator@320
|
15 . /etc/slitaz/slitaz.conf
|
pankso@266
|
16 . /usr/lib/slitaz/httphelper.sh
|
al@603
|
17 cache='/var/cache/pkgs'
|
al@603
|
18 mkdir -p "$cache"
|
al@603
|
19
|
al@603
|
20 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
|
al@603
|
21 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
|
al@603
|
22 _p() { local S="$1" P="$2" N="$3"; shift 3; printf "$(ngettext "$S" "$P" "$N")" "$@"; }
|
al@603
|
23
|
al@603
|
24
|
pascal@456
|
25 [ -n "$MIRROR_URL" ] || MIRROR_URL="http://mirror.slitaz.org"
|
al@284
|
26
|
al@603
|
27
|
al@284
|
28 # User preferred language
|
al@284
|
29 # parameter $1 have priority; without parameter $1 - browser language only
|
al@284
|
30 # if we don't support any of user languages (or only en), then return C locale
|
al@603
|
31
|
al@284
|
32 user_lang() {
|
al@603
|
33 unset LANG
|
al@603
|
34 IFS=','
|
al@603
|
35 for lang in $1 $HTTP_ACCEPT_LANGUAGE; do
|
al@603
|
36 lang=${lang%;*}; lang=${lang# }; lang=${lang%-*}; lang=${lang%_*}
|
al@284
|
37 case "$lang" in
|
al@603
|
38 de) LANG='de_DE';;
|
al@603
|
39 en) LANG='en_US';;
|
al@603
|
40 es) LANG='es_ES';;
|
al@605
|
41 fa) LANG='fa_IR';;
|
al@603
|
42 fr) LANG='fr_FR';;
|
al@605
|
43 #it) LANG='it_IT';; # We haven't Italian translations
|
al@603
|
44 pl) LANG='pl_PL';;
|
al@603
|
45 pt) LANG='pt_BR';;
|
al@603
|
46 ru) LANG='ru_RU';;
|
al@603
|
47 sv) LANG='sv_SE';;
|
al@603
|
48 uk) LANG='uk_UA';;
|
al@603
|
49 zh) LANG='zh_TW';;
|
al@284
|
50 esac
|
al@603
|
51 [ -n "$LANG" ] && break
|
al@284
|
52 done
|
al@284
|
53 unset IFS
|
al@603
|
54 echo "${LANG:-C}"
|
al@284
|
55 }
|
al@284
|
56
|
al@284
|
57
|
al@293
|
58 # Part of query to indicate current debug mode
|
al@603
|
59
|
al@293
|
60 ifdebug() {
|
al@293
|
61 ifdebug="$(GET debug)"
|
al@603
|
62 [ -n "$ifdebug" ] && ifdebug="$1$ifdebug"
|
al@293
|
63 echo "$ifdebug"
|
al@284
|
64 }
|
al@284
|
65
|
al@603
|
66
|
al@293
|
67 # GET or POST variable
|
al@603
|
68
|
al@293
|
69 GETPOST() {
|
al@293
|
70 echo "$(POST $1)$(GET $1)"
|
al@293
|
71 }
|
al@293
|
72
|
al@603
|
73
|
al@603
|
74 # Nice URL replacer - to copy URL from address bar
|
slaxemulator@320
|
75 # TODO: deal with POST method of form submitting
|
al@603
|
76
|
slaxemulator@320
|
77 nice_url() {
|
slaxemulator@320
|
78 # if user submitted a form
|
al@603
|
79 if [ "$REQUEST_METHOD" == 'POST' -o -n "$(GET submit)" ]; then
|
slaxemulator@320
|
80 OBJECT="$(GETPOST object)"
|
slaxemulator@320
|
81 SEARCH="$(GETPOST query)"
|
slaxemulator@320
|
82 case $OBJECT in
|
slaxemulator@320
|
83 Package) NICE="package=$SEARCH";;
|
slaxemulator@320
|
84 Desc) NICE="desc=$SEARCH";;
|
slaxemulator@320
|
85 Tags) NICE="tags=$SEARCH";;
|
slaxemulator@336
|
86 Arch) NICE="arch=$SEARCH";;
|
slaxemulator@336
|
87 Bugs) NICE="bugs=$SEARCH";;
|
slaxemulator@320
|
88 Receipt) NICE="receipt=$SEARCH";;
|
slaxemulator@320
|
89 Depends) NICE="depends=$SEARCH";;
|
slaxemulator@320
|
90 BuildDepends) NICE="builddepends=$SEARCH";;
|
slaxemulator@320
|
91 File) NICE="file=$SEARCH";;
|
slaxemulator@320
|
92 File_list) NICE="filelist=$SEARCH";;
|
slaxemulator@320
|
93 FileOverlap) NICE="fileoverlap=$SEARCH";;
|
al@603
|
94 Category) NICE="category=$SEARCH";;
|
al@603
|
95 Maintainer) NICE="maintainer=$SEARCH";;
|
al@603
|
96 License) NICE="license=$SEARCH";;
|
slaxemulator@320
|
97 esac
|
al@603
|
98
|
slaxemulator@320
|
99 # version, if needed
|
slaxemulator@320
|
100 version="$(GETPOST version)"
|
al@603
|
101 if [ -n "$version" -a "$version" != 'cooking' -a "$version" != 'c' ]; then
|
al@603
|
102 NICE="$NICE&version=${version:0:1}"
|
slaxemulator@320
|
103 fi
|
al@603
|
104
|
slaxemulator@320
|
105 # lang, if needed
|
slaxemulator@320
|
106 query_lang="$(GETPOST lang)"
|
slaxemulator@320
|
107 pref_lang="$(user_lang)"
|
al@603
|
108 browser_lang="${pref_lang%_*}"
|
al@603
|
109 if [ -n "$query_lang" ]; then
|
al@603
|
110 COOKIE="lang=$query_lang"
|
al@603
|
111 else
|
al@603
|
112 COOKIE=''
|
slaxemulator@320
|
113 fi
|
al@603
|
114
|
slaxemulator@320
|
115 # verbose, if needed
|
slaxemulator@320
|
116 verboseq="$(GETPOST verbose)"
|
al@603
|
117 if [ -n "$verboseq" -a "$verboseq" != '0' ]; then
|
al@603
|
118 NICE="$NICE&verbose=1"
|
slaxemulator@320
|
119 fi
|
al@603
|
120
|
slaxemulator@320
|
121 # debug, if needed
|
slaxemulator@320
|
122 debugq="$(GET debug)"
|
al@603
|
123 if [ -n "$debugq" -a "$debugq" == 'debug' ]; then
|
al@603
|
124 NICE="$NICE&debug"
|
slaxemulator@320
|
125 fi
|
al@603
|
126
|
slaxemulator@320
|
127 # redirect
|
al@603
|
128 if [ -z "$COOKIE" ]; then
|
al@603
|
129 header "HTTP/1.1 301 Moved Permanently" "Location: ?$NICE"
|
al@603
|
130 else
|
al@603
|
131 header "HTTP/1.1 301 Moved Permanently" "Set-Cookie: $COOKIE" "Location: ?$NICE"
|
al@603
|
132 fi
|
slaxemulator@320
|
133 exit 0
|
al@293
|
134 fi
|
slaxemulator@320
|
135 }
|
al@284
|
136
|
al@603
|
137
|
slaxemulator@320
|
138 nice_url
|
al@284
|
139
|
al@261
|
140
|
al@603
|
141
|
pankso@268
|
142
|
al@261
|
143 # Internationalization
|
al@261
|
144 . /usr/bin/gettext.sh
|
al@284
|
145 export TEXTDOMAIN='tazpkg-web'
|
al@603
|
146 # Translate actions once
|
al@603
|
147 a_co="$(_ 'Cooker')"
|
al@603
|
148 a_dl="$(_ 'Download')"
|
al@603
|
149 a_rc="$(_ 'Receipt')"
|
pankso@239
|
150
|
al@603
|
151
|
al@603
|
152
|
al@603
|
153
|
al@603
|
154 # Cache icons to fast search
|
al@603
|
155 # Find the latest update in the "icons" folder
|
al@605
|
156 unset ICONS_CACHE_REBUILDED
|
al@603
|
157 iconslast="$cache/icons.$(date -u +%s -r /var/www/pkgs/icons/$(ls -t /var/www/pkgs/icons | head -n1))"
|
al@603
|
158
|
al@603
|
159 if [ ! -f "$iconslast" ]; then
|
al@603
|
160 find "$cache" -name 'icons.*' -delete
|
al@603
|
161
|
al@603
|
162 (
|
al@603
|
163 cat icons/packages.icons
|
al@603
|
164 awk '{printf "%s\tcli\n",$1}' icons/packages-cli.icons
|
llevrel@607
|
165 awk '{printf "%s\tdoc\n",$1}' icons/packages-doc.icons
|
al@603
|
166 awk '{printf "%s\tfont\n",$1}' icons/packages-font.icons
|
al@603
|
167 awk '{printf "%s\ti18n\n",$1}' icons/packages-i18n.icons
|
al@603
|
168 awk '{printf "%s\tthm\n",$1}' icons/packages-thm.icons
|
al@605
|
169 awk '{printf "%s\tlib\n",$1}' icons/packages-lib.icons
|
al@605
|
170 awk '{printf "%s\tpy\n",$1}' icons/packages-py.icons
|
al@605
|
171 awk '{printf "%s\tperl\n",$1}' icons/packages-perl.icons
|
al@603
|
172 ls icons/*.png | awk -F/ '{sub(/\.png/,"",$2);printf "%s\t%s\n", $2, $2}'
|
al@603
|
173 ) | sort > "$iconslast"
|
al@605
|
174 ICONS_CACHE_REBUILDED='yes'
|
al@603
|
175 fi
|
al@603
|
176
|
al@603
|
177
|
al@603
|
178
|
al@603
|
179 unset SEARCH SLITAZ_VERSION
|
al@284
|
180 VERBOSE=0
|
al@603
|
181 s='selected'
|
al@284
|
182 for i in $(echo $QUERY_STRING | sed 's/[?&]/ /g'); do
|
al@284
|
183 case "$(echo $i | tr [A-Z] [a-z])" in
|
al@284
|
184 query=*|search=*) [ ${i#*=} == Search ] || SEARCH=${i#*=};;
|
al@284
|
185 object=*) OBJECT=${i#*=};;
|
al@284
|
186 verbose=*) VERBOSE=${i#*=};;
|
al@284
|
187 lang=*) LANG=${i#*=};;
|
al@603
|
188 file=*) SEARCH=${i#*=}; OBJECT='File'; sel_file=$s;;
|
al@603
|
189 desc=*) SEARCH=${i#*=}; OBJECT='Desc'; sel_desc=$s;;
|
al@603
|
190 tags=*) SEARCH=${i#*=}; OBJECT='Tags'; sel_tags=$s;;
|
al@603
|
191 arch=*) SEARCH=${i#*=}; OBJECT='Arch'; sel_arch=$s;;
|
al@603
|
192 bugs=*) SEARCH=${i#*=}; OBJECT='Bugs'; sel_bugs=$s;;
|
al@603
|
193 receipt=*) SEARCH=${i#*=}; OBJECT='Receipt'; sel_rcpt=$s;;
|
al@603
|
194 filelist=*) SEARCH=${i#*=}; OBJECT='File_list'; sel_flst=$s;;
|
al@603
|
195 package=*) SEARCH=${i#*=}; OBJECT='Package';;
|
al@603
|
196 depends=*) SEARCH=${i#*=}; OBJECT='Depends'; sel_deps=$s;;
|
al@603
|
197 builddepends=*) SEARCH=${i#*=}; OBJECT='BuildDepends'; sel_bdps=$s;;
|
al@603
|
198 fileoverlap=*) SEARCH=${i#*=}; OBJECT='FileOverlap'; sel_over=$s;;
|
al@603
|
199 category=*) SEARCH=${i#*=}; OBJECT='Category'; sel_catg=$s;;
|
al@603
|
200 maintainer=*) SEARCH=${i#*=}; OBJECT='Maintainer'; sel_mtnr=$s;;
|
al@603
|
201 license=*) SEARCH=${i#*=}; OBJECT='License'; sel_lcns=$s;;
|
al@603
|
202 version=1*) SLITAZ_VERSION='1.0'; sel_1=$s;;
|
al@603
|
203 version=2*) SLITAZ_VERSION='2.0'; sel_2=$s;;
|
al@603
|
204 version=3*) SLITAZ_VERSION='3.0'; sel_3=$s;;
|
al@603
|
205 version=s*|version=4*) SLITAZ_VERSION='stable'; sel_s=$s;;
|
al@603
|
206 version=u*) SLITAZ_VERSION='undigest'; sel_u=$s;;
|
al@603
|
207 version=b*) SLITAZ_VERSION='backports'; sel_b=$s;;
|
al@603
|
208 version=t*) SLITAZ_VERSION='tiny'; sel_t=$s;;
|
al@284
|
209 esac
|
al@284
|
210 done
|
al@603
|
211 [ -z "$SLITAZ_VERSION" ] && SLITAZ_VERSION='cooking'
|
al@605
|
212 addver=''; [ "$SLITAZ_VERSION" != 'cooking' ] && addver="&version=$SLITAZ_VERSION"
|
al@603
|
213 SEARCH="${SEARCH//%20/ }"
|
al@284
|
214
|
al@293
|
215 #
|
pankso@268
|
216 # Content negotiation for Gettext
|
al@293
|
217 #
|
al@603
|
218
|
al@603
|
219 LANG=$(user_lang $(COOKIE lang))
|
al@603
|
220 lang="${LANG%_*}"
|
pankso@278
|
221 export LANG LC_ALL=$LANG
|
pankso@230
|
222
|
al@284
|
223
|
pankso@452
|
224 #
|
pankso@452
|
225 # Unescape query and set vars
|
pankso@452
|
226 #
|
al@603
|
227
|
al@603
|
228 SEARCH="$(echo $SEARCH | sed 's|%2B|+|g; s|%3A|:|g; s|%2F|/|g')"
|
al@603
|
229
|
pankso@452
|
230 SLITAZ_HOME="/home/slitaz"
|
al@603
|
231 if [ "$SLITAZ_VERSION" == 'cooking' ]; then
|
al@603
|
232 WOK="$SLITAZ_HOME/wok"
|
pankso@451
|
233 else
|
al@603
|
234 WOK="$SLITAZ_HOME/wok-$SLITAZ_VERSION"
|
pankso@451
|
235 fi
|
al@603
|
236
|
al@603
|
237 pkgsrepo="$SLITAZ_HOME/$SLITAZ_VERSION/packages"
|
al@603
|
238 repoid="$(cat "$pkgsrepo/ID")"
|
al@603
|
239 filelist="$pkgsrepo/files.list.lzma"
|
al@603
|
240 pkglist="$pkgsrepo/packages.txt"
|
al@603
|
241 equiv="$pkgsrepo/packages.equiv"
|
al@603
|
242 pinfo="$pkgsrepo/packages.info"
|
al@603
|
243
|
al@605
|
244 # Date of the last modification (both packages DB or icons DB)
|
al@605
|
245 if [ -f "$pkgsrepo/ID" ]; then
|
al@605
|
246 if [ "$iconslast" -nt "$pkgsrepo/ID" ]; then
|
al@605
|
247 lastmod="$(date -Rur "$iconslast")"
|
al@605
|
248 else
|
al@605
|
249 lastmod="$(date -Rur "$pkgsrepo/ID")"
|
al@605
|
250 fi
|
al@605
|
251 lastmod="${lastmod/UTC/GMT}"
|
al@605
|
252 fi
|
al@605
|
253
|
al@603
|
254
|
al@603
|
255
|
pankso@230
|
256
|
pankso@230
|
257 # Search form
|
al@284
|
258 # TODO: add hint 'You are can search for depends loop, if textfield is empty'...
|
al@284
|
259 # add progress ticker while page is not complete
|
al@603
|
260
|
al@603
|
261 search_form() {
|
al@603
|
262 [ -z "$SEARCH$(GET info)" ] && autofocus='autofocus'
|
al@603
|
263
|
al@603
|
264 cat <<EOT
|
pankso@230
|
265
|
al@293
|
266 <div class="form">
|
al@603
|
267 <form id="s_form" name="s_form" method="post" action="$(ifdebug '?')">
|
al@293
|
268 <span class="small">
|
al@293
|
269 <select name="object">
|
al@605
|
270 <option value="Package" class="pkg">$(_ 'Package name')</option>
|
al@605
|
271 <option $sel_desc value="Desc" class="description">$(_ 'Description')</option>
|
al@605
|
272 <option $sel_tags value="Tags" class="tag">$(_ 'Tag')</option>
|
al@605
|
273 <option $sel_arch value="Arch" class="arch">$(_ 'Architecture')</option>
|
al@605
|
274 <option $sel_bugs value="Bugs" class="bugs">$(_ 'Bugs')</option>
|
al@605
|
275 <option $sel_rcpt value="Receipt" class="receipt">$(_ 'Receipt')</option>
|
al@605
|
276 <option $sel_deps value="Depends" class="dep">$(_ 'Dependencies')</option>
|
al@605
|
277 <option $sel_bdps value="BuildDepends" class="dep">$(_ 'Build dependencies')</option>
|
al@605
|
278 <option $sel_file value="File" class="file">$(_ 'File')</option>
|
al@605
|
279 <option $sel_flst value="File_list" class="files-list">$(_ 'File list')</option>
|
al@605
|
280 <option $sel_over value="FileOverlap" class="common">$(_ 'Common files')</option>
|
al@605
|
281 <option $sel_catg value="Category" class="category">$(_ 'Category')</option>
|
al@605
|
282 <option $sel_mtnr value="Maintainer" class="avatar">$(_ 'Maintainer')</option>
|
al@605
|
283 <option $sel_lcns value="License" class="license">$(_ 'License')</option>
|
al@293
|
284 </select>
|
al@293
|
285 </span>
|
al@293
|
286 <span class="stretch">
|
al@603
|
287 <input $autofocus type="search" name="query" id="query" value="$SEARCH$(GET info)"
|
al@603
|
288 autocorrect="off" autocapitalize="off" autocomplete="on" spellcheck="false"
|
al@603
|
289 results="5" autosave="pkgsearch"/>
|
al@293
|
290 </span>
|
al@293
|
291 <span class="small">
|
al@603
|
292 <select name="version" title="$(_ 'SliTaz version')">
|
al@603
|
293 <option value="cooking">$( _ 'cooking')</option>
|
al@603
|
294 <option $sel_s value="stable">4.0</option>
|
al@603
|
295 <option $sel_3 value="3.0">3.0</option>
|
al@603
|
296 <option $sel_2 value="2.0">2.0</option>
|
al@603
|
297 <option $sel_1 value="1.0">1.0</option>
|
al@603
|
298 <option $sel_t value="tiny">$( _ 'tiny')</option>
|
al@603
|
299 <option $sel_u value="undigest">$( _ 'undigest')</option>
|
al@603
|
300 <option $sel_b value="backports">$( _ 'backports')</option>
|
al@293
|
301 </select>
|
al@293
|
302 </span>
|
al@293
|
303 <span class="small">
|
al@603
|
304 <button type="submit">$(_ 'Search')</button>
|
al@293
|
305 </span>
|
pankso@230
|
306 </form>
|
al@293
|
307 </div>
|
al@603
|
308 EOT
|
pankso@230
|
309 }
|
pankso@230
|
310
|
al@603
|
311
|
al@261
|
312 # xHTML5 Header.
|
al@603
|
313
|
pankso@231
|
314 xhtml_header() {
|
al@261
|
315 . lib/header.sh
|
pankso@230
|
316 }
|
pankso@230
|
317
|
al@603
|
318
|
al@603
|
319 # FIXME: unused function
|
al@603
|
320
|
al@603
|
321 cat_files_list() {
|
al@603
|
322 local tmp="/tmp/files.list.$(basename ${1%/packages})"
|
al@603
|
323 if [ ! -s "$tmp" -o "$1/files.list.lzma" -nt "$tmp" ]; then
|
al@603
|
324 unlzma < "$1/files.list.lzma" > "$tmp.$$" && mv "$tmp.$$" "$tmp"
|
slaxemulator@336
|
325 fi
|
slaxemulator@336
|
326 case "$2" in
|
al@603
|
327 lines)
|
al@603
|
328 if [ ! -s "$tmp.lines" -o "$tmp" -nt "$tmp.lines" ]; then
|
al@603
|
329 wc -l < "$tmp" > "$tmp.lines.$$" &&
|
al@603
|
330 mv "$tmp.lines.$$" "$tmp.lines"
|
al@603
|
331 fi
|
al@603
|
332 cat "$tmp.lines"
|
al@603
|
333 ;;
|
al@603
|
334 *)
|
al@603
|
335 cat "$tmp";;
|
slaxemulator@336
|
336 esac
|
slaxemulator@336
|
337 }
|
slaxemulator@336
|
338
|
al@603
|
339
|
al@603
|
340
|
al@603
|
341
|
pankso@230
|
342 # xHTML Footer.
|
al@603
|
343
|
pankso@231
|
344 xhtml_footer() {
|
al@603
|
345 # Number of packages in the current repo
|
al@603
|
346 if [ ! -f "$cache/stat.p.$SLITAZ_VERSION.$repoid" ]; then
|
al@603
|
347 rm $cache/stat.p.$SLITAZ_VERSION.*
|
al@603
|
348 ls "$WOK/" | wc -l > "$cache/stat.p.$SLITAZ_VERSION.$repoid"
|
al@603
|
349 fi
|
al@603
|
350
|
al@603
|
351 # Number of files in the current repo
|
al@603
|
352 if [ ! -f "$cache/stat.f.$SLITAZ_VERSION.$repoid" ]; then
|
al@603
|
353 rm $cache/stat.f.$SLITAZ_VERSION.*
|
al@603
|
354 unlzma < "$filelist" | wc -l > "$cache/stat.f.$SLITAZ_VERSION.$repoid"
|
al@603
|
355 fi
|
al@603
|
356
|
al@603
|
357 PKGS=$( cat "$cache/stat.p.$SLITAZ_VERSION.$repoid")
|
al@603
|
358 FILES=$(cat "$cache/stat.f.$SLITAZ_VERSION.$repoid")
|
al@605
|
359 echo -en '\n<div class="summary">'
|
al@603
|
360 _p '%s package' '%s packages' "$PKGS" \
|
al@603
|
361 "$PKGS"
|
al@603
|
362 _p ' and %s file in %s database' ' and %s files in %s database' "$FILES" \
|
al@603
|
363 "$FILES" "$SLITAZ_VERSION"
|
al@605
|
364
|
al@605
|
365 # Date of the last update...
|
al@605
|
366 echo -n ' ('
|
al@605
|
367 if [ -e "$pkgsrepo/IDs" ]; then
|
al@605
|
368 # ...based on the value inside IDs
|
al@605
|
369 date +"%c" -d@$(cut -d' ' -f2 "$pkgsrepo/IDs") | tr -d '\n'
|
al@605
|
370 elif [ -e "$pkgsrepo/ID" ]; then
|
al@605
|
371 # ...based on the date of ID
|
al@605
|
372 date +"%c" -r "$pkgsrepo/ID" | tr -d '\n'
|
al@605
|
373 else
|
al@605
|
374 # ...based on the date of the newest file
|
al@605
|
375 date +"%c" -r "$pkgsrepo/$(ls -Lt "$pkgsrepo" | head -n1)" | tr -d '\n'
|
al@605
|
376 fi
|
al@605
|
377 echo -n ')'
|
al@605
|
378
|
al@603
|
379 cat <<EOT
|
al@603
|
380 </div>
|
al@603
|
381 </main>
|
al@603
|
382
|
al@603
|
383 EOT
|
al@603
|
384
|
al@603
|
385 local lang="${LANG%_*}"
|
al@603
|
386 if [ -e "lib/footer.$lang.sh" ]; then
|
al@605
|
387 echo '<footer>'
|
al@603
|
388 . lib/footer.$lang.sh
|
al@603
|
389 else
|
al@605
|
390 echo '<footer dir="ltr">'
|
al@603
|
391 . lib/footer.sh
|
al@603
|
392 fi
|
al@603
|
393
|
al@603
|
394 echo -n '<div class="summary">'
|
al@603
|
395 gen_time=$(( $(date -u +%s) - $date_start ))
|
al@603
|
396 _p 'Page generated in %s second.' 'Page generated in %s seconds.' "$gen_time" \
|
al@603
|
397 "$gen_time"
|
al@603
|
398
|
al@603
|
399 cat <<EOT
|
al@603
|
400 </div>
|
al@603
|
401 <img src="style/qr.png" alt="#" onmouseover="this.title = location.href"
|
al@603
|
402 onclick="this.src = QRCodePNG(location.href, this)"/>
|
al@603
|
403 </footer>
|
al@603
|
404
|
al@603
|
405 <script>
|
al@603
|
406 function QRCodePNG(str, obj) {
|
al@603
|
407 try {
|
al@603
|
408 obj.height = obj.width += 300;
|
al@603
|
409 return QRCode.generatePNG(str, {ecclevel: 'H'});
|
al@603
|
410 }
|
al@603
|
411 catch (any) {
|
al@603
|
412 var element = document.createElement("script");
|
al@603
|
413 element.src = "style/qrcode.min.js";
|
al@603
|
414 element.type ="text/javascript";
|
al@603
|
415 element.onload = function() {
|
al@603
|
416 obj.src = QRCode.generatePNG(str, {ecclevel: 'H'});
|
al@603
|
417 };
|
al@603
|
418 document.body.appendChild(element);
|
al@603
|
419 }
|
pankso@230
|
420 }
|
pankso@230
|
421
|
al@603
|
422 document.getElementById('ticker').style.visibility='hidden';
|
al@603
|
423 </script>
|
al@603
|
424 </body>
|
al@603
|
425 </html>
|
al@603
|
426 EOT
|
al@605
|
427 exit 0
|
al@603
|
428 }
|
al@603
|
429
|
al@603
|
430
|
al@603
|
431
|
al@603
|
432
|
al@603
|
433 # TODO: to remove
|
al@603
|
434
|
al@603
|
435 installed_size() {
|
al@284
|
436 if [ $VERBOSE -gt 0 ]; then
|
slaxemulator@320
|
437 inst=$(grep -A 3 "^$1\$" $pkgslist | grep installed)
|
al@284
|
438 # size=$(echo $inst | cut -d'(' -f2 | cut -d' ' -f1)
|
al@284
|
439 echo $inst | sed 's/.*(\(.*\).*/(\1)/'
|
al@284
|
440 # echo $size
|
al@284
|
441 # | sed 's/.*(\(.*\) installed.*/(\1) /'
|
al@284
|
442 fi
|
pankso@230
|
443 }
|
pankso@230
|
444
|
al@603
|
445
|
al@603
|
446
|
al@603
|
447
|
al@603
|
448 # Package icon
|
al@603
|
449
|
al@603
|
450 package_icon() {
|
al@603
|
451 local icon='pkg'
|
al@603
|
452
|
al@603
|
453 case "$1" in
|
al@603
|
454 *-dev) icon='dev';;
|
al@603
|
455 linux-*|linux64-*) icon='linux';;
|
al@603
|
456 xorg-*) icon='xorg';;
|
al@603
|
457 *) icon=$(awk -F$'\t' -vp="$1" '$1==p{print $2;exit}' "$iconslast");;
|
al@293
|
458 esac
|
al@603
|
459 echo "icons$2/${icon:-pkg}.png"
|
al@293
|
460 }
|
al@293
|
461
|
al@603
|
462
|
al@603
|
463
|
al@603
|
464
|
al@293
|
465 package_entry() {
|
al@603
|
466
|
al@603
|
467 # Level for packages tree
|
al@603
|
468 if [ -n "$1" ]; then
|
al@603
|
469 echo "<tr class=\"l$1\">"
|
al@293
|
470 else
|
al@603
|
471 echo '<tr>'
|
al@603
|
472 fi
|
al@603
|
473
|
al@605
|
474 PACKAGE_URL="$MIRROR_URL/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
|
al@603
|
475
|
al@603
|
476 case "$SLITAZ_VERSION" in
|
al@603
|
477 cooking)
|
al@605
|
478 COOKER="<a href=\"http://cook.slitaz.org/cooker.cgi?pkg=$PACKAGE\" class=\"co\" title=\"$a_co\">$a_co</a>"
|
al@605
|
479 ;;
|
pascal@462
|
480 stable|undigest|backports)
|
al@605
|
481 COOKER="<a href=\"http://cook.slitaz.org/$SLITAZ_VERSION/cooker.cgi?pkg=$PACKAGE\" class=\"co\" title=\"$a_co\">$a_co</a>"
|
al@605
|
482 ;;
|
al@603
|
483 *)
|
al@605
|
484 COOKER=''
|
al@605
|
485 ;;
|
al@603
|
486 esac
|
al@603
|
487
|
al@603
|
488 cat <<EOT
|
al@605
|
489 <td class="first"><a href="?info=$PACKAGE$addver"><img src="$(package_icon $PACKAGE)" alt="$PACKAGE icon"/></a></td>
|
al@603
|
490 <td><b>$PACKAGE</b><br/>$SHORT_DESC</td>
|
al@603
|
491 <td class="last">
|
al@603
|
492 <a class="dl" href="$PACKAGE_URL" title="$a_dl">$a_dl</a>
|
al@605
|
493 <a class="rc" href="?receipt=$PACKAGE$addver" title="$a_rc">$a_rc</a>
|
al@603
|
494 $COOKER
|
al@603
|
495 </td>
|
al@293
|
496 </tr>
|
al@293
|
497 EOT
|
al@293
|
498 }
|
slaxemulator@336
|
499
|
al@603
|
500
|
al@603
|
501 package_entries() {
|
al@603
|
502 # Input: $1 = [ desc | category | tags | name ]
|
al@603
|
503 # $2 = query
|
al@603
|
504
|
al@603
|
505 awk -F$'\t' -vtype="$1" -vquery="$2" -vmurl="$MIRROR_URL" -vver="$SLITAZ_VERSION" \
|
al@605
|
506 -vaco="$a_co" -vadl="$a_dl" -varc="$a_rc" -viconslast="$iconslast" \
|
al@605
|
507 -vnf="$(_ 'Nothing found')" -vaddver="$addver" '
|
al@603
|
508 BEGIN {
|
al@603
|
509 IGNORECASE = 1;
|
al@603
|
510 print "<table class=\"list\">";
|
al@605
|
511 notfound = "y";
|
al@603
|
512 }
|
al@603
|
513
|
al@603
|
514 function cooker() {
|
al@603
|
515 if (ver!="cooking" && ver!="stable" && ver!="undigest" && ver!="backports") return;
|
al@603
|
516
|
al@603
|
517 printf "\t<a href=\"http://cook.slitaz.org/";
|
al@603
|
518 if (ver=="stable" || ver=="undigest" || ver=="backports") printf "%s/", ver;
|
al@603
|
519 printf "cooker.cgi?pkg=%s\" class=\"co\" title=\"%s\">%s</a>", $1, aco, aco;
|
al@603
|
520 }
|
al@603
|
521
|
al@603
|
522 function icon(pkg) {
|
al@603
|
523 i="";
|
al@603
|
524 if (pkg ~ /-dev$/) { return "dev"; }
|
al@603
|
525 if (pkg ~ /^linux(64)?-/) { return "linux"; }
|
al@603
|
526 if (pkg ~ /^xorg-/) { return "xorg"; }
|
al@603
|
527 "awk -vp=\"" pkg "\" \"BEGIN{FS=\\\"\t\\\"}\\\$1==p{print \\\$2;exit}\" " iconslast | getline i;
|
al@603
|
528 if (i) { return i; }
|
al@603
|
529 return "pkg";
|
al@603
|
530 }
|
al@603
|
531
|
al@603
|
532 function tabline() {
|
al@603
|
533 markname = $1; if (type=="name") gsub(query, "<mark>&</mark>", markname);
|
al@603
|
534 markdesc = $4; if (type=="desc") gsub(query, "<mark>&</mark>", markdesc);
|
al@603
|
535 printf "<tr>\n\t<td class=\"first\">"
|
al@605
|
536 printf "<a href=\"?info=%s%s\">", gensub(/\+/, "%2B", "g", $1), addver;
|
al@605
|
537 printf "<img src=\"icons/%s.png\" alt=\"%s icon\"/></a></td>\n", icon($1), $1;
|
al@603
|
538 printf "\t<td><b>%s</b><br/>%s</td>\n", markname, markdesc;
|
al@603
|
539 printf "\t<td class=\"last\">\n";
|
al@603
|
540 printf "\t<a class=\"dl\" href=\"%s\" ", murl "/packages/" ver "/" $1 "-" $2 ".tazpkg";
|
al@603
|
541 printf "title=\"%s\">%s</a>\n", adl, adl;
|
al@605
|
542 printf "\t<a class=\"rc\" href=\"?receipt=%s%s\" ", $1, addver;
|
al@603
|
543 printf "title=\"%s\">%s</a>\n", arc, arc;
|
al@603
|
544 cooker();
|
al@603
|
545 printf "</td>\n</tr>\n"
|
al@603
|
546 }
|
al@603
|
547
|
al@603
|
548
|
al@603
|
549 {
|
al@605
|
550 if (type=="name" && match($1, query)) { tabline(); notfound = ""; }
|
al@605
|
551 if (type=="category" && $3==query) { tabline(); notfound = ""; }
|
al@605
|
552 if (type=="desc" && match($4, query)) { tabline(); notfound = ""; }
|
al@605
|
553 if (type=="tags" && match(" "$6" ", " "query" ")) { tabline(); notfound = ""; }
|
al@603
|
554 }
|
al@603
|
555
|
al@605
|
556 END {
|
al@605
|
557 if (notfound) printf "<tr><td class=\"first\"><img src=\"icons/notfound.png\" alt="Not found"/></td><td><b>%s</b></td></tr>", nf;
|
al@605
|
558 print "</table>";
|
al@605
|
559 }
|
al@603
|
560 ' "$pinfo";
|
al@603
|
561 }
|
al@603
|
562
|
al@603
|
563
|
al@603
|
564
|
al@603
|
565
|
al@293
|
566 package_entry_inline() {
|
al@603
|
567 # if [ -s "$(dirname $0)/$SLITAZ_VERSION/$CATEGORY.html" ]; then
|
al@603
|
568 # cat << _EOT_
|
al@603
|
569 #<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE) : $SHORT_DESC
|
al@603
|
570 #_EOT_
|
al@603
|
571 # else
|
slaxemulator@336
|
572 PACKAGE_URL="$MIRROR_URL/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION$EXTRA_VERSION.tazpkg"
|
al@293
|
573 PACKAGE_HREF="<a href=\"$PACKAGE_URL\">$PACKAGE</a>"
|
pascal@456
|
574 case "$SLITAZ_VERSION" in
|
al@603
|
575 cooking)
|
al@603
|
576 COOKER="<a href=\"http://cook.slitaz.org/cooker.cgi?pkg=$PACKAGE\">$a_co</a>";;
|
al@603
|
577 stable|undigest|backports)
|
al@603
|
578 COOKER="<a href=\"http://cook.slitaz.org/$SLITAZ_VERSION/cooker.cgi?pkg=$PACKAGE\">$a_co</a>";;
|
al@603
|
579 *)
|
al@603
|
580 COOKER='';;
|
pascal@456
|
581 esac
|
al@603
|
582 cat <<EOT
|
pascal@456
|
583 $PACKAGE_HREF $(installed_size $PACKAGE) : $SHORT_DESC \
|
al@603
|
584 <a href="?receipt=$PACKAGE&version=$SLITAZ_VERSION">$a_rc</a> $COOKER
|
al@603
|
585 EOT
|
al@603
|
586 # fi
|
pankso@230
|
587 }
|
pankso@230
|
588
|
al@603
|
589
|
pankso@230
|
590 # Show loop in depends/build_depends chains
|
al@603
|
591
|
al@603
|
592 show_loops() {
|
pankso@230
|
593 awk '
|
pankso@230
|
594 function chkloop(pkg, i, n)
|
pankso@230
|
595 {
|
pankso@230
|
596 if (n < 8)
|
pankso@230
|
597 for (i = 1; i <= split(deps[pkg],curdep," "); i++) {
|
pankso@230
|
598 if (curdep[i] == base || chkloop(curdep[i], 0, n+1)) {
|
pankso@230
|
599 split(deps[pkg],curdep," ")
|
pankso@230
|
600 p = curdep[i] " " p
|
pankso@230
|
601 return 1
|
pankso@230
|
602 }
|
pankso@230
|
603 }
|
pankso@230
|
604 return 0
|
pankso@230
|
605 }
|
pankso@230
|
606 {
|
pankso@230
|
607 for (i = 2; i <= NF; i++)
|
pankso@230
|
608 deps[$1] = deps[$1] " " $i
|
pankso@230
|
609 }
|
pankso@230
|
610 END {
|
pankso@230
|
611 for (pkg in deps) {
|
pankso@230
|
612 base = pkg
|
pankso@230
|
613 p = ""
|
pankso@230
|
614 if (chkloop(pkg, 0, 0))
|
pankso@230
|
615 print pkg " " p
|
pankso@230
|
616 #print pkg " : " p "..."
|
pankso@230
|
617 }
|
pankso@230
|
618 }' | while read line; do
|
pankso@230
|
619 set -- $line
|
pankso@230
|
620 case " $last " in
|
pankso@230
|
621 *\ $1\ *) continue
|
pankso@230
|
622 esac
|
pankso@230
|
623 last="$line"
|
pankso@230
|
624 pkg=$1
|
pankso@230
|
625 shift
|
al@284
|
626 echo "<strong>$pkg </strong>: $@ ..."
|
pankso@230
|
627 done
|
pankso@230
|
628 }
|
pankso@230
|
629
|
al@603
|
630
|
pankso@230
|
631 # recursive dependencies scan
|
al@603
|
632
|
al@603
|
633 dep_scan() {
|
al@603
|
634 for i in $1; do
|
al@603
|
635 case " $ALL_DEPS " in
|
al@603
|
636 *\ $i\ *)
|
al@603
|
637 continue;;
|
al@603
|
638 esac
|
al@603
|
639 ALL_DEPS="$ALL_DEPS $i"
|
al@603
|
640 if [ -n "$2" ]; then
|
al@603
|
641 echo -n "$2"
|
al@603
|
642 (
|
al@603
|
643 . $WOK/$i/receipt
|
al@603
|
644 package_entry_inline
|
al@603
|
645 )
|
al@603
|
646 fi
|
al@603
|
647 [ -f $WOK/$i/receipt ] || continue
|
al@603
|
648 unset BUILD_DEPENDS DEPENDS WANTED
|
pankso@230
|
649 . $WOK/$i/receipt
|
al@603
|
650 if [ -n "$3" ]; then
|
al@603
|
651 [ -n "$BUILD_DEPENDS$WANTED" ] &&
|
al@603
|
652 dep_scan "$WANTED $BUILD_DEPENDS" "$2 " $3
|
al@603
|
653 else
|
al@603
|
654 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
|
al@603
|
655 fi
|
al@603
|
656 done
|
pankso@230
|
657 }
|
pankso@230
|
658
|
al@603
|
659
|
pankso@230
|
660 # recursive reverse dependencies scan
|
al@603
|
661
|
al@603
|
662 rdep_scan() {
|
pankso@230
|
663 SEARCH=$1
|
pankso@230
|
664 case "$SEARCH" in
|
al@261
|
665 glibc-base|gcc-lib-base)
|
al@603
|
666 _ '"glibc-base" and "gcc-lib-base" are implicit dependencies, <b>every</b> package is supposed to depend on them.'
|
pankso@230
|
667 return;;
|
pankso@230
|
668 esac
|
pankso@230
|
669 for i in $WOK/* ; do
|
slaxemulator@336
|
670 unset BUILD_DEPENDS DEPENDS WANTED
|
pankso@230
|
671 . $i/receipt
|
pankso@230
|
672 if [ -n "$2" ]; then
|
pankso@230
|
673 echo "$(basename $i) $(echo $WANTED $BUILD_DEPENDS)"
|
pankso@230
|
674 else
|
pankso@230
|
675 echo "$(basename $i) $(echo $DEPENDS)"
|
pankso@230
|
676 fi
|
pankso@230
|
677 done | awk -v search=$SEARCH '
|
pankso@230
|
678 function show_deps(deps, all_deps, pkg, space)
|
pankso@230
|
679 {
|
pankso@230
|
680 if (all_deps[pkg] == 1) return
|
pankso@230
|
681 all_deps[pkg] = 1
|
pankso@230
|
682 if (space != "") printf "%s%s\n",space,pkg
|
pankso@230
|
683 for (i = 1; i <= split(deps[pkg], mydeps, " "); i++) {
|
pankso@230
|
684 show_deps(deps, all_deps, mydeps[i],"////" space)
|
pankso@230
|
685 }
|
pankso@230
|
686 }
|
pankso@230
|
687
|
pankso@230
|
688 {
|
pankso@230
|
689 all_deps[$1] = 0
|
pankso@230
|
690 for (i = 2; i <= NF; i++)
|
pankso@230
|
691 deps[$i] = deps[$i] " " $1
|
pankso@230
|
692 }
|
pankso@230
|
693
|
pankso@230
|
694 END {
|
pankso@230
|
695 show_deps(deps, all_deps, search, "")
|
pankso@230
|
696 }
|
pankso@230
|
697 ' | while read pkg; do
|
pankso@230
|
698 . $WOK/${pkg##*/}/receipt
|
pankso@230
|
699 cat << _EOT_
|
al@293
|
700 $(echo ${pkg%/*} | sed 's|/| |g') $(package_entry_inline)
|
pankso@230
|
701 _EOT_
|
pankso@230
|
702 done
|
pankso@230
|
703 }
|
pankso@230
|
704
|
pankso@230
|
705
|
al@603
|
706
|
al@603
|
707
|
al@603
|
708 # Check non-empty argument
|
al@603
|
709
|
al@603
|
710 check_n() {
|
al@603
|
711 if [ -z "$1" ]; then
|
al@603
|
712 cat <<EOT
|
al@603
|
713 <div class="err">$(_ 'Please specify name of the package.')</div>
|
al@603
|
714 <p> <br/> </p>
|
al@603
|
715 EOT
|
al@603
|
716 return 1
|
al@603
|
717 fi
|
pankso@230
|
718 }
|
pankso@230
|
719
|
al@603
|
720
|
al@603
|
721 # Check package existence
|
al@603
|
722
|
al@603
|
723 package_exist() {
|
al@603
|
724 check_n "$1"
|
al@603
|
725
|
al@603
|
726 if [ ! -f "$WOK/$1/receipt" ]; then
|
al@603
|
727 cat <<EOT
|
al@605
|
728 <div class="err">$(_ 'Package "%s" was not found' "$1")</div>
|
al@603
|
729 <p> <br/> </p>
|
al@603
|
730 EOT
|
al@603
|
731 return 1
|
al@603
|
732 fi
|
al@603
|
733
|
al@603
|
734 return 0
|
pankso@230
|
735 }
|
pankso@230
|
736
|
al@603
|
737
|
al@603
|
738
|
al@603
|
739
|
al@603
|
740 # Display < > &
|
al@603
|
741
|
al@603
|
742 htmlize() {
|
al@603
|
743 sed -e 's|&|\&|g; s|<|\<|g; s|>|\>|g'
|
al@603
|
744 }
|
al@603
|
745
|
al@603
|
746
|
al@603
|
747
|
al@603
|
748
|
al@293
|
749 display_packages_and_files() {
|
al@603
|
750 unset last
|
al@603
|
751 while read pkg file; do
|
al@603
|
752 pkg=${pkg%:}
|
al@603
|
753 if [ "$pkg" != "$last" ]; then
|
al@603
|
754 . "$WOK/$pkg/receipt"
|
al@236
|
755
|
al@603
|
756 package_entry_inline
|
al@603
|
757 last="$pkg"
|
al@603
|
758 fi
|
al@603
|
759 echo " $file"
|
al@603
|
760 done
|
pankso@230
|
761 }
|
pankso@230
|
762
|
al@603
|
763
|
al@293
|
764 # Syntax highlighting for receipt file - stolen from tazpanel:
|
al@293
|
765 # '/var/www/tazpanel/lib/libtazpanel' and developed
|
al@603
|
766
|
al@293
|
767 syntax_highlighter() {
|
pascal@459
|
768 . $1
|
pascal@457
|
769 sed -e "s|\&|\&|g; s|<|\<|g; s|>|\>|g; s| | |g" \
|
al@293
|
770 -e "s|@|\@|g; s|~|\~|g" \
|
al@293
|
771 -e "#literals" \
|
al@293
|
772 -e "s|'\([^']*\)'|@l\0~|g" \
|
al@293
|
773 -e 's|"\([^"]*\)"|@l\0~|g' \
|
al@293
|
774 -e 's|"\([^"]*\)\\|@l\0~|g' \
|
al@293
|
775 -e 's|\([^"]*\)\"$|@l\0~|g' \
|
al@293
|
776 -e "#paths" \
|
al@293
|
777 -e 's|\([ =]\)\([a-zA-Z0-9/-]*/[\$a-zA-Z0-9/\.-]\+\)\([ )]\)|\1@p\2~\3|g' \
|
al@293
|
778 -e 's|\([ =]\)\([a-zA-Z0-9/-]*/[\$a-zA-Z0-9/\.-]\+$\)|\1@p\2~|g' \
|
al@293
|
779 -e 's|\(\$[a-zA-Z0-9_\.-]\+\)\(/[\$a-zA-Z0-9_/\.\*-]\+\)\([ )]*\)|@p\1\2~\3|g' \
|
al@293
|
780 -e "#functions" \
|
al@293
|
781 -e 's|^\([^()]*\)\(()\)|@f\0~|g' \
|
al@293
|
782 -e "#single line comments" \
|
al@293
|
783 -e 's|^\([ ]*\)#\([^#]*$\)|@c\0~|g' \
|
al@293
|
784 -e "#parameters" \
|
al@293
|
785 -e 's|\( \)\(-[a-z0-9]\+\)\( *\)|\1@r\2~\3|g' \
|
al@293
|
786 -e 's|\( \)\(--[a-z0-9\-]\+\)\([= ]\)|\1@r\2~\3|g' \
|
al@293
|
787 -e "#variables" \
|
al@293
|
788 -e "s|^\([^=@#' \-]*\)\(=\)|@v\1~\2|g" \
|
al@293
|
789 -e 's|\([ ^@-]*\)\([a-zA-Z0-9]\+\)\(=\)|\1@v\2~\3|g' \
|
al@293
|
790 -e "s#\(\$[a-zA-Z0-9_]\+\)#@v\0~#g" \
|
al@293
|
791 -e "#urls" \
|
al@293
|
792 -e s"#\"\(http:[^\"\$ ]*\)\"#\"<a @u href=\0>\1</a>\"#"g \
|
al@293
|
793 -e s"#\"\(ftp:[^\"\$ ]*\)\"#\"<a @u href=\0>\1</a>\"#"g \
|
al@293
|
794 -e "#commands" \
|
al@293
|
795 -e s"#^\( \+\)\([^'= @\-]\+\)#\1@m\2~#"g \
|
al@293
|
796 -e "#simple commands" \
|
al@293
|
797 -e s"#\([{}\]$\)#@s\0~#"g \
|
al@293
|
798 -e s"#\( \)\(\&\&\)\( *\)#\1@s\2~\3#"g \
|
al@293
|
799 -e s"#\(|\)#@s\0~#"g \
|
al@293
|
800 -e s"#\(\<\)#@s\0~#"g \
|
al@293
|
801 -e s"#\(\>\&\)#@s\0~#"g \
|
al@293
|
802 -e s"#\(\>\)#@s\0~#"g \
|
al@293
|
803 -e s"#\(\[\)#@s\0~#"g \
|
al@293
|
804 -e s"#\(\]\)#@s\0~#"g \
|
al@293
|
805 \
|
al@293
|
806 -e "s|´|'|g; s|›|</span>|g" \
|
al@293
|
807 -e "s|@c|<span class='r-comment'>|g" \
|
al@293
|
808 -e "s|@l|<span class='r-literal'>|g" \
|
al@293
|
809 -e "s|@v|<span class='r-var'>|g" \
|
al@293
|
810 -e "s|@f|<span class='r-func'>|g" \
|
al@293
|
811 -e "s|@u|class='r-url' target='_blank'|g" \
|
al@293
|
812 -e "s|@m|<span class='r-com'>|g" \
|
al@293
|
813 -e "s|@s|<span class='r-scom'>|g" \
|
al@293
|
814 -e "s|@p|<span class='r-path'>|g" \
|
al@293
|
815 -e "s|@r|<span class='r-param'>|g" \
|
pascal@459
|
816 -e "s|~|</span>|g" < "$1" | add_url_links
|
pascal@459
|
817 }
|
pascal@459
|
818
|
al@603
|
819
|
pascal@459
|
820 # Create some clickable links
|
al@603
|
821
|
pascal@459
|
822 add_url_links() {
|
pascal@459
|
823 local tarball_url
|
al@603
|
824 sedit=''
|
pascal@461
|
825 case "$SLITAZ_VERSION" in
|
al@603
|
826 cooking)
|
al@603
|
827 [ -n "$VERSION" ] &&
|
al@603
|
828 sedit="$sedit -e 's|\\(>VERSION<[^\"]*\"\\)\\([^\"]*\\)|\\1<a class='r-url' target='_blank' href=\"http://cook.slitaz.org/cooker.cgi?pkg=$PACKAGE\">\\2</a>|}'"
|
al@603
|
829 ;;
|
al@603
|
830 stable|undigest|backports)
|
al@603
|
831 [ -n "$VERSION" ] &&
|
al@603
|
832 sedit="$sedit -e 's|\\(>VERSION<[^\"]*\"\\)\\([^\"]*\\)|\\1<a class='r-url' target='_blank' href=\"http://cook.slitaz.org/$SLITAZ_VERSION/cooker.cgi?pkg=$PACKAGE\">\\2</a>|}'"
|
al@603
|
833 ;;
|
pascal@461
|
834 esac
|
pascal@460
|
835 #[ -n "$WEB_SITE" ] && sedit="$sedit -e '/WEB_SITE/{s|\\($WEB_SITE\\)|<a class='r-url' target='_blank' href=\"\\1\">\\1</a>|}'"
|
al@603
|
836
|
al@603
|
837 [ -n "$WGET_URL" ] &&
|
al@603
|
838 sedit="$sedit -e 's|\\(>WGET_URL<[^\"]*\"\\)\\([^\"]*\\)|\\1<a class='r-url' target='_blank' href=\"${WGET_URL//|/\\|}\">\\2</a>|}'"
|
al@603
|
839
|
al@603
|
840 [ -n "$MAINTAINER" ] &&
|
al@603
|
841 sedit="$sedit -e '/MAINTAINER/{s|\\(${MAINTAINER/@/@}\\)|<a class='r-url' target='_blank' href=\"?maintainer=\\1\\&version=$SLITAZ_VERSION\">\\1</a>|}'"
|
al@603
|
842
|
al@603
|
843 [ -n "$CATEGORY" ] &&
|
al@603
|
844 sedit="$sedit -e '/CATEGORY/{s|\\($CATEGORY\\)|<a class='r-url' target='_blank' href=\"?category=\\1\\&version=$SLITAZ_VERSION\">\\1</a>|}'"
|
al@603
|
845
|
al@603
|
846 [ -f "$WOK/$PACKAGE/description.txt" ] &&
|
al@603
|
847 sedit="$sedit -e '/SHORT_DESC/{s|\\($SHORT_DESC\\)|<a class='r-url' target='_blank' href=\"?desc=$PACKAGE\\&version=$SLITAZ_VERSION\">\\1</a>|}'"
|
al@603
|
848
|
pascal@459
|
849 tarball_url=sources/packages-$SLITAZ_VERSION/${TARBALL:0:1}/$TARBALL
|
pascal@459
|
850 [ -f /var/www/slitaz/mirror/$tarball_url ] || case "$tarball_url" in
|
pascal@459
|
851 *.gz) tarball_url=${tarball_url%gz}lzma ;;
|
pascal@459
|
852 *.tgz) tarball_url=${tarball_url%tgz}tar.lzma ;;
|
pascal@459
|
853 *.bz2) tarball_url=${tarball_url%bz2}lzma ;;
|
pascal@459
|
854 esac
|
pascal@459
|
855 [ -f /var/www/slitaz/mirror/$tarball_url ] && sedit="$sedit -e 's|\\(>TARBALL<[^\"]*\"\\)\\([^\"]*\\)|\\1<a class='r-url' target='_blank' href=\"http://mirror.slitaz.org/$tarball_url\">\\2</a>|'"
|
al@603
|
856
|
al@603
|
857 if [ -n "$EXTRA_SOURCE_FILES" ]; then
|
al@603
|
858 for i in $(echo $EXTRA_SOURCE_FILES) ; do
|
al@603
|
859 p="sources/packages-$SLITAZ_VERSION/${i:0:1}/$i"
|
al@603
|
860 [ -f "/var/www/slitaz/mirror/$p" ] || continue
|
al@603
|
861 #FIXME
|
al@603
|
862 sedit="$sedit -e 's|\\([\" >]\\)$i\\([\" <\\]\\)|\\1<a class='r-url' target='_blank' href=\"http://mirror.slitaz.org/$p\">$i</a>\\2|'"
|
al@603
|
863 sedit="$sedit -e 's|^$i\\([\" <\\]\\)|<a class='r-url' target='_blank' href=\"http://mirror.slitaz.org/$p\">$i</a>\\1|'"
|
al@603
|
864 done
|
al@603
|
865 fi
|
pascal@460
|
866 if [ -n "$DEPENDS$BUILD_DEPENDS$SUGGESTED$PROVIDE$WANTED" ]; then
|
pascal@460
|
867 for i in $(echo $DEPENDS $BUILD_DEPENDS $SUGGESTED $PROVIDE $WANTED) ; do
|
pascal@460
|
868 sedit="$sedit -e 's|\\([\" >]\\)$i\\([\" <\\]\\)|\\1<a class='r-url' target='_blank' href=\\\"?receipt=$i\\&version=$SLITAZ_VERSION\\\">$i</a>\\2|'"
|
pascal@463
|
869 sedit="$sedit -e 's|^$i\\([\" <\\]\\)|<a class='r-url' target='_blank' href=\\\"?receipt=$i\\&version=$SLITAZ_VERSION\\\">$i</a>\\1|'"
|
pascal@459
|
870 done
|
pascal@459
|
871 fi
|
pascal@466
|
872 if [ -n "$LICENSE" ]; then
|
pascal@466
|
873 for i in $LICENSE ; do
|
pascal@466
|
874 sedit="$sedit -e '/LICENSE/{s|\\($i\\)|<a class='r-url' target='_blank' href=\"?license=\\1\\&version=$SLITAZ_VERSION\">\\1</a>|}'"
|
pascal@466
|
875 done
|
pascal@466
|
876 fi
|
pascal@459
|
877 if [ -n "$HOST_ARCH" ]; then
|
pascal@459
|
878 for i in $HOST_ARCH ; do
|
pascal@459
|
879 sedit="$sedit -e '/HOST_ARCH/{s|\\([\" ]\\)$i\\([\" ]\\)|\\1<a class='r-url' target='_blank' href=\\\"?arch=$i\\&version=$SLITAZ_VERSION\\\">$i</a>\\2|}'"
|
pascal@459
|
880 done
|
pascal@459
|
881 fi
|
pascal@459
|
882 if [ -n "$TAGS" ]; then
|
pascal@459
|
883 for i in $TAGS ; do
|
pascal@459
|
884 sedit="$sedit -e '/TAGS/{s|\\([\" ]\\)$i\\([\" ]\\)|\\1<a class='r-url' target='_blank' href=\\\"?tags=$i\\&version=$SLITAZ_VERSION\\\">$i</a>\\2|}'"
|
pascal@459
|
885 done
|
pascal@459
|
886 fi
|
pascal@459
|
887 eval sed $sedit \
|
pascal@459
|
888 -e "'s|genpkg_rules|<a class='r-url' target='_blank' href=\"?filelist=$PACKAGE\\&version=$SLITAZ_VERSION\">&</a>|'"
|
al@293
|
889 }
|
al@293
|
890
|
al@603
|
891
|
pascal@458
|
892 display_cloud() {
|
pascal@458
|
893 arg=$1
|
pascal@458
|
894 awk '
|
pascal@458
|
895 {
|
pascal@458
|
896 for (i = 1; $i != ""; i++)
|
pascal@458
|
897 count[$i]++
|
pascal@458
|
898 }
|
pascal@458
|
899 END {
|
pascal@458
|
900 min=10000
|
pascal@458
|
901 max=0
|
pascal@459
|
902 cnt=0
|
pascal@458
|
903 for (i in count) {
|
pascal@458
|
904 if (count[i] < min) min = count[i]
|
pascal@458
|
905 if (count[i] > max) max = count[i]
|
pascal@459
|
906 cnt++
|
pascal@458
|
907 }
|
pascal@458
|
908 for (i in count)
|
pascal@458
|
909 print count[i] " " min " " max " " i
|
pascal@459
|
910 print cnt
|
pascal@463
|
911 }' | sed 's/[<>]//g' | sort -k 4 | {
|
pascal@461
|
912 while read cnt min max tag ; do
|
pascal@459
|
913 if [ -z "$min" ]; then
|
al@603
|
914 count="$cnt"
|
pascal@459
|
915 continue
|
pascal@459
|
916 fi
|
pascal@458
|
917 pct=$(((($cnt-$min)*100)/($max-$min)))
|
pascal@458
|
918 pct=$(((10000 - ((100 - $pct)**2))/100))
|
pascal@458
|
919 pct=$(((10000 - ((100 - $pct)**2))/100))
|
pascal@458
|
920 cat <<EOT
|
al@605
|
921 <span class="tagn">$cnt</span><a href="?$arg=$tag$addver" class="tag$(($pct/10))">$tag</a>
|
pascal@458
|
922 EOT
|
pascal@458
|
923 done
|
al@603
|
924 echo -n '<hr/><p class="lang">'
|
al@603
|
925 case $arg in
|
al@603
|
926 arch) _p '%s architecture' '%s architectures' "$count" "$count";;
|
al@603
|
927 maintainer) _p '%s maintainer' '%s maintainers' "$count" "$count";;
|
al@603
|
928 license) _p '%s license' '%s licenses' "$count" "$count";;
|
al@603
|
929 category) _p '%s category' '%s categories' "$count" "$count";;
|
al@603
|
930 tags) _p '%s tag' '%s tags' "$count" "$count";;
|
al@603
|
931 esac
|
al@603
|
932 echo '</p>'
|
pascal@461
|
933 }
|
pascal@458
|
934 }
|
al@293
|
935
|
al@603
|
936
|
al@293
|
937 #
|
al@293
|
938 # page begins
|
al@293
|
939 #
|
al@603
|
940
|
al@605
|
941 if [ -n "$HTTP_IF_MODIFIED_SINCE" -a "$HTTP_IF_MODIFIED_SINCE" == "$lastmod" ]; then
|
al@605
|
942 # When user agent asks if content modified since last seen and it is not modified
|
al@605
|
943 header "HTTP/1.1 304 Not Modified"
|
al@605
|
944 exit 0
|
al@605
|
945 fi
|
al@605
|
946 if [ -z "$lastmod" ]; then
|
al@605
|
947 # We don't know last modification date
|
al@605
|
948 header "HTTP/1.1 200 OK" "Content-type: text/html; charset=UTF-8"
|
al@605
|
949 else
|
al@605
|
950 header "HTTP/1.1 200 OK" "Content-type: text/html; charset=UTF-8" "Last-Modified: $lastmod"
|
al@605
|
951 fi
|
al@284
|
952 xhtml_header
|
al@284
|
953
|
al@603
|
954
|
pankso@266
|
955 #
|
al@605
|
956 # Language selector
|
al@293
|
957 #
|
al@603
|
958
|
al@603
|
959 cat <<EOT
|
al@293
|
960 <!-- Languages -->
|
al@603
|
961 <div class="lang"><a class="locale2" href="http://www.slitaz.org/i18n.php"
|
al@603
|
962 target="_blank"></a><select form="s_form" name="lang" onchange="this.form.submit();">
|
al@293
|
963 EOT
|
al@603
|
964
|
al@605
|
965 for i in en de es fa fr pl pt ru sv uk zh; do
|
al@603
|
966 case $i in
|
al@603
|
967 en) c='us'; l='English';;
|
al@603
|
968 de) c='de'; l='Deutsch';;
|
al@603
|
969 es) c='es'; l='Español';;
|
al@605
|
970 fa) c='ir'; l='فارسی';;
|
al@603
|
971 fr) c='fr'; l='Français';;
|
al@603
|
972 it) c='it'; l='Italiano';;
|
al@603
|
973 pl) c='pl'; l='Polski';;
|
al@603
|
974 pt) c='br'; l='Português';;
|
al@603
|
975 ru) c='ru'; l='Русский';;
|
al@603
|
976 sv) c='se'; l='Svenska';;
|
al@603
|
977 uk) c='ua'; l='Українська';;
|
al@603
|
978 zh) c='tw'; l='中文';;
|
al@603
|
979 esac
|
al@603
|
980
|
al@603
|
981 echo -n "<option class=\"$c\" value=\"$i\""
|
al@603
|
982 [ "$i" == "${LANG%_*}" ] && echo -n " selected"
|
al@603
|
983 echo ">$l</option>"
|
al@603
|
984 done
|
al@603
|
985 echo '</select></div>'
|
al@603
|
986
|
al@603
|
987 cat <<EOT
|
al@603
|
988 <!-- Content -->
|
al@603
|
989 <main>
|
al@293
|
990 EOT
|
al@293
|
991
|
al@293
|
992
|
al@293
|
993 #
|
pankso@266
|
994 # Handle GET requests
|
pankso@266
|
995 #
|
al@603
|
996
|
pankso@266
|
997 case " $(GET) " in
|
al@284
|
998 *\ debug\ *|*\ debug*)
|
al@603
|
999 cat <<EOT
|
al@284
|
1000 <h2>Debug info</h2>
|
al@603
|
1001
|
al@284
|
1002 <pre>$(httpinfo)</pre>
|
al@603
|
1003
|
al@605
|
1004 <pre>$(env)</pre>
|
al@605
|
1005
|
al@605
|
1006 <pre>LANG="$LANG"
|
al@605
|
1007 OBJECT="$OBJECT"
|
al@605
|
1008 SEARCH="$SEARCH"
|
al@605
|
1009 SLITAZ_VERSION="$SLITAZ_VERSION"
|
al@605
|
1010 WOK="$WOK"
|
al@605
|
1011 GET="$(GET)"
|
al@605
|
1012
|
al@605
|
1013 HTTP_IF_MODIFIED_SINCE="$HTTP_IF_MODIFIED_SINCE"
|
al@605
|
1014 lastmod ="$lastmod"
|
al@284
|
1015 </pre>
|
al@284
|
1016 EOT
|
al@284
|
1017 ;;
|
pankso@266
|
1018 esac
|
pankso@266
|
1019
|
al@603
|
1020
|
al@603
|
1021
|
al@603
|
1022
|
pankso@230
|
1023 # Display search form and result if requested.
|
al@603
|
1024
|
al@603
|
1025 cat <<EOT
|
al@605
|
1026 <div id="ticker"><img src="loader.gif" alt="."/></div>
|
al@293
|
1027 EOT
|
al@284
|
1028 search_form
|
al@284
|
1029
|
al@293
|
1030
|
al@603
|
1031
|
al@603
|
1032
|
al@603
|
1033 # Show links for "info" page
|
al@603
|
1034
|
al@603
|
1035 show_info_links() {
|
al@603
|
1036 if [ -n "$1" ]; then
|
al@605
|
1037 echo -n "<tr><td class=\"first\"><b>$2</b></td><td class=\"spkg\">"
|
al@603
|
1038
|
al@605
|
1039 echo $1 | tr ' ' $'\n' | awk -vt="$3" -vv="$addver" -viconslast="$iconslast" '
|
al@605
|
1040 function icon(pkg) {
|
al@605
|
1041 i="";
|
al@605
|
1042 if (pkg ~ /-dev$/) { return "dev"; }
|
al@605
|
1043 if (pkg ~ /^linux(64)?-/) { return "linux"; }
|
al@605
|
1044 if (pkg ~ /^xorg-/) { return "xorg"; }
|
al@605
|
1045 "awk -vp=\"" pkg "\" \"BEGIN{FS=\\\"\t\\\"}\\\$1==p{print \\\$2;exit}\" " iconslast | getline i;
|
al@605
|
1046 if (i) { return i; }
|
al@605
|
1047 return "pkg";
|
al@605
|
1048 }
|
al@605
|
1049 function link(pkg) {
|
al@605
|
1050 printf "<a href=\"?%s=%s%s\">", t, gensub(/\+/, "%2B", "g", pkg), v;
|
al@605
|
1051 if (t!="tags") printf "<img src=\"icons-s/%s.png\" alt=\"%s icon\"/>", icon(pkg), pkg;
|
al@605
|
1052 printf "%s</a>", pkg;
|
al@605
|
1053 }
|
al@605
|
1054 {
|
al@605
|
1055 split($1, line, ":");
|
al@605
|
1056 link(line[1]);
|
al@605
|
1057 if (line[2]) { printf ":"; link(line[2]); }
|
al@605
|
1058 printf " ";
|
al@605
|
1059 }'
|
al@603
|
1060 echo "</td></tr>"
|
al@603
|
1061 fi
|
al@603
|
1062 }
|
al@603
|
1063
|
al@603
|
1064 # Source for categories names to translate
|
al@603
|
1065
|
al@603
|
1066 noop() {
|
al@603
|
1067 _ 'base-system'; _ 'x-window'; _ 'utilities'; _ 'network'; _ 'graphics';
|
al@603
|
1068 _ 'multimedia'; _ 'office'; _ 'development'; _ 'system-tools'; _ 'security';
|
al@603
|
1069 _ 'games'; _ 'misc'; _ 'meta'; _ 'non-free'
|
al@603
|
1070 }
|
al@603
|
1071
|
al@603
|
1072 case " $(GET) " in
|
al@603
|
1073 *\ info\ *)
|
al@605
|
1074 package_exist $(GET info) || xhtml_footer
|
al@603
|
1075 . "$WOK/$(GET info)/receipt"
|
al@603
|
1076
|
al@603
|
1077 cat <<EOT
|
al@603
|
1078 <table class="info">
|
al@603
|
1079 <tr>
|
al@605
|
1080 <td class="first"><b>$(gettext 'Name')</b></td>
|
al@603
|
1081 <td>$PACKAGE
|
al@603
|
1082 <div class="appImg" style="background: url($(package_icon $PACKAGE 2))"></div>
|
al@603
|
1083 </td>
|
al@603
|
1084 </tr>
|
al@603
|
1085 EOT
|
al@603
|
1086 [ -n "$VERSION" ] && cat <<EOT
|
al@603
|
1087 <tr>
|
al@605
|
1088 <td class="first"><b>$(gettext 'Version')</b></td>
|
al@603
|
1089 <td>$VERSION</td>
|
al@603
|
1090 </tr>
|
al@603
|
1091 EOT
|
al@603
|
1092 cat <<EOT
|
al@603
|
1093 <tr>
|
al@605
|
1094 <td class="first"><b>$(gettext 'Category')</b></td>
|
al@605
|
1095 <td><a href="?category=$CATEGORY$addver">$(gettext "$CATEGORY")</a></td>
|
al@603
|
1096 </tr>
|
al@603
|
1097
|
al@603
|
1098 <tr>
|
al@605
|
1099 <td class="first"><b>$(gettext 'Description')</b></td>
|
al@603
|
1100 <td>$(echo "$SHORT_DESC" | htmlize)</td>
|
al@603
|
1101 </tr>
|
al@603
|
1102 EOT
|
al@621
|
1103 if [ -n "$MAINTAINER" ]; then
|
al@621
|
1104 # For form "John Doe <jdoe@example.org>"
|
al@621
|
1105 M="${MAINTAINER#*<}"; M="${M%>}" # extract address "jdoe@example.org"
|
al@621
|
1106 MAINTAINER=$(echo $MAINTAINER | htmlize) # escape "<" and ">" for use in HTML
|
al@621
|
1107 cat <<EOT
|
al@603
|
1108 <tr>
|
al@605
|
1109 <td class="first"><b>$(gettext 'Maintainer')</b></td>
|
al@621
|
1110 <td><a href="?maintainer=$M$addver">${MAINTAINER/@/​@​}</a></td>
|
al@603
|
1111 </tr>
|
al@603
|
1112 EOT
|
al@621
|
1113 fi
|
al@603
|
1114 [ -n "$LICENSE" ] && cat <<EOT
|
al@603
|
1115 <tr>
|
al@605
|
1116 <td class="first"><b>$(gettext 'License')</b></td>
|
al@603
|
1117 <td>$(for license in $LICENSE; do
|
al@605
|
1118 echo "<a href=\"?license=$license$addver\">$license</a> "
|
al@603
|
1119 done)</td>
|
al@603
|
1120 </tr>
|
al@603
|
1121 EOT
|
al@605
|
1122 web_site="${WEB_SITE#http://}"
|
al@603
|
1123 cat <<EOT
|
al@603
|
1124 <tr>
|
al@605
|
1125 <td class="first"><b>$(gettext 'Website')</b></td>
|
al@605
|
1126 <td><a href="$WEB_SITE" target="_blank">${web_site%/}</a></td>
|
al@603
|
1127 </tr>
|
al@603
|
1128 EOT
|
al@603
|
1129 show_info_links "$TAGS" "$(_ 'Tags')" 'tags'
|
al@603
|
1130
|
al@603
|
1131 if [ -n "$PACKED_SIZE" ]; then
|
al@603
|
1132 cat <<EOT
|
al@603
|
1133 <tr>
|
al@605
|
1134 <td class="first"><b>$(gettext 'Sizes')</b></td>
|
al@605
|
1135 <td>${PACKED_SIZE/.0/} / ${UNPACKED_SIZE/.0/}</td>
|
al@603
|
1136 </tr>
|
al@603
|
1137 EOT
|
al@603
|
1138 elif [ -f "$pinfo" ]; then
|
al@603
|
1139 cat <<EOT
|
al@603
|
1140 <tr>
|
al@605
|
1141 <td class="first"><b>$(gettext 'Sizes')</b></td>
|
al@605
|
1142 <td>$(awk -F$'\t' -vp=$PACKAGE '$1==p{print $7}' "$pinfo" | sed 's| | / |')</td>
|
al@603
|
1143 </tr>
|
al@603
|
1144 EOT
|
al@603
|
1145 fi
|
al@603
|
1146
|
al@605
|
1147 show_info_links "$DEPENDS" "$(gettext 'Depends on')" 'info'
|
al@603
|
1148
|
al@605
|
1149 show_info_links "$PROVIDE" "$(gettext 'Provides')" 'info'
|
al@603
|
1150
|
al@605
|
1151 show_info_links "$SUGGESTED" "$(gettext 'Suggested')" 'info'
|
al@603
|
1152 cat <<EOT
|
al@603
|
1153 </table>
|
al@603
|
1154
|
al@603
|
1155 EOT
|
al@603
|
1156
|
al@603
|
1157 # Actions / screenshot
|
al@603
|
1158 pkg=${PACKAGE//+/%2B}
|
al@603
|
1159 pkg_url="$MIRROR_URL/packages/$SLITAZ_VERSION/$pkg-$VERSION$EXTRA_VERSION.tazpkg"
|
al@603
|
1160 case "$SLITAZ_VERSION" in
|
al@603
|
1161 cooking)
|
al@605
|
1162 COOKER="<a class=\"cooker\" href=\"http://cook.slitaz.org/cooker.cgi?pkg=$PACKAGE\">$(gettext 'Show cooking log')</a>";;
|
al@603
|
1163 stable|undigest|backports)
|
al@605
|
1164 COOKER="<a class=\"cooker\" href=\"http://cook.slitaz.org/$SLITAZ_VERSION/cooker.cgi?pkg=$PACKAGE\">$(gettext 'Show cooking log')</a>";;
|
al@603
|
1165 *)
|
al@605
|
1166 COOKER="<span class=\"cooker\">$(gettext 'N/A')</span>";;
|
al@603
|
1167 esac
|
al@603
|
1168 cat <<EOT
|
al@605
|
1169 <div class="sssb desc center">
|
al@605
|
1170 <a href="http://screenshots.debian.net/package/$pkg" target="_blank"><img
|
al@605
|
1171 src="http://screenshots.debian.net/thumbnail/$pkg" alt="$PACKAGE screenshot"/></a>
|
al@605
|
1172 </div>
|
al@605
|
1173
|
al@603
|
1174 <table class="info">
|
al@605
|
1175 <tr><td><span class="download"></span>
|
al@605
|
1176 <a href="$pkg_url">$(gettext 'Download package')</a>
|
al@603
|
1177 </td>
|
al@619
|
1178 <td rowspan="5" class="last hssc">
|
al@603
|
1179 <a href="http://screenshots.debian.net/package/$pkg" target="_blank"><img
|
al@605
|
1180 src="http://screenshots.debian.net/thumbnail/$pkg" alt="$PACKAGE screenshot"/></a>
|
al@603
|
1181 </td>
|
al@603
|
1182 </tr>
|
al@605
|
1183 <tr><td><a class="receipt" href="?receipt=$pkg$addver">$(gettext 'Show receipt')</a></td></tr>
|
al@605
|
1184 <tr><td><a class="files-list" href="?filelist=$pkg$addver">$(gettext 'Show files list')</a></td></tr>
|
al@605
|
1185 <tr><td>$COOKER</td></tr>
|
al@605
|
1186 <tr id="tazpanelButtons" class="hidden">
|
al@603
|
1187 <td>
|
al@605
|
1188 <span id="tazpaneli" class="hidden">
|
al@605
|
1189 <a class="pkgi" href="http://127.0.0.1:82/user/pkgs.cgi?do=Install&pkg=$pkg" target="_blank">$(gettext 'Install package')</a>
|
al@605
|
1190 </span>
|
al@605
|
1191 <span id="tazpanelr" class="hidden">
|
al@605
|
1192 <a class="pkgr" href="http://127.0.0.1:82/user/pkgs.cgi?do=Remove&pkg=$pkg" target="_blank">$(gettext 'Remove package')</a>
|
al@605
|
1193 </span>
|
al@603
|
1194 </td>
|
al@603
|
1195 </tr>
|
al@603
|
1196 </table>
|
al@605
|
1197
|
al@605
|
1198 <script>
|
al@605
|
1199 function ajaxTazPanel(pkg) {
|
al@605
|
1200 var req = new XMLHttpRequest();
|
al@605
|
1201 req.onreadystatechange = function() {
|
al@605
|
1202 if (req.readyState == XMLHttpRequest.DONE) {
|
al@605
|
1203 if (req.status == 200) {
|
al@605
|
1204 if (req.responseText == 'i') {
|
al@605
|
1205 // Package installed, allow to remove
|
al@605
|
1206 document.getElementById('tazpanelr').className='';
|
al@605
|
1207 } else {
|
al@605
|
1208 // Package not installed, allow to install
|
al@605
|
1209 document.getElementById('tazpaneli').className='';
|
al@605
|
1210 }
|
al@605
|
1211 document.getElementById('tazpanelButtons').className='';
|
al@605
|
1212 }
|
al@605
|
1213 }
|
al@605
|
1214 }
|
al@605
|
1215 req.open('GET', 'http://tazpanel:82/pkgs.cgi?status&web=y&pkg=' + pkg, true);
|
al@605
|
1216 req.send();
|
al@605
|
1217 }
|
al@605
|
1218 ajaxTazPanel('$pkg');
|
al@605
|
1219 </script>
|
al@603
|
1220 EOT
|
al@603
|
1221
|
al@603
|
1222 # Description
|
al@603
|
1223 if [ -f "$WOK/$PACKAGE/description.txt" ]; then
|
al@603
|
1224 cat <<EOT
|
al@605
|
1225 <h3>$(gettext 'Description')</h3>
|
al@603
|
1226 <table><tr><td>$(./sundown < "$WOK/$PACKAGE/description.txt")</td></tr></table>
|
al@603
|
1227 EOT
|
al@603
|
1228 fi
|
al@603
|
1229
|
al@603
|
1230 # Config files
|
al@603
|
1231 if [ -n "$CONFIG_FILES" ]; then
|
al@603
|
1232 cat <<EOT
|
al@603
|
1233 <div class="conf">
|
al@605
|
1234 <h3>$(gettext 'Configuration files')</h3>
|
al@605
|
1235 <table><tr><td><ul>
|
al@603
|
1236 EOT
|
al@603
|
1237 for file in $CONFIG_FILES; do
|
al@603
|
1238 cat <<EOT
|
al@603
|
1239 <li><a href="ftp://cook.slitaz.org/$PACKAGE/taz/$PACKAGE-$VERSION$EXTRAVERSION/fs$file" target="_blank">$file</a></li>
|
al@603
|
1240 EOT
|
al@603
|
1241 done
|
al@603
|
1242 cat <<EOT
|
al@605
|
1243 </ul></td></tr></table>
|
al@603
|
1244 </div>
|
al@603
|
1245 EOT
|
al@603
|
1246 fi
|
al@603
|
1247
|
al@603
|
1248 ;;
|
al@603
|
1249 esac
|
al@603
|
1250
|
al@603
|
1251
|
al@603
|
1252
|
al@603
|
1253
|
al@284
|
1254 case "$OBJECT" in
|
al@284
|
1255
|
al@284
|
1256
|
al@284
|
1257 ### Depends loops; [Reverse] Dependency tree [(SUGGESTED)]
|
al@284
|
1258 Depends)
|
al@284
|
1259 if [ -z "$SEARCH" ]; then
|
al@603
|
1260 cat <<EOT
|
al@605
|
1261 <h3>$(_ 'Loop dependency')</h3>
|
al@603
|
1262 <pre class="hard">
|
al@603
|
1263 EOT
|
al@284
|
1264 for i in $WOK/*/receipt; do
|
al@284
|
1265 PACKAGE=
|
al@284
|
1266 DEPENDS=
|
al@284
|
1267 . $i
|
al@284
|
1268 echo "$PACKAGE $(echo $DEPENDS)"
|
al@284
|
1269 done | show_loops
|
al@603
|
1270 echo '</pre>'
|
al@603
|
1271
|
al@284
|
1272 elif package_exist $SEARCH ; then
|
al@603
|
1273 cat <<EOT
|
al@603
|
1274 <h3>$(_ 'Dependency tree for package "%s"' "$SEARCH")</h3>
|
al@603
|
1275 <pre class="hard">
|
al@603
|
1276 EOT
|
slaxemulator@336
|
1277 unset ALL_DEPS
|
al@603
|
1278 dep_scan $SEARCH ''
|
slaxemulator@336
|
1279 unset SUGGESTED
|
al@284
|
1280 . $WOK/$SEARCH/receipt
|
al@603
|
1281 echo '</pre>'
|
al@603
|
1282
|
al@284
|
1283 if [ -n "$SUGGESTED" ]; then
|
al@603
|
1284 cat <<EOT
|
al@605
|
1285 <h3>$(_ 'Dependency tree for packages suggested by package "%s"' "$SEARCH")</h3>
|
al@603
|
1286 <pre class="hard">
|
al@603
|
1287 EOT
|
al@603
|
1288 unset ALL_DEPS
|
al@603
|
1289 dep_scan "$SUGGESTED" ' '
|
al@603
|
1290 echo '</pre>'
|
al@603
|
1291 fi
|
pankso@230
|
1292
|
al@603
|
1293 cat <<EOT
|
al@603
|
1294 <h3>$(_ 'Reverse dependency tree for package "%s"' "$SEARCH")</h3>
|
al@603
|
1295 <pre class="hard">
|
al@603
|
1296 EOT
|
slaxemulator@336
|
1297 unset ALL_DEPS
|
al@284
|
1298 rdep_scan $SEARCH
|
al@603
|
1299 echo '</pre>'
|
al@284
|
1300 fi
|
al@284
|
1301 ;;
|
al@284
|
1302
|
al@284
|
1303
|
al@603
|
1304
|
al@603
|
1305
|
al@284
|
1306 ### Build depends loops; [Reverse] Build dependency tree
|
al@603
|
1307
|
al@284
|
1308 BuildDepends)
|
al@284
|
1309 if [ -z "$SEARCH" ]; then
|
al@603
|
1310 cat <<EOT
|
al@605
|
1311 <h3>$(_ 'Loop dependency of build')</h3>
|
al@603
|
1312 <pre class="hard">
|
al@603
|
1313 EOT
|
al@284
|
1314 for i in $WOK/*/receipt; do
|
al@284
|
1315 PACKAGE=
|
al@284
|
1316 WANTED=
|
al@284
|
1317 BUILD_DEPENDS=
|
al@284
|
1318 . $i
|
al@284
|
1319 echo "$PACKAGE $WANTED $(echo $BUILD_DEPENDS)"
|
al@284
|
1320 done | show_loops
|
al@603
|
1321 echo '</pre>'
|
al@603
|
1322
|
al@284
|
1323 elif package_exist $SEARCH ; then
|
al@603
|
1324 cat <<EOT
|
al@603
|
1325 <h3>$(_ 'Package "%s" requires next packages to be built' "$SEARCH")</h3>
|
al@603
|
1326 <pre class="hard">
|
al@603
|
1327 EOT
|
al@603
|
1328 unset ALL_DEPS
|
al@603
|
1329 dep_scan $SEARCH '' build
|
al@603
|
1330 echo '</pre>'
|
pankso@230
|
1331
|
al@603
|
1332 cat <<EOT
|
al@605
|
1333 <h3>$(_ 'Next packages require package "%s" to be built' "$SEARCH")</h3>
|
al@603
|
1334 <pre class="hard">
|
al@603
|
1335 EOT
|
slaxemulator@336
|
1336 unset ALL_DEPS
|
al@284
|
1337 rdep_scan $SEARCH build
|
al@603
|
1338 echo '</pre>'
|
al@284
|
1339 fi
|
al@284
|
1340 ;;
|
al@284
|
1341
|
al@284
|
1342
|
al@603
|
1343
|
al@603
|
1344
|
al@284
|
1345 ### Common files
|
al@603
|
1346
|
al@284
|
1347 FileOverlap)
|
pascal@318
|
1348 if package_exist $SEARCH; then
|
al@603
|
1349 cat <<EOT
|
pankso@230
|
1350
|
al@603
|
1351 <h3>$(_ 'Next packages may overwrite files of package "%s"' "$SEARCH")</h3>
|
al@603
|
1352 <pre class="hard">
|
al@603
|
1353 EOT
|
pascal@457
|
1354 ( unlzma < $filelist | grep ^$SEARCH: ;
|
pascal@457
|
1355 unlzma < $filelist | grep -v ^$SEARCH: ) | awk '
|
pankso@230
|
1356 BEGIN { pkg=""; last="x" }
|
pankso@230
|
1357 {
|
pankso@230
|
1358 if ($2 == "") next
|
al@603
|
1359 if (index($2, last) == 1 && substr($2, 1+length(last), 1) == "/")
|
pankso@230
|
1360 delete file[last]
|
pankso@230
|
1361 last=$2
|
pankso@230
|
1362 if (pkg == "") pkg=$1
|
pankso@230
|
1363 if ($1 == pkg) file[$2]=$1
|
pankso@230
|
1364 else if (file[$2] == pkg) print
|
pankso@230
|
1365 }
|
pankso@230
|
1366 ' | display_packages_and_files
|
al@603
|
1367 echo '</pre>'
|
al@284
|
1368 fi
|
al@284
|
1369 ;;
|
al@284
|
1370
|
al@284
|
1371
|
al@603
|
1372
|
al@603
|
1373
|
al@284
|
1374 ### File search
|
al@603
|
1375
|
al@284
|
1376 File)
|
al@284
|
1377 if [ -n "$SEARCH" ]; then
|
al@603
|
1378 cat <<EOT
|
pankso@230
|
1379
|
al@605
|
1380 <h3>$(_ 'File names matching "%s"' "$SEARCH")</h3>
|
al@603
|
1381 <table class="list">
|
al@603
|
1382 EOT
|
slaxemulator@336
|
1383 unset last
|
al@603
|
1384 unlzma < $filelist | grep -i "$SEARCH" | \
|
al@603
|
1385 while read pkg file; do
|
al@603
|
1386 echo "$file" | grep -qi "$SEARCH" || continue
|
pankso@230
|
1387 if [ "$last" != "${pkg%:}" ]; then
|
al@603
|
1388 [ -n "$last" ] && cat <<EOT
|
al@603
|
1389 </td></tr>
|
al@603
|
1390 EOT
|
pankso@230
|
1391 last=${pkg%:}
|
pankso@230
|
1392 (
|
pankso@230
|
1393 . $WOK/$last/receipt
|
al@603
|
1394 package_entry
|
al@603
|
1395 cat <<EOT
|
al@603
|
1396 <tr><td colspan="3" class="pre">
|
al@293
|
1397 EOT
|
pankso@230
|
1398 )
|
pankso@230
|
1399 fi
|
al@603
|
1400 echo -n "$file" | awk -vquery="$SEARCH" 'BEGIN{IGNORECASE=1}gsub(query, "<mark>&</mark>")'
|
al@603
|
1401 echo "<br/>"
|
pankso@230
|
1402 done
|
al@603
|
1403 cat <<EOT
|
al@293
|
1404 </td></tr>
|
al@293
|
1405 </table>
|
al@603
|
1406 EOT
|
al@284
|
1407 fi
|
al@284
|
1408 ;;
|
al@284
|
1409
|
al@284
|
1410
|
al@603
|
1411
|
al@603
|
1412
|
al@284
|
1413 ### List of files
|
al@603
|
1414
|
al@284
|
1415 File_list)
|
al@284
|
1416 if package_exist $SEARCH; then
|
al@603
|
1417 cat <<EOT
|
pankso@230
|
1418
|
al@603
|
1419 <h3>$(_ 'List of files in the package "%s"' "$SEARCH")</h3>
|
al@603
|
1420 <pre class="hard">
|
al@603
|
1421 EOT
|
slaxemulator@336
|
1422 unset last
|
pascal@457
|
1423 unlzma < $filelist \
|
al@603
|
1424 | grep ^$SEARCH: | sed 's|.*: | |' | sort
|
al@603
|
1425 cat <<EOT
|
pankso@230
|
1426 </pre>
|
al@603
|
1427 <pre class="hard">
|
al@603
|
1428 EOT
|
pascal@457
|
1429 filenb=$(unlzma < $filelist | grep ^$SEARCH: | wc -l)
|
al@603
|
1430 _p '%s file' '%s files' "$filenb" "$filenb"
|
al@603
|
1431 cat <<EOT
|
al@284
|
1432 \
|
slaxemulator@320
|
1433 $(busybox sed -n "/^$SEARCH$/{nnnpq}" $pkglist)
|
al@284
|
1434 </pre>
|
al@603
|
1435 EOT
|
al@284
|
1436 fi
|
al@284
|
1437 ;;
|
al@284
|
1438
|
al@284
|
1439
|
al@603
|
1440
|
al@603
|
1441
|
al@284
|
1442 ### Package description
|
al@603
|
1443
|
al@284
|
1444 Desc)
|
al@603
|
1445 if [ -z "$SEARCH" ]; then
|
al@603
|
1446 cat <<EOT
|
al@603
|
1447 <div class="err">$(_ 'Please specify name of the package.')</div>
|
al@603
|
1448 <p> <br/> </p>
|
al@603
|
1449 EOT
|
al@603
|
1450 xhtml_footer
|
al@603
|
1451 exit 0
|
al@603
|
1452 fi
|
pankso@230
|
1453
|
al@603
|
1454 cat <<EOT
|
al@605
|
1455 <h3>$(_ 'Descriptions matching "%s"' "$SEARCH")</h3>
|
al@603
|
1456 EOT
|
al@603
|
1457 if [ -f "$pinfo" ]; then
|
al@603
|
1458 package_entries desc "$SEARCH"
|
al@284
|
1459 else
|
al@603
|
1460 echo '<table class="list">'
|
slaxemulator@336
|
1461 unset last
|
al@603
|
1462 # FIXME packages.desc should not be used (at least this way)
|
al@603
|
1463 grep -i "$SEARCH" "$pkgsrepo/packages.desc" | \
|
al@284
|
1464 sort | while read pkg extras ; do
|
al@603
|
1465 . "$WOK/$pkg/receipt"
|
al@284
|
1466 package_entry
|
al@284
|
1467 done
|
al@603
|
1468 echo '</table>'
|
al@284
|
1469 fi
|
al@284
|
1470 ;;
|
al@284
|
1471
|
al@603
|
1472
|
al@603
|
1473
|
al@603
|
1474
|
slaxemulator@336
|
1475 Bugs)
|
al@603
|
1476 cat <<EOT
|
slaxemulator@336
|
1477
|
al@603
|
1478 <h3>$(_ 'Known bugs in the packages')</h3>
|
al@603
|
1479
|
al@603
|
1480 <table class="bugs list">
|
al@603
|
1481 EOT
|
slaxemulator@336
|
1482 unset last
|
slaxemulator@336
|
1483 grep ^BUGS= $WOK/*/receipt | \
|
slaxemulator@336
|
1484 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
slaxemulator@336
|
1485 unset BUGS
|
al@603
|
1486 . "$WOK/$pkg/receipt"
|
al@603
|
1487 package_entry
|
al@603
|
1488 echo -n '<tr><td> </td><td colspan="2">'
|
al@603
|
1489 echo -n "$BUGS" | htmlize
|
al@603
|
1490 echo '</td></tr>'
|
slaxemulator@336
|
1491 done
|
al@603
|
1492 echo '</table>'
|
slaxemulator@336
|
1493 ;;
|
slaxemulator@336
|
1494
|
slaxemulator@336
|
1495
|
al@603
|
1496
|
al@603
|
1497
|
slaxemulator@336
|
1498 ### Arch
|
al@603
|
1499
|
slaxemulator@336
|
1500 Arch)
|
al@603
|
1501 if [ -n "$SEARCH" ]; then
|
al@603
|
1502 cat <<EOT
|
slaxemulator@336
|
1503
|
al@603
|
1504 <h3>$(_ 'The list of packages of architecture "%s"' "$SEARCH")</h3>
|
al@603
|
1505 <pre class="hard">
|
al@603
|
1506 EOT
|
al@603
|
1507 unset last
|
al@603
|
1508 grep ^HOST_ARCH= $WOK/*/receipt | grep -i "$SEARCH" | \
|
al@603
|
1509 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
al@603
|
1510 unset HOST_ARCH
|
al@603
|
1511 . "$WOK/$pkg/receipt"
|
al@603
|
1512 echo " $HOST_ARCH " | grep -iq " $SEARCH " &&
|
al@603
|
1513 package_entry_inline
|
al@603
|
1514 done
|
al@603
|
1515 cat <<EOT
|
slaxemulator@336
|
1516 </pre>
|
al@603
|
1517 EOT
|
al@603
|
1518 else
|
al@603
|
1519 # Display arch cloud
|
al@603
|
1520 grep -l ^HOST_ARCH= $WOK/*/receipt | while read file; do
|
al@603
|
1521 HOST_ARCH=
|
al@603
|
1522 . $file
|
al@603
|
1523 echo $HOST_ARCH
|
al@603
|
1524 done | display_cloud arch
|
al@603
|
1525 fi
|
slaxemulator@336
|
1526 ;;
|
al@284
|
1527
|
al@603
|
1528
|
al@603
|
1529
|
al@603
|
1530
|
pascal@458
|
1531 ### Maintainer
|
al@603
|
1532
|
pascal@458
|
1533 Maintainer)
|
pascal@458
|
1534 if [ -n "$SEARCH" ]; then
|
al@603
|
1535 cat <<EOT
|
pascal@458
|
1536
|
al@603
|
1537 <h3>$(_n 'The list of packages that <%s> maintains' "$SEARCH" | htmlize)</h3>
|
al@603
|
1538 <table class="list">
|
al@603
|
1539 EOT
|
pascal@458
|
1540 unset last
|
pascal@458
|
1541 grep ^MAINTAINER= $WOK/*/receipt | grep -i "$SEARCH" | \
|
pascal@458
|
1542 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
al@603
|
1543 . "$WOK/$pkg/receipt"
|
pascal@458
|
1544 package_entry
|
pascal@458
|
1545 done
|
al@603
|
1546 cat <<EOT
|
pascal@458
|
1547 </table>
|
al@603
|
1548 EOT
|
pascal@458
|
1549 else
|
pascal@458
|
1550 # Display maintainer cloud
|
pascal@458
|
1551 grep -l ^MAINTAINER= $WOK/*/receipt | while read file; do
|
pascal@458
|
1552 MAINTAINER=
|
pascal@458
|
1553 . $file
|
al@621
|
1554 case $MAINTAINER in
|
al@621
|
1555 # For form "John Doe <jdoe@example.org>
|
al@621
|
1556 *\<*) MAINTAINER="${MAINTAINER#*<}"; echo "${MAINTAINER%>}";;
|
al@621
|
1557 *) echo $MAINTAINER;;
|
al@621
|
1558 esac
|
pascal@458
|
1559 done | display_cloud maintainer
|
pascal@458
|
1560 fi
|
pascal@458
|
1561 ;;
|
pascal@458
|
1562
|
al@603
|
1563
|
al@603
|
1564
|
al@603
|
1565
|
pascal@458
|
1566 ### License
|
al@603
|
1567
|
pascal@458
|
1568 License)
|
pascal@458
|
1569 if [ -n "$SEARCH" ]; then
|
al@603
|
1570 cat <<EOT
|
al@603
|
1571 <h3>$(_ 'Packages with "%s" license' "$SEARCH")</h3>
|
al@603
|
1572 <table class="list">
|
al@603
|
1573 EOT
|
pascal@458
|
1574 unset last
|
pascal@458
|
1575 grep ^LICENSE= $WOK/*/receipt | grep -i "$SEARCH" | \
|
pascal@458
|
1576 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
al@603
|
1577 . "$WOK/$pkg/receipt"
|
pascal@458
|
1578 package_entry
|
pascal@458
|
1579 done
|
al@603
|
1580 echo '</table>'
|
pascal@458
|
1581 else
|
pascal@458
|
1582 # Display license cloud
|
pascal@458
|
1583 grep -l ^LICENSE= $WOK/*/receipt | while read file; do
|
pascal@458
|
1584 LICENSE=
|
pascal@458
|
1585 . $file
|
pascal@458
|
1586 echo $LICENSE
|
pascal@458
|
1587 done | display_cloud license
|
pascal@458
|
1588 fi
|
pascal@458
|
1589 ;;
|
pascal@458
|
1590
|
al@603
|
1591
|
al@603
|
1592
|
al@603
|
1593
|
pascal@458
|
1594 ### Category
|
al@603
|
1595
|
pascal@458
|
1596 Category)
|
pascal@458
|
1597 if [ -n "$SEARCH" ]; then
|
al@603
|
1598 cat <<EOT
|
al@603
|
1599 <h3>$(_ 'Packages of category "%s"' "$SEARCH")</h3>
|
al@603
|
1600 EOT
|
al@603
|
1601 if [ -f "$pinfo" ]; then
|
al@603
|
1602 package_entries category "$SEARCH"
|
al@603
|
1603 else
|
al@603
|
1604 echo '<table class="list">'
|
al@603
|
1605 unset last
|
al@603
|
1606 grep ^CATEGORY= $WOK/*/receipt | grep -i "$SEARCH" | \
|
al@603
|
1607 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
al@603
|
1608 . "$WOK/$pkg/receipt"
|
al@603
|
1609 package_entry
|
al@603
|
1610 done
|
al@603
|
1611 echo '</table>'
|
al@603
|
1612 fi
|
pascal@458
|
1613 else
|
pascal@458
|
1614 # Display category cloud
|
al@603
|
1615 if [ -f "$pinfo" ]; then
|
al@605
|
1616 tags="$(awk -F$'\t' '{if($3){print $3}}' "$pinfo" | tr ' ' $'\n' | sort | uniq -c)"
|
al@605
|
1617 max="$(echo "$tags" | awk '{if ($1 > MAX) MAX = $1} END{print MAX}')"
|
al@605
|
1618 echo "$tags" | awk -vMAX="$max" -vaddver="$addver" '{
|
al@603
|
1619 printf "<span class=\"tagn\">%s</span>", $1;
|
al@605
|
1620 printf "<a class=\"tag%s\" ", int($1 * 10 / MAX + 1);
|
al@605
|
1621 printf "href=\"?category=%s%s\">%s</a> ", $2, addver, $2;
|
al@603
|
1622 }'
|
al@603
|
1623 else
|
al@603
|
1624 grep -l ^CATEGORY= $WOK/*/receipt | \
|
al@603
|
1625 while read file; do
|
al@603
|
1626 CATEGORY=
|
al@603
|
1627 . $file
|
al@603
|
1628 echo $CATEGORY
|
pascal@458
|
1629 done | display_cloud category
|
al@603
|
1630 fi
|
pascal@458
|
1631 fi
|
pascal@458
|
1632 ;;
|
pascal@458
|
1633
|
al@603
|
1634
|
al@603
|
1635
|
al@603
|
1636
|
al@284
|
1637 ### Tags
|
al@603
|
1638
|
al@284
|
1639 Tags)
|
pascal@312
|
1640 if [ -n "$SEARCH" ]; then
|
al@603
|
1641 cat <<EOT
|
al@603
|
1642 <h3>$(_ 'The list of packages tagged "%s"' "$SEARCH")</h3>
|
al@603
|
1643 EOT
|
al@603
|
1644 if [ -f "$pinfo" ]; then
|
al@603
|
1645 package_entries tags "$SEARCH"
|
al@603
|
1646 else
|
al@603
|
1647 echo '<table class="list">'
|
al@603
|
1648 unset last
|
al@603
|
1649 grep ^TAGS= $WOK/*/receipt | grep -i "$SEARCH" | \
|
al@603
|
1650 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
|
al@603
|
1651 . "$WOK/$pkg/receipt"
|
al@603
|
1652 package_entry
|
al@603
|
1653 done
|
al@603
|
1654 echo '</table>'
|
al@603
|
1655 fi
|
pascal@312
|
1656 else
|
pascal@312
|
1657 # Display tag cloud
|
al@603
|
1658 if [ -f "$pinfo" ]; then
|
al@603
|
1659 TAGS="$(awk -F$'\t' '{if($6){print $6}}' "$pinfo" | tr ' ' $'\n' | sort | uniq -c)"
|
al@603
|
1660 MAX="$(echo "$TAGS" | awk '{if ($1 > MAX) MAX = $1} END{print MAX}')"
|
al@605
|
1661 echo "$TAGS" | awk -vMAX="$MAX" -vv="$addver" '{
|
al@603
|
1662 printf "<span class=\"tagn\">%s</span>", $1;
|
al@605
|
1663 printf "<a class=\"tag%s\" ", int($1 * 10 / MAX + 1);
|
al@605
|
1664 printf "href=\"?tags=%s%s\">%s</a> ", $2, v, $2;
|
al@603
|
1665 }'
|
al@603
|
1666 else
|
al@603
|
1667 grep -l ^TAGS= $WOK/*/receipt | \
|
al@603
|
1668 while read file; do
|
al@603
|
1669 TAGS=
|
al@603
|
1670 . $file
|
al@603
|
1671 echo $TAGS
|
pascal@560
|
1672 done | display_cloud tags
|
al@603
|
1673 fi
|
pascal@312
|
1674 fi
|
al@284
|
1675 ;;
|
al@284
|
1676
|
al@284
|
1677
|
al@603
|
1678
|
al@603
|
1679
|
al@293
|
1680 ### Package receipt with syntax highlighter
|
al@603
|
1681
|
al@284
|
1682 Receipt)
|
al@293
|
1683 if package_exist "$SEARCH"; then
|
al@603
|
1684 cat <<EOT
|
pankso@230
|
1685
|
al@603
|
1686 <h3>$(_ 'Receipt for package "%s"' "$SEARCH")</h3>
|
al@603
|
1687 <pre class="hard">
|
al@603
|
1688 EOT
|
al@603
|
1689 if [ -f $WOK/$SEARCH/taz/*/receipt ]; then
|
al@603
|
1690 syntax_highlighter $WOK/$SEARCH/taz/*/receipt
|
al@293
|
1691 else
|
al@603
|
1692 syntax_highlighter $WOK/$SEARCH/receipt
|
al@293
|
1693 fi
|
al@293
|
1694 echo '</pre>'
|
al@293
|
1695 fi
|
al@284
|
1696 ;;
|
al@284
|
1697
|
al@284
|
1698
|
al@603
|
1699
|
al@603
|
1700
|
al@284
|
1701 ### Package
|
al@603
|
1702
|
al@284
|
1703 Package)
|
al@603
|
1704 if check_n "$SEARCH"; then
|
al@603
|
1705 cat <<EOT
|
al@605
|
1706 <h3>$(_ 'Package names matching "%s"' "$SEARCH")</h3>
|
al@603
|
1707 EOT
|
pankso@230
|
1708
|
al@603
|
1709 if [ -f "$pinfo" ]; then
|
al@603
|
1710 package_entries name "$SEARCH"
|
al@603
|
1711 else
|
al@603
|
1712 echo '<table class="list">'
|
al@603
|
1713 for pkg in $(ls $WOK/ | grep -i "$SEARCH"); do
|
al@603
|
1714 . "$WOK/$pkg/receipt"
|
al@603
|
1715 package_entry
|
al@603
|
1716 done
|
al@603
|
1717 echo '</table>'
|
al@603
|
1718 fi
|
pankso@230
|
1719
|
al@605
|
1720 vpkgs="$(cut -d= -f1 < $equiv | grep -i "$SEARCH")"
|
al@603
|
1721 for vpkg in $vpkgs; do
|
al@603
|
1722 cat <<EOT
|
al@603
|
1723
|
al@603
|
1724 <h3>$(_ 'Packages providing the package "%s"' "$vpkg")</h3>
|
al@603
|
1725
|
al@603
|
1726 <table class="list">
|
al@603
|
1727 EOT
|
al@603
|
1728 for pkg in $(grep $vpkg= $equiv | sed "s|$vpkg=||"); do
|
al@605
|
1729 echo " <!-- '$pkg' - '${pkg#*:}' -->"
|
al@605
|
1730 if [ -e "$WOK/${pkg#*:}/receipt" ]; then
|
al@605
|
1731 . $WOK/${pkg#*:}/receipt
|
al@605
|
1732 package_entry
|
al@605
|
1733 fi
|
pankso@230
|
1734 done
|
al@603
|
1735 echo '</table>'
|
pankso@230
|
1736 done
|
al@284
|
1737 fi
|
al@284
|
1738 ;;
|
al@284
|
1739 esac
|
al@284
|
1740
|
al@284
|
1741 xhtml_footer
|
pankso@230
|
1742
|
pankso@230
|
1743 exit 0
|