Unverified Commit 8f1bb337 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

xrootd: 5.6.6 -> 5.7.1 (#345954)

parents 7407a3f6 31f260e2
Loading
Loading
Loading
Loading
+163 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  callPackage,
  fetchFromGitHub,
  davix,
  cmake,
  gtest,
  makeWrapper,
  pkg-config,
  curl,
  isa-l,
  fuse,
  libkrb5,
  libuuid,
  libxcrypt,
  libxml2,
  openssl,
  readline,
  scitokens-cpp,
  systemd,
  voms,
  zlib,
  # If not null, move the default configuration files to "$etc/etc" and look for the configuration
  # directory at externalEtc.
  # Otherwise, the program will look for the configuration files under $out/etc."
  externalEtc ? "/etc",
  removeReferencesTo,
}:

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

  src = fetchFromGitHub {
    owner = "xrootd";
    repo = "xrootd";
    rev = "refs/tags/v${finalAttrs.version}";
    fetchSubmodules = true;
    hash = "sha256-ZU31nsQgs+Gz9mV8LVv4utJ7g8TXN5OxHjNDfQlt38M=";
  };

  postPatch =
    ''
      patchShebangs genversion.sh
      substituteInPlace cmake/XRootDConfig.cmake.in \
        --replace-fail "@PACKAGE_CMAKE_INSTALL_" "@CMAKE_INSTALL_FULL_"
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      sed -i cmake/XRootDOSDefs.cmake -e '/set( MacOSX TRUE )/ainclude( GNUInstallDirs )'
    '';

  outputs = [
    "bin"
    "out"
    "dev"
    "man"
  ] ++ lib.optional (externalEtc != null) "etc";

  nativeBuildInputs = [
    cmake
    makeWrapper
    pkg-config
    removeReferencesTo
  ];

  buildInputs =
    [
      davix
      curl
      isa-l
      libkrb5
      libuuid
      libxcrypt
      libxml2
      openssl
      readline
      scitokens-cpp
      zlib
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
      # https://github.com/xrootd/xrootd/blob/5b5a1f6957def2816b77ec773c7e1bfb3f1cfc5b/cmake/XRootDFindLibs.cmake#L58
      fuse
    ]
    ++ lib.filter (lib.meta.availableOn stdenv.hostPlatform) [
      systemd # only available on specific non-static Linux platforms
      voms # only available on Linux due to gsoap failing to build on Darwin
    ];

  # https://github.com/xrootd/xrootd/blob/master/packaging/rhel/xrootd.spec.in#L665-L675=
  postInstall =
    ''
      mkdir -p "$out/lib/tmpfiles.d"
      install -m 644 -T ../packaging/rhel/xrootd.tmpfiles "$out/lib/tmpfiles.d/xrootd.conf"
      mkdir -p "$out/etc/xrootd"
      install -m 644 -t "$out/etc/xrootd" ../packaging/common/*.cfg
      install -m 644 -t "$out/etc/xrootd" ../packaging/common/client.conf
      mkdir -p "$out/etc/xrootd/client.plugins.d"
      install -m 644 -t "$out/etc/xrootd/client.plugins.d" ../packaging/common/client-plugin.conf.example
      mkdir -p "$out/etc/logrotate.d"
      install -m 644 -T ../packaging/common/xrootd.logrotate "$out/etc/logrotate.d/xrootd"
    ''
    # Leaving those in bin/ leads to a cyclic reference between $dev and $bin
    # This happens since https://github.com/xrootd/xrootd/commit/fe268eb622e2192d54a4230cea54c41660bd5788
    # So far, this xrootd-config script does not seem necessary in $bin
    + ''
      moveToOutput "bin/xrootd-config" "$dev"
      moveToOutput "bin/.xrootd-config-wrapped" "$dev"
    ''
    + lib.optionalString stdenv.hostPlatform.isLinux ''
      mkdir -p "$out/lib/systemd/system"
      install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket
    '';

  cmakeFlags = [
    (lib.cmakeFeature "XRootD_VERSION_STRING" finalAttrs.version)
    (lib.cmakeBool "FORCE_ENABLED" true)
    (lib.cmakeBool "ENABLE_DAVIX" true)
    (lib.cmakeBool "ENABLE_FUSE" (!stdenv.hostPlatform.isDarwin)) # XRootD doesn't support MacFUSE
    (lib.cmakeBool "ENABLE_MACAROONS" false)
    (lib.cmakeBool "ENABLE_PYTHON" false) # built separately
    (lib.cmakeBool "ENABLE_SCITOKENS" true)
    (lib.cmakeBool "ENABLE_TESTS" finalAttrs.finalPackage.doCheck)
    (lib.cmakeBool "ENABLE_VOMS" stdenv.hostPlatform.isLinux)
  ];

  # TODO(@ShamrockLee): Enable the checks.
  doCheck = false;
  checkInputs = [ gtest ];

  postFixup = lib.optionalString (externalEtc != null) ''
    moveToOutput etc "$etc"
    ln -s ${lib.escapeShellArg externalEtc} "$out/etc"
  '';

  dontPatchELF = true; # shrinking rpath will cause runtime failures in dlopen

  passthru = {
    fetchxrd = callPackage ./fetchxrd.nix { xrootd = finalAttrs.finalPackage; };
    tests = {
      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=";
      };
    };
  };

  meta = {
    description = "High performance, scalable fault tolerant data access";
    homepage = "https://xrootd.slac.stanford.edu";
    changelog = "https://github.com/xrootd/xrootd/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.lgpl3Plus;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ ShamrockLee ];
  };
})
+4 −6
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
  buildPythonPackage,
  cmake,
  setuptools,
  wheel,
  xrootd,
}:

@@ -15,10 +14,9 @@ buildPythonPackage rec {

  sourceRoot = "${src.name}/bindings/python";

  nativeBuildInputs = [
  build-system = [
    cmake
    setuptools
    wheel
  ];

  buildInputs = [ xrootd ];
@@ -30,11 +28,11 @@ buildPythonPackage rec {
  # Tests are only compatible with Python 2
  doCheck = false;

  meta = with lib; {
  meta = {
    description = "XRootD central repository";
    homepage = "https://github.com/xrootd/xrootd";
    changelog = "https://github.com/xrootd/xrootd/releases/tag/v${version}";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ GaetanLepage ];
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
}
+0 −152
Original line number Diff line number Diff line
{ lib
, stdenv
, callPackage
, fetchFromGitHub
, davix
, cmake
, cppunit
, gtest
, makeWrapper
, pkg-config
, curl
, fuse
, libkrb5
, libuuid
, libxcrypt
, libxml2
, openssl
, readline
, scitokens-cpp
, 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.
, externalEtc ? "/etc"
, removeReferencesTo
}:

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

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

  outputs = [ "bin" "out" "dev" "man" ]
  ++ lib.optional (externalEtc != null) "etc";

  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
    makeWrapper
    pkg-config
    removeReferencesTo
  ];

  buildInputs = [
    davix
    curl
    libkrb5
    libuuid
    libxcrypt
    libxml2
    openssl
    readline
    scitokens-cpp
    zlib
  ]
  ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
    # https://github.com/xrootd/xrootd/blob/5b5a1f6957def2816b77ec773c7e1bfb3f1cfc5b/cmake/XRootDFindLibs.cmake#L58
    fuse
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    systemd
    voms
  ]
  ++ lib.optionals enableTestRunner [
    gtest
    cppunit
  ];

  preConfigure = ''
    patchShebangs genversion.sh
    substituteInPlace cmake/XRootDConfig.cmake.in \
      --replace-fail "@PACKAGE_CMAKE_INSTALL_" "@CMAKE_INSTALL_FULL_"
  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
    sed -i cmake/XRootDOSDefs.cmake -e '/set( MacOSX TRUE )/ainclude( GNUInstallDirs )'
  '';

  # https://github.com/xrootd/xrootd/blob/master/packaging/rhel/xrootd.spec.in#L665-L675=
  postInstall = ''
    mkdir -p "$out/lib/tmpfiles.d"
    install -m 644 -T ../packaging/rhel/xrootd.tmpfiles "$out/lib/tmpfiles.d/xrootd.conf"
    mkdir -p "$out/etc/xrootd"
    install -m 644 -t "$out/etc/xrootd" ../packaging/common/*.cfg
    install -m 644 -t "$out/etc/xrootd" ../packaging/common/client.conf
    mkdir -p "$out/etc/xrootd/client.plugins.d"
    install -m 644 -t "$out/etc/xrootd/client.plugins.d" ../packaging/common/client-plugin.conf.example
    mkdir -p "$out/etc/logrotate.d"
    install -m 644 -T ../packaging/common/xrootd.logrotate "$out/etc/logrotate.d/xrootd"
  ''
  # Leaving those in bin/ leads to a cyclic reference between $dev and $bin
  # This happens since https://github.com/xrootd/xrootd/commit/fe268eb622e2192d54a4230cea54c41660bd5788
  # So far, this xrootd-config script does not seem necessary in $bin
  + ''
    moveToOutput "bin/xrootd-config" "$dev"
    moveToOutput "bin/.xrootd-config-wrapped" "$dev"
  '' + lib.optionalString stdenv.hostPlatform.isLinux ''
    mkdir -p "$out/lib/systemd/system"
    install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket
  '';

  cmakeFlags = [
    "-DXRootD_VERSION_STRING=${finalAttrs.version}"
  ] ++ lib.optionals enableTestRunner [
    "-DFORCE_ENABLED=TRUE"
    "-DENABLE_DAVIX=TRUE"
    "-DENABLE_FUSE=${if (!stdenv.hostPlatform.isDarwin) then "TRUE" else "FALSE"}" # not supported
    "-DENABLE_MACAROONS=OFF"
    "-DENABLE_PYTHON=FALSE" # built separately
    "-DENABLE_SCITOKENS=TRUE"
    "-DENABLE_TESTS=TRUE"
    "-DENABLE_VOMS=${if stdenv.hostPlatform.isLinux then "TRUE" else "FALSE"}"
  ];

  postFixup = lib.optionalString (externalEtc != null) ''
    moveToOutput etc "$etc"
    ln -s ${lib.escapeShellArg externalEtc} "$out/etc"
  '';

  dontPatchELF = true; # shrinking rpath will cause runtime failures in dlopen

  meta = with lib; {
    description = "High performance, scalable fault tolerant data access";
    homepage = "https://xrootd.slac.stanford.edu";
    license = licenses.lgpl3Plus;
    platforms = platforms.all;
    maintainers = with maintainers; [ ShamrockLee ];
  };
})
+0 −24
Original line number Diff line number Diff line
{ runCommand, xrootd }:

# These tests are specified in the test procedure of the upstream CD:
# https://github.com/xrootd/xrootd/blob/master/.github/workflows/build.yml#L90-L98
runCommand "${xrootd.pname}-run-tests-${xrootd.version}" {
  testRunnerPath = "${xrootd}/bin/test-runner";
  testLibraries = [ "XrdClTests" ];
  XrdClTestsSuites = [ "UtilsTest" "SocketTest" "PollerTest" ];
  pname = "${xrootd.pname}-run-tests";
  inherit (xrootd) version;
  meta.mainProgram = "test-runner";
} ''
  for testLibrary in $testLibraries; do
    echo "Testing $testLibrary"
    testLibraryPath="${xrootd.out}/lib/lib''${testLibrary}.so"
    testsuiteVarname="''${testLibrary}Suites"
    for testsuite in ''${!testsuiteVarname}; do
      echo "Doing test $testsuite"
      "$testRunnerPath" "$testLibraryPath" "All Tests/$testsuite/"
    done
  done
  mkdir -p "$out/bin"
  ln -s "$testRunnerPath" "$out/bin/test-runner"
''
Loading