buildlogs: index.php Tail more is no more 100 last lines. It is not 'from t...

arekm arekm at pld-linux.org
Sun Oct 12 23:27:11 CEST 2014


Author: arekm                        Date: Sun Oct 12 21:27:11 2014 GMT
Module: buildlogs                     Tag: HEAD
---- Log message:
Tail more is no more 100 last lines. It is not 'from the first error until the end'. Catch 'undefined reference to' errors.

---- Files affected:
buildlogs:
   index.php (1.25 -> 1.26) 

---- Diffs:

================================================================
Index: buildlogs/index.php
diff -u buildlogs/index.php:1.25 buildlogs/index.php:1.26
--- buildlogs/index.php:1.25	Mon Sep 30 19:46:32 2013
+++ buildlogs/index.php	Sun Oct 12 23:27:06 2014
@@ -350,51 +350,67 @@
 	}
 
 	$cmd = "$filter '$root_directory/$f'";
-	if ($tail)
-		$cmd = "$cmd | tail -n 100";
 	$fd = popen($cmd, "r");
 	$toc = array();
-	ob_start();
+	$err = array();
 	$err_count = 0;
 	$time = "";
+	$out_buf = array();
 	while (($s = fgets($fd, 102400)) != false) {
 		if (strlen($s) > 800) {
 			$s = chunk_split($s, 800, "\n    ");
 			$s = trim($s);
 		}
+
+		$toc_elem = false;
+		$err_elem = false;
+
 		$s = htmlspecialchars($s);
 		// highlight errors
 		if (preg_match("/(?:fail|error(s|\sCS\d+)?):/i", $s)) {
 			$err_count++;
-			$toc[] = "error $err_count";
-			$err[] = $s;
+			$toc_elem = "error $err_count";
+			$err_elem = $s;
+			$s = "<span class=error id=error-$err_count>$s</span>";
+		} elseif (preg_match("/(?:undefined reference to)/i", $s)) {
+			$err_count++;
+			$toc_elem = "error $err_count";
+			$err_elem = $s;
 			$s = "<span class=error id=error-$err_count>$s</span>";
 		} elseif (preg_match("#^\+ /usr/bin/make\b.*\b(?P<target>check)\b#", $s, $m)) {
 			// rpm build section
-			$toc[] = "make {$m['target']}";
-			$err[] = $s;
+			$toc_elem = "make {$m['target']}";
+			$err_elem = $s;
 			$s = "<span class=line id=make-{$m['target']}>$s</span>";
 		} elseif (substr($s, 0, 2) == "+ ") {
 			// shell verbose
 			$s = "<span class=verbose>$s</span>";
 		} elseif (preg_match("/^Executing\(%(?P<section>\w+)\)/", $s, $m)) {
 			// rpm build section
-			$toc[] = $m['section'];
-			$err[] = $s;
+			$toc_elem = $m['section'];
+			$err_elem = $s;
 			$s = "<span class=section id={$m['section']}>$s</span>";
 		} elseif (preg_match("/^Processing files: (?P<pkg>(?P<name>.+)-[^-]+-[^-]+)/", $s, $m)) {
 			// processing files
-			$toc[] = "files ".$m['name'];
-			$err[] = $s;
+			$toc_elem = "files ".$m['name'];
+			$err_elem = $s;
 			$s = "<span class=section id=files-{$m['name']}>$s</span>";
 		} elseif (preg_match("/^ended at: (?P<date>.+), done in (?P<time>[\d:.]+)/", $s, $m)) {
 			$time = $m['time'];
 		}
-		echo $s;
+
+		// if (not in tail mode) or (in tail mode but we have an error)
+		if ($err_count || !$tail) {
+			if ($toc_elem)
+				$toc[] = $toc_elem;
+			if ($err_elem)
+				$err[] = $err_elem;
+			$out_buf[] = $s;
+		}
 	}
 	pclose($fd);
-	$code = ob_get_contents();
-	ob_end_clean();
+
+	$code = join(' ', $out_buf);
 
 	if ($time) {
 		one_item(_("Runtime"), $time);
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/buildlogs/index.php?r1=1.25&r2=1.26



More information about the pld-cvs-commit mailing list