From 7d70d35787dc1a32f82bf452f2c410bf2628763e Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li <44064051+ShamrockLee@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:17:09 +0000 Subject: [PATCH 1/3] xrootd: decouple test-runner build and passthru.tests.test-runner --- pkgs/tools/networking/xrootd/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/networking/xrootd/default.nix b/pkgs/tools/networking/xrootd/default.nix index 586e726b3d4..69313eabb8b 100644 --- a/pkgs/tools/networking/xrootd/default.nix +++ b/pkgs/tools/networking/xrootd/default.nix @@ -16,7 +16,7 @@ , systemd , voms , zlib -, enableTests ? stdenv.isLinux +, enableTestRunner ? true # If not null, the builder will # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc. , externalEtc ? "/etc" @@ -36,7 +36,7 @@ stdenv.mkDerivation rec { outputs = [ "bin" "out" "dev" "man" ]; - passthru.tests = lib.optionalAttrs enableTests { + passthru.tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { test-runner = callPackage ./test-runner.nix { }; }; @@ -60,7 +60,7 @@ stdenv.mkDerivation rec { systemd voms ] - ++ lib.optionals enableTests [ + ++ lib.optionals enableTestRunner [ cppunit ]; @@ -84,7 +84,7 @@ stdenv.mkDerivation rec { install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket ''; - cmakeFlags = lib.optionals enableTests [ + cmakeFlags = lib.optionals enableTestRunner [ "-DENABLE_TESTS=TRUE" ]; From 9471e692403aa4a27baf815f5f97e8564ffb85b3 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li <44064051+ShamrockLee@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:30:09 +0000 Subject: [PATCH 2/3] xrootd: use fixed-point style mkDerivation Make passthru.tests follow finalPackage --- pkgs/tools/networking/xrootd/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/networking/xrootd/default.nix b/pkgs/tools/networking/xrootd/default.nix index 69313eabb8b..8f16a14e501 100644 --- a/pkgs/tools/networking/xrootd/default.nix +++ b/pkgs/tools/networking/xrootd/default.nix @@ -22,14 +22,14 @@ , externalEtc ? "/etc" }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "xrootd"; version = "5.5.2"; src = fetchFromGitHub { owner = "xrootd"; repo = "xrootd"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; fetchSubmodules = true; hash = "sha256-2zVCOcjL8TUbo38Dx7W8431ziouzuAdCfogsIMSOOmQ="; }; @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { outputs = [ "bin" "out" "dev" "man" ]; passthru.tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { - test-runner = callPackage ./test-runner.nix { }; + test-runner = callPackage ./test-runner.nix { xrootd = finalAttrs.finalPackage; }; }; nativeBuildInputs = [ @@ -100,4 +100,4 @@ stdenv.mkDerivation rec { platforms = platforms.all; maintainers = with maintainers; [ ShamrockLee ]; }; -} +}) From da98c61085bf0fe3706324718f4aea6eb4e0e277 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li <44064051+ShamrockLee@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:13:22 +0000 Subject: [PATCH 3/3] xrootd: add tests.test-xrdcp and passthru fetchxrd --- pkgs/tools/networking/xrootd/default.nix | 19 ++++++++-- pkgs/tools/networking/xrootd/fetchxrd.nix | 42 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 pkgs/tools/networking/xrootd/fetchxrd.nix diff --git a/pkgs/tools/networking/xrootd/default.nix b/pkgs/tools/networking/xrootd/default.nix index 8f16a14e501..66113a20a2f 100644 --- a/pkgs/tools/networking/xrootd/default.nix +++ b/pkgs/tools/networking/xrootd/default.nix @@ -16,6 +16,7 @@ , systemd , voms , zlib + # Build bin/test-runner , enableTestRunner ? true # If not null, the builder will # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc. @@ -36,9 +37,21 @@ stdenv.mkDerivation (finalAttrs: { outputs = [ "bin" "out" "dev" "man" ]; - passthru.tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { - test-runner = callPackage ./test-runner.nix { xrootd = finalAttrs.finalPackage; }; - }; + passthru.fetchxrd = callPackage ./fetchxrd.nix { xrootd = finalAttrs.finalPackage; }; + passthru.tests = + lib.optionalAttrs stdenv.hostPlatform.isLinux { + test-runner = callPackage ./test-runner.nix { xrootd = finalAttrs.finalPackage; }; + } // { + test-xrdcp = finalAttrs.passthru.fetchxrd { + pname = "xrootd-test-xrdcp"; + # Use the the bin output hash of xrootd as version to ensure that + # the test gets rebuild everytime xrootd gets rebuild + version = finalAttrs.version + "-" + builtins.substring (builtins.stringLength builtins.storeDir + 1) 32 "${finalAttrs.finalPackage}"; + url = "root://eospublic.cern.ch//eos/opendata/alice/2010/LHC10h/000138275/ESD/0000/AliESDs.root"; + hash = "sha256-tIcs2oi+8u/Qr+P7AAaPTbQT+DEt26gEdc4VNerlEHY="; + }; + } + ; nativeBuildInputs = [ cmake diff --git a/pkgs/tools/networking/xrootd/fetchxrd.nix b/pkgs/tools/networking/xrootd/fetchxrd.nix new file mode 100644 index 00000000000..b7a77f80549 --- /dev/null +++ b/pkgs/tools/networking/xrootd/fetchxrd.nix @@ -0,0 +1,42 @@ +{ lib +, runCommandLocal +, buildPlatform +, xrootd +}: + +{ name ? "" +, pname ? "" +, version ? "" +, urls ? [ ] +, url ? if urls == [ ] then abort "Expect either non-empty `urls` or `url`" else builtins.head urls +, hash ? lib.fakeHash +}: + +(runCommandLocal name + { + nativeBuildInputs = [ xrootd ]; + outputHashAlgo = null; + outputHashMode = "flat"; + outputHash = hash; + inherit url; + urls = if urls == [ ] then lib.singleton url else urls; + } + # Set [DY]LD_LIBRARY_PATH to workaround #169677 + # TODO: Remove the library path after #200830 get merged + '' + for u in $urls; do + ${lib.optionalString buildPlatform.isDarwin "DY"}LD_LIBRARY_PATH=${lib.makeLibraryPath [ xrootd ]} xrdcp --force "$u" "$out" + ret=$? + (( ret != 0 )) || break + done + if (( ret )); then + echo "xrdcp failed trying to download any of the urls" >&2 + exit $ret + fi + '').overrideAttrs (finalAttrs: prevAttrs: +if (pname != "" && version != "") then { + inherit pname version; + name = with finalAttrs; "${pname}-${version}"; +} else { + name = if (name != "") then name else (baseNameOf finalAttrs.url); +})