cookutils annotate web/cooker.cgi @ rev 825

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