UpdateDatabase.php
[Pman.Core] / UpdateDatabase.php
index a05fe06..19507af 100644 (file)
@@ -131,6 +131,8 @@ class Pman_Core_UpdateDatabase extends Pman
     {
         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
    
+        $this->checkSystem();
+   
         $ff = HTML_FlexyFramework::get();
         
         $this->disabled = explode(',', $ff->disable);
@@ -390,11 +392,33 @@ class Pman_Core_UpdateDatabase extends Pman
                     continue;
                 }
                 
-                $cmd = "$mysql_cmd -f < " . escapeshellarg($fn) ;
+                $cmd = "$mysql_cmd -f < " . escapeshellarg($fn) ." 2>&1" ;
                 
                 echo basename($dir).'/'. basename($fn) .    '::' .  $cmd. ($this->cli ? "\n" : "<BR>\n");
                 
-                passthru($cmd);
+                
+                $fp = popen($cmd, "r"); 
+                while(!feof($fp)) 
+                { 
+                    // send the current file part to the browser 
+                    $line = trim(fgets($fp, 1024));
+                    $matches = array();
+                    if (!preg_match('/^ERROR\s+([0-9]+)/', $line, $matches)) {
+                        echo "OK - {$line}\n"; flush();
+                        continue;
+                    }
+                    switch($match[1]) {
+                        
+                        
+                    }
+                    // real errors...
+                    // 1051: // Unknown table -- normally drop = add iff exists..
+                    
+                    print_r(array($line,$matches));exit;
+                    
+                    
+                } 
+                
             
                 
         }
@@ -957,4 +981,63 @@ class Pman_Core_UpdateDatabase extends Pman
         }
         
     }
+    
+    
+    function checkSystem()
+    {
+        // most of these are from File_Convert...
+        
+        // these are required - and have simple dependancies.
+        require_once 'System.php';
+        $req = array( 
+            'convert',
+            'grep',
+            'pdfinfo',
+            'pdftoppm',
+            'rsvg-convert',  //librsvg2-bin
+            'strings',
+        );
+         
+         
+         
+        // these are prefered - but may have complicated depenacies
+        $pref= array(
+            'abiword',
+            'faad',
+            'ffmpeg',
+            'html2text', // not availabe in debian squeeze
+            'pdftocairo',  //poppler-utils - not available in debian squeeze.
+
+            'lame',
+            'ssconvert',
+            'unoconv',
+            'wkhtmltopdf',
+            'xvfb-run',
+        );
+        $res = array();
+        $fail = false;
+        foreach($req as $r) {
+            if (!System::which($r)) {
+                $res[] = $r;
+            }
+            $fail = true;
+        }
+        if ($res) {
+            $this->jerr("Missing these programs - need installing\n" . implode("\n",$res));
+        }
+        foreach($pref as $r) {
+            if (!System::which($r)) {
+                $res[] = $r;
+            }
+            $fail = true;
+        }
+        if ($res) {
+            echo "WARNING: Missing these programs - they may need installing\n". implode("\n",$res);
+            sleep(5);
+        }
+        
+        
+    }
+    
+    
 }
\ No newline at end of file