qemu/scripts/extract-vsssdk-headers
<<
>>
Prefs
   1#! /bin/bash
   2
   3# extract-vsssdk-headers
   4# Author: Paolo Bonzini <pbonzini@redhat.com>
   5
   6set -e
   7if test $# != 1 || ! test -f "$1"; then
   8  echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2
   9  exit 1
  10fi
  11
  12if ! command -v msiextract > /dev/null; then
  13  echo 'msiextract not found. Please install msitools.' >&2
  14  exit 1
  15fi
  16
  17if test -e inc; then
  18  echo '"inc" already exists.' >&2
  19  exit 1
  20fi
  21
  22# Extract .MSI file in the .exe, looking for the OLE compound
  23# document signature.  Extra data at the end does not matter.
  24export LC_ALL=C
  25MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'
  26offset=$(grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P')
  27tmpdir=$(mktemp -d)
  28trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM
  29tail -c +$(($offset+1)) -- "$1" > vsssdk.msi
  30
  31# Now extract the files.
  32msiextract -C $tmpdir vsssdk.msi
  33mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc
  34echo 'Extracted SDK headers into "inc" directory.'
  35exit 0
  36