commit:     1f2d1e63a605d5ad4a9257e0102b9803bc59aeb6
Author:     Ulrich Müller <ulm <AT> kph <DOT> uni-mainz <DOT> de>
AuthorDate: Mon Jun  3 15:02:02 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jun  3 18:38:42 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1f2d1e63

repoman: Update header check for Gentoo repo policy.

By decision of the Gentoo Council in its 2019-01-13 meeting, ebuilds
in the Gentoo repository MUST use the simplified form of the copyright
attribution according to GLEP 76, i.e.: "Copyright YEARS Gentoo Authors".

Update the header check accordingly, mostly by reverting to the
simpler single line check that was in place before commit c4096aff48.

Bug: https://bugs.gentoo.org/666330
Signed-off-by: Ulrich Müller <ulm <AT> kph.uni-mainz.de>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 repoman/cnf/linechecks/linechecks.yaml             |  1 -
 .../modules/linechecks/gentoo_header/header.py     | 45 ++++++++--------------
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/repoman/cnf/linechecks/linechecks.yaml 
b/repoman/cnf/linechecks/linechecks.yaml
index 32b1bf82f..c452af07d 100644
--- a/repoman/cnf/linechecks/linechecks.yaml
+++ b/repoman/cnf/linechecks/linechecks.yaml
@@ -10,7 +10,6 @@ repoman_version: 2.3.3
 # scan module
 errors:
     COPYRIGHT_ERROR: 'Invalid Copyright on line: %d'
-    COPYRIGHT_DATE_ERROR: 'No copyright for last modification date before line 
%d'
     LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
     ID_HEADER_ERROR: 'Stale CVS header on line: %d'
     NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'

diff --git a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py 
b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
index c64674319..f94a8a50b 100644
--- a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
+++ b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
@@ -17,46 +17,31 @@ class EbuildHeader(LineCheck):
 
        repoman_check_name = 'ebuild.badheader'
 
-       copyright_re = re.compile(r'^# Copyright 
((1999|2\d\d\d)-)?(?P<year>2\d\d\d) \w')
+       gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Authors$'
        gentoo_license = (
                '# Distributed under the terms'
                ' of the GNU General Public License v2')
        id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*')
+       blank_line_re = re.compile(r'^$')
        ignore_comment = False
 
        def new(self, pkg):
                if pkg.mtime is None:
-                       self.modification_year = None
+                       self.modification_year = r'2\d\d\d'
                else:
-                       self.modification_year = time.gmtime(pkg.mtime)[0]
-               self.last_copyright_line = -1
-               self.last_copyright_year = -1
+                       self.modification_year = str(time.gmtime(pkg.mtime)[0])
+               self.gentoo_copyright_re = re.compile(
+                       self.gentoo_copyright % self.modification_year)
 
        def check(self, num, line):
-               if num > self.last_copyright_line + 2:
+               if num > 2:
                        return
-               elif num == self.last_copyright_line + 1:
-                       # copyright can extend for a few initial lines
-                       copy_match = self.copyright_re.match(line)
-                       if copy_match is not None:
-                               self.last_copyright_line = num
-                               self.last_copyright_year = 
max(self.last_copyright_year,
-                                               int(copy_match.group('year')))
-                       # no copyright lines found?
-                       elif self.last_copyright_line == -1:
+               elif num == 0:
+                       if not self.gentoo_copyright_re.match(line):
                                return self.errors['COPYRIGHT_ERROR']
-                       else:
-                               # verify that the newest copyright line found
-                               # matches the year of last modification
-                               if (self.modification_year is not None
-                                               and self.last_copyright_year != 
self.modification_year):
-                                       return 
self.errors['COPYRIGHT_DATE_ERROR']
-
-                               # copyright is immediately followed by license
-                               if line.rstrip('\n') != self.gentoo_license:
-                                       return self.errors['LICENSE_ERROR']
-               elif num == self.last_copyright_line + 2:
-                       if self.id_header_re.match(line):
-                               return self.errors['ID_HEADER_ERROR']
-                       elif line.rstrip('\n') != '':
-                               return self.errors['NO_BLANK_LINE_ERROR']
+               elif num == 1 and line.rstrip('\n') != self.gentoo_license:
+                       return self.errors['LICENSE_ERROR']
+               elif num == 2 and self.id_header_re.match(line):
+                       return self.errors['ID_HEADER_ERROR']
+               elif num == 2 and not self.blank_line_re.match(line):
+                       return self.errors['NO_BLANK_LINE_ERROR']

Reply via email to