cookutils diff web/cooker.cgi @ rev 17

Improve debug info and syntax highlither
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 05 17:45:44 2011 +0200 (2011-05-05)
parents dcf50aa1bb76
children 58496d7c2c18
line diff
     1.1 --- a/web/cooker.cgi	Thu May 05 17:05:19 2011 +0200
     1.2 +++ b/web/cooker.cgi	Thu May 05 17:45:44 2011 +0200
     1.3 @@ -26,17 +26,21 @@
     1.4  
     1.5  # Put some colors in log and DB files.
     1.6  syntax_highlighter() {
     1.7 -	sed -e 's#OK$#<span class="span-ok">OK</span>#g' \
     1.8 -		-e 's#yes$#<span class="span-ok">yes</span>#g' \
     1.9 -		-e 's#no$#<span class="span-no">no</span>#g' \
    1.10 -		-e 's#error$#<span class="span-error">error</span>#g' \
    1.11 -		-e 's#ERROR:#<span class="span-error">ERROR:</span>#g' \
    1.12 -		-e s"#^Executing:\([^']*\).#<span class='span-sky'>\0</span>#"g \
    1.13 -		-e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g \
    1.14 -		-e s"#ftp://\([^']*\).*#<a href='\0'>\0</a>#"g	\
    1.15 -		-e s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g \
    1.16 -		-e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g 
    1.17 -		#-e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g
    1.18 +	case $1 in
    1.19 +		log)
    1.20 +			sed -e 's#OK$#<span class="span-ok">OK</span>#g' \
    1.21 +				-e 's#yes$#<span class="span-ok">yes</span>#g' \
    1.22 +				-e 's#no$#<span class="span-no">no</span>#g' \
    1.23 +				-e 's#error$#<span class="span-error">error</span>#g' \
    1.24 +				-e 's#ERROR:#<span class="span-error">ERROR:</span>#g' \
    1.25 +				-e s"#^Executing:\([^']*\).#<span class='span-sky'>\0</span>#"g \
    1.26 +				-e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g \
    1.27 +				-e s"#ftp://\([^']*\).*#<a href='\0'>\0</a>#"g	\
    1.28 +				-e s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g ;;
    1.29 +		receipt)
    1.30 +			sed -e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g \
    1.31 +				-e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g ;;
    1.32 +	esac
    1.33  }
    1.34  
    1.35  # Latest build pkgs.
    1.36 @@ -102,16 +106,20 @@
    1.37  					echo "<h3>Cook summary</h3>"
    1.38  					echo '<pre>'
    1.39  					grep -A 8 "^Summary " $LOGS/$pkg.log | sed /^$/d | \
    1.40 -						syntax_highlighter
    1.41 +						syntax_highlighter log
    1.42  					echo '</pre>'
    1.43  				fi
    1.44  			fi
    1.45 -			if fgrep -q "ERROR:" $LOGS/$pkg.log; then
    1.46 -				fgrep "ERROR:" $LOGS/$pkg.log
    1.47 +			if fgrep -q "Debug " $LOGS/$pkg.log; then
    1.48 +				echo "<h3>Cook failed</h3>"
    1.49 +				echo '<pre>'
    1.50 +				grep -A 8 "^Debug " $LOGS/$pkg.log | sed /^$/d | \
    1.51 +						syntax_highlighter log
    1.52 +				echo '</pre>'
    1.53  			fi
    1.54  			echo "<h3>Cook log</h3>"
    1.55  			echo '<pre>'
    1.56 -			cat $log | syntax_highlighter
    1.57 +			cat $log | syntax_highlighter log
    1.58  			echo '</pre>'
    1.59  		else
    1.60  			echo "<pre>No log: $pkg</pre>"
    1.61 @@ -122,17 +130,17 @@
    1.62  		echo "<h2>Log for: $log</h2>"
    1.63  		if [ -f "$LOGS/$log.log" ]; then
    1.64  			echo '<pre>'
    1.65 -			cat $file | syntax_highlighter
    1.66 +			cat $file | syntax_highlighter log
    1.67  			echo '</pre>'
    1.68  		else
    1.69  			echo "<pre>No log for: $log</pre>"
    1.70  		fi ;;
    1.71  	receipt=*)
    1.72  		pkg=${QUERY_STRING#receipt=}
    1.73 -		echo "<h2>Receipt: $pkg</h2>"
    1.74 +		echo "<h2>Receipt for: $pkg</h2>"
    1.75  		if [ -f "$wok/$pkg/receipt" ]; then
    1.76  			echo '<pre>'
    1.77 -			cat $wok/$pkg/receipt | syntax_highlighter
    1.78 +			cat $wok/$pkg/receipt | syntax_highlighter receipt
    1.79  			echo '</pre>'
    1.80  		else
    1.81  			echo "<pre>No receipt for: $log</pre>"