Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
a41c579f
Unverified
Commit
a41c579f
authored
8 years ago
by
Bjoern Schiessle
Browse files
Options
Downloads
Patches
Plain Diff
no more CLA and switch to AGPLv3 or later
parent
e8dc57c4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/license.php
+57
-9
57 additions, 9 deletions
build/license.php
with
57 additions
and
9 deletions
build/license.php
+
57
−
9
View file @
a41c579f
...
@@ -27,6 +27,27 @@ class Licenses
...
@@ -27,6 +27,27 @@ class Licenses
public
function
__construct
()
{
public
function
__construct
()
{
$this
->
licenseText
=
<<<EOD
$this
->
licenseText
=
<<<EOD
/**
/**
@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
/**
@AUTHORS@
@AUTHORS@
*
*
* @copyright Copyright (c) @YEAR@, ownCloud, Inc.
* @copyright Copyright (c) @YEAR@, ownCloud, Inc.
...
@@ -46,7 +67,7 @@ class Licenses
...
@@ -46,7 +67,7 @@ class Licenses
*
*
*/
*/
EOD;
EOD;
$this
->
licenseText
=
str_replace
(
'@YEAR@'
,
date
(
"Y"
),
$this
->
licenseText
);
$this
->
licenseText
Legacy
=
str_replace
(
'@YEAR@'
,
date
(
"Y"
),
$this
->
licenseText
Legacy
);
}
}
/**
/**
...
@@ -118,10 +139,15 @@ With help from many libraries and frameworks including:
...
@@ -118,10 +139,15 @@ With help from many libraries and frameworks including:
echo
"MIT licensed file:
$path
"
.
PHP_EOL
;
echo
"MIT licensed file:
$path
"
.
PHP_EOL
;
return
;
return
;
}
}
$source
=
$this
->
eatOldLicense
(
$source
);
if
(
$this
->
isOwnCloudLicensed
(
$source
))
{
$authors
=
$this
->
getAuthors
(
$path
,
$gitRoot
);
$authors
=
$this
->
getAuthors
(
$path
,
$gitRoot
,
true
);
$license
=
str_replace
(
'@AUTHORS@'
,
$authors
,
$this
->
licenseText
);
$license
=
str_replace
(
'@AUTHORS@'
,
$authors
,
$this
->
licenseTextLegacy
);
}
else
{
$authors
=
$this
->
getAuthors
(
$path
,
$gitRoot
);
$license
=
str_replace
(
'@AUTHORS@'
,
$authors
,
$this
->
licenseText
);
}
$source
=
$this
->
eatOldLicense
(
$source
);
$source
=
"<?php"
.
PHP_EOL
.
$license
.
PHP_EOL
.
$source
;
$source
=
"<?php"
.
PHP_EOL
.
$license
.
PHP_EOL
.
$source
;
file_put_contents
(
$path
,
$source
);
file_put_contents
(
$path
,
$source
);
echo
"License updated:
$path
"
.
PHP_EOL
;
echo
"License updated:
$path
"
.
PHP_EOL
;
...
@@ -143,6 +169,19 @@ With help from many libraries and frameworks including:
...
@@ -143,6 +169,19 @@ With help from many libraries and frameworks including:
return
false
;
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
* @param string $source
* @return string
* @return string
...
@@ -177,7 +216,7 @@ With help from many libraries and frameworks including:
...
@@ -177,7 +216,7 @@ With help from many libraries and frameworks including:
return
implode
(
PHP_EOL
,
$lines
);
return
implode
(
PHP_EOL
,
$lines
);
}
}
private
function
getAuthors
(
$file
,
$gitRoot
)
{
private
function
getAuthors
(
$file
,
$gitRoot
,
$legacyFiles
=
false
)
{
// only add authors that changed code and not the license header
// 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"
));
$licenseHeaderEndsAtLine
=
trim
(
shell_exec
(
"grep -n '*/'
$file
| head -n 1 | cut -d ':' -f 1"
));
$buildDir
=
getcwd
();
$buildDir
=
getcwd
();
...
@@ -205,10 +244,19 @@ With help from many libraries and frameworks including:
...
@@ -205,10 +244,19 @@ With help from many libraries and frameworks including:
$authors
=
array_unique
(
$authors
);
$authors
=
array_unique
(
$authors
);
}
}
$authors
=
array_map
(
function
(
$author
){
if
(
$legacyFiles
)
{
$this
->
authors
[
$author
]
=
$author
;
$authors
=
array_map
(
function
(
$author
){
return
" * @author
$author
"
;
$this
->
authors
[
$author
]
=
$author
;
},
$authors
);
return
" * @author
$author
"
;
},
$authors
);
}
else
{
$authors
=
array_map
(
function
(
$author
){
$this
->
authors
[
$author
]
=
$author
;
return
" * @copyright Copyright (c) "
.
date
(
"Y"
)
.
",
$author
"
;
},
$authors
);
}
return
implode
(
PHP_EOL
,
$authors
);
return
implode
(
PHP_EOL
,
$authors
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment