diff mbox

[v7,04/10] Add a script to extract VSS SDK headers on POSIX system

Message ID 20130715162041.16676.20397.stgit@outback
State New
Headers show

Commit Message

Tomoki Sekiyama July 15, 2013, 4:20 p.m. UTC
VSS SDK(*) setup.exe is only runnable on Windows. This adds a script
to extract VSS SDK headers on POSIX-systems using msitools.

  * http://www.microsoft.com/en-us/download/details.aspx?id=23490

From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 scripts/extract-vsssdk-headers |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 scripts/extract-vsssdk-headers

Comments

Michael Roth July 22, 2013, 9:27 p.m. UTC | #1
Quoting Tomoki Sekiyama (2013-07-15 11:20:41)
> VSS SDK(*) setup.exe is only runnable on Windows. This adds a script
> to extract VSS SDK headers on POSIX-systems using msitools.
> 
>   * http://www.microsoft.com/en-us/download/details.aspx?id=23490
> 
> From: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
>  scripts/extract-vsssdk-headers |   35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>  create mode 100755 scripts/extract-vsssdk-headers
> 
> diff --git a/scripts/extract-vsssdk-headers b/scripts/extract-vsssdk-headers
> new file mode 100755
> index 0000000..9e38510
> --- /dev/null
> +++ b/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
diff mbox

Patch

diff --git a/scripts/extract-vsssdk-headers b/scripts/extract-vsssdk-headers
new file mode 100755
index 0000000..9e38510
--- /dev/null
+++ b/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