Skip to content

Commit baa48e0

Browse files
daringertlaurion
authored andcommitted
flash-gui.sh: add .npf handling; add create-npf.sh
1 parent 37833f6 commit baa48e0

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

create-npf.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -exuo pipefail
3+
HEADS_GIT_VERSION=$(git describe --tags)
4+
BOARD=$1
5+
cd ./build/x86/${BOARD}/
6+
sha256sum heads-${BOARD}-${HEADS_GIT_VERSION}.rom > sha256sum.txt
7+
sed -ie 's@ @ /tmp/verified_rom/@g' sha256sum.txt
8+
zip heads-${BOARD}-${HEADS_GIT_VERSION}.npf heads-${BOARD}-${HEADS_GIT_VERSION}.rom sha256sum.txt

initrd/bin/flash-gui.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,35 @@ while true; do
3333
--yesno "You will need to insert a USB drive containing your BIOS image (*.rom or *.tgz).\n\nAfter you select this file, this program will reflash your BIOS.\n\nDo you want to proceed?" 0 80) then
3434
mount_usb
3535
if grep -q /media /proc/mounts ; then
36-
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' \) | sort > /tmp/filelist.txt
36+
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' -o -type f -name '*.npf' \) | sort > /tmp/filelist.txt
3737
file_selector "/tmp/filelist.txt" "Choose the ROM to flash"
3838
if [ "$FILE" == "" ]; then
3939
return
4040
else
4141
ROM=$FILE
4242
fi
4343

44+
# is a .npf provided?
45+
if [ -z "${ROM##*.npf}" ]; then
46+
# unzip to /tmp/verified_rom
47+
mkdir /tmp/verified_rom
48+
unzip $ROM -d /tmp/verified_rom
49+
# check file integrity
50+
if (cd /tmp/verified_rom/ && sha256sum -cs /tmp/verified_rom/sha256sum.txt) ; then
51+
ROM="$(head -n1 /tmp/verified_rom/sha256sum.txt | cut -d ' ' -f 3)"
52+
else
53+
whiptail --title 'ROM Integrity Check Failed! ' \
54+
--msgbox "$ROM integrity check failed. Did not flash.\n\nPlease check your file (e.g. re-download).\n" 16 60
55+
exit
56+
fi
57+
else
58+
# exit if we shall not proceed
59+
if ! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
60+
--yesno "You have provided a *.rom file. The integrity of the file can not be\nchecked for this file.\nIf you do not know how to check the file integrity yourself,\nyou should use a *.npf file instead.\n\nIf the file is damaged, you will not be able to boot anymore.\nDo you want to proceed flashing without file integrity check?" 16 60) then
61+
exit
62+
fi
63+
fi
64+
4465
if (whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
4566
--yesno "This will replace your current ROM with:\n\n${ROM#"/media/"}\n\nDo you want to proceed?" 0 80) then
4667
if [ "$menu_choice" == "c" ]; then

0 commit comments

Comments
 (0)