Skip to content

Commit dc522d1

Browse files
committed
flash-gui.sh: add .npf handling; add create-npf.sh
1 parent 1d14855 commit dc522d1

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

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
@@ -27,14 +27,35 @@ while true; do
2727
--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
2828
mount_usb
2929
if grep -q /media /proc/mounts ; then
30-
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' \) | sort > /tmp/filelist.txt
30+
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' -o -type f -name '*.npf' \) | sort > /tmp/filelist.txt
3131
file_selector "/tmp/filelist.txt" "Choose the ROM to flash"
3232
if [ "$FILE" == "" ]; then
3333
return
3434
else
3535
ROM=$FILE
3636
fi
3737

38+
# is a .npf provided?
39+
if [ -z "${ROM##*.npf}" ]; then
40+
# unzip to /tmp/verified_rom
41+
mkdir /tmp/verified_rom
42+
unzip $ROM -d /tmp/verified_rom
43+
# check file integrity
44+
if (cd /tmp/verified_rom/ && sha256sum -cs /tmp/verified_rom/sha256sum.txt) ; then
45+
ROM="$(head -n1 /tmp/verified_rom/sha256sum.txt | cut -d ' ' -f 3)"
46+
else
47+
whiptail --title 'ROM Integrity Check Failed! ' \
48+
--msgbox "$ROM integrity check failed. Did not flash.\n\nPlease check your file (e.g. re-download).\n" 16 60
49+
exit
50+
fi
51+
else
52+
# exit if we shall not proceed
53+
if ! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
54+
--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
55+
exit
56+
fi
57+
fi
58+
3859
if (whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
3960
--yesno "This will replace your current ROM with:\n\n${ROM#"/media/"}\n\nDo you want to proceed?" 0 80) then
4061
if [ "$menu_choice" == "c" ]; then

0 commit comments

Comments
 (0)