cookutils view web/cooker.cgi @ rev 951

Minor bug fixes due to the change in the behavior of the dot command in Busybox-1.27.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jul 27 13:36:30 2017 +0300 (2017-07-27)
parents fe29568da760
children b5e6796ff599
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=$(busybox httpd -d "$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=$(busybox httpd -d "$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/share/man ] ||
343 [ -d $wok/$bpkg/taz/*/fs/usr/man ] ||
344 [ -d $wok/$bpkg/taz/*/fs/usr/share/man ]; then
345 echo "<a href='?man=$bpkg'>man</a>"
346 fi
347 if [ -d $wok/$bpkg/install/usr/doc ] ||
348 [ -d $wok/$bpkg/install/usr/share/doc ] ||
349 [ -d $wok/$bpkg/taz/*/fs/usr/doc ] ||
350 [ -d $wok/$bpkg/taz/*/fs/usr/share/doc ]; then
351 echo "<a href='?doc=$bpkg'>doc</a>"
352 fi
353 if [ -d $wok/$bpkg/install/usr/info ] ||
354 [ -d $wok/$bpkg/install/usr/share/info ] ||
355 [ -d $wok/$bpkg/taz/*/fs/usr/info ] ||
356 [ -d $wok/$bpkg/taz/*/fs/usr/share/info ]; then
357 echo "<a href='?info=$bpkg'>info</a>"
358 fi
359 [ -n "$(echo $REQUEST_URI | sed 's|/[^/]*?pkg.*||')" ] ||
360 echo "<a href='ftp://${HTTP_HOST%:*}/$pkg/'>browse</a>"
361 else
362 if [ $(ls $wok/*$pkg*/receipt 2>/dev/null | wc -l) -eq 0 ]; then
363 echo "No package named: $pkg"
364 else
365 ls $wok/$pkg/receipt >/dev/null 2>&1 || pkg="*$pkg*"
366 echo '<table style="width:100%">'
367 for i in $(cd $wok ; ls $pkg/receipt); do
368 pkg=$(dirname $i)
369 unset SHORT_DESC CATEGORY
370 . $wok/$pkg/receipt
371 cat <<EOT
372 <tr>
373 <td><a href="?pkg=$pkg">$pkg</a></td>
374 <td>$SHORT_DESC</td>
375 <td>$CATEGORY</td>
376 </tr>
377 EOT
378 done
379 echo '</table>'
380 unset pkg
381 fi
382 fi
383 echo '</div>'
385 # Check for a log file and display summary if it exists.
386 if [ -f "$log" ]; then
387 if grep -q "cook:$pkg$" $command; then
388 echo "<pre>The Cooker is currently building: $pkg</pre>"
389 fi
390 if fgrep -q "Summary for:" $LOGS/$pkg.log; then
391 echo '<h3>Cook summary</h3>'
392 echo '<pre>'
393 grep -A 12 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
394 syntax_highlighter log
395 echo '</pre>'
396 fi
397 if fgrep -q "Debug information" $LOGS/$pkg.log; then
398 echo '<h3>Cook failed</h3>'
399 echo '<pre>'
400 grep -A 8 "^Debug information" $LOGS/$pkg.log | sed /^$/d | \
401 syntax_highlighter log
402 echo '</pre>'
403 fi
404 echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
405 for i in $(ls -t $log.*); do
406 echo -n "<a href=\"?log=$(basename $i)\">"
407 echo "$(stat -c %y $i | sed 's/ .*//')</a>"
408 done
409 echo '<pre>'
410 cat $log | syntax_highlighter log
411 echo '</pre>'
412 case "$HTTP_USER_AGENT" in
413 *SliTaz*)
414 [ -f $CACHE/cooker-request ] && [ -n "$HTTP_REFERER" ] &&
415 echo "<a class=\"button\" href=\"?recook=$pkg\">Recook $pkg</a>"
416 esac
417 else
418 [ "$pkg" ] && echo "<pre>No log: $pkg</pre>"
419 fi ;;
421 log=*)
422 log=$LOGS/${QUERY_STRING#log=}
423 if [ -s $log ]; then
424 echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
425 if fgrep -q "Summary" $log; then
426 echo '<pre>'
427 grep -A 20 "^Summary" $log | sed /^$/d | \
428 syntax_highlighter log
429 echo '</pre>'
430 fi
431 echo '<pre>'
432 cat $log | syntax_highlighter log
433 echo '</pre>'
434 fi
435 ;;
436 file=*)
437 # Don't allow all files on the system for security reasons.
438 file=${QUERY_STRING#file=}
439 case "$file" in
440 activity|cooknotes|cooklist)
441 [ "$file" == "cooklist" ] && \
442 nb="- Packages: $(cat $cooklist | wc -l)"
443 echo "<h2>DB: $file $nb</h2>"
444 echo '<pre>'
445 tac $CACHE/$file | syntax_highlighter activity
446 echo '</pre>' ;;
448 broken)
449 nb=$(cat $broken | wc -l)
450 echo "<h2>DB: broken - Packages: $nb</h2>"
451 echo '<pre>'
452 cat $CACHE/$file | sort | \
453 sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g
454 echo '</pre>' ;;
456 *.diff)
457 diff=$CACHE/$file
458 echo "<h2>Diff for: ${file%.diff}</h2>"
459 [ "$file" == "installed.diff" ] && echo \
460 "<p>This is the latest diff between installed packages \
461 and installed build dependencies to cook.</p>"
462 echo '<pre>'
463 cat $diff | syntax_highlighter diff
464 echo '</pre>' ;;
466 *.log)
467 log=$LOGS/$file
468 name=$(basename $log)
469 echo "<h2>Log for: ${name%.log}</h2>"
470 if [ -f "$log" ]; then
471 if fgrep -q "Summary" $log; then
472 echo '<pre>'
473 grep -A 20 "^Summary" $log | sed /^$/d | \
474 syntax_highlighter log
475 echo '</pre>'
476 fi
477 echo '<pre>'
478 cat $log | syntax_highlighter log
479 echo '</pre>'
480 else
481 echo "<pre>No log file: $log</pre>"
482 fi ;;
483 esac ;;
485 stuff=*)
486 file=${QUERY_STRING#stuff=}
487 echo "<h2>$file</h2>"
488 echo '<pre>'
489 cat $wok/$file | sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
490 echo '</pre>' ;;
492 receipt=*)
493 pkg=${QUERY_STRING#receipt=}
494 echo "<h2>Receipt for: $pkg</h2>"
495 if [ -f "$wok/$pkg/receipt" ]; then
496 . $wok/$pkg/receipt
497 [ -n "$TARBALL" ] && [ -s "$SRC/$TARBALL" ] &&
498 echo "<a href='?src=$TARBALL'>source</a>"
500 ( cd $wok/$pkg ; find stuff -type f 2> /dev/null ) | \
501 while read file ; do
502 echo "<a href=\"?stuff=$pkg/$file\">$file</a>"
503 done | sort
504 echo '<pre>'
505 cat $wok/$pkg/receipt | \
506 syntax_highlighter receipt
507 echo '</pre>'
508 else
509 echo "<pre>No receipt for: $pkg</pre>"
510 fi ;;
512 files=*)
513 pkg=${QUERY_STRING#files=}
514 dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
515 if [ -d "$dir/fs" ]; then
516 echo "<h2>Installed files by: $pkg ($(du -hs $dir/fs | awk '{ print $1 }'))</h2>"
517 echo '<pre>'
518 find $dir/fs -not -type d -print0 | xargs -0 ls -ld | \
519 sed "s|\(.*\) /.*\(${dir#*wok}/fs\)\(.*\)|\1 <a href=\"?download=../wok\2\3\">\3</a>|;s|^\([^-].*\)\(<a.*\)\">\(.*\)</a>|\1\3|"
520 echo '</pre>'
521 else
522 echo "<pre>No files list for: $pkg</pre>"
523 fi ;;
525 description=*)
526 pkg=${QUERY_STRING#description=}
527 echo "<h2>Description of $pkg</h2>"
528 dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
529 if [ -s "$dir/description.txt" ]; then
530 echo '<pre>'
531 cat $dir/description.txt | \
532 sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
533 echo '</pre>'
534 else
535 echo "<pre>No description for: $pkg</pre>"
536 fi ;;
538 man=*|doc=*|info=*)
539 type=${QUERY_STRING%%=*}
540 pkg=$(GET $type)
541 dir=$WOK/$pkg/install/usr/share/$type
542 [ -d $dir ] || dir=$WOK/$pkg/install/usr/$type
543 [ -d $dir ] || dir=$(echo $WOK/$pkg/taz/*/fs/usr/share/$type)
544 [ -d $dir ] || dir=$(echo $WOK/$pkg/taz/*/fs/usr/$type)
545 page=$(GET file)
546 if [ -z "$page" ]; then
547 page=$(find $dir -type f | sed q)
548 page=${page#$dir/}
549 fi
550 find $dir -type f | while read file ; do
551 [ -s $file ] || continue
552 case "$file" in
553 *.jp*g|*.png|*.gif|*.svg) continue
554 esac
555 file=${file#$dir/}
556 echo "<a href='?$type=$pkg&amp;file=$file'>$(basename $file)</a>"
557 done | sort -t \> -k 2
558 echo "<h2>$(basename $page)</h2>"
559 tmp="$(mktemp)"
560 docat "$dir/$page" > $tmp
561 [ -s "$tmp" ] && case "$type" in
562 info)
563 echo '<pre>'
564 info2html < "$tmp"
565 echo '</pre>' ;;
566 doc)
567 echo '<pre>'
568 case "$page" in
569 *.htm*) cat ;;
570 *) sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
571 esac < "$tmp"
572 echo '</pre>' ;;
573 man)
574 export TEXTDOMAIN='man2html'
575 ./man2html "$tmp" | sed -e '1,/<header>/d' \
576 -e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
577 -e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g' ;;
578 esac
579 rm -f $tmp
580 ;;
581 *)
582 # We may have a toolchain.cgi script for cross cooker's
583 if [ -f "toolchain.cgi" ]; then
584 toolchain='toolchain.cgi'
585 else
586 toolchain='?pkg=slitaz-toolchain'
587 fi
588 # Main page with summary. Count only package include in ARCH,
589 # use 'cooker arch-db' to manually create arch.$ARCH files.
590 inwok=$(ls $WOK/*/arch.$ARCH | wc -l)
591 cooked=$(ls $PKGS/*.tazpkg | wc -l)
592 unbuilt=$(($inwok - $cooked))
593 pct=0
594 [ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok ))
595 cat <<EOT
596 <div style="float: right;">
597 <form method="get" action="$SCRIPT_NAME">
598 Package:
599 <input type="text" name="pkg" />
600 </form>
601 </div>
603 <h2>Summary</h2>
605 <pre>
606 Running command : $(running_command)
607 Wok revision : <a href="$WOK_URL">$(cat $wokrev)</a>
608 Commits to cook : $(cat $commits | wc -l)
609 Current cooklist : $(cat $cooklist | wc -l)
610 Broken packages : $(cat $broken | wc -l)
611 Blocked packages : $(cat $blocked | wc -l)
612 </pre>
613 EOT
614 [ -e $CACHE/cooker-request ] &&
615 [ $CACHE/activity -nt $CACHE/cooker-request ] && cat <<EOT
616 <div style="float: right;">
617 <a class="button" href="?poke">Poke cooker</a>
618 </div>
619 EOT
620 cat <<EOT
621 <p class="info">
622 Packages: $inwok in the wok | $cooked cooked | $unbuilt unbuilt |
623 Server date: $(date -u '+%F %R %Z')
624 </p>
625 <div class="pctbar">
626 <div class="pct" style="width: ${pct}%;">${pct}%</div>
627 </div>
629 <p>
630 Latest:
631 <a href="?file=cookorder.log">cookorder.log</a>
632 <a href="?file=commits.log">commits.log</a>
633 <a href="?file=pkgdb.log">pkgdb.log</a>
634 <a href="?file=installed.diff">installed.diff</a>
635 - Architecture $ARCH:
636 <a href="$toolchain">toolchain</a>
637 </p>
639 $(more_button activity "More activity" $CACHE/activity 12)
640 <h2 id="activity">Activity</h2>
641 <pre>
642 $(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
643 </pre>
644 EOT
646 [ -s $cooknotes ] && cat <<EOT
647 $(more_button cooknotes "More notes" $cooknotes 12)
648 <h2 id="cooknotes">Cooknotes</h2>
649 <pre>
650 $(tac $cooknotes | head -n 12 | syntax_highlighter activity)
651 </pre>
652 EOT
654 [ -s $commits ] && cat <<EOT
655 <h2 id="commits">Commits</h2>
656 <pre>
657 $(cat $commits)
658 </pre>
659 EOT
661 [ -s $cooklist ] && cat <<EOT
662 $(more_button cooklist "Full cooklist" $cooklist 20)
663 <h2 id="cooklist">Cooklist</h2>
664 <pre>
665 $(cat $cooklist | head -n 20)
666 </pre>
667 EOT
669 [ -s $broken ] && cat <<EOT
670 $(more_button broken "All broken packages" $broken 20)
671 <h2 id="broken">Broken</h2>
672 <pre>
673 $(cat $broken | head -n 20 | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
674 </pre>
675 EOT
677 [ -s $blocked ] && cat <<EOT
678 <h2 id="blocked">Blocked</h2>
679 <pre>
680 $(cat $blocked | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
681 </pre>
682 EOT
684 cat <<EOT
685 <h2 id="lastcook">Latest cook</h2>
686 <pre>
687 $(list_packages | sed s"#^\([^']*\).* : #<span class='log-date'>\0</span>#"g)
688 </pre>
689 EOT
690 ;;
691 esac
694 # Close xHTML page
696 cat <<EOT
697 </div>
699 <div id="footer">
700 <a href="http://www.slitaz.org/">SliTaz Website</a>
701 <a href="cooker.cgi">Cooker</a>
702 <a href="doc/cookutils/cookutils.en.html">Documentation</a>
703 </div>
705 </body>
706 </html>
707 EOT
709 exit 0