cookutils annotate web/cooker.cgi @ rev 848

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