Completed
Push — 14.2 ( 4f180f...4cf4e3 )
by Ralf
24:18
created
doc/rpm-build/checkout-build-archives.php 2 patches
Braces   +232 added lines, -57 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 {
15 15
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 16
 }
17
-date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
17
+date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings
18 18
 
19 19
 $verbose = 0;
20 20
 $config = array(
21 21
 	'packagename' => 'egroupware-epl',
22
-	'version' => '14.3',        // '14.3'
22
+	'version' => '14.3', // '14.3'
23 23
 	'packaging' => date('Ymd'), // '20160520'
24
-	'branch'  => '14.2',        // checked out branch
25
-	'tag' => '$version.$packaging',	// name of tag
24
+	'branch'  => '14.2', // checked out branch
25
+	'tag' => '$version.$packaging', // name of tag
26 26
 	'checkoutdir' => realpath(__DIR__.'/../..'),
27 27
 	'egw_buildroot' => '/tmp/build_root/epl_14.2_buildroot',
28 28
 	'sourcedir' => '/home/download/stylite-epl/egroupware-epl-14.2',
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	'svnalias' => 'aliases/default-ssh',    // default alias
35 35
 	'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'),
36 36
 	*/
37
-	'extra' => array('stylite', 'esyncpro', 'archive'),	// create an extra archive for given apps
37
+	'extra' => array('stylite', 'esyncpro', 'archive'), // create an extra archive for given apps
38 38
 		// these apps are placed in egroupware-epl-contrib archive
39 39
 		//'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')),
40
-	'aliasdir' => 'egroupware',             // directory created by the alias
41
-	'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'),
40
+	'aliasdir' => 'egroupware', // directory created by the alias
41
+	'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'),
42 42
 	// add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive
43 43
 	'all-add' => array(/*'contrib',*/ '/home/stylite/epl-trunk/phpfreechat_data_public.tar'),
44 44
 	// diverse binaries we need
@@ -55,35 +55,35 @@  discard block
 block discarded – undo
55 55
 	'gpg' => trim(`which gpg`),
56 56
 	'editor' => trim(`which vi`),
57 57
 	'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"',
58
-	'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
58
+	'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
59 59
 	'after-checkout' => 'rm -rf */source */templates/*/source',
60 60
 	'packager' => '[email protected]',
61 61
 	'obs' => '/home/stylite/obs/stylite-epl',
62
-	'obs_package_alias' => '',	// name used in obs package, if different from packagename
63
-	'changelog' => false,   // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
62
+	'obs_package_alias' => '', // name used in obs package, if different from packagename
63
+	'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
64 64
 	'changelog_packager' => 'Ralf Becker <[email protected]>',
65 65
 	'editchangelog' => '* ',
66 66
 	//'sfuser' => 'ralfbecker',
67 67
 	//'release' => '$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/',
68 68
 	'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README',
69 69
 	'skip' => array(),
70
-	'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'),
70
+	'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'),
71 71
 	'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"',
72
-	'github_user' => 'ralfbecker',	// Github user for following token
73
-	'github_token' => '',	// Github repo personal access token from above user
72
+	'github_user' => 'ralfbecker', // Github user for following token
73
+	'github_token' => '', // Github repo personal access token from above user
74 74
 );
75 75
 
76 76
 // process config from command line
77 77
 $argv = $_SERVER['argv'];
78 78
 $prog = array_shift($argv);
79 79
 
80
-while(($arg = array_shift($argv)))
80
+while (($arg = array_shift($argv)))
81 81
 {
82 82
 	if ($arg == '-v' || $arg == '--verbose')
83 83
 	{
84 84
 		++$verbose;
85 85
 	}
86
-	elseif($arg == '-h' || $arg == '--help')
86
+	elseif ($arg == '-h' || $arg == '--help')
87 87
 	{
88 88
 		if (in_array('editchangelog', $config['skip']) || !in_array('editchangelog', $config['run']))
89 89
 		{
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 		usage();
93 93
 	}
94
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
94
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
95 95
 	{
96 96
 		$value = array_shift($argv);
97
-		switch($name)
97
+		switch ($name)
98 98
 		{
99 99
 			case 'extra':	// stored as array and allow to add/delete items with +/- prefix
100 100
 			case 'types':
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 				{
118 118
 					$value = array_unique(preg_split('/[ ,]+/', $value));
119 119
 				}
120
-				switch($op)
120
+				switch ($op)
121 121
 				{
122 122
 					case '+':
123 123
 						$config[$name] = array_unique(array_merge($config[$name], $value));
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 			case 'release':
136 136
 			case 'copychangelog':
137 137
 				$config[$name] = $value;
138
-				if ($value) array_unshift($config['run'],$name);
138
+				if ($value) array_unshift($config['run'], $name);
139 139
 				break;
140 140
 
141 141
 			case 'editchangelog':
142 142
 				$config[$name] = $value ? $value : true;
143
-				if (!in_array('editchangelog',$config['run']))
143
+				if (!in_array('editchangelog', $config['run']))
144 144
 				{
145
-					array_unshift($config['run'],'editchangelog');
145
+					array_unshift($config['run'], 'editchangelog');
146 146
 				}
147 147
 				break;
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				{
152 152
 					usage("Path '$value' not found!");
153 153
 				}
154
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
154
+				if (!in_array('obs', $config['run'])) $config['run'][] = 'obs';
155 155
 				// fall through
156 156
 			default:
157 157
 				$config[$name] = $value;
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 }
170 170
 $svn = $config['svn'];
171 171
 
172
-$run = array_diff($config['run'],$config['skip']);
172
+$run = array_diff($config['run'], $config['skip']);
173 173
 
174 174
 // if we dont edit the changelog, set packaging from changelog
175 175
 if (!in_array('editchangelog', $run))
176 176
 {
177 177
 	parse_current_changelog(true);
178 178
 }
179
-foreach($run as $func)
179
+foreach ($run as $func)
180 180
 {
181
-	chdir(dirname(__FILE__));	// make relative filenames work, if other command changes dir
181
+	chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir
182 182
 	call_user_func('do_'.$func);
183 183
 }
184 184
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
194 194
  * @return string with changelog
195 195
  */
196
-function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ')
196
+function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ')
197 197
 {
198 198
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
199 199
 	global $config;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	run_cmd($cmd, $output);
215 215
 
216 216
 	$changelog = '';
217
-	foreach($output as $line)
217
+	foreach ($output as $line)
218 218
 	{
219 219
 		if (substr($line, 0, 4) == "    " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix)))
220 220
 		{
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 	{
247 247
 		throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!");
248 248
 	}
249
-	if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig')))
249
+	if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig')))
250 250
 	{
251 251
 		throw new Exception("$path not found!");
252 252
 	}
253 253
 	$module = $baseurl = null;
254 254
 	$modules = array();
255
-	foreach(explode("\n", $mrconfig) as $line)
255
+	foreach (explode("\n", $mrconfig) as $line)
256 256
 	{
257 257
 		$matches = null;
258 258
 		if (isset($baseurl))
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : '').
318 318
 			' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir'];
319 319
 		run_cmd($cmd);
320
-		run_cmd('mr up');	// need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
320
+		run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
321 321
 	}
322 322
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
323 323
 	{
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 	}
342 342
 	chdir($config['checkoutdir']);
343 343
 
344
-	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
344
+	$config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag
345 345
 
346
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
346
+	if (empty($config['tag'])) return; // otherwise we copy everything in svn root!
347 347
 
348 348
 	echo "Creating tag $config[tag]\n";
349 349
 
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
  */
357 357
 function do_release()
358 358
 {
359
-	global $config,$verbose;
359
+	global $config, $verbose;
360 360
 
361 361
 	// push local changes to Github incl. tags
362 362
 	if ($verbose) echo "Pushing changes and tags\n";
363 363
 	chdir($config['checkoutdir']);
364
-	run_cmd($config['mr']. ' up');		// in case someone else pushed something
364
+	run_cmd($config['mr'].' up'); // in case someone else pushed something
365 365
 	chdir($config['checkoutdir']);
366
-	run_cmd($config['git'].' push');	// regular commits like changelog
366
+	run_cmd($config['git'].' push'); // regular commits like changelog
367 367
 	$tag = config_translate('tag');
368
-	run_cmd($config['mr']. ' push origin '.$tag);	// pushing tags in all apps
368
+	run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps
369 369
 
370 370
 	if (empty($config['github_user']) || empty($config['github_token']))
371 371
 	{
@@ -382,26 +382,26 @@  discard block
 block discarded – undo
382 382
 		'body' => $config['changelog'],
383 383
 	);
384 384
 	$response = github_api("/repos/EGroupware/egroupware/releases", $data);
385
-	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']);	// remove {?name,label} template
385
+	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template
386 386
 
387 387
 	$archives = $config['sourcedir'].'/*egroupware-epl-'.$config['version'].'.'.$config['packaging'].'*';
388 388
 
389
-	foreach(glob($archives) as $path)
389
+	foreach (glob($archives) as $path)
390 390
 	{
391 391
 		$label = null;
392 392
 		if (substr($path, -4) == '.zip')
393 393
 		{
394 394
 			$content_type = 'application/zip';
395 395
 		}
396
-		elseif(substr($path, -7) == '.tar.gz')
396
+		elseif (substr($path, -7) == '.tar.gz')
397 397
 		{
398 398
 			$content_type = 'application/x-gzip';
399 399
 		}
400
-		elseif(substr($path, -8) == '.tar.bz2')
400
+		elseif (substr($path, -8) == '.tar.bz2')
401 401
 		{
402 402
 			$content_type = 'application/x-bzip2';
403 403
 		}
404
-		elseif(substr($path, -8) == '.txt.asc')
404
+		elseif (substr($path, -8) == '.txt.asc')
405 405
 		{
406 406
 			$content_type = 'text/plain';
407 407
 			$label = 'Signed hashes of downloads';
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 	if (!empty($config['release']))
421 421
 	{
422
-		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
422
+		$target = config_translate('release'); // allow to use config vars like $svnbranch in module
423 423
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
424 424
 		if ($verbose) echo $cmd."\n";
425 425
 		passthru($cmd);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
  * @throws Exception
438 438
  * @return array with response
439 439
  */
440
-function github_api($_url, $data, $method='POST', $upload=null, $content_type=null)
440
+function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null)
441 441
 {
442 442
 	global $config, $verbose;
443 443
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	curl_setopt($c, CURLOPT_TIMEOUT, 240);
451 451
 	curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
452 452
 
453
-	switch($method)
453
+	switch ($method)
454 454
 	{
455 455
 		case 'POST':
456 456
 			curl_setopt($c, CURLOPT_POST, true);
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
459 459
 			break;
460 460
 		case 'GET':
461
-			if(count($data)) $url .= '?' . http_build_query($data);
461
+			if (count($data)) $url .= '?'.http_build_query($data);
462 462
 			break;
463 463
 		case 'FILE':
464 464
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
465 465
 			curl_setopt($c, CURLOPT_POST, true);
466 466
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
467
-			if(count($data)) $url .= '?' . http_build_query($data);
467
+			if (count($data)) $url .= '?'.http_build_query($data);
468 468
 			break;
469 469
 		default:
470 470
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	curl_setopt($c, CURLOPT_URL, $url);
473 473
 
474 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";
475
+	if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n";
476 476
 
477 477
 	if (($response = curl_exec($c)) === false)
478 478
 	{
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		curl_setopt($c, CURLOPT_HEADER, true);
481 481
 		curl_setopt($c, CURLOPT_RETURNTRANSFER, false);
482 482
 		curl_exec($c);
483
-		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
483
+		throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : ''));
484 484
 	}
485 485
 
486 486
 	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
  * @param string $name
497 497
  * @param string $value =null value to use, default $config[$name]
498 498
  */
499
-function config_translate($name, $value=null)
499
+function config_translate($name, $value = null)
500 500
 {
501 501
 	global $config;
502 502
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	if (is_string($value) && strpos($value, '$') !== false)
505 505
 	{
506 506
 		$translate = array();
507
-		foreach($config as $n => $val)
507
+		foreach ($config as $n => $val)
508 508
 		{
509 509
 			if (is_string($val)) $translate['$'.$n] = $val;
510 510
 		}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
  */
531 531
 function do_editchangelog()
532 532
 {
533
-	global $config,$svn;
533
+	global $config, $svn;
534 534
 
535 535
 	echo "Querying changelog from Git/SVN\n";
536 536
 	if (!isset($config['modules']))
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	// query changelog per repo
541 541
 	$changelog = '';
542 542
 	$last_tag = null;
543
-	foreach($config['modules'] as $branch_url => $modules)
543
+	foreach ($config['modules'] as $branch_url => $modules)
544 544
 	{
545 545
 		$revision = null;
546 546
 		if (substr($branch_url, -4) == '.git')
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 			$changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision);
554 554
 		}
555 555
 	}
556
-	$logfile = tempnam('/tmp','checkout-build-archives');
557
-	file_put_contents($logfile,$changelog);
556
+	$logfile = tempnam('/tmp', 'checkout-build-archives');
557
+	file_put_contents($logfile, $changelog);
558 558
 	$cmd = $config['editor'].' '.escapeshellarg($logfile);
559 559
 	passthru($cmd);
560 560
 	$config['changelog'] = file_get_contents($logfile);
561 561
 	// remove trailing newlines
562
-	while (substr($config['changelog'],-1) == "\n")
562
+	while (substr($config['changelog'], -1) == "\n")
563 563
 	{
564
-		$config['changelog'] = substr($config['changelog'],0,-1);
564
+		$config['changelog'] = substr($config['changelog'], 0, -1);
565 565
 	}
566 566
 	// allow user to abort, by deleting the changelog
567 567
 	if (strlen($config['changelog']) <= 2)
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	run_cmd($cmd);
587 587
 
588 588
 	// update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped)
589
-	do_obs(true);	// true: only update debian.changes in obs checkouts
589
+	do_obs(true); // true: only update debian.changes in obs checkouts
590 590
 }
591 591
 
592 592
 /**
@@ -600,41 +600,41 @@  discard block
 block discarded – undo
600 600
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
601 601
  * @return string with changelog
602 602
  */
603
-function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ')
603
+function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ')
604 604
 {
605 605
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
606
-	global $config,$verbose,$svn;
606
+	global $config, $verbose, $svn;
607 607
 
608 608
 	if (is_null($revision))
609 609
 	{
610
-		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
610
+		list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url);
611 611
 		if (empty($branch)) $branch = $config['version'];
612 612
 		$tags_url .= '/tags';
613
-		$pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|';
613
+		$pattern = '|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|';
614 614
 		$matches = null;
615
-		$revision = get_last_svn_tag($tags_url,$pattern,$matches);
615
+		$revision = get_last_svn_tag($tags_url, $pattern, $matches);
616 616
 		$tag = $matches[1];
617 617
 	}
618
-	elseif(!is_numeric($revision))
618
+	elseif (!is_numeric($revision))
619 619
 	{
620
-		$revision = get_last_svn_tag($tags_url,$tag=$revision);
620
+		$revision = get_last_svn_tag($tags_url, $tag = $revision);
621 621
 	}
622 622
 	$cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url);
623 623
 	if (($v = $verbose))
624 624
 	{
625 625
 		echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n";
626
-		$verbose = false;	// otherwise no $output!
626
+		$verbose = false; // otherwise no $output!
627 627
 	}
628 628
 	$output = array();
629
-	run_cmd($cmd,$output);
629
+	run_cmd($cmd, $output);
630 630
 	$verbose = $v;
631
-	array_shift($output);	// remove the command
631
+	array_shift($output); // remove the command
632 632
 
633
-	$xml = simplexml_load_string($output=implode("\n",$output));
633
+	$xml = simplexml_load_string($output = implode("\n", $output));
634 634
 	$message = '';
635
-	foreach($xml as $log)
635
+	foreach ($xml as $log)
636 636
 	{
637
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
637
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore
638 638
 
639 639
 		$message .= $msg."\n";
640 640
 	}
@@ -651,25 +651,25 @@  discard block
 block discarded – undo
651 651
  * @param string $prefix ='* '
652 652
  * @return string
653 653
  */
654
-function _match_log_pattern($msg, $log_pattern, $prefix='* ')
654
+function _match_log_pattern($msg, $log_pattern, $prefix = '* ')
655 655
 {
656 656
 	$pattern_len = strlen($log_pattern);
657 657
 	$prefix_len = strlen($prefix);
658 658
 
659 659
 	$matches = null;
660
-	if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches))
660
+	if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches))
661 661
 	{
662 662
 		$msg = $matches[1];
663 663
 	}
664
-	elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern)
664
+	elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern)
665 665
 	{
666
-		list($msg) = explode("\n",$msg);
666
+		list($msg) = explode("\n", $msg);
667 667
 	}
668
-	elseif($log_pattern)
668
+	elseif ($log_pattern)
669 669
 	{
670 670
 		return null;
671 671
 	}
672
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
672
+	if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg;
673 673
 
674 674
 	return $msg;
675 675
 }
@@ -683,30 +683,30 @@  discard block
 block discarded – undo
683 683
  * @param array &$matches=null on return matches of preg_match
684 684
  * @return int revision of last svn tag matching pattern
685 685
  */
686
-function get_last_svn_tag($tags_url,$pattern,&$matches=null)
686
+function get_last_svn_tag($tags_url, $pattern, &$matches = null)
687 687
 {
688
-	global $verbose,$svn;
688
+	global $verbose, $svn;
689 689
 
690 690
 	$cmd = $svn.' log --xml --limit 40 -v '.escapeshellarg($tags_url);
691 691
 	if (($v = $verbose))
692 692
 	{
693 693
 		echo "Querying SVN for last tags\n$cmd\n";
694
-		$verbose = false;	// otherwise no $output!
694
+		$verbose = false; // otherwise no $output!
695 695
 	}
696 696
 	$output = array();
697
-	run_cmd($cmd,$output);
697
+	run_cmd($cmd, $output);
698 698
 	$verbose = $v;
699
-	array_shift($output);	// remove the command
699
+	array_shift($output); // remove the command
700 700
 
701
-	$xml = simplexml_load_string($output=implode("\n",$output));
701
+	$xml = simplexml_load_string($output = implode("\n", $output));
702 702
 	$is_regexp = $pattern[0] == substr($pattern, -1);
703
-	foreach($xml as $log)
703
+	foreach ($xml as $log)
704 704
 	{
705 705
 		//print_r($log);
706 706
 		if (!$is_regexp && strpos($log->paths->path, $pattern) !== false ||
707 707
 			$is_regexp && preg_match($pattern, $log->paths->path, $matches))
708 708
 		{
709
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
709
+			if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n";
710 710
 			return (int)$log['revision'];
711 711
 		}
712 712
 	}
@@ -718,9 +718,9 @@  discard block
 block discarded – undo
718 718
  *
719 719
  * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it
720 720
  */
721
-function do_obs($only_update_changelog=false)
721
+function do_obs($only_update_changelog = false)
722 722
 {
723
-	global $config,$verbose;
723
+	global $config, $verbose;
724 724
 
725 725
 	if (!is_dir($config['obs']))
726 726
 	{
@@ -730,25 +730,25 @@  discard block
 block discarded – undo
730 730
 	run_cmd('osc up '.$config['obs']);
731 731
 
732 732
 	$n = 0;
733
-	foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
733
+	foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
734 734
 	{
735 735
 		if (basename(dirname($path)) == '.osc' ||
736 736
 			!preg_match('/\/('.preg_quote($config['packagename']).
737 737
 				($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : '').
738
-				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path))
738
+				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path))
739 739
 		{
740 740
 			continue;
741 741
 		}
742 742
 		$matches = null;
743
-		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) &&
744
-			file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
743
+		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) &&
744
+			file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
745 745
 		{
746 746
 			if (basename($path) != basename($new_name))
747 747
 			{
748 748
 				unlink($path);
749 749
 				if ($verbose) echo "rm $path\n";
750 750
 			}
751
-			copy($new_name,dirname($path).'/'.basename($new_name));
751
+			copy($new_name, dirname($path).'/'.basename($new_name));
752 752
 			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
753 753
 			++$n;
754 754
 		}
@@ -758,35 +758,35 @@  discard block
 block discarded – undo
758 758
 			$config['changelog'] = parse_current_changelog();
759 759
 		}
760 760
 		// updating dsc, spec and changelog files
761
-		if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') ||
761
+		if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') ||
762 762
 			!empty($config['changelog']) && basename($path) == 'debian.changes')
763 763
 		{
764 764
 			$content = $content_was = file_get_contents($path);
765 765
 
766
-			if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec')
766
+			if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec')
767 767
 			{
768
-				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content);
768
+				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content);
769 769
 			}
770
-			if (substr($path,-4) == '.dsc')
770
+			if (substr($path, -4) == '.dsc')
771 771
 			{
772 772
 				$content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'.
773 773
 					preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m',
774
-					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content);
774
+					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content);
775 775
 			}
776
-			if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false)
776
+			if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false)
777 777
 			{
778 778
 				$content = update_changelog($content);
779 779
 			}
780
-			if (!empty($config['changelog']) && substr($path,-5) == '.spec' &&
781
-				($pos_changelog = strpos($content,'%changelog')) !== false)
780
+			if (!empty($config['changelog']) && substr($path, -5) == '.spec' &&
781
+				($pos_changelog = strpos($content, '%changelog')) !== false)
782 782
 			{
783 783
 				$pos_changelog += strlen("%changelog\n");
784
-				$content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
785
-					$config['changelog']."\n".substr($content,$pos_changelog);
784
+				$content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
785
+					$config['changelog']."\n".substr($content, $pos_changelog);
786 786
 			}
787 787
 			if ($content != $content_was)
788 788
 			{
789
-				file_put_contents($path,$content);
789
+				file_put_contents($path, $content);
790 790
 				if ($verbose) echo "Updated $path\n";
791 791
 				++$n;
792 792
 			}
@@ -807,33 +807,33 @@  discard block
 block discarded – undo
807 807
  * @param boolean $set_packaging =false true: set packaging from last changelog entry
808 808
  * @return string changelog entries without header and footer lines
809 809
  */
810
-function parse_current_changelog($set_packaging=false)
810
+function parse_current_changelog($set_packaging = false)
811 811
 {
812 812
 	global $config;
813 813
 
814 814
 	$changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes');
815 815
 	$lines = explode("\n", $changelog, 100);
816 816
 	$matches = null;
817
-	foreach($lines as $n => $line)
817
+	foreach ($lines as $n => $line)
818 818
 	{
819
-		if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'.
819
+		if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'.
820 820
 			($set_packaging ? '([0-9]+)' : preg_quote($config['packaging'])).'/', $line, $matches))
821 821
 		{
822 822
 			if ($set_packaging)
823 823
 			{
824 824
 				$config['packaging'] = $matches[1];
825 825
 			}
826
-			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
826
+			$n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header
827 827
 			$logentry = '';
828
-			while($lines[$n])	// entry is terminated by empty line
828
+			while ($lines[$n])	// entry is terminated by empty line
829 829
 			{
830 830
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
831 831
 				++$n;
832 832
 			}
833
-			return substr($logentry, 0, -1);	// remove training "\n"
833
+			return substr($logentry, 0, -1); // remove training "\n"
834 834
 		}
835 835
 	}
836
-	return null;	// paragraph for current version NOT found
836
+	return null; // paragraph for current version NOT found
837 837
 }
838 838
 
839 839
 /**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	global $config;
848 848
 
849 849
 	list($header) = explode("\n", $content);
850
-	$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']));
850
+	$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']));
852 852
 	$content = $new_header."\n\n".$config['changelog'].
853 853
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
854 854
 
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
 {
863 863
 	global $config;
864 864
 
865
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
865
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
866 866
 	{
867
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
867
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
868 868
 	}
869 869
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
870 870
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
884 884
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
885 885
 	run_cmd($cmd);
886
-	unlink($sumsfile);	// delete the unsigned file
886
+	unlink($sumsfile); // delete the unsigned file
887 887
 }
888 888
 
889 889
 /**
@@ -893,22 +893,22 @@  discard block
 block discarded – undo
893 893
 {
894 894
 	global $config;
895 895
 
896
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
897
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
896
+	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true);
897
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
898 898
 	{
899
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
899
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
900 900
 	}
901 901
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
902 902
 	$sums = '';
903 903
 
904 904
 	chdir($config['egw_buildroot']);
905 905
 
906
-	if($config['extra'])
906
+	if ($config['extra'])
907 907
 	{
908 908
 		$exclude = $exclude_all = array();
909
-		foreach($config['extra'] as $name => $modules)
909
+		foreach ($config['extra'] as $name => $modules)
910 910
 		{
911
-			foreach((array)$modules as $module)
911
+			foreach ((array)$modules as $module)
912 912
 			{
913 913
 				$exclude[] = basename($module);
914 914
 				if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add'])))
@@ -918,24 +918,24 @@  discard block
 block discarded – undo
918 918
 			}
919 919
 		}
920 920
 		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude);
921
-		$exclude_all_extra =  $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
921
+		$exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
922 922
 	}
923
-	foreach($config['types'] as $type)
923
+	foreach ($config['types'] as $type)
924 924
 	{
925 925
 		echo "Creating $type archives\n";
926 926
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
927 927
 
928 928
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
929
-		switch($type)
929
+		switch ($type)
930 930
 		{
931 931
 			case 'all.tar.bz2':	// single tar-ball for debian builds not easily supporting to use multiple
932 932
 				$file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar';
933 933
 				$cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware';
934 934
 				if (!empty($config['all-add']))
935 935
 				{
936
-					foreach((array)$config['all-add'] as $add)
936
+					foreach ((array)$config['all-add'] as $add)
937 937
 					{
938
-						if (substr($add, -4) != '.tar') continue;	// probably a module
938
+						if (substr($add, -4) != '.tar') continue; // probably a module
939 939
 						if (!($tar = realpath($add))) throw new Exception("File '$add' not found!");
940 940
 						$cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar;
941 941
 					}
@@ -959,15 +959,15 @@  discard block
 block discarded – undo
959 959
 		run_cmd($cmd);
960 960
 		$sums .= sha1_file($file)."\t".basename($file)."\n";
961 961
 
962
-		foreach($config['extra'] as $name => $modules)
962
+		foreach ($config['extra'] as $name => $modules)
963 963
 		{
964 964
 			if (is_numeric($name)) $name = $modules;
965 965
 			$dirs = ' egroupware/'.implode(' egroupware/', (array)$modules);
966 966
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
967
-			switch($type)
967
+			switch ($type)
968 968
 			{
969 969
 				case 'all.tar.bz2':
970
-					break;	// nothing to do
970
+					break; // nothing to do
971 971
 				case 'tar.bz2':
972 972
 				case 'tar.gz':
973 973
 					$cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs;
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		}
983 983
 	}
984 984
 	// writing sha1sum file
985
-	file_put_contents($sumsfile,$sums);
985
+	file_put_contents($sumsfile, $sums);
986 986
 }
987 987
 
988 988
 /**
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
  */
991 991
 function do_virusscan()
992 992
 {
993
-	global $config,$verbose;
993
+	global $config, $verbose;
994 994
 
995 995
 	if (!file_exists($config['clamscan']) || !is_executable($config['clamscan']))
996 996
 	{
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
1005 1005
 		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
1006 1006
 		$output = null;
1007
-		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
1007
+		run_cmd($cmd, $output, 1); // 1 = ignore already up to date database
1008 1008
 	}
1009 1009
 	echo "Starting virusscan\n";
1010 1010
 	$cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot'];
@@ -1061,12 +1061,12 @@  discard block
 block discarded – undo
1061 1061
  */
1062 1062
 function do_svncheckout()
1063 1063
 {
1064
-	global $config,$svn;
1064
+	global $config, $svn;
1065 1065
 
1066 1066
 	echo "Starting svn checkout/update\n";
1067 1067
 	if (!file_exists($config['checkoutdir']))
1068 1068
 	{
1069
-		mkdir($config['checkoutdir'],0755,true);
1069
+		mkdir($config['checkoutdir'], 0755, true);
1070 1070
 	}
1071 1071
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
1072 1072
 	{
@@ -1081,17 +1081,17 @@  discard block
 block discarded – undo
1081 1081
 		{
1082 1082
 			get_modules_per_repo();
1083 1083
 		}
1084
-		$config['svntag'] = config_translate('svntag');	// in case svntag command did not run, translate tag name
1084
+		$config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name
1085 1085
 
1086 1086
 		if (file_exists($config['aliasdir']))
1087 1087
 		{
1088
-			system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout, as we dont implement switching tags
1088
+			system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags
1089 1089
 			clearstatcache();
1090 1090
 		}
1091
-		foreach($config['modules'] as $repo => $modules)
1091
+		foreach ($config['modules'] as $repo => $modules)
1092 1092
 		{
1093 1093
 			$cmd = $svn.' co ';
1094
-			foreach($modules as $path => $url)
1094
+			foreach ($modules as $path => $url)
1095 1095
 			{
1096 1096
 				if ($path == $config['aliasdir'])
1097 1097
 				{
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 					$cmd = $svn.' co ';
1102 1102
 					continue;
1103 1103
 				}
1104
-				if(file_exists($config['aliasdir']))
1104
+				if (file_exists($config['aliasdir']))
1105 1105
 				{
1106 1106
 					die("'egroupware' applications must be first one in externals!\n");
1107 1107
 				}
@@ -1119,16 +1119,16 @@  discard block
 block discarded – undo
1119 1119
 			// check if correct branch
1120 1120
 			$cmd = 'LANG=C '.$svn.' info';
1121 1121
 			$output = $ret = null;
1122
-			exec($cmd,$output,$ret);
1123
-			foreach($output as $line)
1122
+			exec($cmd, $output, $ret);
1123
+			foreach ($output as $line)
1124 1124
 			{
1125
-				if ($ret || substr($line,0,5) == 'URL: ')
1125
+				if ($ret || substr($line, 0, 5) == 'URL: ')
1126 1126
 				{
1127
-					$url = substr($line,5);
1128
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1127
+					$url = substr($line, 5);
1128
+					if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1129 1129
 					{
1130 1130
 						echo "Checkout is of wrong branch --> deleting it\n";
1131
-						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1131
+						system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout
1132 1132
 						clearstatcache();
1133 1133
 					}
1134 1134
 					break;
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 		run_cmd($cmd);
1141 1141
 
1142 1142
 		chdir($config['aliasdir']);
1143
-		foreach($config['extra'] as $module)
1143
+		foreach ($config['extra'] as $module)
1144 1144
 		{
1145
-			$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1146
-			$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1145
+			$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1146
+			$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1147 1147
 			$url .= $module;
1148 1148
 			$cmd = $svn.' co '.$url;
1149 1149
 			run_cmd($cmd);
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
  */
1169 1169
 function get_modules_per_svn_repo()
1170 1170
 {
1171
-	global $config,$svn,$verbose;
1171
+	global $config, $svn, $verbose;
1172 1172
 
1173 1173
 	// process alias/externals
1174 1174
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
@@ -1176,27 +1176,27 @@  discard block
 block discarded – undo
1176 1176
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1177 1177
 	if ($verbose) echo $cmd."\n";
1178 1178
 	$output = $ret = null;
1179
-	exec($cmd,$output,$ret);
1179
+	exec($cmd, $output, $ret);
1180 1180
 	$config['modules'] = array();
1181
-	foreach($output as $line)
1181
+	foreach ($output as $line)
1182 1182
 	{
1183 1183
 		$line = trim($line);
1184 1184
 		if (empty($line) || $line[0] == '#') continue;
1185
-		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1185
+		list($path, $url) = preg_split('/[ \t\r\n]+/', $line);
1186 1186
 		$matches = null;
1187
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1187
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1188 1188
 		$repo = $matches[1];
1189 1189
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1190 1190
 		$config['modules'][$repo][$path] = $url;
1191 1191
 	}
1192 1192
 	// process extra modules
1193
-	foreach($config['extra'] as $module)
1193
+	foreach ($config['extra'] as $module)
1194 1194
 	{
1195
-		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1196
-		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1195
+		$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1196
+		$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1197 1197
 		$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");
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");
1200 1200
 		$repo = $matches[1];
1201 1201
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1202 1202
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
@@ -1210,11 +1210,11 @@  discard block
 block discarded – undo
1210 1210
  */
1211 1211
 function do_svntag()
1212 1212
 {
1213
-	global $config,$svn;
1213
+	global $config, $svn;
1214 1214
 
1215
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1215
+	if (empty($config['svntag'])) return; // otherwise we copy everything in svn root!
1216 1216
 
1217
-	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1217
+	$config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag
1218 1218
 
1219 1219
 	echo "Creating SVN tag $config[svntag]\n";
1220 1220
 	if (!isset($config['modules']))
@@ -1222,9 +1222,9 @@  discard block
 block discarded – undo
1222 1222
 		get_modules_per_repo();
1223 1223
 	}
1224 1224
 	// create tags (per repo)
1225
-	foreach($config['modules'] as $repo => $modules)
1225
+	foreach ($config['modules'] as $repo => $modules)
1226 1226
 	{
1227
-		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/';
1227
+		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/';
1228 1228
 		run_cmd($cmd);
1229 1229
 	}
1230 1230
 }
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1238 1238
  * @return int exit code of $cmd
1239 1239
  */
1240
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
1240
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
1241 1241
 {
1242 1242
 	global $verbose;
1243 1243
 
@@ -1245,18 +1245,18 @@  discard block
 block discarded – undo
1245 1245
 	{
1246 1246
 		echo $cmd."\n";
1247 1247
 		$ret = null;
1248
-		system($cmd,$ret);
1248
+		system($cmd, $ret);
1249 1249
 	}
1250 1250
 	else
1251 1251
 	{
1252 1252
 		$output[] = $cmd;
1253
-		exec($cmd,$output,$ret);
1254
-		if ($verbose) echo implode("\n",$output)."\n";
1253
+		exec($cmd, $output, $ret);
1254
+		if ($verbose) echo implode("\n", $output)."\n";
1255 1255
 	}
1256
-	if ($ret && !in_array($ret,(array)$no_bailout))
1256
+	if ($ret && !in_array($ret, (array)$no_bailout))
1257 1257
 	{
1258
-		if (!$verbose) echo implode("\n",$output)."\n";
1259
-		throw new Exception("Error during '$cmd' --> aborting",$ret);
1258
+		if (!$verbose) echo implode("\n", $output)."\n";
1259
+		throw new Exception("Error during '$cmd' --> aborting", $ret);
1260 1260
 	}
1261 1261
 	return $ret;
1262 1262
 }
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 			return 'NULL';
1284 1284
 		case 'object':
1285 1285
 		case 'array':
1286
-			return str_replace(array("\n",'    '/*,'Array'*/),'',print_r($var,true));
1286
+			return str_replace(array("\n", '    '/*,'Array'*/), '', print_r($var, true));
1287 1287
 	}
1288 1288
 	return 'UNKNOWN TYPE!';
1289 1289
 }
@@ -1293,9 +1293,9 @@  discard block
 block discarded – undo
1293 1293
  *
1294 1294
  * @param string $error =null optional error-message
1295 1295
  */
1296
-function usage($error=null)
1296
+function usage($error = null)
1297 1297
 {
1298
-	global $prog,$config,$verbose;
1298
+	global $prog, $config, $verbose;
1299 1299
 
1300 1300
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n";
1301 1301
 	echo "options and their defaults:\n";
@@ -1305,12 +1305,12 @@  discard block
 block discarded – undo
1305 1305
 	}
1306 1306
 	else
1307 1307
 	{
1308
-		unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1308
+		unset($config['modules']); // they give an error, because of nested array and are quite lengthy
1309 1309
 	}
1310
-	foreach($config as $name => $default)
1310
+	foreach ($config as $name => $default)
1311 1311
 	{
1312
-		if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES);
1313
-		echo '--'.str_pad($name,20).$default."\n";
1312
+		if (is_array($default)) $default = json_encode($default, JSON_UNESCAPED_SLASHES);
1313
+		echo '--'.str_pad($name, 20).$default."\n";
1314 1314
 	}
1315 1315
 	if ($error)
1316 1316
 	{
Please login to merge, or discard this patch.