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 , systemd 17 , voms 18 , zlib 19 - , enableTests ? stdenv.isLinux 20 # If not null, the builder will 21 # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc. 22 , externalEtc ? "/etc" 23 }: 24 25 - stdenv.mkDerivation rec { 26 pname = "xrootd"; 27 version = "5.5.5"; 28 29 src = fetchFromGitHub { 30 owner = "xrootd"; 31 repo = "xrootd"; 32 - rev = "v${version}"; 33 fetchSubmodules = true; 34 hash = "sha256-SLmxv8opN7z4V07S9kLGo8HG7Ql62iZQLtf3zGemwA8="; 35 }; 36 37 outputs = [ "bin" "out" "dev" "man" ]; 38 39 - passthru.tests = lib.optionalAttrs enableTests { 40 - test-runner = callPackage ./test-runner.nix { }; 41 - }; 42 43 nativeBuildInputs = [ 44 cmake ··· 60 systemd 61 voms 62 ] 63 - ++ lib.optionals enableTests [ 64 cppunit 65 ]; 66 ··· 84 install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket 85 ''; 86 87 - cmakeFlags = lib.optionals enableTests [ 88 "-DENABLE_TESTS=TRUE" 89 ]; 90 ··· 100 platforms = platforms.all; 101 maintainers = with maintainers; [ ShamrockLee ]; 102 }; 103 - }
··· 16 , systemd 17 , voms 18 , zlib 19 + # Build bin/test-runner 20 + , enableTestRunner ? true 21 # If not null, the builder will 22 # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc. 23 , externalEtc ? "/etc" 24 }: 25 26 + stdenv.mkDerivation (finalAttrs: { 27 pname = "xrootd"; 28 version = "5.5.5"; 29 30 src = fetchFromGitHub { 31 owner = "xrootd"; 32 repo = "xrootd"; 33 + rev = "v${finalAttrs.version}"; 34 fetchSubmodules = true; 35 hash = "sha256-SLmxv8opN7z4V07S9kLGo8HG7Ql62iZQLtf3zGemwA8="; 36 }; 37 38 outputs = [ "bin" "out" "dev" "man" ]; 39 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 + ; 55 56 nativeBuildInputs = [ 57 cmake ··· 73 systemd 74 voms 75 ] 76 + ++ lib.optionals enableTestRunner [ 77 cppunit 78 ]; 79 ··· 97 install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket 98 ''; 99 100 + cmakeFlags = lib.optionals enableTestRunner [ 101 "-DENABLE_TESTS=TRUE" 102 ]; 103 ··· 113 platforms = platforms.all; 114 maintainers = with maintainers; [ ShamrockLee ]; 115 }; 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 + })