Test Setup Failed
Push — 17.1 ( 6edd18...88f1e2 )
by Ralf
08:41
created
install-cli.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
38 38
  */
39 39
 
40
-chdir(__DIR__);	// to enable relative pathes to work
40
+chdir(__DIR__); // to enable relative pathes to work
41 41
 
42 42
 if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
43 43
 {
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 $argv = $_SERVER['argv'];
52 52
 $cmd  = array_shift($argv);
53 53
 
54
-foreach($argv as $n => $arg)
54
+foreach ($argv as $n => $arg)
55 55
 {
56 56
 	if ($arg[0] === '-')
57 57
 	{
58
-		switch($arg)
58
+		switch ($arg)
59 59
 		{
60 60
 			case '-v':
61 61
 			case '--verbose':
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			case '--git':
76 76
 				$run_git = true;
77 77
 				unset($argv[$n]);
78
-				break 2;	// no further argument processing, as they are for git
78
+				break 2; // no further argument processing, as they are for git
79 79
 
80 80
 			default:
81 81
 				usage("Unknown argument '$arg'!");
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 if (!$run_git && count($argv) > 1) usage("Too many arguments!");
87 87
 
88
-function usage($err=null)
88
+function usage($err = null)
89 89
 {
90 90
 	global $cmd;
91 91
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 );
108 108
 
109 109
 // check if the necessary binaries are installed
110
-foreach($bins as $name => $binaries)
110
+foreach ($bins as $name => $binaries)
111 111
 {
112
-	foreach((array)$binaries as $bin)
112
+	foreach ((array)$binaries as $bin)
113 113
 	{
114 114
 		if (file_exists($bin) && is_executable($bin))
115 115
 		{
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		$bins[$name] = $$name = false;
134 134
 		error_log("Could not find $name command!");
135
-		if (!in_array($name, ['npm','grunt']))
135
+		if (!in_array($name, ['npm', 'grunt']))
136 136
 		{
137 137
 			exit(1);
138 138
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 }
146 146
 
147
-if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n";
147
+if ($verbose) echo "Using following binaries: ".json_encode($bins, JSON_UNESCAPED_SLASHES)."\n";
148 148
 
149 149
 if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n");
150 150
 
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 
165 165
 if (!exec($git.' branch --no-color', $output, $ret) || $ret)
166 166
 {
167
-	foreach($output as $line)
167
+	foreach ($output as $line)
168 168
 	{
169 169
 		error_log($line);
170 170
 	}
171 171
 	exit($ret);
172 172
 }
173
-foreach($output as $line)
173
+foreach ($output as $line)
174 174
 {
175 175
 	if ($line[0] == '*')
176 176
 	{
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 echo "Updating to: $target\n";
218 218
 
219 219
 // Update EGroupware itself and further apps installed via git
220
-foreach(scandir(__DIR__) as $dir)
220
+foreach (scandir(__DIR__) as $dir)
221 221
 {
222 222
 	if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git') &&
223 223
 		// these apps / dirs are managed by composer, no need to run manual updates
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	$git_cmd = $git.' '.implode(' ', array_map('escapeshellarg', $argv));
276 276
 
277 277
 	$ret = 0;
278
-	foreach(scandir(__DIR__) as $dir)
278
+	foreach (scandir(__DIR__) as $dir)
279 279
 	{
280 280
 		if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git'))
281 281
 		{
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
  * @param boolean $return_name =true true: just return name, false: full release object
298 298
  * @return array|string|null null if no release found
299 299
  */
300
-function get_latest_release($prerelease=false, $return_name=true)
300
+function get_latest_release($prerelease = false, $return_name = true)
301 301
 {
302
-	foreach(github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release)
302
+	foreach (github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release)
303 303
 	{
304 304
 		if ($prerelease || $release['prerelease'] === false)
305 305
 		{
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
  * @throws Exception
320 320
  * @return array with response
321 321
  */
322
-function github_api($_url, $data, $method='POST', $upload=null, $content_type=null)
322
+function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null)
323 323
 {
324 324
 	global /*$config,*/ $verbose;
325 325
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	curl_setopt($c, CURLOPT_TIMEOUT, 240);
333 333
 	curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
334 334
 
335
-	switch($method)
335
+	switch ($method)
336 336
 	{
337 337
 		case 'POST':
338 338
 			curl_setopt($c, CURLOPT_POST, true);
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
341 341
 			break;
342 342
 		case 'GET':
343
-			if(count($data)) $url .= '?' . http_build_query($data);
343
+			if (count($data)) $url .= '?'.http_build_query($data);
344 344
 			break;
345 345
 		case 'FILE':
346 346
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
347 347
 			curl_setopt($c, CURLOPT_POST, true);
348 348
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
349
-			if(count($data)) $url .= '?' . http_build_query($data);
349
+			if (count($data)) $url .= '?'.http_build_query($data);
350 350
 			break;
351 351
 		default:
352 352
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	curl_setopt($c, CURLOPT_URL, $url);
355 355
 
356 356
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
357
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
357
+	if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n";
358 358
 
359 359
 	if (($response = curl_exec($c)) === false)
360 360
 	{
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 		curl_setopt($c, CURLOPT_HEADER, true);
363 363
 		curl_setopt($c, CURLOPT_RETURNTRANSFER, false);
364 364
 		curl_exec($c);
365
-		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
365
+		throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : ''));
366 366
 	}
367 367
 
368 368
 	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
Please login to merge, or discard this patch.
Braces   +64 added lines, -16 removed lines patch added patch discarded remove patch
@@ -39,10 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
 chdir(__DIR__);	// to enable relative pathes to work
41 41
 
42
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
42
+if (php_sapi_name() !== 'cli')
43
+{
44
+	// security precaution: forbit calling setup-cli as web-page
43 45
 {
44 46
 	die('<h1>install-cli.php must NOT be called as web-page --> exiting !!!</h1>');
45 47
 }
48
+}
46 49
 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
47 50
 
48 51
 // parse arguments
@@ -83,7 +86,10 @@  discard block
 block discarded – undo
83 86
 	}
84 87
 }
85 88
 
86
-if (!$run_git && count($argv) > 1) usage("Too many arguments!");
89
+if (!$run_git && count($argv) > 1)
90
+{
91
+	usage("Too many arguments!");
92
+}
87 93
 
88 94
 function usage($err=null)
89 95
 {
@@ -144,9 +150,15 @@  discard block
 block discarded – undo
144 150
 	}
145 151
 }
146 152
 
147
-if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n";
153
+if ($verbose)
154
+{
155
+	echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n";
156
+}
148 157
 
149
-if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n");
158
+if (!extension_loaded('curl'))
159
+{
160
+	die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n");
161
+}
150 162
 
151 163
 // check if we are on a git clone
152 164
 $output = array();
@@ -188,7 +200,10 @@  discard block
 block discarded – undo
188 200
 {
189 201
 	$channel = isset($matches[1]) ? 'release' : 'bugfix';
190 202
 }
191
-if ($verbose) echo "Currently using branch: $branch --> $channel channel\n";
203
+if ($verbose)
204
+{
205
+	echo "Currently using branch: $branch --> $channel channel\n";
206
+}
192 207
 
193 208
 if ($argv)
194 209
 {
@@ -239,24 +254,36 @@  discard block
 block discarded – undo
239 254
 			$cmd .= "; $git pull --rebase";
240 255
 		}
241 256
 		$cmd .= "; test -z \"$($git stash list)\" || $git stash pop";
242
-		if ($verbose) echo "$cmd\n";
257
+		if ($verbose)
258
+		{
259
+			echo "$cmd\n";
260
+		}
243 261
 		system($cmd);
244 262
 	}
245 263
 }
246 264
 
247 265
 // update composer managed dependencies
248 266
 $cmd = $composer.' install';
249
-if ($verbose) echo "$cmd\n";
267
+if ($verbose)
268
+{
269
+	echo "$cmd\n";
270
+}
250 271
 system($cmd);
251 272
 
252 273
 // update npm dependencies and run grunt to minify javascript and css
253 274
 if ($npm && $grunt)
254 275
 {
255 276
 	$cmd = $npm.' install';
256
-	if ($verbose) echo "$cmd\n";
277
+	if ($verbose)
278
+	{
279
+		echo "$cmd\n";
280
+	}
257 281
 	system($cmd);
258 282
 
259
-	if ($verbose) echo "$grunt\n";
283
+	if ($verbose)
284
+	{
285
+		echo "$grunt\n";
286
+	}
260 287
 	system($grunt);
261 288
 }
262 289
 
@@ -284,7 +311,10 @@  discard block
 block discarded – undo
284 311
 			error_log("\n>>> ".$cmd."\n");
285 312
 			system($cmd, $ret);
286 313
 			// break if command is not successful
287
-			if ($ret) return $ret;
314
+			if ($ret)
315
+			{
316
+				return $ret;
317
+			}
288 318
 		}
289 319
 	}
290 320
 	return $ret;
@@ -336,25 +366,40 @@  discard block
 block discarded – undo
336 366
 	{
337 367
 		case 'POST':
338 368
 			curl_setopt($c, CURLOPT_POST, true);
339
-			if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT);
369
+			if (is_array($data))
370
+			{
371
+				$data = json_encode($data, JSON_FORCE_OBJECT);
372
+			}
340 373
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
341 374
 			break;
342 375
 		case 'GET':
343
-			if(count($data)) $url .= '?' . http_build_query($data);
376
+			if(count($data))
377
+			{
378
+				$url .= '?' . http_build_query($data);
379
+			}
344 380
 			break;
345 381
 		case 'FILE':
346 382
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
347 383
 			curl_setopt($c, CURLOPT_POST, true);
348 384
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
349
-			if(count($data)) $url .= '?' . http_build_query($data);
385
+			if(count($data))
386
+			{
387
+				$url .= '?' . http_build_query($data);
388
+			}
350 389
 			break;
351 390
 		default:
352 391
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
353 392
 	}
354 393
 	curl_setopt($c, CURLOPT_URL, $url);
355 394
 
356
-	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
357
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
395
+	if (is_string($data))
396
+	{
397
+		$short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
398
+	}
399
+	if ($verbose)
400
+	{
401
+		echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
402
+	}
358 403
 
359 404
 	if (($response = curl_exec($c)) === false)
360 405
 	{
@@ -365,7 +410,10 @@  discard block
 block discarded – undo
365 410
 		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
366 411
 	}
367 412
 
368
-	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
413
+	if ($verbose)
414
+	{
415
+		echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
416
+	}
369 417
 
370 418
 	curl_close($c);
371 419
 
Please login to merge, or discard this patch.