Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: repoman/lib/repoman/modules/linechecks/gentoo_header/, repoman/cnf/linechecks/
Date: Mon, 03 Jun 2019 18:39:35
Message-Id: 1559587122.1f2d1e63a605d5ad4a9257e0102b9803bc59aeb6.zmedico@gentoo
1 commit: 1f2d1e63a605d5ad4a9257e0102b9803bc59aeb6
2 Author: Ulrich Müller <ulm <AT> kph <DOT> uni-mainz <DOT> de>
3 AuthorDate: Mon Jun 3 15:02:02 2019 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Jun 3 18:38:42 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1f2d1e63
7
8 repoman: Update header check for Gentoo repo policy.
9
10 By decision of the Gentoo Council in its 2019-01-13 meeting, ebuilds
11 in the Gentoo repository MUST use the simplified form of the copyright
12 attribution according to GLEP 76, i.e.: "Copyright YEARS Gentoo Authors".
13
14 Update the header check accordingly, mostly by reverting to the
15 simpler single line check that was in place before commit c4096aff48.
16
17 Bug: https://bugs.gentoo.org/666330
18 Signed-off-by: Ulrich Müller <ulm <AT> kph.uni-mainz.de>
19 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
20
21 repoman/cnf/linechecks/linechecks.yaml | 1 -
22 .../modules/linechecks/gentoo_header/header.py | 45 ++++++++--------------
23 2 files changed, 15 insertions(+), 31 deletions(-)
24
25 diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml
26 index 32b1bf82f..c452af07d 100644
27 --- a/repoman/cnf/linechecks/linechecks.yaml
28 +++ b/repoman/cnf/linechecks/linechecks.yaml
29 @@ -10,7 +10,6 @@ repoman_version: 2.3.3
30 # scan module
31 errors:
32 COPYRIGHT_ERROR: 'Invalid Copyright on line: %d'
33 - COPYRIGHT_DATE_ERROR: 'No copyright for last modification date before line %d'
34 LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
35 ID_HEADER_ERROR: 'Stale CVS header on line: %d'
36 NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'
37
38 diff --git a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
39 index c64674319..f94a8a50b 100644
40 --- a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
41 +++ b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
42 @@ -17,46 +17,31 @@ class EbuildHeader(LineCheck):
43
44 repoman_check_name = 'ebuild.badheader'
45
46 - copyright_re = re.compile(r'^# Copyright ((1999|2\d\d\d)-)?(?P<year>2\d\d\d) \w')
47 + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Authors$'
48 gentoo_license = (
49 '# Distributed under the terms'
50 ' of the GNU General Public License v2')
51 id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*')
52 + blank_line_re = re.compile(r'^$')
53 ignore_comment = False
54
55 def new(self, pkg):
56 if pkg.mtime is None:
57 - self.modification_year = None
58 + self.modification_year = r'2\d\d\d'
59 else:
60 - self.modification_year = time.gmtime(pkg.mtime)[0]
61 - self.last_copyright_line = -1
62 - self.last_copyright_year = -1
63 + self.modification_year = str(time.gmtime(pkg.mtime)[0])
64 + self.gentoo_copyright_re = re.compile(
65 + self.gentoo_copyright % self.modification_year)
66
67 def check(self, num, line):
68 - if num > self.last_copyright_line + 2:
69 + if num > 2:
70 return
71 - elif num == self.last_copyright_line + 1:
72 - # copyright can extend for a few initial lines
73 - copy_match = self.copyright_re.match(line)
74 - if copy_match is not None:
75 - self.last_copyright_line = num
76 - self.last_copyright_year = max(self.last_copyright_year,
77 - int(copy_match.group('year')))
78 - # no copyright lines found?
79 - elif self.last_copyright_line == -1:
80 + elif num == 0:
81 + if not self.gentoo_copyright_re.match(line):
82 return self.errors['COPYRIGHT_ERROR']
83 - else:
84 - # verify that the newest copyright line found
85 - # matches the year of last modification
86 - if (self.modification_year is not None
87 - and self.last_copyright_year != self.modification_year):
88 - return self.errors['COPYRIGHT_DATE_ERROR']
89 -
90 - # copyright is immediately followed by license
91 - if line.rstrip('\n') != self.gentoo_license:
92 - return self.errors['LICENSE_ERROR']
93 - elif num == self.last_copyright_line + 2:
94 - if self.id_header_re.match(line):
95 - return self.errors['ID_HEADER_ERROR']
96 - elif line.rstrip('\n') != '':
97 - return self.errors['NO_BLANK_LINE_ERROR']
98 + elif num == 1 and line.rstrip('\n') != self.gentoo_license:
99 + return self.errors['LICENSE_ERROR']
100 + elif num == 2 and self.id_header_re.match(line):
101 + return self.errors['ID_HEADER_ERROR']
102 + elif num == 2 and not self.blank_line_re.match(line):
103 + return self.errors['NO_BLANK_LINE_ERROR']