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

[virt-tools-list] [PATCH libosinfo 2/7] Add APIs for dealing with installer automation scripts



From: "Daniel P. Berrange" <berrange redhat com>

This introduces two new objects

 - OsinfoInstallConfig - stores configuration parameters which get
   substituted into the install script template.
 - OsinfoInstallScript - provides a template and the mechanism for
   turning it into an install script using XSLT
---
 configure.ac                       |    1 +
 docs/reference/Libosinfo.types     |    3 +
 libosinfo.spec.in                  |    1 +
 mingw32-libosinfo.spec.in          |    1 +
 osinfo/Makefile.am                 |   11 +
 osinfo/libosinfo.syms              |   35 ++
 osinfo/osinfo.h                    |    3 +
 osinfo/osinfo_install_config.c     |  325 +++++++++++++++++
 osinfo/osinfo_install_config.h     |  157 ++++++++
 osinfo/osinfo_install_script.c     |  696 ++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_install_script.h     |  113 ++++++
 osinfo/osinfo_install_scriptlist.c |  169 +++++++++
 osinfo/osinfo_install_scriptlist.h |   82 +++++
 13 files changed, 1597 insertions(+), 0 deletions(-)
 create mode 100644 osinfo/osinfo_install_config.c
 create mode 100644 osinfo/osinfo_install_config.h
 create mode 100644 osinfo/osinfo_install_script.c
 create mode 100644 osinfo/osinfo_install_script.h
 create mode 100644 osinfo/osinfo_install_scriptlist.c
 create mode 100644 osinfo/osinfo_install_scriptlist.h

diff --git a/configure.ac b/configure.ac
index 462d5e1..2e3d4d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@ PKG_CHECK_MODULES([GIO], [gio-2.0])
 PKG_CHECK_MODULES([SOUP], [libsoup-2.4])
 PKG_CHECK_MODULES([SOUP_GNOME], [libsoup-gnome-2.4])
 PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.6.0])
+PKG_CHECK_MODULES([LIBXSLT], [libxslt >= 1.0.0])
 
 GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
 
diff --git a/docs/reference/Libosinfo.types b/docs/reference/Libosinfo.types
index 2cf0934..faf8643 100644
--- a/docs/reference/Libosinfo.types
+++ b/docs/reference/Libosinfo.types
@@ -8,6 +8,9 @@ osinfo_devicelinklist_get_type
 osinfo_devicelist_get_type
 osinfo_entity_get_type
 osinfo_filter_get_type
+osinfo_install_config_get_type
+osinfo_install_script_get_type
+osinfo_install_scriptlist_get_type
 osinfo_list_get_type
 osinfo_loader_get_type
 osinfo_media_get_type
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 28f4804..d241a54 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -22,6 +22,7 @@ URL: https://fedorahosted.org/libosinfo/
 BuildRequires: glib2-devel
 BuildRequires: check-devel
 BuildRequires: libxml2-devel >= 2.6.0
+BuildRequires: libxslt-devel >= 1.0.0
 BuildRequires: vala
 BuildRequires: vala-tools
 BuildRequires: libsoup-devel
diff --git a/mingw32-libosinfo.spec.in b/mingw32-libosinfo.spec.in
index 0ec510c..cc1e727 100644
--- a/mingw32-libosinfo.spec.in
+++ b/mingw32-libosinfo.spec.in
@@ -22,6 +22,7 @@ BuildRequires: mingw32-binutils
 
 BuildRequires: mingw32-glib2
 BuildRequires: mingw32-libxml2
+BuildRequires: mingw32-libxslt
 BuildRequires: mingw32-libsoup
 BuildRequires: mingw32-libsoup-gnome
 BuildRequires: pkgconfig
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 98e2365..36fe9e4 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -26,6 +26,7 @@ libosinfo_1_0_la_CFLAGS = \
 	$(COVERAGE_CFLAGS) \
 	-I$(top_srcdir) \
 	$(LIBXML_CFLAGS) \
+	$(LIBXSLT_CFLAGS) \
 	$(GOBJECT_CFLAGS) \
 	$(GIO_CFLAGS) \
 	-DDATA_DIR='"$(pkgdatadir)/data"'
@@ -33,12 +34,15 @@ libosinfo_1_0_la_CFLAGS = \
 libosinfo_1_0_la_LDFLAGS = \
 	$(COVERAGE_LDFLAGS) \
 	$(LIBXML_LIBS) \
+	$(LIBXSLT_LIBS) \
 	$(GOBJECT_LIBS) \
 	$(GIO_LIBS) \
 	$(VERSION_SCRIPT_FLAGS)$(LIBOSINFO_VERSION_FILE) \
         -version-info $(LIBOSINFO_VERSION_INFO) \
 	$(NO_UNDEFINED_FLAGS)
 
+libosinfo_1_0_la_DEPENDENCIES = libosinfo.syms
+
 libosinfo_1_0_includedir = $(includedir)/libosinfo-1.0/osinfo
 
 libosinfo_1_0_include_HEADERS = \
@@ -52,6 +56,9 @@ libosinfo_1_0_include_HEADERS = \
   osinfo_devicelinkfilter.h	\
   osinfo_entity.h		\
   osinfo_filter.h		\
+  osinfo_install_config.h       \
+  osinfo_install_script.h       \
+  osinfo_install_scriptlist.h   \
   osinfo_product.h		\
   osinfo_productfilter.h	\
   osinfo_productlist.h		\
@@ -79,6 +86,9 @@ libosinfo_1_0_la_SOURCES =	\
   osinfo_devicelist.c		\
   osinfo_devicelinklist.c	\
   osinfo_devicelinkfilter.c	\
+  osinfo_install_config.c       \
+  osinfo_install_script.c       \
+  osinfo_install_scriptlist.c   \
   osinfo_product.c		\
   osinfo_productfilter.c	\
   osinfo_productlist.c		\
@@ -119,6 +129,7 @@ Libosinfo-1.0.gir: libosinfo-1.0.la $(G_IR_SCANNER) Makefile.am
 		--pkg=gobject-2.0 \
 		--pkg=gio-2.0 \
 		--pkg=libxml-2.0 \
+		--pkg=libxslt \
 		$(libosinfo_1_0_include_HEADERS:%=$(srcdir)/%) \
 		$(libosinfo_1_0_la_SOURCES:%=$(srcdir)/%)
 
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index bb6da44..a9bb5c2 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -211,6 +211,41 @@ LIBOSINFO_0.1.0 {
     global:
 	osinfo_entity_set_param_boolean;
 	osinfo_entity_get_param_value_boolean;
+	osinfo_install_config_get_type;
+	osinfo_install_config_new;
+	osinfo_install_config_get_l10n_keyboard;
+	osinfo_install_config_get_l10n_language;
+	osinfo_install_config_get_l10n_timezone;
+	osinfo_install_config_get_admin_password;
+	osinfo_install_config_get_user_login;
+	osinfo_install_config_get_user_password;
+	osinfo_install_config_get_user_realname;
+	osinfo_install_config_get_user_administrator;
+	osinfo_install_config_get_user_autologin;
+	osinfo_install_config_set_l10n_keyboard;
+	osinfo_install_config_set_l10n_language;
+	osinfo_install_config_set_l10n_timezone;
+	osinfo_install_config_set_admin_password;
+	osinfo_install_config_set_user_login;
+	osinfo_install_config_set_user_password;
+	osinfo_install_config_set_user_realname;
+	osinfo_install_config_set_user_administrator;
+	osinfo_install_config_set_user_autologin;
+	osinfo_install_script_get_type;
+	osinfo_install_script_new;
+	osinfo_install_script_new_data;
+	osinfo_install_script_new_uri;
+	osinfo_install_script_generate;
+	osinfo_install_script_generate_async;
+	osinfo_install_script_generate_finish;
+	osinfo_install_script_get_profile;
+	osinfo_install_script_get_uri;
+	osinfo_install_scriptlist_new;
+	osinfo_install_scriptlist_new_filtered;
+	osinfo_install_scriptlist_new_union;
+	osinfo_install_scriptlist_new_intersection;
+	osinfo_install_scriptlist_new_copy;
+	osinfo_install_scriptlist_get_type;
 	osinfo_tree_new;
 	osinfo_tree_create_from_location;
 	osinfo_tree_create_from_location_async;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index bb2a057..aa06095 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -33,6 +33,9 @@
 #include <osinfo/osinfo_devicelist.h>
 #include <osinfo/osinfo_devicelinklist.h>
 #include <osinfo/osinfo_devicelinkfilter.h>
+#include <osinfo/osinfo_install_config.h>
+#include <osinfo/osinfo_install_script.h>
+#include <osinfo/osinfo_install_scriptlist.h>
 #include <osinfo/osinfo_productlist.h>
 #include <osinfo/osinfo_product.h>
 #include <osinfo/osinfo_productfilter.h>
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
new file mode 100644
index 0000000..80643b1
--- /dev/null
+++ b/osinfo/osinfo_install_config.c
@@ -0,0 +1,325 @@
+/*
+ * libosinfo:
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+G_DEFINE_TYPE (OsinfoInstallConfig, osinfo_install_config, OSINFO_TYPE_ENTITY);
+
+#define OSINFO_INSTALL_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfigPrivate))
+
+/**
+ * SECTION:osinfo_install_config
+ * @short_description: OS install configuration
+ * @see_also: #OsinfoInstallScript
+ *
+ * #OsinfoInstallConfig is an object for representing OS
+ * install configuration data. It is used to generate an
+ * automated installation script
+ */
+
+struct _OsinfoInstallConfigPrivate
+{
+    gboolean unused;
+};
+
+
+/* Init functions */
+static void
+osinfo_install_config_class_init (OsinfoInstallConfigClass *klass)
+{
+    g_type_class_add_private (klass, sizeof (OsinfoInstallConfigPrivate));
+}
+
+static const gchar valid[] = {
+    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'X', 'W', 'X', 'Y', 'Z',
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '+',
+    '=', '!', '@', '#', '%', '^', '&', ',', '(', ')', '[', '{', '}',
+    '[', ']', ';', ':', '<', '>', ',', '.', '?', '/', '~',
+};
+
+
+static void
+osinfo_install_config_init (OsinfoInstallConfig *config)
+{
+    OsinfoInstallConfigPrivate *priv;
+    gchar pass[9];
+    gsize i;
+
+    config->priv = priv = OSINFO_INSTALL_CONFIG_GET_PRIVATE(config);
+
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD,
+                            "us");
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE,
+                            "America/New_York");
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE,
+                            "en_US.UTF-8");
+
+    for (i = 0 ; i < sizeof(pass)-1 ; i++) {
+        gint val = g_random_int_range(0, sizeof(valid));
+        pass[i] = valid[val];
+    }
+    pass[sizeof(pass)-1] = '\0';
+
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_ADMIN_PASSWORD,
+                            pass);
+}
+
+
+/**
+ * osinfo_install_config_new:
+ *
+ * Construct a new install configuration that is initially empty.
+ *
+ * Returns: (transfer full): an empty install configuration
+ */
+OsinfoInstallConfig *osinfo_install_config_new(const gchar *id)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_CONFIG,
+                        "id", id,
+                        NULL);
+}
+
+void osinfo_install_config_set_hardware_arch(OsinfoInstallConfig *config,
+                                             const gchar *arch)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_HARDWARE_ARCH,
+                            arch);
+}
+
+
+const gchar *osinfo_install_config_get_hardware_arch(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_HARDWARE_ARCH);
+}
+
+
+void osinfo_install_config_set_l10n_keyboard(OsinfoInstallConfig *config,
+                                             const gchar *keyboard)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD,
+                            keyboard);
+}
+
+
+const gchar *osinfo_install_config_get_l10n_keyboard(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD);
+}
+
+
+void osinfo_install_config_set_l10n_language(OsinfoInstallConfig *config,
+                                             const gchar *language)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE,
+                            language);
+}
+
+
+const gchar *osinfo_install_config_get_l10n_language(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE);
+}
+
+
+void osinfo_install_config_set_l10n_timezone(OsinfoInstallConfig *config,
+                                             const gchar *tz)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE,
+                            tz);
+}
+
+
+const gchar *osinfo_install_config_get_l10n_timezone(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE);
+}
+
+
+void osinfo_install_config_set_admin_password(OsinfoInstallConfig *config,
+                                              const gchar *password)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_ADMIN_PASSWORD,
+                            password);
+}
+
+
+const gchar *osinfo_install_config_get_admin_password(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_ADMIN_PASSWORD);
+}
+
+
+void osinfo_install_config_set_user_login(OsinfoInstallConfig *config,
+                                          const gchar *username)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_USER_LOGIN,
+                            username);
+}
+
+
+const gchar *osinfo_install_config_get_user_login(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_USER_LOGIN);
+}
+
+
+
+void osinfo_install_config_set_user_password(OsinfoInstallConfig *config,
+                                             const gchar *password)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_USER_PASSWORD,
+                            password);
+}
+
+
+const gchar *osinfo_install_config_get_user_password(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_USER_PASSWORD);
+}
+
+
+void osinfo_install_config_set_user_realname(OsinfoInstallConfig *config,
+                                             const gchar *name)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_USER_REALNAME,
+                            name);
+}
+
+
+const gchar *osinfo_install_config_get_user_realname(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_USER_REALNAME);
+}
+
+
+
+void osinfo_install_config_set_user_autologin(OsinfoInstallConfig *config,
+                                              gboolean autologin)
+{
+    osinfo_entity_set_param_boolean(OSINFO_ENTITY(config),
+                                    OSINFO_INSTALL_CONFIG_PROP_USER_AUTOLOGIN,
+                                    autologin);
+}
+
+
+gboolean osinfo_install_config_get_user_autologin(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(config),
+                                                 OSINFO_INSTALL_CONFIG_PROP_USER_AUTOLOGIN);
+}
+
+
+void osinfo_install_config_set_user_administrator(OsinfoInstallConfig *config,
+                                                  gboolean admin)
+{
+    osinfo_entity_set_param_boolean(OSINFO_ENTITY(config),
+                                    OSINFO_INSTALL_CONFIG_PROP_USER_ADMIN,
+                                    admin);
+}
+
+
+gboolean osinfo_install_config_get_user_administrator(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(config),
+                                                 OSINFO_INSTALL_CONFIG_PROP_USER_ADMIN);
+}
+
+
+void osinfo_install_config_set_reg_login(OsinfoInstallConfig *config,
+                                         const gchar *name)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_REG_LOGIN,
+                            name);
+}
+
+const gchar *osinfo_install_config_get_reg_login(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_REG_LOGIN);
+}
+
+
+void osinfo_install_config_set_reg_password(OsinfoInstallConfig *config,
+                                            const gchar *password)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_REG_PASSWORD,
+                            password);
+}
+
+const gchar *osinfo_install_config_get_reg_password(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_REG_PASSWORD);
+}
+
+
+void osinfo_install_config_set_reg_product_key(OsinfoInstallConfig *config,
+                                               const gchar *key)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_REG_PRODUCTKEY,
+                            key);
+}
+
+const gchar *osinfo_install_config_get_reg_product_key(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_REG_PRODUCTKEY);
+}
+
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
new file mode 100644
index 0000000..2d1c065
--- /dev/null
+++ b/osinfo/osinfo_install_config.h
@@ -0,0 +1,157 @@
+/*
+ * libosinfo: OS installation configuration
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <glib-object.h>
+
+#ifndef __OSINFO_INSTALL_CONFIG_H__
+#define __OSINFO_INSTALL_CONFIG_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_INSTALL_CONFIG                  (osinfo_install_config_get_type ())
+#define OSINFO_INSTALL_CONFIG(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfig))
+#define OSINFO_IS_INSTALL_CONFIG(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_INSTALL_CONFIG))
+#define OSINFO_INSTALL_CONFIG_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfigClass))
+#define OSINFO_IS_INSTALL_CONFIG_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_CONFIG))
+#define OSINFO_INSTALL_CONFIG_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfigClass))
+
+#define OSINFO_INSTALL_CONFIG_PROP_HARDWARE_ARCH  "hardware-arch"
+
+#define OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE  "l10n-timezone"
+#define OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE  "l10n-language"
+#define OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD  "l10n-keyboard"
+
+#define OSINFO_INSTALL_CONFIG_PROP_ADMIN_PASSWORD "admin-password"
+
+#define OSINFO_INSTALL_CONFIG_PROP_USER_PASSWORD  "user-password"
+#define OSINFO_INSTALL_CONFIG_PROP_USER_LOGIN     "user-login"
+#define OSINFO_INSTALL_CONFIG_PROP_USER_REALNAME  "user-realname"
+#define OSINFO_INSTALL_CONFIG_PROP_USER_AUTOLOGIN "user-autologin"
+#define OSINFO_INSTALL_CONFIG_PROP_USER_ADMIN     "user-admin"
+
+#define OSINFO_INSTALL_CONFIG_PROP_REG_LOGIN      "reg-login"
+#define OSINFO_INSTALL_CONFIG_PROP_REG_PASSWORD   "reg-password"
+#define OSINFO_INSTALL_CONFIG_PROP_REG_PRODUCTKEY "reg-product-key"
+
+
+typedef struct _OsinfoInstallConfig        OsinfoInstallConfig;
+typedef struct _OsinfoInstallConfigClass   OsinfoInstallConfigClass;
+typedef struct _OsinfoInstallConfigPrivate OsinfoInstallConfigPrivate;
+
+/* object */
+struct _OsinfoInstallConfig
+{
+    OsinfoEntity parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoInstallConfigPrivate *priv;
+};
+
+/* class */
+struct _OsinfoInstallConfigClass
+{
+    OsinfoEntityClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_install_config_get_type(void);
+
+OsinfoInstallConfig *osinfo_install_config_new(const gchar *id);
+
+void osinfo_install_config_set_hardware_arch(OsinfoInstallConfig *config,
+                                             const gchar *arch);
+const gchar *osinfo_install_config_get_hardware_arch(OsinfoInstallConfig *config);
+
+void osinfo_install_config_set_l10n_keyboard(OsinfoInstallConfig *config,
+                                             const gchar *keyboard);
+const gchar *osinfo_install_config_get_l10n_keyboard(OsinfoInstallConfig *config);
+
+void osinfo_install_config_set_l10n_language(OsinfoInstallConfig *config,
+                                             const gchar *language);
+const gchar *osinfo_install_config_get_l10n_language(OsinfoInstallConfig *config);
+
+void osinfo_install_config_set_l10n_timezone(OsinfoInstallConfig *config,
+                                             const gchar *timezone);
+const gchar *osinfo_install_config_get_l10n_timezone(OsinfoInstallConfig *config);
+
+
+
+
+void osinfo_install_config_set_admin_password(OsinfoInstallConfig *config,
+                                              const gchar *password);
+const gchar *osinfo_install_config_get_admin_password(OsinfoInstallConfig *config);
+
+
+
+
+void osinfo_install_config_set_user_login(OsinfoInstallConfig *config,
+                                          const gchar *username);
+const gchar *osinfo_install_config_get_user_login(OsinfoInstallConfig *config);
+
+
+void osinfo_install_config_set_user_password(OsinfoInstallConfig *config,
+                                             const gchar *password);
+const gchar *osinfo_install_config_get_user_password(OsinfoInstallConfig *config);
+
+
+void osinfo_install_config_set_user_realname(OsinfoInstallConfig *config,
+                                             const gchar *name);
+const gchar *osinfo_install_config_get_user_realname(OsinfoInstallConfig *config);
+
+
+void osinfo_install_config_set_user_autologin(OsinfoInstallConfig *config,
+                                              gboolean autologin);
+gboolean osinfo_install_config_get_user_autologin(OsinfoInstallConfig *config);
+
+
+void osinfo_install_config_set_user_administrator(OsinfoInstallConfig *config,
+                                                  gboolean admin);
+gboolean osinfo_install_config_get_user_administrator(OsinfoInstallConfig *config);
+
+
+
+void osinfo_install_config_set_reg_login(OsinfoInstallConfig *config,
+                                         const gchar *name);
+const gchar *osinfo_install_config_get_reg_login(OsinfoInstallConfig *config);
+
+void osinfo_install_config_set_reg_password(OsinfoInstallConfig *config,
+                                            const gchar *password);
+const gchar *osinfo_install_config_get_reg_password(OsinfoInstallConfig *config);
+
+void osinfo_install_config_set_reg_product_key(OsinfoInstallConfig *config,
+                                               const gchar *key);
+const gchar *osinfo_install_config_get_reg_product_key(OsinfoInstallConfig *config);
+
+
+#endif /* __OSINFO_INSTALL_CONFIG_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
new file mode 100644
index 0000000..7bf1e2e
--- /dev/null
+++ b/osinfo/osinfo_install_script.c
@@ -0,0 +1,696 @@
+/*
+ * libosinfo:
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <string.h>
+#include <libxml/tree.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
+#include <libxslt/xsltInternals.h>
+
+G_DEFINE_TYPE (OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY);
+
+#define OSINFO_INSTALL_SCRIPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScriptPrivate))
+
+/**
+ * SECTION:osinfo_install_script
+ * @short_description: OS install scripturation
+ * @see_also: #OsinfoInstallScript
+ *
+ * #OsinfoInstallScript is an object for representing OS
+ * install scripturation data. It is used to generate an
+ * automated installation script
+ */
+
+struct _OsinfoInstallScriptPrivate
+{
+    gboolean unused;
+};
+
+enum {
+    PROP_0,
+
+    PROP_TEMPLATE_URI,
+    PROP_TEMPLATE_DATA,
+    PROP_PROFILE,
+    PROP_PRODUCT_KEY_FORMAT,
+};
+
+
+static void
+osinfo_os_set_property(GObject    *object,
+                       guint       property_id,
+                       const GValue     *value,
+                       GParamSpec *pspec)
+{
+    OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT(object);
+    const gchar *data;
+
+    switch (property_id) {
+    case PROP_TEMPLATE_URI:
+        data = g_value_get_string(value);
+        if (data)
+            osinfo_entity_set_param(OSINFO_ENTITY(script),
+                                    OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_URI,
+                                    data);
+        break;
+
+    case PROP_TEMPLATE_DATA:
+        data = g_value_get_string(value);
+        if (data)
+            osinfo_entity_set_param(OSINFO_ENTITY(script),
+                                    OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA,
+                                    data);
+        break;
+
+    case PROP_PROFILE:
+        data = g_value_get_string(value);
+        if (data)
+            osinfo_entity_set_param(OSINFO_ENTITY(script),
+                                    OSINFO_INSTALL_SCRIPT_PROP_PROFILE,
+                                    data);
+        break;
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+osinfo_os_get_property(GObject    *object,
+                       guint       property_id,
+                       GValue     *value,
+                       GParamSpec *pspec)
+{
+    OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT(object);
+
+    switch (property_id) {
+    case PROP_TEMPLATE_URI:
+        g_value_set_string(value,
+                           osinfo_install_script_get_template_uri(script));
+        break;
+
+    case PROP_TEMPLATE_DATA:
+        g_value_set_string(value,
+                           osinfo_install_script_get_template_data(script));
+        break;
+
+    case PROP_PROFILE:
+        g_value_set_string(value,
+                           osinfo_install_script_get_profile(script));
+        break;
+
+    case PROP_PRODUCT_KEY_FORMAT:
+        g_value_set_string(value,
+                           osinfo_install_script_get_product_key_format(script));
+        break;
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+
+
+static void
+osinfo_install_script_finalize (GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_install_script_parent_class)->finalize (object);
+}
+
+/* Init functions */
+static void
+osinfo_install_script_class_init (OsinfoInstallScriptClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+    GParamSpec *pspec;
+
+    g_klass->get_property = osinfo_os_get_property;
+    g_klass->set_property = osinfo_os_set_property;
+    g_klass->finalize = osinfo_install_script_finalize;
+
+    pspec = g_param_spec_string("template-uri",
+                                "TemplateURI",
+                                "URI for install script template",
+                                NULL /* default value */,
+                                G_PARAM_READABLE |
+                                G_PARAM_WRITABLE |
+                                G_PARAM_CONSTRUCT_ONLY |
+                                G_PARAM_STATIC_NAME |
+                                G_PARAM_STATIC_NICK |
+                                G_PARAM_STATIC_BLURB);
+    g_object_class_install_property(g_klass,
+                                    PROP_TEMPLATE_URI,
+                                    pspec);
+
+    pspec = g_param_spec_string("template-data",
+                                "TemplateData",
+                                "Data for install script template",
+                                NULL /* default value */,
+                                G_PARAM_READABLE |
+                                G_PARAM_WRITABLE |
+                                G_PARAM_CONSTRUCT_ONLY |
+                                G_PARAM_STATIC_NAME |
+                                G_PARAM_STATIC_NICK |
+                                G_PARAM_STATIC_BLURB);
+    g_object_class_install_property(g_klass,
+                                    PROP_TEMPLATE_DATA,
+                                    pspec);
+
+    pspec = g_param_spec_string("profile",
+                                "Profile",
+                                "Install script profile name",
+                                NULL /* default value */,
+                                G_PARAM_READABLE |
+                                G_PARAM_WRITABLE |
+                                G_PARAM_CONSTRUCT_ONLY |
+                                G_PARAM_STATIC_NAME |
+                                G_PARAM_STATIC_NICK |
+                                G_PARAM_STATIC_BLURB);
+    g_object_class_install_property(g_klass,
+                                    PROP_PROFILE,
+                                    pspec);
+
+    pspec = g_param_spec_string("product-key-format",
+                                "Product Key Format",
+                                "Product key format mask",
+                                NULL /* default value */,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_NAME |
+                                G_PARAM_STATIC_NICK |
+                                G_PARAM_STATIC_BLURB);
+    g_object_class_install_property(g_klass,
+                                    PROP_PROFILE,
+                                    pspec);
+
+    g_type_class_add_private (klass, sizeof (OsinfoInstallScriptPrivate));
+}
+
+static void
+osinfo_install_script_init (OsinfoInstallScript *list)
+{
+    OsinfoInstallScriptPrivate *priv;
+    list->priv = priv = OSINFO_INSTALL_SCRIPT_GET_PRIVATE(list);
+
+}
+
+
+OsinfoInstallScript *osinfo_install_script_new(const gchar *id)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_SCRIPT,
+                        "id", id,
+                        NULL);
+}
+
+/**
+ * osinfo_install_script_new_data:
+ *
+ * Construct a new install script from stylesheet data
+ *
+ * Returns: (transfer full): an new install script
+ */
+OsinfoInstallScript *osinfo_install_script_new_data(const gchar *id,
+                                                    const gchar *profile,
+                                                    const gchar *templateData)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_SCRIPT,
+                        "id", id,
+                        "profile", profile,
+                        "template-data", templateData,
+                        NULL);
+}
+
+
+/**
+ * osinfo_install_script_new_uri:
+ *
+ * Construct a new install script from a stylesheet URI
+ *
+ * Returns: (transfer full): an new install script
+ */
+OsinfoInstallScript *osinfo_install_script_new_uri(const gchar *id,
+                                                   const gchar *profile,
+                                                   const gchar *templateUri)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_SCRIPT,
+                        "id", id,
+                        "profile", profile,
+                        "template-uri", templateUri,
+                        NULL);
+}
+
+
+const gchar *osinfo_install_script_get_template_uri(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
+                                         OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_URI);
+}
+
+const gchar *osinfo_install_script_get_template_data(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
+                                         OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA);
+}
+
+const gchar *osinfo_install_script_get_profile(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
+                                         OSINFO_INSTALL_SCRIPT_PROP_PROFILE);
+}
+
+const gchar *osinfo_install_script_get_product_key_format(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
+                                         OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT);
+}
+
+struct OsinfoInstallScriptGenerate {
+    GSimpleAsyncResult *res;
+    OsinfoOs *os;
+    OsinfoInstallConfig *config;
+    OsinfoInstallScript *script;
+};
+
+
+static void osinfo_install_script_generate_free(struct OsinfoInstallScriptGenerate *data)
+{
+    g_object_unref(data->os);
+    g_object_unref(data->config);
+    g_object_unref(data->script);
+    g_object_unref(data->res);
+    g_free(data);
+}
+
+
+static xsltStylesheetPtr osinfo_install_script_load_template(const gchar *uri,
+                                                             const gchar *template,
+                                                             GError **error)
+{
+    xsltStylesheetPtr xslt = NULL;
+    xmlDocPtr doc = NULL;
+    xmlParserCtxtPtr pctxt;
+
+    /* Set up a parser context so we can catch the details of XML errors. */
+    pctxt = xmlNewParserCtxt();
+    if (!pctxt || !pctxt->sax) {
+        g_set_error(error, 0, 0, "%s",
+                    "Unable to create XML parser context");
+        goto cleanup;
+    }
+
+    if (!(doc = xmlCtxtReadDoc(pctxt, BAD_CAST template, uri, NULL,
+                               XML_PARSE_NOENT | XML_PARSE_NONET |
+                               XML_PARSE_NOWARNING))) {
+        g_set_error(error, 0, 0, "%s",
+                    "Unable to read XSL template");
+        goto cleanup;
+    }
+
+    if (!(xslt = xsltParseStylesheetDoc(doc))) {
+        g_set_error(error, 0, 0, "%s",
+                    "Unable to parse XSL template");
+        goto cleanup;
+    }
+
+ cleanup:
+    xmlFreeParserCtxt(pctxt);
+    return xslt;
+}
+
+static xmlNodePtr osinfo_install_script_generate_entity_config(OsinfoInstallConfig *config,
+                                                               OsinfoEntity *entity,
+                                                               const gchar *name,
+                                                               GError **error)
+{
+    xmlNodePtr node = NULL;
+    xmlNodePtr data = NULL;
+    GList *keys;
+    GList *tmp1;
+
+    if (!(node = xmlNewDocNode(NULL, NULL, (xmlChar*)name, NULL))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to create XML node '%s': '%s'",
+                    name, err ? err->message : "");
+        goto error;
+    }
+
+    if (!(data = xmlNewDocNode(NULL, NULL, (const xmlChar*)"id",
+                               (const xmlChar*)osinfo_entity_get_id(entity)))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to create XML node 'id': '%s'",
+                    err ? err->message : "");
+        goto error;
+    }
+    if (!(xmlAddChild(node, data))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to add XML child '%s'", err ? err->message : "");
+        goto error;
+    }
+    data = NULL;
+
+    tmp1 = keys = osinfo_entity_get_param_keys(entity);
+    while (tmp1) {
+        GList *values = osinfo_entity_get_param_value_list(entity, tmp1->data);
+        GList *tmp2 = values;
+
+        while (tmp2) {
+            if (!(data = xmlNewDocNode(NULL, NULL, (const xmlChar*)tmp1->data,
+                                       (const xmlChar*)tmp2->data))) {
+                xmlErrorPtr err = xmlGetLastError();
+                g_set_error(error, 0, 0, "Unable to create XML node '%s': '%s'",
+                            (const gchar *)tmp1->data, err ? err->message : "");
+                goto error;
+            }
+            if (!(xmlAddChild(node, data))) {
+                xmlErrorPtr err = xmlGetLastError();
+                g_set_error(error, 0, 0, "Unable to add XML child '%s'", err ? err->message : "");
+                goto error;
+            }
+            data = NULL;
+
+            tmp2 = tmp2->next;
+        }
+        g_list_free(values);
+
+        tmp1 = tmp1->next;
+    }
+    g_list_free(keys);
+
+    return node;
+
+ error:
+    xmlFreeNode(data);
+    xmlFreeNode(node);
+    return NULL;
+}
+
+
+static xmlDocPtr osinfo_install_script_generate_config_xml(OsinfoInstallScript *script,
+                                                           OsinfoOs *os,
+                                                           OsinfoInstallConfig *config,
+                                                           GError **error)
+{
+    xmlDocPtr doc = xmlNewDoc((xmlChar *)"1.0");
+    xmlNodePtr root;
+    xmlNodePtr node;
+
+    root = xmlNewDocNode(NULL,
+                         NULL,
+                         (xmlChar*)"install-script-config",
+                         NULL);
+    xmlDocSetRootElement(doc, root);
+
+    if (!(node = osinfo_install_script_generate_entity_config(config,
+                                                              OSINFO_ENTITY(script),
+                                                              "script",
+                                                              error)))
+        goto error;
+    if (!(xmlAddChild(root, node))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to set XML root '%s'", err ? err->message : "");
+        goto error;
+    }
+
+    if (!(node = osinfo_install_script_generate_entity_config(config,
+                                                              OSINFO_ENTITY(os),
+                                                              "os",
+                                                              error)))
+        goto error;
+    if (!(xmlAddChild(root, node))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to set XML root '%s'", err ? err->message : "");
+        goto error;
+    }
+
+    if (!(node = osinfo_install_script_generate_entity_config(config,
+                                                              OSINFO_ENTITY(config),
+                                                              "config",
+                                                              error)))
+        goto error;
+    if (!(xmlAddChild(root, node))) {
+        xmlErrorPtr err = xmlGetLastError();
+        g_set_error(error, 0, 0, "Unable to set XML root '%s'", err ? err->message : "");
+        goto error;
+    }
+
+    return doc;
+
+ error:
+    xmlFreeDoc(doc);
+    doc = NULL;
+    return NULL;
+}
+
+static gchar *osinfo_install_script_apply_xslt(xsltStylesheetPtr ss,
+                                               xmlDocPtr doc,
+                                               GError **error)
+{
+    xsltTransformContextPtr ctxt;
+    gchar *ret;
+    xmlDocPtr docOut = NULL;
+    int len;
+
+    if (!(ctxt = xsltNewTransformContext(ss, doc))) {
+        g_set_error(error, 0, 0, "%s", "Unable to create XSL transform context");
+        goto cleanup;
+    }
+
+    if (!(docOut = xsltApplyStylesheetUser(ss, doc, NULL, NULL, NULL, ctxt))) {
+        g_set_error(error, 0, 0, "%s", "Unable to apply XSL transform context");
+        goto cleanup;
+    }
+
+    if (xsltSaveResultToString((xmlChar **)&ret, &len, docOut, ss) < 0) {
+        g_set_error(error, 0, 0, "%s", "Unable to convert XSL output to string");
+        goto cleanup;
+    }
+
+ cleanup:
+    xmlFreeDoc(docOut);
+    xsltFreeTransformContext(ctxt);
+    return ret;
+}
+
+
+static gboolean osinfo_install_script_apply_template(OsinfoInstallScript *script,
+                                                     OsinfoOs *os,
+                                                     const gchar *templateUri,
+                                                     const gchar *template,
+                                                     gchar **result,
+                                                     OsinfoInstallConfig *config,
+                                                     GError **error)
+{
+    gboolean ret = FALSE;
+    xsltStylesheetPtr templateXsl = osinfo_install_script_load_template(templateUri, template, error);
+    xmlDocPtr configXml = osinfo_install_script_generate_config_xml(script, os, config, error);
+
+    if (!templateXsl || !configXml)
+        goto cleanup;
+
+    if (!(*result = osinfo_install_script_apply_xslt(templateXsl, configXml, error)))
+        goto cleanup;
+
+    ret = TRUE;
+
+ cleanup:
+    xsltFreeStylesheet(templateXsl);
+    xmlFreeDoc(configXml);
+    return ret;
+}
+
+
+static void osinfo_install_script_template_loaded(GObject *src,
+                                                  GAsyncResult *res,
+                                                  gpointer user_data)
+{
+    struct OsinfoInstallScriptGenerate *data = user_data;
+    GError *error = NULL;
+    gchar *input = NULL;
+    gchar *output = NULL;
+    gsize length = 0;
+    GFile *file = G_FILE(src);
+    gchar *uri = g_file_get_uri(file);
+
+    if (!g_file_load_contents_finish(file,
+                                     res,
+                                     &input,
+                                     &length,
+                                     NULL,
+                                     &error)) {
+        g_prefix_error(&error, "Failed to load script template %s: ", uri);
+        g_simple_async_result_take_error(data->res, error);
+        goto cleanup;
+    }
+
+
+    if (!osinfo_install_script_apply_template(data->script,
+                                              data->os,
+                                              uri,
+                                              input,
+                                              &output,
+                                              data->config,
+                                              &error)) {
+        g_prefix_error(&error, "Failed to apply script template %s: ", uri);
+        g_simple_async_result_take_error(data->res, error);
+        goto cleanup;
+    }
+
+    g_simple_async_result_set_op_res_gpointer(data->res,
+                                              output, NULL);
+
+ cleanup:
+    g_simple_async_result_complete(data->res);
+    osinfo_install_script_generate_free(data);
+    g_free(uri);
+}
+
+
+void osinfo_install_script_generate_async(OsinfoInstallScript *script,
+                                          OsinfoOs *os,
+                                          OsinfoInstallConfig *config,
+                                          GCancellable *cancellable,
+                                          GAsyncReadyCallback callback,
+                                          gpointer user_data)
+{
+    struct OsinfoInstallScriptGenerate *data = g_new0(struct OsinfoInstallScriptGenerate, 1);
+    const gchar *templateData = osinfo_install_script_get_template_data(script);
+    const gchar *templateUri = osinfo_install_script_get_template_uri(script);
+
+    data->os = g_object_ref(os);
+    data->config = g_object_ref(config);
+    data->script = g_object_ref(script);
+    data->res = g_simple_async_result_new(G_OBJECT(script),
+                                          callback,
+                                          user_data,
+                                          osinfo_install_script_generate_async);
+
+    if (templateData) {
+        GError *error = NULL;
+        gchar *output;
+        if (!osinfo_install_script_apply_template(script,
+                                                  os,
+                                                  "<data>",
+                                                  templateData,
+                                                  &output,
+                                                  data->config,
+                                                  &error)) {
+            g_prefix_error(&error, "%s", "Failed to apply script template: ");
+            g_simple_async_result_take_error(data->res, error);
+            g_simple_async_result_complete(data->res);
+            osinfo_install_script_generate_free(data);
+            return;
+        }
+        g_simple_async_result_set_op_res_gpointer(data->res,
+                                                  output, NULL);
+        g_simple_async_result_complete_in_idle(data->res);
+        osinfo_install_script_generate_free(data);
+    } else {
+        GFile *file = g_file_new_for_uri(templateUri);
+
+        g_file_load_contents_async(file,
+                                   cancellable,
+                                   osinfo_install_script_template_loaded,
+                                   data);
+    }
+}
+
+gchar *osinfo_install_script_generate_finish(OsinfoInstallScript *script,
+                                             GAsyncResult *res,
+                                             GError **error)
+{
+    GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
+
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+    if (g_simple_async_result_propagate_error(simple, error))
+        return FALSE;
+
+    return g_simple_async_result_get_op_res_gpointer(simple);
+}
+
+
+struct OsinfoInstallScriptGenerateSync {
+    GMainLoop *loop;
+    GError *error;
+    gchar *output;
+};
+
+static void osinfo_install_script_generate_done(GObject *src,
+                                                GAsyncResult *res,
+                                                gpointer user_data)
+{
+    struct OsinfoInstallScriptGenerateSync *data = user_data;
+
+    data->output =
+        osinfo_install_script_generate_finish(OSINFO_INSTALL_SCRIPT(src),
+                                              res,
+                                              &data->error);
+    g_main_loop_quit(data->loop);
+}
+
+
+gchar *osinfo_install_script_generate(OsinfoInstallScript *script,
+                                      OsinfoOs *os,
+                                      OsinfoInstallConfig *config,
+                                      GCancellable *cancellable,
+                                      GError **error)
+{
+    GMainLoop *loop = g_main_loop_new(g_main_context_get_thread_default(),
+                                      TRUE);
+    struct OsinfoInstallScriptGenerateSync data = {
+        loop, NULL, NULL
+    };
+
+    osinfo_install_script_generate_async(script,
+                                         os,
+                                         config,
+                                         cancellable,
+                                         osinfo_install_script_generate_done,
+                                         &data);
+
+    if (g_main_loop_is_running(loop))
+        g_main_loop_run(loop);
+
+    if (data.error)
+        g_propagate_error(error, data.error);
+
+    g_main_loop_unref(loop);
+
+    return data.output;
+}
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
new file mode 100644
index 0000000..00740c2
--- /dev/null
+++ b/osinfo/osinfo_install_script.h
@@ -0,0 +1,113 @@
+/*
+ * libosinfo: OS installation script
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#ifndef __OSINFO_INSTALL_SCRIPT_H__
+#define __OSINFO_INSTALL_SCRIPT_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_INSTALL_SCRIPT                  (osinfo_install_script_get_type ())
+#define OSINFO_INSTALL_SCRIPT(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScript))
+#define OSINFO_IS_INSTALL_SCRIPT(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_INSTALL_SCRIPT))
+#define OSINFO_INSTALL_SCRIPT_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScriptClass))
+#define OSINFO_IS_INSTALL_SCRIPT_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_SCRIPT))
+#define OSINFO_INSTALL_SCRIPT_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScriptClass))
+
+typedef struct _OsinfoOs        OsinfoOs;
+typedef struct _OsinfoInstallScript        OsinfoInstallScript;
+typedef struct _OsinfoInstallScriptClass   OsinfoInstallScriptClass;
+typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
+
+#define OSINFO_INSTALL_SCRIPT_PROFILE_JEOS    "jeos"
+#define OSINFO_INSTALL_SCRIPT_PROFILE_DESKTOP "desktop"
+
+#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_URI       "template-uri"
+#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA      "template-data"
+#define OSINFO_INSTALL_SCRIPT_PROP_PROFILE            "profile"
+#define OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT "product-key-format"
+
+/* object */
+struct _OsinfoInstallScript
+{
+    OsinfoEntity parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoInstallScriptPrivate *priv;
+};
+
+/* class */
+struct _OsinfoInstallScriptClass
+{
+    OsinfoEntityClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_install_script_get_type(void);
+
+OsinfoInstallScript *osinfo_install_script_new(const gchar *id);
+OsinfoInstallScript *osinfo_install_script_new_uri(const gchar *id,
+                                                   const gchar *profile,
+                                                   const gchar *templateUri);
+OsinfoInstallScript *osinfo_install_script_new_data(const gchar *id,
+                                                    const gchar *profile,
+                                                    const gchar *templateData);
+
+const gchar *osinfo_install_script_get_template_uri(OsinfoInstallScript *script);
+const gchar *osinfo_install_script_get_template_data(OsinfoInstallScript *script);
+const gchar *osinfo_install_script_get_profile(OsinfoInstallScript *script);
+
+const gchar *osinfo_install_script_get_product_key_format(OsinfoInstallScript *script);
+
+void osinfo_install_script_generate_async(OsinfoInstallScript *script,
+                                          OsinfoOs *os,
+                                          OsinfoInstallConfig *config,
+                                          GCancellable *cancellable,
+                                          GAsyncReadyCallback callback,
+                                          gpointer user_data);
+
+gchar *osinfo_install_script_generate_finish(OsinfoInstallScript *script,
+                                             GAsyncResult *res,
+                                             GError **error);
+
+gchar *osinfo_install_script_generate(OsinfoInstallScript *script,
+                                      OsinfoOs *os,
+                                      OsinfoInstallConfig *config,
+                                      GCancellable *cancellable,
+                                      GError **error);
+
+
+#endif /* __OSINFO_INSTALL_SCRIPT_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_scriptlist.c b/osinfo/osinfo_install_scriptlist.c
new file mode 100644
index 0000000..e5309b5
--- /dev/null
+++ b/osinfo/osinfo_install_scriptlist.c
@@ -0,0 +1,169 @@
+/*
+ * libosinfo:
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Arjun Roy <arroy redhat com>
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+G_DEFINE_TYPE (OsinfoInstallScriptList, osinfo_install_scriptlist, OSINFO_TYPE_LIST);
+
+#define OSINFO_INSTALL_SCRIPTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptListPrivate))
+
+/**
+ * SECTION:osinfo_install_scriptlist
+ * @short_description: A list of installation install_script
+ * @see_also: #OsinfoList, #OsinfoInstallScript
+ *
+ * #OsinfoInstallScriptList is a list specialization that stores
+ * only #OsinfoInstallScript objects.
+ */
+
+struct _OsinfoInstallScriptListPrivate
+{
+    gboolean unused;
+};
+
+static void
+osinfo_install_scriptlist_finalize (GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_install_scriptlist_parent_class)->finalize (object);
+}
+
+/* Init functions */
+static void
+osinfo_install_scriptlist_class_init (OsinfoInstallScriptListClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+
+    g_klass->finalize = osinfo_install_scriptlist_finalize;
+    g_type_class_add_private (klass, sizeof (OsinfoInstallScriptListPrivate));
+}
+
+static void
+osinfo_install_scriptlist_init (OsinfoInstallScriptList *list)
+{
+    OsinfoInstallScriptListPrivate *priv;
+    list->priv = priv = OSINFO_INSTALL_SCRIPTLIST_GET_PRIVATE(list);
+
+}
+
+/**
+ * osinfo_install_scriptlist_new:
+ *
+ * Construct a new install_script list that is initially empty.
+ *
+ * Returns: (transfer full): an empty install_script list
+ */
+OsinfoInstallScriptList *osinfo_install_scriptlist_new(void)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_SCRIPTLIST,
+                        "element-type", OSINFO_TYPE_INSTALL_SCRIPT,
+                        NULL);
+}
+
+/**
+ * osinfo_install_scriptlist_new_copy:
+ * @source: the install_script list to copy
+ *
+ * Construct a new install_script list that is filled with install_scripts
+ * from @source
+ *
+ * Returns: (transfer full): a copy of the install_script list
+ */
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_copy(OsinfoInstallScriptList *source)
+{
+    OsinfoInstallScriptList *newList = osinfo_install_scriptlist_new();
+    osinfo_list_add_all(OSINFO_LIST(newList),
+                        OSINFO_LIST(source));
+    return newList;
+}
+
+/**
+ * osinfo_install_scriptlist_new_filtered:
+ * @source: the install_script list to copy
+ * @filter: the filter to apply
+ *
+ * Construct a new install_script list that is filled with install_scripts
+ * from @source that match @filter
+ *
+ * Returns: (transfer full): a filtered copy of the install_script list
+ */
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_filtered(OsinfoInstallScriptList *source,
+                                                                OsinfoFilter *filter)
+{
+    OsinfoInstallScriptList *newList = osinfo_install_scriptlist_new();
+    osinfo_list_add_filtered(OSINFO_LIST(newList),
+                             OSINFO_LIST(source),
+                             filter);
+    return newList;
+}
+
+/**
+ * osinfo_install_scriptlist_new_intersection:
+ * @sourceOne: the first install_script list to copy
+ * @sourceTwo: the second install_script list to copy
+ *
+ * Construct a new install_script list that is filled with only the
+ * install_scripts that are present in both @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): an intersection of the two install_script lists
+ */
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_intersection(OsinfoInstallScriptList *sourceOne,
+                                                                    OsinfoInstallScriptList *sourceTwo)
+{
+    OsinfoInstallScriptList *newList = osinfo_install_scriptlist_new();
+    osinfo_list_add_intersection(OSINFO_LIST(newList),
+                                 OSINFO_LIST(sourceOne),
+                                 OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/**
+ * osinfo_install_scriptlist_new_union:
+ * @sourceOne: the first install_script list to copy
+ * @sourceTwo: the second install_script list to copy
+ *
+ * Construct a new install_script list that is filled with all the
+ * install_scripts that are present in either @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): a union of the two install_script lists
+ */
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_union(OsinfoInstallScriptList *sourceOne,
+                                                             OsinfoInstallScriptList *sourceTwo)
+{
+    OsinfoInstallScriptList *newList = osinfo_install_scriptlist_new();
+    osinfo_list_add_union(OSINFO_LIST(newList),
+                          OSINFO_LIST(sourceOne),
+                          OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_scriptlist.h b/osinfo/osinfo_install_scriptlist.h
new file mode 100644
index 0000000..39544d2
--- /dev/null
+++ b/osinfo/osinfo_install_scriptlist.h
@@ -0,0 +1,82 @@
+/*
+ * libosinfo: a list of installation install_script
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Zeeshan Ali <zeenix redhat com>
+ *   Arjun Roy <arroy redhat com>
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <glib-object.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_INSTALL_SCRIPTLIST_H__
+#define __OSINFO_INSTALL_SCRIPTLIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_INSTALL_SCRIPTLIST                  (osinfo_install_scriptlist_get_type ())
+#define OSINFO_INSTALL_SCRIPTLIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptList))
+#define OSINFO_IS_INSTALL_SCRIPTLIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST))
+#define OSINFO_INSTALL_SCRIPTLIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptListClass))
+#define OSINFO_IS_INSTALL_SCRIPTLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_SCRIPTLIST))
+#define OSINFO_INSTALL_SCRIPTLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptListClass))
+
+typedef struct _OsinfoInstallScriptList        OsinfoInstallScriptList;
+
+typedef struct _OsinfoInstallScriptListClass   OsinfoInstallScriptListClass;
+
+typedef struct _OsinfoInstallScriptListPrivate OsinfoInstallScriptListPrivate;
+
+/* object */
+struct _OsinfoInstallScriptList
+{
+    OsinfoList parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoInstallScriptListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoInstallScriptListClass
+{
+    OsinfoListClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_install_scriptlist_get_type(void);
+
+OsinfoInstallScriptList *osinfo_install_scriptlist_new(void);
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_copy(OsinfoInstallScriptList *source);
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_filtered(OsinfoInstallScriptList *source, OsinfoFilter *filter);
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_intersection(OsinfoInstallScriptList *sourceOne, OsinfoInstallScriptList *sourceTwo);
+OsinfoInstallScriptList *osinfo_install_scriptlist_new_union(OsinfoInstallScriptList *sourceOne, OsinfoInstallScriptList *sourceTwo);
+
+#endif /* __OSINFO_INSTALL_SCRIPTLIST_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
1.7.7.6


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