[arch-projects] [namcap] [PATCH v2] makedepends: Make VCS matching more robust
If a VCS source is renamed using the "::" syntax the makedepends are not detected. If there are files starting with <name of VCS binary> in the source array false positives are produced. See the gitlab package for example. Make the matching more robust to avoid such issues. Signed-off-by: Michael Straube <michael.straube@posteo.de> --- v1 -> v2 Make it also work for e.g. git:// Namcap/rules/makedepends.py | 10 +++++++++- Namcap/tests/pkgbuild/test_makedepends.py | 15 +++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py index 2a0ceaa..65747c4 100644 --- a/Namcap/rules/makedepends.py +++ b/Namcap/rules/makedepends.py @@ -54,9 +54,17 @@ class VCSMakedepends(PkgbuildRule): 'svn' : 'subversion', } missing = [] + protocols = set() + + for s in pkginfo["source"]: + p = s.split("::", 1)[-1] + p = p.split("://", 1)[0] + p = p.split("+", 1)[0] + if p in vcs: + protocols.add(p) for v in vcs: - if not any(s.startswith(v) for s in pkginfo["source"]): + if not v in protocols: continue d = vcs[v] if 'makedepends' not in pkginfo: diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py index 78c476a..d443b2b 100644 --- a/Namcap/tests/pkgbuild/test_makedepends.py +++ b/Namcap/tests/pkgbuild/test_makedepends.py @@ -76,10 +76,10 @@ 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) +source=(name::bzr+https://example.com/pub/mypackage + name::git://example.com/pub/mypackage + hg+https://example.com/pub/mypackage + svn://example.com/pub/mypackage) md5sums=('abcdefabcdef12345678901234567890') build() { @@ -104,4 +104,11 @@ package() { set(("missing-vcs-makedeps %s", i) for i in makedeps)) self.assertEqual(r.infos, []) + def test_example2(self): + # Example 2 + r = self.run_on_pkg(self.pkgbuild1 + 'source=(gitsomething)') + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, []) + self.assertEqual(r.infos, []) + # vim: set ts=4 sw=4 noet: -- 2.19.2
On 12/2/18 8:01 AM, Michael Straube via arch-projects wrote:
If a VCS source is renamed using the "::" syntax the makedepends are not detected. If there are files starting with <name of VCS binary> in the source array false positives are produced. See the gitlab package for example. Make the matching more robust to avoid such issues.
Signed-off-by: Michael Straube <michael.straube@posteo.de> --- v1 -> v2 Make it also work for e.g. git://
Namcap/rules/makedepends.py | 10 +++++++++- Namcap/tests/pkgbuild/test_makedepends.py | 15 +++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py index 2a0ceaa..65747c4 100644 --- a/Namcap/rules/makedepends.py +++ b/Namcap/rules/makedepends.py @@ -54,9 +54,17 @@ class VCSMakedepends(PkgbuildRule): 'svn' : 'subversion', } missing = [] + protocols = set() + + for s in pkginfo["source"]: + p = s.split("::", 1)[-1] + p = p.split("://", 1)[0] + p = p.split("+", 1)[0] + if p in vcs: + protocols.add(p)
for v in vcs: - if not any(s.startswith(v) for s in pkginfo["source"]): + if not v in protocols:
Why not just check if protocols is empty? -- Eli Schwartz Bug Wrangler and Trusted User
Am 02.12.18 um 14:14 schrieb Eli Schwartz via arch-projects:
On 12/2/18 8:01 AM, Michael Straube via arch-projects wrote:
If a VCS source is renamed using the "::" syntax the makedepends are not detected. If there are files starting with <name of VCS binary> in the source array false positives are produced. See the gitlab package for example. Make the matching more robust to avoid such issues.
Signed-off-by: Michael Straube <michael.straube@posteo.de> --- v1 -> v2 Make it also work for e.g. git://
Namcap/rules/makedepends.py | 10 +++++++++- Namcap/tests/pkgbuild/test_makedepends.py | 15 +++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py index 2a0ceaa..65747c4 100644 --- a/Namcap/rules/makedepends.py +++ b/Namcap/rules/makedepends.py @@ -54,9 +54,17 @@ class VCSMakedepends(PkgbuildRule): 'svn' : 'subversion', } missing = [] + protocols = set() + + for s in pkginfo["source"]: + p = s.split("::", 1)[-1] + p = p.split("://", 1)[0] + p = p.split("+", 1)[0] + if p in vcs: + protocols.add(p)
for v in vcs: - if not any(s.startswith(v) for s in pkginfo["source"]): + if not v in protocols:
Why not just check if protocols is empty?
Good point, thanks again.
participants (2)
-
Eli Schwartz
-
Michael Straube