From 0a9d954bc6aa8012a1ac8d0f9dafb26a2a3ce1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 23 Apr 2012 15:47:21 +0000 Subject: [PATCH] GNU Patch: On Darwin, use an existing tarball, and patch from there. svn path=/nixpkgs/trunk/; revision=33892 --- pkgs/tools/text/gnupatch/darwin-fix.patch | 60 +++++++++++++++++++++++ pkgs/tools/text/gnupatch/default.nix | 23 +++++---- 2 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 pkgs/tools/text/gnupatch/darwin-fix.patch diff --git a/pkgs/tools/text/gnupatch/darwin-fix.patch b/pkgs/tools/text/gnupatch/darwin-fix.patch new file mode 100644 index 00000000000..50d08534814 --- /dev/null +++ b/pkgs/tools/text/gnupatch/darwin-fix.patch @@ -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 +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 ++ ++#include ++ ++/* 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; ++} diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix index 782c0bec850..a7a166c95c3 100644 --- a/pkgs/tools/text/gnupatch/default.nix +++ b/pkgs/tools/text/gnupatch/default.nix @@ -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 ]; +}))