From: Michael Tremer Date: Thu, 3 Mar 2011 22:34:06 +0000 (+0100) Subject: Enhancements and tests for the pkg-config code. X-Git-Tag: 0.9.3~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e583b3ff09edf192f218e0bf6d8cc2e2ea85d921;p=pakfire.git Enhancements and tests for the pkg-config code. --- diff --git a/pakfire/packages/base.py b/pakfire/packages/base.py index 3645bc528..fc6d95ae5 100644 --- a/pakfire/packages/base.py +++ b/pakfire/packages/base.py @@ -295,6 +295,11 @@ class Package(object): (r_expr, r_name, r_version) = \ util.parse_pkgconfig_expr(requires.requires) + # If we get an invalid expression with no name, we + # do not provide this. + if not r_name: + return False + for provides in self.provides: if not provides.startswith("pkgconfig("): continue diff --git a/pakfire/packages/util.py b/pakfire/packages/util.py index bf895f11d..3b6bb9d41 100644 --- a/pakfire/packages/util.py +++ b/pakfire/packages/util.py @@ -133,7 +133,7 @@ def parse_pkgconfig_expr(s): (name, exp, version) = (None, None, None) - m = re.match(r"^([A-Za-z0-9\-\+]+)(=|\<|\>|\>=|\<=)?([A-Za-z0-9\.\-]+)?", s) + m = re.match(r"^pkgconfig\(([A-Za-z0-9\.\-\+]+)\)(=|\<|\>|\>=|\<=)?([A-Za-z0-9\.\-]+)?", s) if m: (name, exp, version) = m.groups() @@ -141,5 +141,16 @@ def parse_pkgconfig_expr(s): return (exp, name, version) +def test_parse_pkgconfig_expr(): + strings = ( + "pkgconfig(libxml-2.0)", + "pkgconfig(libxml-2.0)=1.2.3", + "pkgconfig(libxml-2.0)>=1.2.3", + ) + + for s in strings: + print s, parse_pkgconfig_expr(s) + if __name__ == "__main__": test_parse_pkg_expr() + test_parse_pkgconfig_expr()