[arch-projects] [namcap] [PATCH v2 1/3] Warn about makedepends already in depends
Add a rule that warns about make dependencies already listed as dependencies. Signed-off-by: Michael Straube <michael.straube@posteo.de> --- v1 -> v2 Added patch that implements FS#58303 Warn about missing VCS make dependencies. Namcap/rules/__init__.py | 1 + Namcap/rules/makedepends.py | 41 +++++++++++++++++++++++++++++++++++++ namcap-tags | 1 + 3 files changed, 43 insertions(+) create mode 100644 Namcap/rules/makedepends.py diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py index e8775a0..dcc950f 100644 --- a/Namcap/rules/__init__.py +++ b/Namcap/rules/__init__.py @@ -59,6 +59,7 @@ from . import ( carch, extravars, invalidstartdir, + makedepends, makepkgfunctions, missingvars, pkginfo, diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py new file mode 100644 index 0000000..48b1049 --- /dev/null +++ b/Namcap/rules/makedepends.py @@ -0,0 +1,41 @@ +# +# namcap rules - makedepends +# Copyright (C) 2018 Michael Straube <michael.straube@posteo.de> +# +# 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 * + +class RedundantMakedepends(PkgbuildRule): + """ + This rule checks for make dependencies that are already + included as dependencies. + """ + name = "makedepends" + description = "Check for redundant make dependencies" + + def analyze(self, pkginfo, pkgbuild): + redundant_makedeps = [] + + if 'makedepends' in pkginfo and 'depends' in pkginfo: + for d in pkginfo["makedepends"]: + if d in pkginfo["depends"]: + redundant_makedeps.append(d) + + for i in redundant_makedeps: + self.warnings.append(("redundant-makedep %s", i)) + +# vim: set ts=4 sw=4 noet: diff --git a/namcap-tags b/namcap-tags index 2133c45..c253042 100644 --- a/namcap-tags +++ b/namcap-tags @@ -71,6 +71,7 @@ potential-non-fhs-man-page %s :: Potential non-FHS man page (%s) found. py-mtime-mtree-warning :: Found .py file unnoticeably newer than associated .pyc/pyo. py-mtime-tar-error :: Found .py file newer than associated .pyc/pyo. py-mtime-file-name %s :: Python script (%s) is newer than associated .pyc/pyo. +redundant-makedep %s :: Make dependency (%s) already included as dependency script-link-detected %s in %s :: Script link detected (%s) in file %s scrollkeeper-dir-exists %s :: Scrollkeeper directory exists (%s). Remember to not run scrollkeeper till post_{install,upgrade,remove}. site-ruby :: Found usr/lib/ruby/site_ruby in package, usr/lib/ruby/vendor_ruby should be used instead. -- 2.19.2
Signed-off-by: Michael Straube <michael.straube@posteo.de> --- Namcap/tests/pkgbuild/test_makedepends.py | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Namcap/tests/pkgbuild/test_makedepends.py diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py new file mode 100644 index 0000000..c8d6e97 --- /dev/null +++ b/Namcap/tests/pkgbuild/test_makedepends.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# +# namcap tests - makedepends +# Copyright (C) 2011 Rémy Oudompheng <remy@archlinux.org> +# +# 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.tests.pkgbuild_test import PkgbuildTest +import Namcap.rules.makedepends as module + +class NamcapRedundantMakedependsTest(PkgbuildTest): + pkgbuild1 = """ +# Maintainer: Arch Linux <archlinux@example.com> +# Contributor: Arch Linux <archlinux@example.com> + +pkgname=mypackage +pkgver=1.0 +pkgrel=1 +pkgdesc="A package" +url="http://www.example.com/" +arch=('i686' 'x86_64') +depends=('lib1' 'lib2' 'lib3') +makedepends=('lib1' 'lib2' 'lib4') +license=('GPL') +options=('!libtool') +source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz) +md5sums=('abcdefabcdef12345678901234567890') + +build() { + true +} + +package() { + true +} +""" + + test_valid = PkgbuildTest.valid_tests + + def preSetUp(self): + self.rule = module.RedundantMakedepends + + def test_example1(self): + # Example 1 + r = self.run_on_pkg(self.pkgbuild1) + self.assertEqual(r.errors, []) + self.assertEqual(set(r.warnings), + set(("redundant-makedep %s", i) for i in ["lib1" ,"lib2"])) + self.assertEqual(r.infos, []) + +# vim: set ts=4 sw=4 noet: -- 2.19.2
Signed-off-by: Michael Straube <michael.straube@posteo.de> --- Namcap/rules/makedepends.py | 32 ++++++++++++++++- Namcap/tests/pkgbuild/test_makedepends.py | 44 ++++++++++++++++++++++- namcap-tags | 1 + 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py index 48b1049..1a32690 100644 --- a/Namcap/rules/makedepends.py +++ b/Namcap/rules/makedepends.py @@ -17,6 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +import re from Namcap.ruleclass import * class RedundantMakedepends(PkgbuildRule): @@ -24,7 +25,7 @@ class RedundantMakedepends(PkgbuildRule): This rule checks for make dependencies that are already included as dependencies. """ - name = "makedepends" + name = "redundant_makedepends" description = "Check for redundant make dependencies" def analyze(self, pkginfo, pkgbuild): @@ -38,4 +39,33 @@ class RedundantMakedepends(PkgbuildRule): for i in redundant_makedeps: self.warnings.append(("redundant-makedep %s", i)) +class VCSMakedepends(PkgbuildRule): + """ + This rule checks for missing VCS make dependencies. + """ + name = "vcs_makedepends" + description = "Verify make dependencies for VCS sources" + + def analyze(self, pkginfo, pkgbuild): + vcs = { + 'bzr' : 'bzr', + 'git' : 'git', + 'hg' : 'mercurial', + 'svn' : 'subversion' + } + missing = [] + + for i in pkginfo["source"]: + for j in vcs: + if re.match('^' + j + '+.*$', i): + d = vcs.get(j) + if 'makedepends' in pkginfo: + if d not in pkginfo["makedepends"]: + missing.append(d) + else: + missing.append(d) + + for i in missing: + self.warnings.append(("missing-vcs-makedeps %s", i)) + # vim: set ts=4 sw=4 noet: diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py index c8d6e97..15f5360 100644 --- a/Namcap/tests/pkgbuild/test_makedepends.py +++ b/Namcap/tests/pkgbuild/test_makedepends.py @@ -48,7 +48,6 @@ package() { true } """ - test_valid = PkgbuildTest.valid_tests def preSetUp(self): @@ -62,4 +61,47 @@ package() { set(("redundant-makedep %s", i) for i in ["lib1" ,"lib2"])) self.assertEqual(r.infos, []) +class NamcapVCSMakedependsTest(PkgbuildTest): + pkgbuild1 = """ +# Maintainer: Arch Linux <archlinux@example.com> +# Contributor: Arch Linux <archlinux@example.com> + +pkgname=mypackage +pkgver=1.0 +pkgrel=1 +pkgdesc="A package" +url="http://www.example.com/" +arch=('i686' 'x86_64') +depends=() +makedepends=() +license=('GPL') +options=('!libtool') +source=(bzr+https://ftp.example.com/pub/mypackage + git+https://ftp.example.com/pub/mypackage + hg+https://ftp.example.com/pub/mypackage + svn+https://ftp.example.com/pub/mypackage) +md5sums=('abcdefabcdef12345678901234567890') + +build() { + true +} + +package() { + true +} +""" + test_valid = PkgbuildTest.valid_tests + + def preSetUp(self): + self.rule = module.VCSMakedepends + + def test_example1(self): + # Example 1 + makedeps = ['bzr', 'git', 'mercurial', 'subversion'] + r = self.run_on_pkg(self.pkgbuild1) + self.assertEqual(r.errors, []) + self.assertEqual(set(r.warnings), + set(("missing-vcs-makedeps %s", i) for i in makedeps)) + self.assertEqual(r.infos, []) + # vim: set ts=4 sw=4 noet: diff --git a/namcap-tags b/namcap-tags index c253042..eade98e 100644 --- a/namcap-tags +++ b/namcap-tags @@ -58,6 +58,7 @@ missing-checksums :: Missing checksums missing-url :: Missing url missing-pkgfunction %s :: Child package %s does not have a valid package() function missing-makedeps %s :: Split PKGBUILD needs additional makedepends %s to work properly +missing-vcs-makedeps %s :: VCS source PKGBUILD needs additional makedepends '%s' to work properly no-elffiles-not-any-package :: No ELF files and not an "any" package non-fhs-info-page %s :: Non-FHS info page (%s) found. Use /usr/share/info instead non-fhs-man-page %s :: Non-FHS man page (%s) found. Use /usr/share/man instead -- 2.19.2
participants (1)
-
Michael Straube