1{
2 lib,
3 stdenv,
4 fetchurl,
5 ed,
6 autoreconfHook,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "patch";
11 version = "2.8";
12
13 src = fetchurl {
14 url = "mirror://gnu/patch/patch-${version}.tar.xz";
15 hash = "sha256-+Hzuae7CtPy/YKOWsDCtaqNBXxkqpffuhMrV4R9/WuM=";
16 };
17
18 # This test is filesystem-dependent - observed failing on ZFS
19 postPatch = lib.optionalString stdenv.hostPlatform.isFreeBSD ''
20 sed -E -i -e '/bad-filenames/d' tests/Makefile.am
21 '';
22
23 nativeBuildInputs = [ autoreconfHook ];
24
25 configureFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
26 "ac_cv_func_strnlen_working=yes"
27 ];
28
29 doCheck = stdenv.hostPlatform.libc != "musl"; # not cross;
30 nativeCheckInputs = [ ed ];
31
32 meta = {
33 description = "GNU Patch, a program to apply differences to files";
34 mainProgram = "patch";
35
36 longDescription = ''
37 GNU Patch takes a patch file containing a difference listing
38 produced by the diff program and applies those differences to one or
39 more original files, producing patched versions.
40 '';
41
42 homepage = "https://savannah.gnu.org/projects/patch";
43
44 license = lib.licenses.gpl3Plus;
45
46 maintainers = [ ];
47 platforms = lib.platforms.all;
48 };
49}