[gnome-boxes] Set arch in win7 unattended installation XML



commit 4fb883ee27d18fd7c10bba334a3841f4400bc40a
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Jan 13 15:11:04 2012 +0100

    Set arch in win7 unattended installation XML
    
    Currently, the CPU arch for unattended win7 installations is
    hardcoded to amd64. This means unattended install of 32 bit
    ISOs will not work. This patch adds a new BOXES_CPU string to
    the template xml file which will get substituted with the actual
    CPU arch.

 data/win7.xml           |    6 +++---
 src/win7-installer.vala |   29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/data/win7.xml b/data/win7.xml
index c14d76c..69a2595 100644
--- a/data/win7.xml
+++ b/data/win7.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <unattend xmlns="urn:schemas-microsoft-com:unattend">
   <settings pass="windowsPE">
-    <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+    <component name="Microsoft-Windows-Setup" processorArchitecture="BOXES_CPU" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
       <DiskConfiguration>
 	<WillShowUI>OnError</WillShowUI>
 	<Disk>
@@ -46,7 +46,7 @@
 	<AcceptEula>true</AcceptEula>
       </UserData>
     </component>
-    <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+    <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="BOXES_CPU" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
       <SetupUILanguage>
 	<UILanguage>BOXES_LANG</UILanguage>
       </SetupUILanguage>
@@ -56,7 +56,7 @@
     </component>
   </settings>
   <settings pass="oobeSystem">
-    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="BOXES_CPU" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
       <UserAccounts>
 	<AdministratorPassword>
 	  <Value>BOXES_PASSWORD</Value>
diff --git a/src/win7-installer.vala b/src/win7-installer.vala
index 88ea01d..b40c2f2 100644
--- a/src/win7-installer.vala
+++ b/src/win7-installer.vala
@@ -1,7 +1,36 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 
 // Automated installer media for Windows 7 and 2008
+
 private class Boxes.Win7Installer: WindowsInstaller {
+    private static Regex arch_regex;
+
+    static construct {
+        try {
+            arch_regex = new Regex ("BOXES_CPU");
+        } catch (RegexError error) {
+            // This just can't fail
+            assert_not_reached ();
+        }
+    }
+
+    protected override string fill_unattended_data (string data) throws RegexError {
+        var str = base.fill_unattended_data (data);
+
+        switch (os_media.architecture) {
+            case "x86_64":
+                return arch_regex.replace (str, str.length, 0, "amd64");
+
+            case "i386":
+                return arch_regex.replace (str, str.length, 0, "x86");
+
+            default:
+                warning("Unexpected osinfo win7 arch: %s", os_media.architecture);
+
+                return arch_regex.replace (str, str.length, 0, "x86");
+        }
+    }
+
     public Win7Installer.copy (InstallerMedia media) throws GLib.Error {
         var unattended_source = get_unattended_dir (media.os.short_id + ".xml");
         base.copy (media, unattended_source, "Autounattend.xml");



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