* [Qemu-devel] signrom.sh and MinGW
@ 2009-08-01 21:47 Sebastian Herbszt
2009-08-01 21:51 ` Filip Navara
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Herbszt @ 2009-08-01 21:47 UTC (permalink / raw)
To: Alexander Graf, qemu-devel
v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh multiboot.raw multiboot.bin
v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh: * 512 - 1 : syntax error: operand expected (error token is "*
512 - 1 ")
make[1]: *** [multiboot.bin] Error 1
rm multiboot.raw multiboot.img multiboot.o
make: *** [romsubdir-optionrom] Error 2
pc-bios/optionrom/signrom.sh has
# find out the file size
x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
#size=`expr $x \* 512 - 1`
size=$(( $x * 512 - 1 ))
but it seems (at least my) MinGW doesn't include "dd".
- Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] signrom.sh and MinGW
2009-08-01 21:47 [Qemu-devel] signrom.sh and MinGW Sebastian Herbszt
@ 2009-08-01 21:51 ` Filip Navara
2009-08-02 12:21 ` Sebastian Herbszt
0 siblings, 1 reply; 5+ messages in thread
From: Filip Navara @ 2009-08-01 21:51 UTC (permalink / raw)
To: Sebastian Herbszt; +Cc: Alexander Graf, qemu-devel
On Sat, Aug 1, 2009 at 11:47 PM, Sebastian Herbszt<herbszt@gmx.de> wrote:
> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh multiboot.raw
> multiboot.bin
> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh: * 512 - 1 : syntax
> error: operand expected (error token is "* 512 - 1 ")
> make[1]: *** [multiboot.bin] Error 1
> rm multiboot.raw multiboot.img multiboot.o
> make: *** [romsubdir-optionrom] Error 2
>
> pc-bios/optionrom/signrom.sh has
>
> # find out the file size
> x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
> #size=`expr $x \* 512 - 1`
> size=$(( $x * 512 - 1 ))
>
> but it seems (at least my) MinGW doesn't include "dd".
>
I have already reported that on the mailing list earlier.
Workaround/fix is to download MSYS coreutils from the MinGW download
page.
Best regards,
Filip Navara
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] signrom.sh and MinGW
2009-08-01 21:51 ` Filip Navara
@ 2009-08-02 12:21 ` Sebastian Herbszt
2009-08-02 12:29 ` Alexander Graf
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Herbszt @ 2009-08-02 12:21 UTC (permalink / raw)
To: Filip Navara; +Cc: Alexander Graf, qemu-devel
Filip Navara wrote:
> Sebastian Herbszt wrote:
>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh multiboot.raw
>> multiboot.bin
>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh: * 512 - 1 : syntax
>> error: operand expected (error token is "* 512 - 1 ")
>> make[1]: *** [multiboot.bin] Error 1
>> rm multiboot.raw multiboot.img multiboot.o
>> make: *** [romsubdir-optionrom] Error 2
>>
>> pc-bios/optionrom/signrom.sh has
>>
>> # find out the file size
>> x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
>> #size=`expr $x \* 512 - 1`
>> size=$(( $x * 512 - 1 ))
>>
>> but it seems (at least my) MinGW doesn't include "dd".
>>
>
> I have already reported that on the mailing list earlier.
> Workaround/fix is to download MSYS coreutils from the MinGW download
> page.
Thanks for the hint - got it working now.
On a closer look at the "od" tool, the use of "dd" seems redundant:
-j, --skip-bytes=BYTES
skip BYTES input bytes first
-N, --read-bytes=BYTES
limit dump to BYTES input bytes
"od -N 1 -j 2 -t u1 -A n multiboot.raw" seems to do the same job and "od" is pre-shipped on
MinGW/MSYS. But maybe "-j" and "-N" are not widely implemented. A possible alternative could
be the use of "head" and "cut".
In any case signrom.sh might check for the presence of tools used.
- Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] signrom.sh and MinGW
2009-08-02 12:21 ` Sebastian Herbszt
@ 2009-08-02 12:29 ` Alexander Graf
2009-08-02 19:56 ` Sebastian Herbszt
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2009-08-02 12:29 UTC (permalink / raw)
To: Sebastian Herbszt; +Cc: Filip Navara, qemu-devel
On 02.08.2009, at 14:21, Sebastian Herbszt wrote:
> Filip Navara wrote:
>> Sebastian Herbszt wrote:
>>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh multiboot.raw
>>> multiboot.bin
>>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh: * 512 - 1 :
>>> syntax
>>> error: operand expected (error token is "* 512 - 1 ")
>>> make[1]: *** [multiboot.bin] Error 1
>>> rm multiboot.raw multiboot.img multiboot.o
>>> make: *** [romsubdir-optionrom] Error 2
>>>
>>> pc-bios/optionrom/signrom.sh has
>>>
>>> # find out the file size
>>> x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
>>> #size=`expr $x \* 512 - 1`
>>> size=$(( $x * 512 - 1 ))
>>>
>>> but it seems (at least my) MinGW doesn't include "dd".
>>>
>> I have already reported that on the mailing list earlier.
>> Workaround/fix is to download MSYS coreutils from the MinGW download
>> page.
>
> Thanks for the hint - got it working now.
>
> On a closer look at the "od" tool, the use of "dd" seems redundant:
>
> -j, --skip-bytes=BYTES
> skip BYTES input bytes first
>
> -N, --read-bytes=BYTES
> limit dump to BYTES input bytes
>
> "od -N 1 -j 2 -t u1 -A n multiboot.raw" seems to do the same job and
> "od" is pre-shipped on
> MinGW/MSYS. But maybe "-j" and "-N" are not widely implemented. A
> possible alternative could
> be the use of "head" and "cut".
Right, but we need dd later on anyways and I find dd parameters easier
to read than the ones from od, probably because I simply use dd more
often :-).
> In any case signrom.sh might check for the presence of tools used.
Good idea. Please post a patch!
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] signrom.sh and MinGW
2009-08-02 12:29 ` Alexander Graf
@ 2009-08-02 19:56 ` Sebastian Herbszt
0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Herbszt @ 2009-08-02 19:56 UTC (permalink / raw)
To: Alexander Graf; +Cc: Filip Navara, qemu-devel
Alexander Graf wrote:
>
> On 02.08.2009, at 14:21, Sebastian Herbszt wrote:
>
>> Filip Navara wrote:
>>> Sebastian Herbszt wrote:
>>>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh multiboot.raw
>>>> multiboot.bin
>>>> v0.11.0-rc0-182-g28e738d/pc-bios/optionrom/signrom.sh: * 512 - 1 :
>>>> syntax
>>>> error: operand expected (error token is "* 512 - 1 ")
>>>> make[1]: *** [multiboot.bin] Error 1
>>>> rm multiboot.raw multiboot.img multiboot.o
>>>> make: *** [romsubdir-optionrom] Error 2
>>>>
>>>> pc-bios/optionrom/signrom.sh has
>>>>
>>>> # find out the file size
>>>> x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
>>>> #size=`expr $x \* 512 - 1`
>>>> size=$(( $x * 512 - 1 ))
>>>>
>>>> but it seems (at least my) MinGW doesn't include "dd".
>>>>
>>> I have already reported that on the mailing list earlier.
>>> Workaround/fix is to download MSYS coreutils from the MinGW download
>>> page.
>>
>> Thanks for the hint - got it working now.
>>
>> On a closer look at the "od" tool, the use of "dd" seems redundant:
>>
>> -j, --skip-bytes=BYTES
>> skip BYTES input bytes first
>>
>> -N, --read-bytes=BYTES
>> limit dump to BYTES input bytes
>>
>> "od -N 1 -j 2 -t u1 -A n multiboot.raw" seems to do the same job and
>> "od" is pre-shipped on
>> MinGW/MSYS. But maybe "-j" and "-N" are not widely implemented. A
>> possible alternative could
>> be the use of "head" and "cut".
>
> Right, but we need dd later on anyways and I find dd parameters easier
> to read than the ones from od, probably because I simply use dd more
> often :-).
signrom.sh currently uses dd, od, expr, cp and printf. All seem to come from coreutils.
coreutils also includes the "sum" utility, which seems to compute the checksum you
calculate in the for loop if the option "-s" is specified.
>> In any case signrom.sh might check for the presence of tools used.
>
> Good idea. Please post a patch!
Maybe something like the following in the hope that "which" is always available.
- Sebastian
diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
index 4322811..31c91f1 100755
--- a/pc-bios/optionrom/signrom.sh
+++ b/pc-bios/optionrom/signrom.sh
@@ -23,23 +23,53 @@
# did we get proper arguments?
test "$1" -a "$2" || exit 1
+DD=`which dd 2>/dev/null`
+if test $? -ne 0 ; then
+ echo dd not found.
+ exit 1
+fi
+
+OD=`which od 2>/dev/null`
+if test $? -ne 0 ; then
+ echo od not found.
+ exit 1
+fi
+
+EXPR=`which expr 2>/dev/null`
+if test $? -ne 0 ; then
+ echo expr not found.
+ exit 1
+fi
+
+CP=`which cp 2>/dev/null`
+if test $? -ne 0 ; then
+ echo cp not found.
+ exit 1
+fi
+
+PRINTF=`which printf 2>/dev/null`
+if test $? -ne 0 ; then
+ echo printf not found.
+ exit 1
+fi
+
sum=0
# find out the file size
-x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
+x=`${DD} if="$1" bs=1 count=1 skip=2 2>/dev/null | ${OD} -t u1 -A n`
#size=`expr $x \* 512 - 1`
size=$(( $x * 512 - 1 ))
# now get the checksum
-nums=`od -A n -t u1 -v "$1"`
+nums=`${OD} -A n -t u1 -v "$1"`
for i in ${nums}; do
# add each byte's value to sum
- sum=`expr $sum + $i`
+ sum=`${EXPR} $sum + $i`
done
sum=$(( $sum % 256 ))
sum=$(( 256 - $sum ))
# and write the output file
-cp "$1" "$2"
-printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null
+${CP} "$1" "$2"
+${PRINTF} "\\$sum" | ${DD} of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-02 19:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-01 21:47 [Qemu-devel] signrom.sh and MinGW Sebastian Herbszt
2009-08-01 21:51 ` Filip Navara
2009-08-02 12:21 ` Sebastian Herbszt
2009-08-02 12:29 ` Alexander Graf
2009-08-02 19:56 ` Sebastian Herbszt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.