public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/genkernel:master commit in: defaults/, /, doc/
@ 2020-07-16 15:03 Thomas Deutschmann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Deutschmann @ 2020-07-16 15:03 UTC (permalink / raw
  To: gentoo-commits

commit:     80e3a6086c92e30101f772170c4b056f1ff4c81c
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 15 22:05:53 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Thu Jul 16 14:29:17 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=80e3a608

Add ZSTD compression support for initramfs

Bug: https://bugs.gentoo.org/731294
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/compression_methods.sh | 5 +++++
 doc/genkernel.8.txt             | 3 ++-
 gen_cmdline.sh                  | 2 +-
 gen_funcs.sh                    | 2 ++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/defaults/compression_methods.sh b/defaults/compression_methods.sh
index 41ee9c4..b65f057 100644
--- a/defaults/compression_methods.sh
+++ b/defaults/compression_methods.sh
@@ -35,3 +35,8 @@ GKICM_XZ_KOPTNAME="XZ"
 GKICM_XZ_CMD="xz -e --check=none -z -f -9"
 GKICM_XZ_EXT=".xz"
 GKICM_XZ_PKG="app-arch/xz-utils"
+
+GKICM_ZSTD_KOPTNAME="ZSTD"
+GKICM_ZSTD_CMD="zstd -f -19 -q"
+GKICM_ZSTD_EXT=".zst"
+GKICM_ZSTD_PKG="app-arch/zstd"

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 40c591e..5b15a02 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -598,7 +598,8 @@ NOTE: System.map filename and System.map symlink name must be different.
     Deprecated alias for *--*[*no-*]*compress-initramfs*.
 
 *--compress-initramfs-type*=<arg>::
-    Compression type for initramfs (best, bzip2, fastest, gzip, lz4, lzma, lza, xz).
+    Compression type for initramfs (best, bzip2, fastest, gzip, lz4, lzma,
+    lza, xz, zstd).
 +
 *best* will select the algorithm providing best compression
 from those selected in your kernel configuration.

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 1daee5c..5e667bd 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -244,7 +244,7 @@ longusage() {
   echo "	--no-compress-initrd	Deprecated alias for --no-compress-initramfs"
   echo "	--compress-initramfs-type=<arg>"
   echo "				Compression type for initramfs (best, bzip2, fastest, gzip, lz4,"
-  echo "				lzma, lza, xz)"
+  echo "				lzma, lza, xz, zstd)"
   echo "	--strip=(all|kernel|modules|none)"
   echo "				Strip debug symbols from none, all, installed kernel (obsolete) or"
   echo "				modules (default)"

diff --git a/gen_funcs.sh b/gen_funcs.sh
index 69e7242..a58fbbb 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -468,6 +468,7 @@ get_initramfs_compression_method_by_compression() {
 	local -a methods=()
 	methods+=( XZ )
 	methods+=( LZMA )
+	methods+=( ZSTD )
 	methods+=( GZIP )
 	methods+=( BZIP2 )
 	methods+=( LZO )
@@ -479,6 +480,7 @@ get_initramfs_compression_method_by_compression() {
 get_initramfs_compression_method_by_speed() {
 	local -a methods=()
 	methods+=( LZ4 )
+	methods+=( ZSTD )
 	methods+=( LZO )
 	methods+=( GZIP )
 	methods+=( BZIP2 )


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/genkernel:master commit in: defaults/, /, doc/
@ 2023-08-30  5:48 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2023-08-30  5:48 UTC (permalink / raw
  To: gentoo-commits

commit:     732bd70737b784aa5e6b15430b7cf9f4e28948a1
Author:     FlyingWaffle <flyingwaffle <AT> pm <DOT> me>
AuthorDate: Thu May 19 23:43:24 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 30 05:47:41 2023 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=732bd707

Plymouth support for genkernel (squashed).

Bug: https://bugs.gentoo.org/753617
Signed-off-by: FlyingWaffle <flyingwaffle <AT> pm.me>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 defaults/initrd.scripts | 95 +++++++++++++++++++++++++++++++++++++++++++++++--
 defaults/linuxrc        | 19 ++++++++--
 doc/genkernel.8.txt     |  7 ++++
 gen_cmdline.sh          | 14 ++++++++
 gen_determineargs.sh    | 16 +++++++++
 gen_initramfs.sh        | 57 +++++++++++++++++++++++++++++
 genkernel.conf          |  7 ++++
 7 files changed, 210 insertions(+), 5 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 3d00a55..01bfe07 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 2f94eb4..34b2d87 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 6f9a64f..3108dde 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 2a4d3de..b6ad861 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 ed9b1bc..448e507 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 986b3b4..ad61faa 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 75c6d39..dae0b42 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"


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-30  5:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-30  5:48 [gentoo-commits] proj/genkernel:master commit in: defaults/, /, doc/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2020-07-16 15:03 Thomas Deutschmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox