2022-01-04 15:44:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, fetchpatch
|
|
|
|
, getopt
|
|
|
|
, ksh
|
2022-12-08 23:38:00 +00:00
|
|
|
, tzdata
|
2021-06-25 16:44:16 +00:00
|
|
|
, pkgsMusl # for passthru.tests
|
2019-06-16 03:51:00 +00:00
|
|
|
}:
|
|
|
|
|
2023-01-29 02:02:19 +00:00
|
|
|
stdenv.mkDerivation (self: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "bmake";
|
2023-01-29 02:02:19 +00:00
|
|
|
version = "20230126";
|
2019-06-16 03:51:00 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2023-01-29 02:02:19 +00:00
|
|
|
url = "http://www.crufty.net/ftp/pub/sjg/${self.pname}-${self.version}.tar.gz";
|
|
|
|
hash = "sha256-hk9yGFgs95Dsc7ILcQVCXLn/ozUiJUF3LwMTMGtqC8Q=";
|
2019-06-16 03:51:00 +00:00
|
|
|
};
|
|
|
|
|
2021-05-29 10:50:32 +00:00
|
|
|
# Make tests work with musl
|
|
|
|
# * Disable deptgt-delete_on_error test (alpine does this too)
|
2021-07-04 17:16:06 +00:00
|
|
|
# * Disable shell-ksh test (ksh doesn't compile with musl)
|
2021-05-29 10:50:32 +00:00
|
|
|
# * Fix test failing due to different strerror(3) output for musl and glibc
|
|
|
|
postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
|
2021-07-04 17:16:06 +00:00
|
|
|
sed -i unit-tests/Makefile \
|
|
|
|
-e '/deptgt-delete_on_error/d' \
|
|
|
|
-e '/shell-ksh/d'
|
2021-05-29 10:50:32 +00:00
|
|
|
substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename"
|
|
|
|
'';
|
|
|
|
|
2019-06-16 19:24:15 +00:00
|
|
|
nativeBuildInputs = [ getopt ];
|
2019-06-16 03:51:00 +00:00
|
|
|
|
2019-06-16 19:24:15 +00:00
|
|
|
patches = [
|
2021-05-29 10:50:32 +00:00
|
|
|
# make bootstrap script aware of the prefix in /nix/store
|
2019-06-16 19:24:15 +00:00
|
|
|
./bootstrap-fix.patch
|
2021-05-29 10:50:32 +00:00
|
|
|
# preserve PATH from build env in unit tests
|
2019-06-16 19:24:15 +00:00
|
|
|
./fix-unexport-env-test.patch
|
2021-07-04 17:16:06 +00:00
|
|
|
# Always enable ksh test since it checks in a impure location /bin/ksh
|
|
|
|
./unconditional-ksh-test.patch
|
2021-05-29 10:50:32 +00:00
|
|
|
# decouple tests from build phase
|
|
|
|
(fetchpatch {
|
|
|
|
name = "separate-tests.patch";
|
|
|
|
url = "https://raw.githubusercontent.com/alpinelinux/aports/2a36f7b79df44136c4d2b8e9512f908af65adfee/community/bmake/separate-tests.patch";
|
2022-12-08 23:38:00 +00:00
|
|
|
hash = "sha256-KkmqASAl46/6Of7JLOQDFUqkOw3rGLxnNmyg7Lk0RwM=";
|
2021-05-29 10:50:32 +00:00
|
|
|
})
|
|
|
|
# add a shebang to bmake's install(1) replacement
|
|
|
|
(fetchpatch {
|
|
|
|
name = "install-sh.patch";
|
|
|
|
url = "https://raw.githubusercontent.com/alpinelinux/aports/34cd8c45397c63c041cf3cbe1ba5232fd9331196/community/bmake/install-sh.patch";
|
2022-12-08 23:38:00 +00:00
|
|
|
hash = "sha256-RvFq5nsmDxq54UTnXGlfO6Rip/XQYj0ZySatqUxjEX0=";
|
2021-05-29 10:50:32 +00:00
|
|
|
})
|
2019-06-16 19:24:15 +00:00
|
|
|
];
|
2019-06-16 03:51:00 +00:00
|
|
|
|
2022-01-04 15:44:13 +00:00
|
|
|
# The generated makefile is a small wrapper for calling ./boot-strap with a
|
|
|
|
# given op. On a case-insensitive filesystem this generated makefile clobbers
|
|
|
|
# a distinct, shipped, Makefile and causes infinite recursion during tests
|
|
|
|
# which eventually fail with "fork: Resource temporarily unavailable"
|
2021-05-26 13:39:23 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--without-makefile"
|
|
|
|
];
|
|
|
|
|
2022-01-04 15:44:13 +00:00
|
|
|
# Disabled tests:
|
2022-08-07 23:30:40 +00:00
|
|
|
# opt-chdir: ofborg complains about it somehow
|
|
|
|
# opt-keep-going-indirect: not yet known
|
2022-01-04 15:44:13 +00:00
|
|
|
# varmod-localtime: musl doesn't support TZDIR and this test relies on impure,
|
|
|
|
# implicit paths
|
2022-08-07 23:30:40 +00:00
|
|
|
BROKEN_TESTS = builtins.concatStringsSep " " [
|
|
|
|
"opt-chdir"
|
|
|
|
"opt-keep-going-indirect"
|
|
|
|
"varmod-localtime"
|
|
|
|
];
|
2022-01-04 15:44:13 +00:00
|
|
|
|
2021-05-26 13:39:23 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
./boot-strap --prefix=$out -o . op=build
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
./boot-strap --prefix=$out -o . op=install
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-05-29 10:50:32 +00:00
|
|
|
doCheck = true;
|
2022-01-04 15:44:13 +00:00
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [
|
2021-07-04 17:16:06 +00:00
|
|
|
tzdata
|
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.libc != "musl") [
|
|
|
|
ksh
|
|
|
|
];
|
2022-01-04 15:44:13 +00:00
|
|
|
|
2021-05-29 10:50:32 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
./boot-strap -o . op=test
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2021-04-13 00:10:06 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2022-01-04 15:44:13 +00:00
|
|
|
homepage = "http://www.crufty.net/help/sjg/bmake.html";
|
2019-06-16 03:51:00 +00:00
|
|
|
description = "Portable version of NetBSD 'make'";
|
2022-01-04 15:44:13 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice AndersonTorres ];
|
|
|
|
platforms = platforms.unix;
|
2019-06-16 03:51:00 +00:00
|
|
|
};
|
2022-01-04 15:44:13 +00:00
|
|
|
|
|
|
|
passthru.tests.bmakeMusl = pkgsMusl.bmake;
|
2022-08-07 23:13:20 +00:00
|
|
|
})
|
2022-01-04 15:44:13 +00:00
|
|
|
# TODO: report the quirks and patches to bmake devteam (especially the Musl one)
|