cookutils diff 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
line diff
     1.1 --- a/web/cooker.cgi	Fri Mar 24 17:29:16 2017 +0200
     1.2 +++ b/web/cooker.cgi	Tue May 30 05:33:45 2017 +0300
     1.3 @@ -23,222 +23,60 @@
     1.4  cooktime="$CACHE/cooktime"
     1.5  wokrev="$CACHE/wokrev"
     1.6  
     1.7 -# Path to markdown to html convertor
     1.8 -if [ -n "$(which cmark 2>/dev/null)" ]; then
     1.9 -	md2html="$(which cmark) --smart -e table -e strikethrough -e autolink -e tagfilter"
    1.10 -elif [ -x "./cmark" ]; then
    1.11 -	md2html="./cmark --smart -e table -e strikethrough -e autolink -e tagfilter"
    1.12 -elif [ -n "$(which sundown 2>/dev/null)" ]; then
    1.13 -	md2html=$(which sundown)
    1.14 -elif [ -x "./sundown" ]; then
    1.15 -	md2html="./sundown"
    1.16 -fi
    1.17 -
    1.18  # We're not logged and want time zone to display correct server date.
    1.19  export TZ=$(cat /etc/TZ)
    1.20  
    1.21 +case "$QUERY_STRING" in
    1.22 +recook=*)
    1.23 +	case "$HTTP_USER_AGENT" in
    1.24 +	*SliTaz*)
    1.25 +		grep -qs "^${QUERY_STRING#recook=}$" $CACHE/recook-packages ||
    1.26 +		echo ${QUERY_STRING#recook=} >> $CACHE/recook-packages
    1.27 +	esac
    1.28 +	cat <<EOT
    1.29 +Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}
    1.30  
    1.31 -# HTML page header. Pages can be customized with a separated header.html file
    1.32 +EOT
    1.33 +	exit ;;
    1.34 +poke)
    1.35 +	touch $CACHE/cooker-request
    1.36 +	cat <<EOT
    1.37 +Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}
    1.38  
    1.39 -page_header() {
    1.40 -	echo -e 'Content-Type: text/html; charset=UTF-8\n'
    1.41 -	if [ -f "header.html" ]; then
    1.42 -		cat header.html
    1.43 -	else
    1.44 -		cat <<EOT
    1.45 -<!DOCTYPE html>
    1.46 -<html lang="en">
    1.47 -<head>
    1.48 -	<meta charset="UTF-8">
    1.49 -	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    1.50 -	<title>SliTaz Cooker</title>
    1.51 -	<link rel="shortcut icon" href="favicon.ico">
    1.52 -	<link rel="stylesheet" href="style.css">
    1.53 -	<script src="prism.js"></script>
    1.54 -	<link rel="stylesheet" href="prism.css">
    1.55 -	<link rel="alternate" type="application/rss+xml" title="Cooker Feed" href="?rss">
    1.56 -	<meta name="robots" content="nofollow">
    1.57 -</head>
    1.58 -<body>
    1.59 +EOT
    1.60 +	exit ;;
    1.61 +src*)
    1.62 +	file=$(busybox httpd -d "$SRC/${QUERY_STRING#*=}")
    1.63 +	cat <<EOT
    1.64 +Content-Type: application/octet-stream
    1.65 +Content-Length: $(stat -c %s "$file")
    1.66 +Content-Disposition: attachment; filename="$(basename "$file")"
    1.67  
    1.68 -<div id="header">
    1.69 -	<div id="logo"></div>
    1.70 -	<h1><a href="cooker.cgi">SliTaz Cooker</a></h1>
    1.71 -</div>
    1.72  EOT
    1.73 -	fi
    1.74 -}
    1.75 +	cat "$file"
    1.76 +	exit ;;
    1.77 +download*)
    1.78 +	file=$(busybox httpd -d "$PKGS/${QUERY_STRING#*=}")
    1.79 +	cat <<EOT
    1.80 +Content-Type: application/octet-stream
    1.81 +Content-Length: $(stat -c %s "$file")
    1.82 +Content-Disposition: attachment; filename="$(basename "$file")"
    1.83  
    1.84 +EOT
    1.85 +	cat "$file"
    1.86 +	exit ;;
    1.87 +rss)
    1.88 +	cat <<EOT
    1.89 +Content-Type: application/rss+xml
    1.90  
    1.91 -# HTML page footer. Pages can be customized with a separated footer.html file
    1.92 +EOT
    1.93 +	;;
    1.94 +*)
    1.95 +	cat <<EOT
    1.96 +Content-Type: text/html; charset=utf-8
    1.97  
    1.98 -page_footer() {
    1.99 -	if [ -f "footer.html" ]; then
   1.100 -		cat footer.html
   1.101 -	else
   1.102 -		cat <<EOT
   1.103 -</div>
   1.104 -
   1.105 -<div id="footer">
   1.106 -	<a href="http://www.slitaz.org/">SliTaz Website</a>
   1.107 -	<a href="cooker.cgi">Cooker</a>
   1.108 -	<a href="doc/cookutils/cookutils.html">Documentation</a>
   1.109 -</div>
   1.110 -
   1.111 -</body>
   1.112 -</html>
   1.113  EOT
   1.114 -	fi
   1.115 -}
   1.116 -
   1.117 -
   1.118 -not_found() {
   1.119 -	local file="${1#$PKGS/}"; file="${file#$LOGS/}"; file="${file#$WOK/}"
   1.120 -	echo "HTTP/1.1 404 Not Found"
   1.121 -	page_header
   1.122 -	echo "<div id='content'><h2>Not Found</h2>"
   1.123 -	case $2 in
   1.124 -		pkg)
   1.125 -			echo "<p>The requested package <b>$(basename "$(dirname "$file")")</b> was not found on this server.</p>" ;;
   1.126 -		*)
   1.127 -			echo "<p>The requested file <b>$file</b> was not found on this server.</p>" ;;
   1.128 -	esac
   1.129 -	page_footer
   1.130 -}
   1.131 -
   1.132 -
   1.133 -manage_modified() {
   1.134 -	local file="$1" option="$2" nul day mon year time hh mm ss date_s
   1.135 -	if [ ! -f "$file" ]; then
   1.136 -		if [ "$option" == 'silently-absent' ]; then
   1.137 -			echo "HTTP/1.1 404 Not Found"
   1.138 -			return
   1.139 -		else
   1.140 -			not_found "$file" "$2"
   1.141 -			exit
   1.142 -		fi
   1.143 -	fi
   1.144 -	[ "$option" == 'no-last-modified' ] && return
   1.145 -	if [ -n "$HTTP_IF_MODIFIED_SINCE" ]; then
   1.146 -		echo "$HTTP_IF_MODIFIED_SINCE" | \
   1.147 -		while read nul day mon year time nul; do
   1.148 -			case $mon in
   1.149 -				Jan) mon='01';; Feb) mon='02';; Mar) mon='03';; Apr) mon='04';;
   1.150 -				May) mon='05';; Jun) mon='06';; Jul) mon='07';; Aug) mon='08';;
   1.151 -				Sep) mon='09';; Oct) mon='10';; Nov) mon='11';; Dec) mon='12';;
   1.152 -			esac
   1.153 -			hh=$(echo $time | cut -d: -f1)
   1.154 -			mm=$(echo $time | cut -d: -f2)
   1.155 -			ss=$(echo $time | cut -d: -f3)
   1.156 -			date_s=$(date -ud "$year$mon$day$hh$mm.$ss" +%s)
   1.157 -#			if [ "$date_s" -ge "$(date -ur "$file" +%s)" ]; then
   1.158 -#				echo -e 'HTTP/1.1 304 Not Modified\n'
   1.159 -#				exit
   1.160 -#			fi
   1.161 -# TODO: improve caching control
   1.162 -		done
   1.163 -	fi
   1.164 -	echo "Last-Modified: $(date -Rur "$file" | sed 's|UTC|GMT|')"
   1.165 -	echo "Cache-Control: public, max-age=3600"
   1.166 -}
   1.167 -
   1.168 -
   1.169 -case "$QUERY_STRING" in
   1.170 -	recook=*)
   1.171 -		case "$HTTP_USER_AGENT" in
   1.172 -			*SliTaz*)
   1.173 -				grep -qs "^$(GET recook)$" $CACHE/recook-packages ||
   1.174 -				echo "$(GET recook)" >> $CACHE/recook-packages
   1.175 -		esac
   1.176 -		echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
   1.177 -		exit
   1.178 -		;;
   1.179 -
   1.180 -	poke)
   1.181 -		touch $CACHE/cooker-request
   1.182 -		echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
   1.183 -		exit
   1.184 -		;;
   1.185 -
   1.186 -	src*)
   1.187 -		file=$(busybox httpd -d "$SRC/$(GET src)")
   1.188 -		manage_modified "$file"
   1.189 -		content_type='application/octet-stream'
   1.190 -		case $file in
   1.191 -			*.tar.gz)   content_type='application/x-compressed-tar' ;;
   1.192 -			*.tar.bz2)  content_type='application/x-bzip-compressed-tar' ;;
   1.193 -			*.tar.xz)   content_type='application/x-xz-compressed-tar' ;;
   1.194 -			*.tar.lzma) content_type='application/x-lzma-compressed-tar' ;;
   1.195 -			*.zip)      content_type='application/zip' ;;
   1.196 -		esac
   1.197 -		echo "Content-Type: $content_type"
   1.198 -		echo "Content-Length: $(stat -c %s "$file")"
   1.199 -		filename=$(basename "$file")
   1.200 -		echo "Content-Disposition: attachment; filename=\"$filename\"" # Note, no conversion '+' -> '%2B' here
   1.201 -		echo
   1.202 -
   1.203 -		cat "$file"
   1.204 -		exit
   1.205 -		;;
   1.206 -
   1.207 -	download*)
   1.208 -		file="$PKGS/$(GET download)"
   1.209 -		manage_modified "$file"
   1.210 -		content_type='application/octet-stream'
   1.211 -		case $file in
   1.212 -			*.txt|*.conf|*/README|*/receipt)
   1.213 -			              content_type='text/plain; charset=UTF-8' ;;
   1.214 -			*.css)        content_type='text/css; charset=UTF-8' ;;
   1.215 -			*.htm|*.html) content_type='text/html; charset=UTF-8' ;;
   1.216 -			*.js)         content_type='application/javascript; charset=UTF-8' ;;
   1.217 -			*.desktop)    content_type='application/x-desktop; charset=UTF-8' ;;
   1.218 -			*.png)        content_type='image/png' ;;
   1.219 -			*.gif)        content_type='image/gif' ;;
   1.220 -			*.svg)        content_type='image/svg+xml' ;;
   1.221 -			*.jpg|*.jpeg) content_type='image/jpeg' ;;
   1.222 -			*.sh|*.cgi)   content_type='application/x-shellscript' ;;
   1.223 -			*.gz)         content_type='application/gzip' ;;
   1.224 -			*.ico)        content_type='image/vnd.microsoft.icon' ;;
   1.225 -			*.tazpkg)     content_type='application/x-tazpkg' ;;
   1.226 -		esac
   1.227 -
   1.228 -		echo "Content-Type: $content_type"
   1.229 -		echo "Content-Length: $(stat -c %s "$file")"
   1.230 -		filename=$(basename "$file")
   1.231 -		echo "Content-Disposition: inline; filename=\"$filename\"" # Note, no conversion '+' -> '%2B' here
   1.232 -		echo
   1.233 -
   1.234 -		cat "$file"
   1.235 -		exit
   1.236 -		;;
   1.237 -
   1.238 -	rss)
   1.239 -		echo -e 'Content-Type: application/rss+xml\n'
   1.240 -		;;
   1.241 -
   1.242 -	stuff*)
   1.243 -		file="$wok/$(GET stuff)"
   1.244 -		manage_modified "$file"
   1.245 -		;;
   1.246 -
   1.247 -	pkg=*|receipt=*|description=*|files=*|log=*|man=*|doc=*|info=*)
   1.248 -		type=${QUERY_STRING%%=*}
   1.249 -		pkg=$(GET $type)
   1.250 -		case "$type" in
   1.251 -			description)
   1.252 -				manage_modified "$wok/$pkg/receipt" 'no-last-modified'
   1.253 -				manage_modified "$wok/$pkg/description.txt" 'silently-absent'
   1.254 -				;;
   1.255 -			log)
   1.256 -				manage_modified "$wok/${pkg%%.log*}/receipt" 'no-last-modified'
   1.257 -				manage_modified "$LOGS/$pkg"
   1.258 -				;;
   1.259 -			*)
   1.260 -				manage_modified "$wok/$pkg/receipt" pkg
   1.261 -				;;
   1.262 -		esac
   1.263 -		;;
   1.264 -
   1.265 +	;;
   1.266  esac
   1.267  
   1.268  
   1.269 @@ -288,21 +126,20 @@
   1.270  
   1.271  info2html() {
   1.272  	sed \
   1.273 -		-e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g' \
   1.274 +		-e 's|&|\&amp;|g' -e 's|<|\&lt;|g' \
   1.275  		-e 's|^\* \(.*\)::|* <a href="#\1">\1</a>  |' \
   1.276  		-e 's|\*note \(.*\)::|<a href="#\1">\1</a>|' \
   1.277 -		-e '/^File: / s|(dir)|Top|g' \
   1.278 -		-e '/^File: / s|Next: \([^,]*\)|<a class="button" href="#\1">Next: \1</a>|' \
   1.279 -		-e '/^File: / s|Prev: \([^,]*\)|<a class="button" href="#\1">Prev: \1</a>|' \
   1.280 -		-e '/^File: / s|Up: \([^,]*\)|<a class="button" href="#\1">Up: \1</a>|' \
   1.281 -		-e '/^File: / s|^.* Node: \([^,]*\), *\(.*\)$|<pre id="\1">\2|' \
   1.282 -		-e '/^<pre id=/ s|^\([^>]*>\)\(<a[^>]*>Next: [^,]*\), *\(<a[^>]*>Prev: [^,]*\), *\(<a[^>]*>Up: .*\)|\1 \3 \4 \2|' \
   1.283 +		-e '/^File: /s|(dir)|Top|g' \
   1.284 +		-e '/^File: /s|Node: \([^,]*\)|Node: <a name="\1"></a><u>\1</u>|' \
   1.285 +		-e '/^File: /s|Next: \([^,]*\)|Next: <a href="#\1">\1</a>|' \
   1.286 +		-e '/^File: /s|Prev: \([^,]*\)|Prev: <a href="#\1">\1</a>|' \
   1.287 +		-e '/^File: /s|Up: \([^,]*\)|Up: <a href="#\1">\1</a>|' \
   1.288 +		-e '/^File: /s|^.*$|<i>&</i>|' \
   1.289  		-e '/^Tag Table:$/,/^End Tag Table$/d' \
   1.290  		-e '/INFO-DIR/,/^END-INFO-DIR/d' \
   1.291 -		-e "s|https*://[^>),'\"\`’ ]*|<a href=\"&\">&</a>|g" \
   1.292 +		-e "s|https*://[^>),'\"\` ]*|<a href=\"&\">&</a>|g" \
   1.293  		-e "s|ftp://[^>),\"\` ]*|<a href=\"&\">&</a>|g" \
   1.294 -		-e 's|^\* Menu:|<b>Menu:</b>|' \
   1.295 -		-e "s|^|</pre>|"
   1.296 +		-e "s|^|</pre><pre>|"
   1.297  }
   1.298  
   1.299  
   1.300 @@ -364,43 +201,34 @@
   1.301  					s|\[93m|<span style='color: #FF0'>|;
   1.302  					s|\[94m|<span style='color: #00F'>|;
   1.303  					s|\[95m|<span style='color: #808'>|;
   1.304 -					s|\[96m|<span style='color: #088'>|;
   1.305 +					s|\[96m|<span style='color: #0CC'>|;
   1.306  					s|\[39m|</span>|;"
   1.307 -			;;
   1.308 +				;;
   1.309  
   1.310 -		files)
   1.311 -			sed \
   1.312 -				-e "s|\[[01];31m|<span style='color: #F00'>|g;
   1.313 -					s|\[[01];32m|<span style='color: #080'>|g;
   1.314 -					s|\[[01];33m|<span style='color: #FF0'>|g;
   1.315 -					s|\[[01];34m|<span style='color: #00F'>|g;
   1.316 -					s|\[[01];35m|<span style='color: #808'>|g;
   1.317 -					s|\[[01];36m|<span style='color: #088'>|g;
   1.318 -					s|\[[01];0m|<span style='color: #333'>|g;
   1.319 -					s|\[0m|</span>|g;"
   1.320 -			;;
   1.321 +		receipt)
   1.322 +			sed	-e s'|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|'g \
   1.323 +				-e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g \
   1.324 +				-e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g ;;
   1.325 +
   1.326 +		diff)
   1.327 +			sed -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g' \
   1.328 +				-e s"#^-\([^']*\).#<span class='span-red'>\0</span>#"g \
   1.329 +				-e s"#^+\([^']*\).#<span class='span-ok'>\0</span>#"g \
   1.330 +				-e s"#@@\([^']*\)@@#<span class='span-sky'>@@\1@@</span>#"g ;;
   1.331  
   1.332  		activity)
   1.333 -			sed s"#^\([^']* : \)#<span class='log-date'>\0</span>#"g
   1.334 -			;;
   1.335 +			sed s"#^\([^']* : \)#<span class='log-date'>\0</span>#"g ;;
   1.336  	esac
   1.337  }
   1.338  
   1.339  
   1.340 -show_code() {
   1.341 -	echo "<pre><code class=\"language-$1\">"
   1.342 -	sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g'
   1.343 -	echo '</code></pre>'
   1.344 -}
   1.345 -
   1.346 -
   1.347  # Latest build pkgs.
   1.348  
   1.349  list_packages() {
   1.350  	cd $PKGS
   1.351  	ls -1t *.tazpkg | head -n 20 | \
   1.352  	while read file; do
   1.353 -		echo -n $(TZ=UTC stat -c '%y' $PKGS/$file | cut -d. -f1 | sed s/:[0-9]*$//)
   1.354 +		echo -n $(TZ=UTC stat -c '%y' $PKGS/$file | cut -d . -f 1 | sed s/:[0-9]*$//)
   1.355  		echo " : $file"
   1.356  	done
   1.357  }
   1.358 @@ -409,19 +237,23 @@
   1.359  # Optional full list button
   1.360  
   1.361  more_button() {
   1.362 -	[ $(wc -l < ${3:-$CACHE/$1}) -gt ${4:-12} ] &&
   1.363 -	echo "<a class='button r' href='?file=$1'>$2</a>"
   1.364 +	[ $(wc -l < ${3:-$CACHE/$1}) -gt ${4:-12} ] && cat <<EOT
   1.365 +<div style="float: right;">
   1.366 +	<a class="button" href="?file=$1">$2</a>
   1.367 +</div>
   1.368 +EOT
   1.369  }
   1.370  
   1.371  
   1.372  # Show the running command and its progression
   1.373  
   1.374 -running_command() {
   1.375 +running_command()
   1.376 +{
   1.377  	local state="Not running"
   1.378  	if [ -s "$command" ]; then
   1.379  		state="$(cat $command)"
   1.380  		set -- $(grep "^$state" $cooktime)
   1.381 -		if [ -n "$1" ]; then
   1.382 +		if [ -n "$1" -a $2 -ne 0 ]; then
   1.383  			state="$state $((($(date +%s)-$3)*100/$2))%"
   1.384  			[ $2 -gt 300 ] && state="$state (should end $(date -u -d @$(($2+$3))))"
   1.385  		fi
   1.386 @@ -430,139 +262,43 @@
   1.387  }
   1.388  
   1.389  
   1.390 -datalist() {
   1.391 -	(
   1.392 -		cd $wok
   1.393 +# xHTML header. Pages can be customized with a separated html.header file.
   1.394  
   1.395 -		ls | awk '
   1.396 -		BEGIN{printf("<datalist id=\"packages\">")}
   1.397 -		     {printf("<option>%s</option>",$1)}
   1.398 -		END  {printf("</datalist>")}
   1.399 -		'
   1.400 -	)
   1.401 -}
   1.402 +if [ -f "header.html" ]; then
   1.403 +	cat header.html
   1.404 +else
   1.405 +	cat <<EOT
   1.406 +<!DOCTYPE html>
   1.407 +<html lang="en">
   1.408 +<head>
   1.409 +	<meta charset="UTF-8">
   1.410 +	<title>SliTaz Cooker</title>
   1.411 +	<link rel="shortcut icon" href="favicon.ico">
   1.412 +	<link rel="stylesheet" href="style.css">
   1.413 +	<meta name="robots" content="nofollow">
   1.414 +</head>
   1.415 +<body>
   1.416  
   1.417 +<div id="header">
   1.418 +	<div id="logo"></div>
   1.419 +	<h1><a href="cooker.cgi">SliTaz Cooker</a></h1>
   1.420 +</div>
   1.421  
   1.422 -summary() {
   1.423 -	log="$1"
   1.424 -	pkg="$(basename ${log%%.log*})"
   1.425 -	if [ -f "$log" ]; then
   1.426 -		if grep -q "cook:$pkg$" $command; then
   1.427 -			echo "<pre>The Cooker is currently building: $pkg</pre>"
   1.428 -		fi
   1.429 -		if fgrep -q "Summary for:" $log; then
   1.430 -			echo "<pre>"
   1.431 -			sed '/^Summary for:/,$!d' $log | sed /^$/d | syntax_highlighter log
   1.432 -			echo "</pre>"
   1.433 -		fi
   1.434 -
   1.435 -		if fgrep -q "Debug information" $log; then
   1.436 -			echo '<pre>'
   1.437 -			sed '/^Debug information/,$!d' $log | sed /^$/d | \
   1.438 -			if [ -n "$2" ]; then
   1.439 -				syntax_highlighter log | \
   1.440 -				sed 's|\([0-9][0-9]*\):|<a href="#l\1">\1</a>:|'
   1.441 -			else
   1.442 -				sed 's|^[0-9][0-9]*:||' | syntax_highlighter log
   1.443 -			fi
   1.444 -			echo '</pre>'
   1.445 -		fi
   1.446 -	else
   1.447 -		[ -n "$pkg" -a -d "$wok/$pkg" ] && echo "<pre>No log for $pkg</pre>"
   1.448 -	fi
   1.449 -}
   1.450 -
   1.451 -
   1.452 -pkg_info() {
   1.453 -	local log cmd active bpkg
   1.454 -	log=$LOGS/$pkg.log
   1.455 -	cmd=${QUERY_STRING%%=*}
   1.456 -	echo '<div id="info">'
   1.457 -	active=''; [ "$cmd" == 'receipt' -o "$cmd" == 'stuff' ] && active=' active'
   1.458 -	echo "<a class='button green$active' href='?receipt=${pkg//+/%2B}'>receipt &amp; stuff</a>"
   1.459 -
   1.460 -	unset WEB_SITE WANTED
   1.461 -	bpkg=$pkg
   1.462 -	. $wok/$pkg/receipt
   1.463 -
   1.464 -	[ -n "$WANTED" ] && bpkg="${WANTED%% *}" # see locale-* with multiple WANTED
   1.465 -
   1.466 -	[ -n "$WEB_SITE" ] &&
   1.467 -	echo "<a class='button sky' href='$WEB_SITE'>web site</a>"
   1.468 -
   1.469 -	if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then
   1.470 -		active=''; [ "$cmd" == 'files' ] && active=' active'
   1.471 -		echo "<a class='button khaki$active' href='?files=${pkg//+/%2B}'>files</a>"
   1.472 -
   1.473 -		unset EXTRAVERSION
   1.474 -		. $wok/$pkg/taz/$PACKAGE-$VERSION/receipt
   1.475 -
   1.476 -		if [ -f $wok/$pkg/taz/$PACKAGE-$VERSION/description.txt ]; then
   1.477 -			active=''; [ "$cmd" == 'description' ] && active=' active'
   1.478 -			echo "<a class='button brown$active' href='?description=${pkg//+/%2B}'>description</a>"
   1.479 -		fi
   1.480 -
   1.481 -		if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
   1.482 -			echo "<a class='button gold' href='?download=${PACKAGE//+/%2B}-${VERSION//+/%2B}${EXTRAVERSION//+/%2B}.tazpkg'>download</a>"
   1.483 -		fi
   1.484 -
   1.485 -		if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then
   1.486 -			echo "<a class='button gold' href='?download=${PACKAGE//+/%2B}-${VERSION//+/%2B}${EXTRAVERSION//+/%2B}-${ARCH//+/%2B}.tazpkg'>download</a>"
   1.487 -		fi
   1.488 -	fi
   1.489 -
   1.490 -	[ -n "$TARBALL" ] && [ -s "$SRC/$TARBALL" ] &&
   1.491 -	echo "<a class='button yellow' href='?src=${TARBALL//+/%2B}'>source</a>"
   1.492 -
   1.493 -	[ -x ./man2html ] &&
   1.494 -	if [ -d $wok/$bpkg/install/usr/man ] ||
   1.495 -	   [ -d $wok/$bpkg/install/usr/share/man ] ||
   1.496 -	   [ -d $wok/$bpkg/taz/*/fs/usr/man ] ||
   1.497 -	   [ -d $wok/$bpkg/taz/*/fs/usr/share/man ]; then
   1.498 -		active=''; [ "$cmd" == 'man' ] && active=' active'
   1.499 -		echo "<a class='button plum$active' href='?man=${bpkg//+/%2B}'>man</a>"
   1.500 -	fi
   1.501 -
   1.502 -	if [ -d $wok/$bpkg/install/usr/doc ] ||
   1.503 -	   [ -d $wok/$bpkg/install/usr/share/doc ] ||
   1.504 -	   [ -d $wok/$bpkg/taz/*/fs/usr/doc ] ||
   1.505 -	   [ -d $wok/$bpkg/taz/*/fs/usr/share/doc ]; then
   1.506 -		active=''; [ "$cmd" == 'doc' ] && active=' active'
   1.507 -		echo "<a class='button plum$active' href='?doc=${bpkg//+/%2B}'>doc</a>"
   1.508 -	fi
   1.509 -
   1.510 -	if [ -d $wok/$bpkg/install/usr/info ] ||
   1.511 -	   [ -d $wok/$bpkg/install/usr/share/info ] ||
   1.512 -	   [ -d $wok/$bpkg/taz/*/fs/usr/info ] ||
   1.513 -	   [ -d $wok/$bpkg/taz/*/fs/usr/share/info ]; then
   1.514 -		active=''; [ "$cmd" == 'info' ] && active=' active'
   1.515 -		echo "<a class='button plum$active' href='?info=${bpkg//+/%2B}#Top'>info</a>"
   1.516 -	fi
   1.517 -
   1.518 -	[ -n "$(echo $REQUEST_URI | sed 's|/[^/]*?pkg.*||')" ] ||
   1.519 -	echo "<a class='button' href='ftp://${HTTP_HOST%:*}/${pkg//+/%2B}/'>browse</a>"
   1.520 -
   1.521 -	if [ -s "$log" ]; then
   1.522 -		active=''; [ "$cmd" == 'log' ] && active=' active'
   1.523 -		echo "<a class='button gray$active' href='?log=${pkg//+/%2B}.log'>logs</a>"
   1.524 -	fi
   1.525 -
   1.526 -	echo '</div>'
   1.527 -}
   1.528 -
   1.529 -
   1.530 +<!-- Content -->
   1.531 +<div id="content">
   1.532 +EOT
   1.533 +fi
   1.534  
   1.535  
   1.536  #
   1.537  # Load requested page
   1.538  #
   1.539  
   1.540 -page_header
   1.541 -
   1.542  case "${QUERY_STRING}" in
   1.543  	pkg=*)
   1.544 -		pkg=$(GET pkg)
   1.545 +		pkg=${QUERY_STRING#pkg=}
   1.546  		log=$LOGS/$pkg.log
   1.547 +		echo "<h2>Package: $pkg</h2>"
   1.548  
   1.549  		# Define cook variables for syntax highlighter
   1.550  		if [ -s "$WOK/$pkg/receipt" ]; then
   1.551 @@ -575,18 +311,59 @@
   1.552  		fi
   1.553  
   1.554  		# Package info.
   1.555 +		echo '<div id="info">'
   1.556  		if [ -f "$wok/$pkg/receipt" ]; then
   1.557 -			echo "<div id='content'>"
   1.558 -			echo "<h2>Package: $pkg</h2>"
   1.559 -			pkg_info
   1.560 +			echo "<a href='?receipt=$pkg'>receipt</a>"
   1.561 +			unset WEB_SITE
   1.562 +			unset WANTED
   1.563 +			bpkg=$pkg
   1.564 +			. $wok/$pkg/receipt
   1.565 +
   1.566 +			[ -n "$WANTED" ] && bpkg="${WANTED%% *}" # see locale-* with multiple WANTED
   1.567 +			[ -n "$WEB_SITE" ] && # busybox wget -s $WEB_SITE &&
   1.568 +			echo "<a href='$WEB_SITE'>home</a>"
   1.569 +
   1.570 +			if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then
   1.571 +				echo "<a href='?files=$pkg'>files</a>"
   1.572 +				unset EXTRAVERSION
   1.573 +				. $wok/$pkg/taz/$PACKAGE-$VERSION/receipt
   1.574 +				if [ -f $wok/$pkg/taz/$PACKAGE-$VERSION/description.txt ]; then
   1.575 +					echo "<a href='?description=$pkg'>description</a>"
   1.576 +				fi
   1.577 +				if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
   1.578 +					echo "<a href='?download=$PACKAGE-$VERSION$EXTRAVERSION.tazpkg'>download</a>"
   1.579 +				fi
   1.580 +				if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then
   1.581 +					echo "<a href='?download=$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg'>download</a>"
   1.582 +				fi
   1.583 +			fi
   1.584 +			[ -x ./man2html ] &&
   1.585 +			if [ -d $wok/$bpkg/install/usr/man ] ||
   1.586 +			   [ -d $wok/$bpkg/install/usr/share/man ] ||
   1.587 +			   [ -d $wok/$bpkg/taz/*/fs/usr/man ] ||
   1.588 +			   [ -d $wok/$bpkg/taz/*/fs/usr/share/man ]; then
   1.589 +				echo "<a href='?man=$bpkg'>man</a>"
   1.590 +			fi
   1.591 +			if [ -d $wok/$bpkg/install/usr/doc ] ||
   1.592 +			   [ -d $wok/$bpkg/install/usr/share/doc ] ||
   1.593 +			   [ -d $wok/$bpkg/taz/*/fs/usr/doc ] ||
   1.594 +			   [ -d $wok/$bpkg/taz/*/fs/usr/share/doc ]; then
   1.595 +				echo "<a href='?doc=$bpkg'>doc</a>"
   1.596 +			fi
   1.597 +			if [ -d $wok/$bpkg/install/usr/info ] ||
   1.598 +			   [ -d $wok/$bpkg/install/usr/share/info ] ||
   1.599 +			   [ -d $wok/$bpkg/taz/*/fs/usr/info ] ||
   1.600 +			   [ -d $wok/$bpkg/taz/*/fs/usr/share/info ]; then
   1.601 +				echo "<a href='?info=$bpkg'>info</a>"
   1.602 +			fi
   1.603 +			[ -n "$(echo $REQUEST_URI | sed 's|/[^/]*?pkg.*||')" ] ||
   1.604 +			echo "<a href='ftp://${HTTP_HOST%:*}/$pkg/'>browse</a>"
   1.605  		else
   1.606  			if [ $(ls $wok/*$pkg*/receipt 2>/dev/null | wc -l) -eq 0 ]; then
   1.607 -				echo "<div id='content'><h2>Not Found</h2>"
   1.608 -				echo "<p>The requested package <b>$pkg</b> was not found on this server.</p>"
   1.609 +				echo "No package named: $pkg"
   1.610  			else
   1.611 -				echo "<div id='content'>"
   1.612  				ls $wok/$pkg/receipt >/dev/null 2>&1 || pkg="*$pkg*"
   1.613 -				echo '<table class="zebra" style="width:100%">'
   1.614 +				echo '<table style="width:100%">'
   1.615  				for i in $(cd $wok ; ls $pkg/receipt); do
   1.616  					pkg=$(dirname $i)
   1.617  					unset SHORT_DESC CATEGORY
   1.618 @@ -603,78 +380,88 @@
   1.619  				unset pkg
   1.620  			fi
   1.621  		fi
   1.622 +		echo '</div>'
   1.623  
   1.624  		# Check for a log file and display summary if it exists.
   1.625 -		summary "$log"
   1.626 +		if [ -f "$log" ]; then
   1.627 +			if grep -q "cook:$pkg$" $command; then
   1.628 +				echo "<pre>The Cooker is currently building: $pkg</pre>"
   1.629 +			fi
   1.630 +			if fgrep -q "Summary for:" $LOGS/$pkg.log; then
   1.631 +				echo '<h3>Cook summary</h3>'
   1.632 +				echo '<pre>'
   1.633 +				grep -A 12 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
   1.634 +					syntax_highlighter log
   1.635 +				echo '</pre>'
   1.636 +			fi
   1.637 +			if fgrep -q "Debug information" $LOGS/$pkg.log; then
   1.638 +				echo '<h3>Cook failed</h3>'
   1.639 +				echo '<pre>'
   1.640 +				grep -A 8 "^Debug information" $LOGS/$pkg.log | sed /^$/d | \
   1.641 +						syntax_highlighter log
   1.642 +				echo '</pre>'
   1.643 +			fi
   1.644 +			echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
   1.645 +			for i in $(ls -t $log.*); do
   1.646 +				echo -n "<a href=\"?log=$(basename $i)\">"
   1.647 +				echo "$(stat -c %y $i | sed 's/ .*//')</a>"
   1.648 +			done
   1.649 +			echo '<pre>'
   1.650 +			cat $log | syntax_highlighter log
   1.651 +			echo '</pre>'
   1.652 +			case "$HTTP_USER_AGENT" in
   1.653 +			*SliTaz*)
   1.654 +				[ -f $CACHE/cooker-request ] && [ -n "$HTTP_REFERER" ] &&
   1.655 +				echo "<a class=\"button\" href=\"?recook=$pkg\">Recook $pkg</a>"
   1.656 +			esac
   1.657 +		else
   1.658 +			[ "$pkg" ] && echo "<pre>No log: $pkg</pre>"
   1.659 +		fi ;;
   1.660  
   1.661 -		# Display <Recook> button only for SliTaz web browser
   1.662 -		if [ -f "$log" ]; then
   1.663 -			case "$HTTP_USER_AGENT" in
   1.664 -				*SliTaz*)
   1.665 -					[ -f $CACHE/cooker-request ] && [ -n "$HTTP_REFERER" ] &&
   1.666 -					echo "<a class=\"button\" href=\"?recook=$pkg\">Recook $pkg</a>"
   1.667 -					;;
   1.668 -			esac
   1.669 +	log=*)
   1.670 +		log=$LOGS/${QUERY_STRING#log=}
   1.671 +		if [ -s $log ]; then
   1.672 +			echo "<h3>Cook log $(stat -c %y $log | sed 's/:..\..*//')</h3>"
   1.673 +			if fgrep -q "Summary" $log; then
   1.674 +				echo '<pre>'
   1.675 +				grep -A 20 "^Summary" $log | sed /^$/d | \
   1.676 +					syntax_highlighter log
   1.677 +				echo '</pre>'
   1.678 +			fi
   1.679 +			echo '<pre>'
   1.680 +			cat $log | syntax_highlighter log
   1.681 +			echo '</pre>'
   1.682  		fi
   1.683  		;;
   1.684 -
   1.685 -	log=*)
   1.686 -		log=$(GET log)
   1.687 -		logfile=$LOGS/$log
   1.688 -		pkg=${log%.log*}
   1.689 -		if [ -s "$logfile" ]; then
   1.690 -			echo "<div id='content'>"
   1.691 -
   1.692 -			echo "<h2>Cook log $(stat -c %y $logfile | sed 's/:..\..*//')</h2>"
   1.693 -			pkg_info
   1.694 -
   1.695 -			case $log in
   1.696 -				*.log) baselog=$logfile ;;
   1.697 -				*)     baselog=${logfile%.*} ;;
   1.698 -			esac
   1.699 -			for i in $(ls -t $baselog $baselog.* 2>/dev/null); do
   1.700 -				class=''; [ $i == $logfile ] && class=' gray'
   1.701 -				j=$(basename "$i")
   1.702 -				echo -n "<a class='button$class' href=\"?log=${j//+/%2B}\">"
   1.703 -				echo "$(stat -c %y $i | cut -d: -f1,2)</a>"
   1.704 -			done
   1.705 -
   1.706 -			summary "$logfile" links
   1.707 -
   1.708 -			cat $logfile | syntax_highlighter log | awk '
   1.709 -			BEGIN { print "<pre class=\"log\">"; }
   1.710 -			      { printf("<a name=\"l%d\" href=\"#l%d\">%5d</a>  %s\n", NR, NR, NR, $0); }
   1.711 -			END   { print "</pre>"; }
   1.712 -			'
   1.713 -		fi
   1.714 -		;;
   1.715 -
   1.716  	file=*)
   1.717 -		echo "<div id='content'>"
   1.718  		# Don't allow all files on the system for security reasons.
   1.719 -		file=$(GET file)
   1.720 +		file=${QUERY_STRING#file=}
   1.721  		case "$file" in
   1.722  			activity|cooknotes|cooklist)
   1.723  				[ "$file" == "cooklist" ] && \
   1.724  					nb="- Packages: $(cat $cooklist | wc -l)"
   1.725 -				echo '<div id="content2">'
   1.726  				echo "<h2>DB: $file $nb</h2>"
   1.727 -				echo '<ul class="activity">'
   1.728 -				tac $CACHE/$file | syntax_highlighter activity | \
   1.729 -				sed 's|^|<li>|; s|$|</li>|'
   1.730 -				echo '</ul></div>'
   1.731 -				;;
   1.732 +				echo '<pre>'
   1.733 +				tac $CACHE/$file | syntax_highlighter activity
   1.734 +				echo '</pre>' ;;
   1.735  
   1.736  			broken)
   1.737 -				nb=$(wc -l < $broken)
   1.738 -				echo '<div id="content2">'
   1.739 +				nb=$(cat $broken | wc -l)
   1.740  				echo "<h2>DB: broken - Packages: $nb</h2>"
   1.741 -				echo '<ul class="activity">'
   1.742 +				echo '<pre>'
   1.743  				cat $CACHE/$file | sort | \
   1.744 -					sed "s#^[^']*#<a href='?pkg=\0'>\0</a>#g" | \
   1.745 -					sed 's|^|<li>|; s|$|</li>|'
   1.746 -				echo '</ul></div>'
   1.747 -				;;
   1.748 +					sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g
   1.749 +				echo '</pre>' ;;
   1.750 +
   1.751 +			*.diff)
   1.752 +				diff=$CACHE/$file
   1.753 +				echo "<h2>Diff for: ${file%.diff}</h2>"
   1.754 +				[ "$file" == "installed.diff" ] && echo \
   1.755 +					"<p>This is the latest diff between installed packages \
   1.756 +					and installed build dependencies to cook.</p>"
   1.757 +				echo '<pre>'
   1.758 +				cat $diff | syntax_highlighter diff
   1.759 +				echo '</pre>' ;;
   1.760  
   1.761  			*.log)
   1.762  				log=$LOGS/$file
   1.763 @@ -692,143 +479,63 @@
   1.764  					echo '</pre>'
   1.765  				else
   1.766  					echo "<pre>No log file: $log</pre>"
   1.767 -				fi
   1.768 -				;;
   1.769 -		esac
   1.770 -		;;
   1.771 +				fi ;;
   1.772 +		esac ;;
   1.773  
   1.774  	stuff=*)
   1.775 -		echo "<div id='content'>"
   1.776 -		file=$(GET stuff)
   1.777 -		pkg=${file%%/*}
   1.778 -		if [ -f "$wok/$file" ]; then
   1.779 -			echo "<h2>$file</h2>"
   1.780 -			pkg_info
   1.781 -			echo "<a class='button' href='?receipt=${pkg//+/%2B}'>receipt</a>"
   1.782 -
   1.783 -			( cd $wok/$pkg ; find stuff -type f 2> /dev/null ) | sort | \
   1.784 -			while read i ; do
   1.785 -				class=''; [ "$pkg/$i" == "$file" ] && class=" green"
   1.786 -				echo "<a class='button$class' href='?stuff=${pkg//+/%2B}/${i//+/%2B}'>$i</a>"
   1.787 -			done
   1.788 -
   1.789 -			case $file in
   1.790 -				*.desktop|*.theme)   class="ini" ;;
   1.791 -				*.patch|*.diff|*.u)  class="diff" ;;
   1.792 -				*.sh)                class="bash" ;;
   1.793 -				*.conf*)
   1.794 -					class="bash"
   1.795 -					[ -n "$(cut -c1 < $wok/$file | fgrep '[')" ] && class="ini"
   1.796 -					;;
   1.797 -				*.pl)           class="perl" ;;
   1.798 -				*.c|*.h|*.awk)  class="clike" ;;
   1.799 -				*.svg)          class="svg" ;;
   1.800 -				*Makefile*)     class="makefile" ;;
   1.801 -				*.po|*.pot)     class="bash" ;;
   1.802 -				*.css)          class="css" ;;
   1.803 -				*.htm|*.html)   class="html" ;;
   1.804 -				*.js)           class="js" ;;
   1.805 -				*.txt)          class="asciidoc" ;;
   1.806 -				*)
   1.807 -					case $(head -n1 $wok/$file) in
   1.808 -						*!/bin/sh*|*!/bin/bash*) class="bash" ;;
   1.809 -					esac
   1.810 -					if [ -z "$class" -a "$(head -n1 $wok/$file | cut -b1)" == '#' ]; then
   1.811 -						class="bash"
   1.812 -					fi
   1.813 -					if [ -z "$class" ]; then
   1.814 -						# Follow Busybox restrictions. Search for non-printable chars
   1.815 -						if [ $(tr -d '[:alnum:][:punct:][:blank:][:cntrl:]' < "$wok/$file" | wc -c) -gt 0 ]; then
   1.816 -							raw="true"
   1.817 -						fi
   1.818 -					fi
   1.819 -					;;
   1.820 -			esac
   1.821 -
   1.822 -			# Display image
   1.823 -			case $file in
   1.824 -				*.png|*.svg|*.jpg|*.jpeg|*.ico)
   1.825 -					echo "<img src='?download=../wok/${file//+/%2B}' style='display: block; max-width: 100%; margin: auto'/>"
   1.826 -					;;
   1.827 -			esac
   1.828 -
   1.829 -			# Display colored listing for all text-based documents (also for *.svg)
   1.830 -			case $file in
   1.831 -				*.png|*.jpg|*.jpeg|*.ico) ;;
   1.832 -				*)
   1.833 -					if [ -z "$raw" ]; then
   1.834 -						cat $wok/$file | show_code $class
   1.835 -					fi
   1.836 -					;;
   1.837 -			esac
   1.838 -
   1.839 -			# Display hex dump for binary files
   1.840 -			if [ -n "$raw" ]; then
   1.841 -				hexdump -C $wok/$file | show_code $class
   1.842 -			fi
   1.843 -		else
   1.844 -			echo "<pre>File '$file' absent!</pre>"
   1.845 -		fi
   1.846 -		;;
   1.847 +		file=${QUERY_STRING#stuff=}
   1.848 +		echo "<h2>$file</h2>"
   1.849 +		echo '<pre>'
   1.850 +		cat $wok/$file | sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
   1.851 +		echo '</pre>' ;;
   1.852  
   1.853  	receipt=*)
   1.854 -		echo "<div id='content'>"
   1.855 -		pkg=$(GET receipt)
   1.856 +		pkg=${QUERY_STRING#receipt=}
   1.857  		echo "<h2>Receipt for: $pkg</h2>"
   1.858 -		pkg_info
   1.859 -		echo "<a class='button green' href='?receipt=${pkg//+/%2B}'>receipt</a>"
   1.860 -		. $wok/$pkg/receipt
   1.861 +		if [ -f "$wok/$pkg/receipt" ]; then
   1.862 +			. $wok/$pkg/receipt
   1.863 +			[ -n "$TARBALL" ] && [ -s "$SRC/$TARBALL" ] &&
   1.864 +			echo "<a href='?src=$TARBALL'>source</a>"
   1.865  
   1.866 -		( cd $wok/$pkg; find stuff -type f 2> /dev/null ) | sort | \
   1.867 -		while read file; do
   1.868 -			echo "<a class='button' href='?stuff=${pkg//+/%2B}/${file//+/%2B}'>$file</a>"
   1.869 -		done | sort
   1.870 -		cat $wok/$pkg/receipt | show_code bash
   1.871 -		;;
   1.872 +			( cd $wok/$pkg ; find stuff -type f 2> /dev/null ) | \
   1.873 +			while read file ; do
   1.874 +				echo "<a href=\"?stuff=$pkg/$file\">$file</a>"
   1.875 +			done | sort
   1.876 +			echo '<pre>'
   1.877 +			cat $wok/$pkg/receipt | \
   1.878 +				syntax_highlighter receipt
   1.879 +			echo '</pre>'
   1.880 +		else
   1.881 +			echo "<pre>No receipt for: $pkg</pre>"
   1.882 +		fi ;;
   1.883  
   1.884  	files=*)
   1.885 -		echo "<div id='content'>"
   1.886 -		pkg=$(GET files)
   1.887 -		dir=$(ls -d $WOK/$pkg/taz/$pkg-* 2>/dev/null)
   1.888 -		size=$(du -hs $dir/fs | awk '{ print $1 }')
   1.889 -		echo "<h2>Files installed by the package \"$pkg\" ($size)</h2>"
   1.890 -		pkg_info
   1.891 -
   1.892 -		echo '<pre class="files">'
   1.893 -
   1.894 -		find $dir/fs -not -type d -print0 | sort -z | \
   1.895 -		xargs -0 ls -ld --color=always | \
   1.896 -		syntax_highlighter files | \
   1.897 -		sed "s|\([^/]*\)/.*\(${dir#*wok}/fs\)\([^<]*\)\(<.*\)$|\1<a href=\"?download=../wok\2\3\">\3</a>\4|" |\
   1.898 -		awk '
   1.899 -			BEGIN { FS="\""; }
   1.900 -			{ gsub("+", "%2B", $2); print; }
   1.901 -			'
   1.902 -
   1.903 -		echo '</pre>'
   1.904 -		;;
   1.905 +		pkg=${QUERY_STRING#files=}
   1.906 +		dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
   1.907 +		if [ -d "$dir/fs" ]; then
   1.908 +			echo "<h2>Installed files by: $pkg ($(du -hs $dir/fs | awk '{ print $1 }'))</h2>"
   1.909 +			echo '<pre>'
   1.910 +			find $dir/fs -not -type d -print0 | xargs -0 ls -ld | \
   1.911 +				sed "s|\(.*\) /.*\(${dir#*wok}/fs\)\(.*\)|\1 <a href=\"?download=../wok\2\3\">\3</a>|;s|^\([^-].*\)\(<a.*\)\">\(.*\)</a>|\1\3|"
   1.912 +			echo '</pre>'
   1.913 +		else
   1.914 +			echo "<pre>No files list for: $pkg</pre>"
   1.915 +		fi ;;
   1.916  
   1.917  	description=*)
   1.918 -		echo "<div id='content'>"
   1.919 -		pkg=$(GET description)
   1.920 -		dir=$(ls -d $WOK/$pkg/taz/$pkg-* 2>/dev/null)
   1.921 +		pkg=${QUERY_STRING#description=}
   1.922  		echo "<h2>Description of $pkg</h2>"
   1.923 -		pkg_info
   1.924 +		dir=$(ls -d $WOK/$pkg/taz/$pkg-*)
   1.925  		if [ -s "$dir/description.txt" ]; then
   1.926 -			if [ -n "$md2html" ]; then
   1.927 -				echo '<div id="content2">'
   1.928 -				$md2html $dir/description.txt
   1.929 -				echo '</div>'
   1.930 -			else
   1.931 -				cat $dir/description.txt | show_code markdown
   1.932 -			fi
   1.933 +			echo '<pre>'
   1.934 +			cat $dir/description.txt | \
   1.935 +				sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
   1.936 +			echo '</pre>'
   1.937  		else
   1.938 -			echo "<pre>No description of $pkg</pre>"
   1.939 -		fi
   1.940 -		;;
   1.941 +			echo "<pre>No description for: $pkg</pre>"
   1.942 +		fi ;;
   1.943  
   1.944  	man=*|doc=*|info=*)
   1.945 -		echo '<div id="content">'
   1.946  		type=${QUERY_STRING%%=*}
   1.947  		pkg=$(GET $type)
   1.948  		dir=$WOK/$pkg/install/usr/share/$type
   1.949 @@ -840,93 +547,37 @@
   1.950  			page=$(find $dir -type f | sed q)
   1.951  			page=${page#$dir/}
   1.952  		fi
   1.953 -
   1.954 +		find $dir -type f | while read file ; do
   1.955 +			[ -s $file ] || continue
   1.956 +			case "$file" in
   1.957 +			*.jp*g|*.png|*.gif|*.svg) continue
   1.958 +			esac
   1.959 +			file=${file#$dir/}
   1.960 +			echo "<a href='?$type=$pkg&amp;file=$file'>$(basename $file)</a>"
   1.961 +		done | sort -t \> -k 2
   1.962  		echo "<h2>$(basename $page)</h2>"
   1.963 -
   1.964 -		pkg_info
   1.965 -		echo '<div style="max-height: 5em; overflow: auto">'
   1.966 -		find $dir -type f | sort | while read i ; do
   1.967 -			[ -s $i ] || continue
   1.968 -			case "$i" in
   1.969 -				*.jp*g|*.png|*.gif|*.svg|*.css) continue
   1.970 -			esac
   1.971 -			i=${i#$dir/}
   1.972 -			class=''; [ "$page" == "$i" ] && class=" plum"
   1.973 -			case "$type" in
   1.974 -				man)
   1.975 -					man=$(basename $i .gz)
   1.976 -					echo "<a class='button$class' href='?$type=$pkg&amp;file=$i'>${man%.*} (${man##*.})</a>"
   1.977 -					;;
   1.978 -				info)
   1.979 -					info=$(basename $i)
   1.980 -					echo "<a class='button$class' href='?$type=$pkg&amp;file=$i#Top'>${info/.info/}</a>"
   1.981 -					;;
   1.982 -				*)
   1.983 -					echo "<a class='button$class' href='?$type=$pkg&amp;file=$i'>$(basename $i .gz)</a>"
   1.984 -					;;
   1.985 -			esac
   1.986 -		done
   1.987 -		echo '</div>'
   1.988 -
   1.989 -		if [ -f "$dir/$page" ]; then
   1.990 -			tmp="$(mktemp)"
   1.991 -			docat "$dir/$page" > $tmp
   1.992 -			[ -s "$tmp" ] &&
   1.993 -			case "$type" in
   1.994 -				info)
   1.995 -					echo '<div id="content2" class="texinfo"><pre class="first">'
   1.996 -					info2html < "$tmp"
   1.997 -					echo '</pre></div>'
   1.998 -					;;
   1.999 -				doc)
  1.1000 -					case "$page" in
  1.1001 -						*.sgml) class='xml';;
  1.1002 -						*.py)   class='python';; # pycurl package
  1.1003 -						*)      class='asciidoc';;
  1.1004 -					esac
  1.1005 -					case "$page" in
  1.1006 -						*.htm*)
  1.1007 -							echo '<div id="content2">'
  1.1008 -							cat
  1.1009 -							echo '</div>'
  1.1010 -							;;
  1.1011 -						*)
  1.1012 -							show_code $class
  1.1013 -							;;
  1.1014 -					esac < "$tmp"
  1.1015 -					;;
  1.1016 -				man)
  1.1017 -					export TEXTDOMAIN='man2html'
  1.1018 -					echo "<div id='content2'>"
  1.1019 -
  1.1020 -					html=$(./man2html "$tmp" | sed -e '1,/<header>/d' \
  1.1021 -					-e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
  1.1022 -					-e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g')
  1.1023 -
  1.1024 -					if [ -n "$(echo "$html" | fgrep 'The requested file /tmp/tmp.')" ]; then
  1.1025 -						# Process the pre-formatted man-cat page
  1.1026 -						echo '<pre>'
  1.1027 -						sed '
  1.1028 -							s|M-bM-^@M-^S|—|g;
  1.1029 -							s|M-bM-^@M-^\\|<b>|g;
  1.1030 -							s|M-bM-^@M-^]|</b>|g
  1.1031 -							s|M-bM-^@M-^X|<u>|g;
  1.1032 -							s|M-bM-^@M-^Y|</u>|g;
  1.1033 -							s|M-BM-||g;
  1.1034 -							' "$tmp"
  1.1035 -						echo '</pre>'
  1.1036 -					else
  1.1037 -						echo "$html"
  1.1038 -					fi
  1.1039 -					echo "</div>"
  1.1040 -					;;
  1.1041 -			esac
  1.1042 -			rm -f $tmp
  1.1043 -		else
  1.1044 -			echo "<pre>File '$page' not exists!</pre>"
  1.1045 -		fi
  1.1046 +		tmp="$(mktemp)"
  1.1047 +		docat "$dir/$page" > $tmp
  1.1048 +		[ -s "$tmp" ] && case "$type" in
  1.1049 +		info)
  1.1050 +			echo '<pre>'
  1.1051 +			info2html < "$tmp"
  1.1052 +			echo '</pre>' ;;
  1.1053 +		doc)
  1.1054 +			echo '<pre>'
  1.1055 +			case "$page" in
  1.1056 +			*.htm*)	cat ;;
  1.1057 +			*)	sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
  1.1058 +			esac < "$tmp"
  1.1059 +			echo '</pre>' ;;
  1.1060 +		man)
  1.1061 +			export TEXTDOMAIN='man2html'
  1.1062 +			./man2html "$tmp" | sed -e '1,/<header>/d' \
  1.1063 +			-e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
  1.1064 +			-e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g' ;;
  1.1065 +		esac
  1.1066 +		rm -f $tmp
  1.1067  		;;
  1.1068 -
  1.1069  	*)
  1.1070  		# We may have a toolchain.cgi script for cross cooker's
  1.1071  		if [ -f "toolchain.cgi" ]; then
  1.1072 @@ -942,57 +593,56 @@
  1.1073  		pct=0
  1.1074  		[ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok ))
  1.1075  		cat <<EOT
  1.1076 -<div id="content2">
  1.1077 -
  1.1078 -<form method="get" action="" class="r">
  1.1079 -	<input type="search" name="pkg" placeholder="Package" list="packages" autocorrect="off" autocapitalize="off"/>
  1.1080 -</form>
  1.1081 +<div style="float: right;">
  1.1082 +	<form method="get" action="$SCRIPT_NAME">
  1.1083 +		Package:
  1.1084 +		<input type="text" name="pkg" />
  1.1085 +	</form>
  1.1086 +</div>
  1.1087  
  1.1088  <h2>Summary</h2>
  1.1089  
  1.1090 -<table>
  1.1091 -<tr><td>Running command</td><td>: $(running_command)</td></tr>
  1.1092 -<tr><td>Wok revision</td><td>: <a href="$WOK_URL">$(cat $wokrev)</a></td></tr>
  1.1093 -<tr><td>Commits to cook</td><td>: $(wc -l < $commits)</td></tr>
  1.1094 -<tr><td>Current cooklist</td><td>: $(wc -l < $cooklist)</td></tr>
  1.1095 -<tr><td>Broken packages</td><td>: $(wc -l < $broken)</td></tr>
  1.1096 -<tr><td>Blocked packages</td><td>: $(wc -l < $blocked)</td></tr>
  1.1097 -<tr><td>Architecture</td><td>: $ARCH, <a href="$toolchain">toolchain</a></td></tr>
  1.1098 -<tr><td>Server date</td><td>: $(date -u '+%F %R %Z')</td></tr>
  1.1099 -
  1.1100 -</table>
  1.1101 +<pre>
  1.1102 +Running command  : $(running_command)
  1.1103 +Wok revision     : <a href="$WOK_URL">$(cat $wokrev)</a>
  1.1104 +Commits to cook  : $(cat $commits | wc -l)
  1.1105 +Current cooklist : $(cat $cooklist | wc -l)
  1.1106 +Broken packages  : $(cat $broken | wc -l)
  1.1107 +Blocked packages : $(cat $blocked | wc -l)
  1.1108 +</pre>
  1.1109  EOT
  1.1110 -
  1.1111  		[ -e $CACHE/cooker-request ] &&
  1.1112 -		[ $CACHE/activity -nt $CACHE/cooker-request ] &&
  1.1113 -		echo '<a class="button r" href="?poke">Poke cooker</a>'
  1.1114 -
  1.1115 +		[ $CACHE/activity -nt $CACHE/cooker-request ] && cat <<EOT
  1.1116 +<div style="float: right;">
  1.1117 +	<a class="button" href="?poke">Poke cooker</a>
  1.1118 +</div>
  1.1119 +EOT
  1.1120  		cat <<EOT
  1.1121 -<p class="info">Packages: $inwok in the wok · $cooked cooked · $unbuilt unbuilt</p>
  1.1122 -
  1.1123 +<p class="info">
  1.1124 +	Packages: $inwok in the wok | $cooked cooked | $unbuilt unbuilt |
  1.1125 +	Server date: $(date -u '+%F %R %Z')
  1.1126 +</p>
  1.1127  <div class="pctbar">
  1.1128  	<div class="pct" style="width: ${pct}%;">${pct}%</div>
  1.1129  </div>
  1.1130  
  1.1131  <p>
  1.1132 -	Service logs:
  1.1133 -	<a href="?file=cookorder.log">cookorder</a> ·
  1.1134 -	<a href="?file=commits.log">commits</a> ·
  1.1135 -	<a href="?file=pkgdb.log">pkgdb</a><!-- ·
  1.1136 -	<a href="?file=installed.diff">installed.diff</a> -->
  1.1137 +	Latest:
  1.1138 +	<a href="?file=cookorder.log">cookorder.log</a>
  1.1139 +	<a href="?file=commits.log">commits.log</a>
  1.1140 +	<a href="?file=pkgdb.log">pkgdb.log</a>
  1.1141 +	<a href="?file=installed.diff">installed.diff</a>
  1.1142 +	- Architecture $ARCH:
  1.1143 +	<a href="$toolchain">toolchain</a>
  1.1144  </p>
  1.1145  
  1.1146  $(more_button activity "More activity" $CACHE/activity 12)
  1.1147  <h2 id="activity">Activity</h2>
  1.1148 -
  1.1149 -<ul class="activity">
  1.1150 +<pre>
  1.1151 +$(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
  1.1152 +</pre>
  1.1153  EOT
  1.1154  
  1.1155 -		tac $CACHE/activity | head -n 12 | syntax_highlighter activity | \
  1.1156 -		sed 's|cooker.cgi||; s|^|<li>|; s|$|</li>|;'
  1.1157 -
  1.1158 -		echo '</ul>'
  1.1159 -
  1.1160  		[ -s $cooknotes ] && cat <<EOT
  1.1161  $(more_button cooknotes "More notes" $cooknotes 12)
  1.1162  <h2 id="cooknotes">Cooknotes</h2>
  1.1163 @@ -1003,46 +653,57 @@
  1.1164  
  1.1165  		[ -s $commits ] && cat <<EOT
  1.1166  <h2 id="commits">Commits</h2>
  1.1167 -<ul class="activity">
  1.1168 -$(sed 's|^|<li>|; s|$|</li>|' $commits)
  1.1169 -</ul>
  1.1170 +<pre>
  1.1171 +$(cat $commits)
  1.1172 +</pre>
  1.1173  EOT
  1.1174  
  1.1175  		[ -s $cooklist ] && cat <<EOT
  1.1176  $(more_button cooklist "Full cooklist" $cooklist 20)
  1.1177  <h2 id="cooklist">Cooklist</h2>
  1.1178 -<ul class="activity">
  1.1179 -$(head -n 20 $cooklist | sed 's|^|<li>|; s|$|</li>|')
  1.1180 -</ul>
  1.1181 +<pre>
  1.1182 +$(cat $cooklist | head -n 20)
  1.1183 +</pre>
  1.1184  EOT
  1.1185  
  1.1186  		[ -s $broken ] && cat <<EOT
  1.1187  $(more_button broken "All broken packages" $broken 20)
  1.1188  <h2 id="broken">Broken</h2>
  1.1189 -<ul class="activity">
  1.1190 -$(head -n 20 $broken | sed "s#^[^']*#<a href='?pkg=\0'>\0</a>#g" | sed 's|^|<li>|; s|$|</li>|')
  1.1191 -</ul>
  1.1192 +<pre>
  1.1193 +$(cat $broken | head -n 20 | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
  1.1194 +</pre>
  1.1195  EOT
  1.1196  
  1.1197  		[ -s $blocked ] && cat <<EOT
  1.1198  <h2 id="blocked">Blocked</h2>
  1.1199 -<ul class="activity">
  1.1200 -$(sed "s#^[^']*#<a href='?pkg=\0'>\0</a>#g" $blocked | sed 's|^|<li>|; s|$|</li>|')
  1.1201 -</ul>
  1.1202 +<pre>
  1.1203 +$(cat $blocked | sed s"#^[^']*#<a href='?pkg=\0'>\0</a>#"g)
  1.1204 +</pre>
  1.1205  EOT
  1.1206  
  1.1207  		cat <<EOT
  1.1208  <h2 id="lastcook">Latest cook</h2>
  1.1209 -<ul class="activity">
  1.1210 -$(list_packages | sed 's|.tazpkg$||' | \
  1.1211 -sed "s|^.* :|<span class='log-date'>\0</span> <span style='white-space:nowrap'>|g; s|^|<li>|; s|$|</span></li>|")
  1.1212 -</ul>
  1.1213 -
  1.1214 +<pre>
  1.1215 +$(list_packages | sed s"#^\([^']*\).* : #<span class='log-date'>\0</span>#"g)
  1.1216 +</pre>
  1.1217  EOT
  1.1218 -		datalist
  1.1219  	;;
  1.1220  esac
  1.1221  
  1.1222  
  1.1223 -page_footer
  1.1224 +# Close xHTML page
  1.1225 +
  1.1226 +cat <<EOT
  1.1227 +</div>
  1.1228 +
  1.1229 +<div id="footer">
  1.1230 +	<a href="http://www.slitaz.org/">SliTaz Website</a>
  1.1231 +	<a href="cooker.cgi">Cooker</a>
  1.1232 +	<a href="doc/cookutils/cookutils.en.html">Documentation</a>
  1.1233 +</div>
  1.1234 +
  1.1235 +</body>
  1.1236 +</html>
  1.1237 +EOT
  1.1238 +
  1.1239  exit 0