Merge pull request #514 from nextcloud/backport-505-license-mailmap-9

[stable9] license and mailmap backports
This commit is contained in:
Roeland Douma 2016-07-22 11:13:51 +02:00 committed by GitHub
commit 34f72b3d6b
2 changed files with 151 additions and 29 deletions

View File

@ -16,8 +16,8 @@ Andreas Schönebeck <aschoenebeck@web.de>
Andreas Ergenzinger <andreas.ergenzinger@gmx.de> AndreasErgenzinger <andreas.ergenzinger@gmx.de>
Andrew Brown <andrew@casabrown.com>
André Gaul <gaul@web-yard.de>
Arthur Schiwon <blizzz@owncloud.com> Arthur Schiwon <blizzz@arthur-schiwon.de>
Arthur Schiwon <blizzz@owncloud.com> blizzz <blizzz@owncloud.com>
Arthur Schiwon <blizzz@arthur-schiwon.de> Arthur Schiwon <blizzz@owncloud.com>
Arthur Schiwon <blizzz@arthur-schiwon.de> blizzz <blizzz@owncloud.com>
Artur Duque de Souza <asouza@kde.org>
Axel Roenn <axel@mpim-bonn.mpg.de>
Bagera <victor@baquero-wihlborg.se>
@ -30,14 +30,16 @@ Benjamin Diele <benjamin@diele.be>
Benjamin Liles <benliles@arch.tamu.edu>
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <nukeawhale@gmail.com>
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <Raydiation@users.noreply.github.com>
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <BernhardPosselt@users.noreply.github.com>
Bernhard Reiter <ockham@raz.or.at>
Birk Borkason <daniel.niccoli@gmail.com>
Björn Schießle <schiessle@owncloud.com> Bjoern Schiessle <schiesbn@woody.(none)>
Björn Schießle <schiessle@owncloud.com> Björn Schießle <bjoern@schiessle.org>
Björn Schießle <schiessle@owncloud.com> Björn Schießle <schiesbn@potato.(none)>
Björn Schießle <schiessle@owncloud.com> Björn Schiessle <schiessle@owncloud.com>
Björn Schießle <schiessle@owncloud.com> Bjoern Schießle <schiessle@owncloud.com>
Björn Schießle <schiessle@owncloud.com> Bjoern Schiessle <schiessle@owncloud.com>
Björn Schießle <bjoern@schiessle.org> Bjoern Schiessle <schiesbn@woody.(none)>
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiessle@owncloud.com>
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiesbn@potato.(none)>
Björn Schießle <bjoern@schiessle.org> Björn Schiessle <schiessle@owncloud.com>
Björn Schießle <bjoern@schiessle.org> Bjoern Schießle <schiessle@owncloud.com>
Björn Schießle <bjoern@schiessle.org> Bjoern Schiessle <schiessle@owncloud.com>
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiessle@owncloud.com>
BlackEagle <ike.devolder@gmail.com>
Boris Rybalkin <ribalkin@gmail.com>
Borjan Tchakaloff <borjan@tchakaloff.fr>
@ -61,6 +63,8 @@ Christian Berendt <berendt@b1-systems.de>
Christian Kampka <christian@kampka.net>
Christian Koch <koch.chris@gmail.com>
Christian Reiner <github@christian-reiner.info> Christian Reiner <arkascha@balder.site>
Christoph Wurst <christoph@owncloud.com> Christoph Wurst <ChristophWurst@users.noreply.github.com>
Christoph Wurst <christoph@owncloud.com> Christoph Wurst <christoph@winzerhof-wurst.at>
Christopher Bunn <b11.chris@gmail.com>
Christopher Schäpers <kondou@ts.unde.re> Christopher <kondou@ts.unde.re>
Christopher Schäpers <kondou@ts.unde.re> kondou <kondou@ts.unde.re>
@ -123,11 +127,11 @@ Florian Vichot <florian.vichot@gmail.com>
Florin Peter <github@florin-peter.de> Florin Peter <fp@datawerk.de>
Florin Peter <github@florin-peter.de> FlorinPeter <github@florin-peter.de>
Francesco Piraneo G. <fpiraneo@iface.ch>
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 <karlitschek@gmx.de>
Frank Karlitschek <frank@owncloud.org> Frank Karlitschek <karlitschek@kde.org>
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 <frank@owncloud.org>
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <karlitschek@kde.org>
François Kubler <francois@kubler.org>
Frédéric Fortier <frederic.fortier@oronospolytechnique.com> Frédéric Fortier <frederic.fortier@polymtl.ca>
Frederik Gladhorn <gladhorn@kde.org>
@ -179,7 +183,8 @@ Jesús Macias <jmacias@solidgear.es> Jesus Macias <jmacias@full-on-net.com>
jknockaert <jasper@knockaert.nl>
Joan <aseques@gmail.com>
Joar Wandborg <git@wandborg.com>
Joas Schilling <nickvergessen@owncloud.com> Joas Schilling <nickvergessen@gmx.de>
Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@gmx.de>
Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@owncloud.com>
joel hansson <joel.hansson@gmail.com>
Johan Björk <johanimon@gmail.com>
Johannes Twittmann <github.com@deryo.de>
@ -206,8 +211,8 @@ Sebastian Döll <sebastian.doell@libasys.de> libasys <sebastian.doell@libasys.de
Lode Hoste <zillode@zillode.be>
lolozere <laurent@chedanne.pro>
Lorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it>
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 <lpolicinski@gmail.com>
Lyonel Vincent <lyonel@ezix.org>
macjohnny <estebanmarin@gmx.ch>
@ -298,17 +303,18 @@ Riccardo Iaconelli <riccardo@kde.org>
Richard Clarkson <robert@trash-mail.com>
rnveach <rveach02@gmail.com>
Robert Jäckel <rjaeckel@users.noreply.github.com>
Robin Appelman <icewind@owncloud.com> icewind1991 <icewind1991@gmail.com>
Robin Appelman <icewind@owncloud.com> icewind1991 <robin@icewind.nl>
Robin Appelman <icewind@owncloud.com> Robin <Robin Appelman icewind1991@gmail.com>
Robin Appelman <icewind@owncloud.com> Robin <robin@Amaya.(none)>
Robin Appelman <icewind@owncloud.com> Robin Appelman <icewind1991@gmail.com>
Robin Appelman <icewind@owncloud.com> Robin Appelman <icewind1991@gmail>
Robin Appelman <icewind@owncloud.com> Robin Appelman <robin@icewind.nl>
Robin Appelman <robin@icewind.nl> icewind1991 <icewind1991@gmail.com>
Robin Appelman <robin@icewind.nl> icewind1991 <robin@icewind.nl>
Robin Appelman <robin@icewind.nl> Robin <Robin Appelman icewind1991@gmail.com>
Robin Appelman <robin@icewind.nl> Robin <robin@Amaya.(none)>
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind1991@gmail.com>
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind1991@gmail>
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind@owncloud.com>
Robin McCorkell <robin@mccorkell.me.uk> Robin McCorkell <rmccorkell@karoshi.org.uk>
Robin McCorkell <robin@mccorkell.me.uk> Robin McCorkell <rmccorkell@owncloud.com>
Rodrigo Hjort <rodrigo.hjort@gmail.com>
Roeland Jago Douma <rullzer@owncloud.com> Roeland Jago Douma <roeland@famdouma.nl>
Roeland Jago Douma <roeland@famdouma.nl> Roeland Jago Douma <rullzer@owncloud.com>
Roeland Jago Douma <roeland@famdouma.nl> Roeland Douma <rullzer@users.noreply.github.com>
rok <brejktru@gmail.com>
Roland Hager <roland.hager@tu-berlin.de>
Roland van Laar <roland@micite.net>
@ -368,6 +374,7 @@ TheSFReader <TheSFReader@gmail.com>
Thibaut GRIDEL <tgridel@free.fr>
thomas <thomas@thomas-VirtualBox.(none)>
Thomas Müller <thomas.mueller@tmit.eu> Thomas Mueller <thomas.mueller@tmit.eu>
Thomas Müller <thomas.mueller@tmit.eu> Thomas Müller <DeepDiver1975@users.noreply.github.com>
Thomas Olsen <tol@tanghus>
Thomas Schmidt <tschmidt@suse.de>
Thomas Tanghus <thomas@tanghus.net>

View File

@ -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
@ -46,7 +71,7 @@ class Licenses
*
*/
EOD;
$this->licenseText = str_replace('@YEAR@', date("Y"), $this->licenseText);
$this->licenseTextLegacy = str_replace('@YEAR@', date("Y"), $this->licenseTextLegacy);
}
/**
@ -68,6 +93,7 @@ EOD;
if (is_file($folder)) {
$this->handleFile($folder, $gitRoot);
$this->printFilesToCheck();
return;
}
@ -92,11 +118,13 @@ EOD;
/** @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:
@ -118,10 +146,17 @@ With help from many libraries and frameworks including:
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;
@ -129,6 +164,7 @@ With help from many libraries and frameworks including:
/**
* @param string $source
* @return bool
*/
private function isMITLicensed($source) {
$lines = explode(PHP_EOL, $source);
@ -143,6 +179,19 @@ With help from many libraries and frameworks including:
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
@ -177,6 +226,68 @@ With help from many libraries and frameworks including:
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"));
@ -209,6 +320,7 @@ With help from many libraries and frameworks including:
$this->authors[$author] = $author;
return " * @author $author";
}, $authors);
return implode(PHP_EOL, $authors);
}
@ -238,6 +350,7 @@ if (isset($argv[1])) {
$licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false);
} else {
$licenses->exec([
'../apps/admin_audit',
'../apps/comments',
'../apps/dav',
'../apps/encryption',
@ -251,8 +364,10 @@ if (isset($argv[1])) {
'../apps/provisioning_api',
'../apps/systemtags',
'../apps/testing',
'../apps/theming',
'../apps/updatenotification',
'../apps/user_ldap',
'../build/integration/features/bootstrap',
'../core',
'../lib',
'../ocs',