Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable9] license and mailmap backports #514

Merged
merged 8 commits into from
Jul 22, 2016
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 <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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
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