[virt-tools-list] [PATCH 10/10] Add desktop profile for Windows

Fabiano Fidêncio fabiano at fidencio.org
Tue Jun 12 02:23:11 UTC 2012


    Based on boxes install script for windows.

    As older windows have more than one script for installation
    (http://bugzilla-attachments.gnome.org/attachment.cgi?id=214681)
    I'm changing, too, osinfo-install-script tool to generate multiple
    files when needed.

    So, in older windows installations (2k3r2 and older), the output
    files are:
    windows.sif, windows.reg and windows.cmd.

    Just to remember. Don't allow the user to choose the output file is
    a decision to simplify our live, because we need to know the name of
    .cmd (used in .sif) and the .reg (used in .cmd) to generate them
    correctly.
---
 data/install-scripts/Makefile.am     |    2 ++
 data/install-scripts/windows-cmd.xml |   22 ++++++++++++
 data/install-scripts/windows-reg.xml |   23 ++++++++++++
 data/install-scripts/windows-sif.xml |   66 +++++++++++++++++++++++++++++++++-
 data/oses/windows.xml                |   20 ++++++++---
 tools/osinfo-install-script.c        |   57 ++++++++++++++++++-----------
 6 files changed, 164 insertions(+), 26 deletions(-)
 create mode 100644 data/install-scripts/windows-cmd.xml
 create mode 100644 data/install-scripts/windows-reg.xml

diff --git a/data/install-scripts/Makefile.am b/data/install-scripts/Makefile.am
index 002a884..cb24e09 100644
--- a/data/install-scripts/Makefile.am
+++ b/data/install-scripts/Makefile.am
@@ -3,6 +3,8 @@ databasedir = $(pkgdatadir)/db/install-scripts/
 database_DATA =     \
   fedora.xml        \
   windows-sif.xml   \
+  windows-cmd.xml   \
+  windows-reg.xml   \
   windows-unattend.xml \
   $(NULL)
 
diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
new file mode 100644
index 0000000..ec09ca4
--- /dev/null
+++ b/data/install-scripts/windows-cmd.xml
@@ -0,0 +1,22 @@
+<libosinfo version="0.0.1">
+  <install-script id='http://microsoft.com/windows/cmd/desktop'>
+    <profile>desktop</profile>
+    <template>
+      <xsl:stylesheet
+        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+        version="1.0">
+
+        <xsl:output method="text"/>
+
+	<xsl:template match="/install-script-config">
+Windows Registry Editor Version 5.00
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
+"DefaultUserName"="<xsl:value-of select="config/user-realname"/>"
+"DefaultPassword"="<xsl:value-of select="config/admin-password"/>"
+"AutoAdminLogon"="1"
+	</xsl:template>
+      </xsl:stylesheet>
+    </template>
+  </install-script>
+</libosinfo>
diff --git a/data/install-scripts/windows-reg.xml b/data/install-scripts/windows-reg.xml
new file mode 100644
index 0000000..93375ce
--- /dev/null
+++ b/data/install-scripts/windows-reg.xml
@@ -0,0 +1,23 @@
+<libosinfo version="0.0.1">
+    <install-script id='http://microsoft.com/windows/reg/desktop'>
+    <profile>desktop</profile>
+    <template>
+      <xsl:stylesheet
+        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+        version="1.0">
+
+        <xsl:output method="text"/>
+
+	<xsl:template match="/install-script-config">
+sc config TlntSvr start= auto
+net user <xsl:value-of select="config/user-realname"/> <xsl:value-of select="config/admin-password"/> /add /passwordreq:no
+net localgroup administrators <xsl:value-of select="config/user-realname"/> /add
+net accounts /maxpwage:unlimited
+copy a:\<xsl:value-of select="config/user-realname"/>.bmp "c:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures"
+REGEDIT /S a:\windows.reg
+EXIT
+	</xsl:template>
+      </xsl:stylesheet>
+    </template>
+  </install-script>
+</libosinfo>
diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml
index 29a0eae..152f8f6 100644
--- a/data/install-scripts/windows-sif.xml
+++ b/data/install-scripts/windows-sif.xml
@@ -1,5 +1,6 @@
 <libosinfo version="0.0.1">
-  <install-script id='http://microsoft.com/windows/sif'>
+  <!-- JEOS POROFILE -->
+  <install-script id='http://microsoft.com/windows/sif/jeos'>
     <profile>jeos</profile>
     <template>
       <xsl:stylesheet
@@ -56,4 +57,67 @@
       </xsl:stylesheet>
     </template>
   </install-script>
+  <!-- DESKTOP POROFILE -->
+  <install-script id='http://microsoft.com/windows/sif/desktop'>
+    <profile>desktop</profile>
+    <template>
+      <xsl:stylesheet
+        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+        version="1.0">
+
+        <xsl:output method="text"/>
+
+	<xsl:template match="/install-script-config">
+;SetupMgrTag
+[Data]
+    AutoPartition=1
+    MsDosInitiated=No
+    UnattendedInstall=Yes
+
+[Unattended]
+    UnattendMode=FullUnattended
+    OemSkipEula=Yes
+    OemPreinstall=No
+    TargetPath=\WINDOWS
+    Repartition=Yes
+    WaitForReboot=No
+    UnattendSwitch=Yes
+
+[GuiUnattended]
+    AdminPassword=<xsl:value-of select="config/admin-password"/>
+    EncryptedAdminPassword=NO
+    OEMSkipRegional=1
+    TimeZone=35
+    OemSkipWelcome=1
+
+[UserData]
+    ProductKey=<xsl:value-of select="config/reg-productkey"/>
+    FullName="<xsl:value-of select="config/user-realname"/>"
+    OrgName=""
+    ComputerName=<xsl:value-of select="config/hostname"/>
+
+[LicenseFilePrintData]
+    AutoMode=PerServer
+    AutoUsers=5
+
+[Identification]
+    JoinWorkgroup=WORKGROUP
+
+[Networking]
+    InstallDefaultComponents=Yes
+
+[SetupParams]
+    UserExecute = "a:\windows.cmd"
+
+[WindowsFirewall]
+    Profiles = WindowsFirewall.TurnOffFirewall
+
+[WindowsFirewall.TurnOffFirewall]
+    Mode = 0
+
+	</xsl:template>
+      </xsl:stylesheet>
+    </template>
+  </install-script>
+
 </libosinfo>
diff --git a/data/oses/windows.xml b/data/oses/windows.xml
index 8769511..2fb18be 100644
--- a/data/oses/windows.xml
+++ b/data/oses/windows.xml
@@ -308,7 +308,10 @@
     </resources>
 
     <installer>
-      <script id='http://microsoft.com/windows/sif'/>
+      <script id='http://microsoft.com/windows/sif/jeos'/>
+      <script id='http://microsoft.com/windows/sif/desktop'/>
+      <script id='http://microsoft.com/windows/reg/desktop'/>
+      <script id='http://microsoft.com/windows/cmd/desktop'/>
     </installer>
   </os>
 
@@ -365,7 +368,10 @@
     </resources>
 
     <installer>
-      <script id='http://microsoft.com/windows/sif'/>
+      <script id='http://microsoft.com/windows/sif/jeos'/>
+      <script id='http://microsoft.com/windows/sif/desktop'/>
+      <script id='http://microsoft.com/windows/reg/desktop'/>
+      <script id='http://microsoft.com/windows/cmd/desktop'/>
     </installer>
   </os>
 
@@ -430,7 +436,10 @@
     </resources>
 
     <installer>
-      <script id='http://microsoft.com/windows/sif'/>
+      <script id='http://microsoft.com/windows/sif/jeos'/>
+      <script id='http://microsoft.com/windows/sif/desktop'/>
+      <script id='http://microsoft.com/windows/reg/desktop'/>
+      <script id='http://microsoft.com/windows/cmd/desktop'/>
     </installer>
   </os>
 
@@ -489,7 +498,10 @@
     </resources>
 
     <installer>
-      <script id='http://microsoft.com/windows/sif'/>
+      <script id='http://microsoft.com/windows/sif/jeos'/>
+      <script id='http://microsoft.com/windows/sif/desktop'/>
+      <script id='http://microsoft.com/windows/reg/desktop'/>
+      <script id='http://microsoft.com/windows/cmd/desktop'/>
     </installer>
   </os>
 
diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c
index 85151b8..c6ada2c 100644
--- a/tools/osinfo-install-script.c
+++ b/tools/osinfo-install-script.c
@@ -27,7 +27,7 @@
 #include <string.h>
 
 static gchar *profile;
-static gchar *output;
+static GSList *outputScripts;
 
 static OsinfoInstallConfig *config;
 
@@ -103,15 +103,18 @@ static void script_file_name_get(char *distro)
 {
     if (!(strcmp(distro, "win2k")) || !(strcmp(distro, "winxp")) ||
         !(strcmp(distro, "win2k3")) || !(strcmp(distro, "win2k3r3"))) {
-        output = g_strdup("windows.sif");
+        outputScripts = g_slist_append(outputScripts, g_strdup("windows.sif"));
+        outputScripts = g_slist_append(outputScripts, g_strdup("windows.reg"));
+        outputScripts = g_slist_append(outputScripts, g_strdup("windows.cmd"));
     } else if (!(strcmp(distro, "win2k8")) || !(strcmp(distro, "win2k8r2")) ||
                !(strcmp(distro, "vista")) || !(strcmp(distro, "win7")) ||
                !(strcmp(distro, "win8"))) {
-        output = g_strdup("windows.xml");
+        outputScripts = g_slist_append(outputScripts, g_strdup("windows.xml"));
     } else {
         gsize len = sizeof(distro) + sizeof(".ks");
-        output = g_malloc(len);
+        gchar *output = g_malloc(len);
         g_snprintf(output, len, "%s.ks", distro);
+        outputScripts = g_slist_append(outputScripts, output);
     }
 }
 
@@ -120,9 +123,9 @@ static gboolean generate_script(OsinfoOs *os)
     OsinfoInstallScriptList *scripts = osinfo_os_get_install_script_list(os);
     OsinfoInstallScriptList *profileScripts;
     OsinfoFilter *filter;
-    OsinfoInstallScript *script;
     GError *error = NULL;
     gboolean ret = FALSE;
+    gint i;
 
     filter = osinfo_filter_new();
     osinfo_filter_add_constraint(filter,
@@ -132,29 +135,41 @@ static gboolean generate_script(OsinfoOs *os)
 
     profileScripts = osinfo_install_scriptlist_new_filtered(scripts,
                                                          filter);
-    if (osinfo_list_get_length(OSINFO_LIST(profileScripts)) != 1) {
+    if (osinfo_list_get_length(OSINFO_LIST(profileScripts)) == 0) {
         g_printerr("Cannot find any install script for profile '%s'\n",
                    profile ? profile :
                    OSINFO_INSTALL_SCRIPT_PROFILE_JEOS);
         goto cleanup;
     }
 
-    script = OSINFO_INSTALL_SCRIPT(
-            osinfo_list_get_nth(OSINFO_LIST(profileScripts), 0));
-
-    if (!osinfo_install_script_generate(script,
-                                        os,
-                                        config,
-                                        output,
-                                        NULL,
-                                        &error)) {
-        g_printerr("Unable to generate install script: %s\n",
-                error ? error->message : "unknown");
-        goto cleanup;
+    for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(profileScripts)); i++) {
+        OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT(
+                osinfo_list_get_nth(OSINFO_LIST(profileScripts), i));
+        gchar *filename = g_slist_nth_data(outputScripts, i);
+
+        if (!osinfo_install_script_generate(script,
+                                            os,
+                                            config,
+                                            filename,
+                                            NULL,
+                                            &error)) {
+            g_printerr("Unable to generate install script: %s\n",
+                    error ? error->message : "unknown");
+            goto cleanup;
+        }
     }
 
     ret = TRUE;
-    g_print("Install script was generated successfully as: %s\n", output);
+
+    if (g_slist_length(outputScripts) == 1)
+        g_print("Install script was generated successfully!\n"
+                "The generated file is:\n");
+    else
+        g_print("Install scripts were generated successfully!\n"
+                "The generated files are:\n");
+
+    for (i = 0; i < g_slist_length(outputScripts); i++)
+        g_print("%s\n", (gchar *)g_slist_nth_data(outputScripts, i));
 
  cleanup:
     g_object_unref(scripts);
@@ -221,8 +236,8 @@ gint main(gint argc, gchar **argv)
 EXIT:
     if (config)
         g_object_unref(config);
-    if (output)
-        g_free(output);
+    if (outputScripts)
+        g_slist_free_full(outputScripts, g_free);
     g_clear_error(&error);
     g_clear_object(&loader);
     g_option_context_free(context);
-- 
1.7.10.2




More information about the virt-tools-list mailing list