From a5ab0f4ea7aea271cd87c75a9cdfac595dcc97b7 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sun, 16 Feb 2014 17:54:48 -0600
Subject: lvm2 update binary path to /usr/bin refs #961

---
 abs/core/lvm2/PKGBUILD               | 74 +++++++++++++++++++++++++-----------
 abs/core/lvm2/dmeventd.service       | 14 +++++++
 abs/core/lvm2/dmeventd.socket        | 11 ++++++
 abs/core/lvm2/lvm-monitoring.service | 17 +++++++++
 abs/core/lvm2/lvm.service            | 16 --------
 abs/core/lvm2/lvm2.install           | 16 ++++++++
 abs/core/lvm2/lvm2_hook              | 24 +++---------
 abs/core/lvm2/lvm2_install           | 16 ++++----
 abs/core/lvm2/lvmetad.service        | 16 ++++++++
 abs/core/lvm2/lvmetad.socket         | 10 +++++
 abs/core/lvm2/sd-lvm2                | 31 +++++++++++++++
 11 files changed, 180 insertions(+), 65 deletions(-)
 create mode 100644 abs/core/lvm2/dmeventd.service
 create mode 100644 abs/core/lvm2/dmeventd.socket
 create mode 100644 abs/core/lvm2/lvm-monitoring.service
 delete mode 100644 abs/core/lvm2/lvm.service
 create mode 100644 abs/core/lvm2/lvm2.install
 create mode 100644 abs/core/lvm2/lvmetad.service
 create mode 100644 abs/core/lvm2/lvmetad.socket
 create mode 100644 abs/core/lvm2/sd-lvm2

diff --git a/abs/core/lvm2/PKGBUILD b/abs/core/lvm2/PKGBUILD
index bda634b..e31f8a8 100644
--- a/abs/core/lvm2/PKGBUILD
+++ b/abs/core/lvm2/PKGBUILD
@@ -1,60 +1,85 @@
-# $Id: PKGBUILD 163019 2012-07-05 20:37:09Z eric $
+# $Id: PKGBUILD 199802 2013-11-16 17:53:26Z thomas $
 # Maintainer: Eric Bélanger <eric@archlinux.org>
 # Maintainer: Thomas Bächler <thomas@archlinux.org>
 
 pkgbase=lvm2
 pkgname=('lvm2' 'device-mapper')
-pkgver=2.02.96
-pkgrel=3
+pkgver=2.02.104
+pkgrel=1
 arch=('i686' 'x86_64')
 url="http://sourceware.org/lvm2/"
 license=('GPL2' 'LGPL2.1')
+makedepends=('systemd' 'thin-provisioning-tools')
 groups=('base')
 source=(ftp://sources.redhat.com/pub/lvm2/LVM2.${pkgver}.tgz{,.asc}
         lvm2_install
         lvm2_hook
+        sd-lvm2
         11-dm-initramfs.rules
-        lvm.service
-        lvm2.conf)
-sha1sums=('29d5097f0ca92c7665f29f862eca78bcf981ff6f'
-          '12e9016485c415c344524e6e75e23dfa6ca097ac'
-          '3e1680f9b76ce9150d08865d99db90fd15532271'
-          'cedc9948123c870f9c5aa3357d0075b41a9c8135'
+        lvm2.conf
+        dmeventd.service
+        dmeventd.socket
+        lvm-monitoring.service
+        lvmetad.service
+        lvmetad.socket)
+sha1sums=('4c296453e10deafe02004fde40075cdb3792eeb2'
+          'SKIP'
+          '76e83966d1bc84f9a1e30bcaff84b8b8fefbca0f'
+          'ff0fdf0a3005a41acd4b36865056109effc3474b'
+          '30777d42e31cb7fe1f4fadc1e8f4c4d4cdd8ffed'
           'f6a554eea9557c3c236df2943bb6e7e723945c41'
-          '17df8689630a77e46899a8bd56997d9db896d5af'
-          'ccefad65fde3d50331a42b0e90a1539dc7c8b9e4')
+          'ccefad65fde3d50331a42b0e90a1539dc7c8b9e4'
+          '01782ce8e10718c1513e3906b126f30f682f5cab'
+          '1d56f47a81350ae37ffbf61ee036fe31f4c5d504'
+          'aad90fce0e12eda41d38571d8eb27c5d5a8c59ec'
+          'f857a4a63fcc604a981e56875edda91767d4f1bf'
+          'fcfc265e3b10294cc4b10949a342e9db4310b186')
+
+prepare() {
+  cd LVM2.${pkgver}
+  # enable lvmetad
+  sed -i 's|use_lvmetad = 0|use_lvmetad = 1|' conf/example.conf.in
+}
 
 build() {
-  cd "${srcdir}/LVM2.${pkgver}"
+  cd LVM2.${pkgver}
   unset LDFLAGS
 
-  ./configure --prefix=/ --sbindir=/sbin --sysconfdir=/etc --localstatedir=/var --datarootdir=/usr/share \
-    --includedir=/usr/include --with-usrlibdir=/usr/lib  --libdir=/usr/lib --with-udev-prefix=/usr \
-    --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-pkgconfig --enable-readline \
-    --enable-dmeventd --enable-cmdlib --enable-applib --enable-udev_sync --enable-udev_rules  \
-    --with-default-locking-dir=/run/lock/lvm
+  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --sbindir=/usr/bin \
+    --with-udev-prefix=/usr --with-systemdsystemunitdir=/usr/lib/systemd/system \
+    --with-default-pid-dir=/run --with-default-dm-run-dir=/run --with-default-run-dir=/run/lvm \
+    --enable-pkgconfig --enable-readline --enable-dmeventd --enable-cmdlib --enable-applib \
+    --enable-udev_sync --enable-udev_rules --with-default-locking-dir=/run/lock/lvm \
+    --enable-lvmetad --with-thin=internal
   make
 }
 
 package_device-mapper() {
   pkgdesc="Device mapper userspace library and tools"
   url="http://sourceware.org/dm/"
-  depends=('glibc' 'udev')
+  depends=('glibc' 'systemd')
 
-  cd "${srcdir}/LVM2.${pkgver}"
+  cd LVM2.${pkgver}
   make DESTDIR="${pkgdir}" install_device-mapper
   # extra udev rule for device-mapper in initramfs
   install -D -m644 "${srcdir}/11-dm-initramfs.rules" "${pkgdir}/usr/lib/initcpio/udev/11-dm-initramfs.rules"
+  # Install dmeventd socket and service
+  install -D -m644 "${srcdir}/dmeventd.service" "${pkgdir}/usr/lib/systemd/system/dmeventd.service"
+  install -D -m644 "${srcdir}/dmeventd.socket" "${pkgdir}/usr/lib/systemd/system/dmeventd.socket"
+  install -d -m755 "${pkgdir}/usr/lib/systemd/system/sockets.target.wants"
+  ln -sf /usr/lib/systemd/system/dmeventd.socket "${pkgdir}/usr/lib/systemd/system/sockets.target.wants/dmeventd.socket"
 }
 
 package_lvm2() {
   pkgdesc="Logical Volume Manager 2 utilities"
-  depends=('bash' "device-mapper>=${pkgver}" 'udev' 'readline')
+  depends=('bash' "device-mapper>=${pkgver}" 'systemd' 'readline')
   conflicts=('lvm' 'mkinitcpio<0.7')
   backup=('etc/lvm/lvm.conf')
   options=('!makeflags')
+  optdepends=('thin-provisioning-tools: For thin provisioning support.')
+  install=lvm2.install
 
-  cd "${srcdir}/LVM2.${pkgver}"
+  cd LVM2.${pkgver}
   make DESTDIR="${pkgdir}" install_lvm2
   # install applib
   make -C liblvm DESTDIR="${pkgdir}" install
@@ -63,7 +88,12 @@ package_lvm2() {
   # mkinitcpio hook
   install -D -m644 "${srcdir}/lvm2_hook" "${pkgdir}/usr/lib/initcpio/hooks/lvm2"
   install -D -m644 "${srcdir}/lvm2_install" "${pkgdir}/usr/lib/initcpio/install/lvm2"
+  install -D -m644 "${srcdir}/sd-lvm2" "${pkgdir}/usr/lib/initcpio/install/sd-lvm2"
   # systemd support
-  install -D -m644 "${srcdir}/lvm.service" "${pkgdir}/usr/lib/systemd/system/lvm.service"
   install -D -m644 "${srcdir}/lvm2.conf" "${pkgdir}/usr/lib/tmpfiles.d/lvm2.conf"
+  install -D -m644 "${srcdir}/lvm-monitoring.service" "${pkgdir}/usr/lib/systemd/system/lvm-monitoring.service"
+  install -D -m644 "${srcdir}/lvmetad.service" "${pkgdir}/usr/lib/systemd/system/lvmetad.service"
+  install -D -m644 "${srcdir}/lvmetad.socket" "${pkgdir}/usr/lib/systemd/system/lvmetad.socket"
+  install -d -m755 "${pkgdir}/usr/lib/systemd/system/sockets.target.wants"
+  ln -sf /usr/lib/systemd/system/lvmetad.socket "${pkgdir}/usr/lib/systemd/system/sockets.target.wants/lvmetad.socket"
 }
diff --git a/abs/core/lvm2/dmeventd.service b/abs/core/lvm2/dmeventd.service
new file mode 100644
index 0000000..e0b1b33
--- /dev/null
+++ b/abs/core/lvm2/dmeventd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Device-mapper event daemon
+Documentation=man:dmeventd(8)
+Requires=dmeventd.socket
+After=dmeventd.socket
+DefaultDependencies=no
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/dmeventd
+ExecReload=/usr/bin/dmeventd -R
+Environment=SD_ACTIVATION=1
+PIDFile=/run/dmeventd.pid
+OOMScoreAdjust=-1000
diff --git a/abs/core/lvm2/dmeventd.socket b/abs/core/lvm2/dmeventd.socket
new file mode 100644
index 0000000..726d112
--- /dev/null
+++ b/abs/core/lvm2/dmeventd.socket
@@ -0,0 +1,11 @@
+[Unit]
+Description=Device-mapper event daemon FIFOs
+Documentation=man:dmeventd(8)
+Before=sockets.target
+DefaultDependencies=no
+Conflicts=shutdown.target
+
+[Socket]
+ListenFIFO=/run/dmeventd-server
+ListenFIFO=/run/dmeventd-client
+SocketMode=0600
diff --git a/abs/core/lvm2/lvm-monitoring.service b/abs/core/lvm2/lvm-monitoring.service
new file mode 100644
index 0000000..14b2d1d
--- /dev/null
+++ b/abs/core/lvm2/lvm-monitoring.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
+Documentation=man:dmeventd(8) man:lvcreate(8) man:lvchange(8) man:vgchange(8)
+Requires=dmeventd.socket
+After=dmeventd.socket lvmetad.socket
+DefaultDependencies=no
+Conflicts=shutdown.target
+
+[Service]
+Type=oneshot
+Environment=LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
+ExecStart=/usr/bin/lvm vgchange --monitor y
+ExecStop=/usr/bin/lvm vgchange --monitor n
+RemainAfterExit=yes
+
+[Install]
+WantedBy=sysinit.target
diff --git a/abs/core/lvm2/lvm.service b/abs/core/lvm2/lvm.service
deleted file mode 100644
index 277d5a7..0000000
--- a/abs/core/lvm2/lvm.service
+++ /dev/null
@@ -1,16 +0,0 @@
-[Unit]
-Description=LVM activation
-DefaultDependencies=no
-Requires=systemd-udev-settle.service
-After=systemd-udev-settle.service
-Before=basic.target shutdown.target
-Conflicts=shutdown.target
-
-[Service]
-ExecStart=/sbin/vgchange --sysinit --available y
-Type=oneshot
-TimeoutSec=0
-RemainAfterExit=yes
-
-[Install]
-WantedBy=basic.target
diff --git a/abs/core/lvm2/lvm2.install b/abs/core/lvm2/lvm2.install
new file mode 100644
index 0000000..7faf708
--- /dev/null
+++ b/abs/core/lvm2/lvm2.install
@@ -0,0 +1,16 @@
+post_upgrade() {
+  if [ $(vercmp $2 2.02.98-2) -lt 0 ]; then
+    echo "Changes to the lvm2 package:"
+    echo " + Activating lvm in mkinitcpio now requires both the 'udev' and 'lvm2' hooks."
+    echo " + LVM volumes are automatically activated by udev (full hotplug support)."
+    echo " + You MUST have use_lvmetad = 1 in /etc/lvm/lvm.conf (the default)."
+    echo " + If you uncomment auto_activation_volume_list in /etc/lvm/lvm.conf, only the"
+    echo "   volumes listed there will be activated (default: it is commented out)."
+    if [ -f /etc/lvm/lvm.conf.pacnew ]; then
+        echo "WARNING: /etc/lvm/lvm.conf.pacnew exists. You MUST merge the required changes"
+        echo "         into /etc/lvm/lvm.conf or LVM will fail to work."
+    fi
+  fi
+}
+
+# vim:set ts=2 sw=2 et:
diff --git a/abs/core/lvm2/lvm2_hook b/abs/core/lvm2/lvm2_hook
index e69b334..65de7bd 100644
--- a/abs/core/lvm2/lvm2_hook
+++ b/abs/core/lvm2/lvm2_hook
@@ -1,24 +1,12 @@
 #!/usr/bin/ash
 
-run_hook() {
-    local pvdev
-
-    modprobe -q dm-mod >/dev/null 2>&1
-
-    # If the lvmwait= parameter has been specified on the command line
-    # wait for the device(s) before trying to activate the volume group(s)
-    for pvdev in ${lvmwait//,/ }; do
-        poll_device ${pvdev} ${rootdelay}
-    done
-
-    msg "Activating logical volumes..."
-    [ -d /etc/lvm ] && lvm vgscan
+run_earlyhook() {
+    mkdir /run/lvm
+    lvmetad
+}
 
-    if [ -n "$quiet" ]; then
-      lvm vgchange --sysinit -a y >/dev/null
-    else
-      lvm vgchange --sysinit -a y
-    fi
+run_cleanuphook() {
+    kill $(cat /run/lvmetad.pid)
 }
 
 # vim: set ft=sh ts=4 sw=4 et:
diff --git a/abs/core/lvm2/lvm2_install b/abs/core/lvm2/lvm2_install
index 145ce49..6f3c1cb 100644
--- a/abs/core/lvm2/lvm2_install
+++ b/abs/core/lvm2/lvm2_install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/bash
 
 build() {
     local mod
@@ -6,25 +6,23 @@ build() {
         add_module "$mod"
     done
 
-    add_binary "/sbin/lvm"
-    add_binary "/sbin/dmsetup"
+    add_binary "/usr/bin/lvm"
+    add_binary "/usr/bin/lvmetad"
+    add_binary "/usr/bin/dmsetup"
     add_file "/usr/lib/udev/rules.d/10-dm.rules"
     add_file "/usr/lib/udev/rules.d/13-dm-disk.rules"
     add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
     add_file "/usr/lib/udev/rules.d/11-dm-lvm.rules"
+    add_file "/usr/lib/udev/rules.d/69-dm-lvm-metad.rules"
     add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
+    add_file "/etc/lvm/lvm.conf"
 
     add_runscript
 }
 
 help() {
   cat <<HELPEOF
-This hook loads the necessary modules for an LVM2 root device.
-
-The optional lvmwait= parameter followed by a comma-separated
-list of device names can be given on the command line.
-It will cause the hook to wait until all given devices exist
-before trying to scan and activate any volume groups.
+This hook enables LVM2 volumes in initramfs.
 HELPEOF
 }
 
diff --git a/abs/core/lvm2/lvmetad.service b/abs/core/lvm2/lvmetad.service
new file mode 100644
index 0000000..4be520a
--- /dev/null
+++ b/abs/core/lvm2/lvmetad.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=LVM2 metadata daemon
+Documentation=man:lvmetad(8)
+Requires=lvmetad.socket
+After=lvmetad.socket
+DefaultDependencies=no
+Conflicts=shutdown.target
+
+[Service]
+Type=forking
+NonBlocking=true
+ExecStart=/usr/bin/lvmetad
+ExecReload=/usr/bin/lvmetad -R
+Environment=SD_ACTIVATION=1
+Restart=on-abort
+PIDFile=/run/lvmetad.pid
diff --git a/abs/core/lvm2/lvmetad.socket b/abs/core/lvm2/lvmetad.socket
new file mode 100644
index 0000000..9c0ffa5
--- /dev/null
+++ b/abs/core/lvm2/lvmetad.socket
@@ -0,0 +1,10 @@
+[Unit]
+Description=LVM2 metadata daemon socket
+Documentation=man:lvmetad(8)
+Before=sockets.target systemd-udev-trigger.service
+DefaultDependencies=no
+Conflicts=shutdown.target
+
+[Socket]
+ListenStream=/run/lvm/lvmetad.socket
+SocketMode=0600
diff --git a/abs/core/lvm2/sd-lvm2 b/abs/core/lvm2/sd-lvm2
new file mode 100644
index 0000000..07cb19a
--- /dev/null
+++ b/abs/core/lvm2/sd-lvm2
@@ -0,0 +1,31 @@
+#!/usr/bin/bash
+
+build() {
+    local mod
+    for mod in dm-mod dm-snapshot dm-mirror; do
+        add_module "$mod"
+    done
+
+    add_binary "/usr/bin/lvm"
+    add_binary "/usr/bin/lvmetad"
+    add_binary "/usr/bin/dmsetup"
+    add_file "/usr/lib/udev/rules.d/10-dm.rules"
+    add_file "/usr/lib/udev/rules.d/13-dm-disk.rules"
+    add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
+    add_file "/usr/lib/udev/rules.d/11-dm-lvm.rules"
+    add_file "/usr/lib/udev/rules.d/69-dm-lvm-metad.rules"
+    add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
+    add_file "/etc/lvm/lvm.conf"
+
+    add_file "/usr/lib/systemd/system/lvmetad.service"
+    add_file "/usr/lib/systemd/system/lvmetad.socket"
+    add_symlink "/usr/lib/systemd/system/sockets.target.wants/lvmetad.socket"
+}
+
+help() {
+  cat <<HELPEOF
+This hook enables LVM2 volumes in systemd-based initramfs.
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
-- 
cgit v0.12

