From fcc631dedb894379cde01af563df3f6a364db7cb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 16 Nov 2010 17:37:30 +0000
Subject: [PATCH] images: Make phony Windows image for testing.

---
 .gitignore                            |   1 +
 images/Makefile.am                    |  31 +++++++++++++++++--
 images/guest-aux/make-windows-img.sh  |  54 ++++++++++++++++++++++++++++++++++
 images/guest-aux/minimal-hive         | Bin 0 -> 8192 bytes
 images/guest-aux/windows-software     | Bin 0 -> 12288 bytes
 images/guest-aux/windows-software.reg |  32 ++++++++++++++++++++
 images/guest-aux/windows-system       | Bin 0 -> 12288 bytes
 images/guest-aux/windows-system.reg   |   8 +++++
 8 files changed, 124 insertions(+), 2 deletions(-)
 create mode 100755 images/guest-aux/make-windows-img.sh
 create mode 100755 images/guest-aux/minimal-hive
 create mode 100755 images/guest-aux/windows-software
 create mode 100644 images/guest-aux/windows-software.reg
 create mode 100755 images/guest-aux/windows-system
 create mode 100644 images/guest-aux/windows-system.reg

diff --git a/.gitignore b/.gitignore
index 1442a04..16f2925 100644
--- a/.gitignore
+++ b/.gitignore
@@ -134,6 +134,7 @@ images/initrd-x86_64.img.gz
 images/test.iso
 images/test-grep.txt.gz
 images/ubuntu.img
+images/windows.img
 initramfs
 initramfs.timestamp
 inspector/virt-inspector.1
diff --git a/images/Makefile.am b/images/Makefile.am
index d97dd45..5688080 100644
--- a/images/Makefile.am
+++ b/images/Makefile.am
@@ -42,13 +42,19 @@ EXTRA_DIST = \
 	guest-aux/make-fedora-img.sh \
 	guest-aux/fedora-name.db.txt \
 	guest-aux/fedora-name.db \
-	guest-aux/make-ubuntu-img.sh
+	guest-aux/make-ubuntu-img.sh \
+	guest-aux/make-windows-img.sh \
+	guest-aux/windows-software \
+	guest-aux/windows-software.reg \
+	guest-aux/windows-system \
+	guest-aux/windows-system.reg \
+	guest-aux/minimal-hive
 
 noinst_DATA = test.iso
 
 # This is 'check_DATA' because we don't need it until 'make check'
 # time and we need the tools we have built in order to make it.
-check_DATA = debian.img fedora.img ubuntu.img
+check_DATA = debian.img fedora.img ubuntu.img windows.img
 
 CLEANFILES = \
 	test.iso test.sqsh \
@@ -181,3 +187,24 @@ ubuntu.img: guest-aux/make-ubuntu-img.sh
 	LIBGUESTFS_PATH=../appliance \
 	LD_LIBRARY_PATH=../src/.libs \
 	bash $<
+
+# Make a (dummy) Windows image.
+windows.img: guest-aux/make-windows-img.sh \
+	     guest-aux/windows-software guest-aux/windows-system
+	LIBGUESTFS_PATH=../appliance \
+	LD_LIBRARY_PATH=../src/.libs \
+	bash $<
+
+# Since users might not have the tools needed to create this, we
+# also distribute these files.
+guest-aux/windows-software: guest-aux/windows-software.reg
+	rm -f $@ $@-t
+	cp guest-aux/minimal-hive $@-t
+	hivexregedit --merge $@-t --prefix 'HKEY_LOCAL_MACHINE\SOFTWARE' $<
+	mv $@-t $@
+
+guest-aux/windows-system: guest-aux/windows-system.reg
+	rm -f $@ $@-t
+	cp guest-aux/minimal-hive $@-t
+	hivexregedit --merge $@-t --prefix 'HKEY_LOCAL_MACHINE\SYSTEM' $<
+	mv $@-t $@
diff --git a/images/guest-aux/make-windows-img.sh b/images/guest-aux/make-windows-img.sh
new file mode 100755
index 0000000..5a0cd6d
--- /dev/null
+++ b/images/guest-aux/make-windows-img.sh
@@ -0,0 +1,54 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2010 Red Hat Inc.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Make a Windows image which is enough to fool the inspection heuristics.
+
+export LANG=C
+set -e
+
+# Create a disk image.
+../fish/guestfish <<'EOF'
+sparse windows.img.tmp 512M
+run
+
+# Format the disk.
+part-init /dev/sda mbr
+part-add /dev/sda p 64     524287
+part-add /dev/sda p 524288    -64
+
+# Phony boot loader filesystem.
+mkfs ntfs /dev/sda1
+
+# Phony root filesystem.
+mkfs ntfs /dev/sda2
+
+# Enough to fool inspection API.
+mount-options "" /dev/sda2 /
+mkdir-p /Windows/System32/Config
+
+upload guest-aux/windows-software /Windows/System32/Config/SOFTWARE
+upload guest-aux/windows-system /Windows/System32/Config/SYSTEM
+
+upload bin-win32.exe /Windows/System32/cmd.exe
+
+mkdir "/Program Files"
+touch /autoexec.bat
+
+EOF
+
+mv windows.img.tmp windows.img
diff --git a/images/guest-aux/minimal-hive b/images/guest-aux/minimal-hive
new file mode 100755
index 0000000000000000000000000000000000000000..3f4ee58c0adc1c3a73da8fed459304fd1083fce7
GIT binary patch
literal 8192
zcmeI0y-EX75QWc17h&;d5sL^GD+X-D+AjD@1Ti8}5K<}rgvB7y2iVdFu(1eO_#Rq{
zm5<;9_yiWNbM6|<MgtZWDb6f+XXfnOxx?4(Z5^MUzyr8muV30@_s<?v-xiH=#30P#
zI?DFcv4?G}n!iE|4ICkM@i{KcuVEb<Shkui)VNnRkOUqMmfi<)FbyRFA|L`HAOa#F
z0wN#+A|L`H@b3i94jWC^)c)@~*0~2@ewU_cGhRS6zjDjF0cwvUd}n5#oiSsOe0k=*
zHflntRNC3C)~bt@&3%4<`bg8u7)UJU;sG=E@-TeEBy=YNQ>GX2hQK^f#I$8z!6klV
zZkBOSq>%j3f2p7AQ}1-EFJmItKl-i@yZbxcrgQb#to|gY2sp8g->voSo2wn-#@;jX
geSpe1t7IY|0wN#+A|L`HAOa#F0wN#+BJei?pOc0_k^lez

literal 0
HcmV?d00001

diff --git a/images/guest-aux/windows-software b/images/guest-aux/windows-software
new file mode 100755
index 0000000000000000000000000000000000000000..1091c13e24f4548c6b87286907c1b1ac25b03fa3
GI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ku5UQ`8xMHb!uVw=gIfW(V1Y+unF}_NeLi~f;y}`j+(esNT|#~z1CvCy
zVsTcM=I7is??S<A1hl<}I2HH|@CDJ^GKoJ2u?n&-jVSsWVoV^e58b48AH6>#!n?)Y
znEz-UiTCg{#!sQ1fvuj`Vcr*_ji<sO8nBSR=J`-1?6?Q?+SzVs_ptfo_-)|d#1l(S
z<TD2yi_Yg1WZr1<{m}WG#n>OBytW~qdrssgY8#bB?<eF&2mM?dYrnisA%FiQud9fy
z<NOzSZN>ce%j+8t)<1}^(6Ij4xM{Ce!@gXHS{1(U^J-6A2futEP*OZALbky{y<=M7
za{+b@#rKWa&Kg9#BzpVV|5y0X#@^Dztm1q)h4wpYrh9xKZ+BqiR1WRq!~5{@W5kPH
z$XO6)3$?AT#FM-jg-++IA1}^eWq*$s;rn=ff1K3!@lC8N<n55W0QqigT((hg?0TiF
zUdCwsOF+Jaxy>Rs+=b?_9~IROqx~FL*mYul=EB{0-Yez<{$t(-j?>s_a`<n_|ETNu
s%}Wj5E@91%%56@Pk@&S^xDzrHVQD?4CG#{07z7Lg1_6V>{|A9T0hJ(}X#fBK

literal 0
HcmV?d00001

diff --git a/images/guest-aux/windows-software.reg b/images/guest-aux/windows-software.reg
new file mode 100644
index 0000000..984cbe4
--- /dev/null
+++ b/images/guest-aux/windows-software.reg
@@ -0,0 +1,32 @@
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
+"ProductName"=str(1):"Microsoft Windows 7 Phony Edition"
+"CurrentVersion"=str(1):"6.1"
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\test1]
+"DisplayName"=str(1):"Test1 is not real software"
+"URLInfoAbout"=str(1):"http://libguestfs.org/"
+"DisplayVersion"=str(1):"1.2.3"
+"VersionMajor"=dword:00000001
+"VersionMinor"=dword:00000002
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\test2]
+"DisplayName"=str(1):"Test2 is not real software"
+"URLInfoAbout"=str(1):"http://libguestfs.org/"
+"DisplayVersion"=str(1):"1.2.4"
+"Comments"=str(1):"Longer description about phony test2 software"
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\test3]
+"DisplayName"=str(1):"Test3 is not real software"
+"DisplayVersion"=str(1):"1.2.5"
+"Publisher"=str(1):"Red Hat Inc."
+"InstallLocation"=str(1):"C:\\Program Files\\Red Hat\\test3"
diff --git a/images/guest-aux/windows-system b/images/guest-aux/windows-system
new file mode 100755
index 0000000000000000000000000000000000000000..7d935b02d07e975ae956c05384b593f439ee0481
GIT binary patch
literal 12288
zcmeI2zl#$=6vyA524nCvip41ws|IZ3h@D_@=&3{y@9?5nToZGvSvI!`n<WP}rnJ*S
zPzyoCLL2`DEf1?Jue@3;u2U>rzi+a`?VcO3usGp6Ve;O*c|T@8spgT$d-%X{M09RF
z*?2wu?u)8Y!qlO<s|vnUUzRz1mgSDzl6lBjBJrgyfzel`4|!Ft$#uC5pPSOuSdKkO
z;FEvx=bk(m4@CkbKmsH{0wh2JBtQZrKmsK2&k1zy`=Lo%-AQfx0BU)YBuN;Y7x&zi
zSK1p;+vfx0UV!Q&#K9#|UF9g1C)KcP9KyO*t1aGMXfDh)Zrs)F^<POc2#^Q5PVGCK
zLKR2$Ki7ss)l?KY4*QgRlM1BBjGVyAnKFx#3vpWY%8VLDf7lEB&ra|+cKFZ9kz9Uv
z$G@7*Z|pdo@gJYHbWBfC(G%nNS=+?CIp2L6xVuI^k4WRNdU22d36KB@kN^pg011!)
z36KB@kig#&Fz<hT`)A(&*~szx-_5=MT{xuAa@n5n{x3>5jkx(<7)QPCk{8$O7qH$&
z&!F3J#6`f{50{=6*2A8yckgI%zhT@LK*G!@LtpZuq2Klf)@<uNL(cm5M`zxnei-EM
zr+c>E`h<Gs#cq?PQhOK8cHi$q+B$;xmmgmoEV`HO*`d7?9a?u2_7SA6?LLkqZo1IB
zF1Di9suz1vdNW(EqxHT%4u2qa3;HJHFesbYG8z+_UuUB?h(lyZQyRZD{F5V;73s;E
p3}n`<hSHKQw3XCxLw`gL5+DH*AOR8}0TLhq5+DH*Ac6mmz;Bc9)c61Z

literal 0
HcmV?d00001

diff --git a/images/guest-aux/windows-system.reg b/images/guest-aux/windows-system.reg
new file mode 100644
index 0000000..87ae779
--- /dev/null
+++ b/images/guest-aux/windows-system.reg
@@ -0,0 +1,8 @@
+[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001]
+
+[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services]
+
+[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip]
+
+[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters]
+"Hostname"=str(1):"windows.invalid"
-- 
1.8.3.1