[arch-projects] [namcap][PATCH] add two rules which check if a PKGBUILD for vcs packages contains the correct makedepends and conflicts array

Jelle van der Waa jelle at vdwaa.nl
Sun Sep 8 14:32:29 EDT 2013


---
 Namcap/rules/__init__.py    |  3 ++-
 Namcap/rules/vcspackages.py | 43 +++++++++++++++++++++++++++++++++++++++++++
 namcap-tags                 |  3 +++
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 Namcap/rules/vcspackages.py

diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py
index f7780d2..62c2617 100644
--- a/Namcap/rules/__init__.py
+++ b/Namcap/rules/__init__.py
@@ -60,7 +60,8 @@ from . import (
   pkginfo,
   pkgnameindesc,
   sfurl,
-  splitpkgbuild
+  splitpkgbuild,
+  vcspackages
 )
 
 all_rules = {}
diff --git a/Namcap/rules/vcspackages.py b/Namcap/rules/vcspackages.py
new file mode 100644
index 0000000..041ddf9
--- /dev/null
+++ b/Namcap/rules/vcspackages.py
@@ -0,0 +1,43 @@
+# 
+# namcap rules - vcspackages
+# Copyright (C) 2013 Jelle van der Waa <jelle at vdwaa.nl>
+# 
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+from Namcap.ruleclass import *
+
+vcspackages = {'-git': 'git', '-svn': 'subversion', '-bzr': 'bzr', '-hg': 'mercurial' }
+
+class ConflictsRule(PkgbuildRule):
+	name = "conflictsrule"
+	description = "Verifies if a pkgname-vcs package conflicts with pkgname"
+	def analyze(self, pkginfo, tar):
+		if 'name' in pkginfo:
+			if any(pkginfo["name"].endswith(vcs) for vcs in vcspackages) and not "conflicts" in pkginfo:
+				self.warnings.append(("vcs-package-conflicts", ()))
+
+class MakedependsRule(PkgbuildRule):
+	name = "makedependsrule"
+	description = "Checks if a vcs package has the correct makedepends array"
+	def analyze(self, pkginfo, tar):
+		if 'name' in pkginfo:
+			for vcsname, vcspkg in vcspackages.items():
+				if not pkginfo['name'].endswith(vcsname):
+					continue
+				if 'makedepends' not in pkginfo or vcspkg not in pkginfo['makedepends']:
+					self.errors.append(("vcs-package-makedepends-missing %s", vcspkg))
+
+# vim: set ts=4 sw=4 noet:
diff --git a/namcap-tags b/namcap-tags
index 818c7a5..ecde1c0 100644
--- a/namcap-tags
+++ b/namcap-tags
@@ -77,6 +77,9 @@ use-pkgdir :: Use $pkgdir instead of $startdir/pkg
 use-srcdir :: Use $srcdir instead of $startdir/src
 using-dl-sourceforge :: Attempting to use dl sourceforge domain, use downloads.sourceforge.net instead
 variable-not-array %s :: Variable %s is not an array.
+vcs-package-conflicts :: Vcs package should conflict with the non-vcs version
+vcs-package-makedepends-missing %s :: Makedepends array should contain '%s' 
+
 
 # dependency tags
 dependency-already-satisfied %s :: Dependency %s included but already satisfied
-- 
1.8.4



More information about the arch-projects mailing list