libopkg: consider provided packages in pkg_vec_mark_if_matches()
authorJo-Philipp Wich <jo@mein.io>
Tue, 15 Jan 2019 07:46:15 +0000 (08:46 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 15 Jan 2019 07:46:15 +0000 (08:46 +0100)
Also consider the list of provided abstract packages when testing the
package vector for name matches. This fixes the "opkg whatdepends"
command with abstract provided package arguments.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg/pkg_vec.c

index ce098bc..a9e2e73 100644 (file)
@@ -140,12 +140,24 @@ int pkg_vec_mark_if_matches(pkg_vec_t * vec, const char *pattern)
        pkg_t **pkgs = vec->pkgs;
        int npkgs = vec->len;
        int i;
+       abstract_pkg_t **providers, *provider;
+
        for (i = 0; i < npkgs; i++) {
                pkg_t *pkg = pkgs[i];
                if (fnmatch(pattern, pkg->name, 0) == 0) {
                        pkg->state_flag |= SF_MARKED;
                        matching_count++;
                }
+               else {
+                       providers = pkg_get_ptr(pkg, PKG_PROVIDES);
+                       while (providers && *providers) {
+                               provider = *providers++;
+                               if (fnmatch(pattern, provider->name, 0) == 0) {
+                                       pkg->state_flag |= SF_MARKED;
+                                       matching_count++;
+                               }
+                       }
+               }
        }
        return matching_count;
 }