diff --git a/functions/configuration.sh b/functions/configuration.sh index 80b17f912..eeed4303a 100755 --- a/functions/configuration.sh +++ b/functions/configuration.sh @@ -303,7 +303,11 @@ Prepare_config () case "${LB_ARCHITECTURE}" in amd64|i386) - LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-syslinux}" + if [ "${LB_INITRAMFS}" = "dracut-live" ]; then + LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-grub-pc}" + else + LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-syslinux}" + fi if ! In_list "${LB_IMAGE_TYPE}" hdd netboot; then LB_BOOTLOADER_EFI="${LB_BOOTLOADER_EFI:-grub-efi}" fi @@ -385,12 +389,25 @@ Prepare_config () fi fi + LB_ISO_APPLICATION="${LB_ISO_APPLICATION:-Debian Live}" + LB_ISO_PREPARER="${LB_ISO_PREPARER:-live-build @LB_VERSION@; https://salsa.debian.org/live-team/live-build}" + LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER:-Debian Live project; https://wiki.debian.org/DebianLive; debian-live@lists.debian.org}" + # The string @ISOVOLUME_TS@ must have the same length as the output of `date +%Y%m%d-%H:%M` + LB_ISO_VOLUME="${LB_ISO_VOLUME:-Debian ${LB_DISTRIBUTION} @ISOVOLUME_TS@}" + case "${LB_INITRAMFS}" in live-boot) LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE:-boot=live components quiet splash}" LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE:-boot=live components memtest noapic noapm nodma nomce nosmp nosplash vga=788}" ;; + dracut-live) + # Replace all spaces with underscore for the CD label + LB_ISO_VOLUME="$(echo "${LB_ISO_VOLUME}" | tr " " "_")" + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE:-boot=live components quiet splash rd.live.image root=live:CDLABEL=${LB_ISO_VOLUME} rd.live.dir=live rd.live.squashimg=filesystem.squashfs}" + LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE:-boot=live components memtest noapic noapm nodma nomce nosmp nosplash vga=788 rd.live.image root=live:CDLABEL=${LB_ISO_VOLUME} rd.live.dir=live rd.live.squashimg=filesystem.squashfs}" + ;; + none) LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE:-quiet splash}" LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE:-memtest noapic noapm nodma nomce nosmp nosplash vga=788}" @@ -433,12 +450,6 @@ Prepare_config () LB_BOOTAPPEND_INSTALL="$(echo ${LB_BOOTAPPEND_INSTALL} | sed -e 's/[ \t]*$//')" - LB_ISO_APPLICATION="${LB_ISO_APPLICATION:-Debian Live}" - LB_ISO_PREPARER="${LB_ISO_PREPARER:-live-build @LB_VERSION@; https://salsa.debian.org/live-team/live-build}" - LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER:-Debian Live project; https://wiki.debian.org/DebianLive; debian-live@lists.debian.org}" - # The string @ISOVOLUME_TS@ must have the same length as the output of `date +%Y%m%d-%H:%M` - LB_ISO_VOLUME="${LB_ISO_VOLUME:-Debian ${LB_DISTRIBUTION} @ISOVOLUME_TS@}" - LB_HDD_LABEL="${LB_HDD_LABEL:-DEBIAN_LIVE}" LB_HDD_SIZE="${LB_HDD_SIZE:-auto}" @@ -697,11 +708,43 @@ Validate_config_permitted_values () exit 1 fi - if ! In_list "${LB_INITRAMFS}" none live-boot; then + if ! In_list "${LB_INITRAMFS}" none live-boot dracut-live; then Echo_error "You have specified an invalid value for LB_INITRAMFS (--initramfs)." exit 1 fi + if [ "${LB_INITRAMFS}" = "dracut-live" ]; then + if [ "${LB_DM_VERITY}" = "true" ]; then + Echo_error "Currently unsupported/untested: dm_verity and dracut." + exit 1 + fi + if [ "${LB_BOOTLOADER_BIOS}" = "grub-legacy" ]; then + Echo_error "Currently unsupported/untested: grub-legacy and dracut." + exit 1 + fi + if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]; then + Echo_error "Currently unsupported/untested: syslinux and dracut." + exit 1 + fi + if ! In_list "${LB_IMAGE_TYPE}" iso iso-hybrid; then + # The boot=live:CDLABEL requires a CD medium + Echo_error "Currently unsupported/untested: image type ${LB_IMAGE_TYPE} and dracut." + exit 1 + fi + if [ "${LB_INITRAMFS_COMPRESSION}" != "gzip" ]; then + Echo_error "Currently unsupported/untested: compression ${LB_INITRAMFS_COMPRESSION} and dracut." + exit 1 + fi + if [ "${LB_CHROOT_FILESYSTEM}" != "squashfs" ]; then + Echo_error "Currently unsupported/untested: chroot filesystem ${LB_CHROOT_FILESYSTEM} and dracut." + exit 1 + fi + if [ "${LB_INITSYSTEM}" != systemd ]; then + Echo_error "Currently unsupported/untested: init system ${LB_INITSYSTEM} and dracut." + exit 1 + fi + fi + if ! In_list "${LB_INITRAMFS_COMPRESSION}" bzip2 gzip lzma; then Echo_error "You have specified an invalid value for LB_INITRAMFS_COMPRESSION (--initramfs-compression)." exit 1 diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1 index a89667e5c..f76b259ab 100644 --- a/manpages/en/lb_config.1 +++ b/manpages/en/lb_config.1 @@ -134,7 +134,7 @@ .br [\fB\-\-image\-name\fR \fINAME\fR] .br - [\fB\-\-initramfs\fR none|live\-boot] + [\fB\-\-initramfs\fR none|live\-boot|dracut\-live] .br [\fB\-\-initramfs\-compression\fR bzip2|gzip|lzma] .br @@ -370,11 +370,11 @@ defines the size for the HDD target. The unit is MiB. Defaults to 'auto', which \fBlb config\fR by default reads system defaults from \fI/etc/live/build.conf\fR and \fI/etc/live/build/*\fR when generating a new live system config directory. This is useful if you want to set global settings, such as mirror locations, and don't want to specify them all of the time. This option allows you to ignore such global settings. .IP "\fB\-\-image\-name\fR \fINAME\fR" 4 sets the base name of the image. Defaults to live-image. -.IP "\fB\-\-initramfs\fR none|live\-boot" 4 -sets the name of the package that contains the live system specific initramfs modification and defaults to live\-boot. Using 'none' is useful if the resulting system image should not be a live image (experimental). -.IP "\fB\-\-initramfs\-compression\fR bzip2|gzip|lzma] +.IP "\fB\-\-initramfs\fR none|live\-boot|dracut\-live" 4 +sets the name of the package that contains the live system specific initramfs modification and defaults to live\-boot. Using 'none' is useful if the resulting system image should not be a live image (experimental). Note that dracut requires the CD label in the kernel command line, so you might want to set \fB\-\-iso\-volume\fR explicitly. +.IP "\fB\-\-initramfs\-compression\fR bzip2|gzip|lzma" 4 defines the compression program to be used to compress the initramfs. Defaults to 'gzip'. -.IP "\fB\-\-initsystem\fR sysvinit|systemd|none] +.IP "\fB\-\-initsystem\fR sysvinit|systemd|none" 4 defines the init system. Defaults to 'systemd'. .IP "\fB\-\-interactive\fR true|shell|x11|xnest|false" 4 defines if after the chroot stage and before the beginning of the binary stage, an interactive shell login should be spawned in the chroot in order to allow you to do manual customizations, or as an alternative to 'true' and 'false' a specific shell to use (note that 'true' corresponds to a value of 'shell'). Once you close the shell with logout or exit, the build will continue as usual. Note that it's strongly discouraged to use this for anything else than testing. Modifications that should be present in all builds of a live system should be properly made through hooks. Everything else destroys the beauty of being able to completely automate the build process and making it non-interactive. By default, this is of course 'false'. diff --git a/scripts/build/binary_grub_cfg b/scripts/build/binary_grub_cfg index 0a9b7e074..087ca3595 100755 --- a/scripts/build/binary_grub_cfg +++ b/scripts/build/binary_grub_cfg @@ -98,6 +98,12 @@ case "${LB_INITRAMFS}" in INITFS="live" ;; + dracut-live) + INITFS="live" + LB_BOOTAPPEND_LIVE="$(echo "${LB_BOOTAPPEND_LIVE}" | sed "s|@ISOVOLUME_TS@|$(date $DATE_UTC_OPTION -d@${SOURCE_DATE_EPOCH} +%Y%m%d-%H:%M)|")" + LB_BOOTAPPEND_LIVE_FAILSAFE="$(echo "${LB_BOOTAPPEND_LIVE_FAILSAFE}" | sed "s|@ISOVOLUME_TS@|$(date $DATE_UTC_OPTION -d@${SOURCE_DATE_EPOCH} +%Y%m%d-%H:%M)|")" + ;; + *) INITFS="boot" ;; diff --git a/scripts/build/binary_linux-image b/scripts/build/binary_linux-image index d1877daf4..562949a87 100755 --- a/scripts/build/binary_linux-image +++ b/scripts/build/binary_linux-image @@ -38,7 +38,7 @@ Check_stagefile Acquire_lockfile case "${LB_INITRAMFS}" in - live-boot) + live-boot|dracut-live) DESTDIR="binary/live" ;; @@ -71,6 +71,12 @@ case "${LB_INITRAMFS}" in cp chroot/usr/share/doc/live-boot/parameters.txt "${DESTDIR}"/parameters fi ;; + dracut-live) + if [ -e chroot/usr/share/doc/live-boot/parameters.txt ] + then + Echo_message "The file parameters.txt will be ignored" + fi + ;; esac # Creating stage file diff --git a/scripts/build/binary_manifest b/scripts/build/binary_manifest index 382305611..c48b7c424 100755 --- a/scripts/build/binary_manifest +++ b/scripts/build/binary_manifest @@ -38,7 +38,7 @@ Check_stagefile Acquire_lockfile case "${LB_INITRAMFS}" in - live-boot) + live-boot|dracut-live) INITFS="live" SUFFIX="packages" ;; diff --git a/scripts/build/binary_rootfs b/scripts/build/binary_rootfs index 080ee158e..041b33087 100755 --- a/scripts/build/binary_rootfs +++ b/scripts/build/binary_rootfs @@ -43,7 +43,7 @@ case "${LB_ARCHITECTURE}" in esac case "${LB_INITRAMFS}" in - live-boot) + live-boot|dracut-live) INITFS="live" ;; diff --git a/scripts/build/chroot_hacks b/scripts/build/chroot_hacks index a59bef044..d16732a8c 100755 --- a/scripts/build/chroot_hacks +++ b/scripts/build/chroot_hacks @@ -62,18 +62,20 @@ esac # Update initramfs (always, because of udev rules in initrd) case "${LB_INITRAMFS}" in live-boot) - #UPDATE_INITRAMFS_OPTIONS="LIVE_GENERATE_UUID=1" + if [ ! -e chroot/initrd.img_has_already_been_regenerated ]; then + Chroot chroot "${UPDATE_INITRAMFS_OPTIONS} update-initramfs -k all -t -u" + fi + ;; + dracut-live) + # Enable the live module (with a unique name) + echo "add_dracutmodules+=\" dmsquash-live \"" > chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf + # This ensures that dracut uses the same filename as initramfs-tools + Chroot chroot dpkg-reconfigure dracut + rm -f chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf ;; esac - -if [ "${LB_INITRAMFS}" != "none" ] -then - if [ ! -e chroot/initrd.img_has_already_been_regenerated ]; then - Chroot chroot "${UPDATE_INITRAMFS_OPTIONS} update-initramfs -k all -t -u" - fi - rm -f chroot/vmlinuz.old - rm -f chroot/initrd.img.old -fi +rm -f chroot/vmlinuz.old +rm -f chroot/initrd.img.old rm -f chroot/initrd.img_has_already_been_regenerated # We probably ought to use COMPRESS= in a temporary file in @@ -100,16 +102,6 @@ case "${LB_INITRAMFS_COMPRESSION}" in ;; esac -case "${LB_INITRAMFS}" in - live-boot) - ID="1000" - ;; - - *) - ID="" - ;; -esac - rm -f chroot/etc/hosts if [ "${LB_DEBIAN_INSTALLER}" = "live" ] diff --git a/scripts/build/chroot_install-packages b/scripts/build/chroot_install-packages index d6519ca9d..61754fbcd 100755 --- a/scripts/build/chroot_install-packages +++ b/scripts/build/chroot_install-packages @@ -76,14 +76,20 @@ then # Restoring cache Restore_package_cache chroot + if [ "${LB_INITRAMFS}" = "dracut-live" ]; then + # Install each package separately, because the list contains conflicts + _INSTALL_ONE_BY_ONE="--max-args 1" + else + _INSTALL_ONE_BY_ONE="" + fi # Installing packages case "${LB_APT}" in apt|apt-get) - Chroot chroot "xargs --arg-file=/root/packages.chroot apt-get ${APT_OPTIONS} install" + Chroot chroot "xargs ${_INSTALL_ONE_BY_ONE} --arg-file=/root/packages.chroot apt-get ${APT_OPTIONS} install" ;; aptitude) - Chroot chroot "xargs --arg-file=/root/packages.chroot aptitude ${APTITUDE_OPTIONS} install" + Chroot chroot "xargs ${_INSTALL_ONE_BY_ONE} --arg-file=/root/packages.chroot aptitude ${APTITUDE_OPTIONS} install" ;; esac diff --git a/scripts/build/config b/scripts/build/config index 096bac6e5..782102e56 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -1402,18 +1402,28 @@ done LIVE_PKG_LIST="config/package-lists/live.list.chroot" if [ ! -e "${LIVE_PKG_LIST}" ]; then NEEDED_PACKAGES="" - if [ "${LB_INITRAMFS}" = "live-boot" ]; then - NEEDED_PACKAGES="live-boot live-config" - case "${LB_INITSYSTEM}" in - systemd) - NEEDED_PACKAGES="${NEEDED_PACKAGES} live-config-systemd systemd-sysv" - ;; + case "${LB_INITRAMFS}" in + live-boot) + NEEDED_PACKAGES="live-boot live-config" + case "${LB_INITSYSTEM}" in + systemd) + NEEDED_PACKAGES="${NEEDED_PACKAGES} live-config-systemd systemd-sysv" + ;; - sysvinit) - NEEDED_PACKAGES="${NEEDED_PACKAGES} live-config-sysvinit sysvinit-core" - ;; - esac - fi + sysvinit) + NEEDED_PACKAGES="${NEEDED_PACKAGES} live-config-sysvinit sysvinit-core" + ;; + esac + ;; + + dracut-live) + NEEDED_PACKAGES="live-config live-config-systemd systemd-sysv dracut-live dracut-config-generic dracut" + # Ensure that the settings are present before dracut is installed + mkdir -p config/includes.chroot_before_packages/etc/dracut.conf.d + echo "reproducible=yes" > config/includes.chroot_before_packages/etc/dracut.conf.d/50-reproducible.conf + # dracut-live (module dmsquash-live) will be enabled in chroot_hacks + ;; + esac for PKG in $NEEDED_PACKAGES; do echo "${PKG}" >> "${LIVE_PKG_LIST}" done diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer index ffd84c63e..03edf72b8 100755 --- a/scripts/build/installer_debian-installer +++ b/scripts/build/installer_debian-installer @@ -873,7 +873,15 @@ EOF mv chroot/root/binary ./ # Add to sources.list with the path that is used inside the live environment - echo "deb [trusted=yes] file:/run/live/medium ${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/chroot/etc/apt/sources.list + case "${LB_INITRAMFS}" in + live-boot) + echo "deb [trusted=yes] file:/run/live/medium ${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/chroot/etc/apt/sources.list + ;; + + dracut-live) + echo "deb [trusted=yes] file:/run/initramfs/live ${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/chroot/etc/apt/sources.list + ;; + esac Echo_debug "Creating distribution directories/symlinks" diff --git a/share/hooks/normal/5050-dracut.hook.chroot b/share/hooks/normal/5050-dracut.hook.chroot new file mode 100755 index 000000000..22065094e --- /dev/null +++ b/share/hooks/normal/5050-dracut.hook.chroot @@ -0,0 +1,55 @@ +#!/bin/sh + +set -e + +# Adjust the remaining bits for dracut-live instead of initramfs-tools. + +if [ ! -d /usr/share/doc/dracut-live ] +then + exit 0 +fi + +# Get access to LB_PARENT_DISTRIBUTION_CHROOT +. /live-build/config/bootstrap + +# Remove remainder of initramfs-tools +apt-get remove --purge --yes initramfs-tools +# Remove live packages that work with initramfs-tools +apt-get remove --purge --yes live-tools +apt-get remove --purge --yes live-boot +apt-get remove --purge --yes live-boot-initramfs-tools +apt-get autoremove --yes + +# Dracut mounts on /run/initramfs/live +# d-i, calamares and debian-installer-launcher have /run/live/medium hardcoded +# d-i -> fixed in live-build: installer_debian-installer +# calamares -> fixed here +# debian-installer-launcher -> probably not needed, is not part of the regular images + +# Adjust the path for Calamares +if [ -e /etc/calamares/modules/unpackfs.conf ] +then + sed -i -e 's|/run/live/medium|/run/initramfs/live|' /etc/calamares/modules/unpackfs.conf +fi +# Use dracut instead of initramfs-tools +if [ -e /etc/calamares/settings.conf ] +then + sed -i -e '/initramfscfg/d;s/initramfs/dracut/' /etc/calamares/settings.conf +fi +# Add dracut-live to the list of packages to uninstall +if [ -e /etc/calamares/modules/packages.conf ] +then + sed -i -e "s/'live-boot'/'dracut-live'/" /etc/calamares/modules/packages.conf +fi +# Calamares script for /etc/apt/sources.list during the installation +SOURCES_MEDIA=/usr/share/calamares/helpers/calamares-sources-media +if [ -e /usr/sbin/sources-media ] +then + # Until calamares-settings-debian 13.0.11 the filename was more generic + SOURCES_MEDIA=/usr/sbin/sources-media +fi +if [ -e ${SOURCES_MEDIA} ] +then + sed -i -e 's|/run/live/medium|/run/initramfs/live|;s|/run/live|/run/initramfs|' ${SOURCES_MEDIA} + sed -i -e "s|RELEASE=\".*\"|RELEASE=\"${LB_PARENT_DISTRIBUTION_CHROOT}\"|" ${SOURCES_MEDIA} +fi