From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfsAw-0003Mn-N6 for qemu-devel@nongnu.org; Fri, 24 May 2013 09:37:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfsAl-0001b6-Lm for qemu-devel@nongnu.org; Fri, 24 May 2013 09:36:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfsAl-0001av-Ce for qemu-devel@nongnu.org; Fri, 24 May 2013 09:36:43 -0400 Message-ID: <519F6D5E.8010707@redhat.com> Date: Fri, 24 May 2013 15:38:38 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <20130521153333.4880.74390.stgit@hds.com> <20130521153345.4880.68009.stgit@hds.com> In-Reply-To: <20130521153345.4880.68009.stgit@hds.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tomoki Sekiyama Cc: mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, vrozenfe@redhat.com, pbonzini@redhat.com, seiji.aguchi@hds.com, areis@redhat.com On 05/21/13 17:33, Tomoki Sekiyama wrote: > 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 > Signed-off-by: Tomoki Sekiyama > --- > scripts/extract-vsssdk-headers | 25 +++++++++++++++++++++++++ > 1 file changed, 25 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..5877137 > --- /dev/null > +++ b/scripts/extract-vsssdk-headers > @@ -0,0 +1,25 @@ > +#! /bin/bash > + > +# extract-vsssdk-headers > +# Author: Paolo Bonzini > + > +set -e > +if test $# = 0 || ! test -f "$1"; then > + echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' > + exit 1 > +fi Error message to >&2 ? (Would not be worth a repost but you're already doing one...) > + > +# 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' Can't help mentioning the following portable (alas, octal) equivalent :) MAGIC=$(printf '%b' '\0320\0317\0021\0340\0241\0261\0032\0341') > +offset=`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' ` Of these grep options, none are portable, hence I'm supposing dependency on GNU grep. In that case, see (*). > +(dd of=/dev/null skip=$offset bs=1 count=0; cat) < "$1" > vsssdk.msi In place of dd for seeking + cat, suggest tail -c +$((offset+1)) -- "$1" > + > +# Now extract the files. > +tmpdir=tmp$$ > +mkdir $tmpdir > +msiextract -C $tmpdir vsssdk.msi > +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc > +rm -rf $tmpdir vsssdk.msi > +exit 0 (*) Since we rely on GNU utilities anyway, I propose the mktemp utility ("Written by Jim Meyering and Eric Blake", heh) from GNU coreutils: tmpdir=$(mktemp -d) Feel free to ignore any of the above, of course :) Thanks, Laszlo