binary_bootloader_splash: New script

Allows for scenarios without syslinux (e.g. arm64)
Breaking change: custom splash.svg images must be placed in
config/bootloaders
This commit is contained in:
Roland Clobus 2024-03-15 22:48:35 +01:00 committed by Luca Boccassi
parent 2f1acabc41
commit 724f449e0d
6 changed files with 235 additions and 45 deletions

View File

@ -62,6 +62,7 @@ lb binary_loadlin "${@}"
lb binary_win32-loader "${@}"
lb binary_includes "${@}"
lb binary_grub-efi "${@}"
lb binary_bootloader_splash "${@}"
lb binary_hooks "${@}"
lb binary_checksums "${@}"

View File

@ -0,0 +1,226 @@
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2024 The Debian Live team
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
set -e
# Including common functions
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
# Setting static variables
DESCRIPTION="Prepares the bootloader splash image"
USAGE="${PROGRAM} [--force]"
# Processing arguments and configuration files
Init_config_data "${@}"
if [ -z "${LB_BOOTLOADER_BIOS}" -a -z "${LB_BOOTLOADER_EFI}" ]; then
exit 0
fi
Echo_message "Begin preparing the bootloader splash image..."
# Requiring stage file
Require_stagefiles config bootstrap
# Checking stage file
Check_stagefile
# Acquire lock file
Acquire_lockfile
if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]; then
# Assembling image specifics
case "${LB_IMAGE_TYPE}" in
iso|iso-hybrid)
_TARGET="binary/isolinux"
;;
netboot)
_TARGET="tftpboot"
;;
hdd|tar)
case ${LB_BINARY_FILESYSTEM} in
fat*|ntfs)
_TARGET="binary/syslinux"
;;
ext[234]|btrfs)
_TARGET="binary/boot/extlinux"
;;
*)
Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
exit 1
;;
esac
;;
esac
else
# If not syslinux, then it is grub
_TARGET="binary/boot/grub"
fi
_TARGETGRUB="binary/boot/grub"
# Checking depends
Check_package chroot /usr/bin/rsvg-convert librsvg2-bin
Check_package chroot /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf fonts-dejavu-core
# Restoring cache
Restore_package_cache binary
# Installing depends
Install_packages
if [ -e chroot/etc/os-release ]
then
_VERSION="$(. chroot/etc/os-release && echo ${VERSION_ID})"
fi
_VERSION="${_VERSION:-none}"
_DISTRIBUTION="${LB_DISTRIBUTION_BINARY}"
_DATE="$(date $DATE_UTC_OPTION -R -d@${SOURCE_DATE_EPOCH})"
_YEAR="$(date $DATE_UTC_OPTION -d "${_DATE}" +%Y)"
_MONTH="$(date $DATE_UTC_OPTION -d "${_DATE}" +%m)"
_DAY="$(date $DATE_UTC_OPTION -d "${_DATE}" +%d)"
_HOUR="$(date $DATE_UTC_OPTION -d "${_DATE}" +%H)"
_MINUTE="$(date $DATE_UTC_OPTION -d "${_DATE}" +%M)"
_SECOND="$(date $DATE_UTC_OPTION -d "${_DATE}" +%S)"
_TIMEZONE="$(date $DATE_UTC_OPTION -d "${_DATE}" +%Z)"
_TIMEZONE_NUM="$(date $DATE_UTC_OPTION -d "${_DATE}" +%z)"
_LINUX_VERSIONS="$(for _LINUX in chroot/boot/vmlinuz-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|vmlinuz-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
_LIVE_BOOT_VERSION="$(chroot chroot apt-cache policy live-boot | awk '/Installed: / { print $2 }')"
_LIVE_CONFIG_VERSION="$(chroot chroot apt-cache policy live-config | awk '/Installed: / { print $2 }')"
_LIVE_TOOLS_VERSION="$(chroot chroot apt-cache policy live-tools | awk '/Installed: / { print $2 }')"
_PROJECT="Debian GNU/Linux"
# If there is no SVG file and no PNG file, try to find a suitable SVG file
if [ ! -e "${_TARGET}"/splash.svg -a ! -e "${_TARGET}"/splash.png ]; then
if [ -n "${LIVE_BUILD}" ]; then
_FALLBACK_SPLASH_LOCATION="${LIVE_BUILD}/share/bootloaders/splash.svg"
else
_FALLBACK_SPLASH_LOCATION="/usr/share/live/build/bootloaders/splash.svg"
fi
# In older versions of live-build the SVG file was in share/bootloaders/syslinux_common
_LEGACY_SPLASH_LOCATIONS="config/bootloaders/grub-pc/splash.svg config/bootloaders/syslinux_common/splash.svg"
# The last entry which is found will be used
for _FILE in ${_FALLBACK_SPLASH_LOCATION} ${_LEGACY_SPLASH_LOCATIONS} config/bootloaders/splash.svg
do
if [ -e ${_FILE} ]; then
_SVG_SOURCE=${_FILE}
fi
done
# Tweak the grub theme to remove the title-text for the fallback image
if [ -e binary/boot/grub/live-theme/theme.txt ] && [ "${_SVG_SOURCE}" = "${_FALLBACK_SPLASH_LOCATION}" ]; then
sed -i -e 's|^title-text:.*|title-text: ""|' \
binary/boot/grub/live-theme/theme.txt
fi
cp ${_SVG_SOURCE} ${_TARGET}
cp ${_SVG_SOURCE} ${_TARGETGRUB}
fi
for _FILE in "${_TARGET}"/*.svg "${_TARGETGRUB}"/*.svg
do
if [ -e "${_FILE}" ] && [ ! -d "${_FILE}" ]
then
sed -i -e "s#@APPEND_LIVE@#${LB_BOOTAPPEND_LIVE}#g" \
-e "s#@APPEND_LIVE_FAILSAFE@#${LB_BOOTAPPEND_LIVE_FAILSAFE}#g" \
-e "s#@APPEND_INSTALL@#${LB_BOOTAPPEND_INSTALL}#g" \
-e "s|@PROJECT@|${_PROJECT}|g" \
-e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION_BINARY}|g" \
-e "s|@VERSION@|${_VERSION}|g" \
-e "s|@ARCHITECTURE@|${LB_ARCHITECTURE}|g" \
-e "s|@DATE@|${_DATE}|g" \
-e "s|@YEAR@|${_YEAR}|g" \
-e "s|@MONTH@|${_MONTH}|g" \
-e "s|@DAY@|${_DAY}|g" \
-e "s|@HOUR@|${_HOUR}|g" \
-e "s|@MINUTE@|${_MINUTE}|g" \
-e "s|@SECOND@|${_SECOND}|g" \
-e "s|@TIMEZONE@|${_TIMEZONE}|g" \
-e "s|@TIMEZONE_NUM@|${_TIMEZONE_NUM}|g" \
-e "s|@LINUX_VERSIONS@|${_LINUX_VERSIONS}|g" \
-e "s|@LIVE_BUILD_VERSION@|${LIVE_BUILD_VERSION}|g" \
-e "s|@LIVE_BOOT_VERSION@|${_LIVE_BOOT_VERSION}|g" \
-e "s|@LIVE_CONFIG_VERSION@|${_LIVE_CONFIG_VERSION}|g" \
-e "s|@LIVE_TOOLS_VERSION@|${_LIVE_TOOLS_VERSION}|g" \
-e "s|@LB_ISO_APPLICATION@|${LB_ISO_APPLICATION}|g" \
-e "s|@LB_ISO_PUBLISHER@|${LB_ISO_PUBLISHER}|g" \
-e "s|@LB_LINUX_PACKAGES@|${LB_LINUX_PACKAGES}|g" \
"${_FILE}"
fi
done
# Scenarios for generated PNG files:
# * BIOS = syslinux EFI = - -> isolinux/splash (640x480)
# * BIOS = grub EFI = - -> boot/grub/splash (800x600)
# * BIOS = syslinux EFI = grub -> isolinux/splash (640x480) && boot/grub/splash (800x600)
# * BIOS = grub EFI = grub -> boot/grub/splash (800x600)
# * BIOS = - EFI = grub -> boot/grub/splash (800x600)
if [ -e "${_TARGET}/splash.svg" -o -e "${_TARGETGRUB}/splash.svg" ]; then
case "${LB_BUILD_WITH_CHROOT}" in
true)
# Non-grub version is required
if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]; then
if [ -e "${_TARGET}/splash.svg" -a ! -e "${_TARGET}/splash.png" ]; then
cp "${_TARGET}/splash.svg" chroot
Chroot chroot "rsvg-convert --format png --height 480 --width 640 splash.svg -o splash.png"
mv chroot/splash.png "${_TARGET}"
rm -f chroot/splash.svg
fi
fi
# Grub version is required
if [ "${LB_BOOTLOADER_BIOS}" != "syslinux" -o -n "${LB_BOOTLOADER_EFI}" ]; then
if [ -e "${_TARGETGRUB}/splash.svg" -a ! -e "${_TARGETGRUB}/splash.png" ]; then
cp "${_TARGETGRUB}/splash.svg" chroot
Chroot chroot "rsvg-convert --format png --height 600 --width 800 splash.svg -o splash.png"
mv chroot/splash.png "${_TARGETGRUB}"
rm -f chroot/splash.svg
fi
fi
;;
false)
if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]; then
if [ -e "${_TARGET}/splash.svg" -a ! -e "${_TARGET}/splash.png" ]; then
rsvg-convert --format png --height 480 --width 640 "${_TARGET}/splash.svg" -o "${_TARGET}/splash.png"
fi
fi
if [ "${LB_BOOTLOADER_BIOS}" != "syslinux" -o -n "${LB_BOOTLOADER_EFI}" ]; then
if [ -e "${_TARGETGRUB}/splash.svg" -a ! -e "${_TARGETGRUB}/splash.png" ]; then
rsvg-convert --format png --height 600 --width 800 "${_TARGET}/splash.svg" -o "${_TARGETGRUB}/splash.png"
fi
fi
;;
esac
fi
rm -f "${_TARGET}/splash.svg"
rm -f "${_TARGETGRUB}/splash.svg"
case "${LB_BUILD_WITH_CHROOT}" in
true)
# Saving cache
Save_package_cache binary
# Removing depends
Remove_packages
;;
esac
# Creating stage file
Create_stagefile

View File

@ -95,8 +95,6 @@ fi
# Checking depends
Check_package chroot /usr/lib/$(echo ${_BOOTLOADER} | tr '[a-z]' '[A-Z]') ${_BOOTLOADER}
Check_package chroot /usr/lib/syslinux syslinux-common
Check_package chroot /usr/bin/rsvg-convert librsvg2-bin
Check_package chroot /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf fonts-dejavu-core
# Restoring cache
Restore_package_cache binary
@ -236,7 +234,7 @@ _LIVE_TOOLS_VERSION="$(chroot chroot apt-cache policy live-tools | awk '/Install
_PROJECT="Debian GNU/Linux"
for _FILE in "${_TARGET}"/*.cfg ${_TARGET}/*.svg
for _FILE in "${_TARGET}"/*.cfg
do
if [ -e "${_FILE}" ] && [ ! -d "${_FILE}" ]
then
@ -305,33 +303,6 @@ else
sed -i -e "s#@OPTIONAL_MEMTEST_INCLUDE@#include memtest.cfg#g" "${_TARGET}"/utilities.cfg
fi
if [ -e "${_TARGET}/splash.svg" ] && [ ! -e "${_TARGET}/splash.png" ]
then
case "${LB_BUILD_WITH_CHROOT}" in
true)
cp "${_TARGET}/splash.svg" chroot
Chroot chroot "rsvg-convert --format png --height 480 --width 640 splash.svg -o splash.png"
mv chroot/splash.png "${_TARGET}"
Chroot chroot "rsvg-convert --format png --height 600 --width 800 splash.svg -o splash800x600.png"
mv chroot/splash800x600.png "${_TARGET}"
rm -f chroot/splash.svg
;;
false)
rsvg-convert --format png --height 480 --width 640 "${_TARGET}/splash.svg" -o "${_TARGET}/splash.png"
rsvg-convert --format png --height 600 --width 800 "${_TARGET}/splash.svg" -o "${_TARGET}/splash800x600.png"
;;
esac
fi
rm -f "${_TARGET}/splash.svg"
# Tweak the grub theme to reuse the syslinux background image if grub doesn't have its own
if [ -e binary/boot/grub/live-theme/theme.txt ] && [ ! -e binary/boot/grub/splash.png ]; then
sed -i -e 's|^desktop-image:.*|desktop-image: "/isolinux/splash800x600.png"|' \
-e 's|^title-text:.*|title-text: ""|' \
binary/boot/grub/live-theme/theme.txt
fi
case "${LB_BUILD_WITH_CHROOT}" in
true)
# Saving cache

View File

@ -1,11 +1,7 @@
set color_normal=light-gray/black
set color_highlight=white/dark-gray
if [ -e /isolinux/splash.png ]; then
# binary_syslinux modifies the theme file to point to the correct
# background picture
set theme=/boot/grub/live-theme/theme.txt
elif [ -e /boot/grub/splash.png ]; then
if [ -e /boot/grub/splash.png ]; then
set theme=/boot/grub/live-theme/theme.txt
else
set menu_color_normal=cyan/blue

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -607,22 +607,18 @@ EOFNEWCONTENT
echo "P: \$(basename \$0) Bugfix hook has been applied"
EOFHOOK
# For stable and soon-to-be-stable use the same boot splash screen as the Debian installer
# For oldstable and stable use the same boot splash screen as the Debian installer
case "$DEBIAN_VERSION" in
"bullseye")
mkdir -p config/bootloaders/syslinux_common
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/11-homeworld/homeworld.svg -O config/bootloaders/syslinux_common/splash.svg
mkdir -p config/bootloaders
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/11-homeworld/homeworld.svg -O config/bootloaders/splash.svg
mkdir -p config/bootloaders/grub-pc
# Use the old resolution of 640x480 for grub
ln -s ../../isolinux/splash.png config/bootloaders/grub-pc/splash.png
;;
"bookworm")
mkdir -p config/bootloaders/syslinux_common
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/12-emerald/emerald.svg -O config/bootloaders/syslinux_common/splash.svg
# To have a 800x600 image and the title 'Live Boot Menu with GRUB', manually undo the title-text modification from binary_syslinux
cat > config/hooks/live/5010-restore-grub-title.hook.binary << EOF
#!/bin/sh
sed -i -e 's|^title-text:.*|title-text: "Live Boot Menu with GRUB"|' boot/grub/live-theme/theme.txt
EOF
mkdir -p config/bootloaders
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/12-emerald/emerald.svg -O config/bootloaders/splash.svg
;;
*)
# Use the default 'under construction' image