From 95570a64dc0636692f88370d7d747b96105403be Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 3 Dec 2021 18:36:06 +0100 Subject: [PATCH] lvm2: allow building static libdm --- pkgs/os-specific/linux/lvm2/common.nix | 33 +++++++++++++++++----- pkgs/os-specific/linux/lvm2/no-shared.diff | 25 ++++++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 pkgs/os-specific/linux/lvm2/no-shared.diff diff --git a/pkgs/os-specific/linux/lvm2/common.nix b/pkgs/os-specific/linux/lvm2/common.nix index 2c8014d700a0..5ee368c242fd 100644 --- a/pkgs/os-specific/linux/lvm2/common.nix +++ b/pkgs/os-specific/linux/lvm2/common.nix @@ -9,7 +9,8 @@ , libaio , enableCmdlib ? false , enableDmeventd ? false -, udev ? null +, udevSupport ? !stdenv.targetPlatform.isStatic, udev ? null +, onlyLib ? stdenv.targetPlatform.isStatic , nixosTests }: @@ -26,7 +27,13 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkg-config ]; - buildInputs = [ udev libuuid libaio ]; + buildInputs = [ + libaio + ] ++ lib.optionals udevSupport [ + udev + ] ++ lib.optionals (!onlyLib) [ + libuuid + ]; configureFlags = [ "--disable-readline" @@ -46,10 +53,11 @@ stdenv.mkDerivation rec { ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "ac_cv_func_malloc_0_nonnull=yes" "ac_cv_func_realloc_0_nonnull=yes" - ] ++ - lib.optionals (udev != null) [ + ] ++ lib.optionals udevSupport [ "--enable-udev_rules" "--enable-udev_sync" + ] ++ lib.optionals stdenv.targetPlatform.isStatic [ + "--enable-static_link" ]; preConfigure = '' @@ -78,30 +86,41 @@ stdenv.mkDerivation rec { url = "https://git.alpinelinux.org/aports/plain/main/lvm2/mallinfo.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50"; sha256 = "0g6wlqi215i5s30bnbkn8w7axrs27y3bnygbpbnf64wwx7rxxlj0"; }) + ] ++ lib.optionals stdenv.targetPlatform.isStatic [ + ./no-shared.diff ]; doCheck = false; # requires root - makeFlags = lib.optionals (udev != null) [ + makeFlags = lib.optionals udevSupport [ "SYSTEMD_GENERATOR_DIR=$(out)/lib/systemd/system-generators" + ] ++ lib.optionals onlyLib [ + "libdm.device-mapper" ]; # To prevent make install from failing. installFlags = [ "OWNER=" "GROUP=" "confdir=$(out)/etc" ]; # Install systemd stuff. - installTargets = [ "install" ] ++ lib.optionals (udev != null) [ + installTargets = [ "install" ] ++ lib.optionals udevSupport [ "install_systemd_generators" "install_systemd_units" "install_tmpfiles_configuration" ]; + installPhase = lib.optionalString onlyLib '' + install -D -t $out/lib libdm/ioctl/libdevmapper.${if stdenv.targetPlatform.isStatic then "a" else "so"} + make -C libdm install_include + make -C libdm install_pkgconfig + ''; + # only split bin and lib out from out if cmdlib isn't enabled outputs = [ "out" + ] ++ lib.optionals (!onlyLib) [ "dev" "man" - ] ++ lib.optionals (enableCmdlib != true) [ + ] ++ lib.optionals (!onlyLib && !enableCmdlib) [ "bin" "lib" ]; diff --git a/pkgs/os-specific/linux/lvm2/no-shared.diff b/pkgs/os-specific/linux/lvm2/no-shared.diff new file mode 100644 index 000000000000..d40dd85dfc62 --- /dev/null +++ b/pkgs/os-specific/linux/lvm2/no-shared.diff @@ -0,0 +1,25 @@ +diff --git a/libdm/Makefile.in b/libdm/Makefile.in +index 66ec39513..ab7123dae 100644 +--- a/libdm/Makefile.in ++++ b/libdm/Makefile.in +@@ -44,7 +44,6 @@ endif + + LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX) + LIB_VERSION = $(LIB_VERSION_DM) +-TARGETS = libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) + + CFLOW_LIST = $(SOURCES) + CFLOW_LIST_TARGET = libdevmapper.cflow +diff --git a/make.tmpl.in b/make.tmpl.in +index e7780e8d4..ca4aa9fdd 100644 +--- a/make.tmpl.in ++++ b/make.tmpl.in +@@ -346,7 +346,7 @@ SUBDIRS.cflow := $(SUBDIRS:=.cflow) + SUBDIRS.clean := $(SUBDIRS:=.clean) + SUBDIRS.distclean := $(SUBDIRS:=.distclean) + +-TARGETS += $(LIB_SHARED) $(LIB_STATIC) ++TARGETS += $(LIB_STATIC) + + all: $(SUBDIRS) $(TARGETS) +