Replace signrom with shell script v2
PATCH 1/1 Replace signrom with shell script v2
In order to not execute code we just compiled, let's replace signrom with a shell script that does the same thing while staying compatible to pretty much every system available.
This should make cross-compilation for windows easier.
Signed-off-by Alexander Graf <[email protected]>
---
v2 changes:
- make the script work with ash
- calculate file size from header
--- pc-bios/optionrom/Makefile | 9 ++--- pc-bios/optionrom/signrom.c | 79 ------------------------------------------ pc-bios/optionrom/signrom.sh | 26 ++++++++++++++ 3 files changed, 29 insertions(+), 85 deletions(-) delete mode 100644 pc-bios/optionrom/signrom.c create mode 100755 pc-bios/optionrom/signrom.sh
pc-bios/optionrom/Makefile +3 -6
@@ -37,12 +37,9 @@ build-all: multiboot.bin %.img: %.o $(LD) --oformat binary -Ttext 0 -o $@ $< -%.bin: %.img signrom - ./signrom $< $@ +%.bin: %.img + ./signrom.sh $< $@ cp $@ $(SRC_PATH)/pc-bios/ -signrom: signrom.c - $(CC) -o $@ -g -Wall $^ - clean: - $(RM) *.o *.img *.bin signrom *~ + $(RM) *.o *.img *.bin *~
pc-bios/optionrom/signrom.c deleted +0 -79
79 lines not on this page · raw message
pc-bios/optionrom/signrom.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/sh + +# syntax: signrom.sh <input> <output> + +# did we get proper arguments? +test "$1" -a "$2" || exit 1 + +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` +#size=`expr $x \* 512 - 1` +size=$(( $x * 512 - 1 )) + +# now get the checksum +for i in `od -A n -t u1 -v "$1"`; do + # add each byte's value to sum + sum=$(( $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
Signature · 1 line
1.6.0.2