mdadm: 4.4 -> 4.6 (#533412)

This commit is contained in:
dotlambda
2026-06-20 21:40:28 +00:00
committed by GitHub
2 changed files with 3 additions and 137 deletions
@@ -1,124 +0,0 @@
diff --git a/Makefile b/Makefile
index 2a51d813..a31ac48a 100644
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,9 @@ endif
ifdef DEBIAN
CPPFLAGS += -DDEBIAN
endif
+ifdef NIXOS
+CPPFLAGS += -DNIXOS
+endif
ifdef DEFAULT_OLD_METADATA
CPPFLAGS += -DDEFAULT_OLD_METADATA
DEFAULT_METADATA=0.90
@@ -129,6 +132,7 @@ endif
INSTALL = /usr/bin/install
DESTDIR =
BINDIR = /sbin
+INSTALL_BINDIR = ${BINDIR}
MANDIR = /usr/share/man
MAN4DIR = $(MANDIR)/man4
MAN5DIR = $(MANDIR)/man5
@@ -253,16 +257,16 @@ sha1.o : sha1.c sha1.h md5.h
install : install-bin install-man install-udev
install-static : mdadm.static install-man
- $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(INSTALL_BINDIR)/mdadm
install-tcc : mdadm.tcc install-man
- $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(INSTALL_BINDIR)/mdadm
install-uclibc : mdadm.uclibc install-man
- $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(INSTALL_BINDIR)/mdadm
install-klibc : mdadm.klibc install-man
- $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(INSTALL_BINDIR)/mdadm
install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
$(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
@@ -305,7 +309,7 @@ install-bin: mdadm mdmon
$(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
uninstall:
- rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
+ rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(INSTALL_BINDIR)/mdadm
test: mdadm mdmon test_stripe swap_super raid6check
@echo "Please run './test' as root"
diff --git a/policy.c b/policy.c
index eee9ef63..9f916e9d 100644
--- a/policy.c
+++ b/policy.c
@@ -817,12 +817,39 @@ char *find_rule(struct rule *rule, char *rule_type)
#define UDEV_RULE_FORMAT \
"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"%s/mdadm --incremental $env{DEVNAME}\"\n"
#define UDEV_RULE_FORMAT_NOTYPE \
"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"%s/mdadm --incremental $env{DEVNAME}\"\n"
+
+#ifdef NIXOS
+const char *get_mdadm_bindir(void)
+{
+ static char *bindir = NULL;
+ if (bindir != NULL) {
+ return bindir;
+ } else {
+ int len;
+ bindir = xmalloc(1025);
+ len = readlink("/proc/self/exe", bindir, 1024);
+ if (len > 0) {
+ char *basename;
+ if ((basename = strrchr(bindir, '/')) != NULL)
+ *basename = '\0';
+ else
+ *(bindir + len) = '\0';
+ } else {
+ *bindir = '\0';
+ }
+ return bindir;
+ }
+}
+#define SELF get_mdadm_bindir()
+#else
+#define SELF BINDIR
+#endif
/* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */
int write_rule(struct rule *rule, int fd, int force_part)
@@ -836,9 +863,9 @@ int write_rule(struct rule *rule, int fd, int force_part)
if (force_part)
typ = type_part;
if (typ)
- snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT, typ, pth);
+ snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT, typ, pth, SELF);
else
- snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE, pth);
+ snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE, pth, SELF);
return write(fd, line, strlen(line)) == (int)strlen(line);
}
diff --git a/util.c b/util.c
index 3d05d074..e004a798 100644
--- a/util.c
+++ b/util.c
@@ -1913,7 +1913,9 @@ int start_mdmon(char *devnm)
char pathbuf[1024];
char *paths[4] = {
pathbuf,
+#ifndef NIXOS
BINDIR "/mdmon",
+#endif
"./mdmon",
NULL
};
+3 -13
View File
@@ -15,27 +15,16 @@
stdenv.mkDerivation (finalAttrs: {
pname = "mdadm";
version = "4.4";
version = "4.6";
src = fetchgit {
url = "https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git";
tag = "mdadm-${finalAttrs.version}";
hash = "sha256-jGmc8fkJM0V9J7V7tQPXSF/WD0kzyEAloBAwaAFenS0=";
hash = "sha256-jFsVPJC4lcShkSwQCGjVdVkvk4q4weM7i5DzrLgpuSM=";
};
patches = [
./no-self-references.patch
./fix-hardcoded-mapdir.patch
# Fixes build on musl
(fetchurl {
url = "https://raw.githubusercontent.com/void-linux/void-packages/e58d2b17d3c40faffc0d426aab00184f28d9dafa/srcpkgs/mdadm/patches/musl.patch";
hash = "sha256-TIcQs+8RM5Q6Z8MHkI50kaJd7f9WdS/EVI16F7b2+SA=";
})
# Fixes build on musl 1.2.5+
(fetchurl {
url = "https://lore.kernel.org/linux-raid/20240220165158.3521874-1-raj.khem@gmail.com/raw";
hash = "sha256-JOZ8n7zi+nq236NPpB4e2gUy8I3l3DbcoLhpeL73f98=";
})
];
makeFlags = [
@@ -97,6 +86,7 @@ stdenv.mkDerivation (finalAttrs: {
};
meta = {
changelog = "https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/tree/CHANGELOG.md?h=${finalAttrs.src.tag}";
description = "Programs for managing RAID arrays under Linux";
homepage = "https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git";
license = lib.licenses.gpl2Plus;