@@ -10,10 +10,13 @@ discard block |
||
| 10 | 10 | * @version $Id$ |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
| 13 | +if (php_sapi_name() !== 'cli') |
|
| 14 | +{ |
|
| 15 | + // security precaution: forbit calling setup-cli as web-page |
|
| 14 | 16 | { |
| 15 | 17 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 16 | 18 | } |
| 19 | +} |
|
| 17 | 20 | date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
| 18 | 21 | |
| 19 | 22 | $verbose = 0; |
@@ -135,7 +138,10 @@ discard block |
||
| 135 | 138 | case 'release': |
| 136 | 139 | case 'copychangelog': |
| 137 | 140 | $config[$name] = $value; |
| 138 | - if ($value) array_unshift($config['run'],$name); |
|
| 141 | + if ($value) |
|
| 142 | + { |
|
| 143 | + array_unshift($config['run'],$name); |
|
| 144 | + } |
|
| 139 | 145 | break; |
| 140 | 146 | |
| 141 | 147 | case 'editchangelog': |
@@ -151,7 +157,10 @@ discard block |
||
| 151 | 157 | { |
| 152 | 158 | usage("Path '$value' not found!"); |
| 153 | 159 | } |
| 154 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
| 160 | + if (!in_array('obs',$config['run'])) |
|
| 161 | + { |
|
| 162 | + $config['run'][] = 'obs'; |
|
| 163 | + } |
|
| 155 | 164 | // fall through |
| 156 | 165 | default: |
| 157 | 166 | $config[$name] = $value; |
@@ -209,7 +218,10 @@ discard block |
||
| 209 | 218 | } |
| 210 | 219 | |
| 211 | 220 | $cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD'); |
| 212 | - if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd; |
|
| 221 | + if (getcwd() != $path) |
|
| 222 | + { |
|
| 223 | + $cmd = 'cd '.$path.'; '.$cmd; |
|
| 224 | + } |
|
| 213 | 225 | $output = null; |
| 214 | 226 | run_cmd($cmd, $output); |
| 215 | 227 | |
@@ -240,7 +252,10 @@ discard block |
||
| 240 | 252 | { |
| 241 | 253 | global $config, $verbose; |
| 242 | 254 | |
| 243 | - if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
| 255 | + if ($verbose) |
|
| 256 | + { |
|
| 257 | + echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
| 258 | + } |
|
| 244 | 259 | |
| 245 | 260 | if (!is_dir($config['checkoutdir'])) |
| 246 | 261 | { |
@@ -271,12 +286,21 @@ discard block |
||
| 271 | 286 | elseif (isset($module) && preg_match('/^checkout\s*=\s*(git\s+clone\s+(-b\s+[0-9.]+\s+)?((git|http)[^ ]+)|svn\s+checkout\s+((svn|http)[^ ]+))/', $line, $matches)) |
| 272 | 287 | { |
| 273 | 288 | $repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[5] : $matches[3]; |
| 274 | - if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
| 289 | + if (substr($matches[1], 0, 3) == 'svn') |
|
| 290 | + { |
|
| 291 | + $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
| 292 | + } |
|
| 275 | 293 | $modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url; |
| 276 | - if ($module === '' && !isset($baseurl)) $baseurl = str_replace('/egroupware.git', '', $url); |
|
| 294 | + if ($module === '' && !isset($baseurl)) |
|
| 295 | + { |
|
| 296 | + $baseurl = str_replace('/egroupware.git', '', $url); |
|
| 297 | + } |
|
| 277 | 298 | } |
| 278 | 299 | } |
| 279 | - if ($verbose) print_r($modules); |
|
| 300 | + if ($verbose) |
|
| 301 | + { |
|
| 302 | + print_r($modules); |
|
| 303 | + } |
|
| 280 | 304 | return $modules; |
| 281 | 305 | } |
| 282 | 306 | |
@@ -343,7 +367,11 @@ discard block |
||
| 343 | 367 | |
| 344 | 368 | $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
| 345 | 369 | |
| 346 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
| 370 | + if (empty($config['tag'])) |
|
| 371 | + { |
|
| 372 | + return; |
|
| 373 | + } |
|
| 374 | + // otherwise we copy everything in svn root! |
|
| 347 | 375 | |
| 348 | 376 | echo "Creating tag $config[tag]\n"; |
| 349 | 377 | |
@@ -359,7 +387,10 @@ discard block |
||
| 359 | 387 | global $config,$verbose; |
| 360 | 388 | |
| 361 | 389 | // push local changes to Github incl. tags |
| 362 | - if ($verbose) echo "Pushing changes and tags\n"; |
|
| 390 | + if ($verbose) |
|
| 391 | + { |
|
| 392 | + echo "Pushing changes and tags\n"; |
|
| 393 | + } |
|
| 363 | 394 | chdir($config['checkoutdir']); |
| 364 | 395 | run_cmd($config['mr']. ' up'); // in case someone else pushed something |
| 365 | 396 | chdir($config['checkoutdir']); |
@@ -421,7 +452,10 @@ discard block |
||
| 421 | 452 | { |
| 422 | 453 | $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
| 423 | 454 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
| 424 | - if ($verbose) echo $cmd."\n"; |
|
| 455 | + if ($verbose) |
|
| 456 | + { |
|
| 457 | + echo $cmd."\n"; |
|
| 458 | + } |
|
| 425 | 459 | passthru($cmd); |
| 426 | 460 | } |
| 427 | 461 | } |
@@ -454,25 +488,40 @@ discard block |
||
| 454 | 488 | { |
| 455 | 489 | case 'POST': |
| 456 | 490 | curl_setopt($c, CURLOPT_POST, true); |
| 457 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 491 | + if (is_array($data)) |
|
| 492 | + { |
|
| 493 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 494 | + } |
|
| 458 | 495 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 459 | 496 | break; |
| 460 | 497 | case 'GET': |
| 461 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 498 | + if(count($data)) |
|
| 499 | + { |
|
| 500 | + $url .= '?' . http_build_query($data); |
|
| 501 | + } |
|
| 462 | 502 | break; |
| 463 | 503 | case 'FILE': |
| 464 | 504 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 465 | 505 | curl_setopt($c, CURLOPT_POST, true); |
| 466 | 506 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 467 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 507 | + if(count($data)) |
|
| 508 | + { |
|
| 509 | + $url .= '?' . http_build_query($data); |
|
| 510 | + } |
|
| 468 | 511 | break; |
| 469 | 512 | default: |
| 470 | 513 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 471 | 514 | } |
| 472 | 515 | curl_setopt($c, CURLOPT_URL, $url); |
| 473 | 516 | |
| 474 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 475 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 517 | + if (is_string($data)) |
|
| 518 | + { |
|
| 519 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 520 | + } |
|
| 521 | + if ($verbose) |
|
| 522 | + { |
|
| 523 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 524 | + } |
|
| 476 | 525 | |
| 477 | 526 | if (($response = curl_exec($c)) === false) |
| 478 | 527 | { |
@@ -483,7 +532,10 @@ discard block |
||
| 483 | 532 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 484 | 533 | } |
| 485 | 534 | |
| 486 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 535 | + if ($verbose) |
|
| 536 | + { |
|
| 537 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 538 | + } |
|
| 487 | 539 | |
| 488 | 540 | curl_close($c); |
| 489 | 541 | |
@@ -500,13 +552,19 @@ discard block |
||
| 500 | 552 | { |
| 501 | 553 | global $config; |
| 502 | 554 | |
| 503 | - if (!isset($value)) $value = $config[$name]; |
|
| 555 | + if (!isset($value)) |
|
| 556 | + { |
|
| 557 | + $value = $config[$name]; |
|
| 558 | + } |
|
| 504 | 559 | if (is_string($value) && strpos($value, '$') !== false) |
| 505 | 560 | { |
| 506 | 561 | $translate = array(); |
| 507 | 562 | foreach($config as $n => $val) |
| 508 | 563 | { |
| 509 | - if (is_string($val)) $translate['$'.$n] = $val; |
|
| 564 | + if (is_string($val)) |
|
| 565 | + { |
|
| 566 | + $translate['$'.$n] = $val; |
|
| 567 | + } |
|
| 510 | 568 | } |
| 511 | 569 | $value = strtr($value, $translate); |
| 512 | 570 | } |
@@ -608,7 +666,10 @@ discard block |
||
| 608 | 666 | if (is_null($revision)) |
| 609 | 667 | { |
| 610 | 668 | list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
| 611 | - if (empty($branch)) $branch = $config['version']; |
|
| 669 | + if (empty($branch)) |
|
| 670 | + { |
|
| 671 | + $branch = $config['version']; |
|
| 672 | + } |
|
| 612 | 673 | $tags_url .= '/tags'; |
| 613 | 674 | $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
| 614 | 675 | $matches = null; |
@@ -634,11 +695,18 @@ discard block |
||
| 634 | 695 | $message = ''; |
| 635 | 696 | foreach($xml as $log) |
| 636 | 697 | { |
| 637 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
| 698 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) |
|
| 699 | + { |
|
| 700 | + continue; |
|
| 701 | + } |
|
| 702 | + // no match --> ignore |
|
| 638 | 703 | |
| 639 | 704 | $message .= $msg."\n"; |
| 640 | 705 | } |
| 641 | - if ($verbose) echo $message; |
|
| 706 | + if ($verbose) |
|
| 707 | + { |
|
| 708 | + echo $message; |
|
| 709 | + } |
|
| 642 | 710 | |
| 643 | 711 | return $message; |
| 644 | 712 | } |
@@ -669,7 +737,10 @@ discard block |
||
| 669 | 737 | { |
| 670 | 738 | return null; |
| 671 | 739 | } |
| 672 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
| 740 | + if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) |
|
| 741 | + { |
|
| 742 | + $msg = $prefix.$msg; |
|
| 743 | + } |
|
| 673 | 744 | |
| 674 | 745 | return $msg; |
| 675 | 746 | } |
@@ -706,7 +777,10 @@ discard block |
||
| 706 | 777 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
| 707 | 778 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
| 708 | 779 | { |
| 709 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 780 | + if ($verbose) |
|
| 781 | + { |
|
| 782 | + echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 783 | + } |
|
| 710 | 784 | return (int)$log['revision']; |
| 711 | 785 | } |
| 712 | 786 | } |
@@ -726,7 +800,10 @@ discard block |
||
| 726 | 800 | { |
| 727 | 801 | usage("Path '$config[obs]' not found!"); |
| 728 | 802 | } |
| 729 | - if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
| 803 | + if ($verbose) |
|
| 804 | + { |
|
| 805 | + echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
| 806 | + } |
|
| 730 | 807 | run_cmd('osc up '.$config['obs']); |
| 731 | 808 | |
| 732 | 809 | $n = 0; |
@@ -746,10 +823,16 @@ discard block |
||
| 746 | 823 | if (basename($path) != basename($new_name)) |
| 747 | 824 | { |
| 748 | 825 | unlink($path); |
| 749 | - if ($verbose) echo "rm $path\n"; |
|
| 826 | + if ($verbose) |
|
| 827 | + { |
|
| 828 | + echo "rm $path\n"; |
|
| 829 | + } |
|
| 750 | 830 | } |
| 751 | 831 | copy($new_name,dirname($path).'/'.basename($new_name)); |
| 752 | - if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
|
| 832 | + if ($verbose) |
|
| 833 | + { |
|
| 834 | + echo "cp $new_name ".dirname($path)."/\n"; |
|
| 835 | + } |
|
| 753 | 836 | ++$n; |
| 754 | 837 | } |
| 755 | 838 | // if we have no changelog (eg. because commands run separate), try parsing it from changelog file |
@@ -787,7 +870,10 @@ discard block |
||
| 787 | 870 | if ($content != $content_was) |
| 788 | 871 | { |
| 789 | 872 | file_put_contents($path,$content); |
| 790 | - if ($verbose) echo "Updated $path\n"; |
|
| 873 | + if ($verbose) |
|
| 874 | + { |
|
| 875 | + echo "Updated $path\n"; |
|
| 876 | + } |
|
| 791 | 877 | ++$n; |
| 792 | 878 | } |
| 793 | 879 | } |
@@ -825,9 +911,12 @@ discard block |
||
| 825 | 911 | } |
| 826 | 912 | $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
| 827 | 913 | $logentry = ''; |
| 828 | - while($lines[$n]) // entry is terminated by empty line |
|
| 914 | + while($lines[$n]) |
|
| 915 | + { |
|
| 916 | + // entry is terminated by empty line |
|
| 829 | 917 | { |
| 830 | 918 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
| 919 | + } |
|
| 831 | 920 | ++$n; |
| 832 | 921 | } |
| 833 | 922 | return substr($logentry, 0, -1); // remove training "\n" |
@@ -848,7 +937,10 @@ discard block |
||
| 848 | 937 | |
| 849 | 938 | list($header) = explode("\n", $content); |
| 850 | 939 | $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
| 851 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
| 940 | + if (substr($config['changelog'],0,2) != ' ') |
|
| 941 | + { |
|
| 942 | + $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
| 943 | + } |
|
| 852 | 944 | $content = $new_header."\n\n".$config['changelog']. |
| 853 | 945 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
| 854 | 946 | |
@@ -862,10 +954,13 @@ discard block |
||
| 862 | 954 | { |
| 863 | 955 | global $config; |
| 864 | 956 | |
| 865 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 957 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
| 958 | + { |
|
| 959 | + // sha1_file cant deal with '~/rpm' |
|
| 866 | 960 | { |
| 867 | 961 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
| 868 | 962 | } |
| 963 | + } |
|
| 869 | 964 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 870 | 965 | |
| 871 | 966 | if (!file_exists($sumsfile)) |
@@ -876,11 +971,17 @@ discard block |
||
| 876 | 971 | // signing it |
| 877 | 972 | if (empty($config['gpg']) || !file_exists($config['gpg'])) |
| 878 | 973 | { |
| 879 | - if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
| 974 | + if (!empty($config['gpg'])) |
|
| 975 | + { |
|
| 976 | + echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
| 977 | + } |
|
| 880 | 978 | return; |
| 881 | 979 | } |
| 882 | 980 | echo "Signing sha1sum file:\n"; |
| 883 | - if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
|
| 981 | + if (file_exists($sumsfile.'.asc')) |
|
| 982 | + { |
|
| 983 | + unlink($sumsfile.'.asc'); |
|
| 984 | + } |
|
| 884 | 985 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
| 885 | 986 | run_cmd($cmd); |
| 886 | 987 | unlink($sumsfile); // delete the unsigned file |
@@ -893,11 +994,17 @@ discard block |
||
| 893 | 994 | { |
| 894 | 995 | global $config; |
| 895 | 996 | |
| 896 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
| 897 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 997 | + if (!file_exists($config['sourcedir'])) |
|
| 998 | + { |
|
| 999 | + mkdir($config['sourcedir'],0755,true); |
|
| 1000 | + } |
|
| 1001 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
| 1002 | + { |
|
| 1003 | + // sha1_file cant deal with '~/rpm' |
|
| 898 | 1004 | { |
| 899 | 1005 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
| 900 | 1006 | } |
| 1007 | + } |
|
| 901 | 1008 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 902 | 1009 | $sums = ''; |
| 903 | 1010 | |
@@ -935,12 +1042,22 @@ discard block |
||
| 935 | 1042 | { |
| 936 | 1043 | foreach((array)$config['all-add'] as $add) |
| 937 | 1044 | { |
| 938 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
| 939 | - if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
|
| 1045 | + if (substr($add, -4) != '.tar') |
|
| 1046 | + { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 1049 | + // probably a module |
|
| 1050 | + if (!($tar = realpath($add))) |
|
| 1051 | + { |
|
| 1052 | + throw new Exception("File '$add' not found!"); |
|
| 1053 | + } |
|
| 940 | 1054 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
| 941 | 1055 | } |
| 942 | 1056 | } |
| 943 | - if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2'; |
|
| 1057 | + if (file_exists($file.'.bz2')) |
|
| 1058 | + { |
|
| 1059 | + $cmd .= '; rm -f '.$file.'.bz2'; |
|
| 1060 | + } |
|
| 944 | 1061 | $cmd .= '; '.$config['bzip2'].' '.$file; |
| 945 | 1062 | // run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it |
| 946 | 1063 | run_cmd($cmd); |
@@ -961,7 +1078,10 @@ discard block |
||
| 961 | 1078 | |
| 962 | 1079 | foreach($config['extra'] as $name => $modules) |
| 963 | 1080 | { |
| 964 | - if (is_numeric($name)) $name = $modules; |
|
| 1081 | + if (is_numeric($name)) |
|
| 1082 | + { |
|
| 1083 | + $name = $modules; |
|
| 1084 | + } |
|
| 965 | 1085 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
| 966 | 1086 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
| 967 | 1087 | switch($type) |
@@ -1002,7 +1122,10 @@ discard block |
||
| 1002 | 1122 | { |
| 1003 | 1123 | echo "Updating virus signatures\n"; |
| 1004 | 1124 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
| 1005 | - if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
|
| 1125 | + if (!$verbose && function_exists('posix_getuid') && posix_getuid()) |
|
| 1126 | + { |
|
| 1127 | + echo $cmd."\n"; |
|
| 1128 | + } |
|
| 1006 | 1129 | $output = null; |
| 1007 | 1130 | run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
| 1008 | 1131 | } |
@@ -1030,7 +1153,10 @@ discard block |
||
| 1030 | 1153 | } |
| 1031 | 1154 | |
| 1032 | 1155 | // we need to stash uncommited changes like .mrconfig, before copying |
| 1033 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash"); |
|
| 1156 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
| 1157 | + { |
|
| 1158 | + run_cmd("cd $config[checkoutdir]; git stash"); |
|
| 1159 | + } |
|
| 1034 | 1160 | |
| 1035 | 1161 | try { |
| 1036 | 1162 | $cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/'; |
@@ -1039,8 +1165,14 @@ discard block |
||
| 1039 | 1165 | catch (Exception $e) { |
| 1040 | 1166 | // catch failures to pop stash, before throwing exception |
| 1041 | 1167 | } |
| 1042 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop"); |
|
| 1043 | - if (isset($e)) throw $e; |
|
| 1168 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
| 1169 | + { |
|
| 1170 | + run_cmd("git stash pop"); |
|
| 1171 | + } |
|
| 1172 | + if (isset($e)) |
|
| 1173 | + { |
|
| 1174 | + throw $e; |
|
| 1175 | + } |
|
| 1044 | 1176 | |
| 1045 | 1177 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
| 1046 | 1178 | { |
@@ -1125,9 +1257,12 @@ discard block |
||
| 1125 | 1257 | if ($ret || substr($line,0,5) == 'URL: ') |
| 1126 | 1258 | { |
| 1127 | 1259 | $url = substr($line,5); |
| 1128 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
| 1260 | + if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) |
|
| 1261 | + { |
|
| 1262 | + // wrong branch (or no svn dir) |
|
| 1129 | 1263 | { |
| 1130 | 1264 | echo "Checkout is of wrong branch --> deleting it\n"; |
| 1265 | + } |
|
| 1131 | 1266 | system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
| 1132 | 1267 | clearstatcache(); |
| 1133 | 1268 | } |
@@ -1174,19 +1309,31 @@ discard block |
||
| 1174 | 1309 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
| 1175 | 1310 | $url = $svnbranch.'/'.$config['svnalias']; |
| 1176 | 1311 | $cmd = $svn.' propget svn:externals --strict '.$url; |
| 1177 | - if ($verbose) echo $cmd."\n"; |
|
| 1312 | + if ($verbose) |
|
| 1313 | + { |
|
| 1314 | + echo $cmd."\n"; |
|
| 1315 | + } |
|
| 1178 | 1316 | $output = $ret = null; |
| 1179 | 1317 | exec($cmd,$output,$ret); |
| 1180 | 1318 | $config['modules'] = array(); |
| 1181 | 1319 | foreach($output as $line) |
| 1182 | 1320 | { |
| 1183 | 1321 | $line = trim($line); |
| 1184 | - if (empty($line) || $line[0] == '#') continue; |
|
| 1322 | + if (empty($line) || $line[0] == '#') |
|
| 1323 | + { |
|
| 1324 | + continue; |
|
| 1325 | + } |
|
| 1185 | 1326 | list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
| 1186 | 1327 | $matches = null; |
| 1187 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1328 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
| 1329 | + { |
|
| 1330 | + die("Invalid SVN URL: $url\n"); |
|
| 1331 | + } |
|
| 1188 | 1332 | $repo = $matches[1]; |
| 1189 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1333 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
| 1334 | + { |
|
| 1335 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1336 | + } |
|
| 1190 | 1337 | $config['modules'][$repo][$path] = $url; |
| 1191 | 1338 | } |
| 1192 | 1339 | // process extra modules |
@@ -1195,13 +1342,25 @@ discard block |
||
| 1195 | 1342 | $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
| 1196 | 1343 | $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
| 1197 | 1344 | $url .= $module; |
| 1198 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
| 1199 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1345 | + if (strpos($module,'://') !== false) |
|
| 1346 | + { |
|
| 1347 | + $module = basename($module); |
|
| 1348 | + } |
|
| 1349 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
| 1350 | + { |
|
| 1351 | + die("Invalid SVN URL: $url\n"); |
|
| 1352 | + } |
|
| 1200 | 1353 | $repo = $matches[1]; |
| 1201 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1354 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
| 1355 | + { |
|
| 1356 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1357 | + } |
|
| 1202 | 1358 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
| 1203 | 1359 | } |
| 1204 | - if ($verbose) print_r($config['modules']); |
|
| 1360 | + if ($verbose) |
|
| 1361 | + { |
|
| 1362 | + print_r($config['modules']); |
|
| 1363 | + } |
|
| 1205 | 1364 | return $config['modules']; |
| 1206 | 1365 | } |
| 1207 | 1366 | |
@@ -1212,7 +1371,11 @@ discard block |
||
| 1212 | 1371 | { |
| 1213 | 1372 | global $config,$svn; |
| 1214 | 1373 | |
| 1215 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
| 1374 | + if (empty($config['svntag'])) |
|
| 1375 | + { |
|
| 1376 | + return; |
|
| 1377 | + } |
|
| 1378 | + // otherwise we copy everything in svn root! |
|
| 1216 | 1379 | |
| 1217 | 1380 | $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
| 1218 | 1381 | |
@@ -1251,11 +1414,17 @@ discard block |
||
| 1251 | 1414 | { |
| 1252 | 1415 | $output[] = $cmd; |
| 1253 | 1416 | exec($cmd,$output,$ret); |
| 1254 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
| 1417 | + if ($verbose) |
|
| 1418 | + { |
|
| 1419 | + echo implode("\n",$output)."\n"; |
|
| 1420 | + } |
|
| 1255 | 1421 | } |
| 1256 | 1422 | if ($ret && !in_array($ret,(array)$no_bailout)) |
| 1257 | 1423 | { |
| 1258 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
| 1424 | + if (!$verbose) |
|
| 1425 | + { |
|
| 1426 | + echo implode("\n",$output)."\n"; |
|
| 1427 | + } |
|
| 1259 | 1428 | throw new Exception("Error during '$cmd' --> aborting",$ret); |
| 1260 | 1429 | } |
| 1261 | 1430 | return $ret; |
@@ -1301,7 +1470,10 @@ discard block |
||
| 1301 | 1470 | echo "options and their defaults:\n"; |
| 1302 | 1471 | if ($verbose) |
| 1303 | 1472 | { |
| 1304 | - if (!isset($config['modules'])) $config['modules'] = get_modules_per_repo(); |
|
| 1473 | + if (!isset($config['modules'])) |
|
| 1474 | + { |
|
| 1475 | + $config['modules'] = get_modules_per_repo(); |
|
| 1476 | + } |
|
| 1305 | 1477 | } |
| 1306 | 1478 | else |
| 1307 | 1479 | { |
@@ -1309,7 +1481,10 @@ discard block |
||
| 1309 | 1481 | } |
| 1310 | 1482 | foreach($config as $name => $default) |
| 1311 | 1483 | { |
| 1312 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
| 1484 | + if (is_array($default)) |
|
| 1485 | + { |
|
| 1486 | + $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
| 1487 | + } |
|
| 1313 | 1488 | echo '--'.str_pad($name,20).$default."\n"; |
| 1314 | 1489 | } |
| 1315 | 1490 | if ($error) |