bear: 3.1.6 -> 4.0.3

This commit is contained in:
Diego
2026-02-15 17:30:54 +01:00
parent 74af355192
commit 0aecf39750
2 changed files with 21 additions and 111 deletions
@@ -1,23 +0,0 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -85,8 +85,9 @@
${CMAKE_CACHE_ARGS_EXTRA}
BUILD_ALWAYS
1
- TEST_BEFORE_INSTALL
+ TEST_EXCLUDE_FROM_MAIN
1
+ STEP_TARGETS test
TEST_COMMAND
ctest # or `ctest -T memcheck`
)
@@ -102,7 +103,8 @@
-DCMAKE_INSTALL_LIBDIR:PATH=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_BINDIR:PATH=${CMAKE_INSTALL_BINDIR}
-DSTAGED_INSTALL_PREFIX:PATH=${STAGED_INSTALL_PREFIX}
- TEST_BEFORE_INSTALL
+ TEST_EXCLUDE_FROM_MAIN
+ STEP_TARGETS test
1
INSTALL_COMMAND
""
+21 -88
View File
@@ -1,110 +1,43 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
ninja,
pkg-config,
grpc,
protobuf,
openssl,
nlohmann_json,
gtest,
spdlog,
c-ares,
zlib,
sqlite,
re2,
lit,
python3,
coreutils,
rustPlatform,
installShellFiles,
lld,
}:
stdenv.mkDerivation (finalAttrs: {
rustPlatform.buildRustPackage (finalAttrs: {
pname = "bear";
version = "3.1.6";
version = "4.0.3";
src = fetchFromGitHub {
owner = "rizsotto";
repo = "bear";
rev = finalAttrs.version;
hash = "sha256-fWNMjqF5PCjGfFGReKIUiJ5lv8z6j7HeBn5hvbnV2V4=";
hash = "sha256-VZNrWfeeOJ5+qLg6hby4vR5rKKO7+mVOKp2p+lvwGOc=";
};
strictDeps = true;
cargoHash = "sha256-61hKYDPPQ79QF3BNCLn2LxiCsoll+MGAMZ8obOVuNZI=";
nativeBuildInputs = [
cmake
ninja
pkg-config
grpc
protobuf
installShellFiles
lld
];
buildInputs = [
grpc
protobuf
openssl
nlohmann_json
spdlog
c-ares
zlib
sqlite
re2
];
patches = [
# This patch is necessary to run tests in a separate phase. By default
# test targets are run with ALL, which is not what we want. This patch creates
# separate 'test' step targets for each cmake ExternalProject:
# - BearTest-test (functional lit tests)
# - BearSource-test (unit tests via gtest)
./0001-exclude-tests-from-all.patch
];
nativeCheckInputs = [
lit
python3
];
checkInputs = [
gtest
];
cmakeFlags = [
# Build system and generated files concatenate install prefix and
# CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
(lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
(lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.finalPackage.doCheck)
];
checkTarget = lib.concatStringsSep " " [
"BearTest-test"
"BearSource-test"
];
doCheck = true;
env = {
# Disable failing tests. The cause is not immediately clear.
LIT_FILTER_OUT = lib.concatStringsSep "|" [
"cases/compilation/output/config/filter_compilers.sh"
"cases/intercept/preload/posix/execvpe/success_to_resolve.c"
"cases/intercept/preload/posix/popen/success.c"
"cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c"
"cases/intercept/preload/posix/system/success.c"
"cases/intercept/preload/shell_commands_intercepted_without_shebang.sh"
];
};
postPatch = ''
patchShebangs test/bin
substituteInPlace bear/build.rs \
--replace-fail 'const DEFAULT_WRAPPER_PATH: &str = "/usr/local/libexec/bear";' \
"const DEFAULT_WRAPPER_PATH: &str = \"$out/libexec/bear\";" \
--replace-fail 'const DEFAULT_PRELOAD_PATH: &str = "/usr/local/libexec/bear/$LIB";' \
"const DEFAULT_PRELOAD_PATH: &str = \"$out/lib\";"
'';
# /usr/bin/env is used in test commands and embedded scripts.
find test -name '*.sh' \
-exec sed -i -e 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
postInstall = ''
# wrapper should not end up on path
install -d $out/libexec/bear
mv $out/bin/wrapper $out/libexec/bear/wrapper
installManPage man/bear.1
'';
# Functional tests use loopback networking.