@@ -1,21 +1,45 @@
1−{ lib, stdenv, fetchurl
2−, getopt
1+{ lib, stdenv, fetchurl, fetchpatch
2+, getopt, tzdata
33}:
44
55stdenv.mkDerivation rec {
66 pname = "bmake";
7− version = "20200902";
7+ version = "20210420";
88
99 src = fetchurl {
1010 url = "http://www.crufty.net/ftp/pub/sjg/${pname}-${version}.tar.gz";
11− sha256 = "1v1v81llsiy8qbpy38nml1x08dhrihwh040pqgwbwb9zy1108b08";
11+ sha256 = "1ajq8v5rq3pl5y9h1hlscs83007fsyk3lhcp87z09ma370lm3ra7";
1212 };
1313
14+ # Make tests work with musl
15+ # * Disable deptgt-delete_on_error test (alpine does this too)
16+ # * Fix test failing due to different strerror(3) output for musl and glibc
17+ postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
18+ sed -i unit-tests/Makefile -e '/deptgt-delete_on_error/d'
19+ substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename"
20+ '';
21+
1422 nativeBuildInputs = [ getopt ];
1523
1624 patches = [
25+ # make bootstrap script aware of the prefix in /nix/store
1726 ./bootstrap-fix.patch
27+ # preserve PATH from build env in unit tests
1828 ./fix-unexport-env-test.patch
29+ # Fix localtime tests without global /etc/zoneinfo directory
30+ ./fix-localtime-test.patch
31+ # decouple tests from build phase
32+ (fetchpatch {
33+ name = "separate-tests.patch";
34+ url = "https://raw.githubusercontent.com/alpinelinux/aports/2a36f7b79df44136c4d2b8e9512f908af65adfee/community/bmake/separate-tests.patch";
35+ sha256 = "00s76jwyr83c6rkvq67b1lxs8jhm0gj2rjgy77xazqr5400slj9a";
36+ })
37+ # add a shebang to bmake's install(1) replacement
38+ (fetchpatch {
39+ name = "install-sh.patch";
40+ url = "https://raw.githubusercontent.com/alpinelinux/aports/34cd8c45397c63c041cf3cbe1ba5232fd9331196/community/bmake/install-sh.patch";
41+ sha256 = "0z8icd6akb96r4cksqnhynkn591vbxlmrrs4w6wil3r6ggk6mwa6";
42+ })
1943 ];
2044
2145 # The generated makefile is a small wrapper for calling ./boot-strap
@@ -43,6 +67,16 @@ stdenv.mkDerivation rec {
4367 runHook postInstall
4468 '';
4569
70+ doCheck = true;
71+ checkInputs = [ tzdata ];
72+ checkPhase = ''
73+ runHook preCheck
74+
75+ ./boot-strap -o . op=test
76+
77+ runHook postCheck
78+ '';
79+
4680 setupHook = ./setup-hook.sh;
4781
4882 meta = with lib; {