cookutils rev 1063

lighttpd/index.cgi: load main page parts asynchronously
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Jun 04 11:27:06 2018 +0300 (2018-06-04)
parents 45a7e146df74
children 0af059297232
files lighttpd/index.cgi modules/deps
line diff
     1.1 --- a/lighttpd/index.cgi	Wed May 30 16:33:35 2018 +0300
     1.2 +++ b/lighttpd/index.cgi	Mon Jun 04 11:27:06 2018 +0300
     1.3 @@ -110,6 +110,22 @@
     1.4  	<meta name="theme-color" content="#222">
     1.5  	<!-- rss -->
     1.6  	<link rel="alternate" type="application/rss+xml" title="$title Feed" href="?rss">
     1.7 +	<script>
     1.8 +		// Get part of the main page
     1.9 +		function getPart(part) {
    1.10 +			var partRequest = new XMLHttpRequest();
    1.11 +			partRequest.onreadystatechange = function() {
    1.12 +				if (this.readyState == 4 && this.status == 200) {
    1.13 +					response = this.responseText;
    1.14 +					var partElement = document.getElementById(part);
    1.15 +					if (response !== null) partElement.innerHTML = response;
    1.16 +				}
    1.17 +			};
    1.18 +			partRequest.open('GET', '?part=' + part, true);
    1.19 +			partRequest.responseType = '';
    1.20 +			partRequest.send();
    1.21 +		}
    1.22 +	</script>
    1.23  </head>
    1.24  <body>
    1.25  <div id="container">
    1.26 @@ -514,6 +530,7 @@
    1.27  				-e 's#\([^a-zA-Z]\)\([Ee]rror\)$#\1<b>\2</b>#' \
    1.28  				-e 's#ERROR:#<b>ERROR:</b>#g' \
    1.29  				\
    1.30 +				-e 's#^.*multiple definition of.*#<b>\0</b>#' \
    1.31  				-e 's#^.*[Ff][Aa][Ii][Ll][Ee][Dd].*#<b>\0</b>#' \
    1.32  				-e 's#^.*[Ff]atal.*#<b>\0</b>#' \
    1.33  				-e '/non-fatal/ s|</*b>||g' \
    1.34 @@ -828,9 +845,9 @@
    1.35  # Note, $webstat file must be owned by www, otherwise this function will not be able to do the job.
    1.36  
    1.37  update_webstat() {
    1.38 -	echo '<div id="waitme">'
    1.39 -	show_note i 'Please wait while statistics are being collected.'
    1.40 -	echo "</div>"
    1.41 +#	echo '<div id="waitme">'
    1.42 +#	show_note i 'Please wait while statistics are being collected.'
    1.43 +#	echo "</div>"
    1.44  
    1.45  	# for receipts:
    1.46  	rtotal=$(ls $WOK/*/arch.$ARCH | wc -l)
    1.47 @@ -861,6 +878,135 @@
    1.48  }
    1.49  
    1.50  
    1.51 +# Generate part of the main page
    1.52 +
    1.53 +part() {
    1.54 +	if [ -z "$nojs" ]; then
    1.55 +		echo "<div id='$1'></div><script>getPart('$1')</script>"
    1.56 +		return
    1.57 +	fi
    1.58 +
    1.59 +	echo '<div>'
    1.60 +	case $1 in
    1.61 +		summary)
    1.62 +			echo '<h2>Summary</h2>'
    1.63 +
    1.64 +			mktable <<EOT
    1.65 +Cooker state     : $(running_command)
    1.66 +Wok revision     : <a href='$WOK_URL' target='_blank' rel='noopener noreferrer'>$(cat $wokrev)</a>
    1.67 +Commits to cook  : $(wc -l < $commits)
    1.68 +Current cooklist : $(wc -l < $cooklist)
    1.69 +Architecture     : $ARCH, <a href="$toolchain">toolchain</a>
    1.70 +Server date      : <span id='date'>$(date -u '+%F %R %Z')</span>
    1.71 +EOT
    1.72 +
    1.73 +			# If command is "cook:*", update gauge and percentage periodically.
    1.74 +			# If different package is cooking, reload the page (with new settings)
    1.75 +			cmd="$(cat $command)"
    1.76 +			case "$cmd" in
    1.77 +				cook:*)
    1.78 +					pkg=${cmd#*:}
    1.79 +					echo "<script>updatePkg = '${pkg//+/%2B}';</script>"
    1.80 +					;;
    1.81 +			esac
    1.82 +			;;
    1.83 +		webstat)
    1.84 +			# Do we need to update the statistics?
    1.85 +			[ "$webstat" -nt "$activity" ] || update_webstat
    1.86 +			. $webstat
    1.87 +
    1.88 +			pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal ))
    1.89 +
    1.90 +			cat <<EOT
    1.91 +<div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div>
    1.92 +
    1.93 +<table class="webstat"><thead>
    1.94 +<tr><th>        </th><th>Total  </th><th>Cooked  </th><th>Unbuilt  </th><th>Blocked  </th><th>Broken  </th></tr>
    1.95 +</thead><tbody>
    1.96 +<tr><td>Receipts</td><td>$rtotal</td><td>$rcooked</td><td>$runbuilt</td><td>$rblocked</td><td>$rbroken</td></tr>
    1.97 +<tr><td>Packages</td><td>$ptotal</td><td>$pcooked</td><td>$punbuilt</td><td>$pblocked</td><td>$pbroken</td></tr>
    1.98 +</tbody></table>
    1.99 +EOT
   1.100 +			;;
   1.101 +		activity)
   1.102 +			tac $activity | head -n12 | sed 's|cooker.cgi?pkg=||;
   1.103 +				s|\[ Done|<span class="r c20">Done|;
   1.104 +				s|\[ Failed|<span class="r c10">Failed|;
   1.105 +				s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
   1.106 +				s| \]|</span>|;
   1.107 +				s|%2B|\+|g' | \
   1.108 +				section $activity 12 "Activity|More activity"
   1.109 +			;;
   1.110 +		cooknotes)
   1.111 +			[ -s "$cooknotes" ] && tac $cooknotes | head -n12 | \
   1.112 +				section $cooknotes 12 "Cooknotes|More notes"
   1.113 +			;;
   1.114 +		commits)
   1.115 +			[ -s "$commits" ] && head -n20 $commits | \
   1.116 +				section $commits 20 "Commits|More commits"
   1.117 +			;;
   1.118 +		cooklist)
   1.119 +			[ -s "$cooklist" ] && head -n 20 $cooklist | \
   1.120 +				section $cooklist 20 "Cooklist|Full cooklist"
   1.121 +			;;
   1.122 +		broken)
   1.123 +			[ -s "$broken" ] && head -n20 $broken | sed "s|^[^']*|<a href='\0'>\0</a>|g" | \
   1.124 +				section $broken 20 "Broken|All broken packages"
   1.125 +			;;
   1.126 +		blocked)
   1.127 +			[ -s "$blocked" ] && sed "s|^[^']*|<a href='\0'>\0</a>|g" $blocked | \
   1.128 +				section $blocked 12 "Blocked|All blocked packages"
   1.129 +			;;
   1.130 +		pkgs)
   1.131 +			cd $PKGS
   1.132 +			# About BusyBox's `ls`
   1.133 +			# On the Tank server: BusyBox v1.18.4 (2012-03-14 03:32:25 CET) multi-call binary.
   1.134 +			# It supported the option `-e`, output with `-let` options like this:
   1.135 +			# -rw-r--r--    1 user     group       100000 Fri Nov  3 10:00:00 2017 filename
   1.136 +			# 1             2 3        4           5      6   7    8 9        10   11
   1.137 +			# Newer BusyBox v1.27.2 doesn't support option `-e` and has no configs to
   1.138 +			# configure it or return the option back. It supported the long option
   1.139 +			# `--full-time` instead, but output is different:
   1.140 +			# -rw-r--r--    1 user     group       100000 2017-11-03 10:00:00 +0200 filename
   1.141 +			# 1             2 3        4           5      6          7        8     9
   1.142 +			if ls -let >/dev/null 2>&1; then
   1.143 +				ls -let *.tazpkg \
   1.144 +				| awk '
   1.145 +				(NR<=20){
   1.146 +					sub(/:[0-9][0-9]$/, "", $9);
   1.147 +					mon = index("  JanFebMarAprMayJunJulAugSepOctNovDec", $7) / 3;
   1.148 +					printf("%d-%02d-%02d %s : <a href=\"get/%s\">%s</a>\n", $10, mon, $8, $9, $11, $11);
   1.149 +				}' \
   1.150 +				| section $activity 1000 "Latest cook"
   1.151 +			else
   1.152 +				ls -lt --full-time *.tazpkg \
   1.153 +				| awk '
   1.154 +				(NR<=20){
   1.155 +					sub(/:[0-9][0-9]$/, "", $7);
   1.156 +					printf("%s %s : <a href=\"get/%s\">%s</a>\n", $6, $7, $9, $9);
   1.157 +				}' \
   1.158 +				| section $activity 1000 "Latest cook"
   1.159 +			fi
   1.160 +			;;
   1.161 +	esac
   1.162 +	echo '</div>'
   1.163 +}
   1.164 +
   1.165 +
   1.166 +# Query '?part=<part>': get part of the main page
   1.167 +
   1.168 +if [ -n "$(GET part)" ]; then
   1.169 +	part="$(GET part)"
   1.170 +	case $part in
   1.171 +		summary|webstat|activity|cooknotes|commits|cooklist|broken|blocked|pkgs)
   1.172 +			nojs='yes'
   1.173 +			part $part
   1.174 +			;;
   1.175 +	esac
   1.176 +	exit 0
   1.177 +fi
   1.178 +
   1.179 +
   1.180  
   1.181  
   1.182  #
   1.183 @@ -977,45 +1123,10 @@
   1.184  	<button type="submit" title="Search">Search</button>
   1.185  	<input type="search" name="q" placeholder="Package" list="packages" autocorrect="off" autocapitalize="off"/>
   1.186  </form>
   1.187 -
   1.188 -<h2>Summary</h2>
   1.189  EOT
   1.190  
   1.191 -mktable <<EOT
   1.192 -Cooker state     : $(running_command)
   1.193 -Wok revision     : <a href='$WOK_URL' target='_blank' rel='noopener noreferrer'>$(cat $wokrev)</a>
   1.194 -Commits to cook  : $(wc -l < $commits)
   1.195 -Current cooklist : $(wc -l < $cooklist)
   1.196 -Architecture     : $ARCH, <a href="$toolchain">toolchain</a>
   1.197 -Server date      : <span id='date'>$(date -u '+%F %R %Z')</span>
   1.198 -EOT
   1.199 -
   1.200 -	# If command is "cook:*", update gauge and percentage periodically.
   1.201 -	# If different package is cooking, reload the page (with new settings)
   1.202 -	cmd="$(cat $command)"
   1.203 -	case "$cmd" in
   1.204 -		cook:*)
   1.205 -			pkg=${cmd#*:}
   1.206 -			echo "<script>updatePkg = '${pkg//+/%2B}';</script>"
   1.207 -			;;
   1.208 -	esac
   1.209 -
   1.210 -	# Do we need to update the statistics?
   1.211 -	[ "$webstat" -nt "$activity" ] || update_webstat
   1.212 -	. $webstat
   1.213 -
   1.214 -	pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal ))
   1.215 -
   1.216 -cat <<EOT
   1.217 -<div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div>
   1.218 -
   1.219 -<table class="webstat"><thead>
   1.220 -<tr><th>        </th><th>Total  </th><th>Cooked  </th><th>Unbuilt  </th><th>Blocked  </th><th>Broken  </th></tr>
   1.221 -</thead><tbody>
   1.222 -<tr><td>Receipts</td><td>$rtotal</td><td>$rcooked</td><td>$runbuilt</td><td>$rblocked</td><td>$rbroken</td></tr>
   1.223 -<tr><td>Packages</td><td>$ptotal</td><td>$pcooked</td><td>$punbuilt</td><td>$pblocked</td><td>$pbroken</td></tr>
   1.224 -</tbody></table>
   1.225 -EOT
   1.226 +	part summary
   1.227 +	part webstat
   1.228  
   1.229  	if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then
   1.230  		if [ "$activity" -nt "$CACHE/cooker-request" ]; then
   1.231 @@ -1035,58 +1146,13 @@
   1.232  </section>
   1.233  EOT
   1.234  
   1.235 -	tac $activity | head -n12 | sed 's|cooker.cgi?pkg=||;
   1.236 -		s|\[ Done|<span class="r c20">Done|;
   1.237 -		s|\[ Failed|<span class="r c10">Failed|;
   1.238 -		s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
   1.239 -		s| \]|</span>|;
   1.240 -		s|%2B|\+|g' | \
   1.241 -		section $activity 12 "Activity|More activity"
   1.242 -
   1.243 -	[ -s "$cooknotes" ] && tac $cooknotes | head -n12 | \
   1.244 -		section $cooknotes 12 "Cooknotes|More notes"
   1.245 -
   1.246 -	[ -s "$commits" ] &&
   1.247 -		section $commits 20 "Commits|More commits" < $commits
   1.248 -
   1.249 -	[ -s "$cooklist" ] && head -n 20 $cooklist | \
   1.250 -		section $cooklist 20 "Cooklist|Full cooklist"
   1.251 -
   1.252 -	[ -s "$broken" ] && head -n20 $broken | sed "s|^[^']*|<a href='\0'>\0</a>|g" | \
   1.253 -		section $broken 20 "Broken|All broken packages"
   1.254 -
   1.255 -	[ -s "$blocked" ] && sed "s|^[^']*|<a href='\0'>\0</a>|g" $blocked | \
   1.256 -		section $blocked 12 "Blocked|All blocked packages"
   1.257 -
   1.258 -	cd $PKGS
   1.259 -	# About BusyBox's `ls`
   1.260 -	# On the Tank server: BusyBox v1.18.4 (2012-03-14 03:32:25 CET) multi-call binary.
   1.261 -	# It supported the option `-e`, output with `-let` options like this:
   1.262 -	# -rw-r--r--    1 user     group       100000 Fri Nov  3 10:00:00 2017 filename
   1.263 -	# 1             2 3        4           5      6   7    8 9        10   11
   1.264 -	# Newer BusyBox v1.27.2 doesn't support option `-e` and has no configs to
   1.265 -	# configure it or return the option back. It supported the long option
   1.266 -	# `--full-time` instead, but output is different:
   1.267 -	# -rw-r--r--    1 user     group       100000 2017-11-03 10:00:00 +0200 filename
   1.268 -	# 1             2 3        4           5      6          7        8     9
   1.269 -	if ls -let >/dev/null 2>&1; then
   1.270 -		ls -let *.tazpkg \
   1.271 -		| awk '
   1.272 -		(NR<=20){
   1.273 -			sub(/:[0-9][0-9]$/, "", $9);
   1.274 -			mon = index("  JanFebMarAprMayJunJulAugSepOctNovDec", $7) / 3;
   1.275 -			printf("%d-%02d-%02d %s : <a href=\"get/%s\">%s</a>\n", $10, mon, $8, $9, $11, $11);
   1.276 -		}' \
   1.277 -		| section $activity 1000 "Latest cook"
   1.278 -	else
   1.279 -		ls -lt --full-time *.tazpkg \
   1.280 -		| awk '
   1.281 -		(NR<=20){
   1.282 -			sub(/:[0-9][0-9]$/, "", $7);
   1.283 -			printf("%s %s : <a href=\"get/%s\">%s</a>\n", $6, $7, $9, $9);
   1.284 -		}' \
   1.285 -		| section $activity 1000 "Latest cook"
   1.286 -	fi
   1.287 +	part activity
   1.288 +	part cooknotes
   1.289 +	part commits
   1.290 +	part cooklist
   1.291 +	part broken
   1.292 +	part blocked
   1.293 +	part pkgs
   1.294  
   1.295  	echo '</div>'
   1.296  	datalist
     2.1 --- a/modules/deps	Wed May 30 16:33:35 2018 +0300
     2.2 +++ b/modules/deps	Mon Jun 04 11:27:06 2018 +0300
     2.3 @@ -178,6 +178,7 @@
     2.4  				s("cairo-dev", "cairo-gl-dev");
     2.5  				s("freetype-dev", "freetype-infinality-dev");
     2.6  				s("nspr", "webian-shell");
     2.7 +				s("nss", "webian-shell");
     2.8  
     2.9  				# if called with "--incl": show all deps including glibc-base,
    2.10  				# gcc-lib-base, glibc-dev and gcc; otherwise hide them