Merge pull request #222252 from ShamrockLee/xrootd-test-xrdcp

xrootd: implement fetchxrd and add test-xrdcp

authored by Dmitry Kalinkin and committed by GitHub c2f6e54e b9fd231d

+64 -9
+22 -9
pkgs/tools/networking/xrootd/default.nix
··· 16 16 , systemd 17 17 , voms 18 18 , zlib 19 - , enableTests ? stdenv.isLinux 19 + # Build bin/test-runner 20 + , enableTestRunner ? true 20 21 # If not null, the builder will 21 22 # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc. 22 23 , externalEtc ? "/etc" 23 24 }: 24 25 25 - stdenv.mkDerivation rec { 26 + stdenv.mkDerivation (finalAttrs: { 26 27 pname = "xrootd"; 27 28 version = "5.5.5"; 28 29 29 30 src = fetchFromGitHub { 30 31 owner = "xrootd"; 31 32 repo = "xrootd"; 32 - rev = "v${version}"; 33 + rev = "v${finalAttrs.version}"; 33 34 fetchSubmodules = true; 34 35 hash = "sha256-SLmxv8opN7z4V07S9kLGo8HG7Ql62iZQLtf3zGemwA8="; 35 36 }; 36 37 37 38 outputs = [ "bin" "out" "dev" "man" ]; 38 39 39 - passthru.tests = lib.optionalAttrs enableTests { 40 - test-runner = callPackage ./test-runner.nix { }; 41 - }; 40 + passthru.fetchxrd = callPackage ./fetchxrd.nix { xrootd = finalAttrs.finalPackage; }; 41 + passthru.tests = 42 + lib.optionalAttrs stdenv.hostPlatform.isLinux { 43 + test-runner = callPackage ./test-runner.nix { xrootd = finalAttrs.finalPackage; }; 44 + } // { 45 + test-xrdcp = finalAttrs.passthru.fetchxrd { 46 + pname = "xrootd-test-xrdcp"; 47 + # Use the the bin output hash of xrootd as version to ensure that 48 + # the test gets rebuild everytime xrootd gets rebuild 49 + version = finalAttrs.version + "-" + builtins.substring (builtins.stringLength builtins.storeDir + 1) 32 "${finalAttrs.finalPackage}"; 50 + url = "root://eospublic.cern.ch//eos/opendata/alice/2010/LHC10h/000138275/ESD/0000/AliESDs.root"; 51 + hash = "sha256-tIcs2oi+8u/Qr+P7AAaPTbQT+DEt26gEdc4VNerlEHY="; 52 + }; 53 + } 54 + ; 42 55 43 56 nativeBuildInputs = [ 44 57 cmake ··· 60 73 systemd 61 74 voms 62 75 ] 63 - ++ lib.optionals enableTests [ 76 + ++ lib.optionals enableTestRunner [ 64 77 cppunit 65 78 ]; 66 79 ··· 84 97 install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket 85 98 ''; 86 99 87 - cmakeFlags = lib.optionals enableTests [ 100 + cmakeFlags = lib.optionals enableTestRunner [ 88 101 "-DENABLE_TESTS=TRUE" 89 102 ]; 90 103 ··· 100 113 platforms = platforms.all; 101 114 maintainers = with maintainers; [ ShamrockLee ]; 102 115 }; 103 - } 116 + })
+42
pkgs/tools/networking/xrootd/fetchxrd.nix
··· 1 + { lib 2 + , runCommandLocal 3 + , buildPlatform 4 + , xrootd 5 + }: 6 + 7 + { name ? "" 8 + , pname ? "" 9 + , version ? "" 10 + , urls ? [ ] 11 + , url ? if urls == [ ] then abort "Expect either non-empty `urls` or `url`" else builtins.head urls 12 + , hash ? lib.fakeHash 13 + }: 14 + 15 + (runCommandLocal name 16 + { 17 + nativeBuildInputs = [ xrootd ]; 18 + outputHashAlgo = null; 19 + outputHashMode = "flat"; 20 + outputHash = hash; 21 + inherit url; 22 + urls = if urls == [ ] then lib.singleton url else urls; 23 + } 24 + # Set [DY]LD_LIBRARY_PATH to workaround #169677 25 + # TODO: Remove the library path after #200830 get merged 26 + '' 27 + for u in $urls; do 28 + ${lib.optionalString buildPlatform.isDarwin "DY"}LD_LIBRARY_PATH=${lib.makeLibraryPath [ xrootd ]} xrdcp --force "$u" "$out" 29 + ret=$? 30 + (( ret != 0 )) || break 31 + done 32 + if (( ret )); then 33 + echo "xrdcp failed trying to download any of the urls" >&2 34 + exit $ret 35 + fi 36 + '').overrideAttrs (finalAttrs: prevAttrs: 37 + if (pname != "" && version != "") then { 38 + inherit pname version; 39 + name = with finalAttrs; "${pname}-${version}"; 40 + } else { 41 + name = if (name != "") then name else (baseNameOf finalAttrs.url); 42 + })