Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 bc, 4 fetchurl, 5 getopt, 6 ksh, 7 pkgsMusl ? { }, 8 stdenv, 9 tzdata, 10}: 11 12stdenv.mkDerivation (finalAttrs: { 13 pname = "bmake"; 14 version = "20250528"; 15 16 src = fetchurl { 17 url = "https://www.crufty.net/ftp/pub/sjg/bmake-${finalAttrs.version}.tar.gz"; 18 hash = "sha256-DcOJpeApiqWFNTtgeW1dYy3mYNreWNAKzWCtcihGyaM="; 19 }; 20 21 patches = [ 22 # decouple tests from build phase 23 ./002-dont-test-while-installing.diff 24 # preserve PATH from build env in unit tests 25 ./003-fix-unexport-env-test.diff 26 # Always enable ksh test since it checks in a impure location /bin/ksh 27 ./004-unconditional-ksh-test.diff 28 ]; 29 30 outputs = [ 31 "out" 32 "man" 33 ]; 34 35 nativeBuildInputs = [ 36 getopt 37 ]; 38 39 nativeCheckInputs = [ 40 bc 41 tzdata 42 ] 43 ++ lib.optionals (stdenv.hostPlatform.libc != "musl") [ 44 ksh 45 ]; 46 47 # The generated makefile is a small wrapper for calling ./boot-strap with a 48 # given op. On a case-insensitive filesystem this generated makefile clobbers 49 # a distinct, shipped Makefile and causes infinite recursion during tests 50 # which eventually fail with "fork: Resource temporarily unavailable" 51 configureFlags = [ 52 "--without-makefile" 53 ]; 54 55 # Disabled tests: 56 # * directive-export{,-gmake}: another failure related to TZ variables 57 # * opt-keep-going-indirect: not yet known 58 # * varmod-localtime: musl doesn't support TZDIR and this test relies on 59 # impure, implicit paths 60 env.BROKEN_TESTS = builtins.concatStringsSep " " [ 61 "directive-export" 62 "directive-export-gmake" 63 "opt-keep-going-indirect" 64 "varmod-localtime" 65 ]; 66 67 strictDeps = true; 68 69 doCheck = true; 70 71 # Make tests work with musl 72 # * Disable deptgt-delete_on_error test (alpine does this too) 73 # * Disable shell-ksh test (ksh doesn't compile with musl) 74 # * Fix test failing due to different strerror(3) output for musl and glibc 75 postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") '' 76 sed -i unit-tests/Makefile \ 77 -e '/deptgt-delete_on_error/d' \ 78 -e '/shell-ksh/d' 79 substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename" 80 ''; 81 82 buildPhase = '' 83 runHook preBuild 84 85 ./boot-strap --prefix=$out -o . op=build 86 87 runHook postBuild 88 ''; 89 90 installPhase = '' 91 runHook preInstall 92 93 ./boot-strap --prefix=$out -o . op=install 94 95 runHook postInstall 96 ''; 97 98 checkPhase = '' 99 runHook preCheck 100 101 ./boot-strap -o . op=test 102 103 runHook postCheck 104 ''; 105 106 setupHook = ./setup-hook.sh; 107 108 passthru = { 109 tests = { 110 bmakeMusl = pkgsMusl.bmake or null; 111 }; 112 }; 113 114 meta = { 115 homepage = "https://www.crufty.net/help/sjg/bmake.html"; 116 description = "Portable version of NetBSD 'make'"; 117 license = lib.licenses.bsd3; 118 mainProgram = "bmake"; 119 maintainers = with lib.maintainers; [ thoughtpolice ]; 120 platforms = lib.platforms.unix; 121 # requires strip 122 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ]; 123 }; 124}) 125# TODO: report the quirks and patches to bmake devteam (especially the Musl one) 126# TODO: investigate static support