Skip to content

Commit fb9c558

Browse files
Merge branch 'newt_colors' of github.com:mdrobnak/heads
PR 1698
2 parents e471a4a + 2f8c1a5 commit fb9c558

17 files changed

Lines changed: 196 additions & 108 deletions

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,12 @@ endif
175175
# Create a temporary directory for the initrd
176176
initrd_dir := $(BOARD)
177177
initrd_tmp_dir := $(shell mktemp -d)
178+
initrd_data_dir := $(initrd_tmp_dir)/etc/terminfo/l
178179
initrd_lib_dir := $(initrd_tmp_dir)/lib
179180
initrd_bin_dir := $(initrd_tmp_dir)/bin
180181
modules-y += initrd
181182

182-
$(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)")
183+
$(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)" "$(initrd_data_dir)")
183184

184185
# We are running our own version of make,
185186
# proceed with the build.
@@ -291,13 +292,17 @@ include modules/*
291292
define bins =
292293
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output)))
293294
endef
295+
define data =
296+
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_data)))
297+
endef
294298
define libs =
295299
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_libraries)))
296300
endef
297301

298302
define outputs =
299303
$(foreach m,$1,\
300304
$(call bins,$m)\
305+
$(call data,$m)\
301306
$(call libs,$m)\
302307
)
303308
endef
@@ -577,6 +582,11 @@ $(initrd_bin_dir)/$(notdir $1): $1
577582
initrd_bins += $(initrd_bin_dir)/$(notdir $1)
578583
endef
579584

585+
define initrd_data_add =
586+
$(initrd_data_dir)/$(notdir $1): $1
587+
$(call do,INSTALL-DATA,$$(<:$(pwd)/%=%),cp -a --remove-destination "$$<" "$$@")
588+
initrd_data += $(initrd_data_dir)/$(notdir $1)
589+
endef
580590

581591
define initrd_lib_add =
582592
$(initrd_lib_dir)/$(notdir $1): $1
@@ -622,6 +632,10 @@ $(foreach m, $(bin_modules-y), \
622632
$(call map,initrd_bin_add,$(call bins,$m)) \
623633
)
624634

635+
# Install the data for every module that we have built
636+
$(foreach m, $(modules-y), \
637+
$(call map,initrd_data_add,$(call data,$m)) \
638+
)
625639
# Install the libraries for every module that we have built
626640
$(foreach m, $(modules-y), \
627641
$(call map,initrd_lib_add,$(call libs,$m)) \
@@ -727,9 +741,11 @@ $(build)/$(initrd_dir)/heads.cpio: FORCE
727741
#
728742
$(build)/$(initrd_dir)/tools.cpio: \
729743
$(initrd_bins) \
744+
$(initrd_data) \
730745
$(initrd_libs) \
731746
$(initrd_tmp_dir)/etc/config \
732747

748+
$(info Used **BINS**: $(initrd_bins))
733749
$(call do-cpio,$@,$(initrd_tmp_dir))
734750
@$(RM) -rf "$(initrd_tmp_dir)"
735751

initrd/bin/config-gui.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ param=$1
1515
read_rom() {
1616
/bin/flash.sh -r "$1"
1717
if [ ! -s "$1" ]; then
18-
whiptail $BG_COLOR_ERROR --title 'ERROR: BIOS Read Failed!' \
18+
whiptail_error --title 'ERROR: BIOS Read Failed!' \
1919
--msgbox "Unable to read BIOS" 0 80
2020
exit 1
2121
fi
@@ -95,7 +95,7 @@ while true; do
9595
)
9696

9797
unset menu_choice
98-
whiptail $BG_COLOR_MAIN_MENU --title "Config Management Menu" \
98+
whiptail_type $BG_COLOR_MAIN_MENU --title "Config Management Menu" \
9999
--menu "This menu lets you change settings for the current BIOS session.\n\nAll changes will revert after a reboot,\n\nunless you also save them to the running BIOS." 0 80 10 \
100100
"${dynamic_config_options[@]}" \
101101
2>/tmp/whiptail || recovery "GUI menu failed"
@@ -116,7 +116,7 @@ while true; do
116116
"b" )
117117
CURRENT_OPTION="$(load_config_value CONFIG_BOOT_DEV)"
118118
if ! fdisk -l | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" > /tmp/disklist.txt ; then
119-
whiptail $BG_COLOR_ERROR --title 'ERROR: No bootable devices found' \
119+
whiptail_error --title 'ERROR: No bootable devices found' \
120120
--msgbox " $ERROR\n\n" 0 80
121121
exit 1
122122
fi
@@ -147,7 +147,7 @@ while true; do
147147
# mount newly selected /boot device
148148
if ! mount -o ro $SELECTED_FILE /boot 2>/tmp/error ; then
149149
ERROR=`cat /tmp/error`
150-
whiptail $BG_COLOR_ERROR --title 'ERROR: unable to mount /boot' \
150+
whiptail_error --title 'ERROR: unable to mount /boot' \
151151
--msgbox " $ERROR\n\n" 0 80
152152
exit 1
153153
fi
@@ -175,7 +175,7 @@ while true; do
175175
;;
176176
"r" )
177177
# prompt for confirmation
178-
if (whiptail $BG_COLOR_WARNING --title 'Reset Configuration?' \
178+
if (whiptail_warning --title 'Reset Configuration?' \
179179
--yesno "This will clear all GPG keys, clear boot signatures and checksums,
180180
\nreset the /boot device, clear/reset the TPM (if present),
181181
\nand reflash your BIOS with the cleaned configuration.
@@ -268,7 +268,7 @@ while true; do
268268
if [ "$CONFIG_ROOT_CHECK_AT_BOOT" != "y" ]; then
269269
# Root device and directories must be set to enable this
270270
if [ -z "$CONFIG_ROOT_DEV" ] || [ -z "$CONFIG_ROOT_DIRLIST" ]; then
271-
whiptail $BG_COLOR_ERROR --title 'Root Check Not Configured' \
271+
whiptail_error --title 'Root Check Not Configured' \
272272
--msgbox "Set the root device and directories to hash before enabling this feature." 0 80
273273
elif (whiptail --title 'Enable Root Hash Check at Boot?' \
274274
--yesno "This will enable checking root hashes each time you boot.
@@ -305,7 +305,7 @@ while true; do
305305
;;
306306
"P" )
307307
if [ "$CONFIG_RESTRICTED_BOOT" = "y" ]; then
308-
whiptail $BG_COLOR_ERROR --title 'Restricted Boot Active' \
308+
whiptail_error --title 'Restricted Boot Active' \
309309
--msgbox "Disable Restricted Boot to enable Basic Mode." 0 80
310310
elif [ "$CONFIG_BASIC" != "y" ]; then
311311
if (whiptail --title "Enable $CONFIG_BRAND_NAME Basic Mode?" \
@@ -365,7 +365,7 @@ while true; do
365365
# disabled.
366366
if ! wipe-totp >/dev/null 2>/tmp/error; then
367367
ERROR=$(tail -n 1 /tmp/error | fold -s)
368-
whiptail $BG_COLOR_ERROR --title 'ERROR: erasing TOTP secret' \
368+
whiptail_error --title 'ERROR: erasing TOTP secret' \
369369
--msgbox "Erasing TOTP Secret Failed\n\n${ERROR}" 0 80
370370
exit 1
371371
fi

initrd/bin/flash-gui.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e -o pipefail
88
TRACE_FUNC
99

1010
if [ "$CONFIG_RESTRICTED_BOOT" = y ]; then
11-
whiptail $BG_COLOR_ERROR --title 'Restricted Boot Active' \
11+
whiptail_error --title 'Restricted Boot Active' \
1212
--msgbox "Disable Restricted Boot to flash new firmware." 0 80
1313
exit 1
1414
fi
@@ -42,7 +42,7 @@ single_glob() {
4242

4343
while true; do
4444
unset menu_choice
45-
whiptail $BG_COLOR_MAIN_MENU --title "Firmware Management Menu" \
45+
whiptail_type $BG_COLOR_MAIN_MENU --title "Firmware Management Menu" \
4646
--menu "Select the firmware function to perform\n\nRetaining settings copies existing settings to the new firmware:\n* Keeps your GPG keyring\n* Keeps changes to the default /boot device\n\nErasing settings uses the new firmware as-is:\n* Erases any existing GPG keyring\n* Restores firmware to default factory settings\n* Clears out /boot signatures\n\nIf you are just updating your firmware, you probably want to retain\nyour settings." 0 80 10 \
4747
'f' ' Flash the firmware with a new ROM, retain settings' \
4848
'c' ' Flash the firmware with a new ROM, erase settings' \
@@ -56,7 +56,7 @@ while true; do
5656
exit 0
5757
;;
5858
f | c)
59-
if (whiptail $BG_COLOR_WARNING --title 'Flash the BIOS with a new ROM' \
59+
if (whiptail_warning --title 'Flash the BIOS with a new ROM' \
6060
--yesno "You will need to insert a USB drive containing your BIOS image (*.zip or\n*.$UPDATE_PLAIN_EXT).\n\nAfter you select this file, this program will reflash your BIOS.\n\nDo you want to proceed?" 0 80); then
6161
mount_usb
6262
if grep -q /media /proc/mounts; then
@@ -115,7 +115,7 @@ while true; do
115115
exit 1
116116
fi
117117

118-
if ! whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
118+
if ! whiptail_warning --title 'Flash ROM?' \
119119
--yesno "This will replace your current ROM with:\n\n$PKG_FILE_DISPLAY\n\nDo you want to proceed?" 0 80; then
120120
exit 1
121121
fi
@@ -136,7 +136,7 @@ while true; do
136136
fi
137137
ROM="$PKG_EXTRACT/$(basename "$PKG_FILE")"
138138
ROM_HASH=$(sha256sum "$ROM" | awk '{print $1}')
139-
if ! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
139+
if ! (whiptail_error --title 'Flash ROM without integrity check?' \
140140
--yesno "You have provided a *.$UPDATE_PLAIN_EXT file. The integrity of the file can not be\nchecked automatically for this file type.\n\nROM: $PKG_FILE_DISPLAY\nSHA256SUM: $ROM_HASH\n\nIf you do not know how to check the file integrity yourself,\nyou should use a *.zip 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?" 0 80); then
141141
exit 1
142142
fi

initrd/bin/gpg-gui.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ gpg_flash_rom() {
6565
if (whiptail --title 'BIOS Flashed Successfully' \
6666
--yesno "Would you like to update the checksums and sign all of the files in /boot?\n\nYou will need your GPG key to continue and this will modify your disk.\n\nOtherwise the system will reboot immediately." 0 80) then
6767
if ! update_checksums ; then
68-
whiptail $BG_COLOR_ERROR --title 'ERROR' \
68+
whiptail_error --title 'ERROR' \
6969
--msgbox "Failed to update checksums / sign default config" 0 80
7070
fi
7171
else
@@ -89,7 +89,7 @@ gpg_post_gen_mgmt() {
8989
whiptail --title "The GPG Key Copied Successfully" \
9090
--msgbox "${GPG_GEN_KEY}.asc copied successfully." 0 80
9191
else
92-
whiptail $BG_COLOR_ERROR --title 'ERROR: Copy Failed' \
92+
whiptail_error --title 'ERROR: Copy Failed' \
9393
--msgbox "Unable to copy ${GPG_GEN_KEY}.asc to /media" 0 80
9494
fi
9595
umount /media
@@ -98,7 +98,7 @@ gpg_post_gen_mgmt() {
9898
--yesno "Would you like to add the GPG public key you generated to the BIOS?\n\nThis makes it a trusted key used to sign files in /boot\n\n" 0 80) then
9999
/bin/flash.sh -r /tmp/gpg-gui.rom
100100
if [ ! -s /tmp/gpg-gui.rom ]; then
101-
whiptail $BG_COLOR_ERROR --title 'ERROR: BIOS Read Failed!' \
101+
whiptail_error --title 'ERROR: BIOS Read Failed!' \
102102
--msgbox "Unable to read BIOS" 0 80
103103
exit 1
104104
fi
@@ -124,7 +124,7 @@ gpg_add_key_reflash() {
124124

125125
/bin/flash.sh -r /tmp/gpg-gui.rom
126126
if [ ! -s /tmp/gpg-gui.rom ]; then
127-
whiptail $BG_COLOR_ERROR --title 'ERROR: BIOS Read Failed!' \
127+
whiptail_error --title 'ERROR: BIOS Read Failed!' \
128128
--msgbox "Unable to read BIOS" 0 80
129129
exit 1
130130
fi
@@ -141,7 +141,7 @@ gpg_add_key_reflash() {
141141

142142
while true; do
143143
unset menu_choice
144-
whiptail $BG_COLOR_MAIN_MENU --title "GPG Management Menu" \
144+
whiptail_type $BG_COLOR_MAIN_MENU --title "GPG Management Menu" \
145145
--menu 'Select the GPG function to perform' 0 80 10 \
146146
'r' ' Add GPG key to running BIOS and reflash' \
147147
'a' ' Add GPG key to standalone BIOS image and flash' \
@@ -181,7 +181,7 @@ while true; do
181181
fi
182182
cp "$ROM" /tmp/gpg-gui.rom
183183

184-
if (whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
184+
if (whiptail_warning --title 'Flash ROM?' \
185185
--yesno "This will replace your old ROM with $ROM\n\nDo you want to proceed?" 0 80) then
186186
gpg_flash_rom
187187
else
@@ -218,7 +218,7 @@ while true; do
218218
whiptail --title "The GPG Key Copied Successfully" \
219219
--msgbox "public-key.asc copied successfully." 0 80
220220
else
221-
whiptail $BG_COLOR_ERROR --title 'ERROR: Copy Failed' \
221+
whiptail_error --title 'ERROR: Copy Failed' \
222222
--msgbox "Unable to copy public-key.asc to /media" 0 80
223223
fi
224224
umount /media

0 commit comments

Comments
 (0)