Message ID | 20130606150638.10486.36820.stgit@hds.com |
---|---|
State | New |
Headers | show |
On 06/06/13 17:06, Tomoki Sekiyama wrote: > +tmpdir=$(mktemp -d) > +trap "rm -fr $tmpdir vsssdk.msi; exit 1" HUP INT QUIT ALRM TERM "mktemp" keys off TMPDIR, so I would prefer something like (note the single quotes -- $tmpdir is expanded at trap execution time): trap 'rm -fr -- "$tmpdir"' but whoever starts TMPDIR with a dash, or puts whitespace in it, deserves what's coming to him. Also sigpsec in "trap" could have been EXIT -- then you could have omitted the final cleanup on the success path. The "exit 1" is not necessary; AFAIR the trap handler doesn't change the exit status that the shell has decided for otherwise (IOW exit status of the trap handler should be suppressed anyway). Placing an "exit 1" in the trap handler could even be detrimental somewhat, since it might mess with WIFSIGNALED() / WTERMSIG() that would otherwise tell a parent shell to interrupt the parent script. http://www.cons.org/cracauer/sigint.html I've said nothing substantial. I wish I could go into such detail when reviewing the real meat of the series... Reviewed-by: Laszlo Ersek <lersek@redhat.com>
On 06/06/13 17:06, Tomoki Sekiyama wrote: > +if ! command -v msiextract > /dev/null; then > + echo 'msiextract not found. Please install msitools.' >&2 > + exit 1 > +fi (This is not a review comment -- I'm trying to test it:) What msiextract version (and dependencies, like libgcab, libgsf etc) are you using? I'm unable to extract "vsssdk.msi"; msiextract spews a bunch of assertion failures. 2e39646b7850a12673bc66ade85fece3 setup.exe 433eb024ed0c669dd1563d952ca41091 vsssdk.msi My versions (RHEL-6.4.z distro): - msitools-0.92 (built from source) - gcab-0.4 (built from source) - libgsf-1.14.15-5.el6 (patch in [1] doesn't seem to help, it only changes the kinds of asserts that fail) - glib2-2.22.5-7.el6 - libuuid-2.17.2-12.9.el6_4.3 [1] http://bugzilla.gnome.org/show_bug.cgi?id=689706 Thanks! Laszlo
diff --git a/scripts/extract-vsssdk-headers b/scripts/extract-vsssdk-headers new file mode 100755 index 0000000..95c0b38 --- /dev/null +++ b/scripts/extract-vsssdk-headers @@ -0,0 +1,36 @@ +#! /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 1" 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 +rm -rf $tmpdir vsssdk.msi +echo 'Extracted SDK headers into "inc" directory.' +exit 0