summaryrefslogtreecommitdiff
path: root/sys-fs/lvm2/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-fs/lvm2/files
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-fs/lvm2/files')
-rw-r--r--sys-fs/lvm2/files/clvmd.confd-2.02.399
-rw-r--r--sys-fs/lvm2/files/clvmd.rc-2.02.39145
-rw-r--r--sys-fs/lvm2/files/device-mapper.conf-1.02.22-r31
-rw-r--r--sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2146
-rw-r--r--sys-fs/lvm2/files/dmeventd.initd-2.02.67-r125
-rw-r--r--sys-fs/lvm2/files/dmtab11
-rw-r--r--sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r238
-rw-r--r--sys-fs/lvm2/files/lvm.confd-2.02.28-r25
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.105-r296
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.116-r4132
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.116-r6132
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.166-r2145
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.172145
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch32
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.108-example.conf.in.patch50
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.108-static-pkgconfig-libs.patch104
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.129-dynamic-static-ldflags.patch59
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch52
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.129-static-pkgconfig-libs.patch102
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.130-pthread-pkgconfig.patch32
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.139-dynamic-static-ldflags.patch63
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.145-mkdev.patch127
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch104
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.56-lvm2create_initrd.patch72
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.63-always-make-static-libdm.patch42
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.67-createinitrd.patch18
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch15
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.92-dynamic-static-ldflags.patch63
-rw-r--r--sys-fs/lvm2/files/lvm2-2.02.99-locale-muck.patch11
-rw-r--r--sys-fs/lvm2/files/lvmetad.initd-2.02.105-r212
-rw-r--r--sys-fs/lvm2/files/lvmetad.initd-2.02.116-r317
-rw-r--r--sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r117
32 files changed, 2022 insertions, 0 deletions
diff --git a/sys-fs/lvm2/files/clvmd.confd-2.02.39 b/sys-fs/lvm2/files/clvmd.confd-2.02.39
new file mode 100644
index 000000000000..57821709f5f8
--- /dev/null
+++ b/sys-fs/lvm2/files/clvmd.confd-2.02.39
@@ -0,0 +1,9 @@
+# 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
new file mode 100644
index 000000000000..efadd892ee94
--- /dev/null
+++ b/sys-fs/lvm2/files/clvmd.rc-2.02.39
@@ -0,0 +1,145 @@
+#!/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.conf-1.02.22-r3 b/sys-fs/lvm2/files/device-mapper.conf-1.02.22-r3
new file mode 100644
index 000000000000..bc7a25158635
--- /dev/null
+++ b/sys-fs/lvm2/files/device-mapper.conf-1.02.22-r3
@@ -0,0 +1 @@
+RC_AFTER="lvm"
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
new file mode 100644
index 000000000000..7dbacce0d94f
--- /dev/null
+++ b/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2
@@ -0,0 +1,146 @@
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+ # means dmeventd is NOT notified, as it cannot be safely running
+ before dmeventd checkfs fsck
+ after modules
+}
+
+dm_in_proc() {
+ local retval=0
+ for x in devices misc ; do
+ grep -qs 'device-mapper' /proc/${x}
+ retval=$((${retval} + $?))
+ done
+ return ${retval}
+}
+
+# char **build_dmsetup_command(volume)
+#
+# Returns complete dmsetup command given single volume name
+build_dmsetup_command() {
+ local count dmsetup_cmd
+
+ # Number of lines mentioning volume name
+ count=$(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | grep -c ${1})
+
+ # If there's just one line:
+ if [ ${count} -eq 1 ] ; then
+ echo "echo $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk '{$1=""; print $0}') | /sbin/dmsetup create ${1}"
+
+ # For all cases with more lines:
+ elif [ ${count} -gt 1 ] ; then
+ for c in $( seq 1 ${count} ) ; do
+ if [ ${c} -eq 1 ] ; then
+ # Heavy escaping in awk-statement because we cannot use apostrophes
+ dmsetup_cmd="echo -e $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+ else
+ # Append starting with newline
+ dmsetup_cmd="${dmsetup_cmd}\\\\n \
+ $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+ fi
+ done
+ echo "${dmsetup_cmd} | /sbin/dmsetup create ${1}"
+ fi
+
+ return 0
+}
+
+# char **get_new_dm_volumes(void)
+#
+# Return unique volumes from /etc/dmtab
+get_new_dm_volumes() {
+ local volume
+
+ # Filter comments and blank lines
+ grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ awk '{ print $1 }' | \
+ uniq | \
+ while read volume ; do
+ # If it exists, skip it
+ dmvolume_exists "${volume%:}" && continue
+
+ echo "${volume%:}"
+ done
+
+ return 0
+}
+
+# int dmvolume_exists(volume)
+#
+# Return true if volume exists in DM table
+dmvolume_exists() {
+ local x line volume=$1
+
+ [ -z "${volume}" ] && return 1
+
+ /sbin/dmsetup ls 2>/dev/null | \
+ while read line ; do
+ for x in ${line} ; do
+ # the following conditonal return only breaks out
+ # of the while loop, as it is running in a pipe.
+ [ "${x}" = "${volume}" ] && return 1
+ # We only want to check the volume name
+ break
+ done
+ done
+
+ # if 1 was returned from the above loop, then indicate that
+ # volume exists
+ [ $? = 1 ] && return 0
+
+ # otherwise the loop exited normally and the volume does not
+ # exist
+ return 1
+}
+
+# int is_empty_dm_volume(volume)
+#
+# Return true if the volume exists in DM table, but is empty/non-valid
+is_empty_dm_volume() {
+ local table volume=$1
+
+ set -- $(/sbin/dmsetup table 2>/dev/null | grep -e "^${volume}:")
+ [ "${volume}" = "$1" -a -z "$2" ]
+}
+
+
+start() {
+ if [ -e /proc/modules ] && ! dm_in_proc ; then
+ modprobe dm-mod 2>/dev/null
+ fi
+ # Ensure the dirs exist for locking and running
+ checkpath -q -d -m 0700 -o root:root /run/lvm /run/lock/lvm
+
+ local x volume
+
+ if [ -x /sbin/dmsetup -a -c /dev/mapper/control -a -f /etc/dmtab ] ; then
+ [ -n "$(get_new_dm_volumes)" ] && \
+ einfo " Setting up device-mapper volumes:"
+
+ get_new_dm_volumes | \
+ while read x ; do
+ [ -n "${x}" ] || continue
+
+ volume="${x##* }"
+
+ ebegin " Creating volume: ${volume}"
+ if ! eval $(build_dmsetup_command ${volume}) >/dev/null 2>/dev/null ; then
+ eend 1 " Error creating volume: ${volume}"
+ # dmsetup still adds an empty volume in some cases,
+ # so lets remove it
+ is_empty_dm_volume "${volume}" && \
+ /sbin/dmsetup remove "${volume}" 2>/dev/null
+ else
+ eend 0
+ fi
+ done
+ fi
+}
+
diff --git a/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1 b/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1
new file mode 100644
index 000000000000..930e84baa866
--- /dev/null
+++ b/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1
@@ -0,0 +1,25 @@
+#!/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/dmtab b/sys-fs/lvm2/files/dmtab
new file mode 100644
index 000000000000..37a0d2864629
--- /dev/null
+++ b/sys-fs/lvm2/files/dmtab
@@ -0,0 +1,11 @@
+#/etc/dmraid: config file for adding device-mapper volumes at boot
+
+# Format: <volume name>: <table>
+# Example: isw0: 0 312602976 striped 2 128 /dev/sda 0 /dev/sdb 0
+#
+# Alternatively you can create all your volumes the first time, and just run:
+#
+# dmsetup table >> /etc/dmtab
+#
+# and verify that they are correct.
+
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
new file mode 100644
index 000000000000..d603718cc226
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2
@@ -0,0 +1,38 @@
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# This script is based on upstream file
+# LVM2.2.02.67/scripts/lvm2_monitoring_init_red_hat.in
+
+depend() {
+ # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+ # means dmeventd is NOT notified, as it cannot be safely running
+ need lvm dmeventd
+}
+
+VGCHANGE=/sbin/vgchange
+VGS=/sbin/vgs
+
+start() {
+ ret=0
+ # TODO do we want to separate out already active groups only?
+ VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+ ebegin "Starting LVM monitoring for VGs ${VGSLIST}:"
+ $VGCHANGE --monitor y --poll y ${VGSLIST}
+ ret=$?
+ eend $ret
+ return $ret
+
+}
+
+stop() {
+ ret=0
+ # TODO do we want to separate out already active groups only?
+ VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+ ebegin "Stopping LVM monitoring for VGs ${VGSLIST}:"
+ $VGCHANGE --monitor n ${VGSLIST}
+ ret=$?
+ eend $ret
+ return $ret
+}
diff --git a/sys-fs/lvm2/files/lvm.confd-2.02.28-r2 b/sys-fs/lvm2/files/lvm.confd-2.02.28-r2
new file mode 100644
index 000000000000..2fbd8668c376
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.confd-2.02.28-r2
@@ -0,0 +1,5 @@
+# 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
new file mode 100644
index 000000000000..c59f9c3c8788
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.105-r2
@@ -0,0 +1,96 @@
+#!/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
new file mode 100644
index 000000000000..74b4a41b9ea0
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.116-r4
@@ -0,0 +1,132 @@
+#!/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
new file mode 100644
index 000000000000..1bf075fae3ef
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.116-r6
@@ -0,0 +1,132 @@
+#!/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
new file mode 100644
index 000000000000..11329bbeaf33
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.166-r2
@@ -0,0 +1,145 @@
+#!/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
new file mode 100644
index 000000000000..9e22c2801ff1
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.172
@@ -0,0 +1,145 @@
+#!/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/lvm2-2.02.106-pthread-pkgconfig.patch b/sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch
new file mode 100644
index 000000000000..594d60617259
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.106-pthread-pkgconfig.patch
@@ -0,0 +1,32 @@
+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
new file mode 100644
index 000000000000..af5a5afe258d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.108-example.conf.in.patch
@@ -0,0 +1,50 @@
+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
new file mode 100644
index 000000000000..3ab699868a5d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.108-static-pkgconfig-libs.patch
@@ -0,0 +1,104 @@
+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
new file mode 100644
index 000000000000..efdfb81a8d1a
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.129-dynamic-static-ldflags.patch
@@ -0,0 +1,59 @@
+--- 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-example.conf.in.patch b/sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch
new file mode 100644
index 000000000000..076e06080ca3
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.129-example.conf.in.patch
@@ -0,0 +1,52 @@
+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
+@@ -128,6 +128,9 @@
+ # Example
+ # Accept every block device:
+ # filter = [ "a|.*/|" ]
++ # Gentoo: we exclude /dev/nbd by default, because it makes a lot of kernel
++ # noise when you probed while not available.
++ filter = [ "r|/dev/nbd.*|", "a/.*/" ]
+ # Reject the cdrom drive:
+ # filter = [ "r|/dev/cdrom|" ]
+ # Work with just loopback devices, e.g. for testing:
+@@ -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.
+ # This configuration option has an automatic default value.
+- # fallback_to_lvm1 = @DEFAULT_FALLBACK_TO_LVM1@
++ # 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 @@
+
+ # 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 @@
+ #
+ # 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.
+@@ -1486,7 +1491,7 @@
+ #
+ # This configuration option is advanced.
+ # This configuration option does not have a default value defined.
+-# }
++}
+
+ # Configuration section report.
+ # LVM report command output formatting.
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
new file mode 100644
index 000000000000..239694523b3d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.129-static-pkgconfig-libs.patch
@@ -0,0 +1,102 @@
+--- 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
new file mode 100644
index 000000000000..11db632e2e7e
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.130-pthread-pkgconfig.patch
@@ -0,0 +1,32 @@
+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
new file mode 100644
index 000000000000..312e546e2403
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.139-dynamic-static-ldflags.patch
@@ -0,0 +1,63 @@
+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
new file mode 100644
index 000000000000..f91dccd5c188
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.145-mkdev.patch
@@ -0,0 +1,127 @@
+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.172-static-pkgconfig-libs.patch b/sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch
new file mode 100644
index 000000000000..e25cb760ea89
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.172-static-pkgconfig-libs.patch
@@ -0,0 +1,104 @@
+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 @@
+ PKG_CHECK_MODULES(BLKID, blkid >= 2.24,
+ [ BLKID_WIPING=yes
+ 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.])
+ ], [if test "$BLKID_WIPING" = maybe; then
+@@ -1372,6 +1373,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.])
+
+ AC_CHECK_LIB(udev, udev_device_get_is_initialized, AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1,
+@@ -1653,19 +1655,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
+
+ ################################################################################
+@@ -2011,6 +2026,7 @@
+ ################################################################################
+ AC_SUBST(APPLIB)
+ AC_SUBST(AWK)
++AC_SUBST(BLKID_STATIC_LIBS)
+ AC_SUBST(BLKID_PC)
+ AC_SUBST(BUILD_CMIRRORD)
+ AC_SUBST(BUILD_DMEVENTD)
+@@ -2125,6 +2141,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)
+@@ -2140,6 +2157,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)
+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 @@
+
+ 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@
+@@ -68,10 +68,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.56-lvm2create_initrd.patch b/sys-fs/lvm2/files/lvm2-2.02.56-lvm2create_initrd.patch
new file mode 100644
index 000000000000..59aaa9b34a08
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.56-lvm2create_initrd.patch
@@ -0,0 +1,72 @@
+--- LVM2.2.02.56/scripts/lvm2create_initrd/lvm2create_initrd.orig 2006-11-21 22:41:56.000000000 +0000
++++ LVM2.2.02.56/scripts/lvm2create_initrd/lvm2create_initrd 2009-12-26 01:47:08.025224602 +0000
+@@ -54,7 +54,9 @@
+ DEVRAM=/tmp/initrd.$$
+
+ # set defaults
+-BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
++LVM=`which lvm.static`
++LVM=${LVM:-"`which lvm`"}
++BINFILES=${BINFILES:-"${LVM} `which bash` `which busybox` `which pivot_root`"}
+ BASICDEVICES=${BASICDEVICES:-"std consoleonly fd"}
+ BLOCKDEVICES=${BLOCKDEVICES:-"md hda hdb hdc hdd sda sdb sdc sdd"}
+ MAKEDEV=${MAKEDEV:-"debian"}
+@@ -119,6 +121,10 @@
+ echo "$PRE Mounting /proc"
+ mount -t proc none /proc
+
++# We need /sys for lvm
++echo "$PRE Mounting /sys"
++mount -t sysfs sysfs /sys
++
+ # plug in modules listed in /etc/modules
+ if [ -f /etc/modules ]; then
+ echo -n "$PRE plugging in kernel modules:"
+@@ -179,26 +185,29 @@
+ # run a shell if we're passed lvm2rescue on commandline
+ grep lvm2rescue /proc/cmdline 1>/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+- lvm vgchange --ignorelockingfailure -P -a y
++ $LVM vgchange --ignorelockingfailure -P -a y
+ do_shell
+ else
+- lvm vgchange --ignorelockingfailure -a y
++ $LVM vgchange --ignorelockingfailure -a y
+ fi
+
+ echo "$PRE Mounting root filesystem $rootvol ro"
+ mkdir /rootvol
+ if ! mount -t auto -o ro $rootvol /rootvol; then
+- echo "\t*FAILED*";
++ echo "\t*FAILED TRYING TO MOUNT ROOTVOL*";
+ do_shell
+ fi
+
+ echo "$PRE Umounting /proc"
+ umount /proc
+
++echo "$PRE Umounting /sys"
++umount /sys
++
+ echo "$PRE Changing roots"
+ cd /rootvol
+ if ! pivot_root . initrd ; then
+- echo "\t*FAILED*"
++ echo "\t*FAILED PIVOT TO NEW ROOT*"
+ do_shell
+ fi
+
+@@ -356,7 +365,7 @@
+ fi
+
+ verbose "creating basic set of directories in $TMPMNT"
+-(cd $TMPMNT; mkdir bin dev etc lib proc sbin var)
++(cd $TMPMNT; mkdir bin dev etc lib proc sbin sys var)
+ if [ $? -ne 0 ]; then
+ echo "$cmd -- ERROR creating directories in $TMPMNT"
+ cleanup 1
+@@ -499,4 +508,3 @@
+ FINALTXT
+
+ cleanup 0
+-
diff --git a/sys-fs/lvm2/files/lvm2-2.02.63-always-make-static-libdm.patch b/sys-fs/lvm2/files/lvm2-2.02.63-always-make-static-libdm.patch
new file mode 100644
index 000000000000..5ddcb4e56711
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.63-always-make-static-libdm.patch
@@ -0,0 +1,42 @@
+diff -Nuar --exclude '*~' LVM2.2.02.63.orig/daemons/dmeventd/Makefile.in LVM2.2.02.63/daemons/dmeventd/Makefile.in
+--- LVM2.2.02.63.orig/daemons/dmeventd/Makefile.in 2010-04-09 14:42:48.000000000 -0700
++++ LVM2.2.02.63/daemons/dmeventd/Makefile.in 2010-04-19 11:53:27.000000000 -0700
+@@ -28,11 +28,12 @@
+ INSTALL_LIB_TARGETS = install_lib_dynamic
+
+ LIB_NAME = libdevmapper-event
++LIB_STATIC = $(LIB_NAME).a
++INSTALL_LIB_TARGETS += install_lib_static
++TARGETS += $(LIB_STATIC)
+ ifeq ("@STATIC_LINK@", "yes")
+- LIB_STATIC = $(LIB_NAME).a
+- TARGETS += $(LIB_STATIC) dmeventd.static
++ TARGETS += dmeventd.static
+ INSTALL_DMEVENTD_TARGETS += install_dmeventd_static
+- INSTALL_LIB_TARGETS += install_lib_static
+ endif
+
+ LIB_VERSION = $(LIB_VERSION_DM)
+diff -Nuar --exclude '*~' LVM2.2.02.63.orig/libdm/Makefile.in LVM2.2.02.63/libdm/Makefile.in
+--- LVM2.2.02.63.orig/libdm/Makefile.in 2010-04-09 14:42:51.000000000 -0700
++++ LVM2.2.02.63/libdm/Makefile.in 2010-04-19 11:52:20.000000000 -0700
+@@ -34,8 +34,8 @@
+
+ INCLUDES = -I$(srcdir)/$(interface) -I$(srcdir)
+
+-ifeq ("@STATIC_LINK@", "yes")
+ LIB_STATIC = $(interface)/libdevmapper.a
++ifeq ("@STATIC_LINK@", "yes")
+ endif
+
+ LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX)
+@@ -63,8 +63,8 @@
+
+ INSTALL_TYPE = install_dynamic
+
+-ifeq ("@STATIC_LINK@", "yes")
+ INSTALL_TYPE += install_static
++ifeq ("@STATIC_LINK@", "yes")
+ endif
+
+ ifeq ("@PKGCONFIG@", "yes")
diff --git a/sys-fs/lvm2/files/lvm2-2.02.67-createinitrd.patch b/sys-fs/lvm2/files/lvm2-2.02.67-createinitrd.patch
new file mode 100644
index 000000000000..7f0bfb894f02
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.67-createinitrd.patch
@@ -0,0 +1,18 @@
+X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=301331
+X-Gentoo-Bug: 301331
+
+diff -Nuar LVM2.2.02.67.orig/scripts/lvm2create_initrd/lvm2create_initrd LVM2.2.02.67/scripts/lvm2create_initrd/lvm2create_initrd
+--- LVM2.2.02.67.orig/scripts/lvm2create_initrd/lvm2create_initrd 2010-06-07 18:44:34.182980475 +0000
++++ LVM2.2.02.67/scripts/lvm2create_initrd/lvm2create_initrd 2010-06-07 18:51:27.636312899 +0000
+@@ -469,9 +469,9 @@
+ rmdir $TMPMNT/lost+found
+
+ echo "$cmd -- ummounting ram disk"
+-umount $DEVRAM
++umount $TMPMNT
+ if [ $? -ne 0 ]; then
+- echo "$cmd -- ERROR umounting $DEVRAM"
++ echo "$cmd -- ERROR umounting $TMPMNT"
+ cleanup 1
+ fi
+
diff --git a/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch b/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch
new file mode 100644
index 000000000000..1bae0db10c1d
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.70-asneeded.patch
@@ -0,0 +1,15 @@
+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.02.92-dynamic-static-ldflags.patch b/sys-fs/lvm2/files/lvm2-2.02.92-dynamic-static-ldflags.patch
new file mode 100644
index 000000000000..de2b294ef3e4
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.92-dynamic-static-ldflags.patch
@@ -0,0 +1,63 @@
+diff -Nuar --exclude '*.rej' --exclude '*.orig' LVM2.2.02.92.orig/configure.in LVM2.2.02.92/configure.in
+--- LVM2.2.02.92.orig/configure.in 2012-02-20 11:36:27.000000000 -0800
++++ LVM2.2.02.92/configure.in 2012-02-20 15:53:40.700124222 -0800
+@@ -32,6 +32,7 @@
+ COPTIMISE_FLAG="-O2"
+ 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"
+@@ -1458,6 +1459,7 @@
+ AC_SUBST(SELINUX_PC)
+ AC_SUBST(SNAPSHOTS)
+ AC_SUBST(STATICDIR)
++AC_SUBST(STATIC_LDFLAGS)
+ AC_SUBST(STATIC_LINK)
+ AC_SUBST(TESTING)
+ AC_SUBST(THIN)
+diff -Nuar --exclude '*.rej' --exclude '*.orig' LVM2.2.02.92.orig/daemons/dmeventd/Makefile.in LVM2.2.02.92/daemons/dmeventd/Makefile.in
+--- LVM2.2.02.92.orig/daemons/dmeventd/Makefile.in 2012-02-20 15:48:04.861683196 -0800
++++ LVM2.2.02.92/daemons/dmeventd/Makefile.in 2012-02-20 15:52:50.732314588 -0800
+@@ -65,7 +65,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 -Nuar --exclude '*.rej' --exclude '*.orig' LVM2.2.02.92.orig/make.tmpl.in LVM2.2.02.92/make.tmpl.in
+--- LVM2.2.02.92.orig/make.tmpl.in 2012-02-20 15:48:05.034685963 -0800
++++ LVM2.2.02.92/make.tmpl.in 2012-02-20 15:48:58.622550855 -0800
+@@ -38,6 +38,7 @@
+ ELDFLAGS += @ELDFLAGS@
+ LDDEPS += @LDDEPS@
+ LDFLAGS += @LDFLAGS@
++STATIC_LDFLAGS += @STATIC_LDFLAGS@
+ LIB_SUFFIX = @LIB_SUFFIX@
+ LVMINTERNAL_LIBS = -llvm-internal $(UDEV_LIBS) $(DL_LIBS)
+ DL_LIBS = @DL_LIBS@
+diff -Nuar --exclude '*.rej' --exclude '*.orig' LVM2.2.02.92.orig/tools/Makefile.in LVM2.2.02.92/tools/Makefile.in
+--- LVM2.2.02.92.orig/tools/Makefile.in 2011-11-14 13:30:36.000000000 -0800
++++ LVM2.2.02.92/tools/Makefile.in 2012-02-20 15:52:25.242901501 -0800
+@@ -126,7 +126,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
+@@ -136,7 +136,7 @@
+ $(LVMLIBS) $(READLINE_LIBS) $(LIBS) -rdynamic
+
+ 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.99-locale-muck.patch b/sys-fs/lvm2/files/lvm2-2.02.99-locale-muck.patch
new file mode 100644
index 000000000000..fe7ec87931e3
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm2-2.02.99-locale-muck.patch
@@ -0,0 +1,11 @@
+--- LVM2/make.tmpl.in
++++ LVM2/make.tmpl.in
+@@ -395,7 +395,7 @@
+ ( cat $(srcdir)/.exported_symbols; \
+ if test x$(EXPORTED_HEADER) != x; then \
+ $(CC) -E -P $(INCLUDES) $(DEFS) $(EXPORTED_HEADER) | \
+- $(SED) -ne "/^typedef|}/!s/.*[ *]\($(EXPORTED_FN_PREFIX)_[a-z0-9_]*\)(.*/\1/p"; \
++ LC_ALL=C $(SED) -ne "/^typedef|}/!s/.*[ *]\($(EXPORTED_FN_PREFIX)_[a-z0-9_]*\)(.*/\1/p"; \
+ fi \
+ ) > $@
+
diff --git a/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2 b/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2
new file mode 100644
index 000000000000..c95a47d5be51
--- /dev/null
+++ b/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2
@@ -0,0 +1,12 @@
+#!/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
new file mode 100644
index 000000000000..2efce4223e55
--- /dev/null
+++ b/sys-fs/lvm2/files/lvmetad.initd-2.02.116-r3
@@ -0,0 +1,17 @@
+#!/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() {
+ :
+}
+
+start_pre()
+{
+ checkpath --directory /run/lvm || return 1
+}
diff --git a/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1 b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
new file mode 100644
index 000000000000..16e2cc3f12bf
--- /dev/null
+++ b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+pidfile="/run/lvmlockd.pid"
+command="/sbin/lvmlockd"
+command_args="${LVMLOCKD_OPTS:--p ${pidfile}} ${LVMLOCKD_TYPE:--g sanlock}"
+start_stop_daemon_args="--pidfile ${pidfile}"
+
+depend() {
+ before sanlock
+}
+
+start_pre()
+{
+ checkpath --directory /run/lvm || return 1
+}