GNU Patch: On Darwin, use an existing tarball, and patch from there.

svn path=/nixpkgs/trunk/; revision=33892
This commit is contained in:
Ludovic Courtès 2012-04-23 15:47:21 +00:00
parent f1135ba545
commit 0a9d954bc6
2 changed files with 71 additions and 12 deletions

View File

@ -0,0 +1,60 @@
Fix builds on Darwin:
http://lists.gnu.org/archive/html/bug-patch/2010-01/msg00004.html .
commit 2c4e3ecddec8a686bd50d238f4cefebb950298b7
Author: Andreas Gruenbacher <agruen@suse.de>
Date: Fri Jan 1 15:58:15 2010 +0100
* Makefile.in (LIBSRCS, LIBM4FILES): Add the missing files strnlen.c,
strnlen.m4, and safe-read.m4.
diff --git a/Makefile.in b/Makefile.in
index 3b3d78a..26dc281 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -91,6 +91,7 @@ LIBSRCS = \
gl/lib/stripslash.c \
gl/lib/strncasecmp.c \
gl/lib/strndup.c \
+ gl/lib/strnlen.c \
gl/lib/xmalloc.c \
gl/lib/xstrndup.c
Add the missing bits from Gnulib.
--- /dev/null 2012-04-23 08:54:35.747205543 +0200
+++ b/gl/lib/strnlen.c 2012-01-16 22:35:02.000000000 +0100
@@ -0,0 +1,31 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+#include <string.h>
+
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}

View File

@ -1,19 +1,12 @@
{ stdenv, fetchurl, ed }:
stdenv.mkDerivation rec {
stdenv.mkDerivation (rec {
name = "patch-2.6.1";
src =
if stdenv.isDarwin
then fetchurl {
# Temporary fix for
# http://lists.gnu.org/archive/html/bug-patch/2010-01/msg00004.html .
url = "ftp://alpha.gnu.org/gnu/patch/patch-2.6.1.87-94d8.tar.gz";
sha256 = "0jnw8p0nvkmwi1a2z56bssqik8fvkb71zd2cpzl1sklnrg1g3b6p";
} else fetchurl {
url = "mirror://gnu/patch/${name}.tar.gz";
sha256 = "1fc1jyq80nswkf492fiqdbl2bhvlw2wb44ghqlfd3zngx4qkfmni";
};
src = fetchurl {
url = "mirror://gnu/patch/${name}.tar.gz";
sha256 = "1fc1jyq80nswkf492fiqdbl2bhvlw2wb44ghqlfd3zngx4qkfmni";
};
buildInputs = (stdenv.lib.optional doCheck ed);
@ -40,3 +33,9 @@ stdenv.mkDerivation rec {
platforms = stdenv.lib.platforms.all;
};
}
//
(stdenv.lib.optionalAttrs stdenv.isDarwin {
patches = [ ./darwin-fix.patch ];
}))