From 77a46300fa05cd780e71cbf1ca400c714bd13340 Mon Sep 17 00:00:00 2001
From: Michael Raskin <7c6f434c@mail.ru>
Date: Thu, 11 Oct 2007 03:41:29 +0000
Subject: [PATCH] Added patch from Gentoo for glibc 2.6 compatibility. It just
 randomly renames an inner function, so glibc 2.5-safe.

svn path=/nixpkgs/trunk/; revision=9441
---
 pkgs/tools/archivers/cpio/default.nix         |  2 +-
 .../archivers/cpio/gnulib-futimens.patch      | 30 +++++++++++
 pkgs/tools/archivers/gnutar/default.nix       |  2 +-
 .../archivers/gnutar/gnulib-futimens.patch    | 42 +++++++++++++++
 pkgs/tools/compression/gzip/default.nix       |  1 +
 .../compression/gzip/gnulib-futimens.patch    | 42 +++++++++++++++
 pkgs/tools/misc/coreutils/default.nix         |  1 +
 .../misc/coreutils/gnulib-futimens.patch      | 54 +++++++++++++++++++
 pkgs/tools/misc/su/default.nix                |  1 +
 9 files changed, 173 insertions(+), 2 deletions(-)
 create mode 100644 pkgs/tools/archivers/cpio/gnulib-futimens.patch
 create mode 100644 pkgs/tools/archivers/gnutar/gnulib-futimens.patch
 create mode 100644 pkgs/tools/compression/gzip/gnulib-futimens.patch
 create mode 100644 pkgs/tools/misc/coreutils/gnulib-futimens.patch

diff --git a/pkgs/tools/archivers/cpio/default.nix b/pkgs/tools/archivers/cpio/default.nix
index deed73bc0318..225bc557350e 100644
--- a/pkgs/tools/archivers/cpio/default.nix
+++ b/pkgs/tools/archivers/cpio/default.nix
@@ -6,5 +6,5 @@ stdenv.mkDerivation {
     url = http://ftp.gnu.org/gnu/cpio/cpio-2.7.tar.bz2;
     md5 = "69ad6cb3d288aafe5f969f68d9fd0fb7";
   };
-  patches = [./symlink.patch];
+  patches = [./symlink.patch ./gnulib-futimens.patch];
 }
diff --git a/pkgs/tools/archivers/cpio/gnulib-futimens.patch b/pkgs/tools/archivers/cpio/gnulib-futimens.patch
new file mode 100644
index 000000000000..11703d5706df
--- /dev/null
+++ b/pkgs/tools/archivers/cpio/gnulib-futimens.patch
@@ -0,0 +1,30 @@
+now hat glibc-2.6  declares futimens.
+http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00089.html
+
+diff -ru cpio-2.7.orig/lib/utimens.c cpio-2.7/lib/utimens.c
+--- cpio-2.7.orig/lib/utimens.c	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.c	2007-05-21 08:40:22.000000000 +0900
+@@ -73,7 +73,7 @@
+    Return 0 on success, -1 (setting errno) on failure.  */
+ 
+ int
+-futimens (int fd ATTRIBUTE_UNUSED,
++gl_futimens (int fd ATTRIBUTE_UNUSED,
+ 	  char const *file, struct timespec const timespec[2])
+ {
+   /* There's currently no interface to set file timestamps with
+@@ -166,5 +166,5 @@
+ int
+ utimens (char const *file, struct timespec const timespec[2])
+ {
+-  return futimens (-1, file, timespec);
++  return gl_futimens (-1, file, timespec);
+ }
+diff -ru cpio-2.7.orig/lib/utimens.h cpio-2.7/lib/utimens.h
+--- cpio-2.7.orig/lib/utimens.h	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.h	2007-05-21 08:39:57.000000000 +0900
+@@ -1,3 +1,3 @@
+ #include "timespec.h"
+-int futimens (int, char const *, struct timespec const [2]);
++int gl_futimens (int, char const *, struct timespec const [2]);
+ int utimens (char const *, struct timespec const [2]);
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index 8072c5865807..c8d77071123d 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -6,5 +6,5 @@ stdenv.mkDerivation {
     url = mirror://gnu/tar/tar-1.16.1.tar.bz2;
     md5 = "d51593461c5ef1f7e37134f22338bb9e";
   };
-  patches = [./implausible.patch];
+  patches = [./implausible.patch ./gnulib-futimens.patch];
 }
diff --git a/pkgs/tools/archivers/gnutar/gnulib-futimens.patch b/pkgs/tools/archivers/gnutar/gnulib-futimens.patch
new file mode 100644
index 000000000000..00cdf9322e62
--- /dev/null
+++ b/pkgs/tools/archivers/gnutar/gnulib-futimens.patch
@@ -0,0 +1,42 @@
+now hat glibc-2.6  declares futimens.
+http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00089.html
+
+diff -ru cpio-2.7.orig/lib/utimens.c cpio-2.7/lib/utimens.c
+--- cpio-2.7.orig/lib/utimens.c	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.c	2007-05-21 08:40:22.000000000 +0900
+@@ -73,7 +73,7 @@
+    Return 0 on success, -1 (setting errno) on failure.  */
+ 
+ int
+-futimens (int fd ATTRIBUTE_UNUSED,
++gl_futimens (int fd ATTRIBUTE_UNUSED,
+ 	  char const *file, struct timespec const timespec[2])
+ {
+   /* There's currently no interface to set file timestamps with
+@@ -166,5 +166,5 @@
+ int
+ utimens (char const *file, struct timespec const timespec[2])
+ {
+-  return futimens (-1, file, timespec);
++  return gl_futimens (-1, file, timespec);
+ }
+diff -ru cpio-2.7.orig/lib/utimens.h cpio-2.7/lib/utimens.h
+--- cpio-2.7.orig/lib/utimens.h	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.h	2007-05-21 08:39:57.000000000 +0900
+@@ -1,3 +1,3 @@
+ #include "timespec.h"
+-int futimens (int, char const *, struct timespec const [2]);
++int gl_futimens (int, char const *, struct timespec const [2]);
+ int utimens (char const *, struct timespec const [2]);
+diff -ur tar-1.16.1.orig/src/misc.c tar-1.16.1/src/misc.c
+--- tar-1.16.1.orig/src/misc.c	2007-05-21 08:57:02.000000000 +0900
++++ tar-1.16.1/src/misc.c	2007-05-21 08:57:16.000000000 +0900
+@@ -518,7 +518,7 @@
+     }
+ #endif
+ 
+-  return futimens (fd, file, timespec);
++  return gl_futimens (fd, file, timespec);
+ }
+ 
+ /* A description of a working directory.  */
diff --git a/pkgs/tools/compression/gzip/default.nix b/pkgs/tools/compression/gzip/default.nix
index 94a2fa8b7041..58d6e8b97078 100644
--- a/pkgs/tools/compression/gzip/default.nix
+++ b/pkgs/tools/compression/gzip/default.nix
@@ -6,4 +6,5 @@ stdenv.mkDerivation {
     url = http://ftp.gnu.org/gnu/gzip/gzip-1.3.12.tar.gz;
     sha256 = "1bw7sm68xjlnlzgcx66hnw80ac1qqyvhw0vw27zilgbzbzh5nmiz";
   };
+	patches = [./gnulib-futimens.patch];
 }
diff --git a/pkgs/tools/compression/gzip/gnulib-futimens.patch b/pkgs/tools/compression/gzip/gnulib-futimens.patch
new file mode 100644
index 000000000000..5804bf27ff3f
--- /dev/null
+++ b/pkgs/tools/compression/gzip/gnulib-futimens.patch
@@ -0,0 +1,42 @@
+now hat glibc-2.6  declares futimens.
+http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00089.html
+
+diff -ru cpio-2.7.orig/lib/utimens.c cpio-2.7/lib/utimens.c
+--- cpio-2.7.orig/lib/utimens.c	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.c	2007-05-21 08:40:22.000000000 +0900
+@@ -73,7 +73,7 @@
+    Return 0 on success, -1 (setting errno) on failure.  */
+ 
+ int
+-futimens (int fd ATTRIBUTE_UNUSED,
++gl_futimens (int fd ATTRIBUTE_UNUSED,
+ 	  char const *file, struct timespec const timespec[2])
+ {
+   /* There's currently no interface to set file timestamps with
+@@ -166,5 +166,5 @@
+ int
+ utimens (char const *file, struct timespec const timespec[2])
+ {
+-  return futimens (-1, file, timespec);
++  return gl_futimens (-1, file, timespec);
+ }
+diff -ru cpio-2.7.orig/lib/utimens.h cpio-2.7/lib/utimens.h
+--- cpio-2.7.orig/lib/utimens.h	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.h	2007-05-21 08:39:57.000000000 +0900
+@@ -1,3 +1,3 @@
+ #include "timespec.h"
+-int futimens (int, char const *, struct timespec const [2]);
++int gl_futimens (int, char const *, struct timespec const [2]);
+ int utimens (char const *, struct timespec const [2]);
+diff -ur gzip-1.3.12.orig/gzip.c gzip-1.3.12/gzip.c
+--- gzip-1.3.12.orig/gzip.c	2007-05-21 09:12:46.000000000 +0900
++++ gzip-1.3.12/gzip.c	2007-05-21 09:13:14.000000000 +0900
+@@ -1637,7 +1637,7 @@
+ 	}
+       }
+ 
+-    if (futimens (ofd, ofname, timespec) != 0)
++    if (gl_futimens (ofd, ofname, timespec) != 0)
+       {
+ 	int e = errno;
+ 	WARN ((stderr, "%s: ", program_name));
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index a6079654d461..770a1dbfbc9a 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -6,4 +6,5 @@ stdenv.mkDerivation {
     url = mirror://gnu/coreutils/coreutils-6.9.tar.bz2;
     sha256 = "1c4p2kiy4m024qcl1przvphy8vhivf8jvclq6bjm1pjps5d8khl9";
   };
+  patches = [ ./gnulib-futimens.patch ] ;
 }
diff --git a/pkgs/tools/misc/coreutils/gnulib-futimens.patch b/pkgs/tools/misc/coreutils/gnulib-futimens.patch
new file mode 100644
index 000000000000..f107f017d821
--- /dev/null
+++ b/pkgs/tools/misc/coreutils/gnulib-futimens.patch
@@ -0,0 +1,54 @@
+now hat glibc-2.6  declares futimens.
+http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00089.html
+
+diff -ru cpio-2.7.orig/lib/utimens.c cpio-2.7/lib/utimens.c
+--- cpio-2.7.orig/lib/utimens.c	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.c	2007-05-21 08:40:22.000000000 +0900
+@@ -73,7 +73,7 @@
+    Return 0 on success, -1 (setting errno) on failure.  */
+ 
+ int
+-futimens (int fd ATTRIBUTE_UNUSED,
++gl_futimens (int fd ATTRIBUTE_UNUSED,
+ 	  char const *file, struct timespec const timespec[2])
+ {
+   /* There's currently no interface to set file timestamps with
+@@ -166,5 +166,5 @@
+ int
+ utimens (char const *file, struct timespec const timespec[2])
+ {
+-  return futimens (-1, file, timespec);
++  return gl_futimens (-1, file, timespec);
+ }
+diff -ru cpio-2.7.orig/lib/utimens.h cpio-2.7/lib/utimens.h
+--- cpio-2.7.orig/lib/utimens.h	2007-05-20 21:23:57.000000000 +0900
++++ cpio-2.7/lib/utimens.h	2007-05-21 08:39:57.000000000 +0900
+@@ -1,3 +1,3 @@
+ #include "timespec.h"
+-int futimens (int, char const *, struct timespec const [2]);
++int gl_futimens (int, char const *, struct timespec const [2]);
+ int utimens (char const *, struct timespec const [2]);
+diff -ru coreutils-6.9.orig/src/copy.c coreutils-6.9/src/copy.c
+--- coreutils-6.9.orig/src/copy.c	2007-05-21 09:27:22.000000000 +0900
++++ coreutils-6.9/src/copy.c	2007-05-21 09:27:47.000000000 +0900
+@@ -623,7 +623,7 @@
+       timespec[0] = get_stat_atime (src_sb);
+       timespec[1] = get_stat_mtime (src_sb);
+ 
+-      if (futimens (dest_desc, dst_name, timespec) != 0)
++      if (gl_futimens (dest_desc, dst_name, timespec) != 0)
+ 	{
+ 	  error (0, errno, _("preserving times for %s"), quote (dst_name));
+ 	  if (x->require_preserve)
+diff -ru coreutils-6.9.orig/src/touch.c coreutils-6.9/src/touch.c
+--- coreutils-6.9.orig/src/touch.c	2007-05-21 09:27:22.000000000 +0900
++++ coreutils-6.9/src/touch.c	2007-05-21 09:27:57.000000000 +0900
+@@ -182,7 +182,7 @@
+       t = timespec;
+     }
+ 
+-  ok = (futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
++  ok = (gl_futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
+ 
+   if (fd == STDIN_FILENO)
+     {
diff --git a/pkgs/tools/misc/su/default.nix b/pkgs/tools/misc/su/default.nix
index 440c33e8f5c9..45290ad9038e 100644
--- a/pkgs/tools/misc/su/default.nix
+++ b/pkgs/tools/misc/su/default.nix
@@ -13,6 +13,7 @@ stdenv.mkDerivation {
   patches = [
     # PAM patch taken from SUSE's coreutils-6.7-5.src.rpm.
     ./su-pam.patch
+	../coreutils/gnulib-futimens.patch
   ];
   buildInputs = [pam];
   buildPhase = "