From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UethV-00068b-EZ for qemu-devel@nongnu.org; Tue, 21 May 2013 17:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UethP-0005BD-Vk for qemu-devel@nongnu.org; Tue, 21 May 2013 17:02:29 -0400 Received: from usindpps04.hds.com ([207.126.252.17]:39926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UethP-0005As-OL for qemu-devel@nongnu.org; Tue, 21 May 2013 17:02:23 -0400 From: Tomoki Sekiyama Date: Tue, 21 May 2013 21:02:18 +0000 Message-ID: In-Reply-To: <519BA540.2020205@redhat.com> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <1626DB792CCB044B818A74D1C57D8029@hds.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Eric Blake Cc: "mdroth@linux.vnet.ibm.com" , "qemu-devel@nongnu.org" , "lcapitulino@redhat.com" , "vrozenfe@redhat.com" , "pbonzini@redhat.com" , Seiji Aguchi , "areis@redhat.com" On 5/21/13 12:48 , "Eric Blake" wrote: >On 05/21/2013 09:33 AM, 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. >>=20 >> * http://www.microsoft.com/en-us/download/details.aspx?id=3D23490 >>=20 >> 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 >>=20 > >> +#! /bin/bash > >Since you are using bash... > >> + >> +# extract-vsssdk-headers >> +# Author: Paolo Bonzini >> + >> +set -e >> +if test $# =3D 0 || ! test -f "$1"; then > >Why reject 0 arguments but not 2? Shouldn't the first check be test $# >!=3D 1? I agree, will fix this. >> + echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >> + 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=3DC >> +MAGIC=3D$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1' >> +offset=3D`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' ` > >...I'd prefer $() over ``. OK. >> +(dd of=3D/dev/null skip=3D$offset bs=3D1 count=3D0; cat) < "$1" > vsssd= k.msi >> + >> +# Now extract the files. >> +tmpdir=3Dtmp$$ >> +mkdir $tmpdir > >...also, this name is rather predictable; adding a $RANDOM might help >improve its quality. I will add $RANDOM here. >> +msiextract -C $tmpdir vsssdk.msi >> +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc >> +rm -rf $tmpdir vsssdk.msi > >What, no trap, to guarantee clean up of the temp directory even if you >Ctrl-C the script in the middle of a potentially long-running msiextract? OK, I will add some trap here. Maybe it also should have an additional check and a message to install Msitools for the case msiextract isn't exectable. Thanks, --=20 Tomoki Sekiyama