[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libosinfo] [libosinfo PATCH 4/8] db: Deal with "unknown" tree architectures



On Wed, Mar 27, 2019 at 12:42 PM Daniel P. Berrangé <berrange redhat com> wrote:
>
> On Wed, Mar 27, 2019 at 12:24:26PM +0100, Fabiano Fidêncio wrote:
> > https://gitlab.com/libosinfo/libosinfo/issues/20
>
> Commit messages should be self-contained, fully describing why that are
> doing what they're doing & why.

' "unknown" tree architectures (from our database) are used as a
fallback to guess some os from a tree.

  Knowing that, any entry containing "unknown" architecture should not
be considered in the first iteration done trying to match the passed
tree with our database entries, thus those are skipped.

  The skipped entries are, later on, considered in case no specific
match has been found.'

I'll add the above text to this commit and a similar one to the commit
dealing with medias.

>
> It is fine to include a bug URL, but the commit message should
> expect that the URL becomes a 404 in the future.
>
> >
> > Signed-off-by: Fabiano Fidêncio <fidencio redhat com>
> > ---
> >  osinfo/osinfo_db.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 44 insertions(+)
> >
> > diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
> > index b6d9282..1038142 100644
> > --- a/osinfo/osinfo_db.c
> > +++ b/osinfo/osinfo_db.c
> > @@ -761,6 +761,7 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
> >      OsinfoOs *ret = NULL;
> >      GList *oss = NULL;
> >      GList *os_iter;
> > +    GList *unknown_oss = NULL;
> >      const gchar *tree_arch;
> >      const gchar *treeinfo_family;
> >      const gchar *treeinfo_variant;
> > @@ -797,6 +798,11 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
> >                  continue;
> >
> >              os_tree_arch = osinfo_tree_get_architecture(os_tree);
> > +            if (g_str_equal(os_tree_arch, "unknown")) {
> > +                unknown_oss = g_list_prepend(unknown_oss, os);
> > +                continue;
> > +            }
> > +
> >              os_treeinfo_family = osinfo_tree_get_treeinfo_family(os_tree);
> >              os_treeinfo_variant = osinfo_tree_get_treeinfo_variant(os_tree);
> >              os_treeinfo_version = osinfo_tree_get_treeinfo_version(os_tree);
> > @@ -817,11 +823,49 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
> >          g_list_free(trees);
> >          g_object_unref(tree_list);
> >
> > +        if (ret)
> > +            goto end;
> > +    }
> > +
> > +    for (os_iter = unknown_oss; os_iter; os_iter = os_iter->next) {
> > +        OsinfoOs *os = OSINFO_OS(os_iter->data);
> > +        OsinfoTreeList *tree_list = osinfo_os_get_tree_list(os);
> > +        GList *trees = osinfo_list_get_elements(OSINFO_LIST(tree_list));
> > +        GList *tree_iter;
> > +
> > +        for (tree_iter = trees; tree_iter; tree_iter = tree_iter->next) {
> > +            OsinfoTree *os_tree = OSINFO_TREE(tree_iter->data);
> > +            const gchar *os_treeinfo_family;
> > +            const gchar *os_treeinfo_variant;
> > +            const gchar *os_treeinfo_version;
> > +            const gchar *os_treeinfo_arch;
> > +
> > +            os_treeinfo_family = osinfo_tree_get_treeinfo_family(os_tree);
> > +            os_treeinfo_variant = osinfo_tree_get_treeinfo_variant(os_tree);
> > +            os_treeinfo_version = osinfo_tree_get_treeinfo_version(os_tree);
> > +            os_treeinfo_arch = osinfo_tree_get_treeinfo_arch(os_tree);
> > +
> > +            if (match_regex(os_treeinfo_family, treeinfo_family) &&
> > +                match_regex(os_treeinfo_variant, treeinfo_variant) &&
> > +                match_regex(os_treeinfo_version, treeinfo_version) &&
> > +                match_regex(os_treeinfo_arch, treeinfo_arch)) {
> > +                ret = os;
> > +                if (matched_tree != NULL)
> > +                    *matched_tree = os_tree;
> > +                break;
> > +            }
> > +        }
> > +
> > +        g_list_free(trees);
> > +        g_object_unref(tree_list);
> > +
> >          if (ret)
> >              break;
> >      }
> >
> > + end:
> >      g_list_free(oss);
> > +    g_list_free(unknown_oss);
> >
> >      return ret;
> >  }
> > --
> > 2.20.1
> >
> > _______________________________________________
> > Libosinfo mailing list
> > Libosinfo redhat com
> > https://www.redhat.com/mailman/listinfo/libosinfo
>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]