ソースを参照

Update license script apps

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
tags/v18.0.0beta2
Christoph Wurst 4年前
コミット
a166796378
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更41行の追加15行の削除
  1. 41
    15
      build/license.php

+ 41
- 15
build/license.php ファイルの表示

$license = str_replace('@COPYRIGHT@', $copyrightNotices, $license); $license = str_replace('@COPYRIGHT@', $copyrightNotices, $license);
} }


$source = $this->eatOldLicense($source);
$source = "<?php" . PHP_EOL . $license . PHP_EOL . $source;
[$source, $isStrict] = $this->eatOldLicense($source);
if ($isStrict) {
$source = "<?php" . PHP_EOL . PHP_EOL . 'declare(strict_types=1);' . PHP_EOL . PHP_EOL . $license . PHP_EOL . $source;
} else {
$source = "<?php" . PHP_EOL . $license . PHP_EOL . $source;
}
file_put_contents($path,$source); file_put_contents($path,$source);
echo "License updated: $path" . PHP_EOL; echo "License updated: $path" . PHP_EOL;
} }
return false; return false;
} }


private function isOwnCloudLicensed($source) {
$lines = explode(PHP_EOL, $source);
while(!empty($lines)) {
$line = $lines[0];
array_shift($lines);
if (strpos($line, 'ownCloud, Inc') !== false || strpos($line, 'ownCloud GmbH') !== false) {
return true;
}
private function isOwnCloudLicensed($source) {
$lines = explode(PHP_EOL, $source);
while(!empty($lines)) {
$line = $lines[0];
array_shift($lines);
if (strpos($line, 'ownCloud, Inc') !== false || strpos($line, 'ownCloud GmbH') !== false) {
return true;
} }
}


return false;
}
return false;
}


/** /**
* @param string $source * @param string $source
*/ */
private function eatOldLicense($source) { private function eatOldLicense($source) {
$lines = explode(PHP_EOL, $source); $lines = explode(PHP_EOL, $source);
$isStrict = false;
while(!empty($lines)) { while(!empty($lines)) {
$line = $lines[0]; $line = $lines[0];
if (strpos($line, '<?php') !== false) {
if (trim($line) === '<?php') {
array_shift($lines);
continue;
}
if (strpos($line, '<?php declare(strict_types') !== false) {
$isStrict = true;
array_shift($lines);
continue;
}
if (strpos($line, 'declare (strict_types') !== false) {
$isStrict = true;
array_shift($lines);
continue;
}
if (strpos($line, 'declare(strict_types') !== false) {
$isStrict = true;
array_shift($lines); array_shift($lines);
continue; continue;
} }
break; break;
} }


return implode(PHP_EOL, $lines);
return [implode(PHP_EOL, $lines), $isStrict];
} }


private function getCopyrightNotices($path, $file) { private function getCopyrightNotices($path, $file) {
$licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false); $licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false);
} else { } else {
$licenses->exec([ $licenses->exec([
'../apps/accessibility',
'../apps/admin_audit', '../apps/admin_audit',
'../apps/cloud_federation_api',
'../apps/comments', '../apps/comments',
'../apps/dav', '../apps/dav',
'../apps/encryption', '../apps/encryption',
'../apps/files_sharing', '../apps/files_sharing',
'../apps/files_trashbin', '../apps/files_trashbin',
'../apps/files_versions', '../apps/files_versions',
'../apps/lookup_server_connector',
'../apps/oauth2',
'../apps/provisioning_api', '../apps/provisioning_api',
'../apps/settings',
'../apps/sharebymail',
'../apps/systemtags', '../apps/systemtags',
'../apps/testing', '../apps/testing',
'../apps/theming', '../apps/theming',
'../apps/twofactor_backupcodes',
'../apps/updatenotification', '../apps/updatenotification',
'../apps/user_ldap', '../apps/user_ldap',
'../build/integration/features/bootstrap', '../build/integration/features/bootstrap',
'../core', '../core',
'../lib', '../lib',
'../ocs', '../ocs',
'../settings',
'../console.php', '../console.php',
'../cron.php', '../cron.php',
'../index.php', '../index.php',

読み込み中…
キャンセル
保存