From 762d76f0c3222dd8fc2cd4759af3d42606c15785 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 13 Jul 2016 17:45:21 +0200 Subject: [PATCH] - keep copyright notice and only update the authors list - check if all changes to a file happened after the fork, this allows the authors to check if the file can be relicensed to AGPLv3 or later --- build/license.php | 99 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 18 deletions(-) diff --git a/build/license.php b/build/license.php index bed3854925f..1712899d686 100644 --- a/build/license.php +++ b/build/license.php @@ -22,11 +22,14 @@ class Licenses { protected $paths = []; protected $mailMap = []; + protected $checkFiles = []; public $authors = []; public function __construct() { $this->licenseText = <<licenseTextLegacy = <<handleFile($folder, $gitRoot); + $this->printFilesToCheck(); return; } @@ -113,6 +118,8 @@ EOD; /** @var SplFileInfo $file */ $this->handleFile($file, $gitRoot); } + + $this->printFilesToCheck(); } function writeAuthorsFile() { @@ -139,13 +146,15 @@ With help from many libraries and frameworks including: echo "MIT licensed file: $path" . PHP_EOL; return; } + $copyrightNotices = $this->getCopyrightNotices($path, $source); + $authors = $this->getAuthors($path, $gitRoot); if ($this->isOwnCloudLicensed($source)) { - $authors = $this->getAuthors($path, $gitRoot, true); $license = str_replace('@AUTHORS@', $authors, $this->licenseTextLegacy); + $this->checkCopyrightState($path, $gitRoot); } else { - $authors = $this->getAuthors($path, $gitRoot); $license = str_replace('@AUTHORS@', $authors, $this->licenseText); } + $license = str_replace('@COPYRIGHT@', $copyrightNotices, $license); $source = $this->eatOldLicense($source); $source = "getTimestamp(); + + $buildDir = getcwd(); + if ($gitRoot) { + chdir($gitRoot); + $path = substr($path, strlen($gitRoot)); + } + $out = shell_exec("git --no-pager blame --line-porcelain $path | sed -n 's/^author-time //p'"); + if ($gitRoot) { + chdir($buildDir); + } + $timestampChanges = explode(PHP_EOL, $out); + $timestampChanges = array_slice($timestampChanges, 0, count($timestampChanges)-1); + foreach ($timestampChanges as $timestamp) { + if ((int)$timestamp < $deadlineTimestamp) { + return; + } + } + + //all changes after the deadline + $this->checkFiles[] = $path; + + } + + private function printFilesToCheck() { + if (!empty($this->checkFiles)) { + print "\n"; + print "For following files all lines changes since the Nextcloud fork." . PHP_EOL; + print "Please check if these files can be moved over to AGPLv3 or later" . PHP_EOL; + print "\n"; + foreach ($this->checkFiles as $file) { + print $file . PHP_EOL; + } + print "\n"; + } + } + + private function getAuthors($file, $gitRoot) { // only add authors that changed code and not the license header $licenseHeaderEndsAtLine = trim(shell_exec("grep -n '*/' $file | head -n 1 | cut -d ':' -f 1")); $buildDir = getcwd(); @@ -244,19 +315,11 @@ With help from many libraries and frameworks including: $authors = array_unique($authors); } - if ($legacyFiles) { - $authors = array_map(function($author){ - $this->authors[$author] = $author; - return " * @author $author"; - }, $authors); - } else { - $authors = array_map(function($author){ - $this->authors[$author] = $author; - return " * @copyright Copyright (c) " . date("Y") . ", $author"; - }, $authors); - } - - + $authors = array_map(function($author){ + $this->authors[$author] = $author; + return " * @author $author"; + }, $authors); + return implode(PHP_EOL, $authors); } -- 2.39.5