loader: always install help files

Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR:		267134
Reported by:	Daniel O'Connor <darius@dons.net.au>
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28591
This commit is contained in:
Mitchell Horne 2021-02-11 10:29:00 -04:00
parent 09d3671b0e
commit 8859960436
9 changed files with 24 additions and 8 deletions

View File

@ -52,6 +52,9 @@
# xargs -n1 | sort | uniq -d;
# done
# 20230203: loader help files renamed
OLD_FILES+=boot/loader.help
# 20230201: timeout moved from /usr/bin to /bin
OLD_FILES+=usr/tests/usr.bin/timeout/Kyuafile
OLD_FILES+=usr/tests/usr.bin/timeout/timeout_test

View File

@ -123,7 +123,6 @@ help_emitsummary(char *topic, char *subtopic, char *desc)
return (pager_output("\n"));
}
static int
command_help(int argc, char *argv[])
{
@ -132,7 +131,8 @@ command_help(int argc, char *argv[])
char *topic, *subtopic, *t, *s, *d;
/* page the help text from our load path */
snprintf(buf, sizeof(buf), "%s/boot/loader.help", getenv("loaddev"));
snprintf(buf, sizeof(buf), "%s/boot/%s", getenv("loaddev"),
HELP_FILENAME);
if ((hfd = open(buf, O_RDONLY)) < 0) {
printf("Verbose help not available, "
"use '?' to list commands\n");

View File

@ -83,6 +83,7 @@ CFLAGS+= -DEFI_SECUREBOOT
NEWVERSWHAT= "EFI loader" ${MACHINE}
VERSION_FILE= ${.CURDIR}/../loader/version
HELP_FILENAME= loader.help.efi
# Always add MI sources
.include "${BOOTSRC}/loader.mk"

View File

@ -62,6 +62,7 @@ CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
.if exists(${.CURDIR}/help.i386)
HELP_FILES= ${.CURDIR}/help.i386
.endif
HELP_FILENAME= loader.help.bios
# Always add MI sources
.include "${BOOTSRC}/loader.mk"

View File

@ -44,6 +44,8 @@ CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
HAVE_ZFS=yes
.endif
HELP_FILENAME= loader.help.kboot
.include "${BOOTSRC}/fdt.mk"
# We share bootinfo.c with efi

View File

@ -162,12 +162,17 @@ vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
CFLAGS+= -DELF_VERBOSE
.endif
.if !empty(HELP_FILES)
# Each loader variant defines their own help filename. Optional or
# build-specific commands are included by augmenting HELP_FILES.
.if !defined(HELP_FILENAME)
.error Define HELP_FILENAME before including loader.mk
.endif
HELP_FILES+= ${LDRSRC}/help.common
CLEANFILES+= loader.help
FILES+= loader.help
CFLAGS+= -DHELP_FILENAME=\"${HELP_FILENAME}\"
CLEANFILES+= ${HELP_FILENAME}
FILES+= ${HELP_FILENAME}
loader.help: ${HELP_FILES}
${HELP_FILENAME}: ${HELP_FILES}
cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
.endif

View File

@ -37,6 +37,7 @@ SRCS+= trampolineLE.S
.endif
HELP_FILES= ${FDTSRC}/help.fdt
HELP_FILENAME= loader.help.ofw
# Always add MI sources
.include "${BOOTSRC}/loader.mk"

View File

@ -35,7 +35,8 @@ WARNS?= 1
CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized
.endif
HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt
HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt
HELP_FILENAME= loader.help.uboot
# Always add MI sources
.include "${BOOTSRC}/loader.mk"

View File

@ -54,6 +54,8 @@ CFLAGS+= -DUSERBOOT_ZFS_SUPPORT
HAVE_ZFS=yes
.endif
HELP_FILENAME= loader.help.userboot
# Always add MI sources
.include "${BOOTSRC}/loader.mk"
CFLAGS+= -I.