summaryrefslogtreecommitdiffstats
path: root/qemu/scripts/extract-vsssdk-headers
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/scripts/extract-vsssdk-headers
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff)
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/scripts/extract-vsssdk-headers')
-rwxr-xr-xqemu/scripts/extract-vsssdk-headers35
1 files changed, 35 insertions, 0 deletions
diff --git a/qemu/scripts/extract-vsssdk-headers b/qemu/scripts/extract-vsssdk-headers
new file mode 100755
index 000000000..9e38510f0
--- /dev/null
+++ b/qemu/scripts/extract-vsssdk-headers
@@ -0,0 +1,35 @@
+#! /bin/bash
+
+# extract-vsssdk-headers
+# Author: Paolo Bonzini <pbonzini@redhat.com>
+
+set -e
+if test $# != 1 || ! test -f "$1"; then
+ echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2
+ exit 1
+fi
+
+if ! command -v msiextract > /dev/null; then
+ echo 'msiextract not found. Please install msitools.' >&2
+ exit 1
+fi
+
+if test -e inc; then
+ echo '"inc" already exists.' >&2
+ exit 1
+fi
+
+# Extract .MSI file in the .exe, looking for the OLE compound
+# document signature. Extra data at the end does not matter.
+export LC_ALL=C
+MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'
+offset=$(grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P')
+tmpdir=$(mktemp -d)
+trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM
+tail -c +$(($offset+1)) -- "$1" > vsssdk.msi
+
+# Now extract the files.
+msiextract -C $tmpdir vsssdk.msi
+mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc
+echo 'Extracted SDK headers into "inc" directory.'
+exit 0