aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlyingWaffle <flyingwaffle@pm.me>2022-05-19 18:43:24 -0500
committerSam James <sam@gentoo.org>2023-08-30 06:47:41 +0100
commit732bd70737b784aa5e6b15430b7cf9f4e28948a1 (patch)
tree31b8a48a2efe9a34d2e20584bc66f86ea95655f4
parentFix build->built (diff)
downloadgenkernel-732bd70737b784aa5e6b15430b7cf9f4e28948a1.tar.gz
genkernel-732bd70737b784aa5e6b15430b7cf9f4e28948a1.tar.bz2
genkernel-732bd70737b784aa5e6b15430b7cf9f4e28948a1.zip
Plymouth support for genkernel (squashed).
Bug: https://bugs.gentoo.org/753617 Signed-off-by: FlyingWaffle <flyingwaffle@pm.me> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--defaults/initrd.scripts95
-rw-r--r--defaults/linuxrc19
-rw-r--r--doc/genkernel.8.txt7
-rwxr-xr-xgen_cmdline.sh14
-rwxr-xr-xgen_determineargs.sh16
-rwxr-xr-xgen_initramfs.sh57
-rw-r--r--genkernel.conf7
7 files changed, 210 insertions, 5 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 3d00a555..01bfe07f 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1031,6 +1031,8 @@ run_emergency_shell() {
}
run_shell() {
+ splash 'verbose' >/dev/null &
+
if ! is_userinteraction_allowed
then
bad_msg "gk.userinteraction.disabled is set; Spawning a shell is disabled!"
@@ -1226,9 +1228,22 @@ write_env_file() {
}
crypt_filter() {
+ local ask_pass=${2}
+ good_msg "Using the following decryption command: ${1}" ${CRYPT_SILENT}
+
if [ "${CRYPT_SILENT}" = '1' ]
then
eval run ${1}
+ elif [ "${PLYMOUTH}" = '1' ] && [ ${ask_pass} -eq 1 ]
+ then
+ local ply_cmd_file="$(mktemp -t 'ply_cmd.XXXXXX' 2>/dev/null)"
+ printf '#!/bin/sh\n%s\n' "${1}" > "${ply_cmd_file}"
+ run chmod 500 "${ply_cmd_file}"
+ plymouthRun ask-for-password --prompt "Enter LUKS passphrase" \
+ --number-of-tries=3 --command="${ply_cmd_file}"
+ res=$?
+ run rm "${ply_cmd_file}" >/dev/null 2>&1
+ return ${res}
else
splash 'verbose' >/dev/null &
eval run ${1}
@@ -1306,6 +1321,7 @@ prompt_user() {
fi
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
+ splash 'verbose' >/dev/null &
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ]
@@ -1388,6 +1404,8 @@ prompt_user() {
eval ${1}'='${oldvalue}
;;
esac
+
+ splash 'quiet' >/dev/null &
}
cmdline_hwopts() {
@@ -1550,7 +1568,64 @@ copyKeymap() {
}
splash() {
- return 0
+ if [ "${FBSPLASH}" = '1' ]
+ then
+ return 0
+ elif [ "${PLYMOUTH}" = '1' ]
+ then
+ case "${1}" in
+ init)
+ plymouthInit
+ ;;
+
+ verbose)
+ plymouthRun --hide-splash
+ ;;
+
+ set_msg)
+ plymouthRun --update="${2}"
+ ;;
+
+ quiet)
+ plymouthRun --show-splash
+ ;;
+
+ hasroot)
+ plymouthRun --newroot="${2}"
+ ;;
+ esac
+ fi
+}
+
+plymouthRun() {
+ run plymouth --ping 2>/dev/null || return $?
+ run plymouth "${@}" 2>/dev/null
+}
+
+plymouthInit() {
+ good_msg "Starting Plymouth..."
+ run mkdir -p -m 0755 /run/plymouth || return 1
+
+ # Make sure that udev is done loading tty and drm
+ run udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
+ run udevadm trigger --action=add --subsystem-match=graphics \
+ --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
+ udevsettle
+
+ run plymouthd --mode=boot --attach-to-session \
+ --pid-file=/run/plymouth/pid
+ if [ $? -ne 0 ]
+ then
+ bad_msg "Can't start plymouthd!"
+ PLYMOUTH=0
+ return 1
+ fi
+
+ plymouthRun --show-splash
+ if [ $? -eq 0 ]
+ then
+ good_msg "Plymouth initialized"
+ fi
}
start_volumes() {
@@ -1825,6 +1900,7 @@ openLUKS() {
eval local LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
eval local LUKS_KEYDEV_FSTYPE='"${CRYPT_'${TYPE}'_KEYDEV_FSTYPE}"'
eval local OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
+ local ASK_PASS=0
local DEV_ERROR=0
local HEADER_ERROR=0 HEADERDEV_ERROR=0
local KEY_ERROR=0 KEYDEV_ERROR=0
@@ -2054,12 +2130,25 @@ openLUKS() {
else
[ -e /dev/tty ] && run mv /dev/tty /dev/tty.org
run mknod /dev/tty c 5 1
+ ASK_PASS=1
cryptsetup_options="${cryptsetup_options} -d -"
- gpg_cmd="gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |"
+ gpg_cmd="gpg --logger-file /dev/null --quiet"
+ # plymouth password entry is passed through STDIN, requiring '--passphrase-fd 0 --batch'
+ # for newer gpg versions (>=2.1) '--pinentry-mode loopback' may also be required for the above
+ # '--no-tty' is included to prevent interruption of plymouth by any gpg output
+ if [ "${PLYMOUTH}" = '1' -a "${CRYPT_SILENT}" != '1' ]
+ then
+ gpg_cmd="${gpg_cmd} --passphrase-fd 0 --batch --no-tty --decrypt ${mntkey}${LUKS_KEY} | "
+ else
+ gpg_cmd="${gpg_cmd} --decrypt ${mntkey}${LUKS_KEY} | "
+ fi
fi
else
cryptsetup_options="${cryptsetup_options} -d ${mntkey}${LUKS_KEY}"
fi
+ else
+ # no keyfile defined, password is required
+ ASK_PASS=1
fi
if [ -n "${cryptsetup_options}" ]
@@ -2068,7 +2157,7 @@ openLUKS() {
fi
# At this point, {header,key}file or not, we're ready!
- crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
+ crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}" "${ASK_PASS}"
crypt_filter_ret=$?
[ -e /dev/tty.org ] \
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 2f94eb46..34b2d878 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -163,6 +163,18 @@ do
MLIST=$(echo ${MLIST} ${x#*=} | sed -e 's/^\ *//;s/,/ /g')
export MLIST
;;
+ splash)
+ if [ -x /usr/bin/plymouth -a -x /usr/sbin/plymouthd ]
+ then
+ PLYMOUTH=1
+ fi
+ ;;
+ splash=*)
+ if [ -e /etc/initrd.splash ]
+ then
+ FBSPLASH=1
+ fi
+ ;;
# /dev/md
lvmraid=*)
warn_msg "'${x}' kernel command-line argument is deprecated; Use 'dolvm' instead!"
@@ -557,8 +569,6 @@ then
FIRSTMODS="${FIRSTMODS} btrfs"
fi
-splash 'init'
-
cmdline_hwopts
# Mount devfs
@@ -636,6 +646,9 @@ fi
cd /
+# start splash; plymouth must start after udev
+splash 'init'
+
# Start iSCSI
if hash iscsistart >/dev/null 2>&1
then
@@ -1336,6 +1349,8 @@ keyctl_keyremove
# Re-run to ensure $NEWROOT/etc/initramfs.mounts was processed at least once
process_initramfs_mounts
+splash 'hasroot' "${NEW_ROOT}"
+
# Execute script on the cdrom just before boot to update things if necessary
cdupdate
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 6f9a64fd..3108dde2 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -357,6 +357,13 @@ INITIALIZATION
<theme> rather than the default theme specified in your splash
configuration. If *--no-splash* is specified, then splash is disabled.
+*--*[*no-*]*plymouth*::
+ Includes or excludes Plymouth from the initramfs. If "splash" is
+ passed at boot, Plymouth will be activated.
+
+*--plymouth-theme*=<theme>::
+ Embeds the given Plymouth theme into the initramfs.
+
*--do-keymap-auto*::
Force keymap selection at boot.
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 2a4d3de4..b6ad8612 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -53,6 +53,8 @@ longusage() {
echo " --no-mrproper Do not run 'make mrproper' before compilation"
echo " --splash Install framebuffer splash support into initramfs"
echo " --no-splash Do not install framebuffer splash"
+ echo " --plymouth Enable Plymouth support"
+ echo " --no-plymouth Do not enable Plymouth support"
echo " --install Install the kernel after building"
echo " --no-install Do not install the kernel after building"
echo " --symlink Manage symlinks in /boot for installed images"
@@ -129,6 +131,7 @@ longusage() {
echo " --splash-res=<res> Select splash theme resolutions to install"
echo " --splash=<theme> Enable framebuffer splash using <theme>"
echo " --splash-res=<res> Select splash theme resolutions to install"
+ echo " --plymouth-theme=<theme> Embed the given Plymouth theme"
echo " --do-keymap-auto Forces keymap selection at boot"
echo " --keymap Enables keymap selection support"
echo " --no-keymap Disables keymap selection support"
@@ -678,6 +681,17 @@ parse_cmdline() {
SPLASH_RES="${*#*=}"
print_info 3 "SPLASH_RES: ${SPLASH_RES}"
;;
+ --plymouth)
+ CMD_PLYMOUTH="yes"
+ PLYMOUTH_THEME='text'
+ print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}"
+ ;;
+ --plymouth-theme=*)
+ CMD_PLYMOUTH="yes"
+ PLYMOUTH_THEME="${*#*=}"
+ print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}"
+ print_info 3 "PLYMOUTH_THEME: ${PLYMOUTH_THEME}"
+ ;;
--install|--no-install)
CMD_INSTALL=$(parse_optbool "$*")
print_info 3 "CMD_INSTALL: ${CMD_INSTALL}"
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index ed9b1bcb..448e5076 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -388,6 +388,7 @@ determine_real_args() {
set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
set_config_with_override BOOL SPLASH CMD_SPLASH "no"
+ set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH "no"
set_config_with_override BOOL CLEAR_CACHEDIR CMD_CLEAR_CACHEDIR "no"
set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR "no"
set_config_with_override BOOL MRPROPER CMD_MRPROPER "yes"
@@ -1021,6 +1022,21 @@ determine_real_args() {
fi
fi
+ if isTrue "${PLYMOUTH}" && isTrue "${SPLASH}"
+ then
+ gen_die "--plymouth and --splash are mutually exclusive!"
+ fi
+
+ if isTrue "${PLYMOUTH}" && ! isTrue "${FIRMWARE}"
+ then
+ gen_die "--plymouth requires --firmware but --no-firmware is set!"
+ fi
+
+ if isTrue "${PLYMOUTH}" && ! isTrue "${ALLRAMDISKMODULES}"
+ then
+ gen_die "--plymouth requires --all-ramdisk-modules but --no-all-ramdisk-modules is set!"
+ fi
+
if isTrue "${SSH}"
then
local ssh_authorized_keys_file=$(expand_file "${SSH_AUTHORIZED_KEYS_FILE}")
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 986b3b47..ad61faa0 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -483,6 +483,7 @@ append_base_layout() {
isTrue "${UNIONFS}" && build_parameters+=( --unionfs ) || build_parameters+=( --no-unionfs )
isTrue "${ZFS}" && build_parameters+=( --zfs ) || build_parameters+=( --no-zfs )
isTrue "${SPLASH}" && build_parameters+=( --splash ) || build_parameters+=( --no-splash )
+ isTrue "${PLYMOUTH}" && build_parameters+=( --plymouth ) || build_parameters+=( --no-plymouth )
isTrue "${STRACE}" && build_parameters+=( --strace ) || build_parameters+=( --no-strace )
isTrue "${KEYCTL}" && build_parameters+=( --keyctl ) || build_parameters+=( --no-keyctl )
isTrue "${GPG}" && build_parameters+=( --gpg ) || build_parameters+=( --no-gpg )
@@ -1330,6 +1331,61 @@ append_splash() {
fi
}
+append_plymouth() {
+ local PN=plymouth
+ local TDIR="${TEMP}/initramfs-${PN}-temp"
+ if [ -d "${TDIR}" ]
+ then
+ rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!"
+ fi
+
+ mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
+ cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
+
+ # set plymouth theme
+ if [ -n "${PLYMOUTH_THEME}" ]
+ then
+ plymouth-set-default-theme ${PLYMOUTH_THEME} || gen_die "Failed to set default plymouth theme!"
+ fi
+ if [ -z "${PLYMOUTH_THEME}" -a -e /etc/plymouth/plymouthd.conf ]
+ then
+ PLYMOUTH_THEME=$(plymouth-set-default-theme) || gen_die "Failed to set default plymouth theme!"
+ fi
+ if [ -z "${PLYMOUTH_THEME}" ]
+ then
+ PLYMOUTH_THEME=text
+ fi
+
+ print_info 1 "$(get_indent 1)>> Installing plymouth [ using the '${PLYMOUTH_THEME}' theme ]..."
+
+ /usr/libexec/plymouth/plymouth-populate-initrd -t "${TDIR}" \
+ || gen_die "Failed to build plymouth cpio archive!"
+
+ # can probably get rid of this; depends if plymouth was built with static libs
+ # rm -f "${TDIR}"/lib*/{ld*,libc*,libz*} \
+ # || gen_die "Failed to clean up plymouth cpio archive!"
+
+ ln -sf "${PLYMOUTH_THEME}/${PLYMOUTH_THEME}.plymouth" "${TDIR}/usr/share/plymouth/themes/default.plymouth" \
+ || gen_die "Failed to set the default plymouth theme!"
+
+ # include required udev rules
+ mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!"
+ cp -aL /lib/udev/rules.d/70-uaccess.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '70-uaccess.rules'!"
+ cp -aL /lib/udev/rules.d/71-seat.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '71-seat.rules'!"
+
+ # clean up
+ cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
+ log_future_cpio_content
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
+ || gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
+}
+
append_strace() {
local PN=strace
local TDIR="${TEMP}/initramfs-${PN}-temp"
@@ -2086,6 +2142,7 @@ create_initramfs() {
append_data 'modprobed'
append_data 'multipath' "${MULTIPATH}"
append_data 'splash' "${SPLASH}"
+ append_data 'plymouth' "${PLYMOUTH}"
append_data 'strace' "${STRACE}"
append_data 'unionfs_fuse' "${UNIONFS}"
append_data 'xfsprogs' "${XFSPROGS}"
diff --git a/genkernel.conf b/genkernel.conf
index 75c6d39f..dae0b421 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -174,6 +174,13 @@ NOCOLOR="false"
# This supersedes the "SPLASH_THEME" option in '/etc/conf.d/splash'.
#SPLASH_THEME="gentoo"
+# Includes or excludes Plymouth from the initramfs. If "splash" is
+# passed at boot, Plymouth will be activated.
+#PLYMOUTH="no"
+
+# Embeds the given plymouth theme in the initramfs.
+#PLYMOUTH_THEME="text"
+
# Run "emerge @module-rebuild" automatically when possible and necessary
# after kernel and modules have been compiled
#MODULEREBUILD="yes"