cookutils annotate web/cooker.cgi @ rev 909

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