Show
Ignore:
Timestamp:
12/07/11 14:22:24 (1 year ago)
Author:
p_lindheimer
Message:

extend run_cmd to beable to execute and print some commands in debug mode, allow it to pass back the return value of the system command through an optional reference variable since it returns the ret_val of the underlying system command, make php checking always happen and check all files in a module then check if it was suppose to check and if so bail, and add .agi as a php extension

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.10/package.php

    r13001 r13002  
    150150   
    151151  //check php files for syntax errors 
    152   if ($vars['checkphp']) { 
    153     var_dump($tar_dir); 
    154     $files = package_scandirr($tar_dir, true, $file_scan_exclude_list); 
    155     foreach ($files as $f) { 
    156       if (pathinfo($f, PATHINFO_EXTENSION) == 'php') { 
    157         $ret_val = 0; 
    158          
    159         if (!run_cmd($vars['php_-l'] . ' ' . $f)) { 
    160           echo('syntax error detected in ' . $f . ', ' .  $mod . ' won\'t be packaged' . PHP_EOL); 
    161           continue 2; 
    162         } 
     152  $bail = false; 
     153  $files = package_scandirr($tar_dir, true, $file_scan_exclude_list); 
     154  foreach ($files as $f) { 
     155    if (pathinfo($f, PATHINFO_EXTENSION) == 'php' || pathinfo($f, PATHINFO_EXTENSION) == 'agi') { 
     156      if (!run_cmd($vars['php_-l'] . ' ' . $f, $outline, false, true)) { 
     157        echo('syntax error detected in ' . $f . ', ' .  $mod . ' won\'t be packaged' . PHP_EOL); 
     158        $bail=true; // finish scanning all files before bailing 
    163159      } 
    164160    } 
    165     unset($files, $list); 
     161  } 
     162  unset($files, $list); 
     163  if ($bail && $vars['checkphp']) { 
     164    echo('syntax error detecteded in ' .  $mod . ' skipping packaging going to next' . PHP_EOL); 
     165    continue; 
    166166  } 
    167167   
    168168  //check in any out standing files 
    169   if (run_cmd('svn st ' . $mod_dir . '|wc -l') > 0) { 
     169  run_cmd('svn st ' . $mod_dir . '|wc -l', $lines); 
     170  if ( $lines > 0) { 
    170171    run_cmd('svn ci -m "Auto Check-in of any outstanding changes in ' . $mod . '" ' . $mod_dir); 
    171172  } 
     
    214215   
    215216  //set latpublished property 
    216   $lastpub = run_cmd('svn info ' . $mod_dir . ' | grep Revision: | awk \'{print $2}\''); 
     217  run_cmd('svn info ' . $mod_dir . ' | grep Revision: | awk \'{print $2}\'', $lastpub, false, true); 
    217218  run_cmd('svn ps lastpublish ' . $lastpub . ' ' . $mod_dir); 
    218219   
     
    283284} 
    284285 
    285 function run_cmd($cmd, $quiet = false) { 
     286// if $duplex set to true and in debug mode, it will echo the command AND run it 
     287function run_cmd($cmd, &$outline='', $quiet = false, $duplex = false) { 
    286288  global $vars; 
    287289  $quiet = $quiet ? ' > /dev/null' : ''; 
     
    289291  if ($vars['debug']) { 
    290292    echo $cmd . PHP_EOL; 
    291     return true; 
    292   } elseif($vars['verbose']) { 
     293    if (!$duplex) { 
     294      return true; 
     295    } 
     296  } 
     297  if ($vars['verbose']) { 
    293298    $bt = debug_backtrace(); 
    294299    echo PHP_EOL . '+' . $bt[0]["file"] . ':' . $bt[0]["line"] . PHP_EOL; 
    295300    echo "\t" . $cmd . PHP_EOL; 
    296     system($cmd . $quiet, $ret_val); 
     301    $outline = system($cmd . $quiet, $ret_val); 
    297302  } else { 
    298     system($cmd . $quiet, $ret_val); 
     303    $outline = system($cmd . $quiet, $ret_val); 
    299304  } 
    300305  return ($ret_val == 0);