[Libosinfo] [libosinfo PATCH v2 4/5] os: Introduce APIs to deal with images
Fabiano Fidêncio
fidencio at redhat.com
Thu Nov 1 14:52:04 UTC 2018
On Thu, Nov 1, 2018 at 1:45 PM Fabiano Fidêncio <fidencio at redhat.com> wrote:
>
> Let's introduce the needed APIs on os side to deal will the images.
> For now, there's no info being loaded as the loader part depends on one
> of these APIs.
>
> https://gitlab.com/libosinfo/osinfo-db/issues/10
>
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
> osinfo/osinfo_os.c | 37 +++++++++++++++++++++++++++++++++++++
> osinfo/osinfo_os.h | 4 ++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
> index 4f74331..6e12a06 100644
> --- a/osinfo/osinfo_os.c
> +++ b/osinfo/osinfo_os.c
> @@ -52,6 +52,7 @@ struct _OsinfoOsPrivate
>
> OsinfoMediaList *medias;
> OsinfoTreeList *trees;
> + OsinfoImageList *images;
> OsinfoOsVariantList *variants;
> OsinfoResourcesList *minimum;
> OsinfoResourcesList *recommended;
> @@ -116,6 +117,7 @@ osinfo_os_finalize(GObject *object)
> g_list_free(os->priv->deviceLinks);
> g_object_unref(os->priv->medias);
> g_object_unref(os->priv->trees);
> + g_object_unref(os->priv->images);
> g_object_unref(os->priv->variants);
> g_object_unref(os->priv->minimum);
> g_object_unref(os->priv->recommended);
> @@ -181,6 +183,7 @@ osinfo_os_init(OsinfoOs *os)
> os->priv->deviceLinks = NULL;
> os->priv->medias = osinfo_medialist_new();
> os->priv->trees = osinfo_treelist_new();
> + os->priv->images = osinfo_imagelist_new();
> os->priv->variants = osinfo_os_variantlist_new();
> os->priv->minimum = osinfo_resourceslist_new();
> os->priv->recommended = osinfo_resourceslist_new();
> @@ -494,6 +497,40 @@ void osinfo_os_add_tree(OsinfoOs *os, OsinfoTree *tree)
> osinfo_list_add(OSINFO_LIST(os->priv->trees), OSINFO_ENTITY(tree));
> }
>
> +/**
> + * osinfo_os_get_image_list:
> + * @os: an operating system
> + *
> + * Get all installed images associated with operating system @os.
> + *
> + * Returns: (transfer full): A list of images
> + */
> +OsinfoImageList *osinfo_os_get_image_list(OsinfoOs *os)
> +{
> + g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
> +
> + OsinfoImageList *newList = osinfo_imagelist_new();
> +
> + osinfo_list_add_all(OSINFO_LIST(newList), OSINFO_LIST(os->priv->images));
> +
> + return newList;
> +}
> +
> +/**
> + * osinfo_os_add_image:
> + * @os: an operating system
> + * @image: (transfer none): the image to add
> + *
> + * Adds an installed image @image to operating system @os.
> + */
> +void osinfo_os_add_image(OsinfoOs *os, OsinfoImage *image)
> +{
> + g_return_if_fail(OSINFO_IS_OS(os));
> + g_return_if_fail(OSINFO_IS_IMAGE(image));
> +
> + osinfo_list_add(OSINFO_LIST(os->priv->images), OSINFO_ENTITY(image));
> +}
> +
> /**
> * osinfo_os_get_variant_list:
> * @os: an operating system
> diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
> index 96bd6e3..d51bbb4 100644
> --- a/osinfo/osinfo_os.h
> +++ b/osinfo/osinfo_os.h
> @@ -34,6 +34,8 @@
> #include <osinfo/osinfo_tree.h>
> #include <osinfo/osinfo_resources.h>
> #include <osinfo/osinfo_resourceslist.h>
> +#include <osinfo/osinfo_image.h>
> +#include <osinfo/osinfo_imagelist.h>
>
> #ifndef __OSINFO_OS_H__
> #define __OSINFO_OS_H__
> @@ -116,6 +118,8 @@ OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
> void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
> OsinfoTreeList *osinfo_os_get_tree_list(OsinfoOs *os);
> void osinfo_os_add_tree(OsinfoOs *os, OsinfoTree *tree);
> +OsinfoImageList *osinfo_os_get_image_list(OsinfoOs *os);
> +void osinfo_os_add_image(OsinfoOs *os, OsinfoImage *image);
> OsinfoOsVariantList *osinfo_os_get_variant_list(OsinfoOs *os);
> void osinfo_os_add_variant(OsinfoOs *os, OsinfoOsVariant *variant);
> OsinfoResourcesList *osinfo_os_get_minimum_resources(OsinfoOs *os);
> --
> 2.19.1
>
And this patch will need the following fixup:
Author: Fabiano Fidêncio <fidencio at redhat.com>
AuthorDate: Thu Nov 1 15:48:55 2018 +0100
Commit: Fabiano Fidêncio <fidencio at redhat.com>
CommitDate: Thu Nov 1 15:50:36 2018 +0100
fixup! os: Introduce APIs to deal with images
---
osinfo/libosinfo.syms | 3 +++
1 file changed, 3 insertions(+)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index aeb74a7..7711bce 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -541,6 +541,9 @@ LIBOSINFO_1.3.0 {
osinfo_imagelist_get_type;
osinfo_imagelist_new;
+
+ osinfo_os_add_image;
+ osinfo_os_get_image_list;
} LIBOSINFO_0.2.13;
/* Symbols in next release...
More information about the Libosinfo
mailing list