Bug #324075 - Avoid erroneous 'Invalid Gentoo Copyright' warnings when
authorZac Medico <zmedico@gentoo.org>
Tue, 15 Jun 2010 17:53:36 +0000 (10:53 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 15 Jun 2010 17:53:36 +0000 (10:53 -0700)
the vcs (git) does not support mtime preservation. Also, fix the same
check to work for ebuilds wiht copyrigh beginning in 2011 and later.

bin/repoman
pym/repoman/checks.py

index 14d442dc7e216fc5f0794b7fe7642ed7ed982a6d..6124f04089d2b2cb2582c35c2b961a601d45e8a1 100755 (executable)
@@ -494,6 +494,9 @@ elif os.path.isdir(os.path.join(portdir_overlay, ".hg")):
 # This is needed because we try to avoid merge collisions.
 check_changelog = vcs in ('CVS', 'SVN')
 
+# Disable copyright/mtime check if vcs does not preserve mtime (bug #324075).
+check_copyright_mtime = vcs not in ('git',)
+
 vcs_local_opts = repoman_settings.get("REPOMAN_VCS_LOCAL_OPTS", "").split()
 vcs_global_opts = repoman_settings.get("REPOMAN_VCS_GLOBAL_OPTS")
 if vcs_global_opts is None:
@@ -1769,6 +1772,8 @@ for x in scanlist:
                # Syntax Checks
                relative_path = os.path.join(x, y + ".ebuild")
                full_path = os.path.join(repodir, relative_path)
+               if not check_copyright_mtime:
+                       pkg.mtime = None
                try:
                        # All ebuilds should have utf_8 encoding.
                        f = codecs.open(_unicode_encode(full_path,
index 23f1267d92868928303bd40b444925ebc8ebd939..4d12b07fdca69e76920784bc1d0dc635fbf95978 100644 (file)
@@ -67,14 +67,17 @@ class EbuildHeader(LineCheck):
 
        repoman_check_name = 'ebuild.badheader'
 
-       gentoo_copyright = r'^# Copyright ((1999|200\d)-)?%s Gentoo Foundation$'
+       gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$'
        # Why a regex here, use a string match
        # gentoo_license = re.compile(r'^# Distributed under the terms of the GNU General Public License v2$')
        gentoo_license = r'# Distributed under the terms of the GNU General Public License v2'
        cvs_header = re.compile(r'^#\s*\$Header.*\$$')
 
        def new(self, pkg):
-               self.modification_year = str(time.gmtime(pkg.mtime)[0])
+               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)