cookutils view web/cooker.cgi @ rev 1145

cooker.cgi: fix src= path
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 05 15:22:15 2020 +0100 (2020-02-05)
parents b5e6796ff599
children 00665abb42f1
line source
1 #!/bin/sh
2 #
3 # SliTaz Cooker CGI/web interface.
4 #
6 . /usr/lib/slitaz/httphelper.sh
8 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
9 [ -f "cook.conf" ] && . ./cook.conf
11 # The same wok as cook.
12 wok="$WOK"
14 # Cooker DB files.
15 activity="$CACHE/activity"
16 commits="$CACHE/commits"
17 cooklist="$CACHE/cooklist"
18 cookorder="$CACHE/cookorder"
19 command="$CACHE/command"; touch $command
20 blocked="$CACHE/blocked"
21 broken="$CACHE/broken"
22 cooknotes="$CACHE/cooknotes"
23 cooktime="$CACHE/cooktime"
24 wokrev="$CACHE/wokrev"
26 # We're not logged and want time zone to display correct server date.
27 export TZ=$(cat /etc/TZ)
29 case "$QUERY_STRING" in
30 recook=*)
31 case "$HTTP_USER_AGENT" in
32 *SliTaz*)
33 grep -qs "^${QUERY_STRING#recook=}$" $CACHE/recook-packages ||
34 echo ${QUERY_STRING#recook=} >> $CACHE/recook-packages
35 esac
36 cat <<EOT
37 Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}
39 EOT
40 exit ;;
41 poke)
42 touch $CACHE/cooker-request
43 cat <<EOT
44 Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}
46 EOT
47 exit ;;
48 src*)
49 file="$PKGS/../src/${QUERY_STRING#*=}"
50 cat <<EOT
51 Content-Type: application/octet-stream
52 Content-Length: $(stat -c %s "$file")
53 Content-Disposition: attachment; filename="$(basename "$file")"
55 EOT
56 cat "$file"
57 exit ;;
58 download*)
59 file="$PKGS/${QUERY_STRING#*=}"
60 cat <<EOT
61 Content-Type: application/octet-stream
62 Content-Length: $(stat -c %s "$file")
63 Content-Disposition: attachment; filename="$(basename "$file")"
65 EOT
66 cat "$file"
67 exit ;;
68 rss)
69 cat <<EOT
70 Content-Type: application/rss+xml
72 EOT
73 ;;
74 *)
75 cat <<EOT
76 Content-Type: text/html; charset=utf-8
78 EOT
79 ;;
80 esac
83 # RSS feed generator
84 if [ "$QUERY_STRING" == 'rss' ]; then
85 pubdate=$(date -R)
86 cat <<EOT
87 <?xml version="1.0" encoding="utf-8" ?>
88 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
89 <channel>
90 <title>SliTaz Cooker</title>
91 <description>The SliTaz packages cooker feed</description>
92 <link>$COOKER_URL</link>
93 <lastBuildDate>$pubdate</lastBuildDate>
94 <pubDate>$pubdate</pubDate>
95 <atom:link href="http://cook.slitaz.org/?rss" rel="self" type="application/rss+xml" />
96 EOT
97 for rss in $(ls -lt $FEEDS/*.xml | head -n 12); do
98 cat $rss | sed 's|<guid|& isPermaLink="false"|g;s|</pubDate| GMT&|g'
99 done
100 cat <<EOT
101 </channel>
102 </rss>
103 EOT
104 exit 0
105 fi
108 #
109 # Functions
110 #
113 # Unpack to stdout
115 docat() {
116 case "$1" in
117 *gz) zcat ;;
118 *bz2) bzcat ;;
119 *xz) xzcat ;;
120 *) cat
121 esac < $1
122 }
125 # Tiny texinfo browser
127 info2html() {
128 sed \
129 -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' \
130 -e 's|^\* \(.*\)::|* <a href="#\1">\1</a> |' \
131 -e 's|\*note \(.*\)::|<a href="#\1">\1</a>|' \
132 -e '/^File: /s|(dir)|Top|g' \
133 -e '/^File: /s|Node: \([^,]*\)|Node: <a name="\1"></a><u>\1</u>|' \
134 -e '/^File: /s|Next: \([^,]*\)|Next: <a href="#\1">\1</a>|' \
135 -e '/^File: /s|Prev: \([^,]*\)|Prev: <a href="#\1">\1</a>|' \
136 -e '/^File: /s|Up: \([^,]*\)|Up: <a href="#\1">\1</a>|' \
137 -e '/^File: /s|^.*$|<i>&</i>|' \
138 -e '/^Tag Table:$/,/^End Tag Table$/d' \
139 -e '/INFO-DIR/,/^END-INFO-DIR/d' \
140 -e "s|https*://[^>),'\"\` ]*|<a href=\"&\">&</a>|g" \
141 -e "s|ftp://[^>),\"\` ]*|<a href=\"&\">&</a>|g" \
142 -e "s|^|</pre><pre>|"
143 }
146 # Put some colors in log and DB files.
148 syntax_highlighter() {
149 case $1 in
150 log)
151 # If variables not defined - define them with some rare values
152 : ${_src=#_#_#}
153 : ${_install=#_#_#}
154 : ${_fs=#_#_#}
155 : ${_stuff=#_#_#}
156 sed -e 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g' \
157 -e 's#OK$#<span class="span-ok">OK</span>#g' \
158 -e 's#Done$#<span class="span-ok">Done</span>#g' \
159 -e 's#done$#<span class="span-ok">done</span>#g' \
160 -e 's#\([^a-z]\)ok$#\1<span class="span-ok">ok</span>#g' \
161 -e 's#\([^a-z]\)yes$#\1<span class="span-ok">yes</span>#g' \
162 -e 's#\([^a-z]\)no$#\1<span class="span-no">no</span>#g' \
163 \
164 -e 's#\( \[Y[nm/]\?\] n\)$# <span class="span-no">\1</span>#g' \
165 -e 's#\( \[N[ym/]\?\] y\)$# <span class="span-ok">\1</span>#g' \
166 -e 's#(NEW) $#<span class="span-red">(NEW) </span>#g' \
167 \
168 -e 's#.*(pkg/local).*#<span class="span-ok">\0</span>#g' \
169 -e 's#.*(web/cache).*#<span class="span-no">\0</span>#g' \
170 \
171 -e 's#error$#<span class="span-red">error</span>#g' \
172 -e 's#ERROR:#<span class="span-red">ERROR:</span>#g' \
173 -e 's#Error#<span class="span-red">Error</span>#g' \
174 \
175 -e 's#^.*[Ff]ailed.*#<span class="span-red">\0</span>#g' \
176 -e 's#^.*[Ff]atal.*#<span class="span-red">\0</span>#g' \
177 -e 's#^.*[Nn]ot found.*#<span class="span-red">\0</span>#g' \
178 -e 's#^.*[Nn]o such file.*#<span class="span-red">\0</span>#g' \
179 \
180 -e 's#WARNING:#<span class="span-red">WARNING:</span>#g' \
181 -e 's#warning:#<span class="span-no">warning:</span>#g' \
182 -e 's#error:#<span class="span-no">error:</span>#g' \
183 -e 's#missing#<span class="span-no">missing</span>#g' \
184 \
185 -e 's#^.* will not .*#<span class="span-no">\0</span>#' \
186 -e 's!^Hunk .* succeeded at .*!<span class="span-no">\0</span>!' \
187 -e 's#^.* Warning: .*#<span class="span-no">\0</span>#' \
188 \
189 -e "s#^Executing:\([^']*\).#<span class='sh-val'>\0</span>#" \
190 -e "s#^Making.*#<span class='sh-val'>\0</span>#" \
191 -e "s#^====\([^']*\).#<span class='span-line'>\0</span>#g" \
192 -e "s#^[a-zA-Z0-9]\([^']*\) :: #<span class='span-sky'>\0</span>#g" \
193 -e "s#ftp://[^ '\"]*#<a href='\0'>\0</a>#g" \
194 -e "s#http://[^ '\"]*#<a href='\0'>\0</a>#g" \
195 -e "s|$_src|<span class='var'>\${src}</span>|g;
196 s|$_install|<span class='var'>\${install}</span>|g;
197 s|$_fs|<span class='var'>\${fs}</span>|g;
198 s|$_stuff|<span class='var'>\${stuff}</span>|g" \
199 -e "s|\[91m|<span style='color: #F00'>|;
200 s|\[92m|<span style='color: #080'>|;
201 s|\[93m|<span style='color: #FF0'>|;
202 s|\[94m|<span style='color: #00F'>|;
203 s|\[95m|<span style='color: #808'>|;
204 s|\[96m|<span style='color: #0CC'>|;
205 s|\[39m|</span>|;"
206 ;;
208 receipt)
209 sed -e s'|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|'g \
210 -e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g \
211 -e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g ;;
213 diff)
214 sed -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g' \
215 -e s"#^-\([^']*\).#<span class='span-red'>\0</span>#"g \
216 -e s"#^+\([^']*\).#<span class='span-ok'>\0</span>#"g \
217 -e s"#@@\([^']*\)@@#<span class='span-sky'>@@\1@@</span>#"g ;;
219 activity)
220 sed s"#^\([^']* : \)#<span class='log-date'>\0</span>#"g ;;
221 esac
222 }
225 # Latest build pkgs.
227 list_packages() {
228 cd $PKGS
229 ls -1t *.tazpkg | head -n20 | \
230 while read file; do
231 echo -n $(TZ=UTC stat -c '%y' $PKGS/$file | cut -d. -f1 | sed s/:[0-9]*$//)
232 echo " : $file"
233 done
234 }
237 # Optional full list button
239 more_button() {
240 [ $(wc -l < ${3:-$CACHE/$1}) -gt ${4:-12} ] && cat <<EOT
241 <div style="float: right;">
242 <a class="button" href="?file=$1">$2</a>
243 </div>
244 EOT
245 }
248 # Show the running command and its progression
250 running_command()
251 {
252 local state="Not running"
253 if [ -s "$command" ]; then
254 state="$(cat $command)"
255 set -- $(grep "^$state" $cooktime)
256 if [ -n "$1" -a $2 -ne 0 ]; then
257 state="$state $((($(date +%s)-$3)*100/$2))%"
258 [ $2 -gt 300 ] && state="$state (should end $(date -u -d @$(($2+$3))))"
259 fi
260 fi
261 echo $state
262 }
265 # xHTML header. Pages can be customized with a separated html.header file.
267 if [ -f "header.html" ]; then
268 cat header.html
269 else
270 cat <<EOT
271 <!DOCTYPE html>
272 <html lang="en">
273 <head>
274 <meta charset="UTF-8">
275 <title>SliTaz Cooker</title>
276 <link rel="shortcut icon" href="favicon.ico">
277 <link rel="stylesheet" href="style.css">
278 <meta name="robots" content="nofollow">
279 </head>
280 <body>
282 <div id="header">
283 <div id="logo"></div>
284 <h1><a href="cooker.cgi">SliTaz Cooker</a></h1>
285 </div>
287 <!-- Content -->
288 <div id="content">
289 EOT
290 fi
293 #
294 # Load requested page
295 #
297 case "${QUERY_STRING}" in
298 pkg=*)
299 pkg=${QUERY_STRING#pkg=}
300 log=$LOGS/$pkg.log
301 echo "<h2>Package: $pkg</h2>"
303 # Define cook variables for syntax highlighter
304 if [ -s "$WOK/$pkg/receipt" ]; then
305 . "$WOK/$pkg/receipt"
306 _wok='/home/slitaz/wok'
307 _src="$_wok/$pkg/source/$PACKAGE-$VERSION"
308 _install="$_wok/$pkg/install"
309 _fs="$_wok/$pkg/taz/$PACKAGE-$VERSION/fs"
310 _stuff="$_wok/$pkg/stuff"
311 fi
313 # Package info.
314 echo '<div id="info">'
315 if [ -f "$wok/$pkg/receipt" ]; then
316 echo "<a href='?receipt=$pkg'>receipt</a>"
317 unset WEB_SITE
318 unset WANTED
319 bpkg=$pkg
320 . $wok/$pkg/receipt
322 [ -n "$WANTED" ] && bpkg="${WANTED%% *}" # see locale-* with multiple WANTED
323 [ -n "$WEB_SITE" ] && # busybox wget -s $WEB_SITE &&
324 echo "<a href='$WEB_SITE'>home</a>"
326 if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then
327 echo "<a href='?files=$pkg'>files</a>"
328 unset EXTRAVERSION
329 . $wok/$pkg/taz/$PACKAGE-$VERSION/receipt
330 if [ -f $wok/$pkg/taz/$PACKAGE-$VERSION/description.txt ]; then
331 echo "<a href='?description=$pkg'>description</a>"
332 fi
333 if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
334 echo "<a href='?download=$PACKAGE-$VERSION$EXTRAVERSION.tazpkg'>download</a>"
335 fi
336 if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then
337 echo "<a href='?download=$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg'>download</a>"
338 fi
339 fi
340 [ -x ./man2html ] &&
341 if [ -d $wok/$bpkg/install/usr/man ] ||
342 [ -d $wok/$bpkg/install/usr/local/man ] ||
343 [ -d $wok/$bpkg/install/usr/share/man ] ||
344 [ -d $wok/$bpkg/taz/*/fs/usr/man ] ||
345 [ -d $wok/$bpkg/taz/*/fs/usr/share/man ]; then
346 echo "<a href='?man=$bpkg'>man</a>"
347 fi
348 if [ -d $wok/$bpkg/install/usr/doc ] ||
349 [ -d $wok/$bpkg/install/usr/share/doc ] ||
350 [ -d $wok/$bpkg/taz/*/fs/usr/doc ] ||
351 [ -d $wok/$bpkg/taz/*/fs/usr/share/doc ]; then
352 echo "<a href='?doc=$bpkg'>doc</a>"
353 fi
354 if [ -d $wok/$bpkg/install/usr/info ] ||
355 [ -d $wok/$bpkg/install/usr/share/info ] ||
356 [ -d $wok/$bpkg/taz/*/fs/usr/info ] ||
357 [ -d $wok/$bpkg/taz/*/fs/usr/share/info ]; then
358 echo "<a href='?info=$bpkg'>info</a>"
359 fi
360 [ -n "$(echo $REQUEST_URI | sed 's|/[^/]*?pkg.*||')" ] ||
361 echo "<a href='?browse=$pkg/'>browse</a>"
362 else
363 if [ $(ls $wok/*$pkg*/receipt 2>/dev/null | wc -l) -eq 0 ]; then
364 echo "No package named: $pkg"
365 else
366 ls $wok/$pkg/receipt >/dev/null 2>&1 || pkg="*$pkg*"
367 echo '<table style="width:100%">'
368 for i in $(cd $wok ; ls $pkg/receipt); do
369 pkg=$(dirname $i)
370 unset SHORT_DESC CATEGORY
371 . $wok/$pkg/receipt
372 cat <<EOT
373 <tr>
374 <td><a href="?pkg=$pkg">$pkg</a></td>
375 <td>$SHORT_DESC</td>
376 <td>$CATEGORY</td>
377 </tr>
378 EOT
379 done
380 echo '</table>'
381 unset pkg
382 fi
383 fi
384 echo '</div>'
386 # Check for a log file and display summary if it exists.
387 if [ -f "$log" ]; then
388 if grep -q "cook:$pkg$" $command; then
389 echo "<pre>The Cooker is currently building: $pkg</pre>"
390 fi
391 if fgrep -q "Summary for:" $LOGS/$pkg.log; then
392 echo '<h3>Cook summary</h3>'
393 echo '<pre>'
394 grep -A 12 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
395 syntax_highlighter log
396 echo '</pre>'
397 fi
398 if fgrep -q "Debug information" $LOGS/$pkg.log; then
399 echo '<h3>Cook failed</h3>'
400 echo '<pre>'
401 grep -A 8 "^Debug information" $LOGS/$pkg.log | sed /^$/d | \
402 syntax_highlighter log
403 echo '</pre>'
404 fi
405 echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
406 for i in $(ls -t $log.*); do
407 echo -n "<a href=\"?log=$(basename $i)\">"
408 echo "$(stat -c %y $i | sed 's/ .*//')</a>"
409 done
410 echo '<pre>'
411 cat $log | syntax_highlighter log
412 echo '</pre>'
413 case "$HTTP_USER_AGENT" in
414 *SliTaz*)
415 [ -f $CACHE/cooker-request ] && [ -n "$HTTP_REFERER" ] &&
416 echo "<a class=\"button\" href=\"?recook=$pkg\">Recook $pkg</a>"
417 esac
418 else
419 [ "$pkg" ] && echo "<pre>No log: $pkg</pre>"
420 fi ;;
422 view=*)
423 file="${QUERY_STRING#view=}"
424 echo "<h2>View: $file</h2>"
425 echo "<a href=\"?browse=?$file\">browse</a>"
426 echo "<pre>"
427 ls "$WOK/$file" | while read i; do
428 meta="$(ls -ld "$WOK/$file/$i" | cut -c-57)"
429 name="$i"
430 ref="stuff=../wok/$file$i"
431 [ -d "$WOK/$file/$i" ] && ref="view=$file$i/"
432 [ -L "$WOK/$file/$i" ] && name="$i -> $(readlink "$i")"
433 echo "$meta<a href=\"?$ref\">$name</a>"
434 done
435 echo "</pre>"
436 ;;
438 browse=*)
439 file="${QUERY_STRING#browse=}"
440 echo "<h2>Browse: $file</h2>"
441 echo "<pre>"
442 ls "$WOK/$file" | while read i; do
443 meta="$(ls -ld "$WOK/$file/$i" | cut -c-57)"
444 name="$i"
445 ref="download=../wok/$file$i"
446 [ -d "$WOK/$file/$i" ] && ref="browse=$file$i/"
447 [ -L "$WOK/$file/$i" ] && name="$i -> $(readlink "$i")"
448 echo "$meta<a href=\"?$ref\">$name</a>"
449 done
450 echo "</pre>"
451 ;;
453 log=*)
454 log=$LOGS/${QUERY_STRING#log=}
455 if [ -s $log ]; then
456 echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
457 if fgrep -q "Summary" $log; then
458 echo '<pre>'
459 grep -A 20 "^Summary" $log | sed /^$/d | \
460 syntax_highlighter log
461 echo '</pre>'
462 fi
463 echo '<pre>'
464 cat $log | syntax_highlighter log
465 echo '</pre>'
466 fi
467 ;;
468 file=*)
469 # Don't allow all files on the system for security reasons.
470 file=${QUERY_STRING#file=}
471 case "$file" in
472 activity|cooknotes|cooklist)
473 [ "$file" == "cooklist" ] && \
474 nb="- Packages: $(cat $cooklist | wc -l)"
475 echo "<h2>DB: $file $nb</h2>"
476 echo '<pre>'
477 tac $CACHE/$file | syntax_highlighter activity
478 echo '</pre>' ;;
480 broken)
481 nb=$(cat $broken | wc -l)
482 echo "<h2>DB: broken - Packages: $nb</h2>"
483 echo '<pre>'
484 cat $CACHE/$file | sort | \
485 sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g
486 echo '</pre>' ;;
488 *.diff)
489 diff=$CACHE/$file
490 echo "<h2>Diff for: ${file%.diff}</h2>"
491 [ "$file" == "installed.diff" ] && echo \
492 "<p>This is the latest diff between installed packages \
493 and installed build dependencies to cook.</p>"
494 echo '<pre>'
495 cat $diff | syntax_highlighter diff
496 echo '</pre>' ;;
498 *.log)
499 log=$LOGS/$file
500 name=$(basename $log)
501 echo "<h2>Log for: ${name%.log}</h2>"
502 if [ -f "$log" ]; then
503 if fgrep -q "Summary" $log; then
504 echo '<pre>'
505 grep -A 20 "^Summary" $log | sed /^$/d | \
506 syntax_highlighter log
507 echo '</pre>'
508 fi
509 echo '<pre>'
510 cat $log | syntax_highlighter log
511 echo '</pre>'
512 else
513 echo "<pre>No log file: $log</pre>"
514 fi ;;
515 esac ;;
517 stuff=*)
518 file=${QUERY_STRING#stuff=}
519 file="${file//%20/ }"
520 echo "<h2>$file</h2>"
521 #echo "<a href=\"?download=$file\">download</a>"
522 echo '<pre>'
523 cat "$wok/$file" | sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
524 echo '</pre>' ;;
526 receipt=*)
527 pkg=${QUERY_STRING#receipt=}
528 echo "<h2>Receipt for: $pkg</h2>"
529 if [ -f "$wok/$pkg/receipt" ]; then
530 . $wok/$pkg/receipt
531 [ -n "$TARBALL" ] && [ -s "$SRC/$TARBALL" ] &&
532 echo "<a href='?src=$TARBALL'>source</a>"
534 ( cd $wok/$pkg ; find stuff -type f 2> /dev/null ) | \
535 while read file ; do
536 echo "<a href=\"?stuff=$pkg/$file\">$file</a>"
537 done | sort
538 echo '<pre>'
539 cat $wok/$pkg/receipt | \
540 syntax_highlighter receipt
541 echo '</pre>'
542 else
543 echo "<pre>No receipt for: $pkg</pre>"
544 fi ;;
546 files=*)
547 pkg=${QUERY_STRING#files=}
548 dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
549 if [ -d "$dir/fs" ]; then
550 echo "<h2>Installed files by: $pkg ($(du -hs $dir/fs | awk '{ print $1 }'))</h2>"
551 echo '<pre>'
552 find $dir/fs -not -type d -print0 | xargs -0 ls -ld | \
553 sed "s|^\(-.*\) /.*\(${dir#*wok}/fs\)\(.*\)|\1 <a href=\"?download=../wok\2\3\">\3</a>|;s| /[^>]*${dir#*wok}/fs| \1|"
554 echo '</pre>'
555 else
556 echo "<pre>No files list for: $pkg</pre>"
557 fi ;;
559 description=*)
560 pkg=${QUERY_STRING#description=}
561 echo "<h2>Description of $pkg</h2>"
562 dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
563 if [ -s "$dir/description.txt" ]; then
564 echo '<pre>'
565 cat $dir/description.txt | \
566 sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
567 echo '</pre>'
568 else
569 echo "<pre>No description for: $pkg</pre>"
570 fi ;;
572 man=*|doc=*|info=*)
573 type=${QUERY_STRING%%=*}
574 pkg=$(GET $type)
575 dir=$WOK/$pkg/install/usr/share/$type
576 [ -d $dir ] || dir=$WOK/$pkg/install/usr/$type
577 [ -d $dir ] || dir=$(echo $WOK/$pkg/taz/*/fs/usr/share/$type)
578 [ -d $dir ] || dir=$(echo $WOK/$pkg/taz/*/fs/usr/$type)
579 page=$(GET file)
580 if [ -z "$page" ]; then
581 page=$(find $dir -type f | sed q)
582 page=${page#$dir/}
583 fi
584 find $dir -type f | while read file ; do
585 [ -s $file ] || continue
586 case "$file" in
587 *.jp*g|*.png|*.gif|*.svg) continue
588 esac
589 file=${file#$dir/}
590 echo "<a href='?$type=$pkg&amp;file=$file'>$(basename $file)</a>"
591 done | sort -t \> -k 2
592 echo "<h2>$(basename $page)</h2>"
593 tmp="$(mktemp)"
594 docat "$dir/$page" > $tmp
595 [ -s "$tmp" ] && case "$type" in
596 info)
597 echo '<pre>'
598 info2html < "$tmp"
599 echo '</pre>' ;;
600 doc)
601 echo '<pre>'
602 case "$page" in
603 *.htm*) cat ;;
604 *) sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
605 esac < "$tmp"
606 echo '</pre>' ;;
607 man)
608 export TEXTDOMAIN='man2html'
609 ./man2html "$tmp" | sed -e '1,/<header>/d' \
610 -e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
611 -e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g' ;;
612 esac
613 rm -f $tmp
614 ;;
615 *)
616 # We may have a toolchain.cgi script for cross cooker's
617 if [ -f "toolchain.cgi" ]; then
618 toolchain='toolchain.cgi'
619 else
620 toolchain='?pkg=slitaz-toolchain'
621 fi
622 # Main page with summary. Count only package include in ARCH,
623 # use 'cooker arch-db' to manually create arch.$ARCH files.
624 inwok=$(ls $WOK/*/arch.$ARCH | wc -l)
625 cooked=$(ls $PKGS/*.tazpkg | wc -l)
626 unbuilt=$(($inwok - $cooked))
627 pct=0
628 [ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok ))
629 cat <<EOT
630 <div style="float: right;">
631 <form method="get" action="$SCRIPT_NAME">
632 Package:
633 <input type="text" name="pkg" />
634 </form>
635 </div>
637 <h2>Summary</h2>
639 <pre>
640 Running command : $(running_command)
641 Wok revision : <a href="$WOK_URL">$(cat $wokrev)</a>
642 Commits to cook : $(cat $commits | wc -l)
643 Current cooklist : $(cat $cooklist | wc -l)
644 Broken packages : $(cat $broken | wc -l)
645 Blocked packages : $(cat $blocked | wc -l)
646 </pre>
647 EOT
648 [ -e $CACHE/cooker-request ] &&
649 [ $CACHE/activity -nt $CACHE/cooker-request ] && cat <<EOT
650 <div style="float: right;">
651 <a class="button" href="?poke">Poke cooker</a>
652 </div>
653 EOT
654 cat <<EOT
655 <p class="info">
656 Packages: $inwok in the wok | $cooked cooked | $unbuilt unbuilt |
657 Server date: $(date -u '+%F %R %Z')
658 </p>
659 <div class="pctbar">
660 <div class="pct" style="width: ${pct}%;">${pct}%</div>
661 </div>
663 <p>
664 Latest:
665 <a href="?file=cookorder.log">cookorder.log</a>
666 <a href="?file=commits.log">commits.log</a>
667 <a href="?file=pkgdb.log">pkgdb.log</a>
668 <a href="?file=installed.diff">installed.diff</a>
669 - Architecture $ARCH:
670 <a href="$toolchain">toolchain</a>
671 </p>
673 $(more_button activity "More activity" $CACHE/activity 12)
674 <h2 id="activity">Activity</h2>
675 <pre>
676 $(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
677 </pre>
678 EOT
680 [ -s $cooknotes ] && cat <<EOT
681 $(more_button cooknotes "More notes" $cooknotes 12)
682 <h2 id="cooknotes">Cooknotes</h2>
683 <pre>
684 $(tac $cooknotes | head -n 12 | syntax_highlighter activity)
685 </pre>
686 EOT
688 [ -s $commits ] && cat <<EOT
689 <h2 id="commits">Commits</h2>
690 <pre>
691 $(cat $commits)
692 </pre>
693 EOT
695 [ -s $cooklist ] && cat <<EOT
696 $(more_button cooklist "Full cooklist" $cooklist 20)
697 <h2 id="cooklist">Cooklist</h2>
698 <pre>
699 $(cat $cooklist | head -n 20)
700 </pre>
701 EOT
703 [ -s $broken ] && cat <<EOT
704 $(more_button broken "All broken packages" $broken 20)
705 <h2 id="broken">Broken</h2>
706 <pre>
707 $(cat $broken | head -n 20 | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
708 </pre>
709 EOT
711 [ -s $blocked ] && cat <<EOT
712 <h2 id="blocked">Blocked</h2>
713 <pre>
714 $(cat $blocked | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
715 </pre>
716 EOT
718 cat <<EOT
719 <h2 id="lastcook">Latest cook</h2>
720 <pre>
721 $(list_packages | sed s"#^\([^']*\).* : #<span class='log-date'>\0</span>#"g)
722 </pre>
723 EOT
724 ;;
725 esac
728 # Close xHTML page
730 cat <<EOT
731 </div>
733 <div id="footer">
734 <a href="http://www.slitaz.org/">SliTaz Website</a>
735 <a href="cooker.cgi">Cooker</a>
736 <a href="doc/cookutils/cookutils.en.html">Documentation</a>
737 </div>
739 </body>
740 </html>
741 EOT
743 exit 0