Quellcode durchsuchen

Added blivet-gui

Sergei Ilinykh vor 1 Jahr
Ursprung
Commit
8c33da86ea

+ 1 - 1
games-action/oolite/oolite-1.90.ebuild

@@ -6,7 +6,7 @@ EAPI=8
 inherit gnustep-2 desktop
 
 DESCRIPTION="Elite space trading & warfare remake"
-HOMEPAGE="http://oolite.org/"
+HOMEPAGE="http://oolite.space/"
 FF_JS_URI="http://jens.ayton.se/oolite/deps/firefox-4.0.source.js-only.tbz"
 BINRES_REV=1fe395fe185611b2de54b027cda6c29f15a9f3a0
 OOLITE_REV=1.90

+ 1 - 0
sys-block/blivet-gui/Manifest

@@ -0,0 +1 @@
+DIST blivet-gui-2.4.3_alpha.tar.gz 1015762 BLAKE2B a8343c243171d7e9776a265f5e393378f589998932aaca766ee493dce03351985dceaacb5044da6b1e3c894d59c548b1fd93c28dd1d7c10927750256d69ae540 SHA512 5223b097e41f930e403f865eebc96c333c61b35b7b16a1583469d9fc1b212c14a0f2e492023e09f41fb8dcaade9dd1cde3e310509de409a42bf9a468b1a0691d

+ 30 - 0
sys-block/blivet-gui/blivet-gui-2.4.3_alpha.ebuild

@@ -0,0 +1,30 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} )
+BLIVET_REV=db6a3ea9bdecf4c0cc536b9cd4528316569d27fb
+S="${WORKDIR}/${PN}-${BLIVET_REV}"
+
+inherit distutils-r1
+
+DESCRIPTION="Python module for system storage configuration"
+HOMEPAGE="https://github.com/storaged-project/blivet-gui"
+SRC_URI="https://github.com/storaged-project/blivet-gui/archive/${BLIVET_REV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+DEPEND="
+	sys-block/blivet
+	dev-python/pid
+"
+RDEPEND="
+	${DEPEND}
+"
+
+distutils_enable_tests unittest

+ 30 - 0
sys-block/blivet-gui/blivet-gui-9999.ebuild

@@ -0,0 +1,30 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit distutils-r1 git-r3
+
+DESCRIPTION="Python module for system storage configuration"
+HOMEPAGE="
+	https://github.com/storaged-project/blivet-gui
+"
+EGIT_REPO_URI="https://github.com/storaged-project/blivet-gui"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS=""
+
+DEPEND="
+	sys-block/blivet
+	dev-python/pid
+"
+RDEPEND="
+	${DEPEND}
+"
+
+distutils_enable_tests unittest

+ 1 - 0
sys-block/blivet/Manifest

@@ -0,0 +1 @@
+DIST blivet-3.8.2.tar.gz 584440 BLAKE2B 024eda5486dabeb8c486794d3648740dc369c7b73a280e4804aee60b695103611535a9d7a5a2ed20ac0c774876918c4e25fc34e0842ea64419a428009439e7fd SHA512 0e29d774e855000fefcaa33c91cb08d6fbc64d8674da2cf4a842a72bec748b499e086a829a172777279d822f635fc547750da0c40090b4e7aed0a079c615e4e2

+ 40 - 0
sys-block/blivet/blivet-3.8.2.ebuild

@@ -0,0 +1,40 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit distutils-r1
+
+DESCRIPTION="Python module for system storage configuration"
+HOMEPAGE="
+	https://github.com/storaged-project/blivet
+	https://pypi.org/project/blivet/
+"
+SRC_URI="
+	https://github.com/storaged-project/blivet/archive/refs/tags/${P}.tar.gz
+"
+S="${WORKDIR}/${PN}-${P}"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~alpha amd64 ~hppa ~ia64 ppc ppc64 sparc x86"
+
+DEPEND="
+	>=sys-block/parted-3.4
+	sys-libs/libblockdev[introspection]
+	dev-libs/libbytesize[python]
+	dev-python/pyudev
+	sys-fs/lvm2[dbus]
+"
+RDEPEND="
+	${DEPEND}
+"
+BDEPEND="
+	virtual/pkgconfig
+"
+
+distutils_enable_tests unittest

+ 2 - 0
sys-fs/lvm2/Manifest

@@ -0,0 +1,2 @@
+DIST LVM2.2.03.21.tgz 2742294 BLAKE2B 529bc01b3d1ba6207c9ddc95309b39e6293fcd0286334240b9fdc076da0b7bc7e026338ec0243564ec153f2fb5009014149c3f8e0db0cd47a29418af62068728 SHA512 6024811c3fa92afd2fc13a10d1c3542352aa9a016f40c3ef588bd2f5f3e41245fed4b36c8a87d9f7f8dddc6e13b7253396f5c811f99665df27751676dc7b5bde
+DIST LVM2.2.03.22.tgz 2755031 BLAKE2B 79bbea84bd82f111c1bb5de336e6a9f1368b2c9e43f075dccaa90c7746a364259ad278adf650379eca75f2803ed74e74dd372be2cca8518462182657f96a0033 SHA512 17cd24ceee8026481566824b688dafd03ec816201d5cb3549cb7fc8a36f4cdaa982faaef4dcd26debfe775dea5ffa2744798164314ea6dc99a84f8ccccfc33ff

+ 1 - 0
sys-fs/lvm2/files/device-mapper.conf-r4

@@ -0,0 +1 @@
+RC_AFTER="lvm"

+ 146 - 0
sys-fs/lvm2/files/device-mapper.rc-r3

@@ -0,0 +1,146 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+	# As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+	# means dmeventd is NOT notified, as it cannot be safely running
+	before dmeventd checkfs fsck
+	after modules
+}
+
+dm_in_proc() {
+	local retval=0
+	for x in devices misc ; do
+		grep -qs 'device-mapper' /proc/${x}
+		retval=$((${retval} + $?))
+	done
+	return ${retval}
+}
+
+# char **build_dmsetup_command(volume)
+#
+# Returns complete dmsetup command given single volume name
+build_dmsetup_command() {
+	local count dmsetup_cmd
+	
+	# Number of lines mentioning volume name
+	count=$(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | grep -c ${1})
+	
+	# If there's just one line:
+	if [ ${count} -eq 1 ] ; then
+		echo "echo $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+			  grep ${1} | awk '{$1=""; print $0}') | /sbin/dmsetup create ${1}"
+			  
+	# For all cases with more lines:
+	elif [ ${count} -gt 1 ] ; then
+		for c in $( seq 1 ${count} ) ; do
+			if [ ${c} -eq 1 ] ; then
+				# Heavy escaping in awk-statement because we cannot use apostrophes
+				dmsetup_cmd="echo -e $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+							 grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+			else
+				# Append starting with newline
+				dmsetup_cmd="${dmsetup_cmd}\\\\n \
+							 $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+							 grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+			fi
+		done
+		echo "${dmsetup_cmd} | /sbin/dmsetup create ${1}"
+	fi
+
+	return 0
+}
+
+# char **get_new_dm_volumes(void)
+#
+#   Return unique volumes from /etc/dmtab
+get_new_dm_volumes() {
+	local volume
+
+	# Filter comments and blank lines
+	grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+	awk '{ print $1 }' | \
+	uniq | \
+	while read volume ; do
+		# If it exists, skip it
+		dmvolume_exists "${volume%:}" && continue
+
+		echo "${volume%:}"
+	done
+
+	return 0
+}
+
+# int dmvolume_exists(volume)
+#
+#   Return true if volume exists in DM table
+dmvolume_exists() {
+	local x line volume=$1
+
+	[ -z "${volume}" ] && return 1
+
+	/sbin/dmsetup ls 2>/dev/null | \
+	while read line ; do
+		for x in ${line} ; do
+			# the following conditonal return only breaks out
+			# of the while loop, as it is running in a pipe.
+			[ "${x}" = "${volume}" ] && return 1
+			# We only want to check the volume name
+			break
+		done
+	done
+
+	# if 1 was returned from the above loop, then indicate that
+	# volume exists
+	[ $? = 1 ] && return 0
+
+	# otherwise the loop exited normally and the volume does not
+	# exist
+	return 1
+}
+
+# int is_empty_dm_volume(volume)
+#
+#   Return true if the volume exists in DM table, but is empty/non-valid
+is_empty_dm_volume() {
+	local table volume=$1
+
+	set -- $(/sbin/dmsetup table 2>/dev/null | grep -e "^${volume}:")
+	[ "${volume}" = "$1" -a -z "$2" ]
+}
+
+
+start() {
+	if [ -e /proc/modules ] && ! dm_in_proc ; then
+		modprobe dm-mod 2>/dev/null
+	fi
+	# Ensure the dirs exist for locking and running
+	checkpath -q -d -m 0700 -o root:root /run/lvm /run/lock/lvm
+
+	local x volume
+	
+	if [ -x /sbin/dmsetup -a -c /dev/mapper/control -a -f /etc/dmtab ] ; then
+		[ -n "$(get_new_dm_volumes)" ] && \
+			einfo " Setting up device-mapper volumes:"
+		
+		get_new_dm_volumes | \
+		while read x ; do
+			[ -n "${x}" ] || continue
+			
+			volume="${x##* }"
+			
+			ebegin "  Creating volume: ${volume}"
+			if ! eval $(build_dmsetup_command ${volume}) >/dev/null 2>/dev/null ; then
+				eend 1 "  Error creating volume: ${volume}"
+				# dmsetup still adds an empty volume in some cases,
+				#  so lets remove it
+				is_empty_dm_volume "${volume}" && \
+					/sbin/dmsetup remove "${volume}" 2>/dev/null
+			else
+				eend 0
+			fi
+		done
+	fi
+}
+

+ 21 - 0
sys-fs/lvm2/files/dmeventd.initd-r3

@@ -0,0 +1,21 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+command=/sbin/dmeventd
+command_args_foreground='-f'
+extra_started_commands=reload
+pidfile=/run/dmeventd.pid
+# Control idle exit behavior of daemon
+export DMEVENTD_IDLE_EXIT_TIMEOUT=${DMEVENTD_IDLE_EXIT_TIMEOUT:=-1}
+
+depend() {
+	# As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+	# means dmeventd is NOT notified, as it cannot be safely running
+	after lvm device-mapper
+}
+
+reload() {
+	# TODO: this is not supported under supervisors
+	${command} -R
+}

+ 11 - 0
sys-fs/lvm2/files/dmtab

@@ -0,0 +1,11 @@
+#/etc/dmraid: config file for adding device-mapper volumes at boot
+
+# Format: <volume name>: <table>
+# Example: isw0: 0 312602976 striped 2 128 /dev/sda 0 /dev/sdb 0
+#
+# Alternatively you can create all your volumes the first time, and just run:
+#
+#   dmsetup table >> /etc/dmtab
+#
+# and verify that they are correct.
+

+ 38 - 0
sys-fs/lvm2/files/lvm-monitoring.initd-r3

@@ -0,0 +1,38 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# This script is based on upstream file
+# LVM2.2.02.67/scripts/lvm2_monitoring_init_red_hat.in
+
+depend() {
+	# As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+	# means dmeventd is NOT notified, as it cannot be safely running
+	need lvm dmeventd
+}
+
+VGCHANGE=/sbin/vgchange
+VGS=/sbin/vgs
+
+start() {
+	ret=0
+	# TODO do we want to separate out already active groups only?
+	VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+	ebegin "Starting LVM monitoring for VGs ${VGSLIST}:"
+	$VGCHANGE --monitor y --poll y  ${VGSLIST}
+	ret=$?
+	eend $ret
+	return $ret
+
+}
+
+stop() {
+	ret=0
+	# TODO do we want to separate out already active groups only?
+	VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+	ebegin "Stopping LVM monitoring for VGs ${VGSLIST}:"
+	$VGCHANGE --monitor n ${VGSLIST}
+	ret=$?
+	eend $ret
+	return $ret
+}

+ 9 - 0
sys-fs/lvm2/files/lvm.confd-r4

@@ -0,0 +1,9 @@
+# If LVM is built with udev, you must ensure udev is running first!
+# Otherwise it will hang
+rc_need="udev"
+
+# LVM should normally only be started after mdraid is available
+# this is because LVM physical volumes are very often MD devices.
+rc_after="mdraid"
+
+# vim: ft=gentoo-conf-d

+ 173 - 0
sys-fs/lvm2/files/lvm.rc-r1

@@ -0,0 +1,173 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+_get_lvm_path() {
+	local lvm_path=
+	for lvm_path in /bin/lvm /sbin/lvm ; do
+		[ -x "${lvm_path}" ] && break
+	done
+	echo "${lvm_path}"
+}
+
+_use_lvmetad() {
+	local lvm_path="$(_get_lvm_path)"
+	[ ! -x "${lvm_path}" ] && return 1
+	${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
+}
+
+_use_lvmlockd() {
+	local lvm_path="$(_get_lvm_path)"
+	[ ! -x "${lvm_path}" ] && return 1
+	${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmlockd=1'
+}
+
+depend() {
+	before checkfs fsck
+	after modules device-mapper
+	# We may want lvmetad based on the configuration. If we added lvmetad
+	# support while lvm2 is running then we aren't dependent on it. For the
+	# more common case, if its disabled in the config we aren't dependent
+	# on it.
+	config /etc/lvm/lvm.conf
+	local _want=
+
+	if service_started ; then
+		_want=$(service_get_value want)
+	else
+		if _use_lvmetad ; then
+			_want="${_want} lvmetad"
+		fi
+
+		if _use_lvmlockd ; then
+			_want="${_want} lvmlockd"
+		fi
+	fi
+
+	# Make sure you review /etc/conf.d/lvm as well!
+	# Depending on your system, it might also introduce udev & mdraid
+	need sysfs
+
+	if [ -n "${_want}" ] ; then
+		want ${_want}
+	fi
+}
+
+config='global { locking_dir = "/run/lock/lvm" }'
+
+dm_in_proc() {
+	local retval=0
+	for x in devices misc ; do
+		grep -qs 'device-mapper' /proc/${x}
+		retval=$((${retval} + $?))
+	done
+	return ${retval}
+}
+
+start() {
+	# LVM support for /usr, /home, /opt ....
+	# This should be done *before* checking local
+	# volumes, or they never get checked.
+
+	# NOTE: Add needed modules for LVM or RAID, etc
+	#       to /etc/modules.autoload if needed
+
+	lvm_path="$(_get_lvm_path)"
+	if [ -z "${lvm_path}" ] ; then
+		eerror "Failed to find lvm binary in /bin or /sbin!"
+		return 1
+	fi
+
+	if [ -z "${CDBOOT}" ] ; then
+		if [ -e /proc/modules ] && ! dm_in_proc ; then
+			ebegin "Trying to load dm-mod module"
+			modprobe dm-mod 2>/dev/null
+			eend $?
+		fi
+
+		if [ -d /proc/lvm ] || dm_in_proc ; then
+			local has_errors=0 verbose_command
+
+			yesno "${rc_verbose}" && verbose_command=" -v"
+
+			ebegin "Starting the Logical Volume Manager"
+
+			if _use_lvmetad ; then
+				# Extra PV find pass because some devices might not have been available until very recently
+				${lvm_path} pvscan${verbose_command} --config "${config}" --cache
+				[ $? -ne 0 ] && has_errors=1
+			fi
+
+			# Now make the nodes
+			${lvm_path} vgscan${verbose_command} --config "${config}" --mknodes
+			[ $? -ne 0 ] && has_errors=1
+
+			# Enable all VGs
+			${lvm_path} vgchange${verbose_command} --config "${config}" --sysinit --activate y
+			[ $? -ne 0 ] && has_errors=1
+
+			if _use_lvmlockd ; then
+				# Start lockd VGs as required
+				${lvm_path} vgchange${verbose_command} --config "${config}" --lock-start --lock-opt auto
+				[ $? -ne 0 ] && has_errors=1
+			fi
+
+			eend ${has_errors} "Failed to start the Logical Volume Manager"
+		fi
+	fi
+}
+
+start_post() {
+	local _want=
+	if _use_lvmetad ; then
+		_want="${_want} lvmetad"
+	fi
+
+	if _use_lvmlockd ; then
+		_want="${_want} lvmlockd"
+	fi
+
+	service_set_value want "${_want}"
+}
+
+stop() {
+	lvm_path="$(_get_lvm_path)"
+	if [ -z "${lvm_path}" ] ; then
+		eerror "Failed to find lvm binary in /bin or /sbin!"
+		return 1
+	fi
+
+	# Stop LVM2
+	if [ -f /etc/lvmtab -o -d /etc/lvm ] \
+		&& [ -d /proc/lvm  -o "$(grep device-mapper /proc/misc 2>/dev/null)" ]
+	then
+		local VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
+		if [ -z "${VGS}" ] ; then
+			# nothing to do for us
+			return 0
+		fi
+
+		local has_errors=0 verbose_command eend_cmd="eend"
+
+		yesno "${rc_verbose}" && verbose_command=" -v"
+
+		local msg="Failed to stop Logical Volume Manager"
+		if [ "${RC_RUNLEVEL}" = shutdown ] ; then
+			# failures on shutdown are non-fatal
+			eend_cmd="ewend"
+			msg="${msg} (possibly some LVs still needed for /usr or root)"
+		fi
+
+		ebegin "Stopping the Logical Volume Manager"
+
+		${lvm_path} vgchange${verbose_command} --config "${config}" --sysinit --activate n
+		[ $? -ne 0 ] && has_errors=1
+
+		${eend_cmd} ${has_errors} "${msg}"
+	fi
+
+	# at this point make sure we always exit without indicating an error
+	return 0
+}
+
+# vim:ts=4

+ 11 - 0
sys-fs/lvm2/files/lvm2-2.03.20-dm_lvm_rules_no_systemd.patch

@@ -0,0 +1,11 @@
+--- a/udev/69-dm-lvm.rules.in
++++ b/udev/69-dm-lvm.rules.in
+@@ -76,7 +76,7 @@
+ # it's better suited to appearing in the journal.
+ 
+ IMPORT{program}="(LVM_EXEC)/lvm pvscan --cache --listvg --checkcomplete --vgonline --autoactivation event --udevoutput --journal=output $env{DEVNAME}"
+-ENV{LVM_VG_NAME_COMPLETE}=="?*", RUN+="(SYSTEMDRUN) --no-block --property DefaultDependencies=no --unit lvm-activate-$env{LVM_VG_NAME_COMPLETE} (LVM_EXEC)/lvm vgchange -aay --autoactivation event $env{LVM_VG_NAME_COMPLETE}"
++ENV{LVM_VG_NAME_COMPLETE}=="?*", RUN+="(LVM_EXEC)/lvm vgchange -aay --nohints --autoactivation event $env{LVM_VG_NAME_COMPLETE}"
+ GOTO="lvm_end"
+ 
+ LABEL="lvm_end"

+ 66 - 0
sys-fs/lvm2/files/lvm2-2.03.20-dmeventd-no-idle-exit.patch

@@ -0,0 +1,66 @@
+From ab3ae0a22dfbe20e2d17e7dc60e0f76184ec098c Mon Sep 17 00:00:00 2001
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Wed, 24 Jul 2019 11:22:32 +0200
+Subject: [PATCH] dmeventd configurable idle exit time
+
+dmeventd nominally exits after 1 hour of idle time. There are use cases for
+this, esp. with socket activation, but also cases where users don't expect
+dmeventd to exit.
+
+Provide a tuning knob via environment variable, DMEVENTD_IDLE_EXIT_TIMEOUT,
+that can be -1 to not exit, or a configurable time for different idle exit.
+
+Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
+Fixes: https://bugs.gentoo.org/682556
+--- a/daemons/dmeventd/dmeventd.c
++++ b/daemons/dmeventd/dmeventd.c
+@@ -2169,6 +2169,18 @@
+ 		.server_path = DM_EVENT_FIFO_SERVER
+ 	};
+ 	time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
++
++	/* Provide a basic way to config the idle timeout */
++	char* idle_exit_timeout_env = getenv("DMEVENTD_IDLE_EXIT_TIMEOUT") ? : NULL;
++	if(NULL != idle_exit_timeout_env) {
++		char* endptr;
++		idle_exit_timeout = strtol(idle_exit_timeout_env, &endptr, 10);
++		if (errno == ERANGE || *endptr != '\0') {
++			fprintf(stderr, "DMEVENTD_IDLE_EXIT_TIMEOUT: bad time input\n");
++			exit(EXIT_FAILURE);
++		}
++	}
++
+ 	opterr = 0;
+ 	optind = 0;
+ 
+@@ -2265,7 +2277,7 @@
+ 		_process_initial_registrations();
+ 
+ 	for (;;) {
+-		if (_idle_since) {
++		if (_idle_since || _exit_now) {
+ 			if (_exit_now) {
+ 				if (_exit_now == DM_SCHEDULED_EXIT)
+ 					break; /* Only prints shutdown message */
+@@ -2274,7 +2286,7 @@
+ 					 (long) (time(NULL) - _idle_since));
+ 				break;
+ 			}
+-			if (idle_exit_timeout) {
++			if (idle_exit_timeout && idle_exit_timeout > 0) {
+ 				now = time(NULL);
+ 				if (now < _idle_since)
+ 					_idle_since = now; /* clock change? */
+--- a/man/dmeventd.8_main
++++ b/man/dmeventd.8_main
+@@ -169,6 +169,10 @@
+ Variable is set by thin and vdo plugin to prohibit recursive interaction
+ with dmeventd by any executed lvm2 command from
+ a thin_command, vdo_command environment.
++.TP
++.B DMEVENTD_IDLE_EXIT_TIMEOUT
++Configure the dmeventd idle exit timeout behavior, value in seconds. Default
++is 3600 (1 hour). -1 means do not exit.
+ .
+ .SH SEE ALSO
+ .

+ 42 - 0
sys-fs/lvm2/files/lvm2-2.03.20-example.conf.in.patch

@@ -0,0 +1,42 @@
+Add Gentoo specific changes
+
+--- a/conf/example.conf.in
++++ b/conf/example.conf.in
+@@ -170,6 +170,9 @@
+ 	# Example
+ 	# Accept every block device:
+ 	# filter = [ "a|.*|" ]
++	# Gentoo: we exclude /dev/nbd by default, because it makes a lot of kernel
++	# noise when you probed while not available.
++	filter = [ "r|/dev/nbd.*|", "a|.*|" ]
+ 	# Reject the cdrom drive:
+ 	# filter = [ "r|/dev/cdrom|" ]
+ 	# Work with just loopback devices, e.g. for testing:
+@@ -1843,7 +1846,7 @@
+ 
+ # Configuration section metadata.
+ # This configuration section has an automatic default value.
+-# metadata {
++metadata {
+ 
+ 	# Configuration option metadata/check_pv_device_sizes.
+ 	# Check device sizes are not smaller than corresponding PV sizes.
+@@ -1888,7 +1891,8 @@
+ 	#
+ 	# This configuration option is advanced.
+ 	# This configuration option has an automatic default value.
+-	# pvmetadatacopies = 1
++	# Gentoo: enable for data safety, but PV resize is then disabled.
++	# pvmetadatacopies = 2
+ 
+ 	# Configuration option metadata/vgmetadatacopies.
+ 	# Number of copies of metadata to maintain for each VG.
+@@ -1931,7 +1935,7 @@
+ 	# This configuration option is advanced.
+ 	# This configuration option has an automatic default value.
+ 	# stripesize = 64
+-# }
++}
+ 
+ # Configuration section report.
+ # LVM report command output formatting.

+ 54 - 0
sys-fs/lvm2/files/lvm2-2.03.20-freopen-musl.patch

@@ -0,0 +1,54 @@
+From 4cf08811e112100a2b10c60047f3c537ad21d674 Mon Sep 17 00:00:00 2001
+From: David Seifert <soap@gentoo.org>
+Date: Sat, 28 Jan 2023 14:22:42 +0100
+Subject: [PATCH] Use `freopen()` on {stdin,stdout,stderr}
+
+* ISO C does not guarantee that the standard streams are modifiable
+  lvalues. Glibc even calls out this behaviour as non-portable:
+    https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html
+--- a/lib/log/log.c
++++ b/lib/log/log.c
+@@ -208,7 +208,11 @@ int reopen_standard_stream(FILE **stream, const char *mode)
+ 
+ 	_check_and_replace_standard_log_streams(old_stream, new_stream);
+ 
++#ifdef __GLIBC__
+ 	*stream = new_stream;
++#else
++	freopen(NULL, mode, *stream);
++#endif
+ 	return 1;
+ }
+ 
+--- a/tools/lvmcmdline.c
++++ b/tools/lvmcmdline.c
+@@ -3422,7 +3422,7 @@ static int _check_standard_fds(void)
+ 	int err = is_valid_fd(STDERR_FILENO);
+ 
+ 	if (!is_valid_fd(STDIN_FILENO) &&
+-	    !(stdin = fopen(_PATH_DEVNULL, "r"))) {
++	    !freopen(_PATH_DEVNULL, "r", stdin)) {
+ 		if (err)
+ 			perror("stdin stream open");
+ 		else
+@@ -3432,7 +3432,7 @@ static int _check_standard_fds(void)
+ 	}
+ 
+ 	if (!is_valid_fd(STDOUT_FILENO) &&
+-	    !(stdout = fopen(_PATH_DEVNULL, "w"))) {
++	    !freopen(_PATH_DEVNULL, "w", stdout)) {
+ 		if (err)
+ 			perror("stdout stream open");
+ 		/* else no stdout */
+@@ -3440,7 +3440,7 @@ static int _check_standard_fds(void)
+ 	}
+ 
+ 	if (!is_valid_fd(STDERR_FILENO) &&
+-	    !(stderr = fopen(_PATH_DEVNULL, "w"))) {
++	    !freopen(_PATH_DEVNULL, "w", stderr)) {
+ 		printf("stderr stream open: %s\n",
+ 		       strerror(errno));
+ 		return 0;
+-- 
+2.39.2
+

+ 12 - 0
sys-fs/lvm2/files/lvm2-2.03.22-mkdir-lockfile.patch

@@ -0,0 +1,12 @@
+diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
+index 27b869c..206d495 100644
+--- a/daemons/lvmdbusd/utils.py
++++ b/daemons/lvmdbusd/utils.py
+@@ -778,6 +778,7 @@ class LockFile(object):
+ 
+ 	def __enter__(self):
+ 		try:
++			os.makedirs(os.path.dirname(self.lock_file), exist_ok=True)
+ 			self.fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, stat.S_IRUSR | stat.S_IWUSR)
+ 
+ 			# Get and set the close on exec and lock the file

+ 17 - 0
sys-fs/lvm2/files/lvmlockd.initd-r2

@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+pidfile="/run/lvmlockd.pid"
+command="/sbin/lvmlockd"
+command_args="${LVMLOCKD_OPTS:--p ${pidfile}} ${LVMLOCKD_TYPE:--g sanlock}"
+start_stop_daemon_args="--pidfile ${pidfile}"
+
+depend() {
+	before sanlock
+}
+
+start_pre()
+{
+	checkpath --directory /run/lvm || return 1
+}

+ 17 - 0
sys-fs/lvm2/files/lvmpolld.initd-r1

@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+pidfile="/run/lvmpolld.pid"
+command="/sbin/lvmpolld"
+command_args="${LVMPOLLD_OPTS:=-p ${pidfile}}"
+start_stop_daemon_args="--pidfile ${pidfile}"
+
+depend() {
+	:
+}
+
+start_pre()
+{
+	checkpath --directory /run/lvm || return 1
+}

+ 307 - 0
sys-fs/lvm2/lvm2-2.03.22-r2.ebuild

@@ -0,0 +1,307 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+TMPFILES_OPTIONAL=1
+inherit autotools linux-info systemd toolchain-funcs tmpfiles udev flag-o-matic
+
+DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
+HOMEPAGE="https://sourceware.org/lvm2/"
+SRC_URI="https://sourceware.org/ftp/lvm2/${PN^^}.${PV}.tgz"
+S="${WORKDIR}/${PN^^}.${PV}"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm arm64 ~loong ~mips ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux"
+IUSE="dbus lvm readline sanlock selinux static static-libs systemd thin +udev valgrind"
+REQUIRED_USE="
+	static? ( !systemd !udev )
+	static-libs? ( static !udev )
+	systemd? ( udev )
+	thin? ( lvm )
+"
+
+DEPEND_COMMON="
+	udev? ( virtual/libudev:= )
+	lvm? (
+		dev-libs/libaio
+		sys-apps/util-linux
+		readline? ( sys-libs/readline:= )
+		sanlock? ( sys-cluster/sanlock )
+		systemd? ( sys-apps/systemd:= )
+	)
+"
+# /run is now required for locking during early boot. /var cannot be assumed to
+# be available -- thus, pull in recent enough baselayout for /run.
+# This version of LVM is incompatible with cryptsetup <1.1.2.
+RDEPEND="
+	${DEPEND_COMMON}
+	>=sys-apps/baselayout-2.2
+	lvm? (
+		virtual/tmpfiles
+		thin? ( >=sys-block/thin-provisioning-tools-1.0.6 )
+	)
+"
+# note: thin-0.3.0 is required to avoid --disable-thin_check_needs_check
+DEPEND="
+	${DEPEND_COMMON}
+	static? (
+		sys-apps/util-linux[static-libs]
+		lvm? (
+			dev-libs/libaio[static-libs]
+			readline? ( sys-libs/readline[static-libs] )
+		)
+		selinux? ( sys-libs/libselinux[static-libs] )
+	)
+	valgrind? ( >=dev-util/valgrind-3.6 )
+"
+BDEPEND="
+	sys-devel/autoconf-archive
+	virtual/pkgconfig
+"
+
+PATCHES=(
+	# Gentoo specific modification(s):
+	"${FILESDIR}"/${PN}-2.03.20-example.conf.in.patch
+
+	# For upstream -- review and forward:
+	"${FILESDIR}"/${PN}-2.03.20-dmeventd-no-idle-exit.patch
+	"${FILESDIR}"/${PN}-2.03.20-freopen-musl.patch
+	"${FILESDIR}"/${PN}-2.03.22-mkdir-lockfile.patch
+)
+
+pkg_setup() {
+	local CONFIG_CHECK="~SYSVIPC"
+
+	if use udev; then
+		local WARNING_SYSVIPC="CONFIG_SYSVIPC:\tis not set (required for udev sync)\n"
+		if linux_config_exists; then
+			local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
+			if [[ -n "${uevent_helper_path}" ]] && [[ "${uevent_helper_path}" != '""' ]]; then
+				ewarn "It's recommended to set an empty value to the following kernel config option:"
+				ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
+			fi
+		fi
+	fi
+
+	check_extra_config
+
+	# 1. Genkernel no longer copies /sbin/lvm blindly.
+	if use static; then
+		elog "Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with"
+		elog "their static versions. If you need the static binaries,"
+		elog "you must append .static to the filename!"
+	fi
+}
+
+src_prepare() {
+	default
+
+	# Users without systemd get no auto-activation of any logical volume
+	if ! use systemd ; then
+		eapply "${FILESDIR}"/${PN}-2.03.20-dm_lvm_rules_no_systemd.patch
+	fi
+
+	eautoreconf
+}
+
+src_configure() {
+	filter-lto
+
+	# Workaround for bug #822210
+	tc-ld-disable-gold
+
+	# Most of this package does weird stuff.
+	# The build options are tristate, and --without is NOT supported
+	# options: 'none', 'internal', 'shared'
+	local myeconfargs=(
+		$(use_enable lvm dmfilemapd)
+		$(use_enable lvm dmeventd)
+		$(use_enable lvm cmdlib)
+		$(use_enable lvm fsadm)
+		$(use_enable lvm lvmpolld)
+
+		# This only causes the .static versions to become available
+		$(usev static --enable-static_link)
+
+		# dmeventd requires mirrors to be internal, and snapshot available
+		# so we cannot disable them
+		--with-mirrors="$(usex lvm internal none)"
+		--with-snapshots="$(usex lvm internal none)"
+	)
+
+	if use lvm && use thin; then
+		myeconfargs+=( --with-thin=internal --with-cache=internal )
+		local texec
+		for texec in check dump repair restore; do
+			myeconfargs+=( --with-thin-${texec}="${EPREFIX}"/sbin/thin_${texec} )
+			myeconfargs+=( --with-cache-${texec}="${EPREFIX}"/sbin/cache_${texec} )
+		done
+	else
+		myeconfargs+=( --with-thin=none --with-cache=none )
+	fi
+
+	myeconfargs+=(
+		# musl doesn't do symbol versioning so can end up with
+		# runtime breakage.
+		--with-symvers=$(usex elibc_glibc 'gnu' 'no')
+		$(use_enable readline)
+		$(use_enable selinux)
+		--enable-pkgconfig
+		--with-confdir="${EPREFIX}"/etc
+		--exec-prefix="${EPREFIX}"
+		--sbindir="${EPREFIX}/sbin"
+		--with-staticdir="${EPREFIX}"/sbin
+		--libdir="${EPREFIX}/$(get_libdir)"
+		--with-usrlibdir="${EPREFIX}/usr/$(get_libdir)"
+		--with-default-dm-run-dir=/run
+		--with-default-run-dir=/run/lvm
+		--with-default-locking-dir=/run/lock/lvm
+		--with-default-pid-dir=/run
+		$(use_enable dbus dbus-service)
+		$(use_enable udev udev_rules)
+		$(use_enable udev udev_sync)
+		$(use_with udev udevdir "${EPREFIX}$(get_udevdir)"/rules.d)
+		# USE=sanlock requires USE=lvm
+		$(use_enable $(usex lvm sanlock lvm) lvmlockd-sanlock)
+		$(use_enable systemd notify-dbus)
+		$(use_enable systemd app-machineid)
+		$(use_enable systemd systemd-journal)
+		$(use_with systemd systemd-run "/usr/bin/systemd-run")
+		$(use_enable valgrind valgrind-pool)
+		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
+		CLDFLAGS="${LDFLAGS}"
+	)
+
+	econf "${myeconfargs[@]}"
+}
+
+src_compile() {
+	emake V=1 -C include
+
+	if use lvm ; then
+		emake V=1
+		emake V=1 CC="$(tc-getCC)" -C scripts
+	else
+		emake V=1 device-mapper
+		# https://bugs.gentoo.org/878131
+		emake V=1 -C libdm/dm-tools device-mapper
+	fi
+}
+
+src_test() {
+	einfo "Tests are disabled because of device-node mucking, if you want to"
+	einfo "run tests, compile the package and see ${S}/tests"
+}
+
+src_install() {
+	local targets=()
+	if use lvm; then
+		targets+=( install install_tmpfiles_configuration )
+		if use systemd; then
+			# install systemd related files only when requested, bug #522430
+			targets+=( install_systemd_units )
+		fi
+	else
+		targets+=( install_device-mapper )
+	fi
+
+	# -j1 for bug #918125
+	emake -j1 V=1 DESTDIR="${D}" "${targets[@]}"
+
+	newinitd "${FILESDIR}"/device-mapper.rc-r3 device-mapper
+	newconfd "${FILESDIR}"/device-mapper.conf-r4 device-mapper
+
+	if use lvm ; then
+		newinitd "${FILESDIR}"/dmeventd.initd-r3 dmeventd
+		newinitd "${FILESDIR}"/lvm.rc-r1 lvm
+		newconfd "${FILESDIR}"/lvm.confd-r4 lvm
+		if ! use udev ; then
+			# We keep the variable but remove udev from it.
+			sed -r -i \
+				-e '/^rc_need=/s/\<udev\>//g' \
+				"${ED}"/etc/conf.d/lvm || die "Could not drop udev from rc_need"
+		fi
+
+		newinitd "${FILESDIR}"/lvm-monitoring.initd-r3 lvm-monitoring
+		newinitd "${FILESDIR}"/lvmpolld.initd-r1 lvmpolld
+
+		if use sanlock; then
+			newinitd "${FILESDIR}"/lvmlockd.initd-r2 lvmlockd
+		fi
+	fi
+
+	if use static-libs; then
+		dolib.a libdm/ioctl/libdevmapper.a
+		if use lvm; then
+			# depends on lvmetad
+			dolib.a libdaemon/client/libdaemonclient.a #462908
+			# depends on dmeventd
+			dolib.a daemons/dmeventd/libdevmapper-event.a
+		fi
+	else
+		rm -f "${ED}"/usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a || die
+	fi
+
+	insinto /etc
+	doins "${FILESDIR}"/dmtab
+
+	dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
+}
+
+pkg_preinst() {
+	HAD_LVM=0
+
+	if has_version 'sys-fs/lvm2[lvm(+)]' ; then
+		HAD_LVM=1
+	fi
+}
+
+pkg_postinst() {
+	use lvm && tmpfiles_process lvm2.conf
+	use udev && udev_reload
+
+	# This is a new installation
+	if [[ -z "${REPLACING_VERSIONS}" ]]; then
+		if use lvm ; then
+			ewarn "Make sure the \"lvm\" init script is in the runlevels:"
+			ewarn "# rc-update add lvm boot"
+			ewarn
+			ewarn "Make sure to enable lvmetad in ${EROOT}/etc/lvm/lvm.conf if you want"
+			ewarn "to enable lvm autoactivation and metadata caching."
+		else
+			ewarn "Please enable USE=lvm if you need the LVM daemon and"
+			ewarn "tools like 'lvchange', 'vgchange', etc!"
+		fi
+	else
+		if ! use lvm && [[ ${HAD_LVM} -eq 1 ]] ; then
+			ewarn "LVM was previously enabled but is now disabled."
+			ewarn "Please enable USE=lvm if you need the LVM daemon and"
+			ewarn "tools like 'lvchange', 'vgchange', etc!"
+			ewarn "See the 2022-11-19-lvm2-default-USE-flags news item for more details."
+		fi
+	fi
+
+	if use udev && [[ -d /run ]] ; then
+		local permission_run_expected="drwxr-xr-x"
+		local permission_run=$(stat -c "%A" /run)
+		if [[ "${permission_run}" != "${permission_run_expected}" ]] ; then
+			ewarn "Found the following problematic permissions:"
+			ewarn ""
+			ewarn "    ${permission_run} /run"
+			ewarn ""
+			ewarn "Expected:"
+			ewarn ""
+			ewarn "    ${permission_run_expected} /run"
+			ewarn ""
+			ewarn "This is known to cause problems for udev-enabled LVM services."
+		fi
+	fi
+}
+
+pkg_postrm() {
+	if use udev && [[ -z ${REPLACED_BY_VERSION} ]]; then
+		udev_reload
+	fi
+}

+ 22 - 0
sys-fs/lvm2/metadata.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="project">
+		<email>base-system@gentoo.org</email>
+		<name>Gentoo Base System</name>
+	</maintainer>
+	<use>
+		<flag name="thin">Support for thin volumes</flag>
+		<flag name="lvm">
+			Build all of LVM2 including daemons and tools like lvchange, not just the device-mapper library (for other packages to use).
+
+			If your system uses LVM2 for managing disks and partitions, enable this flag.
+		</flag>
+		<flag name="sanlock">Enable lvmlockd with support for sanlock</flag>
+	</use>
+	<upstream>
+		<remote-id type="cpe">cpe:/a:heinz_mauelshagen:lvm2</remote-id>
+		<remote-id type="github">lvmteam/lvm2</remote-id>
+		<remote-id type="gitlab">lvmteam/lvm2</remote-id>
+	</upstream>
+</pkgmetadata>