diff --git b/defaults/initrd.scripts a/defaults/initrd.scripts index 5181d6c..421c70e 100644 --- b/defaults/initrd.scripts +++ a/defaults/initrd.scripts @@ -75,7 +75,6 @@ modules_scan() { elif [ "${USE_MDADM}" = '1' ] \ || [ "${USE_LVM_NORMAL}" = '1' ] \ || [ "${USE_CRYPTSETUP}" = '1' ] \ - || [ "${USE_BTRFS}" = '1' ] \ || [ "${USE_ZFS}" = '1' ] \ || [ "${USE_DMRAID_NORMAL}" = '1' ] then @@ -561,8 +560,7 @@ conf_rc_no_umounts() { if nomount=$(grep -n '^[[:blank:]]*no_umounts=' ${conf}) then local i n data cmd IFS - IFS=' -' + IFS='' set -- ${nomount} unset IFS @@ -1010,6 +1008,8 @@ run_emergency_shell() { } run_shell() { + splashCmd 'verbose' >/dev/null & + if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ] then bad_msg "gk.userinteraction.disabled is set; Spawning a shell is disabled!" @@ -1161,7 +1161,7 @@ bad_msg() { if [ "$2" != '1' ] then - splash 'verbose' >/dev/null & + splashCmd 'verbose' >/dev/null & printf "%b\n" "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}" fi } @@ -1202,13 +1202,19 @@ crypt_filter() { if [ "${CRYPT_SILENT}" = '1' ] then eval run ${1} >/dev/null 2>&1 + elif [ "${PLYMOUTH}" = '1' ] && plymouth_running + then + run plymouth ask-for-password --prompt "Enter LUKS passphrase" \ + --number-of-tries=3 --command="${2}" + res=$? + return ${res} else - splash 'verbose' >/dev/null & + splashCmd 'verbose' >/dev/null & eval run ${1} res=$? if [ ${res} -eq 0 ] then - splash set_msg 'Disk unlocked.' + splashCmd set_msg 'Disk unlocked.' fi return ${res} fi @@ -1279,6 +1285,7 @@ prompt_user() { fi [ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="." + splashCmd 'verbose' >/dev/null & bad_msg "Could not find the ${2} in ${oldvalue}${explnt}" if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ] @@ -1361,6 +1368,8 @@ prompt_user() { eval ${1}'='${oldvalue} ;; esac + + splashCmd 'quiet' >/dev/null & } cmdline_hwopts() { @@ -1433,7 +1442,7 @@ chooseKeymap() { good_msg "Loading keymaps" if [ -z "${keymap}" ] then - splash 'verbose' >/dev/null & + splashCmd 'verbose' >/dev/null & run cat /lib/keymaps/keymapList read -t 10 -p '<< Load keymap (Enter for default): ' keymap case ${keymap} in @@ -1491,12 +1500,12 @@ chooseKeymap() { run mkdir -p /etc/sysconfig echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard - splash set_msg "Set keymap to '${keymap}'" + splashCmd set_msg "Set keymap to '${keymap}'" elif [ -z "${keymap}" ] then good_msg good_msg "Keeping default keymap" - splash set_msg "Keeping default keymap" + splashCmd set_msg "Keeping default keymap" else bad_msg "Sorry, but keymap '${keymap}' is invalid!" unset keymap @@ -1519,6 +1528,71 @@ splash() { return 0 } +splashCmd() { + case "${1}" in + init) + if [ "${FBSPLASH}" = '1' ] + then + splash 'init' + elif [ "${PLYMOUTH}" = '1' ] + then + plymouthInit + fi + ;; + + verbose) + if [ "${FBSPLASH}" = '1' ] + then + splash 'verbose' + elif [ "${PLYMOUTH}" = '1' ] + then + plymouth_running && run plymouth --hide-splash + fi + ;; + + set_msg) + if [ "${FBSPLASH}" = '1' ] + then + splash 'set_msg' "${2}" + elif [ "${PLYMOUTH}" = '1' ] + then + plymouth_running && run plymouth --update="${2}" + fi + ;; + + quiet) + plymouth_running && run plymouth --show-splash + ;; + + hasroot) + plymouth_running && run plymouth --newroot="${2}" + ;; + esac +} + +plymouth_running() { + [ -n "${PLYMOUTH_FAIL}" ] && return 1 + run plymouth --ping 2>/dev/null + return $? +} + +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 || { PLYMOUTH_FAIL=1; return 1; } + + plymouth_running && run plymouth --show-splash + good_msg "Plymouth initialized" +} + start_volumes() { # Here, we check for /dev/device-mapper, and if it exists, we setup a # a symlink, which should hopefully fix bug #142775 and bug #147015 @@ -1612,25 +1686,6 @@ start_volumes() { fi fi - if [ "${USE_BTRFS}" = '1' ] - then - if ! hash btrfs >/dev/null 2>&1 - then - bad_msg "dobtrfs invoked but 'btrfs' not found; Skipping btrfs device scanning ..." - else - good_msg "Scanning for BTRFS devices ..." - - local btrfs_cmd="run btrfs device scan 2>&1" - is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'" - - eval "${btrfs_cmd}" - if [ $? -ne 0 ] - then - bad_msg "Scanning for BTRFS devices failed!" - fi - fi - fi - if [ "${USE_ZFS}" = '1' ] then # Avoid race involving asynchronous module loading @@ -1804,6 +1859,7 @@ openLUKS() { local cryptsetup_options='' local gpg_cmd="" + local ply_cmd="" if [ -e "${OPENED_LOCKFILE}" ] then good_msg "The LUKS device ${LUKS_DEVICE} meanwhile was opened by someone else." @@ -1925,15 +1981,27 @@ openLUKS() { [ -e /dev/tty ] && run mv /dev/tty /dev/tty.org run mknod /dev/tty c 5 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 --decrypt ${mntkey}${LUKS_KEY} | " + ply_cmd="gpg --logger-file /dev/null --quiet --passphrase-fd 0 --batch --no-tty --decrypt ${mntkey}${LUKS_KEY} | " fi else cryptsetup_options="${cryptsetup_options} -d ${mntkey}${LUKS_KEY}" fi fi # At this point, keyfile or not, we're ready! - crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}" + if [ "${PLYMOUTH}" = '1' ] + then + ply_cmd="${ply_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}" + local ply_cmd_file="$(mktemp -t "ply_cmd.XXXXXX")" + printf '#!/bin/sh\n%s\n' "${ply_cmd}" > "${ply_cmd_file}" + run chmod 500 "${ply_cmd_file}" + fi + crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}" "${ply_cmd_file}" crypt_filter_ret=$? + if [ "${PLYMOUTH}" = '1' ] + then + run rm -f "${ply_cmd_file}" + fi [ -e /dev/tty.org ] \ && run rm -f /dev/tty \ @@ -2510,18 +2578,6 @@ cdupdate() { fi } -setup_btrfsctl() { - # start BTRFS volume detection, if available - if hash btrfsctl >/dev/null 2>&1 - then - local btrfs_cmd="run btrfsctl -a 2>&1" - is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'" - - eval "${btrfs_cmd}" - udevsettle - fi -} - rundebugshell() { if is_debug then diff --git b/defaults/linuxrc a/defaults/linuxrc index 6d07d9b..13fa8de 100644 --- b/defaults/linuxrc +++ a/defaults/linuxrc @@ -151,9 +151,6 @@ do ;; esac ;; - dobtrfs) - USE_BTRFS=1 - ;; quiet|quiet_genkernel) QUIET=1 ;; @@ -191,6 +188,18 @@ do NEW_CONSOLE=$(basename ${NEW_CONSOLE}) NEW_CONSOLE=${NEW_CONSOLE%%,*} ;; + 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=*) RAID_DEVICES="${x#*=}" @@ -518,8 +527,6 @@ then FIRSTMODS="${FIRSTMODS} crc32_generic" fi -splash 'init' - cmdline_hwopts # Mount devfs @@ -597,6 +604,9 @@ fi cd / +# start splash; plymouth must start after udev +splashCmd 'init' + # Start iSCSI if hash iscsistart >/dev/null 2>&1 then @@ -615,9 +625,6 @@ fi # Apply scan delay if specified sdelay -# Setup btrfs, see bug 303529 -setup_btrfsctl - # Scan volumes start_volumes @@ -1276,6 +1283,8 @@ fi # if [ "${CDROOT}" = '1' ] # Re-run to ensure $NEWROOT/etc/initramfs.mounts was processed at least once process_initramfs_mounts +splashCmd 'hasroot' "${NEW_ROOT}" + # Execute script on the cdrom just before boot to update things if necessary cdupdate @@ -1348,7 +1357,7 @@ else fi # If we get here, something bad has happened -splash 'verbose' +splashCmd 'verbose' bad_msg "A fatal error has occured since ${init} did not" bad_msg "boot correctly. Trying to open a shell ..." diff --git b/doc/genkernel.8.txt a/doc/genkernel.8.txt index 5d7b74d..94352ad 100644 --- b/doc/genkernel.8.txt +++ a/doc/genkernel.8.txt @@ -317,6 +317,13 @@ INITIALIZATION 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*=:: + Embeds the given Plymouth theme into the initramfs. + *--do-keymap-auto*:: Force keymap selection at boot. @@ -775,9 +782,6 @@ when not set. This will allow remote user to provide answer through Scan for bootable ZFS pools on bootup. Optionally use cachefile or force import if necessary or perform both actions. -*dobtrfs*:: - Scan for attached Btrfs devices on bootup. - *domultipath*:: Activate Multipath on bootup. diff --git b/gen_cmdline.sh a/gen_cmdline.sh index 33bf1c5..d5cd436 100755 --- b/gen_cmdline.sh +++ a/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" @@ -113,6 +115,7 @@ longusage() { echo " --splash-res= Select splash theme resolutions to install" echo " --splash= Enable framebuffer splash using " echo " --splash-res= Select splash theme resolutions to install" + echo " --plymouth-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" @@ -600,6 +603,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 b/gen_determineargs.sh a/gen_determineargs.sh index 265c557..368f982 100755 --- b/gen_determineargs.sh +++ a/gen_determineargs.sh @@ -352,6 +352,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" @@ -984,6 +985,11 @@ determine_real_args() { fi fi + if isTrue "${PLYMOUTH}" && isTrue "${SPLASH}" + then + gen_die "--plymouth and --splash are mutually exclusive!" + fi + if isTrue "${SSH}" then local ssh_authorized_keys_file=$(expand_file "${SSH_AUTHORIZED_KEYS_FILE}") diff --git b/gen_initramfs.sh a/gen_initramfs.sh index ae71c38..8a00d3e 100755 --- b/gen_initramfs.sh +++ a/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 "${GPG}" && build_parameters+=( --gpg ) || build_parameters+=( --no-gpg ) isTrue "${LUKS}" && build_parameters+=( --luks ) || build_parameters+=( --no-luks ) @@ -1283,6 +1284,136 @@ 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!" + + # this might be better located in append_drm (?) + 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/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_drm() { + local PN=drm + local TDIR="${TEMP}/initramfs-${PN}-${KV}-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}'!" + + print_info 1 "$(get_indent 1)>> Appending drm drivers..." + + # mkdir -p "${TDIR}/lib/modules/${KV}" + + local drm_path="/lib/modules/${KV}/kernel/drivers/gpu/drm" + local modules + if [ -d "${drm_path}" ] + then + modules=$(strip_mod_paths $(find "${drm_path}" -name "*.ko")) + else + print_info 1 "$(get_indent 2)Warning :: no drm modules in drivers/gpu/drm..." + fi + + rm -f "${TEMP}/moddeps" || gen_die "Failed to clear old moddeps!" + gen_deps ${modules} + if [ -f "${TEMP}/moddeps" ] + then + modules=$(cat "${TEMP}/moddeps" | sort | uniq) + else + print_info 1 "$(get_indent 2)Warning :: module dependencies not generated..." + fi + + local mod i fws fw + for i in ${modules} + do + mod=$(find "/lib/modules/${KV}" -name "${i}.ko" 2>/dev/null| head -n 1) + if [ -z "${mod}" ] + then + print_info 1 "$(get_indent 2)Warning :: ${i}.ko not found; skipping..." + continue + fi + + print_info 1 "$(get_indent 2)>> Copying ${mod}..." + cp -ax --parents "${mod}" "${TDIR}" || gen_die "Failed to copy '${mod}'!" + + # check that firmware files exist, then copy them (modinfo may list deprecated firmware) + fws=( $(get_firmware_files "${mod}") ) + for fw in "${fws[@]}" + do + if [ -e "/lib/firmware/${fw}" ] + then + print_info 1 "$(get_indent 2)>> Copying firmware ${fw}..." + cp -ax --parents "/lib/firmware/${fw}" "${TDIR}" \ + || gen_die "Failed to copy ${fw}!" + fi + done + done + + 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 +} + +get_firmware_files() { + local kmod="${1}" + modinfo --set-version="${KV}" -F firmware "${kmod}" || gen_die "Failed to get modinfo for ${kmod}!" +} + append_strace() { local PN=strace local TDIR="${TEMP}/initramfs-${PN}-temp" @@ -2003,11 +2134,17 @@ 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}" append_data 'zfs' "${ZFS}" + if isTrue "${PLYMOUTH}" + then + append_data 'drm' + fi + if isTrue "${ZFS}" then append_data 'libgcc_s' diff --git b/genkernel a/genkernel index 595c6ea..6ec8905 100755 --- b/genkernel +++ a/genkernel @@ -485,7 +485,6 @@ then print_warning 1 "${BOLD}WARNING... WARNING... WARNING...${NORMAL}" print_warning 1 'Additional kernel parameters that *may* be required to boot properly:' isTrue "${SPLASH}" && print_warning 1 "- Add \"vga=791 splash=silent,theme:${SPLASH_THEME} console=tty1 quiet\" if you use a splash framebuffer ]" - isTrue "${BTRFS}" && print_warning 1 '- Add "dobtrfs" for Btrfs device scanning support' isTrue "${MULTIPATH}" && print_warning 1 '- Add "domultipath" for multipath support' isTrue "${ISCSI}" && print_warning 1 '- For iSCSI support, add at least:' isTrue "${ISCSI}" && print_warning 1 ' - "iscsi_initiatorname="' diff --git b/genkernel.conf a/genkernel.conf index fdf00fa..d5072f2 100644 --- b/genkernel.conf +++ a/genkernel.conf @@ -171,6 +171,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"