Skip to content

Commit f1df26b

Browse files
authored
Merge pull request #1205 from jimklimov/unlicensed-yet
Problem: too easy to re-release a project with obsolete Copyrights
2 parents 5d305b4 + 89901a9 commit f1df26b

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ zproject's `project.xml` contains an extensive description of the available conf
223223
name := The name of your project (optional)
224224
description := A short description for your project (optional)
225225
email := The email address where to reach you (optional)
226+
url := The website or similar resource about the project or its ecosystem (optional)
226227
repository := git repository holding project (optional)
227228
unique_class_name := "0"|"1" (optional, defaults to 0) As a failsafe, forbid naming agents or classes same as the project itself (can cause conflicts in generated header filenames). Disable explicitly (set to 0) only in legacy projects that can not regenerate otherwise, and try to fix those.
229+
license := optional common tag of the project's license ("MPLv2", "GPL-2.0+", "CompanyName Proprietary" etc.); see also license.xml for longer wording
230+
check_license_years := "0"|"1"|"2" (optional, defaults to 0) When a project is regenerated, and if any license text(s) are defined, we check that at least one Copyright line in at least one license text contains the current year, and warn if not. If this option is set to "1", we also pause so that interactive developers can see this warning better and intervene. With "2" require that the year is mentioned, abort GSL with year if it is not.
228231
-->
229232
<project script = "zproject.gsl" name = "zproject"
230233
@@ -237,7 +240,10 @@ zproject's `project.xml` contains an extensive description of the available conf
237240
part of the XML tree. This file can provide content of such tags
238241
as <license> (detailed text to put in generated file headers)
239242
and <starting_year> (a number to put in packaging copyright
240-
summaries).
243+
summaries). Note that a verbatim "license.xml" file would be
244+
created if it is currently missing but the tag is present, and
245+
then it would be seeded with a current starting_year and some
246+
boilerplate reminder to specify a real license and copyright.
241247
-->
242248
<include filename = "license.xml" />
243249

project.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@
4646
name := The name of your project (optional)
4747
description := A short description for your project (optional)
4848
email := The email address where to reach you (optional)
49+
url := The website or similar resource about the project or its ecosystem (optional)
4950
repository := git repository holding project (optional)
5051
unique_class_name := "0"|"1" (optional, defaults to 0) As a failsafe, forbid naming agents or classes same as the project itself (can cause conflicts in generated header filenames). Disable explicitly (set to 0) only in legacy projects that can not regenerate otherwise, and try to fix those.
52+
license := optional common tag of the project's license ("MPLv2", "GPL-2.0+", "CompanyName Proprietary" etc.); see also license.xml for longer wording
53+
check_license_years := "0"|"1"|"2" (optional, defaults to 0) When a project is regenerated, and if any license text(s) are defined, we check that at least one Copyright line in at least one license text contains the current year, and warn if not. If this option is set to "1", we also pause so that interactive developers can see this warning better and intervene. With "2" require that the year is mentioned, abort GSL with year if it is not.
5154
-->
5255
<project script = "zproject.gsl" name = "zproject"
5356
@@ -60,7 +63,10 @@
6063
part of the XML tree. This file can provide content of such tags
6164
as <license> (detailed text to put in generated file headers)
6265
and <starting_year> (a number to put in packaging copyright
63-
summaries).
66+
summaries). Note that a verbatim "license.xml" file would be
67+
created if it is currently missing but the tag is present, and
68+
then it would be seeded with a current starting_year and some
69+
boilerplate reminder to specify a real license and copyright.
6470
-->
6571
<include filename = "license.xml" />
6672

zproject.gsl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,45 @@ function resolve_includes (xml)
5050
endfor
5151
endfunction
5252

53+
# Sanity-check if project.xml, license.xml etc. reference the current
54+
# year (as starting, ending, just listed...) in Copyright line context
55+
function check_license_years (xml)
56+
if count (my.xml.license) > 0
57+
# Assign HHMMSSss into my.time and YYYYMMDD into my.date:
58+
my.time = time.now(my.date)
59+
my.now_year = string.substr(my.date, 0, , 4)
60+
my.year_seen = 0
61+
for my.xml.license
62+
# This pattern supports several ways of spelling the copyright
63+
# character (ASCII code 169) or registered symbol (ASCII 174).
64+
# Note that in XML tag they should be spelled via escape sequences;
65+
# a direct UTF character in the tag can be misinterpreted by GSL.
66+
if regexp.match ("(opyright|\(C\)|\&\#(169|[xX][aA]9|174|[xX][aA][eE])\;|\&copy\;|&copy;|&#(169|174|[xX][aA]9|[xX][aA][eE]);|$(conv.chr(169))|$(conv.chr(174))).*$(my.now_year)", license.)
67+
my.year_seen += 1
68+
endif
69+
endfor
70+
if (0 = my.year_seen)
71+
echo "W: Current year '$(my.now_year)' is not listed in any license tag / Copyright line!"
72+
echo "W: Do you want to Ctrl+Break now, edit your license.xml and regenerate the project?"
73+
# Per PR review, there's no hard need for a pause - after the
74+
# Bern convention the "copyright YYYY-YYYY" line is actually not
75+
# legally required almost anywhere in the world, and is purely
76+
# informative. Copyright is implicit and automatic, and with
77+
# git there is enough metadata to satisfty any lawyer/court.
78+
if (my.xml.check_license_years ?= 1)
79+
echo "W: (Sleeping 5 sec...)"
80+
thread.sleep (500)
81+
echo "W: Oh well, moving on with possibly obsoleted copyrights"
82+
endif
83+
if (my.xml.check_license_years ?= 2)
84+
abort "E: This project is configured to require that copyrights are up to date"
85+
endif
86+
endif
87+
endif
88+
endfunction
89+
5390
resolve_includes (project)
91+
check_license_years (project)
5492

5593
# Check if project contains one or more C++ sources
5694
function project_use_cxx ()

0 commit comments

Comments
 (0)