From 4dbbed915c5e6a93ee9c030e03ee88398acc0d07 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 16 Nov 2010 17:37:30 +0000 Subject: [PATCH] images: Make phony Windows image for testing. (cherry picked from commit fcc631dedb894379cde01af563df3f6a364db7cb) --- .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 bb1a64b..f59e012 100644 --- a/.gitignore +++ b/.gitignore @@ -124,6 +124,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|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 GIT binary patch literal 12288 zcmeHNJ!~9B6n^I2%IWByYkdzu%@^Hn*R8%T)~oN{;@tpst;fT=0Lo2_gGrY%pUvp`6cs(?7~13G zcr1!@z|#e*T%y2ZXk9OPquYGl2K<{oBhQvE77xAC=`Nv_GgGRX*-O$91x1eXrCg28;Px znP##Ly9M>7g)g4eQP=S8g(X*^bESm#CbX8kg_@NL+OFJyd=Y&%EN!LH@kV42KF5%| z44$lM^FAvRavFUscM#vLT1g(n^3pkg2Wff1^^wkt?82{88Iad7{*zxmoa~nu+HkHc zm8bXe02h7lo%-eFCVVn4X*^(`x{N`*yU(Y`Bgc9RdA{P>Zav65PSmM+Fo=0y`}EXM z8lLRag==ErcQ`xHH}Pa!_Y>E%QG+%?xgIcAn%~zk=KJ?<4H4fC zQRTyePV->Ku5UQ`8xMHb!uVw=gIfW(V1Y+unF}_NeLi~f;y}`j+(esNT|#~z1CvCy zVsTcM=I7is??S#!n?)Y znEz-UiTCg{#!sQ1fvuj`Vcr*_jiOBytW~qdrssgY8#bB?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!@lC8NRs+=b?_9~IROqx~FL*mYul=EB{0-Yez<{$t(-j?>s_a`{|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!`nrzi+a`?VcO3usGp6Ve;O*c|T@8spgT$d-%X{M09RF z*?2wu?u)8Y!qlO5jkx(<7)QPCk{8$O7qH$& z&!F3J#6`f{50{=6*2A8yckgI%zhT@LK*G!@LtpZuq2Klf)@E`h