Discussion:
[arch-projects] [namcap] [PATCH] makedepends: Make VCS matching more robust
Michael Straube via arch-projects
2018-12-01 14:54:27 UTC
Permalink
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 <***@posteo.de>
---
Perhaps there is a more elegant way?

Namcap/rules/makedepends.py | 2 +-
Namcap/tests/pkgbuild/test_makedepends.py | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
index 2a0ceaa..710e969 100644
--- a/Namcap/rules/makedepends.py
+++ b/Namcap/rules/makedepends.py
@@ -56,7 +56,7 @@ class VCSMakedepends(PkgbuildRule):
missing = []

for v in vcs:
- if not any(s.startswith(v) for s in pkginfo["source"]):
+ if not any(s.split("::")[-1].startswith(v + '+') for s in pkginfo["source"]):
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..0309016 100644
--- a/Namcap/tests/pkgbuild/test_makedepends.py
+++ b/Namcap/tests/pkgbuild/test_makedepends.py
@@ -77,7 +77,7 @@ makedepends=()
license=('GPL')
options=('!libtool')
source=(bzr+https://ftp.example.com/pub/mypackage
- git+https://ftp.example.com/pub/mypackage
+ some_name::git+https://ftp.example.com/pub/mypackage
hg+https://ftp.example.com/pub/mypackage
svn+https://ftp.example.com/pub/mypackage)
md5sums=('abcdefabcdef12345678901234567890')
@@ -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
Eli Schwartz via arch-projects
2018-12-02 05:04:35 UTC
Permalink
Post by Michael Straube via arch-projects
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.
---
Perhaps there is a more elegant way?
Namcap/rules/makedepends.py | 2 +-
Namcap/tests/pkgbuild/test_makedepends.py | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
index 2a0ceaa..710e969 100644
--- a/Namcap/rules/makedepends.py
+++ b/Namcap/rules/makedepends.py
missing = []
Instead this fails to detect git:// instead?

The check makepkg uses is to strip ::* and then strip ://* to get the
protocol, and match on protocols like git*, although I have pending
patches to also strip +* and match protocols exactly.
Post by Michael Straube via arch-projects
continue
d = vcs[v]
diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py
index 78c476a..0309016 100644
--- a/Namcap/tests/pkgbuild/test_makedepends.py
+++ b/Namcap/tests/pkgbuild/test_makedepends.py
@@ -77,7 +77,7 @@ makedepends=()
license=('GPL')
options=('!libtool')
source=(bzr+https://ftp.example.com/pub/mypackage
- git+https://ftp.example.com/pub/mypackage
+ some_name::git+https://ftp.example.com/pub/mypackage
hg+https://ftp.example.com/pub/mypackage
svn+https://ftp.example.com/pub/mypackage)
md5sums=('abcdefabcdef12345678901234567890')
@@ -104,4 +104,11 @@ package() {
set(("missing-vcs-makedeps %s", i) for i in makedeps))
self.assertEqual(r.infos, [])
+ # Example 2
+ r = self.run_on_pkg(self.pkgbuild1 + 'source=(gitsomething)')
+ self.assertEqual(r.errors, [])
+ self.assertEqual(r.warnings, [])
+ self.assertEqual(r.infos, [])
+
--
Eli Schwartz
Bug Wrangler and Trusted User
Michael Straube via arch-projects
2018-12-02 09:25:50 UTC
Permalink
Post by Eli Schwartz via arch-projects
Post by Michael Straube via arch-projects
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.
---
Perhaps there is a more elegant way?
Namcap/rules/makedepends.py | 2 +-
Namcap/tests/pkgbuild/test_makedepends.py | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
index 2a0ceaa..710e969 100644
--- a/Namcap/rules/makedepends.py
+++ b/Namcap/rules/makedepends.py
missing = []
Instead this fails to detect git:// instead?
The check makepkg uses is to strip ::* and then strip ://* to get the
protocol, and match on protocols like git*, although I have pending
patches to also strip +* and match protocols exactly.
Ah yes, I will send a v2 that also works for things like git://.
Thank you!

Loading...