util/genbuild_h: Update printf %d to %s for sh compatability

When printing a date, genbuild_h is printing it as two digits, using
a leading zero if the value is below 10.

The shells like bash, dash, etc don't fully import the numbers 08 and
09 when using the printf conversion specifier %d.  They apparently
interpret the numbers as octal and only import the leading 0, dropping
the 8 or 9. This isn't an issue for 01 to 07, because those are valid
octal numbers, so %d prints them without an issue.  Because 08 and 09
are not valid octal, various shells return different errors:

Example shell returns for 'printf "%d" 08':
 bash: printf: 08: invalid octal number
 dash: printf: 08: not completely converted
 fish: 008: value not completely converted
 yash: printf: `08' is not a valid integer
 sash: printf: 08: not completely converted

To prevent this, just print all of the values as strings.

zsh just seems to ignore the possibility of the value being octal
and prints the value as a single digit 0-9.

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I97b6aa74d74379f6bdc1f0fceecc8002cc36ca09
Reviewed-on: https://review.coreboot.org/c/coreboot/+/70478
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Martin Roth 2022-12-08 19:04:02 -07:00 committed by Felix Held
parent 4e37a8dad2
commit 0110e1abe0
1 changed files with 8 additions and 8 deletions

View File

@ -80,16 +80,16 @@ printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "${DATE}"
printf "#define COREBOOT_ORIGIN_GIT_REVISION \"%s\"\n" "${GITREV}"
printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "${COREBOOT_EXTRA_VERSION}"
printf "#define COREBOOT_MAJOR_VERSION %d\n" "${MAJOR_VER}"
printf "#define COREBOOT_MINOR_VERSION %d\n" "${MINOR_VER}"
printf "#define COREBOOT_MAJOR_VERSION %s\n" "${MAJOR_VER}"
printf "#define COREBOOT_MINOR_VERSION %s\n" "${MINOR_VER}"
printf "#define COREBOOT_BUILD \"%s\"\n" "$(our_date "${DATE}" "+%a %b %d %H:%M:%S %Z %Y")"
printf "#define COREBOOT_BUILD_YEAR_BCD 0x%d\n" "$(our_date "${DATE}" "+%y")"
printf "#define COREBOOT_BUILD_MONTH_BCD 0x%d\n" "$(our_date "${DATE}" "+%m")"
printf "#define COREBOOT_BUILD_DAY_BCD 0x%d\n" "$(our_date "${DATE}" "+%d")"
printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x%d\n" "$(our_date "${DATE}" "+%w")"
printf "#define COREBOOT_BUILD_EPOCH \"%d\"\n" "$(our_date "${DATE}" "+%s")"
printf "#define COREBOOT_BUILD_YEAR_BCD 0x%s\n" "$(our_date "${DATE}" "+%y")"
printf "#define COREBOOT_BUILD_MONTH_BCD 0x%s\n" "$(our_date "${DATE}" "+%m")"
printf "#define COREBOOT_BUILD_DAY_BCD 0x%s\n" "$(our_date "${DATE}" "+%d")"
printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x%s\n" "$(our_date "${DATE}" "+%w")"
printf "#define COREBOOT_BUILD_EPOCH \"%s\"\n" "$(our_date "${DATE}" "+%s")"
printf "#define COREBOOT_DMI_DATE \"%s\"\n" "$(our_date "${DATE}" "+%m/%d/%Y")"
printf "\n"
printf "#define COREBOOT_COMPILE_TIME \"%s\"\n" "$(our_date "${DATE}" "+%T")"
printf "#define ASL_VERSION 0x%d\n" "${IASLVERSION}"
printf "#define ASL_VERSION 0x%s\n" "${IASLVERSION}"
printf "#endif\n"