cookutils rev 15

Add debug info if cook error
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 05 05:04:15 2011 +0200 (2011-05-05)
parents 01dfc1ed1e0e
children dcf50aa1bb76
files cook web/cooker.cgi web/style.css
line diff
     1.1 --- a/cook	Thu May 05 03:12:10 2011 +0200
     1.2 +++ b/cook	Thu May 05 05:04:15 2011 +0200
     1.3 @@ -150,7 +150,8 @@
     1.4  	case "$WGET_URL" in
     1.5  		http://*|ftp://*)
     1.6  			# Busybox Wget is better!
     1.7 -			busybox wget -c -P $SRC $WGET_URL ;;
     1.8 +			busybox wget -c -P $SRC $WGET_URL || \
     1.9 +				(echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
    1.10  		hg*|mercurial*)
    1.11  			# We are in cache so clone here and create a tarball
    1.12  			pwd=$(pwd)
    1.13 @@ -163,7 +164,7 @@
    1.14  			tarball=$pkgsrc.tar.bz2
    1.15  			gettext "Getting source from Hg: "; echo $url
    1.16  			gettext "Cloning to: "; echo "$pwd/$pkgsrc"
    1.17 -			hg clone $url $pkgsrc || exit 1
    1.18 +			hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
    1.19  			gettext "Creating tarball: "; echo "$tarball"
    1.20  			tar cjf $tarball $pkgsrc || exit 1
    1.21  			mv $tarball $SRC && rm -rf $pkgsrc ;;
    1.22 @@ -209,6 +210,14 @@
    1.23  EOT
    1.24  }
    1.25  
    1.26 +# Display debugging erroe info.
    1.27 +debug_info() {
    1.28 +	echo "Debug information"
    1.29 +	separator
    1.30 +	fgrep ERROR $LOGS/$pkg.log
    1.31 +	separator && echo ""
    1.32 +}
    1.33 +
    1.34  # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
    1.35  # so some packages need to copy these files with the receipt and genpkg_rules.
    1.36  copy_generic_files()
    1.37 @@ -382,10 +391,15 @@
    1.38  # Cook quality assurance.
    1.39  cookit_quality() {
    1.40  	if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
    1.41 -		echo -e "\nERROR: cook failed\n" | tee -a $LOGS/$pkg.log
    1.42 +		echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
    1.43  	fi
    1.44  	# ERROR can be echoed any time in cookit()
    1.45  	if grep -q ^ERROR $LOGS/$pkg.log; then
    1.46 +		echo ""
    1.47 +		debug_info | tee $CACHE/debug
    1.48 +		# Debug info on top, easier to check errors.
    1.49 +		cat $CACHE/debug $LOGS/$pkg.log > $CACHE/$pkg.debug
    1.50 +		mv -f $CACHE/$pkg.debug $LOGS/$pkg.log
    1.51  		exit 1
    1.52  	fi
    1.53  }
    1.54 @@ -585,7 +599,7 @@
    1.55  
    1.56  		# Cook and pack or exit on error and log everything.
    1.57  		cookit | tee $LOGS/$pkg.log
    1.58 -		remove_deps
    1.59 +		remove_deps | tee -a $LOGS/$pkg.log
    1.60  		cookit_quality
    1.61  		packit | tee -a $LOGS/$pkg.log
    1.62  		clean_log
     2.1 --- a/web/cooker.cgi	Thu May 05 03:12:10 2011 +0200
     2.2 +++ b/web/cooker.cgi	Thu May 05 05:04:15 2011 +0200
     2.3 @@ -30,9 +30,10 @@
     2.4  		-e 's#yes$#<span class="span-ok">yes</span>#g' \
     2.5  		-e 's#no$#<span class="span-no">no</span>#g' \
     2.6  		-e 's#error$#<span class="span-error">error</span>#g' \
     2.7 -		-e 's#ERROR:#<span class="span-error">ERROR</span>#g' \
     2.8 +		-e 's#ERROR:#<span class="span-error">ERROR:</span>#g' \
     2.9  		-e s"#^Executing:\([^']*\).#<span class='span-sky'>\0</span>#"g \
    2.10 -		-e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g
    2.11 +		-e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g \
    2.12 +		-e s"#http://\([^']*\).*#<a href='\0'>\1</a>#"g	
    2.13  }
    2.14  
    2.15  # Latest build pkgs.
    2.16 @@ -74,19 +75,21 @@
    2.17  		pkg=${QUERY_STRING#log=}
    2.18  		if [ -f "$LOGS/$pkg.log" ]; then
    2.19  			echo "<h2>Log for: $pkg</h2>"
    2.20 -			if [ "$pkg" == "commits" ]; then
    2.21 +			if fgrep -q "Summary " $LOGS/$pkg.log; then
    2.22 +				echo '<pre>'
    2.23 +				grep -A 8 "^Summary " $LOGS/$pkg.log | sed /^$/d | \
    2.24 +					syntax_highlighter
    2.25 +				echo '</pre>'
    2.26 +				echo '<pre>'
    2.27 +				cat $LOGS/$pkg.log | syntax_highlighter
    2.28 +				echo '</pre>'
    2.29 +			else
    2.30 +				if fgrep -q "cook:$pkg$" $command; then
    2.31 +					echo "<pre>The Cooker is currently cooking: $pkg</pre>"
    2.32 +				fi
    2.33  				echo '<pre>' && cat $LOGS/$pkg.log | syntax_highlighter
    2.34 -				echo '</pre>' && exit 0
    2.35 +				echo '</pre>'
    2.36  			fi
    2.37 -			echo '<pre>'
    2.38 -			if grep -q "cook:$pkg$" $command; then
    2.39 -				echo "$pkg currently cooking"
    2.40 -			fi
    2.41 -			grep -A 8 "Summary" $LOGS/$pkg.log | sed /^$/d | syntax_highlighter
    2.42 -			echo '</pre>'
    2.43 -			echo '<pre>'
    2.44 -			cat $LOGS/$pkg.log | syntax_highlighter
    2.45 -			echo '</pre>'
    2.46  		else
    2.47  			echo "<pre>No log file found for: $pkg</pre>"
    2.48  		fi ;;
    2.49 @@ -146,7 +149,7 @@
    2.50  </div>
    2.51  
    2.52  <div id="footer">
    2.53 -	<a href="http://www.slitaz.org/">SliTaz Cooker</a>
    2.54 +	<a href="cooker.cgi">SliTaz Cooker</a>
    2.55  </div>
    2.56  
    2.57  </body>
     3.1 --- a/web/style.css	Thu May 05 03:12:10 2011 +0200
     3.2 +++ b/web/style.css	Thu May 05 05:04:15 2011 +0200
     3.3 @@ -10,6 +10,7 @@
     3.4  	border: 1px solid #ddd;
     3.5  	padding: 10px;
     3.6  	border-radius: 4px;
     3.7 +	overflow: auto;
     3.8  }
     3.9  
    3.10  #header {
    3.11 @@ -27,6 +28,7 @@
    3.12  	text-align: center;
    3.13  	padding: 20px;
    3.14  	border-top: 1px solid #ddd;
    3.15 +	font-size: 90%;
    3.16  }
    3.17  
    3.18  .span-ok { color: green; }