1
0
forked from brl/citadel

Add support for disk decryption to initramfs

This is now found in a separate package called systemd-extra-utils

Some related recipes have been updated:

  * libblockdev 2.24
  * cryptsetup 2.3.4
  * lvm 2.03.06
This commit is contained in:
Bruce Leidl 2020-11-02 11:01:58 -05:00
parent 4c3baa433b
commit 7bf4c57437
20 changed files with 316 additions and 354 deletions

View File

@ -8,6 +8,9 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
BBMASK += "meta-intel/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend"
LICENSE_PATH += "${LAYERDIR}/licenses"
# see https://patches.openembedded.org/patch/164502/
PREFERRED_RPROVIDER_libdevmapper = "lvm2"
BBFILE_COLLECTIONS += "citadel"
BBFILE_PATTERN_citadel = "^${LAYERDIR}/"
BBFILE_PRIORITY_citadel = "5"

View File

@ -9,7 +9,7 @@ ALTERNATIVE_${PN}_remove = "resolv-conf"
GROUPADD_PARAM_${PN} += "; -r kvm"
PACKAGECONFIG = "\
efi acl ldconfig pam usrmerge rfkill backlight binfmt hostnamed localed logind machined myhostname \
nss polkit randomseed seccomp timedated utmp timesyncd kmod sysusers gshadow \
nss polkit randomseed seccomp timedated utmp timesyncd kmod sysusers gshadow cryptsetup \
"
do_install_append() {

View File

@ -17,6 +17,7 @@ PACKAGE_INSTALL = "\
keymaps \
systemd \
systemd-initramfs \
systemd-extra-utils \
linux-firmware-i915 \
kernel-module-arc4 \
kernel-module-ansi-cprng \

View File

@ -1,38 +0,0 @@
SUMMARY = "Manage plain dm-crypt and LUKS encrypted volumes"
DESCRIPTION = "Cryptsetup is used to conveniently setup dm-crypt managed \
device-mapper mappings. These include plain dm-crypt volumes and \
LUKS volumes. The difference is that LUKS uses a metadata header \
and can hence offer more features than plain dm-crypt. On the other \
hand, the header is visible and vulnerable to damage."
HOMEPAGE = "https://gitlab.com/cryptsetup/cryptsetup"
SECTION = "console"
LICENSE = "GPL-2.0-with-OpenSSL-exception"
LIC_FILES_CHKSUM = "file://COPYING;md5=32107dd283b1dfeb66c9b3e6be312326"
DEPENDS = "util-linux libdevmapper popt libgcrypt json-c"
SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/v2.0/${BP}.tar.xz"
SRC_URI[md5sum] = "ed42b31f67d05b05e392d1943d467b8d"
SRC_URI[sha256sum] = "9d3a3c7033293e0c97f0ad0501fd5b4d4913ae497cbf70cca06633ccc54b5734"
inherit autotools gettext pkgconfig
# Use openssl because libgcrypt drops root privileges
# if libgcrypt is linked with libcap support
PACKAGECONFIG ??= "openssl"
PACKAGECONFIG[openssl] = "--with-crypto_backend=openssl,,openssl"
PACKAGECONFIG[gcrypt] = "--with-crypto_backend=gcrypt,,libgcrypt"
RRECOMMENDS_${PN} = "kernel-module-aes-generic \
kernel-module-dm-crypt \
kernel-module-md5 \
kernel-module-cbc \
kernel-module-sha256-generic \
kernel-module-xts \
"
EXTRA_OECONF = "--enable-static"
FILES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES','systemd','${exec_prefix}/lib/tmpfiles.d/cryptsetup.conf', '', d)}"
BBCLASSEXTEND = "native nativesdk"

View File

@ -0,0 +1,92 @@
SUMMARY = "Manage plain dm-crypt and LUKS encrypted volumes"
DESCRIPTION = "Cryptsetup is used to conveniently setup dm-crypt managed \
device-mapper mappings. These include plain dm-crypt volumes and \
LUKS volumes. The difference is that LUKS uses a metadata header \
and can hence offer more features than plain dm-crypt. On the other \
hand, the header is visible and vulnerable to damage."
HOMEPAGE = "https://gitlab.com/cryptsetup/cryptsetup"
SECTION = "console"
LICENSE = "GPL-2.0-with-OpenSSL-exception"
LIC_FILES_CHKSUM = "file://COPYING;md5=32107dd283b1dfeb66c9b3e6be312326"
DEPENDS = " \
json-c \
libdevmapper \
popt \
util-linux \
"
RDEPENDS_${PN} = " \
libdevmapper \
"
SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/v${@d.getVar('PV').split('.')[0]}.${@d.getVar('PV').split('.')[1]}/${BP}.tar.xz"
SRC_URI[md5sum] = "911272e73181fdc850bb4d25103a9f83"
SRC_URI[sha256sum] = "9d16eebb96b53b514778e813019b8dd15fea9fec5aafde9fae5febf59df83773"
inherit autotools gettext pkgconfig
# Use openssl because libgcrypt drops root privileges
# if libgcrypt is linked with libcap support
PACKAGECONFIG ??= " \
keyring \
cryptsetup \
veritysetup \
cryptsetup-reencrypt \
integritysetup \
${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \
kernel_crypto \
internal-argon2 \
blkid \
luks-adjust-xts-keysize \
openssl \
"
PACKAGECONFIG_append_class-target = " \
udev \
"
PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
PACKAGECONFIG[pwquality] = "--enable-pwquality,--disable-pwquality,libpwquality"
PACKAGECONFIG[passwdqc] = "--enable-passwdqc,--disable-passwdqc,passwdqc"
PACKAGECONFIG[cryptsetup] = "--enable-cryptsetup,--disable-cryptsetup"
PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"
PACKAGECONFIG[cryptsetup-reencrypt] = "--enable-cryptsetup-reencrypt,--disable-cryptsetup-reencrypt"
PACKAGECONFIG[integritysetup] = "--enable-integritysetup,--disable-integritysetup"
PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux"
PACKAGECONFIG[udev] = "--enable-udev,--disable-udev,,udev"
PACKAGECONFIG[kernel_crypto] = "--enable-kernel_crypto,--disable-kernel_crypto"
# gcrypt-pkbdf2 requries --with-crypto_backend=gcrypt or the flag isn't
# recognized.
PACKAGECONFIG[gcrypt-pbkdf2] = "--enable-gcrypt-pbkdf2"
PACKAGECONFIG[internal-argon2] = "--enable-internal-argon2,--disable-internal-argon2"
PACKAGECONFIG[internal-sse-argon2] = "--enable-internal-sse-argon2,--disable-internal-sse-argon2"
PACKAGECONFIG[blkid] = "--enable-blkid,--disable-blkid,util-linux"
PACKAGECONFIG[dev-random] = "--enable-dev-random,--disable-dev-random"
PACKAGECONFIG[luks-adjust-xts-keysize] = "--enable-luks-adjust-xts-keysize,--disable-luks-adjust-xts-keysize"
PACKAGECONFIG[openssl] = "--with-crypto_backend=openssl,,openssl"
PACKAGECONFIG[gcrypt] = "--with-crypto_backend=gcrypt,,libgcrypt"
PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"
PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
PACKAGECONFIG[luks2] = "--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"
RRECOMMENDS_${PN} = "kernel-module-aes-generic \
kernel-module-dm-crypt \
kernel-module-md5 \
kernel-module-cbc \
kernel-module-sha256-generic \
kernel-module-xts \
"
EXTRA_OECONF = "--enable-static"
# Building without largefile is not supported by upstream
EXTRA_OECONF += "--enable-largefile"
# Requires a static popt library
EXTRA_OECONF += "--disable-static-cryptsetup"
# There's no recipe for libargon2 yet
EXTRA_OECONF += "--disable-libargon2"
FILES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES','systemd','${exec_prefix}/lib/tmpfiles.d/cryptsetup.conf', '', d)}"
BBCLASSEXTEND = "native nativesdk"

View File

@ -1,2 +1,3 @@
PACKAGECONFIG = "fs crypto parted mdraid"
PACKAGECONFIG = "fs crypto parted mdraid kmod"
DEPENDS += "systemd"

View File

@ -8,20 +8,17 @@ SECTION = "devel/lib"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c07cb499d259452f324bb90c3067d85c"
inherit autotools python3native gobject-introspection
SRCREV = "cb308566c3c5222b8422f78997a1742713b265a9"
SRC_URI = " \
git://github.com/rhinstaller/libblockdev;branch=master \
"
inherit autotools gobject-introspection
SRC_URI = "git://github.com/storaged-project/libblockdev;branch=2.x-branch"
SRCREV = "f5a4ba8bb298f8cbc435707d0b19b4b2ff836a8e"
S = "${WORKDIR}/git"
FILES_${PN} += "${PYTHON_SITEPACKAGES_DIR}"
FILES_${PN} += "${libdir}/python2.7/dist-packages ${libdir}/python3.*/site-packages"
PACKAGECONFIG ??= "python3 lvm dm kmod parted fs escrow btrfs crypto mdraid kbd mpath nvdimm"
PACKAGECONFIG[python3] = "--with-python3, --without-python3,,python3"
PACKAGECONFIG[python2] = "--with-python2, --without-python2,,python2"
PACKAGECONFIG[python2] = "--with-python2, --without-python2,,python"
PACKAGECONFIG[lvm] = "--with-lvm, --without-lvm, multipath-tools, lvm2"
PACKAGECONFIG[lvm-dbus] = "--with-lvm_dbus, --without-lvm_dbus, multipath-tools, lvm2"
PACKAGECONFIG[dm] = "--with-dm, --without-dm, multipath-tools, lvm2"

View File

@ -1,30 +0,0 @@
From b1ad91a059d99afd1ce25823b7c0a8d3ac63d2fd Mon Sep 17 00:00:00 2001
From: Dengke Du <dengke.du@windriver.com>
Date: Tue, 25 Oct 2016 11:55:49 +0000
Subject: [PATCH 3/4] include fcntl.h for O_* defines and fcntl() signature
On glibc _somehow_ this header gets pulled in indirectly
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Dengke Du <dengke.du@windriver.com>
---
Upstream-Status: Pending
---
libdaemon/server/daemon-server.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 6af6de9..a9590e7 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -18,6 +18,7 @@
#include "daemon-server.h"
#include "daemon-log.h"
+#include <fcntl.h>
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
--
2.9.3

View File

@ -14,6 +14,11 @@ Do not build man to workaround the issue.
Upstream-Status: Pending
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Update context for lvm2 2.03.02.
Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
Makefile.in | 6 +++---
configure.ac | 1 -
@ -41,7 +46,7 @@ index 6a1a990..80cba91 100644
libdaemon lib tools daemons libdm \
udev po
tools.distclean: test.distclean
@@ -59,7 +59,7 @@ libdm.device-mapper: include.device-mapper
@@ -65,7 +65,7 @@ libdm.device-mapper: include.device-mapper
daemons.device-mapper: libdm.device-mapper
tools.device-mapper: libdm.device-mapper
scripts.device-mapper: include.device-mapper
@ -51,17 +56,17 @@ index 6a1a990..80cba91 100644
ifeq ("@INTL@", "yes")
lib.pofile: include.pofile
diff --git a/configure.ac b/configure.ac
index 9c45745..8fee4c4 100644
index 7fd0561..4154dc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1806,7 +1806,6 @@ libdaemon/server/Makefile
@@ -1812,7 +1812,6 @@ libdaemon/server/Makefile
libdm/Makefile
libdm/dm-tools/Makefile
libdm/libdevmapper.pc
-man/Makefile
po/Makefile
scripts/lvm2-pvscan.service
scripts/blkdeactivate.sh
scripts/blk_availability_init_red_hat
--
2.7.4

View File

@ -1,6 +1,6 @@
From 24a2c47fd01dde1710f1fa66f5c30ce7010c5956 Mon Sep 17 00:00:00 2001
From e213ed33a28704f6f538df41a91b7ce95594a4f8 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Thu, 21 Sep 2017 15:28:10 +0800
Date: Tue, 15 Oct 2019 18:12:54 +0800
Subject: [PATCH] start lvm2-monitor.service after tmp.mount
The lvm2-monitor.service reqires the existence of locking_dir
@ -9,24 +9,25 @@ So start lvm2-monitor.service after tmp.mount
Upstream-Status: Inappropriate [oe specific]
Rebase to v2_03_05
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
scripts/lvm2_monitoring_systemd_red_hat.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
index 22238b7..93b2bee 100644
index 4bf744a..46766cb 100644
--- a/scripts/lvm2_monitoring_systemd_red_hat.service.in
+++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
@@ -2,7 +2,7 @@
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=dm-event.socket lvm2-lvmetad.socket
-After=dm-event.socket dm-event.service lvm2-lvmetad.socket lvm2-activation.service lvm2-lvmetad.service
+After=dm-event.socket dm-event.service lvm2-lvmetad.socket lvm2-activation.service lvm2-lvmetad.service tmp.mount
Before=local-fs-pre.target
Requires=dm-event.socket
-After=dm-event.socket dm-event.service lvm2-activation.service
+After=dm-event.socket dm-event.service lvm2-activation.service tmp.mount
Before=local-fs-pre.target shutdown.target
DefaultDependencies=no
Conflicts=shutdown.target
--
1.8.3.1
2.7.4

View File

@ -62,7 +62,7 @@ devices {
cache = "/etc/lvm/.cache"
# You can turn off writing this cache file by setting this to 0.
write_cache_state = 0
write_cache_state = 1
# Advanced settings.
@ -137,7 +137,7 @@ backup {
# Should we maintain a backup of the current metadata configuration ?
# Use 1 for Yes; 0 for No.
# Think very hard before turning this off!
backup = 0
backup = 1
# Where shall we keep it ?
# Remember to back up this directory regularly!
@ -146,7 +146,7 @@ backup {
# Should we maintain an archive of old metadata configurations.
# Use 1 for Yes; 0 for No.
# On by default. Think very hard before turning this off.
archive = 0
archive = 1
# Where should archived files go ?
# Remember to back up this directory regularly!

View File

@ -0,0 +1,28 @@
configure.ac: override CONFIGURE_LINE
For reproducible binaries, we need to report a constant CONFIGURE_LINE.
Upstream-Status: Pending
Signed-off-by: Joe Slater <joe.slater@windriver.com>
--- git.orig/configure.ac
+++ git/configure.ac
@@ -15,7 +15,15 @@ AC_PREREQ(2.69)
################################################################################
dnl -- Process this file with autoconf to produce a configure script.
AC_INIT
-CONFIGURE_LINE="$0 $@"
+
+dnl per reproducible-builds.org check SOURCE_DATE_EPOCH
+dnl
+if test -z "${SOURCE_DATE_EPOCH+set}" ; then
+ CONFIGURE_LINE="$0 $@"
+else
+ CONFIGURE_LINE="configure options are not available for reproducible builds"
+fi
+
AC_CONFIG_SRCDIR([lib/device/dev-cache.h])
AC_CONFIG_HEADERS([include/configure.h])

View File

@ -1,15 +0,0 @@
require lvm2.inc
SRCREV = "913c28917e62577a2ef67152b2e5159237503dda"
DEPENDS += "autoconf-archive-native"
TARGET_CC_ARCH += "${LDFLAGS}"
do_install() {
oe_runmake 'DESTDIR=${D}' -C libdm install
}
RRECOMMENDS_${PN}_append_class-target = " lvm2-udevrules"
BBCLASSEXTEND = "native nativesdk"

View File

@ -0,0 +1,17 @@
# Break circular dependencies, only populate sysroot (header,
# libraries) to other recipe for compiling, recipe lvm2
# generates package libdevmapper
require lvm2.inc
DEPENDS += "autoconf-archive-native"
TARGET_CC_ARCH += "${LDFLAGS}"
do_install() {
oe_runmake 'DESTDIR=${D}' -C libdm install
}
# Do not generate package libdevmapper
PACKAGES = ""
BBCLASSEXTEND = "native nativesdk"

View File

@ -5,19 +5,20 @@ LICENSE = "GPLv2 & LGPLv2.1"
LIC_FILES_CHKSUM = "file://COPYING;md5=12713b4d9386533feeb07d6e4831765a \
file://COPYING.LIB;md5=fbc093901857fcd118f065f900982c24"
DEPENDS += "util-linux libaio"
DEPENDS += "libaio"
SRC_URI = "git://github.com/lvmteam/lvm2.git;protocol=https;branch=master \
SRC_URI = "git://sourceware.org/git/lvm2.git \
file://lvm.conf \
file://0001-implement-libc-specific-reopen_stream.patch \
file://0002-Guard-use-of-mallinfo-with-__GLIBC__.patch \
file://0003-include-fcntl.h-for-O_-defines-and-fcntl-signature.patch \
file://0004-tweak-MODPROBE_CMD-for-cross-compile.patch \
file://0001-Avoid-bashisms-in-init-scripts.patch \
file://0005-do-not-build-manual.patch \
file://0006-start-lvm2-monitor.service-after-tmp.mount.patch \
file://reproducible-build.patch \
"
SRCREV = "b9391b1b9f0b73303fa21f8f92574d17ce4c2b02"
S = "${WORKDIR}/git"
inherit autotools-brokensep pkgconfig systemd license
@ -26,7 +27,6 @@ LVM2_PACKAGECONFIG = "dmeventd"
LVM2_PACKAGECONFIG_append_class-target = " \
${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \
${@incompatible_license_contains('GPLv3', '', 'thin-provisioning-tools', d)} \
udev \
"
# odirect is always enabled because there currently is a bug in
@ -40,7 +40,6 @@ PACKAGECONFIG[odirect] = "--enable-o_direct,--disable-o_direct"
PACKAGECONFIG[readline] = "--enable-readline,--disable-readline,readline"
PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux"
PACKAGECONFIG[thin-provisioning-tools] = "--with-thin=internal,--with-thin=none,,thin-provisioning-tools"
PACKAGECONFIG[udev] = "--enable-udev_sync --enable-udev_rules --with-udevdir=${nonarch_base_libdir}/udev/rules.d,--disable-udev_sync --disable-udev_rules,udev"
# Unset user/group to unbreak install.
EXTRA_OECONF = "--with-user= \

View File

@ -0,0 +1,32 @@
From 93c93e3b85492e58f9451841e6079d00c497efa4 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Mon, 25 Feb 2019 13:29:12 +0800
Subject: [PATCH] "/dev/hdc: open failed: No medium found" will print out in
lvmdiskscan.
commit [57bb46c5e7f8] introduce this issue.
"/dev/hdc: open failed: No medium found" will be print out
after run lvmdiskscan. change dev_open_readonly()
to dev_open_readonly_quiet() in fuction _dev_get_size_dev().
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
lib/device/dev-io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index dc95131..81a66b0 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -338,7 +338,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
}
if (fd <= 0) {
- if (!dev_open_readonly(dev))
+ if (!dev_open_readonly_quiet(dev))
return_0;
fd = dev_fd(dev);
do_close = 1;
--
1.9.1

View File

@ -1,55 +0,0 @@
From 3c16d9aaa46602e7594d717d86e7f02066d21134 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Mon, 26 Nov 2018 17:20:20 +0800
Subject: [PATCH] explicitly do not install libdm
Already have package libdevmapper which split from lvm2,
explicitly do not do the installation here.
Upstream-Status: Inappropriate [meta-oe specific]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
libdm/Makefile.in | 6 ++++--
libdm/dm-tools/Makefile.in | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libdm/Makefile.in b/libdm/Makefile.in
index 8c8334a..effcf25 100644
--- a/libdm/Makefile.in
+++ b/libdm/Makefile.in
@@ -81,9 +81,11 @@ ifeq ("@PKGCONFIG@", "yes")
INSTALL_TYPE += install_pkgconfig
endif
-install: $(INSTALL_TYPE) install_include
+install:
+ echo "Do not install device mapper in lvm2"
-install_device-mapper: install
+install_device-mapper:
+ echo "Do not install device mapper in lvm2"
install_include: $(srcdir)/libdevmapper.h
$(INSTALL_DATA) -D $< $(includedir)/$(<F)
diff --git a/libdm/dm-tools/Makefile.in b/libdm/dm-tools/Makefile.in
index 39d411d..4a0f61a 100644
--- a/libdm/dm-tools/Makefile.in
+++ b/libdm/dm-tools/Makefile.in
@@ -60,9 +60,11 @@ install_dmsetup_static: dmsetup.static
$(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
$(Q) $(LN_S) -f $(<F) $(staticdir)/dmstats
-install_device-mapper: $(INSTALL_DMSETUP_TARGETS)
+install_device-mapper:
+ echo "Do not install device mapper in lvm2"
-install: install_device-mapper
+install:
+ echo "Do not install device mapper in lvm2"
# dmfilemapd support
ifeq ("@BUILD_DMFILEMAPD@", "yes")
--
2.7.4

View File

@ -0,0 +1,73 @@
From 27b56cb6b5dfc75ea8ddb395dc9ef41fb7a09c93 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Mon, 2 Sep 2019 23:04:50 -0400
Subject: [PATCH] fix command /bin/findmnt, /bin/lsblk, /bin/sort not found
In oe-core (util-linux and coreutils), the commands locates in
${bindir} rather than /bin, add BINDIR to configure it
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
configure.ac | 3 +++
scripts/blkdeactivate.sh.in | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index d1431e2..54e5a7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1495,6 +1495,8 @@ fi
SYSCONFDIR="$(eval echo $(eval echo $sysconfdir))"
+BINDIR="$(eval echo $(eval echo $bindir))"
+
SBINDIR="$(eval echo $(eval echo $sbindir))"
LVM_PATH="$SBINDIR/lvm"
AC_DEFINE_UNQUOTED(LVM_PATH, ["$LVM_PATH"], [Path to lvm binary.])
@@ -1721,6 +1723,7 @@ AC_SUBST(SACKPT_CFLAGS)
AC_SUBST(SACKPT_LIBS)
AC_SUBST(SALCK_CFLAGS)
AC_SUBST(SALCK_LIBS)
+AC_SUBST(BINDIR)
AC_SUBST(SBINDIR)
AC_SUBST(SELINUX_LIBS)
AC_SUBST(SELINUX_PC)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index a4b8a8f..3db4226 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -41,13 +41,14 @@ UMOUNT="/bin/umount"
sbindir="@SBINDIR@"
DMSETUP="$sbindir/dmsetup"
+bindir="@BINDIR@"
LVM="$sbindir/lvm"
if "$UMOUNT" --help | grep -- "--all-targets" >"$DEV_DIR/null"; then
UMOUNT_OPTS="--all-targets "
else
UMOUNT_OPTS=""
- FINDMNT="/bin/findmnt -r --noheadings -u -o TARGET"
+ FINDMNT="$bindir/findmnt -r --noheadings -u -o TARGET"
FINDMNT_READ="read -r mnt"
fi
DMSETUP_OPTS=""
@@ -55,10 +56,10 @@ LVM_OPTS=""
MDADM_OPTS=""
MPATHD_OPTS=""
-LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
+LSBLK="$bindir/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
LSBLK_VARS="local devtype local kname local name local mnt"
LSBLK_READ="read -r devtype kname name mnt"
-SORT_MNT="/bin/sort -r -u -k 4"
+SORT_MNT="$bindir/sort -r -u -k 4"
# Do not show tool errors by default (only done/skipping summary
# message provided by this script) and no verbose mode by default.
--
2.8.1

View File

@ -1,171 +0,0 @@
From b7a71bce5114db0b993a34565bd29bca04f9d71c Mon Sep 17 00:00:00 2001
From: Bruce Leidl <bruce@subgraph.com>
Date: Mon, 14 Jan 2019 18:22:30 -0500
Subject: [PATCH] fix systemd generator
---
Makefile.in | 1 -
configure.ac | 1 +
lib/config/config_settings.h | 9 +++++++++
scripts/Makefile.in | 1 +
scripts/generator-internals.c | 14 +++++++-------
scripts/lvm2-pvscan.service.in | 14 ++++++++++++++
.../lvm2_activation_generator_systemd_red_hat.c | 13 ++++++-------
7 files changed, 38 insertions(+), 15 deletions(-)
create mode 100644 scripts/lvm2-pvscan.service.in
diff --git a/Makefile.in b/Makefile.in
index 80cba91d1..d6e7bb8f2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -137,7 +137,6 @@ install_initscripts:
install_systemd_generators:
$(MAKE) -C scripts install_systemd_generators
- $(MAKE) -C man install_systemd_generators
install_systemd_units:
$(MAKE) -C scripts install_systemd_units
diff --git a/configure.ac b/configure.ac
index 8fee4c4f7..2e99d7b5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1807,6 +1807,7 @@ libdm/Makefile
libdm/dm-tools/Makefile
libdm/libdevmapper.pc
po/Makefile
+scripts/lvm2-pvscan.service
scripts/blkdeactivate.sh
scripts/blk_availability_init_red_hat
scripts/blk_availability_systemd_red_hat.service
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 636446f76..63e172acc 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -997,6 +997,15 @@ cfg(global_lvdisplay_shows_full_device_path_CFG, "lvdisplay_shows_full_device_pa
"Previously this was always shown as /dev/vgname/lvname even when that\n"
"was never a valid path in the /dev filesystem.\n")
+cfg(global_event_activation_CFG, "event_activation", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 3, 1), 0, 0, NULL,
+ "Activate LVs based on system-generated device events.\n"
+ "When a device appears on the system, a system-generated event runs\n"
+ "the pvscan command to activate LVs if the new PV completes the VG.\n"
+ "Use auto_activation_volume_list to select which LVs should be\n"
+ "activated from these events (the default is all.)\n"
+ "When event_activation is disabled, the system will generally run\n"
+ "a direct activation command to activate LVs in complete VGs.\n")
+
cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), 0, vsn(3, 0, 0), NULL,
"This setting is no longer used.\n")
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 039cac2e7..467e460ca 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -87,6 +87,7 @@ install_systemd_generators:
install_systemd_units: install_dbus_service
$(INSTALL_DIR) $(systemd_unit_dir)
+ $(INSTALL_DATA) lvm2-pvscan.service $(systemd_unit_dir)/lvm2-pvscan@.service
ifeq ("@BUILD_DMEVENTD@", "yes")
$(INSTALL_DATA) dm_event_systemd_red_hat.socket $(systemd_unit_dir)/dm-event.socket
$(INSTALL_DATA) dm_event_systemd_red_hat.service $(systemd_unit_dir)/dm-event.service
diff --git a/scripts/generator-internals.c b/scripts/generator-internals.c
index 00a15e547..a6c81b2e9 100644
--- a/scripts/generator-internals.c
+++ b/scripts/generator-internals.c
@@ -93,11 +93,11 @@ static bool _close_child(struct child_process *child)
//----------------------------------------------------------------
// Aquiring config from the lvmconfig process
-#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
-#define LVM_CONF_USE_LVMPOLLD "global/use_lvmpolld"
+#define LVM_CONF_EVENT_ACTIVATION "global/event_activation"
+#define LVM_CONF_USE_LVMPOLLD "global/use_lvmpolld"
struct config {
- bool use_lvmetad;
+ bool event_activation;
bool sysinit_needed;
};
@@ -153,8 +153,8 @@ static bool _parse_line(const char *line, struct config *cfg)
{
const char *val;
- if (_begins_with(line, "use_lvmetad=", &val)) {
- return _parse_bool(val, &cfg->use_lvmetad);
+ if (_begins_with(line, "event_activation=", &val)) {
+ return _parse_bool(val, &cfg->event_activation);
} else if (_begins_with(line, "use_lvmpolld=", &val)) {
bool r;
@@ -170,14 +170,14 @@ static bool _parse_line(const char *line, struct config *cfg)
static bool _get_config(struct config *cfg, const char *lvmconfig_path)
{
static const char *_argv[] = {
- "lvmconfig", LVM_CONF_USE_LVMETAD, LVM_CONF_USE_LVMPOLLD, NULL
+ "lvmconfig", LVM_CONF_EVENT_ACTIVATION, LVM_CONF_USE_LVMPOLLD, NULL
};
bool r = true;
char buffer[256];
struct child_process child;
- cfg->use_lvmetad = false;
+ cfg->event_activation = false;
cfg->sysinit_needed = true;
if (!_open_child(&child, lvmconfig_path, _argv)) {
diff --git a/scripts/lvm2-pvscan.service.in b/scripts/lvm2-pvscan.service.in
new file mode 100644
index 000000000..93fe062d0
--- /dev/null
+++ b/scripts/lvm2-pvscan.service.in
@@ -0,0 +1,14 @@
+[Unit]
+Description=LVM event activation on device %i
+Documentation=man:pvscan(8)
+DefaultDependencies=no
+StartLimitInterval=0
+BindsTo=dev-block-%i.device
+Before=shutdown.target
+Conflicts=shutdown.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@SBINDIR@/lvm pvscan --cache --activate ay %i
+ExecStop=@SBINDIR@/lvm pvscan --cache %i
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index 5dc39ae03..0e6c05acc 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -150,12 +150,11 @@ static int generate_unit(struct generator *gen, int unit)
fputs("# Automatically generated by lvm2-activation-generator.\n"
"#\n"
- "# This unit is responsible for direct activation of LVM2 logical volumes\n"
- "# if lvmetad daemon is not used (global/use_lvmetad=0 lvm.conf setting),\n"
- "# hence volume autoactivation is not applicable.\n"
- "# Direct LVM2 activation requires udev to be settled!\n\n"
+ "# This unit is responsible for direct activation of LVM logical volumes\n"
+ "# if event-based activation not used (global/event_activation=0 in\n"
+ "# lvm.conf). Direct LVM activation requires udev to be settled!\n\n"
"[Unit]\n"
- "Description=Activation of LVM2 logical volumes\n"
+ "Description=LVM direct activation of logical volumes\n"
"Documentation=man:lvm2-activation-generator(8)\n"
"SourcePath=/etc/lvm/lvm.conf\n" "DefaultDependencies=no\n", f);
@@ -217,8 +216,8 @@ static bool _run(int argc, const char **argv)
if (!_get_config(&gen.cfg, LVMCONFIG_PATH))
return false;
- if (gen.cfg.use_lvmetad)
- // If lvmetad used, rely on autoactivation instead of direct activation.
+ if (gen.cfg.event_activation)
+ // If event_activation=1, pvscan --cache -aay does activation.
return true;
/* mark lvm2-activation.*.service as world-accessible */

View File

@ -1,17 +1,8 @@
require lvm2.inc
SRCREV = "913c28917e62577a2ef67152b2e5159237503dda"
SRC_URI = "git://github.com/lvmteam/lvm2.git;protocol=https;branch=master \
file://lvm.conf \
file://0001-implement-libc-specific-reopen_stream.patch \
file://0002-Guard-use-of-mallinfo-with-__GLIBC__.patch \
file://0003-include-fcntl.h-for-O_-defines-and-fcntl-signature.patch \
file://0004-tweak-MODPROBE_CMD-for-cross-compile.patch \
file://0001-Avoid-bashisms-in-init-scripts.patch \
file://0005-do-not-build-manual.patch \
file://0006-start-lvm2-monitor.service-after-tmp.mount.patch \
file://0001-explicitly-do-not-install-libdm.patch \
SRC_URI += " \
file://0001-dev-hdc-open-failed-No-medium-found-will-print-out-i.patch \
file://0001-fix-command-bin-findmnt-bin-lsblk-bin-sort-not-found.patch \
"
DEPENDS += "autoconf-archive-native"
@ -48,7 +39,24 @@ TARGET_CC_ARCH += "${LDFLAGS}"
EXTRA_OECONF_append_class-nativesdk = " --with-confdir=${sysconfdir}"
FILES_${PN} += "${libdir}/device-mapper/*.so"
DEPENDS += "util-linux"
LVM2_PACKAGECONFIG_append_class-target = " \
udev \
"
PACKAGECONFIG[udev] = "--enable-udev_sync --enable-udev_rules --with-udevdir=${nonarch_base_libdir}/udev/rules.d,--disable-udev_sync --disable-udev_rules,udev,${PN}-udevrules"
PACKAGES =+ "libdevmapper"
FILES_libdevmapper = " \
${libdir}/libdevmapper.so.* \
${sbindir}/dmsetup \
${sbindir}/dmstats \
"
FILES_${PN} += " \
${libdir}/device-mapper/*.so \
${systemd_system_unitdir}/lvm2-pvscan@.service \
"
FILES_${PN}-scripts = " \
${sbindir}/blkdeactivate \
${sbindir}/fsadm \
@ -58,13 +66,27 @@ FILES_${PN}-scripts = " \
# Specified explicitly for the udev rules, just in case that it does not get picked
# up automatically:
FILES_${PN}-udevrules = "${nonarch_base_libdir}/udev/rules.d"
RDEPENDS_${PN}-udevrules = "${PN}"
RDEPENDS_${PN}-udevrules = "libdevmapper"
RDEPENDS_${PN}_append_class-target = " libdevmapper"
RDEPENDS_${PN}_append_class-nativesdk = " libdevmapper"
RDEPENDS_${PN}-scripts = "${PN} (= ${EXTENDPKGV}) bash"
RDEPENDS_${PN}-scripts = "${PN} (= ${EXTENDPKGV}) \
bash \
util-linux-lsblk \
util-linux-findmnt \
coreutils \
"
RRECOMMENDS_${PN}_class-target = "${PN}-scripts (= ${EXTENDPKGV})"
CONFFILES_${PN} += "${sysconfdir}/lvm/lvm.conf"
SYSROOT_PREPROCESS_FUNCS_append = " remove_libdevmapper_sysroot_preprocess"
remove_libdevmapper_sysroot_preprocess() {
rm -f ${SYSROOT_DESTDIR}${libdir}/libdevmapper.so* \
${SYSROOT_DESTDIR}${sbindir}/dmsetup \
${SYSROOT_DESTDIR}${sbindir}/dmstats \
${SYSROOT_DESTDIR}${includedir}/libdevmapper.h \
${SYSROOT_DESTDIR}${libdir}/pkgconfig/devmapper.pc
}
BBCLASSEXTEND = "native nativesdk"