[Libosinfo] [PATCH] Remove osinfo-db-validate tool

Daniel P. Berrange berrange at redhat.com
Fri May 13 11:56:36 UTC 2016


A new osinfo-db-tools package has been forked off from the
libosinfo package. This contains the osinfo-db-validate
tool, so it is no longer neccessary to include it here.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 .gitignore                 |   3 -
 libosinfo.spec.in          |   3 +-
 mingw-libosinfo.spec.in    |   4 +-
 po/POTFILES.in             |   1 -
 tools/Makefile.am          |  11 +-
 tools/osinfo-db-validate.c | 350 ---------------------------------------------
 6 files changed, 5 insertions(+), 367 deletions(-)
 delete mode 100644 tools/osinfo-db-validate.c

diff --git a/.gitignore b/.gitignore
index 1cc9e2f..b8c42ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,9 +76,6 @@ data/usb.ids
 tools/osinfo-detect
 tools/osinfo-detect.1
 tools/osinfo-detect.exe
-tools/osinfo-db-validate
-tools/osinfo-db-validate.exe
-tools/osinfo-db-validate.1
 tools/osinfo-query
 tools/osinfo-query.1
 tools/osinfo-query.exe
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 0feed84..6647341 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -33,6 +33,7 @@ BuildRequires: hwdata
 BuildRequires: gobject-introspection-devel
 %endif
 Requires: hwdata
+Requires: osinfo-db-tools
 
 %description
 libosinfo is a library that allows virtualization provisioning tools to
@@ -102,7 +103,6 @@ rm -fr %{buildroot}
 %defattr(-, root, root)
 %doc AUTHORS ChangeLog COPYING.LIB NEWS README
 %{_bindir}/osinfo-detect
-%{_bindir}/osinfo-db-validate
 %{_bindir}/osinfo-query
 %{_bindir}/osinfo-install-script
 %dir %{_datadir}/libosinfo/
@@ -114,7 +114,6 @@ rm -fr %{buildroot}
 %{_datadir}/libosinfo/db/platform
 %{_datadir}/libosinfo/db/install-script
 %{_datadir}/libosinfo/schemas/libosinfo.rng
-%{_mandir}/man1/osinfo-db-validate.1*
 %{_mandir}/man1/osinfo-detect.1*
 %{_mandir}/man1/osinfo-query.1*
 %{_mandir}/man1/osinfo-install-script.1*
diff --git a/mingw-libosinfo.spec.in b/mingw-libosinfo.spec.in
index 16c5699..c69ec8b 100644
--- a/mingw-libosinfo.spec.in
+++ b/mingw-libosinfo.spec.in
@@ -42,6 +42,7 @@ combination.
 Summary: %{summary}
 
 Requires: pkgconfig
+Requires: mingw32-osinfo-db-tools
 
 %description -n mingw32-libosinfo
 libosinfo is a library that allows virtualization provisioning tools to
@@ -52,6 +53,7 @@ combination.
 Summary: %{summary}
 
 Requires: pkgconfig
+Requires: mingw64-osinfo-db-tools
 
 %description -n mingw64-libosinfo
 libosinfo is a library that allows virtualization provisioning tools to
@@ -91,7 +93,6 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_datadir}/gtk-doc
 %files -n mingw32-libosinfo
 %doc AUTHORS ChangeLog COPYING.LIB NEWS README
 %{mingw32_bindir}/osinfo-detect.exe
-%{mingw32_bindir}/osinfo-db-validate.exe
 %{mingw32_bindir}/osinfo-install-script.exe
 %{mingw32_bindir}/osinfo-query.exe
 %{mingw32_bindir}/libosinfo-1.0-0.dll
@@ -116,7 +117,6 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_datadir}/gtk-doc
 %files -n mingw64-libosinfo
 %doc AUTHORS ChangeLog COPYING.LIB NEWS README
 %{mingw64_bindir}/osinfo-detect.exe
-%{mingw64_bindir}/osinfo-db-validate.exe
 %{mingw64_bindir}/osinfo-install-script.exe
 %{mingw64_bindir}/osinfo-query.exe
 %{mingw64_bindir}/libosinfo-1.0-0.dll
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5af54e3..0385517 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -427,7 +427,6 @@ osinfo/osinfo_product.c
 osinfo/osinfo_resources.c
 osinfo/osinfo_tree.c
 osinfo/osinfo_os_variant.c
-tools/osinfo-db-validate.c
 tools/osinfo-detect.c
 tools/osinfo-install-script.c
 tools/osinfo-query.c
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 7f7249f..60515e6 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -8,9 +8,9 @@ AM_CFLAGS = $(GOBJECT_CFLAGS) \
 	    -I$(top_srcdir) \
             $(NULL)
 
-bin_PROGRAMS = osinfo-detect osinfo-db-validate osinfo-query osinfo-install-script
+bin_PROGRAMS = osinfo-detect osinfo-query osinfo-install-script
 
-man1_MANS = osinfo-db-validate.1 osinfo-detect.1 osinfo-query.1 osinfo-install-script.1
+man1_MANS = osinfo-detect.1 osinfo-query.1 osinfo-install-script.1
 
 CLEANFILES = $(man1_MANS)
 
@@ -26,13 +26,6 @@ osinfo_detect_LDADD = $(GOBJECT_LIBS)		\
 		      $(LIBXML_LIBS)		\
 		      $(top_builddir)/osinfo/libosinfo-1.0.la
 
-osinfo_db_validate_SOURCES = osinfo-db-validate.c
-osinfo_db_validate_LDADD = $(GOBJECT_LIBS)	\
-		      $(GIO_LIBS)		\
-		      $(GLIB_LIBS)		\
-		      $(LIBXML_LIBS)		\
-		      $(top_builddir)/osinfo/libosinfo-1.0.la
-
 osinfo_query_SOURCES = osinfo-query.c
 osinfo_query_LDADD = $(GOBJECT_LIBS)		\
 		      $(GIO_LIBS)		\
diff --git a/tools/osinfo-db-validate.c b/tools/osinfo-db-validate.c
deleted file mode 100644
index 965ed0e..0000000
--- a/tools/osinfo-db-validate.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (C) 2012 Red Hat, Inc
- *
- * osinfo-validate: validate that XML file(s) follows the published schema
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Authors:
- *   Daniel P. Berrange <berrange at redhat.com>
- */
-
-#include <config.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <libxml/relaxng.h>
-#include <locale.h>
-#include <glib/gi18n.h>
-
-#define SCHEMA PKGDATADIR "/schemas/libosinfo.rng"
-
-static gboolean verbose = FALSE;
-
-static const GOptionEntry entries[] = {
-    { "verbose", 'v', 0, G_OPTION_ARG_NONE, (void*)&verbose,
-      N_("Verbose progress information"), NULL, },
-    { NULL, 0, 0, 0, NULL, NULL, NULL }
-};
-
-
-static void validate_generic_error_nop(void *userData G_GNUC_UNUSED,
-                                       const char *msg G_GNUC_UNUSED,
-                                       ...)
-{
-}
-
-static void validate_structured_error_nop(void *userData G_GNUC_UNUSED,
-                                          xmlErrorPtr error G_GNUC_UNUSED)
-{
-    if (error->file)
-        g_printerr("%s:%d %s", error->file, error->line, error->message);
-    else
-        g_printerr(_("Schema validity error %s"), error->message);
-}
-
-static xmlDocPtr parse_file(GFile *file, GError **error)
-{
-    xmlDocPtr doc = NULL;
-    xmlParserCtxtPtr pctxt;
-    gchar *data = NULL;
-    gsize length;
-    gchar *uri = g_file_get_uri(file);
-
-    if (!g_file_load_contents(file, NULL, &data, &length, NULL, error))
-        goto cleanup;
-
-    if (!(pctxt = xmlNewParserCtxt())) {
-        g_set_error(error, 0, 0, "%s",
-                    _("Unable to create libxml parser"));
-        goto cleanup;
-    }
-
-    if (!(doc = xmlCtxtReadDoc(pctxt, (const xmlChar*)data, uri, NULL,
-                               XML_PARSE_NOENT | XML_PARSE_NONET |
-                               XML_PARSE_NOWARNING))) {
-        g_set_error(error, 0, 0,
-                    _("Unable to parse XML document '%s'"),
-                    uri);
-        goto cleanup;
-    }
-
- cleanup:
-    g_free(uri);
-    g_free(data);
-    return doc;
-}
-
-static gboolean validate_file(xmlRelaxNGValidCtxtPtr rngValid, GFile *file, GFileInfo *info, GError **error);
-
-
-static gboolean validate_file_regular(xmlRelaxNGValidCtxtPtr rngValid,
-                                      GFile *file,
-                                      GError **error)
-{
-    gboolean ret = FALSE;
-    xmlDocPtr doc = NULL;
-    gchar *uri = g_file_get_uri(file);
-
-    if (!g_str_has_suffix(uri, ".xml")) {
-        ret = TRUE;
-        goto cleanup;
-    }
-
-    if (!(doc = parse_file(file, error)))
-        goto cleanup;
-
-    if (xmlRelaxNGValidateDoc(rngValid, doc) != 0) {
-        g_set_error(error, 0, 0,
-                    _("Unable to validate XML document '%s'"),
-                    uri);
-        goto cleanup;
-    }
-
-    ret = TRUE;
-
- cleanup:
-    //g_free(uri);
-    xmlFreeDoc(doc);
-    return ret;
-}
-
-
-static gboolean validate_file_directory(xmlRelaxNGValidCtxtPtr rngValid, GFile *file, GError **error)
-{
-    gboolean ret = FALSE;
-    GFileEnumerator *children = NULL;
-    GFileInfo *info = NULL;
-
-    if (!(children = g_file_enumerate_children(file, "standard::*", 0, NULL, error)))
-        goto cleanup;
-
-    while ((info = g_file_enumerator_next_file(children, NULL, error))) {
-        GFile *child = g_file_get_child(file, g_file_info_get_name(info));
-        if (!validate_file(rngValid, child, info, error)) {
-            g_object_unref(child);
-            goto cleanup;
-        }
-        g_object_unref(child);
-    }
-
-    if (*error)
-        goto cleanup;
-
-    ret = TRUE;
-
- cleanup:
-    g_object_unref(children);
-    return ret;
-}
-
-
-static gboolean validate_file(xmlRelaxNGValidCtxtPtr rngValid, GFile *file, GFileInfo *info, GError **error)
-{
-    gboolean ret = FALSE;
-    GFileInfo *thisinfo = NULL;
-    gchar *uri = g_file_get_uri(file);
-
-    if (verbose)
-        g_print(_("Processing '%s'...\n"), uri);
-
-    if (!info) {
-        if (!(thisinfo = g_file_query_info(file, "standard::*",
-                                           G_FILE_QUERY_INFO_NONE,
-                                           NULL, error)))
-            goto cleanup;
-        info = thisinfo;
-    }
-
-    if (g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY) {
-        if (!validate_file_directory(rngValid, file, error))
-            goto cleanup;
-    } else if (g_file_info_get_file_type(info) == G_FILE_TYPE_REGULAR) {
-        if (!validate_file_regular(rngValid, file, error))
-            goto cleanup;
-    } else {
-        g_set_error(error, 0, 0,
-                    "Unable to handle file type for %s",
-                    uri);
-        goto cleanup;
-    }
-
-    g_print(_("Processed '%s'.\n"), uri);
-    ret = TRUE;
-
- cleanup:
-    g_free(uri);
-    if (thisinfo)
-        g_object_unref(thisinfo);
-    return ret;
-}
-
-
-static gboolean validate_files(gint argc, gchar **argv, GError **error)
-{
-    xmlRelaxNGParserCtxtPtr rngParser = NULL;
-    xmlRelaxNGPtr rng = NULL;
-    xmlRelaxNGValidCtxtPtr rngValid = NULL;
-    gboolean ret = FALSE;
-    gsize i;
-
-    xmlSetGenericErrorFunc(NULL, validate_generic_error_nop);
-    xmlSetStructuredErrorFunc(NULL, validate_structured_error_nop);
-
-    rngParser = xmlRelaxNGNewParserCtxt(SCHEMA);
-    if (!rngParser) {
-        g_set_error(error, 0, 0,
-                    _("Unable to create RNG parser for %s"),
-                    SCHEMA);
-        goto cleanup;
-    }
-
-    rng = xmlRelaxNGParse(rngParser);
-    if (!rng) {
-        g_set_error(error, 0, 0,
-                    _("Unable to parse RNG %s"),
-                    SCHEMA);
-        goto cleanup;
-    }
-
-    rngValid = xmlRelaxNGNewValidCtxt(rng);
-    if (!rngValid) {
-        g_set_error(error, 0, 0,
-                    _("Unable to create RNG validation context %s"),
-                    SCHEMA);
-        goto cleanup;
-    }
-
-    for (i = 0; i < argc; i++) {
-        GFile *file = g_file_new_for_commandline_arg(argv[i]);
-        if (!validate_file(rngValid, file, NULL, error)) {
-            g_object_unref(file);
-            goto cleanup;
-        }
-        g_object_unref(file);
-    }
-
-    ret = TRUE;
-
- cleanup:
-    xmlRelaxNGFreeValidCtxt(rngValid);
-    xmlRelaxNGFreeParserCtxt(rngParser);
-    xmlRelaxNGFree(rng);
-    return ret;
-}
-
-gint main(gint argc, gchar **argv)
-{
-    GOptionContext *context;
-    GError *error = NULL;
-    gint ret = EXIT_FAILURE;
-
-    setlocale(LC_ALL, "");
-    textdomain(GETTEXT_PACKAGE);
-    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
-    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-
-    context = g_option_context_new(_("- Validate XML documents "));
-
-    g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
-
-    if (!g_option_context_parse(context, &argc, &argv, &error)) {
-        g_printerr(_("Error while parsing commandline options: %s\n"),
-                   error->message);
-        g_printerr("%s\n", g_option_context_get_help(context, FALSE, NULL));
-        goto error;
-    }
-
-    if (!validate_files(argc - 1, argv + 1, &error)) {
-        g_printerr("%s\n", error->message);
-        goto error;
-    }
-
-    ret = EXIT_SUCCESS;
-
- error:
-    g_clear_error(&error);
-    g_option_context_free(context);
-
-    return ret;
-}
-
-/*
-=pod
-
-=head1 NAME
-
-osinfo-db-validate - Validate libosinfo XML data files
-
-=head1 SYNOPSIS
-
-osinfo-db-validate [OPTIONS...] LOCAL-PATH1 [LOCAL-PATH2...]
-
-osinfo-db-validate [OPTIONS...] URI1 [URI2...]
-
-=head1 DESCRIPTION
-
-Check that all files (C<LOCAL-PATH1> or C<URI1>) comply with the
-libosinfo XML schema. The local path may point to a directory
-containing XML files, or directly to an XML file. The uris must
-point directly to remote XML files
-
-Any validation errors will be displayed on the console when
-detected.
-
-=head1 OPTIONS
-
-=over 8
-
-=item B<-v>, B<--verbose>
-
-Display verbose progress information when validating files
-
-=back
-
-=head1 EXIT STATUS
-
-The exit status will be 0 if all files passed validation,
-or 1 if a validation error was hit.
-
-=head1 SEE ALSO
-
-C<xmllint(1)>
-
-=head1 AUTHORS
-
-Daniel P. Berrange <berrange at redhat.com>
-
-=head1 COPYRIGHT
-
-Copyright (C) 2012, 2014 Red Hat, Inc.
-
-=head1 LICENSE
-
-C<osinfo-db-validate> is distributed under the termsof the GNU LGPL v2+
-license. This is free software; see the source for copying conditions.
-There is NO warranty; not even for MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE
-
-=cut
-*/
-
-/*
- * Local variables:
- *  indent-tabs-mode: nil
- *  c-indent-level: 4
- *  c-basic-offset: 4
- * End:
- */
-- 
2.5.5




More information about the Libosinfo mailing list