summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-10 08:55:48 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-12 09:19:21 +0000
commitad3ed169292942d5bd17683e533eb3f2fdc69596 (patch)
tree17b3cc1e3d786b2b396ca442c819daf70073b0a4
parent3bc7ad5378e6aaf050d34a8eb54d8964e4165fc3 (diff)
downloadnixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar.gz
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar.bz2
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar.lz
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar.xz
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.tar.zst
nixpkgs-ad3ed169292942d5bd17683e533eb3f2fdc69596.zip
lvm2: fix musl patches; apply unconditionally
Alpine's version of the first patch no longer applied, because we're
on a newer lvm2 version.

The fixes in both of these patches are either Musl-specific, or
shouldn't negatively affect Glibc, so change to applying them
unconditionally so they don't bitrot in future.
-rw-r--r--pkgs/os-specific/linux/lvm2/default.nix10
-rw-r--r--pkgs/os-specific/linux/lvm2/fix-stdio-usage.patch53
2 files changed, 56 insertions, 7 deletions
diff --git a/pkgs/os-specific/linux/lvm2/default.nix b/pkgs/os-specific/linux/lvm2/default.nix
index 4c07c0f7477..fed7152d07a 100644
--- a/pkgs/os-specific/linux/lvm2/default.nix
+++ b/pkgs/os-specific/linux/lvm2/default.nix
@@ -67,13 +67,9 @@ stdenv.mkDerivation rec {
     sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h
   '';
 
-
-  patches = lib.optionals stdenv.hostPlatform.isMusl [
-    (fetchpatch {
-      name = "fix-stdio-usage.patch";
-      url = "https://git.alpinelinux.org/aports/plain/main/lvm2/fix-stdio-usage.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50";
-      sha256 = "0m6wr6qrvxqi2d2h054cnv974jq1v65lqxy05g1znz946ga73k3p";
-    })
+  patches = [
+    # Musl fixes from Alpine.
+    ./fix-stdio-usage.patch
     (fetchpatch {
       name = "mallinfo.patch";
       url = "https://git.alpinelinux.org/aports/plain/main/lvm2/mallinfo.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50";
diff --git a/pkgs/os-specific/linux/lvm2/fix-stdio-usage.patch b/pkgs/os-specific/linux/lvm2/fix-stdio-usage.patch
new file mode 100644
index 00000000000..59666ffbad5
--- /dev/null
+++ b/pkgs/os-specific/linux/lvm2/fix-stdio-usage.patch
@@ -0,0 +1,53 @@
+diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
+index 296618686..96343eeb7 100644
+--- a/lib/commands/toolcontext.c
++++ b/lib/commands/toolcontext.c
+@@ -1619,7 +1619,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
+ 	/* FIXME Make this configurable? */
+ 	reset_lvm_errno(1);
+ 
+-#ifndef VALGRIND_POOL
++#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
+ 	/* Set in/out stream buffering before glibc */
+ 	if (set_buffering
+ #ifdef SYS_gettid
+@@ -2006,7 +2006,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
+ 
+ 	if (cmd->pending_delete_mem)
+ 		dm_pool_destroy(cmd->pending_delete_mem);
+-#ifndef VALGRIND_POOL
++#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
+ 	if (cmd->linebuffer) {
+ 		/* Reset stream buffering to defaults */
+ 		if (is_valid_fd(STDIN_FILENO) &&
+diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
+index d97ff5720..bbbda82bd 100644
+--- a/tools/lvmcmdline.c
++++ b/tools/lvmcmdline.c
+@@ -3342,7 +3342,7 @@ static int _check_standard_fds(void)
+ 	int err = is_valid_fd(STDERR_FILENO);
+ 
+ 	if (!is_valid_fd(STDIN_FILENO) &&
+-	    !(stdin = fopen(_PATH_DEVNULL, "r"))) {
++	    !freopen(_PATH_DEVNULL, "r", stdin)) {
+ 		if (err)
+ 			perror("stdin stream open");
+ 		else
+@@ -3352,7 +3352,7 @@ static int _check_standard_fds(void)
+ 	}
+ 
+ 	if (!is_valid_fd(STDOUT_FILENO) &&
+-	    !(stdout = fopen(_PATH_DEVNULL, "w"))) {
++	    !freopen(_PATH_DEVNULL, "w", stdout)) {
+ 		if (err)
+ 			perror("stdout stream open");
+ 		/* else no stdout */
+@@ -3360,7 +3360,7 @@ static int _check_standard_fds(void)
+ 	}
+ 
+ 	if (!is_valid_fd(STDERR_FILENO) &&
+-	    !(stderr = fopen(_PATH_DEVNULL, "w"))) {
++	    !freopen(_PATH_DEVNULL, "w", stderr)) {
+ 		printf("stderr stream open: %s\n",
+ 		       strerror(errno));
+ 		return 0;