| # Author: Paolo Bonzini <pbonzini@redhat.com> |
| if test $# != 1 || ! test -f "$1"; then |
| echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2 |
| if ! command -v msiextract > /dev/null; then |
| echo 'msiextract not found. Please install msitools.' >&2 |
| echo '"inc" already exists.' >&2 |
| # Extract .MSI file in the .exe, looking for the OLE compound |
| # document signature. Extra data at the end does not matter. |
| MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1' |
| offset=$(grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P') |
| trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM |
| tail -c +$(($offset+1)) -- "$1" > vsssdk.msi |
| msiextract -C $tmpdir vsssdk.msi |
| mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc |
| echo 'Extracted SDK headers into "inc" directory.' |