# HG changeset patch # User Aleksej Bobylev # Date 1497788009 -10800 # Node ID 9b8a08ce85c955fce3720c83532581bb785ce1bb # Parent 9a70c8fdc40ccdfdf4e9436da9d728e144815bf2 cook: fix commands --clean, --getsrc, --block, --unblock; lighttpd/index.cgi: add rich statistics on main page. diff -r 9a70c8fdc40c -r 9b8a08ce85c9 cook --- a/cook Sat Jun 17 23:56:37 2017 +0300 +++ b/cook Sun Jun 18 15:13:29 2017 +0300 @@ -91,7 +91,8 @@ _ 'Creating directories structure in "%s"' "$SLITAZ" mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS _ 'Creating DB files in "%s"' "$CACHE" - touch $activity $command $broken $blocked + touch $activity $command $broken $blocked $CACHE/webstat + chown www:www $cache/webstat } @@ -1462,7 +1463,55 @@ # # cook --deps -[ -n "$deps" ] && { @@PREFIX@@/libexec/cookutils/deps $1; exit 0; } +[ -n "$deps" ] && { + @@PREFIX@@/libexec/cookutils/deps $1 + exit 0 +} + +# cook --clean +# cook -c +[ -n "$clean" -o "$2" == '-c' ] && { + action 'Cleaning "%s"' "$1" + cd $WOK/$1; rm -rf install taz source + status; newline + touch $activity # update $activity -> something changed -> update webstat + exit 0 +} + +# cook --getsrc +# cook -gs +[ -n "$getsrc" -o "$2" == '-gs' ] && { + title 'Getting source for "%s"' "$1" + receipt="$WOK/$pkg/receipt" + check_pkg_in_wok + unset_receipt + . $receipt + get_source + _ 'Tarball: %s' "$SRC/$TARBALL"; newline + exit 0 +} + +# cook --block +# cook -b +[ -n "$block" -o "$2" == '-b' ] && { + action 'Blocking package "%s"' "$1" + [ $(grep "^$1$" $blocked) ] || echo "$1" >> $blocked + status; newline + touch $activity + exit 0 +} + +# cook --unblock +# cook -ub +[ -n "$unblock" -o "$2" == '-ub' ] && { + action 'Unblocking package "%s"' "$1" + sed -i "/^$1$/d" $blocked + status; newline + touch $activity + exit 0 +} + + case "$1" in @@ -1841,33 +1890,9 @@ # Handle --options case "$2" in - --clean|-c) - action 'Cleaning "%s"' "$pkg" - cd $WOK/$pkg; rm -rf install taz source - status; newline - exit 0 ;; - --install|-i) inst='yes' ;; - --getsrc|-gs) - title 'Getting source for "%s"' "$pkg" - get_source - _ 'Tarball: %s' "$SRC/$TARBALL"; newline - exit 0 ;; - - --block|-b) - action 'Blocking package "%s"' "$pkg" - [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked - status; newline - exit 0 ;; - - --unblock|-ub) - action 'Unblocking package "%s"' "$pkg" - sed -i "/^${pkg}$/d" $blocked - status; newline - exit 0 ;; - --pack) [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg" [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz" diff -r 9a70c8fdc40c -r 9b8a08ce85c9 cooker --- a/cooker Sat Jun 17 23:56:37 2017 +0300 +++ b/cooker Sun Jun 18 15:13:29 2017 +0300 @@ -253,7 +253,7 @@ # Commands # -previous_command="$(cat $command)" +previous_command="$(cat $command 2>/dev/null)" case "$1" in usage|help|-u|-h) usage ;; diff -r 9a70c8fdc40c -r 9b8a08ce85c9 lighttpd/cooker.css --- a/lighttpd/cooker.css Sat Jun 17 23:56:37 2017 +0300 +++ b/lighttpd/cooker.css Sun Jun 18 15:13:29 2017 +0300 @@ -334,6 +334,8 @@ .summary th, .summary td { white-space: nowrap; width: 1rem; text-align: center; } .summary th:last-child, .summary td:last-child { width: unset; } +.webstat td { text-align: center; } +.webstat td:first-child { text-align: unset; } div.list td, div.list th { padding: 5px 2px; } @@ -355,6 +357,7 @@ .meter { height: 1.4rem; + margin: 0.7rem 0; color: inherit; } .meter progress { diff -r 9a70c8fdc40c -r 9b8a08ce85c9 lighttpd/index.cgi --- a/lighttpd/index.cgi Sat Jun 17 23:56:37 2017 +0300 +++ b/lighttpd/index.cgi Sun Jun 18 15:13:29 2017 +0300 @@ -30,6 +30,7 @@ cooknotes="$CACHE/cooknotes" cooktime="$CACHE/cooktime" wokrev="$CACHE/wokrev" +webstat="$CACHE/webstat" # Path to markdown to html convertor cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter' @@ -734,6 +735,37 @@ } +# Update statistics used in web interface. +# There is no need to recalculate the statistics every time the page is displayed. + +update_webstat() { + # for receipts: + rtotal=$(ls $WOK/*/arch.$ARCH | wc -l) + rcooked=$(ls -d $WOK/*/taz | wc -l) + runbuilt=$(($rtotal - $rcooked)) + rblocked=$(wc -l < $blocked) + rbroken=$(wc -l < $broken) + + # for packages: + ptotal=$(cut -d$'\t' -f2 $CACHE/split.db | tr ' ' '\n' | wc -l) + pcooked=$(ls $PKGS/*.tazpkg | wc -l) + punbuilt=$(($ptotal - $pcooked)) + pblocked=$( + while read i; do + sed "/^$i\t/!d" $CACHE/split.db + done < $blocked | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l) + pbroken=$( + while read i; do + sed "/^$i\t/!d" $CACHE/split.db + done < $broken | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l) + + cat > $webstat < @@ -846,8 +876,6 @@ Wok revision : $(cat $wokrev) Commits to cook : $(wc -l < $commits) Current cooklist : $(wc -l < $cooklist) -Broken packages : $(wc -l < $broken) -Blocked packages : $(wc -l < $blocked) Architecture : $ARCH, toolchain Server date : $(date -u '+%F %R %Z') EOT @@ -862,6 +890,23 @@ ;; esac + # Do we need to update the statistics? + [ "$webstat" -nt "$activity" ] || update_webstat + . $webstat + + pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal )) + +cat <${pct}%${pct}% + + + + + + +
Total Cooked Unbuilt Blocked Broken
Receipts$rtotal$rcooked$runbuilt$rblocked$rbroken
Packages$ptotal$pcooked$punbuilt$pblocked$pbroken
+EOT + if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then if [ "$activity" -nt "$CACHE/cooker-request" ]; then echo 'Wake up' @@ -871,10 +916,6 @@ fi cat <Receipts in the wok: $inwok total · $cooked cooked · $unbuilt unbuilt

- -
${pct}%${pct}%
-

Service logs: cookorder ·