fix kernel version on startup screen and motd

Signed-off-by: Tobias Powalowski <tpowa@archlinux.org>
This commit is contained in:
Tobias Powalowski 2021-09-11 14:27:21 +02:00
parent 86fe4c2dc9
commit 70630cf4a3
2 changed files with 27 additions and 3 deletions

View file

@ -50,7 +50,31 @@ if ! [[ ${UID} -eq 0 ]]; then
exit 1
fi
# from initcpio functions
kver() {
# this is intentionally very loose. only ensure that we're
# dealing with some sort of string that starts with something
# resembling dotted decimal notation. remember that there's no
# requirement for CONFIG_LOCALVERSION to be set.
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+'
# scrape the version out of the kernel image. locate the offset
# to the version string by reading 2 bytes out of image at at
# address 0x20E. this leads us to a string of, at most, 128 bytes.
# read the first word from this string as the kernel version.
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "/boot/vmlinuz-linux")
[[ $offset = +([0-9]) ]] || return 1
read kver _ < \
<(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null)
[[ $kver =~ $re ]] || return 1
printf '%s' "$kver"
}
# set defaults, if nothing given
[[ -z "${KERNEL}" ]] && KERNEL="$(kver)"
[[ -z "${RELEASENAME}" ]] && RELEASENAME="$(date +%Y%m%d-%H%M)"
[[ -z "${IMAGENAME}" ]] && IMAGENAME="archlinux-${RELEASENAME}-archboot-X86_64"

View file

@ -10,15 +10,15 @@ build ()
echo "Consoles:" >> ${MOTD}
echo " - Virtual consoles 1-6 are active." >> ${MOTD}
echo " - To change virtual console use ALT + F(1-6)" >> ${MOTD}
if [ "$(echo "${HOOKS[@]}" | grep arch_keymap)" ]; then
if [ "$(echo "${HOOKS[@]}" | grep archboot_keymap)" ]; then
echo "Change keymap:" >> ${MOTD}
echo " - To change to a non-US keymap, type 'km' at the console." >> ${MOTD}
fi
if [ "$(echo "${HOOKS[@]}" | grep arch_tz)" ]; then
if [ "$(echo "${HOOKS[@]}" | grep archboot_tz)" ]; then
echo "Change time and date:" >> ${MOTD}
echo " - To change your time and date, type 'tz' at the console." >> ${MOTD}
fi
if [ "$(echo "${HOOKS[@]}" | grep arch_installer)" ]; then
if [ "$(echo "${HOOKS[@]}" | grep archboot_installer)" ]; then
echo "Normal Setup:" >> ${MOTD}
echo " - On first login /arch/setup is launched automatically." >> ${MOTD}
echo " - Please run '/arch/setup' again to install Arch Linux if you left setup." >> ${MOTD}