# HG changeset patch # User Christopher Rogers # Date 1339432032 0 # Node ID 4721d19207ed8704bc1b18bf69702965e3f0b84a # Parent ee10b96cd87b98635ad0884a837a6ddc08d21ffa cooker.cgi: Updated. diff -r ee10b96cd87b -r 4721d19207ed web/cooker.cgi --- a/web/cooker.cgi Mon Jun 11 16:26:15 2012 +0000 +++ b/web/cooker.cgi Mon Jun 11 16:27:12 2012 +0000 @@ -3,22 +3,7 @@ # SliTaz Cooker CGI/web interface. # -[ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf -[ -f "cook.conf" ] && . ./cook.conf - -# The same wok as cook. -wok="$WOK" - -# Cooker DB files. -activity="$CACHE/activity" -commits="$CACHE/commits" -cooklist="$CACHE/cooklist" -cookorder="$CACHE/cookorder" -command="$CACHE/command" -blocked="$CACHE/blocked" -broken="$CACHE/broken" -cooknotes="$CACHE/cooknotes" -wokrev="$CACHE/wokrev" +. /usr/lib/slitaz/libcook.sh # We're not logged and want time zone to display correct server date. export TZ=$(cat /etc/TZ) @@ -106,11 +91,21 @@ done } +list_incoming() { + cd $INCOMING + ls -1t *.tazpkg | head -20 | \ + while read file + do + echo -n $(stat -c '%y' $INCOMING/$file | cut -d . -f 1 | sed s/:[0-9]*$//) + echo " : $file" + done +} + # xHTML header. Pages can be customized with a separated html.header file. if [ -f "header.html" ]; then cat header.html else - cat << EOT +cat << EOT @@ -123,6 +118,13 @@ @@ -143,26 +145,38 @@ # Package info. echo '
' - if [ -f "$wok/$pkg/receipt" ]; then + if [ -f "$WOK/$pkg/receipt" ]; then echo "receipt" unset WEB_SITE - . $wok/$pkg/receipt - [ -n "$WEB_SITE" ] && # busybox wget -s $WEB_SITE && + . $WOK/$pkg/receipt + [ -n "$WEB_SITE" ] && busybox wget -s $WEB_SITE && echo "home" - if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then + if [ -f "$WOK/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then echo "files" unset EXTRAVERSION - . $wok/$pkg/taz/$PACKAGE-$VERSION/receipt - if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then + . $WOK/$pkg/taz/$PACKAGE-$VERSION/receipt + if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then + echo "download" + elif [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then echo "download" fi - if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then - echo "download" + + if [ -f $SRC/$TARBALL ]; then + echo "src tarball" + elif [ -f $SRC/$SOURCE-${KBASEVER:-$VERSION}.tar.lzma ]; then + echo "src tarball" + elif [ -f $SRC/$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma ]; then + echo "src tarball" fi fi else echo "No package named: $pkg" fi + if [ -f $WOK/$pkg/taz/*/library.list ]; then + echo "library" + else + echo "No library: $pkg" + fi echo '
' # Check for a log file and display summary if it exists. @@ -173,7 +187,7 @@ if fgrep -q "Summary for:" $LOGS/$pkg.log; then echo "

Cook summary

" echo '
'
-				grep -A 9 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
+				grep -A 10 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
 					syntax_highlighter log
 				echo '
' fi @@ -209,6 +223,14 @@ cat $CACHE/$file | sort | \ sed s"#^[^']*#\0#"g echo '' ;; + unbuild) + # Main page with summary. + nb=$(cat $unbuild | wc -l) + echo "

DB: unbuild - Packages: $nb

" + echo '
'
+				cat $CACHE/$file | sort | \
+					sed s"#^[^']*#\0#"g
+				echo '
' ;; *.diff) diff=$CACHE/$file echo "

Diff for: ${file%.diff}

" @@ -239,9 +261,9 @@ receipt=*) pkg=${QUERY_STRING#receipt=} echo "

Receipt for: $pkg

" - if [ -f "$wok/$pkg/receipt" ]; then + if [ -f "$WOK/$pkg/receipt" ]; then echo '
'
-			cat $wok/$pkg/receipt | syntax_highlighter receipt
+			cat $WOK/$pkg/receipt | syntax_highlighter receipt
 			echo '
' else echo "
No receipt for: $pkg
" @@ -258,6 +280,14 @@ else echo "
No files list for: $pkg
" fi ;; + library=*) + pkg=${QUERY_STRING#library=} + echo "

Library for: $pkg

" + if [ -f $WOK/$pkg/taz/*/library.list ]; then + echo '
'
+			cat $WOK/$pkg/taz/*/library.list | sed "s|$pkg	||g" | sed 's| |\n|g' | sed '/^$/d'
+			echo '
' + fi ;; *) # We may have a toolchain.cgi script for cross cooker's if [ -f "toolchain.cgi" ]; then @@ -272,10 +302,14 @@ arm|x86_64) inwok=$(ls $WOK/*/arch.$ARCH | wc -l) ;; *) inwok=$(ls $WOK | wc -l) ;; esac - cooked=$(ls $PKGS/*.tazpkg | wc -l) - unbuilt=$(($inwok - $cooked)) - pct=0 - [ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok )) + pkg_cooked=$(ls $PKGS/*.tazpkg | wc -l) + incoming_cooked=$(ls $INCOMING/*.tazpkg | wc -l) + pkg_unbuilt=$(($inwok - $pkg_cooked)) + incoming_unbuilt=$(($inwok -$incoming_cooked)) + pkg_pct=0 + [ $inwok -gt 0 ] && pkg_pct=$(( ($pkg_cooked * 100) / $inwok )) + incoming_pct=0 + [ $inwok -gt 0 ] && incoming_pct=$(( ($incoming_cooked * 100) / $inwok )) cat << EOT
@@ -293,14 +327,21 @@ Current cooklist : $(cat $cooklist | wc -l) Broken packages : $(cat $broken | wc -l) Blocked packages : $(cat $blocked | wc -l) +Unbuild packages : $(cat $unbuild | wc -l) -

- Packages: $inwok in the wok - $cooked cooked - $unbuilt unbuilt - - Server date: $(date '+%Y-%m-%d %H:%M') +

+ Packages: $inwok in the wok - Server date: $(date '+%Y-%m-%d %H:%M')

+ + $pkg_cooked packages cooked - $pkg_unbuilt unbuilt
-
${pct}%
+
${pkg_pct}%
+
+ + $incoming_cooked incoming packages cooked - $incoming_unbuilt unbuilt +
+
${incoming_pct}%

@@ -315,7 +356,7 @@

Activity

-$(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
+$(tac $activity | head -n 12 | syntax_highlighter activity)
 
More activity @@ -352,15 +393,30 @@ $(cat $blocked | sed s"#^[^']*#\0#"g) + +

Unbuild

+
+$(cat $unbuild | head -n 20)
+
+Unbuild +

Latest cook

+$(list_incoming | sed s"#^\([^']*\).* : #\0#"g)
+
+ +

Latest packages for mirror

+
 $(list_packages | sed s"#^\([^']*\).* : #\0#"g)
 
EOT ;; esac +if [ -f "footer.html" ]; then + cat footer.html +else # Close xHTML page cat << EOT
@@ -375,5 +431,6 @@ EOT +fi exit 0