cookutils rev 933
cook: fix commands --clean, --getsrc, --block, --unblock; lighttpd/index.cgi: add rich statistics on main page.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sun Jun 18 15:13:29 2017 +0300 (2017-06-18) |
parents | 9a70c8fdc40c |
children | e4202f708ddb |
files | cook cooker lighttpd/cooker.css lighttpd/index.cgi |
line diff
1.1 --- a/cook Sat Jun 17 23:56:37 2017 +0300 1.2 +++ b/cook Sun Jun 18 15:13:29 2017 +0300 1.3 @@ -91,7 +91,8 @@ 1.4 _ 'Creating directories structure in "%s"' "$SLITAZ" 1.5 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS 1.6 _ 'Creating DB files in "%s"' "$CACHE" 1.7 - touch $activity $command $broken $blocked 1.8 + touch $activity $command $broken $blocked $CACHE/webstat 1.9 + chown www:www $cache/webstat 1.10 } 1.11 1.12 1.13 @@ -1462,7 +1463,55 @@ 1.14 # 1.15 1.16 # cook <package> --deps 1.17 -[ -n "$deps" ] && { @@PREFIX@@/libexec/cookutils/deps $1; exit 0; } 1.18 +[ -n "$deps" ] && { 1.19 + @@PREFIX@@/libexec/cookutils/deps $1 1.20 + exit 0 1.21 +} 1.22 + 1.23 +# cook <package> --clean 1.24 +# cook <package> -c 1.25 +[ -n "$clean" -o "$2" == '-c' ] && { 1.26 + action 'Cleaning "%s"' "$1" 1.27 + cd $WOK/$1; rm -rf install taz source 1.28 + status; newline 1.29 + touch $activity # update $activity -> something changed -> update webstat 1.30 + exit 0 1.31 +} 1.32 + 1.33 +# cook <package> --getsrc 1.34 +# cook <package> -gs 1.35 +[ -n "$getsrc" -o "$2" == '-gs' ] && { 1.36 + title 'Getting source for "%s"' "$1" 1.37 + receipt="$WOK/$pkg/receipt" 1.38 + check_pkg_in_wok 1.39 + unset_receipt 1.40 + . $receipt 1.41 + get_source 1.42 + _ 'Tarball: %s' "$SRC/$TARBALL"; newline 1.43 + exit 0 1.44 +} 1.45 + 1.46 +# cook <package> --block 1.47 +# cook <package> -b 1.48 +[ -n "$block" -o "$2" == '-b' ] && { 1.49 + action 'Blocking package "%s"' "$1" 1.50 + [ $(grep "^$1$" $blocked) ] || echo "$1" >> $blocked 1.51 + status; newline 1.52 + touch $activity 1.53 + exit 0 1.54 +} 1.55 + 1.56 +# cook <package> --unblock 1.57 +# cook <package> -ub 1.58 +[ -n "$unblock" -o "$2" == '-ub' ] && { 1.59 + action 'Unblocking package "%s"' "$1" 1.60 + sed -i "/^$1$/d" $blocked 1.61 + status; newline 1.62 + touch $activity 1.63 + exit 0 1.64 +} 1.65 + 1.66 + 1.67 1.68 1.69 case "$1" in 1.70 @@ -1841,33 +1890,9 @@ 1.71 1.72 # Handle --options 1.73 case "$2" in 1.74 - --clean|-c) 1.75 - action 'Cleaning "%s"' "$pkg" 1.76 - cd $WOK/$pkg; rm -rf install taz source 1.77 - status; newline 1.78 - exit 0 ;; 1.79 - 1.80 --install|-i) 1.81 inst='yes' ;; 1.82 1.83 - --getsrc|-gs) 1.84 - title 'Getting source for "%s"' "$pkg" 1.85 - get_source 1.86 - _ 'Tarball: %s' "$SRC/$TARBALL"; newline 1.87 - exit 0 ;; 1.88 - 1.89 - --block|-b) 1.90 - action 'Blocking package "%s"' "$pkg" 1.91 - [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked 1.92 - status; newline 1.93 - exit 0 ;; 1.94 - 1.95 - --unblock|-ub) 1.96 - action 'Unblocking package "%s"' "$pkg" 1.97 - sed -i "/^${pkg}$/d" $blocked 1.98 - status; newline 1.99 - exit 0 ;; 1.100 - 1.101 --pack) 1.102 [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg" 1.103 [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz"
2.1 --- a/cooker Sat Jun 17 23:56:37 2017 +0300 2.2 +++ b/cooker Sun Jun 18 15:13:29 2017 +0300 2.3 @@ -253,7 +253,7 @@ 2.4 # Commands 2.5 # 2.6 2.7 -previous_command="$(cat $command)" 2.8 +previous_command="$(cat $command 2>/dev/null)" 2.9 case "$1" in 2.10 usage|help|-u|-h) 2.11 usage ;;
3.1 --- a/lighttpd/cooker.css Sat Jun 17 23:56:37 2017 +0300 3.2 +++ b/lighttpd/cooker.css Sun Jun 18 15:13:29 2017 +0300 3.3 @@ -334,6 +334,8 @@ 3.4 .summary th, .summary td { white-space: nowrap; width: 1rem; text-align: center; } 3.5 .summary th:last-child, .summary td:last-child { width: unset; } 3.6 3.7 +.webstat td { text-align: center; } 3.8 +.webstat td:first-child { text-align: unset; } 3.9 3.10 div.list td, div.list th { padding: 5px 2px; } 3.11 3.12 @@ -355,6 +357,7 @@ 3.13 3.14 .meter { 3.15 height: 1.4rem; 3.16 + margin: 0.7rem 0; 3.17 color: inherit; 3.18 } 3.19 .meter progress {
4.1 --- a/lighttpd/index.cgi Sat Jun 17 23:56:37 2017 +0300 4.2 +++ b/lighttpd/index.cgi Sun Jun 18 15:13:29 2017 +0300 4.3 @@ -30,6 +30,7 @@ 4.4 cooknotes="$CACHE/cooknotes" 4.5 cooktime="$CACHE/cooktime" 4.6 wokrev="$CACHE/wokrev" 4.7 +webstat="$CACHE/webstat" 4.8 4.9 # Path to markdown to html convertor 4.10 cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter' 4.11 @@ -734,6 +735,37 @@ 4.12 } 4.13 4.14 4.15 +# Update statistics used in web interface. 4.16 +# There is no need to recalculate the statistics every time the page is displayed. 4.17 + 4.18 +update_webstat() { 4.19 + # for receipts: 4.20 + rtotal=$(ls $WOK/*/arch.$ARCH | wc -l) 4.21 + rcooked=$(ls -d $WOK/*/taz | wc -l) 4.22 + runbuilt=$(($rtotal - $rcooked)) 4.23 + rblocked=$(wc -l < $blocked) 4.24 + rbroken=$(wc -l < $broken) 4.25 + 4.26 + # for packages: 4.27 + ptotal=$(cut -d$'\t' -f2 $CACHE/split.db | tr ' ' '\n' | wc -l) 4.28 + pcooked=$(ls $PKGS/*.tazpkg | wc -l) 4.29 + punbuilt=$(($ptotal - $pcooked)) 4.30 + pblocked=$( 4.31 + while read i; do 4.32 + sed "/^$i\t/!d" $CACHE/split.db 4.33 + done < $blocked | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l) 4.34 + pbroken=$( 4.35 + while read i; do 4.36 + sed "/^$i\t/!d" $CACHE/split.db 4.37 + done < $broken | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l) 4.38 + 4.39 + cat > $webstat <<EOT 4.40 +rtotal="$rtotal"; rcooked="$rcooked"; runbuilt="$runbuilt"; rblocked="$rblocked"; rbroken="$rbroken" 4.41 +ptotal="$ptotal"; pcooked="$pcooked"; punbuilt="$punbuilt"; pblocked="$pblocked"; pbroken="$pbroken" 4.42 +EOT 4.43 +} 4.44 + 4.45 + 4.46 4.47 4.48 # 4.49 @@ -822,12 +854,10 @@ 4.50 else 4.51 toolchain="?toolchain" 4.52 fi 4.53 + 4.54 # Main page with summary. Count only packages included in ARCH, 4.55 # use 'cooker arch-db' to manually create arch.$ARCH files. 4.56 - inwok=$(ls $WOK/*/arch.$ARCH | wc -l) 4.57 - cooked=$(ls -d $WOK/*/taz | wc -l) 4.58 - unbuilt=$(($inwok - $cooked)) 4.59 - pct=0; [ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok )) 4.60 + 4.61 cat <<EOT 4.62 <div id="content2"> 4.63 4.64 @@ -846,8 +876,6 @@ 4.65 Wok revision : <a href='$WOK_URL' target='_blank' rel='noopener noreferrer'>$(cat $wokrev)</a> 4.66 Commits to cook : $(wc -l < $commits) 4.67 Current cooklist : $(wc -l < $cooklist) 4.68 -Broken packages : $(wc -l < $broken) 4.69 -Blocked packages : $(wc -l < $blocked) 4.70 Architecture : $ARCH, <a href="$toolchain">toolchain</a> 4.71 Server date : <span id='date'>$(date -u '+%F %R %Z')</span> 4.72 EOT 4.73 @@ -862,6 +890,23 @@ 4.74 ;; 4.75 esac 4.76 4.77 + # Do we need to update the statistics? 4.78 + [ "$webstat" -nt "$activity" ] || update_webstat 4.79 + . $webstat 4.80 + 4.81 + pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal )) 4.82 + 4.83 +cat <<EOT 4.84 +<div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div> 4.85 + 4.86 +<table class="webstat"><thead> 4.87 +<tr><th> </th><th>Total </th><th>Cooked </th><th>Unbuilt </th><th>Blocked </th><th>Broken </th></tr> 4.88 +</thead><tbody> 4.89 +<tr><td>Receipts</td><td>$rtotal</td><td>$rcooked</td><td>$runbuilt</td><td>$rblocked</td><td>$rbroken</td></tr> 4.90 +<tr><td>Packages</td><td>$ptotal</td><td>$pcooked</td><td>$punbuilt</td><td>$pblocked</td><td>$pbroken</td></tr> 4.91 +</tbody></table> 4.92 +EOT 4.93 + 4.94 if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then 4.95 if [ "$activity" -nt "$CACHE/cooker-request" ]; then 4.96 echo '<a class="button icon bell r" href="?poke">Wake up</a>' 4.97 @@ -871,10 +916,6 @@ 4.98 fi 4.99 4.100 cat <<EOT 4.101 -<p>Receipts in the wok: $inwok total · $cooked cooked · $unbuilt unbuilt</p> 4.102 - 4.103 -<div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div> 4.104 - 4.105 <p> 4.106 Service logs: 4.107 <a href="?cookorder.log">cookorder</a> ·