Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 666330
Collapse All | Expand All

(-)a/repoman/cnf/linechecks/linechecks.yaml (-1 lines)
Lines 10-16 repoman_version: 2.3.3 Link Here
10
# scan module
10
# scan module
11
errors:
11
errors:
12
    COPYRIGHT_ERROR: 'Invalid Copyright on line: %d'
12
    COPYRIGHT_ERROR: 'Invalid Copyright on line: %d'
13
    COPYRIGHT_DATE_ERROR: 'No copyright for last modification date before line %d'
14
    LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
13
    LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
15
    ID_HEADER_ERROR: 'Stale CVS header on line: %d'
14
    ID_HEADER_ERROR: 'Stale CVS header on line: %d'
16
    NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'
15
    NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'
(-)a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py (-31 / +15 lines)
Lines 17-62 class EbuildHeader(LineCheck): Link Here
17
17
18
	repoman_check_name = 'ebuild.badheader'
18
	repoman_check_name = 'ebuild.badheader'
19
19
20
	copyright_re = re.compile(r'^# Copyright ((1999|2\d\d\d)-)?(?P<year>2\d\d\d) \w')
20
	gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Authors$'
21
	gentoo_license = (
21
	gentoo_license = (
22
		'# Distributed under the terms'
22
		'# Distributed under the terms'
23
		' of the GNU General Public License v2')
23
		' of the GNU General Public License v2')
24
	id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*')
24
	id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*')
25
	blank_line_re = re.compile(r'^$')
25
	ignore_comment = False
26
	ignore_comment = False
26
27
27
	def new(self, pkg):
28
	def new(self, pkg):
28
		if pkg.mtime is None:
29
		if pkg.mtime is None:
29
			self.modification_year = None
30
			self.modification_year = r'2\d\d\d'
30
		else:
31
		else:
31
			self.modification_year = time.gmtime(pkg.mtime)[0]
32
			self.modification_year = str(time.gmtime(pkg.mtime)[0])
32
		self.last_copyright_line = -1
33
		self.gentoo_copyright_re = re.compile(
33
		self.last_copyright_year = -1
34
			self.gentoo_copyright % self.modification_year)
34
35
35
	def check(self, num, line):
36
	def check(self, num, line):
36
		if num > self.last_copyright_line + 2:
37
		if num > 2:
37
			return
38
			return
38
		elif num == self.last_copyright_line + 1:
39
		elif num == 0:
39
			# copyright can extend for a few initial lines
40
			if not self.gentoo_copyright_re.match(line):
40
			copy_match = self.copyright_re.match(line)
41
			if copy_match is not None:
42
				self.last_copyright_line = num
43
				self.last_copyright_year = max(self.last_copyright_year,
44
						int(copy_match.group('year')))
45
			# no copyright lines found?
46
			elif self.last_copyright_line == -1:
47
				return self.errors['COPYRIGHT_ERROR']
41
				return self.errors['COPYRIGHT_ERROR']
48
			else:
42
		elif num == 1 and line.rstrip('\n') != self.gentoo_license:
49
				# verify that the newest copyright line found
43
			return self.errors['LICENSE_ERROR']
50
				# matches the year of last modification
44
		elif num == 2 and self.id_header_re.match(line):
51
				if (self.modification_year is not None
45
			return self.errors['ID_HEADER_ERROR']
52
						and self.last_copyright_year != self.modification_year):
46
		elif num == 2 and not self.blank_line_re.match(line):
53
					return self.errors['COPYRIGHT_DATE_ERROR']
47
			return self.errors['NO_BLANK_LINE_ERROR']
54
55
				# copyright is immediately followed by license
56
				if line.rstrip('\n') != self.gentoo_license:
57
					return self.errors['LICENSE_ERROR']
58
		elif num == self.last_copyright_line + 2:
59
			if self.id_header_re.match(line):
60
				return self.errors['ID_HEADER_ERROR']
61
			elif line.rstrip('\n') != '':
62
				return self.errors['NO_BLANK_LINE_ERROR']
63
- 

Return to bug 666330