Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvm: cleanups #93024

Merged
merged 17 commits into from Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions nixos/modules/system/boot/stage-1.nix
Expand Up @@ -111,8 +111,8 @@ let
copy_bin_and_libs ${pkgs.utillinux}/sbin/blkid

# Copy dmsetup and lvm.
copy_bin_and_libs ${pkgs.lvm2}/sbin/dmsetup
copy_bin_and_libs ${pkgs.lvm2}/sbin/lvm
copy_bin_and_libs ${getBin pkgs.lvm2}/bin/dmsetup
copy_bin_and_libs ${getBin pkgs.lvm2}/bin/lvm

# Add RAID mdadm tool.
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
Expand Down Expand Up @@ -235,7 +235,7 @@ let
--replace cdrom_id ${extraUtils}/bin/cdrom_id \
--replace ${pkgs.coreutils}/bin/basename ${extraUtils}/bin/basename \
--replace ${pkgs.utillinux}/bin/blkid ${extraUtils}/bin/blkid \
--replace ${pkgs.lvm2}/sbin ${extraUtils}/bin \
--replace ${getBin pkgs.lvm2}/bin ${extraUtils}/bin \
--replace ${pkgs.mdadm}/sbin ${extraUtils}/sbin \
--replace ${pkgs.bash}/bin/sh ${extraUtils}/bin/sh \
--replace ${udev} ${extraUtils}
Expand Down
111 changes: 67 additions & 44 deletions pkgs/os-specific/linux/lvm2/default.nix
@@ -1,48 +1,70 @@
{ stdenv, fetchgit, fetchpatch, pkgconfig, systemd, udev, utillinux, libuuid
{ stdenv
, fetchpatch
, fetchurl
, pkgconfig
, utillinux
, libuuid
, thin-provisioning-tools, libaio
, enable_dmeventd ? false }:
, enable_cmdlib ? false
, enable_dmeventd ? false
flokli marked this conversation as resolved.
Show resolved Hide resolved
, udev ? null
}:

let
version = "2.03.01";
in
# configure: error: --enable-dmeventd requires --enable-cmdlib to be used as well
assert enable_dmeventd -> enable_cmdlib;

stdenv.mkDerivation {
pname = "lvm2";
inherit version;
stdenv.mkDerivation rec {
pname = "lvm2" + stdenv.lib.optionalString enable_dmeventd "with-dmeventd";
version = "2.03.09";

src = fetchgit {
url = "git://sourceware.org/git/lvm2.git";
rev = "v${builtins.replaceStrings [ "." ] [ "_" ] version}";
sha256 = "0jlaswf1srdxiqpgpp97j950ddjds8z0kr4pbwmal2za2blrgvbl";
src = fetchurl {
url = "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${version}.tgz";
arianvp marked this conversation as resolved.
Show resolved Hide resolved
sha256 = "0xdr9qbqw6kja267wmx6ajnfv1nhw056gpxx9v2qmfh3bj6qnfn0";
};

nativeBuildInputs = [ pkgconfig ];
buildInputs = [ udev libuuid thin-provisioning-tools libaio ];

configureFlags = [
"--disable-readline"
"--enable-udev_rules"
"--enable-udev_sync"
"--enable-pkgconfig"
"--enable-cmdlib"
] ++ stdenv.lib.optional enable_dmeventd " --enable-dmeventd"
"--bindir=${placeholder "bin"}/bin"
"--sbindir=${placeholder "bin"}/bin"
"--libdir=${placeholder "lib"}/lib"
"--with-default-locking-dir=/run/lock/lvm"
"--with-default-run-dir=/run/lvm"
"--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
] ++ stdenv.lib.optionals enable_dmeventd [
"--enable-dmeventd"
"--with-dmeventd-pidfile=/run/dmeventd/pid"
"--with-default-dm-run-dir=/run/dmeventd"
] ++ stdenv.lib.optional enable_cmdlib "--enable-cmdlib"
++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"ac_cv_func_malloc_0_nonnull=yes"
"ac_cv_func_realloc_0_nonnull=yes"
] ++
stdenv.lib.optionals (udev != null) [
"--enable-udev_rules"
"--enable-udev_sync"
];

nativeBuildInputs = [ pkgconfig ];
buildInputs = [ udev libuuid thin-provisioning-tools libaio ];
preConfigure = ''
sed -i /DEFAULT_SYS_DIR/d Makefile.in
sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
--replace /usr/bin/udevadm /run/current-system/systemd/bin/udevadm
# https://github.com/lvmteam/lvm2/issues/36
substituteInPlace udev/69-dm-lvm-metad.rules.in \
--replace "(BINDIR)/systemd-run" /run/current-system/systemd/bin/systemd-run
arianvp marked this conversation as resolved.
Show resolved Hide resolved

substituteInPlace make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system"
substituteInPlace libdm/make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system"
'';

preConfigure =
''
sed -i /DEFAULT_SYS_DIR/d Makefile.in
sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
'' + stdenv.lib.optionalString (systemd != null) ''
substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
--replace /usr/bin/udevadm ${systemd}/bin/udevadm
'';
postConfigure = ''
sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h
'';

# https://github.com/NixOS/nixpkgs/pull/52597
# gcc: error: ../../device_mapper/libdevice-mapper.a: No such file or directory
enableParallelBuilding = false;

patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
(fetchpatch {
Expand All @@ -64,30 +86,31 @@ stdenv.mkDerivation {

doCheck = false; # requires root

makeFlags = stdenv.lib.optionals (udev != null) [
"SYSTEMD_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
flokli marked this conversation as resolved.
Show resolved Hide resolved
];

# To prevent make install from failing.
installFlags = [ "OWNER=" "GROUP=" "confdir=$(out)/etc" ];

# Install systemd stuff.
#installTargets = "install install_systemd_generators install_systemd_units install_tmpfiles_configuration";

postInstall =
''
substituteInPlace $out/lib/udev/rules.d/13-dm-disk.rules \
--replace $out/sbin/blkid ${utillinux}/sbin/blkid
'' + stdenv.lib.optionalString (systemd != null) ''
# Systemd stuff
mkdir -p $out/etc/systemd/system $out/lib/systemd/system-generators
cp scripts/blk_availability_systemd_red_hat.service $out/etc/systemd/system
cp scripts/lvm2_activation_generator_systemd_red_hat $out/lib/systemd/system-generators
'';
installTargets = [ "install" ] ++ stdenv.lib.optionals (udev != null) [
"install_systemd_generators"
"install_systemd_units"
"install_tmpfiles_configuration"
];

postInstall = ''
moveToOutput lib/libdevmapper.so $lib
'';

outputs = [ "out" "bin" "lib" "dev" "man" ];

meta = with stdenv.lib; {
homepage = "http://sourceware.org/lvm2/";
description = "Tools to support Logical Volume Management (LVM) on Linux";
platforms = platforms.linux;
license = with licenses; [ gpl2 bsd2 lgpl21 ];
maintainers = with maintainers; [raskin];
inherit version;
downloadPage = "ftp://sources.redhat.com/pub/lvm2/";
maintainers = with maintainers; [ raskin ajs124 ];
};
}
4 changes: 0 additions & 4 deletions pkgs/os-specific/linux/lvm2/default.upstream

This file was deleted.

4 changes: 1 addition & 3 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -16817,9 +16817,7 @@ in

directvnc = callPackage ../os-specific/linux/directvnc { };

dmraid = callPackage ../os-specific/linux/dmraid {
lvm2 = lvm2.override {enable_dmeventd = true;};
};
dmraid = callPackage ../os-specific/linux/dmraid { };

drbd = callPackage ../os-specific/linux/drbd { };

Expand Down