File: extract-vsssdk-headers

package info (click to toggle)
qemu 1%3A2.1%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,688 kB
  • sloc: ansic: 806,370; sh: 12,093; asm: 10,812; python: 8,293; cpp: 6,289; perl: 4,521; makefile: 2,326; objc: 914; xml: 526
file content (35 lines) | stat: -rwxr-xr-x 937 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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