Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Andreas Schönebeck <[email protected]>
Andreas Ergenzinger <[email protected]> AndreasErgenzinger <[email protected]>
Andrew Brown <[email protected]>
André Gaul <[email protected]>
Arthur Schiwon <blizzz@owncloud.com> Arthur Schiwon <blizzz@arthur-schiwon.de>
Arthur Schiwon <blizzz@owncloud.com> blizzz <[email protected]>
Arthur Schiwon <blizzz@arthur-schiwon.de> Arthur Schiwon <blizzz@owncloud.com>
Arthur Schiwon <blizzz@arthur-schiwon.de> blizzz <[email protected]>
Artur Duque de Souza <[email protected]>
Axel Roenn <[email protected]>
Bagera <[email protected]>
Expand All @@ -30,14 +30,16 @@ Benjamin Diele <[email protected]>
Benjamin Liles <[email protected]>
Bernhard Posselt <[email protected]> Bernhard Posselt <[email protected]>
Bernhard Posselt <[email protected]> Bernhard Posselt <[email protected]>
Bernhard Posselt <[email protected]> Bernhard Posselt <[email protected]>
Bernhard Reiter <[email protected]>
Birk Borkason <[email protected]>
Björn Schießle <[email protected]> Bjoern Schiessle <schiesbn@woody.(none)>
Björn Schießle <[email protected]> Björn Schießle <[email protected]>
Björn Schießle <[email protected]> Björn Schießle <schiesbn@potato.(none)>
Björn Schießle <[email protected]> Björn Schiessle <[email protected]>
Björn Schießle <[email protected]> Bjoern Schießle <[email protected]>
Björn Schießle <[email protected]> Bjoern Schiessle <[email protected]>
Björn Schießle <[email protected]> Bjoern Schiessle <schiesbn@woody.(none)>
Björn Schießle <[email protected]> Björn Schießle <[email protected]>
Björn Schießle <[email protected]> Björn Schießle <schiesbn@potato.(none)>
Björn Schießle <[email protected]> Björn Schiessle <[email protected]>
Björn Schießle <[email protected]> Bjoern Schießle <[email protected]>
Björn Schießle <[email protected]> Bjoern Schiessle <[email protected]>
Björn Schießle <[email protected]> Björn Schießle <[email protected]>
BlackEagle <[email protected]>
Boris Rybalkin <[email protected]>
Borjan Tchakaloff <[email protected]>
Expand All @@ -61,6 +63,8 @@ Christian Berendt <[email protected]>
Christian Kampka <[email protected]>
Christian Koch <[email protected]>
Christian Reiner <[email protected]> Christian Reiner <[email protected]>
Christoph Wurst <[email protected]> Christoph Wurst <[email protected]>
Christoph Wurst <[email protected]> Christoph Wurst <[email protected]>
Christopher Bunn <[email protected]>
Christopher Schäpers <[email protected]> Christopher <[email protected]>
Christopher Schäpers <[email protected]> kondou <[email protected]>
Expand Down Expand Up @@ -123,11 +127,11 @@ Florian Vichot <[email protected]>
Florin Peter <[email protected]> Florin Peter <[email protected]>
Florin Peter <[email protected]> FlorinPeter <[email protected]>
Francesco Piraneo G. <[email protected]>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <frank@dev.(none)>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <frank@devel.(none)>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <frank@oc.(none)>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <[email protected]>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <[email protected]>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@dev.(none)>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@devel.(none)>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@oc.(none)>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <[email protected]>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <[email protected]>
François Kubler <[email protected]>
Frédéric Fortier <[email protected]> Frédéric Fortier <[email protected]>
Frederik Gladhorn <[email protected]>
Expand Down Expand Up @@ -179,7 +183,8 @@ Jesús Macias <[email protected]> Jesus Macias <[email protected]>
jknockaert <[email protected]>
Joan <[email protected]>
Joar Wandborg <[email protected]>
Joas Schilling <[email protected]> Joas Schilling <[email protected]>
Joas Schilling <[email protected]> Joas Schilling <[email protected]>
Joas Schilling <[email protected]> Joas Schilling <[email protected]>
joel hansson <[email protected]>
Johan Björk <[email protected]>
Johannes Twittmann <[email protected]>
Expand All @@ -206,8 +211,8 @@ Sebastian Döll <[email protected]> libasys <[email protected]
Lode Hoste <[email protected]>
lolozere <[email protected]>
Lorenzo M. Catucci <[email protected]>
Lukas Reschke <lukas@owncloud.com> Lukas Reschke <lukas@owncloud.org>
Lukas Reschke <lukas@owncloud.com> Lukas Reschke <lukas@statuscode.ch>
Lukas Reschke <lukas@statuscode.ch> Lukas Reschke <lukas@owncloud.com>
Lukas Reschke <lukas@statuscode.ch> Lukas Reschke <lukas@owncloud.org>
Luke Policinski <[email protected]>
Lyonel Vincent <[email protected]>
macjohnny <[email protected]>
Expand Down Expand Up @@ -298,17 +303,18 @@ Riccardo Iaconelli <[email protected]>
Richard Clarkson <[email protected]>
rnveach <[email protected]>
Robert Jäckel <[email protected]>
Robin Appelman <[email protected]> icewind1991 <[email protected]>
Robin Appelman <[email protected]> icewind1991 <[email protected]>
Robin Appelman <[email protected]> Robin <Robin Appelman [email protected]>
Robin Appelman <[email protected]> Robin <robin@Amaya.(none)>
Robin Appelman <[email protected]> Robin Appelman <[email protected]>
Robin Appelman <[email protected]> Robin Appelman <icewind1991@gmail>
Robin Appelman <[email protected]> Robin Appelman <robin@icewind.nl>
Robin Appelman <[email protected]> icewind1991 <[email protected]>
Robin Appelman <[email protected]> icewind1991 <[email protected]>
Robin Appelman <[email protected]> Robin <Robin Appelman [email protected]>
Robin Appelman <[email protected]> Robin <robin@Amaya.(none)>
Robin Appelman <[email protected]> Robin Appelman <[email protected]>
Robin Appelman <[email protected]> Robin Appelman <icewind1991@gmail>
Robin Appelman <[email protected]> Robin Appelman <icewind@owncloud.com>
Robin McCorkell <[email protected]> Robin McCorkell <[email protected]>
Robin McCorkell <[email protected]> Robin McCorkell <[email protected]>
Rodrigo Hjort <[email protected]>
Roeland Jago Douma <[email protected]> Roeland Jago Douma <[email protected]>
Roeland Jago Douma <[email protected]> Roeland Jago Douma <[email protected]>
Roeland Jago Douma <[email protected]> Roeland Douma <[email protected]>
rok <[email protected]>
Roland Hager <[email protected]>
Roland van Laar <[email protected]>
Expand Down Expand Up @@ -368,6 +374,7 @@ TheSFReader <[email protected]>
Thibaut GRIDEL <[email protected]>
thomas <thomas@thomas-VirtualBox.(none)>
Thomas Müller <[email protected]> Thomas Mueller <[email protected]>
Thomas Müller <[email protected]> Thomas Müller <[email protected]>
Thomas Olsen <tol@tanghus>
Thomas Schmidt <[email protected]>
Thomas Tanghus <[email protected]>
Expand Down
125 changes: 120 additions & 5 deletions build/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,39 @@ class Licenses
{
protected $paths = [];
protected $mailMap = [];
protected $checkFiles = [];
public $authors = [];

public function __construct() {
$this->licenseText = <<<EOD
/**
@COPYRIGHT@
*
@AUTHORS@
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
EOD;
$this->licenseTextLegacy = <<<EOD
/**
@COPYRIGHT@
*
@AUTHORS@
*
* @copyright Copyright (c) @YEAR@, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
Expand All @@ -46,7 +71,7 @@ public function __construct() {
*
*/
EOD;
$this->licenseText = str_replace('@YEAR@', date("Y"), $this->licenseText);
$this->licenseTextLegacy = str_replace('@YEAR@', date("Y"), $this->licenseTextLegacy);
}

/**
Expand All @@ -68,6 +93,7 @@ function exec($folder, $gitRoot = false) {

if (is_file($folder)) {
$this->handleFile($folder, $gitRoot);
$this->printFilesToCheck();
return;
}

Expand All @@ -92,11 +118,13 @@ function exec($folder, $gitRoot = false) {
/** @var SplFileInfo $file */
$this->handleFile($file, $gitRoot);
}

$this->printFilesToCheck();
}

function writeAuthorsFile() {
ksort($this->authors);
$template = "ownCloud is written by:
$template = "Nextcloud is written by:
@AUTHORS@

With help from many libraries and frameworks including:
Expand All @@ -118,17 +146,25 @@ function handleFile($path, $gitRoot) {
echo "MIT licensed file: $path" . PHP_EOL;
return;
}
$source = $this->eatOldLicense($source);
$copyrightNotices = $this->getCopyrightNotices($path, $source);
$authors = $this->getAuthors($path, $gitRoot);
$license = str_replace('@AUTHORS@', $authors, $this->licenseText);
if ($this->isOwnCloudLicensed($source)) {
$license = str_replace('@AUTHORS@', $authors, $this->licenseTextLegacy);
$this->checkCopyrightState($path, $gitRoot);
} else {
$license = str_replace('@AUTHORS@', $authors, $this->licenseText);
}
$license = str_replace('@COPYRIGHT@', $copyrightNotices, $license);

$source = $this->eatOldLicense($source);
$source = "<?php" . PHP_EOL . $license . PHP_EOL . $source;
file_put_contents($path,$source);
echo "License updated: $path" . PHP_EOL;
}

/**
* @param string $source
* @return bool
*/
private function isMITLicensed($source) {
$lines = explode(PHP_EOL, $source);
Expand All @@ -143,6 +179,19 @@ private function isMITLicensed($source) {
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) {
return true;
}
}

return false;
}

/**
* @param string $source
* @return string
Expand Down Expand Up @@ -177,6 +226,68 @@ private function eatOldLicense($source) {
return implode(PHP_EOL, $lines);
}

private function getCopyrightNotices($path, $file) {
$licenseHeaderEndsAtLine = (int)trim(shell_exec("grep -n '*/' $path | head -n 1 | cut -d ':' -f 1"));
$lineByLine = explode(PHP_EOL, $file, $licenseHeaderEndsAtLine + 1);
$copyrightNotice = [];
$licensePart = array_slice($lineByLine, 0, $licenseHeaderEndsAtLine);
foreach ($licensePart as $line) {
if (strpos($line, '@copyright') !== false) {
$copyrightNotice[] = $line;
}
}

return implode(PHP_EOL, $copyrightNotice);
}

/**
* check if all lines where changed after the Nextcloud fork.
* That's not a guarantee that we can switch to AGPLv3 or later,
* but a good indicator that we should have a look at the file
*
* @param $path
* @param $gitRoot
*/
private function checkCopyrightState($path, $gitRoot) {
// This was the date the Nextcloud fork was created
$deadline = new DateTime('06/06/2016');
$deadlineTimestamp = $deadline->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 changed 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"));
Expand Down Expand Up @@ -209,6 +320,7 @@ private function getAuthors($file, $gitRoot) {
$this->authors[$author] = $author;
return " * @author $author";
}, $authors);

return implode(PHP_EOL, $authors);
}

Expand Down Expand Up @@ -238,6 +350,7 @@ private function checkCoreMailMap($author) {
$licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false);
} else {
$licenses->exec([
'../apps/admin_audit',
'../apps/comments',
'../apps/dav',
'../apps/encryption',
Expand All @@ -251,8 +364,10 @@ private function checkCoreMailMap($author) {
'../apps/provisioning_api',
'../apps/systemtags',
'../apps/testing',
'../apps/theming',
'../apps/updatenotification',
'../apps/user_ldap',
'../build/integration/features/bootstrap',
'../core',
'../lib',
'../ocs',
Expand Down