Unverified Commit c2f6e54e authored by Dmitry Kalinkin's avatar Dmitry Kalinkin Committed by GitHub
Browse files

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

xrootd: implement fetchxrd and add test-xrdcp
parents b9fd231d da98c610
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -16,29 +16,42 @@
, systemd
, voms
, zlib
, enableTests ? stdenv.isLinux
  # 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.
, externalEtc ? "/etc"
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "xrootd";
  version = "5.5.5";

  src = fetchFromGitHub {
    owner = "xrootd";
    repo = "xrootd";
    rev = "v${version}";
    rev = "v${finalAttrs.version}";
    fetchSubmodules = true;
    hash = "sha256-SLmxv8opN7z4V07S9kLGo8HG7Ql62iZQLtf3zGemwA8=";
  };

  outputs = [ "bin" "out" "dev" "man" ];

  passthru.tests = lib.optionalAttrs enableTests {
    test-runner = callPackage ./test-runner.nix { };
  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
@@ -60,7 +73,7 @@ stdenv.mkDerivation rec {
    systemd
    voms
  ]
  ++ lib.optionals enableTests [
  ++ lib.optionals enableTestRunner [
    cppunit
  ];

@@ -84,7 +97,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"
  ];

@@ -100,4 +113,4 @@ stdenv.mkDerivation rec {
    platforms = platforms.all;
    maintainers = with maintainers; [ ShamrockLee ];
  };
}
})
+42 −0
Original line number Diff line number Diff line
{ 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);
})