From zeeshanak at gnome.org Sun Nov 3 16:07:21 2013 From: zeeshanak at gnome.org (Zeeshan Ali (Khattak)) Date: Sun, 3 Nov 2013 16:07:21 +0000 Subject: [Libosinfo] [PATCH v3 2/8] schema: allow to specify is-snapshot for unreleased products In-Reply-To: <877gdb8xdb.fsf@redhat.com> References: <1381934878-22524-1-git-send-email-gscrivan@redhat.com> <1381934878-22524-3-git-send-email-gscrivan@redhat.com> <20131017083153.GF6483@teriyaki.redhat.com> <87li1sclqh.fsf@redhat.com> <20131017090937.GH6483@teriyaki.redhat.com> <877gdb8xdb.fsf@redhat.com> Message-ID: On Thu, Oct 17, 2013 at 9:18 PM, Giuseppe Scrivano wrote: > Christophe Fergeau writes: > >> On Thu, Oct 17, 2013 at 11:03:50AM +0200, Giuseppe Scrivano wrote: >>> Christophe Fergeau writes: >>> >>> >> diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng >>> >> index 735ced0..9841bce 100644 >>> >> --- a/data/schemas/libosinfo.rng >>> >> +++ b/data/schemas/libosinfo.rng >>> >> @@ -212,6 +212,11 @@ >>> >> >>> >> >>> >> >>> >> + >>> >> + >>> >> + >>> >> + >>> >> + >>> > >>> > Regarding this bit, see >>> > https://www.redhat.com/archives/libosinfo/2013-October/msg00014.html >>> >>> since someone is already working on it (I've added that patch just to >>> get "make check" work again), what do you think about addressing this >>> issue once "is-snapshot" is supported by libosinfo and use v2 for now? >> >> This would be fine with me, but is Daniel's call. +1 from my side as well. > Daniel, would you be fine with it? I don't think we need to block on Daniel anymore about this for so long. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 From zeeshanak at gnome.org Sun Nov 3 18:23:06 2013 From: zeeshanak at gnome.org (Zeeshan Ali (Khattak)) Date: Sun, 3 Nov 2013 18:23:06 +0000 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries Message-ID: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> Applications can use this to determine if an OS is just a snapshot and not an actual released product yet. For example, gnome-continuous images for development snapshots of GNOME and pre-release and nightly build ISOs of Fedora etc. --- data/schemas/libosinfo.rng | 5 +++++ osinfo/libosinfo.syms | 4 ++++ osinfo/osinfo_loader.c | 1 + osinfo/osinfo_os.c | 18 ++++++++++++++++++ osinfo/osinfo_os.h | 6 ++++-- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng index 735ced0..1e572e2 100644 --- a/data/schemas/libosinfo.rng +++ b/data/schemas/libosinfo.rng @@ -481,6 +481,11 @@ + + + + + diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms index ccd7c30..85ae67a 100644 --- a/osinfo/libosinfo.syms +++ b/osinfo/libosinfo.syms @@ -444,6 +444,10 @@ LIBOSINFO_0.2.8 { osinfo_product_get_release_date_string; } LIBOSINFO_0.2.7; +LIBOSINFO_0.2.9 { + osinfo_os_get_is_snapshot; +} LIBOSINFO_0.2.8; + /* Symbols in next release... LIBOSINFO_0.0.2 { diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index f852de8..0c873a0 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -1097,6 +1097,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, const gchar *const keys[] = { OSINFO_OS_PROP_FAMILY, OSINFO_OS_PROP_DISTRO, + OSINFO_OS_PROP_IS_SNAPSHOT, NULL }; if (!id) { diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c index 638d9c1..5544036 100644 --- a/osinfo/osinfo_os.c +++ b/osinfo/osinfo_os.c @@ -402,6 +402,24 @@ const gchar *osinfo_os_get_distro(OsinfoOs *os) } /** + * osinfo_os_get_is_snapshot: + * @os: an #OsinfoOs + * + * Use this to determine if @os is just a snapshot and not an actual released + * product yet. For example, gnome-continuous images for development snapshots + * of GNOME and pre-release and nightly build ISOs of Fedora etc. + * + * Returns: (transfer none): %TRUE if @os is a snapshot, %FALSE otherwise. + */ +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os) +{ + g_return_val_if_fail(OSINFO_IS_OS(os), FALSE); + + return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(os), + "is-snapshot"); +} + +/** * osinfo_os_get_media_list: * @os: an operating system * diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h index d667e3b..93b5961 100644 --- a/osinfo/osinfo_os.h +++ b/osinfo/osinfo_os.h @@ -55,8 +55,9 @@ typedef struct _OsinfoOsClass OsinfoOsClass; typedef struct _OsinfoOsPrivate OsinfoOsPrivate; -#define OSINFO_OS_PROP_FAMILY "family" -#define OSINFO_OS_PROP_DISTRO "distro" +#define OSINFO_OS_PROP_FAMILY "family" +#define OSINFO_OS_PROP_DISTRO "distro" +#define OSINFO_OS_PROP_IS_SNAPSHOT "is-snapshot" /* object */ struct _OsinfoOs @@ -93,6 +94,7 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev); const gchar *osinfo_os_get_family(OsinfoOs *os); const gchar *osinfo_os_get_distro(OsinfoOs *os); +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os); 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); -- 1.8.4.2 From zeeshanak at gnome.org Sun Nov 3 19:51:31 2013 From: zeeshanak at gnome.org (Zeeshan Ali (Khattak)) Date: Sun, 3 Nov 2013 19:51:31 +0000 Subject: [Libosinfo] [PATCH v4 2/9] schema: allow to specify is-snapshot for unreleased products In-Reply-To: <1382970418-23952-3-git-send-email-gscrivan@redhat.com> References: <1382970418-23952-1-git-send-email-gscrivan@redhat.com> <1382970418-23952-3-git-send-email-gscrivan@redhat.com> Message-ID: On Mon, Oct 28, 2013 at 2:26 PM, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > data/schemas/libosinfo.rng | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng > index 735ced0..f35e439 100644 > --- a/data/schemas/libosinfo.rng > +++ b/data/schemas/libosinfo.rng > @@ -212,6 +212,11 @@ > > > > + > + > + > + > + I don't think this info is loaded if element is empty. There is no point in adding it if thats the case and also if you are not adding the API to retrieve this info either. As I said in a related mail, this isn't as trivial as it sounds so unless you have time to fix this properly, I suggest we go with the solution I provided ('Add an optional 'snapshot' tag to OS entries') for now and you rebase your patches on top of that patch of mine. We can later change all these boolean elements later then to be less ugly. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 From cfergeau at redhat.com Mon Nov 4 09:22:55 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Mon, 4 Nov 2013 10:22:55 +0100 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries In-Reply-To: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> References: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> Message-ID: <20131104092250.GG16429@teriyaki.cdg.redhat.com> NACK, Daniel's comments still stand, and https://www.redhat.com/archives/libosinfo/2013-October/msg00015.html is not useful at all to convince people that we should go with this for now, or to help out. Christophe On Sun, Nov 03, 2013 at 06:23:06PM +0000, Zeeshan Ali (Khattak) wrote: > Applications can use this to determine if an OS is just a snapshot and > not an actual released product yet. For example, gnome-continuous images > for development snapshots of GNOME and pre-release and nightly build ISOs > of Fedora etc. > --- > data/schemas/libosinfo.rng | 5 +++++ > osinfo/libosinfo.syms | 4 ++++ > osinfo/osinfo_loader.c | 1 + > osinfo/osinfo_os.c | 18 ++++++++++++++++++ > osinfo/osinfo_os.h | 6 ++++-- > 5 files changed, 32 insertions(+), 2 deletions(-) > > diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng > index 735ced0..1e572e2 100644 > --- a/data/schemas/libosinfo.rng > +++ b/data/schemas/libosinfo.rng > @@ -481,6 +481,11 @@ > > > > + > + > + > + > + > > > > diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms > index ccd7c30..85ae67a 100644 > --- a/osinfo/libosinfo.syms > +++ b/osinfo/libosinfo.syms > @@ -444,6 +444,10 @@ LIBOSINFO_0.2.8 { > osinfo_product_get_release_date_string; > } LIBOSINFO_0.2.7; > > +LIBOSINFO_0.2.9 { > + osinfo_os_get_is_snapshot; > +} LIBOSINFO_0.2.8; > + > /* Symbols in next release... > > LIBOSINFO_0.0.2 { > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c > index f852de8..0c873a0 100644 > --- a/osinfo/osinfo_loader.c > +++ b/osinfo/osinfo_loader.c > @@ -1097,6 +1097,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, > const gchar *const keys[] = { > OSINFO_OS_PROP_FAMILY, > OSINFO_OS_PROP_DISTRO, > + OSINFO_OS_PROP_IS_SNAPSHOT, > NULL > }; > if (!id) { > diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c > index 638d9c1..5544036 100644 > --- a/osinfo/osinfo_os.c > +++ b/osinfo/osinfo_os.c > @@ -402,6 +402,24 @@ const gchar *osinfo_os_get_distro(OsinfoOs *os) > } > > /** > + * osinfo_os_get_is_snapshot: > + * @os: an #OsinfoOs > + * > + * Use this to determine if @os is just a snapshot and not an actual released > + * product yet. For example, gnome-continuous images for development snapshots > + * of GNOME and pre-release and nightly build ISOs of Fedora etc. > + * > + * Returns: (transfer none): %TRUE if @os is a snapshot, %FALSE otherwise. > + */ > +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os) > +{ > + g_return_val_if_fail(OSINFO_IS_OS(os), FALSE); > + > + return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(os), > + "is-snapshot"); > +} > + > +/** > * osinfo_os_get_media_list: > * @os: an operating system > * > diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h > index d667e3b..93b5961 100644 > --- a/osinfo/osinfo_os.h > +++ b/osinfo/osinfo_os.h > @@ -55,8 +55,9 @@ typedef struct _OsinfoOsClass OsinfoOsClass; > > typedef struct _OsinfoOsPrivate OsinfoOsPrivate; > > -#define OSINFO_OS_PROP_FAMILY "family" > -#define OSINFO_OS_PROP_DISTRO "distro" > +#define OSINFO_OS_PROP_FAMILY "family" > +#define OSINFO_OS_PROP_DISTRO "distro" > +#define OSINFO_OS_PROP_IS_SNAPSHOT "is-snapshot" > > /* object */ > struct _OsinfoOs > @@ -93,6 +94,7 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil > OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev); > const gchar *osinfo_os_get_family(OsinfoOs *os); > const gchar *osinfo_os_get_distro(OsinfoOs *os); > +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os); > 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); > -- > 1.8.4.2 > > _______________________________________________ > Libosinfo mailing list > Libosinfo at redhat.com > https://www.redhat.com/mailman/listinfo/libosinfo -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From gscrivan at redhat.com Mon Nov 4 09:35:19 2013 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Mon, 04 Nov 2013 10:35:19 +0100 Subject: [Libosinfo] [PATCH v4 2/9] schema: allow to specify is-snapshot for unreleased products In-Reply-To: (Zeeshan Ali's message of "Sun, 3 Nov 2013 19:51:31 +0000") References: <1382970418-23952-1-git-send-email-gscrivan@redhat.com> <1382970418-23952-3-git-send-email-gscrivan@redhat.com> Message-ID: <8761s8ik6g.fsf@redhat.com> "Zeeshan Ali (Khattak)" writes: > On Mon, Oct 28, 2013 at 2:26 PM, Giuseppe Scrivano wrote: >> Signed-off-by: Giuseppe Scrivano >> --- >> data/schemas/libosinfo.rng | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng >> index 735ced0..f35e439 100644 >> --- a/data/schemas/libosinfo.rng >> +++ b/data/schemas/libosinfo.rng >> @@ -212,6 +212,11 @@ >> >> >> >> + >> + >> + >> + >> + > > I don't think this info is loaded if element is empty. There is no > point in adding it if thats the case and also if you are not adding > the API to retrieve this info either. The original goal of this patch was to move some information that is known to virt-manager to libosinfo so that we can use libosinfo instead of hard-coding it. It wasn't my intention to support "is-snapshot" with this series. I needed this patch just to get tests working again and follow the "is-snapshot" design that was suggested to me in the last iteration. > As I said in a related mail, this isn't as trivial as it sounds so > unless you have time to fix this properly, I suggest we go with the > solution I provided ('Add an optional 'snapshot' tag to OS entries') > for now and you rebase your patches on top of that patch of mine. It would make more sense to me that we add these new OSes without depending from another feature that is still work-in-progress. It will be a trivial change to update those once is-snapshot is there. Regards, Giuseppe From zeeshanak at gnome.org Mon Nov 4 15:11:41 2013 From: zeeshanak at gnome.org (Zeeshan Ali (Khattak)) Date: Mon, 4 Nov 2013 15:11:41 +0000 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries In-Reply-To: <20131104092250.GG16429@teriyaki.cdg.redhat.com> References: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> <20131104092250.GG16429@teriyaki.cdg.redhat.com> Message-ID: On Mon, Nov 4, 2013 at 9:22 AM, Christophe Fergeau wrote: > NACK, Daniel's comments still stand, and > https://www.redhat.com/archives/libosinfo/2013-October/msg00015.html is not > useful at all to convince people that we should go with this for now, or > to help out. This patch follows the convention currently followed by libosinfo. Besides its a mater of minor (mostly internal) ugliness so I don't think its worth blocking my changes at all. My changes has been pending for a month now and now you also want Giuseppe's changes to be pending on this change as well. If you think otherwise and are not convinced with my arguments, feel free to fix this yourself. Otherwise, I don't thing you are being very fair here. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 From cfergeau at redhat.com Mon Nov 4 15:54:54 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Mon, 4 Nov 2013 16:54:54 +0100 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries In-Reply-To: References: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> <20131104092250.GG16429@teriyaki.cdg.redhat.com> Message-ID: <20131104155454.GM16429@teriyaki.cdg.redhat.com> On Mon, Nov 04, 2013 at 03:11:41PM +0000, Zeeshan Ali (Khattak) wrote: > If you think otherwise and are not convinced with my arguments, feel > free to fix this yourself. Otherwise, I don't thing you are being very > fair here. I'm not going to duplicate work you have already started. I'm happy to be convinced that supporting is-snapshot is difficult, or to help with the patch, but I cannot do either starting from that email from the archives where you just say "I tried it, it's hard" with no further explanation. Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From zeeshanak at gnome.org Mon Nov 4 16:11:20 2013 From: zeeshanak at gnome.org (Zeeshan Ali (Khattak)) Date: Mon, 4 Nov 2013 16:11:20 +0000 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries In-Reply-To: <20131104155454.GM16429@teriyaki.cdg.redhat.com> References: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> <20131104092250.GG16429@teriyaki.cdg.redhat.com> <20131104155454.GM16429@teriyaki.cdg.redhat.com> Message-ID: On Mon, Nov 4, 2013 at 3:54 PM, Christophe Fergeau wrote: > On Mon, Nov 04, 2013 at 03:11:41PM +0000, Zeeshan Ali (Khattak) wrote: >> If you think otherwise and are not convinced with my arguments, feel >> free to fix this yourself. Otherwise, I don't thing you are being very >> fair here. > > I'm not going to duplicate work you have already started. I'm happy to be > convinced that supporting is-snapshot is difficult, or to help with the > patch, but I cannot do either starting from that email from the archives > where you just say "I tried it, it's hard" with no further explanation. It wasn't previously clear to me that you want to help. Now that it is, here is the my attempt to fix this issue: https://gitorious.org/libosinfo/libosinfo/commit/77531e31ec579d5ce6857f09e983325bb6b56d5c As you can see, I have tried to tell the loader not to ignore empty elements. However, for some reason unknown to me, this break things completely as libosinfo to loads OS entries where there is no name provided. `make check` fails as our test data is matched to unnamed OSs. Anyway, when you build and test those changes, you'll see what I mean and hopefully will have a better luck with figuring out what is going on. Happy hacking :) -- Regards, Zeeshan Ali (Khattak) FSF member#5124 From cfergeau at redhat.com Tue Nov 5 16:14:11 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Tue, 5 Nov 2013 17:14:11 +0100 Subject: [Libosinfo] [v2] Add an optional 'snapshot' tag to OS entries In-Reply-To: References: <1383502986-12672-1-git-send-email-zeeshanak@gnome.org> <20131104092250.GG16429@teriyaki.cdg.redhat.com> <20131104155454.GM16429@teriyaki.cdg.redhat.com> Message-ID: <20131105161411.GV16429@teriyaki.cdg.redhat.com> On Mon, Nov 04, 2013 at 04:11:20PM +0000, Zeeshan Ali (Khattak) wrote: > It wasn't previously clear to me that you want to help. Now that it > is, here is the my attempt to fix this issue: > > https://gitorious.org/libosinfo/libosinfo/commit/77531e31ec579d5ce6857f09e983325bb6b56d5c > > As you can see, I have tried to tell the loader not to ignore empty > elements. However, for some reason unknown to me, this break things > completely as libosinfo to loads OS entries where there is no name > provided. What happens is that string(./foo) in xpath returns "" even for non-existing nodes. If you combine this with the code to load localized values (string(./foo[lang('XX_xx')])), then this means we'll get "" for any non-localized attribute. The patch at http://paste.fedoraproject.org/51766/66649413/ appears to be working, I want to play a bit more with it before sending it. Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From cfergeau at redhat.com Wed Nov 6 13:41:49 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:41:49 +0100 Subject: [Libosinfo] [libosinfo 0/4] In-Reply-To: References: Message-ID: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> Hey, In order to support the syntax to represent booleans in libosinfo databases, some changes are needed in the OsinfoLoader parser in order for it to be able to parse empty nodes when needed (see patch 2/4 for details). These patches do the needed changes, and adjust the libosinfo database to use the shorter syntax for booleans. The older syntax is still supported. An alternative to this patch would be to modify osinfo_loader_string() so that it can make the difference between non-existing nodes, and empty ones. Handling booleans through a new osinfo_loader_boolean() has the advantage that all booleans are stored the same way in the in-memory OsinfoDb. If we change osinfo_loader_string(), some booleans will be stored as ("foo", "true") while others will be stored as ("foo", "") depending on how they are represented in the XML. One last note, the schema change could be improved a little bit, as we have some attributes marked as booleans. The schema allows for an empty value to mean 'true', so will now be accepted and be the same as . We could have 2 'bool' definitions in the schema for nodes and attributes, but that seemed a bit too much. Christophe From cfergeau at redhat.com Wed Nov 6 13:41:52 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:41:52 +0100 Subject: [Libosinfo] [libosinfo 3/4] Teach osinfo_loader_entity() how to parse booleans In-Reply-To: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> References: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745313-18683-4-git-send-email-cfergeau@redhat.com> We want to support both true and to specify booleans. Now that osinfo_loader_entity additional keys have type information, we can use a dedicated boolean parser for boolean keys. --- data/schemas/libosinfo.rng | 9 +++++--- osinfo/osinfo_loader.c | 56 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng index 735ced0..d491832 100644 --- a/data/schemas/libosinfo.rng +++ b/data/schemas/libosinfo.rng @@ -704,9 +704,12 @@ - - true|false - + + + true|false + + + diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 10aff48..9716935 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -186,6 +186,48 @@ osinfo_loader_string(const char *xpath, return ret; } +static gboolean +osinfo_loader_boolean(const char *xpath, + xmlXPathContextPtr ctxt, + GError **err) +{ + + xmlNodePtr *nodes; + int count; + int i; + gboolean ret = FALSE; + + g_return_val_if_fail(ctxt != NULL, NULL); + g_return_val_if_fail(xpath != NULL, NULL); + + count = osinfo_loader_nodeset(xpath, ctxt, &nodes, err); + + if (count < 0) { + return FALSE; + } + for (i = 0 ; i < count ; i++) { + xmlNodePtr node = nodes[i]; + + if (!node->children) { + /* node is present -> TRUE */ + ret = TRUE; + break; + } + if (node->children->type != XML_TEXT_NODE) { + OSINFO_ERROR(err, _("Expected a text node attribute value")); + goto cleanup; + } + + if (g_strcmp0((const char *)nodes[i]->children->content, "true") == 0) { + ret = TRUE; + break; + } + } +cleanup: + g_free(nodes); + return ret; +} + static gchar * osinfo_loader_doc(const char *xpath, xmlXPathContextPtr ctxt, @@ -238,6 +280,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader, /* Standard well-known keys first, allow single value only */ for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) { gchar *value_str = NULL; + gboolean value_bool; gchar *xpath = NULL; int j; @@ -266,6 +309,10 @@ static void osinfo_loader_entity(OsinfoLoader *loader, value_str = osinfo_loader_string(xpath, ctxt, err); } break; + case G_TYPE_BOOLEAN: + xpath = g_strdup_printf("./%s", keys[i].name); + value_bool = osinfo_loader_boolean(xpath, ctxt, err); + break; default: g_warn_if_reached(); break; @@ -280,6 +327,9 @@ static void osinfo_loader_entity(OsinfoLoader *loader, value_str = NULL; } break; + case G_TYPE_BOOLEAN: + osinfo_entity_set_param_boolean(entity, keys[i].name, value_bool); + break; default: g_warn_if_reached(); break; @@ -692,7 +742,7 @@ static OsinfoAvatarFormat *osinfo_loader_avatar_format(OsinfoLoader *loader, { OSINFO_AVATAR_FORMAT_PROP_MIME_TYPE, G_TYPE_STRING }, { OSINFO_AVATAR_FORMAT_PROP_WIDTH, G_TYPE_STRING }, { OSINFO_AVATAR_FORMAT_PROP_HEIGHT, G_TYPE_STRING }, - { OSINFO_AVATAR_FORMAT_PROP_ALPHA, G_TYPE_STRING }, + { OSINFO_AVATAR_FORMAT_PROP_ALPHA, G_TYPE_BOOLEAN }, { NULL, G_TYPE_INVALID } }; @@ -719,8 +769,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, { OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT, G_TYPE_STRING }, { OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT, G_TYPE_STRING }, { OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME, G_TYPE_STRING }, - { OSINFO_INSTALL_SCRIPT_PROP_CAN_PRE_INSTALL_DRIVERS, G_TYPE_STRING }, - { OSINFO_INSTALL_SCRIPT_PROP_CAN_POST_INSTALL_DRIVERS, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_CAN_PRE_INSTALL_DRIVERS, G_TYPE_BOOLEAN }, + { OSINFO_INSTALL_SCRIPT_PROP_CAN_POST_INSTALL_DRIVERS, G_TYPE_BOOLEAN }, { OSINFO_INSTALL_SCRIPT_PROP_PRE_INSTALL_DRIVERS_SIGNING_REQ, G_TYPE_STRING }, { OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ, G_TYPE_STRING }, { NULL, G_TYPE_INVALID } -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:41:50 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:41:50 +0100 Subject: [Libosinfo] [libosinfo 1/4] Allow to pass a NULL 'keys' argument to osinfo_loader_entity() In-Reply-To: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> References: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745313-18683-2-git-send-email-cfergeau@redhat.com> Some callers don't want to pass in any additional keys, and would have to resort to build a dummy empty key list to pass to osinfo_loader_entity(). It's better to allow for that 'keys' argument to be NULL and have osinfo_loader_entity() deal with it. --- osinfo/osinfo_loader.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index f852de8..309d0a5 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -229,7 +229,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader, const gchar * const *langs = g_get_language_names (); /* Standard well-known keys first, allow single value only */ - for (i = 0 ; keys[i] != NULL; i++) { + for (i = 0 ; keys != NULL && keys[i] != NULL; i++) { gchar *value = NULL; gchar *xpath; int j; @@ -509,9 +509,6 @@ static void osinfo_loader_platform(OsinfoLoader *loader, GError **err) { gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); - const gchar *const keys[] = { - NULL, - }; if (!id) { OSINFO_ERROR(err, _("Missing platform id property")); return; @@ -520,7 +517,7 @@ static void osinfo_loader_platform(OsinfoLoader *loader, OsinfoPlatform *platform = osinfo_loader_get_platform(loader, id); xmlFree(id); - osinfo_loader_entity(loader, OSINFO_ENTITY(platform), keys, ctxt, root, err); + osinfo_loader_entity(loader, OSINFO_ENTITY(platform), NULL, ctxt, root, err); if (error_is_set(err)) return; @@ -540,9 +537,6 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, GError **err) { gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); - const gchar *const keys[] = { - NULL - }; if (!id) { OSINFO_ERROR(err, _("Missing deployment id property")); return; @@ -569,7 +563,7 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, OsinfoDeployment *deployment = osinfo_deployment_new(id, os, platform); xmlFree(id); - osinfo_loader_entity(loader, OSINFO_ENTITY(deployment), keys, ctxt, root, err); + osinfo_loader_entity(loader, OSINFO_ENTITY(deployment), NULL, ctxt, root, err); if (error_is_set(err)) { g_object_unref(G_OBJECT(deployment)); return; -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:41:53 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:41:53 +0100 Subject: [Libosinfo] [libosinfo 4/4] Stop using true in libosinfo database In-Reply-To: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> References: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745313-18683-5-git-send-email-cfergeau@redhat.com> libosinfo can now parse as an alternative to true to represent a boolean. As the former is the preferred representation, switch to using this in the data libosinfo ships. --- data/install-scripts/windows-cmd.xml | 2 +- data/install-scripts/windows-sif.xml | 4 ++-- data/install-scripts/windows-unattend.xml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml index 876cf53..04ffb23 100644 --- a/data/install-scripts/windows-cmd.xml +++ b/data/install-scripts/windows-cmd.xml @@ -4,7 +4,7 @@ desktop dos windows.cmd - true + strict diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml index 2bccc5d..b45f154 100644 --- a/data/install-scripts/windows-sif.xml +++ b/data/install-scripts/windows-sif.xml @@ -5,7 +5,7 @@ dos $$$$$-$$$$$-$$$$$-$$$$$-$$$$$ winnt.sif - true + @@ -75,7 +75,7 @@ dos $$$$$-$$$$$-$$$$$-$$$$$-$$$$$ winnt.sif - true + diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml index 93fafa4..37fefdb 100644 --- a/data/install-scripts/windows-unattend.xml +++ b/data/install-scripts/windows-unattend.xml @@ -4,7 +4,7 @@ dos $$$$$-$$$$$-$$$$$-$$$$$-$$$$$ autounattend.xml - true + @@ -216,7 +216,7 @@ dos $$$$$-$$$$$-$$$$$-$$$$$-$$$$$ autounattend.xml - true + -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:41:51 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:41:51 +0100 Subject: [Libosinfo] [libosinfo 2/4] Add type info to osinfo_loader_entity() 'key' argument In-Reply-To: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> References: <1383745313-18683-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745313-18683-3-git-send-email-cfergeau@redhat.com> When using 'string(./foo)' as an XPath query, if foo does not exist, an empty string ("") will be returned. Thus osinfo_loader_string() ignores empty strings during parsing. This happens during regular parsing as we try to lookup string(./foo[lang(XX-xx)]) for localized nodes, and ignore its result if the XPath query returns "" However, we want to represent booleans as . Boolean values are currently parsed using osinfo_loader_string(), which means such nodes will be ignored. By associating type information to the additional keys we want osinfo_loader_entity() to parse, we'll be able to indicate which values are booleans, and to parse them accordingly. --- osinfo/osinfo_loader.c | 180 ++++++++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 77 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 309d0a5..10aff48 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -57,6 +57,13 @@ struct _OsinfoLoaderPrivate OsinfoDb *db; }; +struct _OsinfoEntityKey +{ + const char *name; + GType type; +}; +typedef struct _OsinfoEntityKey OsinfoEntityKey; + static void osinfo_loader_finalize (GObject *object) { @@ -220,7 +227,7 @@ osinfo_loader_doc(const char *xpath, static void osinfo_loader_entity(OsinfoLoader *loader, OsinfoEntity *entity, - const gchar *const *keys, + const OsinfoEntityKey *keys, xmlXPathContextPtr ctxt, xmlNodePtr root, GError **err) @@ -229,37 +236,55 @@ static void osinfo_loader_entity(OsinfoLoader *loader, const gchar * const *langs = g_get_language_names (); /* Standard well-known keys first, allow single value only */ - for (i = 0 ; keys != NULL && keys[i] != NULL; i++) { - gchar *value = NULL; - gchar *xpath; + for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) { + gchar *value_str = NULL; + gchar *xpath = NULL; int j; /* We are guaranteed to have at least the default "C" locale and we * want to ignore that, hence the NULL check on index 'j + 1'. */ - for (j = 0; langs[j + 1] != NULL; j++) { - xpath = g_strdup_printf("string(./%s[lang('%s')])", keys[i], langs[j]); - value = osinfo_loader_string(xpath, ctxt, err); - g_free(xpath); - if (error_is_set(err)) - return; - - if (value != NULL) - break; + if (keys[i].type == G_TYPE_STRING) { + for (j = 0; langs[j + 1] != NULL; j++) { + xpath = g_strdup_printf("string(./%s[lang('%s')])", + keys[i].name, langs[j]); + value_str = osinfo_loader_string(xpath, ctxt, err); + g_free(xpath); + xpath = NULL; + if (error_is_set(err)) + return; + + if (value_str != NULL) + break; + } } - if (value == NULL) { - xpath = g_strdup_printf("string(./%s)", keys[i]); - value = osinfo_loader_string(xpath, ctxt, err); - g_free(xpath); - if (error_is_set(err)) - return; + switch (keys[i].type) { + case G_TYPE_STRING: + xpath = g_strdup_printf("string(./%s)", keys[i].name); + if (value_str == NULL) { + value_str = osinfo_loader_string(xpath, ctxt, err); + } + break; + default: + g_warn_if_reached(); + break; } - - if (value) { - osinfo_entity_set_param(entity, keys[i], value); - g_free(value); + g_free(xpath); + + switch (keys[i].type) { + case G_TYPE_STRING: + if (value_str) { + osinfo_entity_set_param(entity, keys[i].name, value_str); + g_free(value_str); + value_str = NULL; + } + break; + default: + g_warn_if_reached(); + break; } + g_warn_if_fail(value_str == NULL); } /* Then any site specific custom keys. x-... Can be repeated */ @@ -352,16 +377,16 @@ static void osinfo_loader_device(OsinfoLoader *loader, GError **err) { gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); - const gchar *const keys[] = { - OSINFO_DEVICE_PROP_VENDOR, - OSINFO_DEVICE_PROP_VENDOR_ID, - OSINFO_DEVICE_PROP_PRODUCT, - OSINFO_DEVICE_PROP_PRODUCT_ID, - OSINFO_DEVICE_PROP_SUBSYSTEM, - OSINFO_DEVICE_PROP_BUS_TYPE, - OSINFO_DEVICE_PROP_CLASS, - OSINFO_DEVICE_PROP_NAME, - NULL, + const OsinfoEntityKey keys[] = { + { OSINFO_DEVICE_PROP_VENDOR, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_VENDOR_ID, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_PRODUCT, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_PRODUCT_ID, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_SUBSYSTEM, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_BUS_TYPE, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_CLASS, G_TYPE_STRING }, + { OSINFO_DEVICE_PROP_NAME, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; if (!id) { OSINFO_ERROR(err, _("Missing device id property")); @@ -388,9 +413,9 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, return; for (i = 0 ; i < nrelated ; i++) { - const gchar *keys[] = { - OSINFO_DEVICELINK_PROP_DRIVER, - NULL, + const OsinfoEntityKey keys[] = { + { OSINFO_DEVICELINK_PROP_DRIVER, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); if (!id) { @@ -461,16 +486,16 @@ static void osinfo_loader_product(OsinfoLoader *loader, xmlNodePtr root, GError **err) { - const gchar *const keys[] = { - OSINFO_PRODUCT_PROP_NAME, - OSINFO_PRODUCT_PROP_VENDOR, - OSINFO_PRODUCT_PROP_VERSION, - OSINFO_PRODUCT_PROP_LOGO, - OSINFO_PRODUCT_PROP_SHORT_ID, - OSINFO_PRODUCT_PROP_RELEASE_DATE, - OSINFO_PRODUCT_PROP_EOL_DATE, - OSINFO_PRODUCT_PROP_CODENAME, - NULL, + const OsinfoEntityKey keys[] = { + { OSINFO_PRODUCT_PROP_NAME, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_VENDOR, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_VERSION, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_LOGO, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_SHORT_ID, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_RELEASE_DATE, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_EOL_DATE, G_TYPE_STRING }, + { OSINFO_PRODUCT_PROP_CODENAME, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; osinfo_loader_entity(loader, OSINFO_ENTITY(product), keys, ctxt, root, err); @@ -663,12 +688,12 @@ static OsinfoAvatarFormat *osinfo_loader_avatar_format(OsinfoLoader *loader, GError **err) { OsinfoAvatarFormat *avatar_format; - const gchar *const keys[] = { - OSINFO_AVATAR_FORMAT_PROP_MIME_TYPE, - OSINFO_AVATAR_FORMAT_PROP_WIDTH, - OSINFO_AVATAR_FORMAT_PROP_HEIGHT, - OSINFO_AVATAR_FORMAT_PROP_ALPHA, - NULL + const OsinfoEntityKey keys[] = { + { OSINFO_AVATAR_FORMAT_PROP_MIME_TYPE, G_TYPE_STRING }, + { OSINFO_AVATAR_FORMAT_PROP_WIDTH, G_TYPE_STRING }, + { OSINFO_AVATAR_FORMAT_PROP_HEIGHT, G_TYPE_STRING }, + { OSINFO_AVATAR_FORMAT_PROP_ALPHA, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; avatar_format = osinfo_avatar_format_new(); @@ -689,16 +714,16 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, GError **err) { gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); - const gchar *const keys[] = { - OSINFO_INSTALL_SCRIPT_PROP_PROFILE, - OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT, - OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT, - OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME, - OSINFO_INSTALL_SCRIPT_PROP_CAN_PRE_INSTALL_DRIVERS, - OSINFO_INSTALL_SCRIPT_PROP_CAN_POST_INSTALL_DRIVERS, - OSINFO_INSTALL_SCRIPT_PROP_PRE_INSTALL_DRIVERS_SIGNING_REQ, - OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ, - NULL + const OsinfoEntityKey keys[] = { + { OSINFO_INSTALL_SCRIPT_PROP_PROFILE, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_CAN_PRE_INSTALL_DRIVERS, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_CAN_POST_INSTALL_DRIVERS, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_PRE_INSTALL_DRIVERS_SIGNING_REQ, G_TYPE_STRING }, + { OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; gchar *value = NULL; xmlNodePtr *nodes = NULL; @@ -784,11 +809,11 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, xmlChar *installer = xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_INSTALLER); xmlChar *installer_reboots = xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_INSTALLER_REBOOTS); - const gchar *const keys[] = { - OSINFO_MEDIA_PROP_URL, - OSINFO_MEDIA_PROP_KERNEL, - OSINFO_MEDIA_PROP_INITRD, - NULL + const OsinfoEntityKey keys[] = { + { OSINFO_MEDIA_PROP_URL, G_TYPE_STRING }, + { OSINFO_MEDIA_PROP_KERNEL, G_TYPE_STRING }, + { OSINFO_MEDIA_PROP_INITRD, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; OsinfoMedia *media = osinfo_media_new(id, arch); @@ -879,12 +904,12 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, guint i; gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch"); - const gchar *const keys[] = { - OSINFO_TREE_PROP_URL, - OSINFO_TREE_PROP_KERNEL, - OSINFO_TREE_PROP_INITRD, - OSINFO_TREE_PROP_BOOT_ISO, - NULL + const OsinfoEntityKey keys[] = { + { OSINFO_TREE_PROP_URL, G_TYPE_STRING }, + { OSINFO_TREE_PROP_KERNEL, G_TYPE_STRING }, + { OSINFO_TREE_PROP_INITRD, G_TYPE_STRING }, + { OSINFO_TREE_PROP_BOOT_ISO, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; OsinfoTree *tree = osinfo_tree_new(id, arch); @@ -1088,11 +1113,12 @@ static void osinfo_loader_os(OsinfoLoader *loader, int nnodes; gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); - const gchar *const keys[] = { - OSINFO_OS_PROP_FAMILY, - OSINFO_OS_PROP_DISTRO, - NULL + const OsinfoEntityKey keys[] = { + { OSINFO_OS_PROP_FAMILY, G_TYPE_STRING }, + { OSINFO_OS_PROP_DISTRO, G_TYPE_STRING }, + { NULL, G_TYPE_INVALID } }; + if (!id) { OSINFO_ERROR(err, _("Missing os id property")); return; -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:43:42 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:43:42 +0100 Subject: [Libosinfo] [libosinfo 0/4] Add is-snapshot support Message-ID: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> This patch goes on top of the 'boolean support' series, and adds support for the 'is-snapshot' tag. Regarding patch 1/4, I set myself as the author of the commit as it had initially more substantial changes, but now it's very close to the initial patches from Zeeshan, so maybe the author should be switched back (Zeeshan?). I don't care either way. Christophe From cfergeau at redhat.com Wed Nov 6 13:43:45 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:43:45 +0100 Subject: [Libosinfo] [libosinfo 3/4] gnome: Add info for gnome-continuous 3.12 In-Reply-To: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> References: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745426-19948-4-git-send-email-cfergeau@redhat.com> From: "Zeeshan Ali (Khattak)" gnome-continuous is continuous integration system so images produced by it track the git master of all modules and now that GNOME 3.10 is out and many projects have branched for 3.10 maintainance, these images are already 3.12 (3.11 at the moment but thats splitting hair I guess). --- data/oses/gnome.xml.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/data/oses/gnome.xml.in b/data/oses/gnome.xml.in index 20b4b6a..94a2de5 100644 --- a/data/oses/gnome.xml.in +++ b/data/oses/gnome.xml.in @@ -89,4 +89,25 @@ + + gnome-continuous-3.12 + <_name>GNOME 3.12 + 3.12 + <_vendor>GNOME Project + linux + gnome + + + + + 2014-03-25 + + + + 2 + 1073741824 + + + + -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:43:43 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:43:43 +0100 Subject: [Libosinfo] [libosinfo 1/4] Add an optional 'is-snapshot' tag to OS entries In-Reply-To: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> References: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745426-19948-2-git-send-email-cfergeau@redhat.com> Applications can use this to determine if an OS is just a snapshot and not an actual released product yet. For example, gnome-continuous images for development snapshots of GNOME and pre-release and nightly build ISOs of Fedora etc. Based on a patch from Zeeshan Ali --- data/schemas/libosinfo.rng | 5 +++++ osinfo/libosinfo.syms | 4 ++++ osinfo/osinfo_loader.c | 1 + osinfo/osinfo_os.c | 18 ++++++++++++++++++ osinfo/osinfo_os.h | 6 ++++-- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng index d491832..88e5fbf 100644 --- a/data/schemas/libosinfo.rng +++ b/data/schemas/libosinfo.rng @@ -481,6 +481,11 @@ + + + + + diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms index ccd7c30..85ae67a 100644 --- a/osinfo/libosinfo.syms +++ b/osinfo/libosinfo.syms @@ -444,6 +444,10 @@ LIBOSINFO_0.2.8 { osinfo_product_get_release_date_string; } LIBOSINFO_0.2.7; +LIBOSINFO_0.2.9 { + osinfo_os_get_is_snapshot; +} LIBOSINFO_0.2.8; + /* Symbols in next release... LIBOSINFO_0.0.2 { diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 9716935..0be18b8 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -1166,6 +1166,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, const OsinfoEntityKey keys[] = { { OSINFO_OS_PROP_FAMILY, G_TYPE_STRING }, { OSINFO_OS_PROP_DISTRO, G_TYPE_STRING }, + { OSINFO_OS_PROP_IS_SNAPSHOT, G_TYPE_BOOLEAN }, { NULL, G_TYPE_INVALID } }; diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c index 638d9c1..5544036 100644 --- a/osinfo/osinfo_os.c +++ b/osinfo/osinfo_os.c @@ -402,6 +402,24 @@ const gchar *osinfo_os_get_distro(OsinfoOs *os) } /** + * osinfo_os_get_is_snapshot: + * @os: an #OsinfoOs + * + * Use this to determine if @os is just a snapshot and not an actual released + * product yet. For example, gnome-continuous images for development snapshots + * of GNOME and pre-release and nightly build ISOs of Fedora etc. + * + * Returns: (transfer none): %TRUE if @os is a snapshot, %FALSE otherwise. + */ +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os) +{ + g_return_val_if_fail(OSINFO_IS_OS(os), FALSE); + + return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(os), + "is-snapshot"); +} + +/** * osinfo_os_get_media_list: * @os: an operating system * diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h index d667e3b..93b5961 100644 --- a/osinfo/osinfo_os.h +++ b/osinfo/osinfo_os.h @@ -55,8 +55,9 @@ typedef struct _OsinfoOsClass OsinfoOsClass; typedef struct _OsinfoOsPrivate OsinfoOsPrivate; -#define OSINFO_OS_PROP_FAMILY "family" -#define OSINFO_OS_PROP_DISTRO "distro" +#define OSINFO_OS_PROP_FAMILY "family" +#define OSINFO_OS_PROP_DISTRO "distro" +#define OSINFO_OS_PROP_IS_SNAPSHOT "is-snapshot" /* object */ struct _OsinfoOs @@ -93,6 +94,7 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev); const gchar *osinfo_os_get_family(OsinfoOs *os); const gchar *osinfo_os_get_distro(OsinfoOs *os); +gboolean osinfo_os_get_is_snapshot(OsinfoOs *os); 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); -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:43:44 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:43:44 +0100 Subject: [Libosinfo] [libosinfo 2/4] Add testcase for loading OS XML In-Reply-To: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> References: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745426-19948-3-git-send-email-cfergeau@redhat.com> There was no test testing that OS XML data is correctly loaded. This test is also an opportunity to test the various ways of representing a boolean in XML. --- test/test-os.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test-os.xml | 31 +++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 test/test-os.xml diff --git a/test/test-os.c b/test/test-os.c index 8ea86df..d21dda8 100644 --- a/test/test-os.c +++ b/test/test-os.c @@ -63,6 +63,70 @@ START_TEST(test_devices) END_TEST +START_TEST(test_loader) +{ + OsinfoLoader *loader; + OsinfoDb *db; + OsinfoOs *os; + GError *error = NULL; + const char *str; + + loader = osinfo_loader_new(); + osinfo_loader_process_path(loader, SRCDIR "/test/test-os.xml", &error); + fail_unless(error == NULL, error ? error->message:"none"); + db = osinfo_loader_get_db(loader); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/test1"); + fail_unless(os != NULL, "could not find OS 'test1'"); + str = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "test1") == 0, "wrong OS short-id"); + str = osinfo_product_get_name(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "Test 1") == 0, "wrong OS name"); + str = osinfo_product_get_version(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "unknown") == 0, "wrong OS version"); + str = osinfo_product_get_vendor(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "libosinfo.org") == 0, "wrong OS vendor"); + str = osinfo_os_get_family(os); + fail_unless(g_strcmp0(str, "test") == 0, "wrong OS family"); + fail_unless(osinfo_os_get_is_snapshot(os), "OS should be a snapshot"); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/test2"); + fail_unless(os != NULL, "could not find OS 'test2'"); + str = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "test2") == 0, "wrong OS short-id"); + str = osinfo_product_get_name(OSINFO_PRODUCT(os)); + fail_unless(str == NULL, "wrong OS name"); + str = osinfo_product_get_version(OSINFO_PRODUCT(os)); + fail_unless(str == NULL, "wrong OS version"); + str = osinfo_product_get_vendor(OSINFO_PRODUCT(os)); + fail_unless(str == NULL, "wrong OS vendor"); + str = osinfo_os_get_family(os); + fail_unless(str == NULL, "wrong OS family"); + fail_unless(!osinfo_os_get_is_snapshot(os), "OS should not be a snapshot"); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/test3"); + fail_unless(os != NULL, "could not find OS 'test3'"); + str = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "test3") == 0, "wrong OS short-id"); + fail_unless(osinfo_os_get_is_snapshot(os), "OS should be a snapshot"); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/test4"); + fail_unless(os != NULL, "could not find OS 'test4'"); + str = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "test4") == 0, "wrong OS short-id"); + fail_unless(!osinfo_os_get_is_snapshot(os), "OS should not be a snapshot"); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/test5"); + fail_unless(os != NULL, "could not find OS 'test5'"); + str = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + fail_unless(g_strcmp0(str, "test5") == 0, "wrong OS short-id"); + fail_unless(!osinfo_os_get_is_snapshot(os), "OS should not be a snapshot"); + + g_object_unref(loader); +} +END_TEST + + START_TEST(test_devices_filter) { OsinfoOs *os = osinfo_os_new("awesome"); @@ -130,6 +194,7 @@ os_suite(void) Suite *s = suite_create("Os"); TCase *tc = tcase_create("Core"); tcase_add_test(tc, test_basic); + tcase_add_test(tc, test_loader); tcase_add_test(tc, test_devices); tcase_add_test(tc, test_devices_filter); tcase_add_test(tc, test_device_driver); diff --git a/test/test-os.xml b/test/test-os.xml new file mode 100644 index 0000000..c410aa7 --- /dev/null +++ b/test/test-os.xml @@ -0,0 +1,31 @@ + + + + + test1 + Test 1 + unknown + libosinfo.org + test + + + + + test2 + + + + test3 + true + + + + test4 + false + + + + test5 + invalid-value + + -- 1.8.4.2 From cfergeau at redhat.com Wed Nov 6 13:43:46 2013 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 6 Nov 2013 14:43:46 +0100 Subject: [Libosinfo] [libosinfo 4/4] fedora: Add generic entry for future releases In-Reply-To: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> References: <1383745426-19948-1-git-send-email-cfergeau@redhat.com> Message-ID: <1383745426-19948-5-git-send-email-cfergeau@redhat.com> From: "Zeeshan Ali (Khattak)" This is to ensure that we do recognise medias of future releases of Fedora and therefore give apps some clue about what they are dealing with and some rough estimate of required resources. --- data/oses/fedora.xml.in | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/data/oses/fedora.xml.in b/data/oses/fedora.xml.in index 06abc85..a16ddaa 100644 --- a/data/oses/fedora.xml.in +++ b/data/oses/fedora.xml.in @@ -1532,4 +1532,56 @@