From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 160A5138331 for ; Thu, 29 Mar 2018 21:35:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ED15FE0984; Thu, 29 Mar 2018 21:35:03 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AF99AE097E for ; Thu, 29 Mar 2018 21:35:03 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1E5ED335C93 for ; Thu, 29 Mar 2018 21:35:02 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 612F526A for ; Thu, 29 Mar 2018 21:35:00 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1522356218.727c92c218a886f4d1fdcf69b68013c6600bb248.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/ X-VCS-Repository: proj/portage X-VCS-Files: repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py repoman/pym/repoman/modules/linechecks/gentoo_header/header.py X-VCS-Directories: repoman/pym/repoman/modules/linechecks/gentoo_header/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 727c92c218a886f4d1fdcf69b68013c6600bb248 X-VCS-Branch: repoman Date: Thu, 29 Mar 2018 21:35:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a30e6289-02ed-4df3-83fc-76cb16659cc7 X-Archives-Hash: 38c8ba552f1d107920681d8ac6106d91 commit: 727c92c218a886f4d1fdcf69b68013c6600bb248 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:38 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=727c92c2 repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++++++++++ .../modules/linechecks/gentoo_header/header.py | 49 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 000000000..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 000000000..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + 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 = r'2\d\d\d' + else: + 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 > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_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'] + +