diff --git a/README.md b/README.md index 7ca7d5fcbfc48418f3a90403611700b039368454..7a540a6e45ec062065bd04a2a3f6c417cf15d31d 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Please stay tuned while we get all the repositories up. Meanwhile check out https://nextcloud.com and follow us on https://twitter.com/nextclouders -If you want to [contribute](https://nextcloud.com/contribute/), you are very welcome: +If you want to [contribute](https://nextcloud.com/contribute/), you are very welcome: -- on our IRC channels #nextcloud & #nextcloud-dev irc://#nextcloud-dev@freenode.net (on freenode) and +- on our IRC channels #nextcloud & #nextcloud-dev irc://#nextcloud-dev@freenode.net (on freenode) and - our forum at https://help.nextcloud.com Please read the [Code of Conduct](https://nextcloud.com/community/code-of-conduct/). This document offers some guidance to ensure Nextcloud participants can cooperate effectively in a positive and inspiring atmosphere, and to explain how together we can strengthen and support each other. @@ -30,7 +30,20 @@ if you want to join the Github organization just let us know and we’ll add you * ... ## Contribution Guidelines -https://nextcloud.com/contribute/ + +All contributions to this repository from June, 16 2016 on are considered to be +licensed under the AGPLv3 or any later version. + +Nextcloud doesn't require a CLA (Contributor License Agreement). +The copyright belongs to all the individual contributors. Therefore we recommend +that every contributor adds following line to the header of a file, if he +changed it substantially: + +``` +@copyright Copyright (c) <year>, <your name> (<your email address>) +``` + +More information how to contribute: https://nextcloud.com/contribute/ ## Support Learn about the different ways you can get support for Nextcloud: https://nextcloud.com/support/ diff --git a/build/license.php b/build/license.php index bed3854925ff262ed1ea00e9439f5f1705bb933d..1712899d6866b647ebbf83c5c9d3e38b50d304ad 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 = <<<EOD /** +@COPYRIGHT@ + * @AUTHORS@ * * @license GNU AGPL version 3 or any later version @@ -48,9 +51,10 @@ class 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 @@ -89,6 +93,7 @@ EOD; if (is_file($folder)) { $this->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 = "<?php" . PHP_EOL . $license . PHP_EOL . $source; @@ -155,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); @@ -181,7 +191,7 @@ With help from many libraries and frameworks including: return false; } - + /** * @param string $source * @return string @@ -216,7 +226,68 @@ With help from many libraries and frameworks including: return implode(PHP_EOL, $lines); } - private function getAuthors($file, $gitRoot, $legacyFiles = false) { + 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); + $copyrightNotice = []; + foreach ($lineByLine 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 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); }