lvm2: upgraded package to upstream

Upgraded sys-fs/lvm2 to version 2.02.187-r2 on amd64, arm

BUG=chromium:1026982
TEST=Run platform.DMVerity.unstable_kernel, CQ Dryrun.

Cq-Depend: chromium:2207999
Change-Id: I0ef0eb2e06f295ba08536a9578afe0b221e2a296
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2207686
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
diff --git a/metadata/md5-cache/sys-fs/lvm2-2.02.145-r2 b/metadata/md5-cache/sys-fs/lvm2-2.02.145-r2
deleted file mode 100644
index 708f79e..0000000
--- a/metadata/md5-cache/sys-fs/lvm2-2.02.145-r2
+++ /dev/null
@@ -1,14 +0,0 @@
-DEFINED_PHASES=compile configure install postinst prepare setup test
-DEPEND=clvm? ( cman? ( =sys-cluster/cman-3* ) corosync? ( sys-cluster/corosync ) openais? ( sys-cluster/openais ) =sys-cluster/libdlm-3* ) readline? ( sys-libs/readline:0= ) systemd? ( >=sys-apps/systemd-205:0= ) udev? ( >=virtual/libudev-208:=[static-libs?] ) virtual/pkgconfig >=sys-devel/binutils-2.20.1-r1 sys-devel/autoconf-archive static? ( selinux? ( sys-libs/libselinux[static-libs] ) udev? ( >=sys-fs/eudev-3.1.2[static-libs] ) >=sys-apps/util-linux-2.16[static-libs] ) >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4 virtual/pkgconfig virtual/pkgconfig
-DESCRIPTION=User-land utilities for LVM2 (device-mapper) software
-EAPI=6
-HOMEPAGE=https://sourceware.org/lvm2/
-IUSE=readline static static-libs systemd clvm cman corosync lvm1 lvm2create_initrd openais selinux +udev +thin device-mapper-only kernel_linux
-KEYWORDS=*
-LICENSE=GPL-2
-RDEPEND=clvm? ( cman? ( =sys-cluster/cman-3* ) corosync? ( sys-cluster/corosync ) openais? ( sys-cluster/openais ) =sys-cluster/libdlm-3* ) readline? ( sys-libs/readline:0= ) systemd? ( >=sys-apps/systemd-205:0= ) udev? ( >=virtual/libudev-208:=[static-libs?] ) >=sys-apps/baselayout-2.2 !<sys-apps/openrc-0.11 !<sys-fs/cryptsetup-1.1.2 !!sys-fs/clvm !!sys-fs/lvm-user >=sys-apps/util-linux-2.16 lvm2create_initrd? ( sys-apps/makedev ) thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )
-REQUIRED_USE=device-mapper-only? ( !clvm !cman !corosync !lvm1 !lvm2create_initrd !openais !thin ) systemd? ( udev ) clvm? ( !systemd )
-SLOT=0
-SRC_URI=ftp://sourceware.org/pub/lvm2/LVM2.2.02.145.tgz ftp://sourceware.org/pub/lvm2/old/LVM2.2.02.145.tgz
-_eclasses_=autotools	d0e5375d47f4c809f406eb892e531513	eapi7-ver	756b3f27d8e46131d5cf3c51bd876446	eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	linux-info	6accc0e19163336db48a3c346993eb16	multilib	b2f01ad412baf81650c23fcf0975fa33	systemd	71fd8d2065d102753fb9e4d20eaf3e9f	toolchain-funcs	209edad4a5c4812e7b2f8021650974f0	udev	452708c3f55cf6e918b045adb949a9e6
-_md5_=10846a569ce5bec5231b250499735a34
diff --git a/metadata/md5-cache/sys-fs/lvm2-2.02.187-r2 b/metadata/md5-cache/sys-fs/lvm2-2.02.187-r2
new file mode 100644
index 0000000..82fe713
--- /dev/null
+++ b/metadata/md5-cache/sys-fs/lvm2-2.02.187-r2
@@ -0,0 +1,15 @@
+BDEPEND=sys-devel/autoconf-archive virtual/pkgconfig >=app-portage/elt-patches-20170815 virtual/pkgconfig virtual/pkgconfig
+DEFINED_PHASES=compile configure install postinst prepare setup test
+DEPEND=dev-libs/libaio[static-libs?] static? ( dev-libs/libaio[static-libs] ) !static? ( dev-libs/libaio[static-libs?] ) readline? ( sys-libs/readline:0= ) sanlock? ( sys-cluster/sanlock ) systemd? ( >=sys-apps/systemd-205:0= ) udev? ( >=virtual/libudev-208:=[static-libs(-)?] ) >=sys-devel/binutils-2.20.1-r1 static? ( selinux? ( sys-libs/libselinux[static-libs] ) udev? ( >=sys-fs/eudev-3.1.2[static-libs] ) >=sys-apps/util-linux-2.16[static-libs] ) !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4
+DESCRIPTION=User-land utilities for LVM2 (device-mapper) software
+EAPI=7
+HOMEPAGE=https://sourceware.org/lvm2/
+IUSE=readline static static-libs systemd lvm2create_initrd sanlock selinux +udev +thin device-mapper-only kernel_linux
+KEYWORDS=*
+LICENSE=GPL-2
+RDEPEND=dev-libs/libaio[static-libs?] static? ( dev-libs/libaio[static-libs] ) !static? ( dev-libs/libaio[static-libs?] ) readline? ( sys-libs/readline:0= ) sanlock? ( sys-cluster/sanlock ) systemd? ( >=sys-apps/systemd-205:0= ) udev? ( >=virtual/libudev-208:=[static-libs(-)?] ) >=sys-apps/baselayout-2.2 !<sys-apps/openrc-0.11 !<sys-fs/cryptsetup-1.1.2 !!sys-fs/lvm-user >=sys-apps/util-linux-2.16 lvm2create_initrd? ( sys-apps/makedev ) thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )
+REQUIRED_USE=device-mapper-only? ( !lvm2create_initrd !sanlock !thin ) systemd? ( udev )
+SLOT=0
+SRC_URI=ftp://sourceware.org/pub/lvm2/LVM2.2.02.187.tgz ftp://sourceware.org/pub/lvm2/old/LVM2.2.02.187.tgz
+_eclasses_=autotools	d0e5375d47f4c809f406eb892e531513	eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	linux-info	6accc0e19163336db48a3c346993eb16	multilib	b2f01ad412baf81650c23fcf0975fa33	systemd	71fd8d2065d102753fb9e4d20eaf3e9f	toolchain-funcs	209edad4a5c4812e7b2f8021650974f0	udev	452708c3f55cf6e918b045adb949a9e6
+_md5_=8f996e2681c3c15fd328381618d32ceb
diff --git a/sys-fs/lvm2/Manifest b/sys-fs/lvm2/Manifest
index 58bfa8b..a94c173 100644
--- a/sys-fs/lvm2/Manifest
+++ b/sys-fs/lvm2/Manifest
@@ -1 +1 @@
-DIST LVM2.2.02.145.tgz 1986370 SHA256 98b7c4c07c485a462c6a86e1a5265757133ceea36289ead8a419af29ef39560b SHA512 84e28b3efc940837ea9da70fce620744aea0945ba29383b76ad7bcd4b5259b897c714162a8e8b7cfe26ae736a3ad2eca633a3e0df4d6280a32b28bd4cf472d27 WHIRLPOOL b8c6f4b737625547d4c2994d055f3334e2954f160d10840f1405b6a78f25fc17ba1d270f574408c151140e2afceb007cbfa1c146ed105bbdeca001a03368d549
+DIST LVM2.2.02.187.tgz 2405544 BLAKE2B be804be3c64927a8848e8ea8de228fb563b6f8c22628b785aabb33fc993629e5370788216bd814246aeb3a5546fd5446383ce24342e716579887556edf2bbed2 SHA512 3ce56f0c0d2e7dbcdae5be263199f73ee5c4c052599d53cde9b16500a326d0340893344f4671839be06b5b4225d592175d01c9974db14f2dc220d6e9a1d47e91
diff --git a/sys-fs/lvm2/files/clvmd.confd-2.02.39 b/sys-fs/lvm2/files/clvmd.confd-2.02.39
deleted file mode 100644
index 5782170..0000000
--- a/sys-fs/lvm2/files/clvmd.confd-2.02.39
+++ /dev/null
@@ -1,9 +0,0 @@
-# CLVMD_CLUSTER_TIMEOUT -- amount of time to wait for cluster quorum.
-
-CLVMD_CLUSTER_TIMEOUT=30
-
-
-# CLVMD_NODES_TIMEOUT -- amount of time to wait for the other nodes to
-# join the cluster.
-
-CLVMD_NODES_TIMEOUT=60
diff --git a/sys-fs/lvm2/files/clvmd.rc-2.02.39 b/sys-fs/lvm2/files/clvmd.rc-2.02.39
deleted file mode 100644
index efadd89..0000000
--- a/sys-fs/lvm2/files/clvmd.rc-2.02.39
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-[ -x /usr/sbin/clvmd ] && CLVMD_BIN="/usr/sbin/clvmd" || CLVMD_BIN="/sbin/clvmd"
-
-[ -z "$CLVMD_CLUSTER_TIMEOUT" ] && CLVMD_CLUSTER_TIMEOUT=30
-[ -n "$CLVMD_NODES_TIMEOUT" ] || CLVMD_NODES_TIMEOUT=60
-
-VGCHANGE="/sbin/vgchange"
-VGSCAN="/sbin/vgscan"
-VGDISPLAY="/sbin/vgdisplay"
-CLVMD_PIDFILE="/var/run/clvmd.pid"
-
-depend() {
-	use net dns logger dmeventd
-	want cman corosync openais
-}
-
-load_modules() {
-	local module modules
-	modules=$1
-	
-	for module in ${modules}; do
-		ebegin "Loading ${module} kernel module"
-		modprobe ${module}
-		eend $? "Failed to load ${module} kernel module"
-	done
-}
-
-unload_modules() {
-	local module modules
-	modules=$1
-	
-	for module in ${modules}; do
-		ebegin "Unloading ${module} kernel module"
-		modprobe -r ${module}
-		eend $? "Failed to unload ${module} kernel module"
-	done
-}
-
-umount_gfs_filesystems() {
-	local sig retry
-	local remaining="$(awk '$3 == "gfs" { print $2 }' /proc/mounts | sort -r)"
-
-	if [ -n "${remaining}" ]
-	then
-	        sig=
-	        retry=3
-	        while [ -n "${remaining}" -a "${retry}" -gt 0 ]
-	        do
-	                if [ "${retry}" -lt 3 ]
-			then
-	                        ebegin "Unmounting GFS filesystems (retry)"
-	                        umount ${remaining} &>/dev/null
-	                        eend $? "Failed to unmount GFS filesystems this retry"
-	                else
-	                        ebegin "Unmounting GFS filesystems"
-	                        umount ${remaining} &>/dev/null
-	                        eend $? "Failed to unmount GFS filesystems"
-	                fi
-	                remaining="$(awk '$3 == "gfs" { print $2 }' /proc/mounts | sort -r)"
-	                [ -z "${remaining}" ] && break
-	                /bin/fuser -k -m ${sig} ${remaining} &>/dev/null
-	                sleep 5
-	                retry=$((${retry} -1))
-	                sig=-9
-	        done
-	fi
-}
-
-
-start_volumes() {
-	ebegin "Scanning LVM volumes"
-	$VGSCAN > /dev/null 2>&1
-	eend $?
-
-	ret=$?
-	if [ "$ret" -eq 5 ]
-	then
-		einfo "  Waiting for other nodes to join the cluster ($CLVMD_NODES_TIMEOUT seconds)"
-	fi
-
-	clustervgs=`$VGDISPLAY 2> /dev/null | awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'`
-	for vg in $clustervgs; do
-		ebegin "  Activating Clustered VG: ${vg} "
-
-		wait=0
-		while [ -n "$($VGCHANGE -a y ${vg} 2>&1 |grep "clvmd not running")" ]; do
-			if [ $wait -lt $CLVMD_NODES_TIMEOUT ]; then
-				sleep 3
-				wait=$(($wait + 3))
-			else
-				eend 1
-			fi
-		done
-		eend 0
-	done
-}
-
-stop_volumes() {
-	# Deactivate only clustered volumes
-	clustervgs=`$VGDISPLAY 2> /dev/null | awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'`
-	for vg in $clustervgs; do
-		ebegin "  Shutting Down Clustered VG: ${vg} "
-		$VGCHANGE -anl ${vg} >/dev/null
-		eend $?
-	done
-}
-
-
-start() {
-	local module=$(awk '$1 == "dm_mod" { print $1 }' /proc/{modules,devices})
-
-	if [ -z "${module}" ]; then
-		load_modules "dm-mod"
-		sleep 1s
-	fi
-
-	ebegin "Starting clvmd ($CLVMD_CLUSTER_TIMEOUT seconds)"
-
-	start-stop-daemon --start --quiet --exec ${CLVMD_BIN} -- -T ${CLVMD_CLUSTER_TIMEOUT}
-	eend $?
-
-	start_volumes
-}
-
-stop() {
-
-	# umount GFS filesystems
-	umount_gfs_filesystems
-
-	#stop_volumes
-
-	ebegin "Stopping clvmd"
-	#start-stop-daemon --stop -s TERM --quiet --exec ${CLVMD_BIN} --name clvmd
-	killall -TERM ${CLVMD_BIN} >/dev/null
-	eend $?
-
-        #local module=$(awk '$1 == "dm_mod" { print $1 }' /proc/modules)
-
-	#if [[ "$?" -eq 0 && ! -z "${module}" ]]; then
-        #        unload_modules "dm-mod"
-        #fi
-}
diff --git a/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2 b/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2
index 7dbacce..79fdff2 100644
--- a/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2
+++ b/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 depend() {
diff --git a/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2 b/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2
new file mode 100644
index 0000000..bc08c0a
--- /dev/null
+++ b/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2
@@ -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
+}
diff --git a/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1 b/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1
deleted file mode 100644
index 930e84b..0000000
--- a/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-PIDFILE=/run/dmeventd.pid
-BIN=/sbin/dmeventd
-
-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
-}
-
-start() {
-	ebegin "Starting dmeventd"
-	start-stop-daemon --start --exec $BIN --pidfile $PIDFILE
-	eend $?
-}
-
-stop() {
-	ebegin "Stopping dmeventd"
-	start-stop-daemon --stop --exec $BIN --pidfile $PIDFILE
-	eend $?
-}
-
diff --git a/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2 b/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2
index d603718..914d663 100644
--- a/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2
+++ b/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # This script is based on upstream file
diff --git a/sys-fs/lvm2/files/lvm.confd-2.02.184-r3 b/sys-fs/lvm2/files/lvm.confd-2.02.184-r3
new file mode 100644
index 0000000..b29e170
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.confd-2.02.184-r3
@@ -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
diff --git a/sys-fs/lvm2/files/lvm.confd-2.02.28-r2 b/sys-fs/lvm2/files/lvm.confd-2.02.28-r2
deleted file mode 100644
index 2fbd866..0000000
--- a/sys-fs/lvm2/files/lvm.confd-2.02.28-r2
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.105-r2 b/sys-fs/lvm2/files/lvm.rc-2.02.105-r2
deleted file mode 100644
index c59f9c3..0000000
--- a/sys-fs/lvm2/files/lvm.rc-2.02.105-r2
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-depend() {
-	before checkfs fsck
-	after modules device-mapper
-	need lvmetad sysfs
-}
-
-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
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-	if [ -z "${CDBOOT}" ] ; then
-		if [ -e /proc/modules ] && ! dm_in_proc ; then
-			modprobe dm-mod 2>/dev/null
-		fi
-		if [ -d /proc/lvm ] || dm_in_proc ; then
-			ebegin "Setting up the Logical Volume Manager"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}pvscan\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgscan --mknodes\n"
-			# And turn them on!
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed to setup the LVM"
-		fi
-	fi
-}
-
-stop() {
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-# Stop LVM2
-if [ -x /sbin/vgs ] && \
-   [ -x /sbin/vgchange ] && \
-   [ -x /sbin/lvchange ] && \
-   [ -f /etc/lvmtab -o -d /etc/lvm ] && \
-   [ -d /proc/lvm  -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
-then
-	einfo "Shutting down the Logical Volume Manager"
-	
-
-        VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
-
-        if [ "$VGS" ]
-        then
-            ebegin "  Shutting Down LVs & VGs"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed (possibly some LVs still needed for /usr or root)"
-        fi
-
-	einfo "Finished shutting down the Logical Volume Manager"
-	return 0
-fi
-}
-
-# vim:ts=4
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.116-r4 b/sys-fs/lvm2/files/lvm.rc-2.02.116-r4
deleted file mode 100644
index 74b4a41..0000000
--- a/sys-fs/lvm2/files/lvm.rc-2.02.116-r4
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# 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}"
-}
-
-_need_lvmetad()
-{
-	local lvm_path="$(_get_lvm_path)"
-	[ ! -x "${lvm_path}" ] && return 1
-	${lvm_path} dumpconfig global | grep -q 'use_lvmetad=1'
-}
-
-depend() {
-	before checkfs fsck
-	after modules device-mapper
-	# We may use 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 _need=
-	if service_started; then
-		_need=$(service_get_value need)
-	else
-		if _need_lvmetad; then
-			_need="${_need} lvmetad"
-		fi
-	fi
-	need sysfs ${_need}
-}
-
-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)"
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-	if [ -z "${CDBOOT}" ] ; then
-		if [ -e /proc/modules ] && ! dm_in_proc ; then
-			modprobe dm-mod 2>/dev/null
-		fi
-		if [ -d /proc/lvm ] || dm_in_proc ; then
-			ebegin "Setting up the Logical Volume Manager"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}pvscan\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgscan --mknodes\n"
-			# And turn them on!
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed to setup the LVM"
-		fi
-	fi
-}
-
-start_post()
-{
-	# Save if we needed lvmetad
-	if _need_lvmetad; then
-		service_set_value need lvmetad
-	fi
-}
-
-stop() {
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-# Stop LVM2
-if [ -x /sbin/vgs ] && \
-   [ -x /sbin/vgchange ] && \
-   [ -x /sbin/lvchange ] && \
-   [ -f /etc/lvmtab -o -d /etc/lvm ] && \
-   [ -d /proc/lvm  -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
-then
-	einfo "Shutting down the Logical Volume Manager"
-
-        VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
-
-        if [ "$VGS" ]
-        then
-            ebegin "  Shutting Down LVs & VGs"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed (possibly some LVs still needed for /usr or root)"
-        fi
-
-	einfo "Finished shutting down the Logical Volume Manager"
-	return 0
-fi
-}
-
-# vim:ts=4
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.116-r6 b/sys-fs/lvm2/files/lvm.rc-2.02.116-r6
deleted file mode 100644
index 1bf075f..0000000
--- a/sys-fs/lvm2/files/lvm.rc-2.02.116-r6
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# 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}"
-}
-
-_need_lvmetad()
-{
-	local lvm_path="$(_get_lvm_path)"
-	[ ! -x "${lvm_path}" ] && return 1
-	${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
-}
-
-depend() {
-	before checkfs fsck
-	after modules device-mapper
-	# We may use 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 _need=
-	if service_started; then
-		_need=$(service_get_value need)
-	else
-		if _need_lvmetad; then
-			_need="${_need} lvmetad"
-		fi
-	fi
-	need sysfs ${_need}
-}
-
-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)"
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-	if [ -z "${CDBOOT}" ] ; then
-		if [ -e /proc/modules ] && ! dm_in_proc ; then
-			modprobe dm-mod 2>/dev/null
-		fi
-		if [ -d /proc/lvm ] || dm_in_proc ; then
-			ebegin "Setting up the Logical Volume Manager"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}pvscan\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgscan --mknodes\n"
-			# And turn them on!
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed to setup the LVM"
-		fi
-	fi
-}
-
-start_post()
-{
-	# Save if we needed lvmetad
-	if _need_lvmetad; then
-		service_set_value need lvmetad
-	fi
-}
-
-stop() {
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-# Stop LVM2
-if [ -x /sbin/vgs ] && \
-   [ -x /sbin/vgchange ] && \
-   [ -x /sbin/lvchange ] && \
-   [ -f /etc/lvmtab -o -d /etc/lvm ] && \
-   [ -d /proc/lvm  -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
-then
-	einfo "Shutting down the Logical Volume Manager"
-
-        VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
-
-        if [ "$VGS" ]
-        then
-            ebegin "  Shutting Down LVs & VGs"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed (possibly some LVs still needed for /usr or root)"
-        fi
-
-	einfo "Finished shutting down the Logical Volume Manager"
-	return 0
-fi
-}
-
-# vim:ts=4
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.166-r2 b/sys-fs/lvm2/files/lvm.rc-2.02.166-r2
deleted file mode 100644
index 11329bb..0000000
--- a/sys-fs/lvm2/files/lvm.rc-2.02.166-r2
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
-# 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}"
-}
-
-_need_lvmetad()
-{
-	local lvm_path="$(_get_lvm_path)"
-	[ ! -x "${lvm_path}" ] && return 1
-	${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
-}
-
-_need_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 use 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 _need=
-	if service_started; then
-		_need=$(service_get_value need)
-	else
-		if _need_lvmetad; then
-			_need="${_need} lvmetad"
-		fi
-		if _need_lvmlockd; then
-			_need="${_need} lvmlockd"
-		fi
-	fi
-	need sysfs ${_need}
-}
-
-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)"
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-	if [ -z "${CDBOOT}" ] ; then
-		if [ -e /proc/modules ] && ! dm_in_proc ; then
-			modprobe dm-mod 2>/dev/null
-		fi
-		if [ -d /proc/lvm ] || dm_in_proc ; then
-			ebegin "Setting up the Logical Volume Manager"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}pvscan\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgscan --mknodes\n"
-			# And turn them on!
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
-			if _need_lvmlockd; then
-				# Start lockd VGs as required
-				lvm_commands="${lvm_commands}vgchange --lock-start --lock-opt auto\n"
-			fi
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed to setup the LVM"
-		fi
-	fi
-}
-
-start_post()
-{
-	# Save if we needed lvmetad
-	if _need_lvmetad; then
-		service_set_value need lvmetad
-	fi
-}
-
-stop() {
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-# Stop LVM2
-if [ -x /sbin/vgs ] && \
-   [ -x /sbin/vgchange ] && \
-   [ -x /sbin/lvchange ] && \
-   [ -f /etc/lvmtab -o -d /etc/lvm ] && \
-   [ -d /proc/lvm  -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
-then
-	einfo "Shutting down the Logical Volume Manager"
-
-        VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
-
-        if [ "$VGS" ]
-        then
-            ebegin "  Shutting Down LVs & VGs"
-			#still echo stderr for debugging
-			lvm_commands="#! ${lvm_path} --config '${config}'\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed (possibly some LVs still needed for /usr or root)"
-        fi
-
-	einfo "Finished shutting down the Logical Volume Manager"
-	return 0
-fi
-}
-
-# vim:ts=4
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.172 b/sys-fs/lvm2/files/lvm.rc-2.02.172
deleted file mode 100644
index 9e22c28..0000000
--- a/sys-fs/lvm2/files/lvm.rc-2.02.172
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
-# 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}"
-}
-
-_need_lvmetad()
-{
-	local lvm_path="$(_get_lvm_path)"
-	[ ! -x "${lvm_path}" ] && return 1
-	${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
-}
-
-_need_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 use 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 _need=
-	if service_started; then
-		_need=$(service_get_value need)
-	else
-		if _need_lvmetad; then
-			_need="${_need} lvmetad"
-		fi
-		if _need_lvmlockd; then
-			_need="${_need} lvmlockd"
-		fi
-	fi
-	need sysfs ${_need}
-}
-
-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)"
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-	if [ -z "${CDBOOT}" ] ; then
-		if [ -e /proc/modules ] && ! dm_in_proc ; then
-			modprobe dm-mod 2>/dev/null
-		fi
-		if [ -d /proc/lvm ] || dm_in_proc ; then
-			ebegin "Setting up the Logical Volume Manager"
-			#still echo stderr for debugging
-			lvm_commands="#!${lvm_path}\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}pvscan --config '${config}'\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgscan --config '${config}' --mknodes\n"
-			# And turn them on!
-			lvm_commands="${lvm_commands}vgchange --config '${config}' --sysinit -a ly\n"
-			if _need_lvmlockd; then
-				# Start lockd VGs as required
-				lvm_commands="${lvm_commands}vgchange --config '${config}' --lock-start --lock-opt auto\n"
-			fi
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 >/dev/null
-			eend $? "Failed to setup the LVM"
-		fi
-	fi
-}
-
-start_post()
-{
-	# Save if we needed lvmetad
-	if _need_lvmetad; then
-		service_set_value need lvmetad
-	fi
-}
-
-stop() {
-	for lvm_path in /bin/lvm /sbin/lvm ; do
-		[ -x "$lvm_path" ] && break
-	done
-	if [ ! -x "$lvm_path" ]; then
-		eerror "Cannot find lvm binary in /sbin or /bin!"
-		return 1
-	fi
-# Stop LVM2
-if [ -x /sbin/vgs ] && \
-   [ -x /sbin/vgchange ] && \
-   [ -x /sbin/lvchange ] && \
-   [ -f /etc/lvmtab -o -d /etc/lvm ] && \
-   [ -d /proc/lvm  -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
-then
-	einfo "Shutting down the Logical Volume Manager"
-
-        VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
-
-        if [ "$VGS" ]
-        then
-            ebegin "  Shutting Down LVs & VGs"
-			#still echo stderr for debugging
-			lvm_commands="#!${lvm_path}\n"
-			# Extra PV find pass because some devices might not have been available until very recently
-			lvm_commands="${lvm_commands}lvchange --config '${config}' --sysinit -a ln ${VGS}\n"
-			# Now make the nodes
-			lvm_commands="${lvm_commands}vgchange --config '${config}' --sysinit -a ln ${VGS}\n"
-			# Order of this is important, have to work around dash and LVM readline
-			printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
-			eend $? "Failed (possibly some LVs still needed for /usr or root)"
-        fi
-
-	einfo "Finished shutting down the Logical Volume Manager"
-	return 0
-fi
-}
-
-# vim:ts=4
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.187 b/sys-fs/lvm2/files/lvm.rc-2.02.187
new file mode 100644
index 0000000..3468adc
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.187
@@ -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
diff --git a/sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch b/sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch
deleted file mode 100644
index 594d606..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-Make sure that libdm usage always brings in pthread libraries, both in
-pkgconfig and during manual build.
-
---- tools/Makefile.in
-+++ tools/Makefile.in
-@@ -87,6 +87,7 @@
-   INSTALL_LVM_TARGETS += install_tools_static
-   INSTALL_DMSETUP_TARGETS += install_dmsetup_static
-   INSTALL_CMDLIB_TARGETS += install_cmdlib_static
-+  STATIC_LIBS += @PTHREAD_LIBS@
- endif
- 
- LVMLIBS = $(LVMINTERNAL_LIBS)
-@@ -118,6 +119,10 @@
- 
- include $(top_builddir)/make.tmpl
- 
-+ifeq ("@STATIC_LINK@", "yes")
-+  STATIC_LIBS += @PTHREAD_LIBS@
-+endif
-+
- device-mapper: $(TARGETS_DM)
- 
- CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS)
---- libdm/libdevmapper.pc.in
-+++ libdm/libdevmapper.pc.in
-@@ -8,4 +8,5 @@
- Version: @DM_LIB_PATCHLEVEL@
- Cflags: -I${includedir} 
- Libs: -L${libdir} -ldevmapper
-+Libs.private: -L${libdir} @PTHREAD_LIBS@
- Requires.private: @SELINUX_PC@ @UDEV_PC@
diff --git a/sys-fs/lvm2/files/lvm2-2.02.108-example.conf.in.patch b/sys-fs/lvm2/files/lvm2-2.02.108-example.conf.in.patch
deleted file mode 100644
index af5a5af..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.108-example.conf.in.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-Maintainer note: Forward ported without editing from lvm2-2.02.99-example.conf.in.patch to apply cleanly.
-
---- conf/example.conf.in
-+++ conf/example.conf.in
-@@ -105,6 +105,10 @@
-     # By default we 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/.*/" ]
-+
-     # Exclude the cdrom drive
-     # filter = [ "r|/dev/cdrom|" ]
- 
-@@ -522,7 +526,8 @@
-     # e.g. vgscan.lvm1 and they will stop working after you start using
-     # the new lvm2 on-disk metadata format.
-     # The default value is set when the tools are built.
--    # fallback_to_lvm1 = 0
-+    # Gentoo: the LVM tools are a seperate package.
-+    fallback_to_lvm1 = 0
- 
-     # The default metadata format that commands should use - "lvm1" or "lvm2".
-     # The command line override is -M1 or -M2.
-@@ -1182,12 +1187,13 @@
- 
- # Metadata settings
- #
--# metadata {
-+metadata {
-     # Default number of copies of metadata to hold on each PV.  0, 1 or 2.
-     # You might want to override it from the command line with 0 
-     # when running pvcreate on new PVs which are to be added to large VGs.
- 
--    # pvmetadatacopies = 1
-+    # Gentoo: enable for data safety, but PV resize is then disabled.
-+    # pvmetadatacopies = 2
- 
-     # Default number of copies of metadata to maintain for each VG.
-     # If set to a non-zero value, LVM automatically chooses which of
-@@ -1222,7 +1228,7 @@
-     # the supplied toolset to make changes (e.g. vgcfgrestore).
- 
-     # dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ]
--#}
-+}
- 
- # Event daemon
- #
diff --git a/sys-fs/lvm2/files/lvm2-2.02.108-static-pkgconfig-libs.patch b/sys-fs/lvm2/files/lvm2-2.02.108-static-pkgconfig-libs.patch
deleted file mode 100644
index 3ab6998..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.108-static-pkgconfig-libs.patch
+++ /dev/null
@@ -1,104 +0,0 @@
-Maintainer note: Forward ported without editing from lvm2-2.02.107-static-pkgconfig-libs.patch to apply cleanly.
-
---- configure.in
-+++ configure.in
-@@ -1067,6 +1067,7 @@
- 			   fi])
- 	if test "$BLKID_WIPING" = yes; then
- 		BLKID_PC="blkid"
-+		BLKID_STATIC_LIBS=`$PKG_CONFIG --static --libs $BLKID_PC`
- 		AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
- 	fi
- fi
-@@ -1092,6 +1093,7 @@
- if test "$UDEV_SYNC" = yes; then
- 	pkg_config_init
- 	PKG_CHECK_MODULES(UDEV, libudev >= 143, [UDEV_PC="libudev"])
-+	UDEV_STATIC_LIBS=`$PKG_CONFIG --static --libs libudev`
- 	AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
- fi
- 
-@@ -1312,19 +1314,32 @@
- if test "$SELINUX" = yes; then
- 	AC_CHECK_LIB([sepol], [sepol_check_context], [
- 		AC_DEFINE([HAVE_SEPOL], 1, [Define to 1 if sepol_check_context is available.])
--		SELINUX_LIBS="-lsepol"])
-+		SEPOL_LIBS="-lsepol"])
-+
-+	dnl -- init pkgconfig if required
-+	if  test x$PKGCONFIG_INIT != x1; then
-+		pkg_config_init
-+	fi
-+	PKG_CHECK_MODULES(SELINUX, libselinux, [
-+		SELINUX_PC="libselinux"
-+		SELINUX_STATIC_LIBS=`$PKG_CONFIG --static --libs libselinux`
-+		SELINUX_LIBS="$SELINUX_LIBS $SEPOL_LIBS"
-+		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
-+	],[
-+		dnl -- old non-pkgconfig method, is buggy with static builds
- 
- 	AC_CHECK_LIB([selinux], [is_selinux_enabled], [
- 		AC_CHECK_HEADERS([selinux/selinux.h],, hard_bailout)
- 		AC_CHECK_HEADERS([selinux/label.h])
- 		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
--		SELINUX_LIBS="-lselinux $SELINUX_LIBS"
-+		SELINUX_LIBS="-lselinux $SEPOL_LIBS"
- 		SELINUX_PC="libselinux"
- 		HAVE_SELINUX=yes ], [
- 		AC_MSG_WARN(Disabling selinux)
- 		SELINUX_LIBS=
- 		SELINUX_PC=
- 		HAVE_SELINUX=no ])
-+	])
- fi
- 
- ################################################################################
-@@ -1626,6 +1641,7 @@
- ################################################################################
- AC_SUBST(APPLIB)
- AC_SUBST(AWK)
-+AC_SUBST(BLKID_STATIC_LIBS)
- AC_SUBST(BLKID_PC)
- AC_SUBST(BLKID_WIPING)
- AC_SUBST(BUILD_CMIRRORD)
-@@ -1721,6 +1737,7 @@
- AC_SUBST(SALCK_CFLAGS)
- AC_SUBST(SALCK_LIBS)
- AC_SUBST(SELINUX_LIBS)
-+AC_SUBST(SELINUX_STATIC_LIBS)
- AC_SUBST(SELINUX_PC)
- AC_SUBST(SNAPSHOTS)
- AC_SUBST(STATICDIR)
-@@ -1735,6 +1752,7 @@
- AC_SUBST(CACHE_DUMP_CMD)
- AC_SUBST(CACHE_REPAIR_CMD)
- AC_SUBST(CACHE_RESTORE_CMD)
-+AC_SUBST(UDEV_STATIC_LIBS)
- AC_SUBST(UDEV_PC)
- AC_SUBST(UDEV_RULES)
- AC_SUBST(UDEV_SYNC)
---- make.tmpl.in
-+++ make.tmpl.in
-@@ -43,7 +43,7 @@
- 
- LIBS = @LIBS@
- # Extra libraries always linked with static binaries
--STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
-+STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS)
- DEFS += @DEFS@
- # FIXME set this only where it's needed, not globally?
- CFLAGS += @CFLAGS@
-@@ -57,10 +57,13 @@
- PTHREAD_LIBS = @PTHREAD_LIBS@
- READLINE_LIBS = @READLINE_LIBS@
- SELINUX_LIBS = @SELINUX_LIBS@
-+SELINUX_STATIC_LIBS = @SELINUX_STATIC_LIBS@
- UDEV_CFLAGS = @UDEV_CFLAGS@
- UDEV_LIBS = @UDEV_LIBS@
-+UDEV_STATIC_LIBS = @UDEV_STATIC_LIBS@
- BLKID_CFLAGS = @BLKID_CFLAGS@
- BLKID_LIBS = @BLKID_LIBS@
-+BLKID_STATIC_LIBS = @BLKID_STATIC_LIBS@
- TESTING = @TESTING@
- 
- # Setup directory variables
diff --git a/sys-fs/lvm2/files/lvm2-2.02.129-dynamic-static-ldflags.patch b/sys-fs/lvm2/files/lvm2-2.02.129-dynamic-static-ldflags.patch
deleted file mode 100644
index efdfb81..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.129-dynamic-static-ldflags.patch
+++ /dev/null
@@ -1,59 +0,0 @@
---- LVM2.2.02.129/configure.in
-+++ LVM2.2.02.129/configure.in
-@@ -31,6 +31,7 @@
- 	linux*)
- 		CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
- 		ELDFLAGS="-Wl,--export-dynamic"
-+		STATIC_LDFLAGS="-Wl,--no-export-dynamic"
- 		# FIXME Generate list and use --dynamic-list=.dlopen.sym
- 		CLDWHOLEARCHIVE="-Wl,-whole-archive"
- 		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
-@@ -2008,6 +2009,7 @@
- AC_SUBST(SELINUX_PC)
- AC_SUBST(SNAPSHOTS)
- AC_SUBST(STATICDIR)
-+AC_SUBST(STATIC_LDFLAGS)
- AC_SUBST(STATIC_LINK)
- AC_SUBST(TESTING)
- AC_SUBST(TESTSUITE_DATA)
---- LVM2.2.02.129/daemons/dmeventd/Makefile.in
-+++ LVM2.2.02.129/daemons/dmeventd/Makefile.in
-@@ -66,7 +66,7 @@
- 	$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
- 
- dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(STATIC_LDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
- 	dmeventd.o $(DL_LIBS) $(LVMLIBS) $(LIBS) $(STATIC_LIBS)
- 
- ifeq ("@PKGCONFIG@", "yes")
---- LVM2.2.02.129/make.tmpl.in
-+++ LVM2.2.02.129/make.tmpl.in
-@@ -48,6 +48,7 @@
- # FIXME set this only where it's needed, not globally?
- CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
- LDFLAGS ?= @COPTIMISE_FLAG@ @LDFLAGS@
-+STATIC_LDFLAGS += @STATIC_LDFLAGS@
- CLDFLAGS += @CLDFLAGS@
- ELDFLAGS += @ELDFLAGS@
- LDDEPS += @LDDEPS@
---- LVM2.2.02.129/tools/Makefile.in
-+++ LVM2.2.02.129/tools/Makefile.in
-@@ -129,7 +129,7 @@
- 	      -o $@ dmsetup.o -ldevmapper $(LIBS)
- 
- dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) \
- 	      -o $@ dmsetup.o -ldevmapper $(STATIC_LIBS) $(LIBS)
- 
- all: device-mapper
-@@ -146,7 +146,7 @@
- endif
- 
- lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
- 	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
- 
- liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
diff --git a/sys-fs/lvm2/files/lvm2-2.02.129-static-pkgconfig-libs.patch b/sys-fs/lvm2/files/lvm2-2.02.129-static-pkgconfig-libs.patch
deleted file mode 100644
index 2396945..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.129-static-pkgconfig-libs.patch
+++ /dev/null
@@ -1,102 +0,0 @@
---- LVM2.2.02.129/configure.in
-+++ LVM2.2.02.129/configure.in
-@@ -1287,6 +1287,7 @@
- 			   fi])
- 	if test "$BLKID_WIPING" = yes; then
- 		BLKID_PC="blkid"
-+		BLKID_STATIC_LIBS=`$PKG_CONFIG --static --libs $BLKID_PC`
- 		DEFAULT_USE_BLKID_WIPING=1
- 		AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
- 	else
-@@ -1332,6 +1333,7 @@
- if test "$UDEV_SYNC" = yes; then
- 	pkg_config_init
- 	PKG_CHECK_MODULES(UDEV, libudev >= 143, [UDEV_PC="libudev"])
-+	UDEV_STATIC_LIBS=`$PKG_CONFIG --static --libs libudev`
- 	AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
- fi
- 
-@@ -1558,19 +1560,32 @@
- if test "$SELINUX" = yes; then
- 	AC_CHECK_LIB([sepol], [sepol_check_context], [
- 		AC_DEFINE([HAVE_SEPOL], 1, [Define to 1 if sepol_check_context is available.])
--		SELINUX_LIBS="-lsepol"])
-+		SEPOL_LIBS="-lsepol"])
-+
-+	dnl -- init pkgconfig if required
-+	if  test x$PKGCONFIG_INIT != x1; then
-+		pkg_config_init
-+	fi
-+	PKG_CHECK_MODULES(SELINUX, libselinux, [
-+		SELINUX_PC="libselinux"
-+		SELINUX_STATIC_LIBS=`$PKG_CONFIG --static --libs libselinux`
-+		SELINUX_LIBS="$SELINUX_LIBS $SEPOL_LIBS"
-+		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
-+	],[
-+		dnl -- old non-pkgconfig method, is buggy with static builds
- 
- 	AC_CHECK_LIB([selinux], [is_selinux_enabled], [
- 		AC_CHECK_HEADERS([selinux/selinux.h],, hard_bailout)
- 		AC_CHECK_HEADERS([selinux/label.h])
- 		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
--		SELINUX_LIBS="-lselinux $SELINUX_LIBS"
-+		SELINUX_LIBS="-lselinux $SEPOL_LIBS"
- 		SELINUX_PC="libselinux"
- 		HAVE_SELINUX=yes ], [
- 		AC_MSG_WARN(Disabling selinux)
- 		SELINUX_LIBS=
- 		SELINUX_PC=
- 		HAVE_SELINUX=no ])
-+	])
- fi
- 
- ################################################################################
-@@ -1902,6 +1917,7 @@
- ################################################################################
- AC_SUBST(APPLIB)
- AC_SUBST(AWK)
-+AC_SUBST(BLKID_STATIC_LIBS)
- AC_SUBST(BLKID_PC)
- AC_SUBST(BUILD_CMIRRORD)
- AC_SUBST(BUILD_DMEVENTD)
-@@ -2005,6 +2021,7 @@
- AC_SUBST(SALCK_CFLAGS)
- AC_SUBST(SALCK_LIBS)
- AC_SUBST(SELINUX_LIBS)
-+AC_SUBST(SELINUX_STATIC_LIBS)
- AC_SUBST(SELINUX_PC)
- AC_SUBST(SNAPSHOTS)
- AC_SUBST(STATICDIR)
-@@ -2020,6 +2037,7 @@
- AC_SUBST(CACHE_DUMP_CMD)
- AC_SUBST(CACHE_REPAIR_CMD)
- AC_SUBST(CACHE_RESTORE_CMD)
-+AC_SUBST(UDEV_STATIC_LIBS)
- AC_SUBST(UDEV_PC)
- AC_SUBST(UDEV_RULES)
- AC_SUBST(UDEV_SYNC)
---- LVM2.2.02.129/make.tmpl.in
-+++ LVM2.2.02.129/make.tmpl.in
-@@ -43,7 +43,7 @@
- 
- LIBS = @LIBS@
- # Extra libraries always linked with static binaries
--STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
-+STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS)
- DEFS += @DEFS@
- # FIXME set this only where it's needed, not globally?
- CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
-@@ -58,10 +58,13 @@
- PTHREAD_LIBS = @PTHREAD_LIBS@
- READLINE_LIBS = @READLINE_LIBS@
- SELINUX_LIBS = @SELINUX_LIBS@
-+SELINUX_STATIC_LIBS = @SELINUX_STATIC_LIBS@
- UDEV_CFLAGS = @UDEV_CFLAGS@
- UDEV_LIBS = @UDEV_LIBS@
-+UDEV_STATIC_LIBS = @UDEV_STATIC_LIBS@
- BLKID_CFLAGS = @BLKID_CFLAGS@
- BLKID_LIBS = @BLKID_LIBS@
-+BLKID_STATIC_LIBS = @BLKID_STATIC_LIBS@
- VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
- TESTING = @TESTING@
- 
diff --git a/sys-fs/lvm2/files/lvm2-2.02.130-pthread-pkgconfig.patch b/sys-fs/lvm2/files/lvm2-2.02.130-pthread-pkgconfig.patch
deleted file mode 100644
index 11db632..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.130-pthread-pkgconfig.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-Make sure that libdm usage always brings in pthread libraries, both in
-pkgconfig and during manual build.
-
---- LVM2.2.02.130/libdm/libdevmapper.pc.in
-+++ LVM2.2.02.130/libdm/libdevmapper.pc.in
-@@ -9,4 +9,4 @@
- Cflags: -I${includedir} 
- Libs: -L${libdir} -ldevmapper
- Requires.private: @SELINUX_PC@ @UDEV_PC@
--Libs.private: -lm @RT_LIB@
-+Libs.private: -lm @RT_LIB@ @PTHREAD_LIBS@
---- LVM2.2.02.130/tools/Makefile.in
-+++ LVM2.2.02.130/tools/Makefile.in
-@@ -90,6 +90,7 @@
-   INSTALL_LVM_TARGETS += install_tools_static
-   INSTALL_DMSETUP_TARGETS += install_dmsetup_static
-   INSTALL_CMDLIB_TARGETS += install_cmdlib_static
-+  STATIC_LIBS += @PTHREAD_LIBS@
- endif
- 
- LVMLIBS = $(LVMINTERNAL_LIBS)
-@@ -120,6 +121,10 @@
- 
- include $(top_builddir)/make.tmpl
- 
-+ifeq ("@STATIC_LINK@", "yes")
-+  STATIC_LIBS += @PTHREAD_LIBS@
-+endif
-+
- device-mapper: $(TARGETS_DM)
- 
- CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS)
diff --git a/sys-fs/lvm2/files/lvm2-2.02.139-dynamic-static-ldflags.patch b/sys-fs/lvm2/files/lvm2-2.02.139-dynamic-static-ldflags.patch
deleted file mode 100644
index 312e546..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.139-dynamic-static-ldflags.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-diff -ur LVM2.2.02.139_O/configure.in LVM2.2.02.139/configure.in
---- LVM2.2.02.139_O/configure.in	2016-01-19 12:54:33.155187005 +0000
-+++ LVM2.2.02.139/configure.in	2016-01-19 12:56:39.487181372 +0000
-@@ -31,6 +31,7 @@
- 	linux*)
- 		CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
- 		ELDFLAGS="-Wl,--export-dynamic"
-+		STATIC_LDFLAGS="-Wl,--no-export-dynamic"
- 		# FIXME Generate list and use --dynamic-list=.dlopen.sym
- 		CLDWHOLEARCHIVE="-Wl,-whole-archive"
- 		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
-@@ -2009,6 +2010,7 @@
- AC_SUBST(SELINUX_PC)
- AC_SUBST(SNAPSHOTS)
- AC_SUBST(STATICDIR)
-+AC_SUBST(STATIC_LDFLAGS)
- AC_SUBST(STATIC_LINK)
- AC_SUBST(TESTING)
- AC_SUBST(TESTSUITE_DATA)
-diff -ur LVM2.2.02.139_O/daemons/dmeventd/Makefile.in LVM2.2.02.139/daemons/dmeventd/Makefile.in
---- LVM2.2.02.139_O/daemons/dmeventd/Makefile.in	2016-01-19 12:54:33.278186999 +0000
-+++ LVM2.2.02.139/daemons/dmeventd/Makefile.in	2016-01-19 12:57:44.277178484 +0000
-@@ -67,7 +67,7 @@
- 	$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
- 
- dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(STATIC_LDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
- 	dmeventd.o $(DL_LIBS) $(LVMLIBS) $(LIBS) $(STATIC_LIBS)
- 
- ifeq ("@PKGCONFIG@", "yes")
-diff -ur LVM2.2.02.139_O/make.tmpl.in LVM2.2.02.139/make.tmpl.in
---- LVM2.2.02.139_O/make.tmpl.in	2016-01-19 12:54:33.529186988 +0000
-+++ LVM2.2.02.139/make.tmpl.in	2016-01-19 12:58:31.514176378 +0000
-@@ -49,6 +49,7 @@
- # FIXME set this only where it's needed, not globally?
- CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
- LDFLAGS ?= @COPTIMISE_FLAG@ @LDFLAGS@
-+STATIC_LDFLAGS += @STATIC_LDFLAGS@
- CLDFLAGS += @CLDFLAGS@
- ELDFLAGS += @ELDFLAGS@
- LDDEPS += @LDDEPS@
-diff -ur LVM2.2.02.139_O/tools/Makefile.in LVM2.2.02.139/tools/Makefile.in
---- LVM2.2.02.139_O/tools/Makefile.in	2016-01-08 18:51:21.000000000 +0000
-+++ LVM2.2.02.139/tools/Makefile.in	2016-01-19 13:00:08.349172060 +0000
-@@ -129,7 +129,7 @@
- 	      -o $@ dmsetup.o -ldevmapper $(LIBS)
- 
- dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) \
- 	      -o $@ dmsetup.o -ldevmapper $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
- 
- all: device-mapper
-@@ -146,7 +146,7 @@
- endif
- 
- lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
--	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-+	$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
- 	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
- 
- liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
diff --git a/sys-fs/lvm2/files/lvm2-2.02.145-mkdev.patch b/sys-fs/lvm2/files/lvm2-2.02.145-mkdev.patch
deleted file mode 100644
index f91dccd..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.145-mkdev.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-https://bugs.gentoo.org/580062
-
-From 2a1d0fa8ea765604cd8274aac5aa7876f1c145c9 Mon Sep 17 00:00:00 2001
-From: Mike Frysinger <vapier@gentoo.org>
-Date: Tue, 19 Apr 2016 23:53:22 -0400
-Subject: [PATCH] convert major/minor/makedev handling
-
-Most of the files in here use MAJOR/MINOR/MKDEV macros, but a few
-missed it.  Update the defines in those files to match them.
----
- daemons/cmirrord/functions.c                          | 16 ++++++++++++----
- daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c | 12 ++++++++++--
- lib/filters/filter-sysfs.c                            |  6 ++++--
- 3 files changed, 26 insertions(+), 8 deletions(-)
-
-diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
-index e9d3c09..5b3cb38 100644
---- a/daemons/cmirrord/functions.c
-+++ b/daemons/cmirrord/functions.c
-@@ -20,6 +20,14 @@
- #include <time.h>
- #include <unistd.h>
- 
-+#ifdef __linux__
-+#  include "kdev_t.h"
-+#else
-+#  define MAJOR(x) major((x))
-+#  define MINOR(x) minor((x))
-+#  define MKDEV(x,y) makedev((x),(y))
-+#endif
-+
- #define BYTE_SHIFT 3
- 
- /*
-@@ -333,8 +341,8 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
- 			continue;
- 		}
- 		if (S_ISBLK(statbuf.st_mode) &&
--		    (major(statbuf.st_rdev) == major) &&
--		    (minor(statbuf.st_rdev) == minor)) {
-+		    (MAJOR(statbuf.st_rdev) == major) &&
-+		    (MINOR(statbuf.st_rdev) == minor)) {
- 			LOG_DBG("  %s: YES", dep->d_name);
- 			if (closedir(dp))
- 				LOG_DBG("Unable to closedir /dev/mapper %s",
-@@ -1451,7 +1459,7 @@ static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
- 	}
- 
- 	r = sprintf(data, "3 clustered-disk %d:%d %c",
--		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
-+		    MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
- 		    (lc->log_dev_failed) ? 'D' : 'A');
- 	if (r < 0)
- 		return r;
-@@ -1514,7 +1522,7 @@ static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
- 	}
- 
- 	r = sprintf(data, "clustered-disk %d:%d %u %s%s ",
--		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
-+		    MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
- 		    lc->region_size,
- 		    (lc->sync == DEFAULTSYNC) ? "" :
- 		    (lc->sync == NOSYNC) ? "nosync " : "sync ",
-diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
-index 7b060ed..4098203 100644
---- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
-+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
-@@ -20,6 +20,14 @@
- #include <stdarg.h>
- #include <pthread.h>
- 
-+#ifdef __linux__
-+#  include "kdev_t.h"
-+#else
-+#  define MAJOR(x) major((x))
-+#  define MINOR(x) minor((x))
-+#  define MKDEV(x,y) makedev((x),(y))
-+#endif
-+
- /* First warning when snapshot is 80% full. */
- #define WARNING_THRESH	(DM_PERCENT_1 * 80)
- /* Run a check every 5%. */
-@@ -148,8 +156,8 @@ static void _umount(const char *device, int major, int minor)
- 			continue; /* can't stat, skip this one */
- 
- 		if (S_ISBLK(st.st_mode) &&
--		    major(st.st_rdev) == major &&
--		    minor(st.st_rdev) == minor) {
-+		    MAJOR(st.st_rdev) == major &&
-+		    MINOR(st.st_rdev) == minor) {
- 			log_error("Unmounting invalid snapshot %s from %s.", device, words[1]);
- 			if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
- 				log_error("Failed to umount snapshot %s from %s: %s.",
-diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
-index 3115f86..5f76e8b 100644
---- a/lib/filters/filter-sysfs.c
-+++ b/lib/filters/filter-sysfs.c
-@@ -19,6 +19,8 @@
- 
- #include <dirent.h>
- 
-+#include "kdev_t.h"
-+
- static int _locate_sysfs_blocks(const char *sysfs_dir, char *path, size_t len,
- 				unsigned *sysfs_depth)
- {
-@@ -120,7 +122,7 @@ static struct dev_set *_dev_set_create(struct dm_pool *mem,
- 
- static unsigned _hash_dev(dev_t dev)
- {
--	return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
-+	return (MAJOR(dev) ^ MINOR(dev)) & (SET_BUCKETS - 1);
- }
- 
- /*
-@@ -171,7 +173,7 @@ static int _parse_dev(const char *file, FILE *fp, dev_t *result)
- 		return 0;
- 	}
- 
--	*result = makedev(major, minor);
-+	*result = MKDEV(major, minor);
- 	return 1;
- }
- 
--- 
-2.7.4
-
diff --git a/sys-fs/lvm2/files/lvm2-2.02.166-HPPA-no-O_DIRECT.patch b/sys-fs/lvm2/files/lvm2-2.02.166-HPPA-no-O_DIRECT.patch
new file mode 100644
index 0000000..0f830e4
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.166-HPPA-no-O_DIRECT.patch
@@ -0,0 +1,12 @@
+--- a/lib/device/dev-io.c
++++ b/lib/device/dev-io.c
+@@ -505,7 +505,9 @@
+ 			dev->flags |= DEV_NOT_O_NOATIME;
+ 			if ((dev->fd = open(name, flags, 0777)) >= 0) {
+ 				log_debug_devs("%s: Not using O_NOATIME", name);
++#ifdef O_DIRECT_SUPPORT
+ 				goto opened;
++#endif
+ 			}
+ 		}
+ #endif
diff --git a/sys-fs/lvm2/files/lvm2-2.02.171-static-libm.patch b/sys-fs/lvm2/files/lvm2-2.02.171-static-libm.patch
new file mode 100644
index 0000000..1cbf956
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.171-static-libm.patch
@@ -0,0 +1,13 @@
+diff --git a/make.tmpl.in b/make.tmpl.in
+index a40eaaa15..7eea943aa 100644
+--- a/make.tmpl.in
++++ b/make.tmpl.in
+@@ -53,7 +53,7 @@ PYCOMPILE = $(top_srcdir)/autoconf/py-compile
+ 
+ LIBS = @LIBS@
+ # Extra libraries always linked with static binaries
+-STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS)
++STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS) $(M_LIBS)
+ DEFS += @DEFS@
+ # FIXME set this only where it's needed, not globally?
+ CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
diff --git a/sys-fs/lvm2/files/lvm2-2.02.176-pthread-pkgconfig.patch b/sys-fs/lvm2/files/lvm2-2.02.176-pthread-pkgconfig.patch
new file mode 100644
index 0000000..c0265e8
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.176-pthread-pkgconfig.patch
@@ -0,0 +1,29 @@
+--- LVM2.2.02.176/libdm/libdevmapper.pc.in
++++ LVM2.2.02.176/libdm/libdevmapper.pc.in
+@@ -9,4 +9,4 @@
+ Cflags: -I${includedir} 
+ Libs: -L${libdir} -ldevmapper
+ Requires.private: @SELINUX_PC@ @UDEV_PC@
+-Libs.private: -lm @RT_LIBS@
++Libs.private: -lm @RT_LIBS@ @PTHREAD_LIBS@
+--- LVM2.2.02.176/tools/Makefile.in
++++ LVM2.2.02.176/tools/Makefile.in
+@@ -93,6 +93,7 @@
+   INSTALL_LVM_TARGETS += install_tools_static
+   INSTALL_DMSETUP_TARGETS += install_dmsetup_static
+   INSTALL_CMDLIB_TARGETS += install_cmdlib_static
++  STATIC_LIBS += @PTHREAD_LIBS@
+ endif
+ 
+ LVMLIBS = $(LVMINTERNAL_LIBS) -ldevmapper
+@@ -118,6 +119,10 @@
+ 
+ include $(top_builddir)/make.tmpl
+ 
++ifeq ("@STATIC_LINK@", "yes")
++  STATIC_LIBS += @PTHREAD_LIBS@
++endif
++
+ device-mapper: $(TARGETS_DM)
+ 
+ CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS)
diff --git a/sys-fs/lvm2/files/lvm2-2.02.178-asneeded.patch b/sys-fs/lvm2/files/lvm2-2.02.178-asneeded.patch
new file mode 100644
index 0000000..c831c6d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.178-asneeded.patch
@@ -0,0 +1,15 @@
+http://bugs.gentoo.org/330255
+
+liblvm2app.so: undefined reference to `floor'
+
+--- LVM2.2.02.178/liblvm/Makefile.in
++++ LVM2.2.02.178/liblvm/Makefile.in
+@@ -43,7 +43,7 @@
+ include $(top_builddir)/make.tmpl
+ 
+ LDFLAGS += -L$(top_builddir)/lib -L$(top_builddir)/daemons/dmeventd
+-LIBS += $(LVMINTERNAL_LIBS) -ldevmapper -laio
++LIBS += $(LVMINTERNAL_LIBS) -ldevmapper -laio -lm
+ 
+ .PHONY: install_dynamic install_static install_include install_pkgconfig
+ 
diff --git a/sys-fs/lvm2/files/lvm2-2.02.178-dynamic-static-ldflags.patch b/sys-fs/lvm2/files/lvm2-2.02.178-dynamic-static-ldflags.patch
new file mode 100644
index 0000000..0a0e732
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.178-dynamic-static-ldflags.patch
@@ -0,0 +1,59 @@
+--- LVM2.2.02.178/configure.ac
++++ LVM2.2.02.178/configure.ac
+@@ -33,6 +33,7 @@
+ 		CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
+ 		# equivalent to -rdynamic
+ 		ELDFLAGS="-Wl,--export-dynamic"
++		STATIC_LDFLAGS="-Wl,--no-export-dynamic"
+ 		# FIXME Generate list and use --dynamic-list=.dlopen.sym
+ 		CLDWHOLEARCHIVE="-Wl,-whole-archive"
+ 		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
+@@ -2042,6 +2043,7 @@
+ AC_SUBST(SYSTEMD_LIBS)
+ AC_SUBST(SNAPSHOTS)
+ AC_SUBST(STATICDIR)
++AC_SUBST(STATIC_LDFLAGS)
+ AC_SUBST(STATIC_LINK)
+ AC_SUBST(TESTSUITE_DATA)
+ AC_SUBST(THIN)
+--- LVM2.2.02.178/daemons/dmeventd/Makefile.in
++++ LVM2.2.02.178/daemons/dmeventd/Makefile.in
+@@ -64,7 +64,7 @@
+ 		-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS)
+ 
+ dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
+-	$(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
++	$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
+ 		-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS) $(STATIC_LIBS)
+ 
+ ifeq ("@PKGCONFIG@", "yes")
+--- LVM2.2.02.178/make.tmpl.in
++++ LVM2.2.02.178/make.tmpl.in
+@@ -64,6 +64,7 @@
+ # FIXME set this only where it's needed, not globally?
+ CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
+ LDFLAGS ?= @LDFLAGS@
++STATIC_LDFLAGS += @STATIC_LDFLAGS@
+ CLDFLAGS += @CLDFLAGS@
+ ELDFLAGS += @ELDFLAGS@
+ LDDEPS += @LDDEPS@
+--- LVM2.2.02.178/tools/Makefile.in
++++ LVM2.2.02.178/tools/Makefile.in
+@@ -129,7 +129,7 @@
+ 
+ dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
+ 	@echo "    [CC] $@"
+-	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
++	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) \
+ 	      -o $@ dmsetup.o -ldevmapper $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
+ 
+ all: device-mapper
+@@ -159,7 +159,7 @@
+ 
+ lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
+ 	@echo "    [CC] $@"
+-	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
++	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
+ 	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
+ 
+ liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
diff --git a/sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch b/sys-fs/lvm2/files/lvm2-2.02.178-example.conf.in.patch
similarity index 65%
rename from sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch
rename to sys-fs/lvm2/files/lvm2-2.02.178-example.conf.in.patch
index 076e060..34c710d 100644
--- a/sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch
+++ b/sys-fs/lvm2/files/lvm2-2.02.178-example.conf.in.patch
@@ -1,7 +1,5 @@
-Maintainer note: Forward ported without editing from lvm2-2.02.108-example.conf.in.patch to apply cleanly.
-
---- LVM2.2.02.129/conf/example.conf.in
-+++ LVM2.2.02.129/conf/example.conf.in
+--- LVM2.2.02.178/conf/example.conf.in
++++ LVM2.2.02.178/conf/example.conf.in
 @@ -128,6 +128,9 @@
  	# Example
  	# Accept every block device:
@@ -12,26 +10,26 @@
  	# Reject the cdrom drive:
  	# filter = [ "r|/dev/cdrom|" ]
  	# Work with just loopback devices, e.g. for testing:
-@@ -620,7 +623,8 @@
- 	# tools need to be installed with .lvm1 suffices, e.g. vgscan.lvm1.
- 	# They will stop working once the lvm2 on-disk metadata format is used.
+@@ -704,7 +707,8 @@
+ 	# Configuration option global/fallback_to_lvm1.
+ 	# This setting is no longer used.
  	# This configuration option has an automatic default value.
--	# fallback_to_lvm1 = @DEFAULT_FALLBACK_TO_LVM1@
+-	# fallback_to_lvm1 = 0
 +	# Gentoo: the LVM tools are a seperate package.
 +	fallback_to_lvm1 = 0
  
  	# Configuration option global/format.
- 	# The default metadata format that commands should use.
-@@ -1413,7 +1417,7 @@
+ 	# This setting is no longer used.
+@@ -1508,7 +1512,7 @@
  
  # Configuration section metadata.
  # This configuration section has an automatic default value.
 -# metadata {
 +metadata {
  
- 	# Configuration option metadata/pvmetadatacopies.
- 	# Number of copies of metadata to store on each PV.
-@@ -1431,7 +1435,8 @@
+ 	# Configuration option metadata/check_pv_device_sizes.
+ 	# Check device sizes are not smaller than corresponding PV sizes.
+@@ -1553,7 +1557,8 @@
  	# 
  	# This configuration option is advanced.
  	# This configuration option has an automatic default value.
@@ -41,7 +39,7 @@
  
  	# Configuration option metadata/vgmetadatacopies.
  	# Number of copies of metadata to maintain for each VG.
-@@ -1486,7 +1491,7 @@
+@@ -1608,7 +1613,7 @@
  	# 
  	# This configuration option is advanced.
  	# This configuration option does not have a default value defined.
diff --git a/sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch b/sys-fs/lvm2/files/lvm2-2.02.178-static-pkgconfig-libs.patch
similarity index 78%
rename from sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch
rename to sys-fs/lvm2/files/lvm2-2.02.178-static-pkgconfig-libs.patch
index e25cb76..989b308 100644
--- a/sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch
+++ b/sys-fs/lvm2/files/lvm2-2.02.178-static-pkgconfig-libs.patch
@@ -1,15 +1,14 @@
-diff -Nuar --exclude '*.orig' --exclude '*.rej' LVM2.2.02.172.orig/configure.in LVM2.2.02.172/configure.in
---- LVM2.2.02.172.orig/configure.in	2017-06-28 08:54:27.000000000 -0700
-+++ LVM2.2.02.172/configure.in	2017-07-09 14:58:11.933777531 -0700
-@@ -1324,6 +1324,7 @@
+--- LVM2.2.02.178/configure.ac
++++ LVM2.2.02.178/configure.ac
+@@ -1238,6 +1238,7 @@
  	PKG_CHECK_MODULES(BLKID, blkid >= 2.24,
  			  [ BLKID_WIPING=yes
  			    BLKID_PC="blkid"
-+				BLKID_STATIC_LIBS=`$PKG_CONFIG --static --libs $BLKID_PC`
++			    BLKID_STATIC_LIBS=`$PKG_CONFIG --static --libs $BLKID_PC`
  			    DEFAULT_USE_BLKID_WIPING=1
  			    AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
  			  ], [if test "$BLKID_WIPING" = maybe; then
-@@ -1372,6 +1373,7 @@
+@@ -1286,6 +1287,7 @@
  if test "$UDEV_SYNC" = yes; then
  	pkg_config_init
  	PKG_CHECK_MODULES(UDEV, libudev >= 143, [UDEV_PC="libudev"])
@@ -17,7 +16,7 @@
  	AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
  
  	AC_CHECK_LIB(udev, udev_device_get_is_initialized, AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1,
-@@ -1653,19 +1655,32 @@
+@@ -1564,19 +1566,32 @@
  if test "$SELINUX" = yes; then
  	AC_CHECK_LIB([sepol], [sepol_check_context], [
  		AC_DEFINE([HAVE_SEPOL], 1, [Define to 1 if sepol_check_context is available.])
@@ -52,7 +51,7 @@
  fi
  
  ################################################################################
-@@ -2011,6 +2026,7 @@
+@@ -1927,6 +1942,7 @@
  ################################################################################
  AC_SUBST(APPLIB)
  AC_SUBST(AWK)
@@ -60,15 +59,15 @@
  AC_SUBST(BLKID_PC)
  AC_SUBST(BUILD_CMIRRORD)
  AC_SUBST(BUILD_DMEVENTD)
-@@ -2125,6 +2141,7 @@
- AC_SUBST(SALCK_CFLAGS)
+@@ -2037,6 +2053,7 @@
  AC_SUBST(SALCK_LIBS)
+ AC_SUBST(SBINDIR)
  AC_SUBST(SELINUX_LIBS)
 +AC_SUBST(SELINUX_STATIC_LIBS)
  AC_SUBST(SELINUX_PC)
- AC_SUBST(SNAPSHOTS)
- AC_SUBST(STATICDIR)
-@@ -2140,6 +2157,7 @@
+ AC_SUBST(SYSCONFDIR)
+ AC_SUBST(SYSTEMD_LIBS)
+@@ -2053,6 +2070,7 @@
  AC_SUBST(CACHE_DUMP_CMD)
  AC_SUBST(CACHE_REPAIR_CMD)
  AC_SUBST(CACHE_RESTORE_CMD)
@@ -76,10 +75,9 @@
  AC_SUBST(UDEV_PC)
  AC_SUBST(UDEV_RULES)
  AC_SUBST(UDEV_SYNC)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' LVM2.2.02.172.orig/make.tmpl.in LVM2.2.02.172/make.tmpl.in
---- LVM2.2.02.172.orig/make.tmpl.in	2017-06-28 08:54:28.000000000 -0700
-+++ LVM2.2.02.172/make.tmpl.in	2017-07-09 14:56:38.262933483 -0700
-@@ -53,7 +53,7 @@
+--- LVM2.2.02.178/make.tmpl.in
++++ LVM2.2.02.178/make.tmpl.in
+@@ -59,7 +59,7 @@
  
  LIBS = @LIBS@
  # Extra libraries always linked with static binaries
@@ -88,7 +86,7 @@
  DEFS += @DEFS@
  # FIXME set this only where it's needed, not globally?
  CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
-@@ -68,10 +68,13 @@
+@@ -75,10 +75,13 @@
  PTHREAD_LIBS = @PTHREAD_LIBS@
  READLINE_LIBS = @READLINE_LIBS@
  SELINUX_LIBS = @SELINUX_LIBS@
@@ -99,6 +97,6 @@
  BLKID_CFLAGS = @BLKID_CFLAGS@
  BLKID_LIBS = @BLKID_LIBS@
 +BLKID_STATIC_LIBS = @BLKID_STATIC_LIBS@
+ SYSTEMD_LIBS = @SYSTEMD_LIBS@
  VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
- TESTING = @TESTING@
  
diff --git a/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch b/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch
new file mode 100644
index 0000000..34968c7
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch
@@ -0,0 +1,72 @@
+From a397b69ce33d811aba7d64d54b5c8e0efb86fd15 Mon Sep 17 00:00:00 2001
+From: Zdenek Kabelac <zkabelac@redhat.com>
+Date: Fri, 10 May 2019 14:40:11 +0200
+Subject: [PATCH] metadata: allow reading metadata with invalid creation_time
+
+lvm2 till version 2.02.169 (commit 78d004efa8a1809cea68283e6204edfa9d7c1091)
+was printing invalid creation_time argument into metadata on 32bit arch.
+
+However with commit ba9820b14223b731125c83dbc9709aa44fdcdbf1 we started
+to properly validate all input numbers and thus we refused to accept
+invalid metadata with 'garbage' string - but this results in the
+situation where metadata produced on older lvm2 on 32 bit architecture
+will become unreadable after upgrade.
+
+To fix this case - extend libdm parser in a way, that whenever we
+find error integer value, we also check if the parsed value is not for
+creation_time node and in this case we let the metadata pass through
+with made-up date 2018-05-24 (release date of 2.02.169).
+---
+ libdm/libdm-config.c | 18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
+index 3f0d2510e..382f86bbf 100644
+--- a/libdm/libdm-config.c
++++ b/libdm/libdm-config.c
+@@ -51,6 +51,8 @@ struct parser {
+ 
+ 	struct dm_pool *mem;
+ 	int no_dup_node_check;	/* whether to disable dup node checking */
++	const char *key;        /* last obtained key */
++	unsigned ignored_creation_time;
+ };
+ 
+ struct config_output {
+@@ -176,7 +178,7 @@ static int _do_dm_config_parse(struct dm_config_tree *cft, const char *start, co
+ 	/* TODO? if (start == end) return 1; */
+ 
+ 	struct parser *p;
+-	if (!(p = dm_pool_alloc(cft->mem, sizeof(*p))))
++	if (!(p = dm_pool_zalloc(cft->mem, sizeof(*p))))
+ 		return_0;
+ 
+ 	p->mem = cft->mem;
+@@ -615,6 +617,7 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
+ 		match(TOK_SECTION_E);
+ 	} else {
+ 		match(TOK_EQ);
++		p->key = root->key;
+ 		if (!(value = _value(p)))
+ 			return_NULL;
+ 		if (root->v)
+@@ -682,8 +685,17 @@ static struct dm_config_value *_type(struct parser *p)
+ 		errno = 0;
+ 		v->v.i = strtoll(p->tb, NULL, 0);	/* FIXME: check error */
+ 		if (errno) {
+-			log_error("Failed to read int token.");
+-			return NULL;
++			if (errno == ERANGE && p->key &&
++			    strcmp("creation_time", p->key) == 0) {
++				/* Due to a bug in some older 32bit builds (<2.02.169),
++				 * lvm was able to produce invalid creation_time string */
++				v->v.i = 1527120000; /* Pick 2018-05-24 day instead */
++				if (!p->ignored_creation_time++)
++					log_warn("WARNING: Invalid creation_time found in metadata (repaired with next metadata update).");
++			} else {
++				log_error("Failed to read int token.");
++				return NULL;
++			}
+ 		}
+ 		match(TOK_INT);
+ 		break;
diff --git a/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch b/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch
new file mode 100644
index 0000000..c80bd2b
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch
@@ -0,0 +1,68 @@
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Wed, 17 Apr 2019 06:54:27 +0000
+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
+
+diff -Nuar LVM2.2.02.184.orig/daemons/dmeventd/dmeventd.c LVM2.2.02.184/daemons/dmeventd/dmeventd.c
+--- LVM2.2.02.184.orig/daemons/dmeventd/dmeventd.c	2019-03-22 03:14:59.000000000 -0700
++++ LVM2.2.02.184/daemons/dmeventd/dmeventd.c	2019-04-17 00:18:23.535029906 -0700
+@@ -2158,6 +2158,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;
+ 
+@@ -2253,7 +2265,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 */
+@@ -2262,7 +2274,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? */
+diff -Nuar LVM2.2.02.184.orig/man/dmeventd.8_main LVM2.2.02.184/man/dmeventd.8_main
+--- LVM2.2.02.184.orig/man/dmeventd.8_main	2019-03-22 03:15:00.000000000 -0700
++++ LVM2.2.02.184/man/dmeventd.8_main	2019-04-17 00:17:46.076023638 -0700
+@@ -143,6 +143,10 @@
+ Variable is set by thin plugin to prohibit recursive interation
+ with dmeventd by any executed lvm2 command from
+ a thin_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
+ .
diff --git a/sys-fs/lvm2/files/lvm2-2.02.184-mksh_build.patch b/sys-fs/lvm2/files/lvm2-2.02.184-mksh_build.patch
new file mode 100644
index 0000000..49c6853
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.184-mksh_build.patch
@@ -0,0 +1,13 @@
+https://bugs.gentoo.org/686652
+
+--- LVM2.2.02.184/tools/Makefile.in
++++ LVM2.2.02.184/tools/Makefile.in
+@@ -220,6 +220,6 @@
+ 	  echo "/* Do not edit. This file is generated by the Makefile. */" && \
+ 	  echo -en "const char _command_input[] =\n\n\"" && \
+ 	  $(EGREP) -v '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
+-	  echo "\\n\";" \
++	  printf "%s\n" "\\n\";" \
+ 	) > $@
+ 
+ $(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
diff --git a/sys-fs/lvm2/files/lvm2-2.02.186-udev_remove_unsupported_option.patch b/sys-fs/lvm2/files/lvm2-2.02.186-udev_remove_unsupported_option.patch
new file mode 100644
index 0000000..f895e19
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.186-udev_remove_unsupported_option.patch
@@ -0,0 +1,34 @@
+From f98f79a047dd1c4980008e0ed6c9ad4e18596cdc Mon Sep 17 00:00:00 2001
+From: Peter Rajnoha <prajnoha@redhat.com>
+Date: Tue, 13 Aug 2019 15:18:30 +0200
+Subject: [PATCH] udev: remove unsupported OPTIONS+="event_timeout" rule
+
+The OPTIONS+="event_timeout" is Unsupported since systemd/udev version 216,
+that is ~5 years ago.
+
+Since systemd/udev version 243, there's a new message printed if unsupported
+OPTIONS value is used:
+
+  Invalid value for OPTIONS key, ignoring: 'event_timeout=180'
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1740666
+---
+ udev/11-dm-lvm.rules.in | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
+index 91cb991df9..7c589943b7 100644
+--- a/udev/11-dm-lvm.rules.in
++++ b/udev/11-dm-lvm.rules.in
+@@ -37,8 +37,6 @@ ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHE
+ 
+ ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
+ 
+-OPTIONS+="event_timeout=180"
+-
+ # Do not create symlinks for inappropriate subdevices.
+ ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
+ ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
+-- 
+2.24.0
+
diff --git a/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch b/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch
deleted file mode 100644
index 1bae0db..0000000
--- a/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-http://bugs.gentoo.org/330255
-
-liblvm2app.so: undefined reference to `floor'
-
---- LVM2/liblvm/Makefile.in
-+++ LVM2/liblvm/Makefile.in
-@@ -39,7 +39,7 @@
- 
- include $(top_builddir)/make.tmpl
- 
--LIBS += $(LVMINTERNAL_LIBS) -ldevmapper
-+LIBS += $(LVMINTERNAL_LIBS) -ldevmapper -lm
- 
- ifeq ("@DMEVENTD@", "yes")
-   LIBS += -ldevmapper-event
diff --git a/sys-fs/lvm2/files/lvm2-2.03.05-dmeventd-no-idle-exit.patch b/sys-fs/lvm2/files/lvm2-2.03.05-dmeventd-no-idle-exit.patch
new file mode 100644
index 0000000..ec37e5d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.03.05-dmeventd-no-idle-exit.patch
@@ -0,0 +1,81 @@
+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
+
+Forward-ported from 2.02.184 to 2.03.05
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ daemons/dmeventd/dmeventd.c | 16 ++++++++++++++--
+ man/dmeventd.8_main         |  4 ++++
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
+index 33859ef414..ac0b9743fc 100644
+--- a/daemons/dmeventd/dmeventd.c
++++ b/daemons/dmeventd/dmeventd.c
+@@ -2158,6 +2158,18 @@ int main(int argc, char *argv[])
+ 		.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;
+ 
+@@ -2253,7 +2265,7 @@ int main(int argc, char *argv[])
+ 		_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 */
+@@ -2262,7 +2274,7 @@ int main(int argc, char *argv[])
+ 					 (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? */
+diff --git a/man/dmeventd.8_main b/man/dmeventd.8_main
+index dc4abf627e..4b0e522041 100644
+--- a/man/dmeventd.8_main
++++ b/man/dmeventd.8_main
+@@ -178,6 +178,10 @@ is processed.
+ Variable is set by thin and vdo plugin to prohibit recursive interation
+ 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
+ .
+-- 
+2.22.0
+
diff --git a/sys-fs/lvm2/files/lvm2-2.03.05-dynamic-static-ldflags.patch b/sys-fs/lvm2/files/lvm2-2.03.05-dynamic-static-ldflags.patch
new file mode 100644
index 0000000..2b9a5dd
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.03.05-dynamic-static-ldflags.patch
@@ -0,0 +1,75 @@
+From 93101699f5e1190184c00c99ab7b6e9717e5019a Mon Sep 17 00:00:00 2001
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Wed, 24 Jul 2019 11:11:35 +0200
+Subject: [PATCH] Add dynamic static ldflags
+
+Forward-ported from 2.02.178 to 2.03.05
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ configure.ac                 | 2 ++
+ daemons/dmeventd/Makefile.in | 2 +-
+ make.tmpl.in                 | 1 +
+ tools/Makefile.in            | 2 +-
+ 4 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1e45c0edcb..cc2625294a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -33,6 +33,7 @@ case "$host_os" in
+ 		CLDFLAGS="${CLDFLAGS:"$LDFLAGS"} -Wl,--version-script,.export.sym"
+ 		# equivalent to -rdynamic
+ 		ELDFLAGS="-Wl,--export-dynamic"
++		STATIC_LDFLAGS="-Wl,--no-export-dynamic"
+ 		# FIXME Generate list and use --dynamic-list=.dlopen.sym
+ 		CLDWHOLEARCHIVE="-Wl,-whole-archive"
+ 		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
+@@ -1758,6 +1759,7 @@ AC_SUBST(SYSCONFDIR)
+ AC_SUBST(SYSTEMD_LIBS)
+ AC_SUBST(SNAPSHOTS)
+ AC_SUBST(STATICDIR)
++AC_SUBST(STATIC_LDFLAGS)
+ AC_SUBST(STATIC_LINK)
+ AC_SUBST(TESTSUITE_DATA)
+ AC_SUBST(THIN)
+diff --git a/daemons/dmeventd/Makefile.in b/daemons/dmeventd/Makefile.in
+index 6bd36d0325..a3c30ec1a0 100644
+--- a/daemons/dmeventd/Makefile.in
++++ b/daemons/dmeventd/Makefile.in
+@@ -66,7 +66,7 @@ dmeventd: $(LIB_SHARED) dmeventd.o
+ 
+ dmeventd.static: $(LIB_STATIC) dmeventd.o
+ 	@echo "    [CC] $@"
+-	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
++	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
+ 		-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS) $(STATIC_LIBS)
+ 
+ ifeq ("@PKGCONFIG@", "yes")
+diff --git a/make.tmpl.in b/make.tmpl.in
+index f3332e91c1..1489c2afad 100644
+--- a/make.tmpl.in
++++ b/make.tmpl.in
+@@ -68,6 +68,7 @@ DEFS += @DEFS@
+ # FIXME set this only where it's needed, not globally?
+ CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
+ LDFLAGS ?= @LDFLAGS@
++STATIC_LDFLAGS += @STATIC_LDFLAGS@
+ CLDFLAGS += @CLDFLAGS@
+ ELDFLAGS += @ELDFLAGS@
+ LDDEPS += @LDDEPS@
+diff --git a/tools/Makefile.in b/tools/Makefile.in
+index 2620daa17c..e5fc9c4ae4 100644
+--- a/tools/Makefile.in
++++ b/tools/Makefile.in
+@@ -136,7 +136,7 @@ man-generator: man-generator.o
+ 
+ lvm.static: $(OBJECTS) lvm-static.o $(LVMINTERNAL_LIBS)
+ 	@echo "    [CC] $@"
+-	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ $+ \
++	$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) -o $@ $+ \
+ 	      $(DMEVENT_LIBS) $(STATIC_LIBS) $(LVMLIBS)
+ 
+ liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
+-- 
+2.22.0
+
diff --git a/sys-fs/lvm2/files/lvm2-2.03.05-pthread-pkgconfig.patch b/sys-fs/lvm2/files/lvm2-2.03.05-pthread-pkgconfig.patch
new file mode 100644
index 0000000..56aa2a7
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.03.05-pthread-pkgconfig.patch
@@ -0,0 +1,48 @@
+From dbb68df8d02eff87f10df331e17bd0940e158f56 Mon Sep 17 00:00:00 2001
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Wed, 24 Jul 2019 11:15:59 +0200
+Subject: [PATCH] Add pthread to libdevmapper pkgconfig file
+
+Forward-ported from 2.02.176 to 2.03.05
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ libdm/libdevmapper.pc.in | 2 +-
+ tools/Makefile.in        | 5 +++++
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/libdm/libdevmapper.pc.in b/libdm/libdevmapper.pc.in
+index a325aeb9e0..aa0980378f 100644
+--- a/libdm/libdevmapper.pc.in
++++ b/libdm/libdevmapper.pc.in
+@@ -9,4 +9,4 @@ Version: @DM_LIB_PATCHLEVEL@
+ Cflags: -I${includedir} 
+ Libs: -L${libdir} -ldevmapper
+ Requires.private: @SELINUX_PC@ @UDEV_PC@
+-Libs.private: -lm @RT_LIBS@
++Libs.private: -lm @RT_LIBS@ @PTHREAD_LIBS@
+diff --git a/tools/Makefile.in b/tools/Makefile.in
+index e5fc9c4ae4..12e4de2c63 100644
+--- a/tools/Makefile.in
++++ b/tools/Makefile.in
+@@ -87,6 +87,7 @@ ifeq ("@STATIC_LINK@", "yes")
+   TARGETS += lvm.static
+   INSTALL_LVM_TARGETS += install_tools_static
+   INSTALL_CMDLIB_TARGETS += install_cmdlib_static
++  STATIC_LIBS += @PTHREAD_LIBS@
+ endif
+ 
+ LVMLIBS = $(SYSTEMD_LIBS) -L$(top_builddir)/libdm -ldevmapper $(LIBS) -laio
+@@ -113,6 +114,10 @@ CFLOW_TARGET = lvm
+ 
+ include $(top_builddir)/make.tmpl
+ 
++ifeq ("@STATIC_LINK@", "yes")
++    STATIC_LIBS += @PTHREAD_LIBS@
++endif
++
+ device-mapper:
+ 
+ all: device-mapper
+-- 
+2.22.0
+
diff --git a/sys-fs/lvm2/files/lvm2-2.03.06-example.conf.in.patch b/sys-fs/lvm2/files/lvm2-2.03.06-example.conf.in.patch
new file mode 100644
index 0000000..329bfde
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.03.06-example.conf.in.patch
@@ -0,0 +1,56 @@
+From a26cc1e7e299b61d1877ead03aacafef9fbe81ff Mon Sep 17 00:00:00 2001
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Fri, 25 Oct 2019 08:45:17 +0200
+Subject: [PATCH] Add Gentoo specific changes
+
+Forward-ported from 2.03.05 to 2.03.06
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ conf/example.conf.in | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/conf/example.conf.in b/conf/example.conf.in
+index 05b0857920..33ffb0097c 100644
+--- a/conf/example.conf.in
++++ b/conf/example.conf.in
+@@ -143,6 +143,9 @@ devices {
+ 	# 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:
+@@ -1680,7 +1683,7 @@ activation {
+ 
+ # 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.
+@@ -1725,7 +1728,8 @@ activation {
+ 	# 
+ 	# 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.
+@@ -1768,7 +1772,7 @@ activation {
+ 	# This configuration option is advanced.
+ 	# This configuration option has an automatic default value.
+ 	# stripesize = 64
+-# }
++}
+ 
+ # Configuration section report.
+ # LVM report command output formatting.
+-- 
+2.24.0.rc1
+
diff --git a/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2 b/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2
deleted file mode 100644
index c95a47d..0000000
--- a/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-pidfile="/run/lvmetad.pid"
-command="/sbin/lvmetad"
-command_args="${LVMETAD_OPTS:=-p ${pidfile}}"
-start_stop_daemon_args="--pidfile ${pidfile}"
-
-depend() {
-	:
-}
diff --git a/sys-fs/lvm2/files/lvmetad.initd-2.02.116-r3 b/sys-fs/lvm2/files/lvmetad.initd-2.02.116-r3
index 2efce42..55bbf9c 100644
--- a/sys-fs/lvm2/files/lvmetad.initd-2.02.116-r3
+++ b/sys-fs/lvm2/files/lvmetad.initd-2.02.116-r3
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 pidfile="/run/lvmetad.pid"
diff --git a/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1 b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
index 16e2cc3..8b5986f 100644
--- a/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
+++ b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 pidfile="/run/lvmlockd.pid"
diff --git a/sys-fs/lvm2/files/lvmpolld.initd-2.02.183 b/sys-fs/lvm2/files/lvmpolld.initd-2.02.183
new file mode 100644
index 0000000..6b26010
--- /dev/null
+++ b/sys-fs/lvm2/files/lvmpolld.initd-2.02.183
@@ -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
+}
diff --git a/sys-fs/lvm2/lvm2-2.02.145-r2.ebuild b/sys-fs/lvm2/lvm2-2.02.145-r2.ebuild
deleted file mode 100644
index 3465e32..0000000
--- a/sys-fs/lvm2/lvm2-2.02.145-r2.ebuild
+++ /dev/null
@@ -1,292 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-inherit autotools eutils linux-info multilib systemd toolchain-funcs udev flag-o-matic
-
-DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
-HOMEPAGE="https://sourceware.org/lvm2/"
-SRC_URI="ftp://sourceware.org/pub/lvm2/${PN/lvm/LVM}.${PV}.tgz
-	ftp://sourceware.org/pub/lvm2/old/${PN/lvm/LVM}.${PV}.tgz"
-
-LICENSE="GPL-2"
-SLOT="0"
-KEYWORDS="*"
-IUSE="readline static static-libs systemd clvm cman corosync lvm1 lvm2create_initrd openais selinux +udev +thin device-mapper-only"
-REQUIRED_USE="device-mapper-only? ( !clvm !cman !corosync !lvm1 !lvm2create_initrd !openais !thin )
-	systemd? ( udev )
-	clvm? ( !systemd )"
-
-DEPEND_COMMON="
-	clvm? (
-		cman? ( =sys-cluster/cman-3* )
-		corosync? ( sys-cluster/corosync )
-		openais? ( sys-cluster/openais )
-		=sys-cluster/libdlm-3*
-	)
-
-	readline? ( sys-libs/readline:0= )
-	systemd? ( >=sys-apps/systemd-205:0= )
-	udev? ( >=virtual/libudev-208:=[static-libs?] )"
-# /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
-	!<sys-apps/openrc-0.11
-	!<sys-fs/cryptsetup-1.1.2
-	!!sys-fs/clvm
-	!!sys-fs/lvm-user
-	>=sys-apps/util-linux-2.16
-	lvm2create_initrd? ( sys-apps/makedev )
-	thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )"
-# note: thin- 0.3.0 is required to avoid --disable-thin_check_needs_check
-# USE 'static' currently only works with eudev, bug 520450
-DEPEND="${DEPEND_COMMON}
-	virtual/pkgconfig
-	>=sys-devel/binutils-2.20.1-r1
-	sys-devel/autoconf-archive
-	static? (
-		selinux? ( sys-libs/libselinux[static-libs] )
-		udev? ( >=sys-fs/eudev-3.1.2[static-libs] )
-		>=sys-apps/util-linux-2.16[static-libs]
-	)"
-
-S=${WORKDIR}/${PN/lvm/LVM}.${PV}
-
-PATCHES=(
-	# Gentoo specific modification(s):
-	"${FILESDIR}"/${PN}-2.02.129-example.conf.in.patch
-
-	# For upstream -- review and forward:
-	"${FILESDIR}"/${PN}-2.02.63-always-make-static-libdm.patch
-	"${FILESDIR}"/${PN}-2.02.56-lvm2create_initrd.patch
-	"${FILESDIR}"/${PN}-2.02.67-createinitrd.patch #301331
-	"${FILESDIR}"/${PN}-2.02.99-locale-muck.patch #330373
-	"${FILESDIR}"/${PN}-2.02.70-asneeded.patch # -Wl,--as-needed
-	"${FILESDIR}"/${PN}-2.02.139-dynamic-static-ldflags.patch #332905
-	"${FILESDIR}"/${PN}-2.02.129-static-pkgconfig-libs.patch #370217, #439414 + blkid
-	"${FILESDIR}"/${PN}-2.02.130-pthread-pkgconfig.patch #492450
-	"${FILESDIR}"/${PN}-2.02.145-mkdev.patch #580062
-)
-
-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
-
-	sed -i \
-		-e "1iAR = $(tc-getAR)" \
-		-e "s:CC ?= @CC@:CC = $(tc-getCC):" \
-		make.tmpl.in || die #444082
-
-	sed -i -e '/FLAG/s:-O2::' configure{.in,} || die #480212
-
-	if use udev && ! use device-mapper-only; then
-		sed -i -e '/use_lvmetad =/s:0:1:' conf/example.conf.in || die #514196
-		elog "Notice that \"use_lvmetad\" setting is enabled with USE=\"udev\" in"
-		elog "/etc/lvm/lvm.conf, which will require restart of udev, lvm, and lvmetad"
-		elog "if it was previously disabled."
-	fi
-
-	sed -i -e "s:/usr/bin/true:$(type -P true):" scripts/blk_availability_systemd_red_hat.service.in || die #517514
-
-	# Without thin-privision-tools, there is nothing to install for target install_man7:
-	use thin || { sed -i -e '/^install_lvm2/s:install_man7::' man/Makefile.in || die; }
-
-	eautoreconf
-}
-
-src_configure() {
-	filter-flags -flto
-	local myconf=()
-	local buildmode
-
-	myconf+=( $(use_enable !device-mapper-only dmeventd) )
-	myconf+=( $(use_enable !device-mapper-only cmdlib) )
-	myconf+=( $(use_enable !device-mapper-only applib) )
-	myconf+=( $(use_enable !device-mapper-only fsadm) )
-	myconf+=( $(use_enable !device-mapper-only lvmetad) )
-	use device-mapper-only && myconf+=( --disable-udev-systemd-background-jobs )
-
-	# Most of this package does weird stuff.
-	# The build options are tristate, and --without is NOT supported
-	# options: 'none', 'internal', 'shared'
-	if use static; then
-		buildmode="internal"
-		# This only causes the .static versions to become available
-		myconf+=( --enable-static_link )
-	else
-		buildmode="shared"
-	fi
-	dmbuildmode=$(use !device-mapper-only && echo internal || echo none)
-
-	# dmeventd requires mirrors to be internal, and snapshot available
-	# so we cannot disable them
-	myconf+=( --with-mirrors=${dmbuildmode} )
-	myconf+=( --with-snapshots=${dmbuildmode} )
-	if use thin; then
-		myconf+=( --with-thin=internal --with-cache=internal )
-		local texec
-		for texec in check dump repair restore; do
-			myconf+=( --with-thin-${texec}="${EPREFIX}"/sbin/thin_${texec} )
-			myconf+=( --with-cache-${texec}="${EPREFIX}"/sbin/cache_${texec} )
-		done
-	else
-		myconf+=( --with-thin=none --with-cache=none )
-	fi
-
-	if use lvm1; then
-		myconf+=( --with-lvm1=${buildmode} )
-	else
-		myconf+=( --with-lvm1=none )
-	fi
-
-	# disable O_DIRECT support on hppa, breaks pv detection (#99532)
-	use hppa && myconf+=( --disable-o_direct )
-
-	if use clvm; then
-		myconf+=( --with-cluster=${buildmode} )
-		# 4-state! Make sure we get it right, per bug 210879
-		# Valid options are: none, cman, gulm, all
-		#
-		# 2009/02:
-		# gulm is removed now, now dual-state:
-		# cman, none
-		# all still exists, but is not needed
-		#
-		# 2009/07:
-		# TODO: add corosync and re-enable ALL
-		local clvmd=""
-		use cman && clvmd="cman"
-		#clvmd="${clvmd/cmangulm/all}"
-		use corosync && clvmd="${clvmd:+$clvmd,}corosync"
-		use openais && clvmd="${clvmd:+$clvmd,}openais"
-		[ -z "${clvmd}" ] && clvmd="none"
-		myconf+=( --with-clvmd=${clvmd} )
-		myconf+=( --with-pool=${buildmode} )
-	else
-		myconf+=( --with-clvmd=none --with-cluster=none )
-	fi
-
-	econf \
-		$(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 udev udev_rules) \
-		$(use_enable udev udev_sync) \
-		$(use_with udev udevdir "$(get_udevdir)"/rules.d) \
-		$(use_enable systemd udev-systemd-background-jobs) \
-		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
-		${myconf[@]} \
-		CLDFLAGS="${LDFLAGS}"
-}
-
-src_compile() {
-	pushd include >/dev/null
-	emake
-	popd >/dev/null
-
-	if use device-mapper-only ; then
-		emake device-mapper
-	else
-		emake
-		emake CC="$(tc-getCC)" -C scripts lvm2_activation_generator_systemd_red_hat
-	fi
-}
-
-src_install() {
-	local inst
-	INSTALL_TARGETS="install install_tmpfiles_configuration"
-	# install systemd related files only when requested, bug #522430
-	use systemd && INSTALL_TARGETS="${INSTALL_TARGETS} install_systemd_units install_systemd_generators"
-	use device-mapper-only && INSTALL_TARGETS="install_device-mapper"
-	for inst in ${INSTALL_TARGETS}; do
-		emake DESTDIR="${D}" ${inst}
-	done
-
-	newinitd "${FILESDIR}"/device-mapper.rc-2.02.105-r2 device-mapper
-	newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
-
-	if use !device-mapper-only ; then
-		newinitd "${FILESDIR}"/dmeventd.initd-2.02.67-r1 dmeventd
-		newinitd "${FILESDIR}"/lvm.rc-2.02.116-r6 lvm
-		newconfd "${FILESDIR}"/lvm.confd-2.02.28-r2 lvm
-
-		newinitd "${FILESDIR}"/lvm-monitoring.initd-2.02.105-r2 lvm-monitoring
-		newinitd "${FILESDIR}"/lvmetad.initd-2.02.116-r3 lvmetad
-	fi
-
-	if use clvm; then
-		newinitd "${FILESDIR}"/clvmd.rc-2.02.39 clvmd
-		newconfd "${FILESDIR}"/clvmd.confd-2.02.39 clvmd
-	fi
-
-	if use static-libs; then
-		dolib.a libdm/ioctl/libdevmapper.a
-		if use !device-mapper-only ; then
-			dolib.a libdaemon/client/libdaemonclient.a #462908
-			#gen_usr_ldscript libdevmapper.so
-			dolib.a daemons/dmeventd/libdevmapper-event.a
-			#gen_usr_ldscript libdevmapper-event.so
-		fi
-	else
-		rm -f "${ED}"usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a
-	fi
-
-	if use lvm2create_initrd; then
-		dosbin scripts/lvm2create_initrd/lvm2create_initrd
-		doman scripts/lvm2create_initrd/lvm2create_initrd.8
-		newdoc scripts/lvm2create_initrd/README README.lvm2create_initrd
-	fi
-
-	insinto /etc
-	doins "${FILESDIR}"/dmtab
-
-	dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
-}
-
-pkg_postinst() {
-	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 /etc/lvm/lvm.conf if you want"
-	ewarn "to enable lvm autoactivation and metadata caching."
-}
-
-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"
-}
diff --git a/sys-fs/lvm2/lvm2-2.02.187-r2.ebuild b/sys-fs/lvm2/lvm2-2.02.187-r2.ebuild
new file mode 100644
index 0000000..1e90e17
--- /dev/null
+++ b/sys-fs/lvm2/lvm2-2.02.187-r2.ebuild
@@ -0,0 +1,279 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit autotools linux-info multilib systemd toolchain-funcs udev flag-o-matic
+
+DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
+HOMEPAGE="https://sourceware.org/lvm2/"
+SRC_URI="ftp://sourceware.org/pub/lvm2/${PN/lvm/LVM}.${PV}.tgz
+	ftp://sourceware.org/pub/lvm2/old/${PN/lvm/LVM}.${PV}.tgz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="*"
+IUSE="readline static static-libs systemd lvm2create_initrd sanlock selinux +udev +thin device-mapper-only"
+REQUIRED_USE="device-mapper-only? ( !lvm2create_initrd !sanlock !thin )
+	systemd? ( udev )"
+
+DEPEND_COMMON="
+	dev-libs/libaio[static-libs?]
+	static? ( dev-libs/libaio[static-libs] )
+	!static? ( dev-libs/libaio[static-libs?] )
+	readline? ( sys-libs/readline:0= )
+	sanlock? ( sys-cluster/sanlock )
+	systemd? ( >=sys-apps/systemd-205:0= )
+	udev? ( >=virtual/libudev-208:=[static-libs(-)?] )"
+# /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
+	!<sys-apps/openrc-0.11
+	!<sys-fs/cryptsetup-1.1.2
+	!!sys-fs/lvm-user
+	>=sys-apps/util-linux-2.16
+	lvm2create_initrd? ( sys-apps/makedev )
+	thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )"
+# note: thin- 0.3.0 is required to avoid --disable-thin_check_needs_check
+# USE 'static' currently only works with eudev, bug 520450
+DEPEND="${DEPEND_COMMON}
+	>=sys-devel/binutils-2.20.1-r1
+	static? (
+		selinux? ( sys-libs/libselinux[static-libs] )
+		udev? ( >=sys-fs/eudev-3.1.2[static-libs] )
+		>=sys-apps/util-linux-2.16[static-libs]
+	)"
+BDEPEND="
+	sys-devel/autoconf-archive
+	virtual/pkgconfig
+"
+
+S="${WORKDIR}/${PN/lvm/LVM}.${PV}"
+
+PATCHES=(
+	# Gentoo specific modification(s):
+	"${FILESDIR}"/${PN}-2.02.178-example.conf.in.patch
+
+	# For upstream -- review and forward:
+	"${FILESDIR}"/${PN}-2.02.63-always-make-static-libdm.patch
+	"${FILESDIR}"/${PN}-2.02.56-lvm2create_initrd.patch
+	"${FILESDIR}"/${PN}-2.02.67-createinitrd.patch #301331
+	"${FILESDIR}"/${PN}-2.02.99-locale-muck.patch #330373
+	"${FILESDIR}"/${PN}-2.02.178-asneeded.patch # -Wl,--as-needed
+	"${FILESDIR}"/${PN}-2.02.178-dynamic-static-ldflags.patch #332905
+	"${FILESDIR}"/${PN}-2.02.178-static-pkgconfig-libs.patch #370217, #439414 + blkid
+	"${FILESDIR}"/${PN}-2.02.176-pthread-pkgconfig.patch #492450
+	"${FILESDIR}"/${PN}-2.02.171-static-libm.patch #617756
+	"${FILESDIR}"/${PN}-2.02.166-HPPA-no-O_DIRECT.patch #657446
+	#"${FILESDIR}"/${PN}-2.02.145-mkdev.patch #580062 # Merged upstream
+	"${FILESDIR}"/${PN}-2.02.184-dmeventd-no-idle-exit.patch
+	#"${FILESDIR}"/${PN}-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch #682380 # merged upstream
+	"${FILESDIR}"/${PN}-2.02.184-mksh_build.patch #686652
+	"${FILESDIR}"/${PN}-2.02.186-udev_remove_unsupported_option.patch #700160
+)
+
+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
+
+	sed -i \
+		-e "1iAR = $(tc-getAR)" \
+		-e "s:CC ?= @CC@:CC = $(tc-getCC):" \
+		make.tmpl.in || die #444082
+
+	sed -i -e '/FLAG/s:-O2::' configure{.ac,} || die #480212
+
+	if use udev && ! use device-mapper-only; then
+		sed -i -e '/use_lvmetad =/s:0:1:' conf/example.conf.in || die #514196
+		elog "Notice that \"use_lvmetad\" setting is enabled with USE=\"udev\" in"
+		elog "/etc/lvm/lvm.conf, which will require restart of udev, lvm, and lvmetad"
+		elog "if it was previously disabled."
+	fi
+
+	sed -i -e "s:/usr/bin/true:$(type -P true):" scripts/blk_availability_systemd_red_hat.service.in || die #517514
+
+	# Don't install thin man page when not requested
+	if ! use thin ; then
+		sed -i -e 's/^\(MAN7+=.*\) $(LVMTHINMAN) \(.*\)$/\1 \2/' man/Makefile.in || die
+	fi
+
+	eautoreconf
+}
+
+src_configure() {
+	filter-flags -flto
+	local myeconfargs=()
+
+	# Most of this package does weird stuff.
+	# The build options are tristate, and --without is NOT supported
+	# options: 'none', 'internal', 'shared'
+	myeconfargs+=(
+		$(use_enable !device-mapper-only dmfilemapd)
+		$(use_enable !device-mapper-only dmeventd)
+		$(use_enable !device-mapper-only cmdlib)
+		$(use_enable !device-mapper-only applib)
+		$(use_enable !device-mapper-only fsadm)
+		$(use_enable !device-mapper-only lvmetad)
+		$(use_enable !device-mapper-only lvmpolld)
+		$(usex device-mapper-only --disable-udev-systemd-background-jobs '')
+
+		# This only causes the .static versions to become available
+		$(usex static --enable-static_link '')
+
+		# dmeventd requires mirrors to be internal, and snapshot available
+		# so we cannot disable them
+		--with-mirrors="$(usex device-mapper-only none internal)"
+		--with-snapshots="$(usex device-mapper-only none internal)"
+
+		# disable O_DIRECT support on hppa, breaks pv detection (#99532)
+		$(usex hppa --disable-o_direct '')
+	)
+
+	if 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+=( --with-clvmd=none --with-cluster=none )
+
+	myeconfargs+=(
+		$(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 udev udev_rules)
+		$(use_enable udev udev_sync)
+		$(use_with udev udevdir "$(get_udevdir)"/rules.d)
+		$(use_enable sanlock lvmlockd-sanlock)
+		$(use_enable systemd udev-systemd-background-jobs)
+		$(use_enable systemd notify-dbus)
+		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
+		CLDFLAGS="${LDFLAGS}"
+	)
+	# Hard-wire this to bash as some shells (dash) don't know
+	# "-o pipefail" #682404
+	CONFIG_SHELL="/bin/bash" \
+	econf "${myeconfargs[@]}"
+}
+
+src_compile() {
+	pushd include >/dev/null
+	emake V=1
+	popd >/dev/null
+
+	if use device-mapper-only ; then
+		emake V=1 device-mapper
+	else
+		emake V=1
+		emake V=1 CC="$(tc-getCC)" -C scripts lvm2_activation_generator_systemd_red_hat
+	fi
+}
+
+src_install() {
+	local inst INSTALL_TARGETS
+	INSTALL_TARGETS=( install install_tmpfiles_configuration )
+	# install systemd related files only when requested, bug #522430
+	use systemd && INSTALL_TARGETS+=( install_systemd_units install_systemd_generators )
+	use device-mapper-only && INSTALL_TARGETS=( install_device-mapper )
+	for inst in ${INSTALL_TARGETS[@]}; do
+		emake V=1 DESTDIR="${D}" ${inst}
+	done
+
+	newinitd "${FILESDIR}"/device-mapper.rc-2.02.105-r2 device-mapper
+	newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
+
+	if use !device-mapper-only ; then
+		newinitd "${FILESDIR}"/dmeventd.initd-2.02.184-r2 dmeventd
+		newinitd "${FILESDIR}"/lvm.rc-2.02.187 lvm
+		newconfd "${FILESDIR}"/lvm.confd-2.02.184-r3 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-2.02.105-r2 lvm-monitoring
+		newinitd "${FILESDIR}"/lvmetad.initd-2.02.116-r3 lvmetad
+		newinitd "${FILESDIR}"/lvmpolld.initd-2.02.183 lvmpolld
+	fi
+
+	if use sanlock; then
+		newinitd "${FILESDIR}"/lvmlockd.initd-2.02.166-r1 lvmlockd
+	fi
+
+	if use static-libs; then
+		dolib.a libdm/ioctl/libdevmapper.a
+		if use !device-mapper-only; 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
+	fi
+
+	if use lvm2create_initrd; then
+		dosbin scripts/lvm2create_initrd/lvm2create_initrd
+		doman scripts/lvm2create_initrd/lvm2create_initrd.8
+		newdoc scripts/lvm2create_initrd/README README.lvm2create_initrd
+	fi
+
+	insinto /etc
+	doins "${FILESDIR}"/dmtab
+
+	dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
+}
+
+pkg_postinst() {
+	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 /etc/lvm/lvm.conf if you want"
+	ewarn "to enable lvm autoactivation and metadata caching."
+}
+
+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"
+}
diff --git a/sys-fs/lvm2/metadata.xml b/sys-fs/lvm2/metadata.xml
index cca547c..8fb1374 100644
--- a/sys-fs/lvm2/metadata.xml
+++ b/sys-fs/lvm2/metadata.xml
@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
+	<maintainer type="project">
+		<email>base-system@gentoo.org</email>
+		<name>Gentoo Base System</name>
+	</maintainer>
 	<maintainer type="person">
 		<email>robbat2@gentoo.org</email>
 		<name>Robin H. Johnson</name>
@@ -10,18 +14,8 @@
 		<name>Alasdair Kergon</name>
 		<description>Upstream Maintainer (please CC on bugs)</description>
 	</maintainer>
-	<maintainer type="person">
-		<email>cardoe@gentoo.org</email>
-		<name>Doug Goldstein</name>
-		<description>Backup to Robin. Please CC on bugs.</description>
-	</maintainer>
 	<use>
-		<flag name="clvm">Allow users to build clustered lvm2</flag>
-		<flag name="cman">Cman support for clustered lvm</flag>
-		<flag name="corosync">Corosync support for clustered lvm</flag>
-		<flag name="lvm1">Allow users to build lvm2 with lvm1 support</flag>
 		<flag name="lvm2create_initrd">Install lvm2create_initrd script and pull in <pkg>sys-apps/makedev</pkg> for the /sbin/MAKEDEV command</flag>
-		<flag name="openais">Openais support for clustered lvm</flag>
 		<flag name="thin">Support for thin volumes</flag>
 		<flag name="device-mapper-only">Build only device-mapper and not the rest of LVM2 (UNSUPPORTED)</flag>
 		<flag name="sanlock">Enable lvmlockd with support for sanlock</flag>