Skip to content

Commit

Permalink
Merge pull request spack#102 from greenc-FNAL/feature/xrootd
Browse files Browse the repository at this point in the history
Improvements to xrootd and dependencies
  • Loading branch information
marcmengel committed Apr 10, 2023
2 parents e646f75 + 9544ad5 commit 6ec252e
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 22 deletions.
69 changes: 69 additions & 0 deletions var/spack/repos/builtin/packages/jwt-cpp/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

# ----------------------------------------------------------------------------
# If you submit this package back to Spack as a pull request,
# please first remove this boilerplate and all FIXME comments.
#
# This is a template package file for Spack. We've put "FIXME"
# next to all the things you'll want to change. Once you've handled
# them, you can save this file and test your package like this:
#
# spack install jwt-cpp
#
# You can edit this file again by typing:
#
# spack edit jwt-cpp
#
# See the Spack documentation for more information on packaging.
# ----------------------------------------------------------------------------

from spack.package import *


class JwtCpp(CMakePackage):
"""A header only library for creating and validating JSON Web Tokens in C++11."""

homepage = "https://github.com/Thalhammer/jwt-cpp"
url = "https://github.com/Thalhammer/jwt-cpp/archive/refs/tags/v0.4.0.tar.gz"

maintainers("greenc-FNAL", "gartung", "marcmengel", "vitodb")

version("0.6.0", sha256="0227bd6e0356b211341075c7997c837f0b388c01379bd256aa525566a5553f03")
version("0.5.2", sha256="d3188f9611597eb1bb285169879e1d87202bf10a08e4e7734c9f2097bfd4a850")
version("0.5.1", sha256="d8f5ffb361824630b3b6f4aad26c730c915081071040c232ac57947d6177ef4f")
version("0.5.0", sha256="079a273f070dd11213e301712319a65881e51ab81535cc436d5313191df852a2")
version("0.4.0", sha256="f0dcc7b0e8bef8f9c3f434e7121f9941145042c9fe3055a5bdd709085a4f2be4")

# TODO: jwt-cpp>=0.6.0 supports wolfSSL for which there is currently
# no Spack recipe.
variant(
"ssl",
default="openssl",
values=("openssl", "libressl"),
multi=False,
when="@0.5.0:",
description="SSL library to use",
)

depends_on("openssl@1.0.2:", when="@0.4.0:0.4.99")
depends_on("openssl@1.0.2:", when="@0.5.0:0.5.99 ssl=openssl")
depends_on("openssl@1.0.1:", when="@0.6.0: ssl=openssl")
depends_on("libressl@3:", when="@0.5.0: ssl=libressl")


def cmake_args(self):
spec = self.spec
define = self.define
args = []
if spec.satisfies("@0.5.0:"):
ssl_library_dict = { "openssl": "OpenSSL", "libressl": "LibreSSL" }
args.append(define("JWT_SSL_LIBRARY",
ssl_library_dict[spec.variants["ssl"].value]))
args+=[define("JWT_BUILD_TESTS", False),
define("JWT_BUILD_EXAMPLES", False)]
else:
args.append(define("BUILD_TESTS", False))
return args
28 changes: 28 additions & 0 deletions var/spack/repos/builtin/packages/scitokens-cpp/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,41 @@ class ScitokensCpp(CMakePackage):
homepage = "https://github.com/scitokens/scitokens-cpp"
url = "https://github.com/scitokens/scitokens-cpp/archive/refs/tags/v0.7.0.tar.gz"

version("0.7.3", sha256="7d3c438596588cd74cf1af8255c55f44ca86a34293b81415ee24b33de64f886a")
version("0.7.2", sha256="594eee5f80463cd501e9b4c17b6ea6dcae47a42ef4947406ce8b157e15d50d5b")
version("0.7.1", sha256="44a1bca188897b1e97645149d1f6bc187cd0e482ad36159ca376834f028ce5ef")
version("0.7.0", sha256="72600cf32523b115ec7abf4ac33fa369e0a655b3d3b390e1f68363e6c4e961b6")

variant(
"cxxstd",
default="11",
values=("11", "14", "17", "20"),
multi=False,
description="Use the specified C++ standard when building",
)

depends_on("sqlite")
depends_on("curl")
depends_on("jwt-cpp", type="build")
depends_on("uuid", type="build")

conflicts("jwt-cpp@0.5:", when="@:0.7")

# https://github.com/scitokens/scitokens-cpp/issues/72
@when("^openssl@3:")
def patch(self):
filter_file(" -Werror", "", "CMakeLists.txt")

def cmake_args(self):
spec = self.spec
define = self.define
define_from_variant = self.define_from_variant
args = [
define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
define("CMAKE_CXX_STANDARD_REQUIRED", True)
]
return args

def setup_build_environment(self, env):
spec=self.spec
env.set("JWC_CPP_DIR", spec["jwt-cpp"].prefix)
17 changes: 17 additions & 0 deletions var/spack/repos/builtin/packages/xrootd/no-systemd-5.5.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/cmake/XRootDFindLibs.cmake 2021-07-29 12:22:48.000000000 +0000
+++ b/cmake/XRootDFindLibs.cmake 2021-10-25 18:26:07.308918231 +0000
@@ -30,10 +30,10 @@
add_definitions( -DHAVE_XML2 )
endif()

-find_package( systemd )
-if( SYSTEMD_FOUND )
- add_definitions( -DHAVE_SYSTEMD )
-endif()
+#find_package( systemd )
+#if( SYSTEMD_FOUND )
+# add_definitions( -DHAVE_SYSTEMD )
+#endif()

find_package( CURL )

17 changes: 17 additions & 0 deletions var/spack/repos/builtin/packages/xrootd/no-systemd-pre-5.5.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/cmake/XRootDFindLibs.cmake 2021-07-29 12:22:48.000000000 +0000
+++ b/cmake/XRootDFindLibs.cmake 2021-10-25 18:26:07.308918231 +0000
@@ -26,10 +26,10 @@
add_definitions( -DHAVE_XML2 )
endif()

-find_package( Systemd )
-if( SYSTEMD_FOUND )
- add_definitions( -DHAVE_SYSTEMD )
-endif()
+#find_package( Systemd )
+#if( SYSTEMD_FOUND )
+# add_definitions( -DHAVE_SYSTEMD )
+#endif()

find_package( CURL )

110 changes: 88 additions & 22 deletions var/spack/repos/builtin/packages/xrootd/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,74 @@ class Xrootd(CMakePackage):
version("4.4.0", sha256="f066e7488390c0bc50938d23f6582fb154466204209ca92681f0aa06340e77c8")
version("4.3.0", sha256="d34865772d975b5d58ad80bb05312bf49aaf124d5431e54dc8618c05a0870e3c")

variant("davix", default=True, description="Build with Davix")
variant("http", default=True, description="Build with HTTP support")

variant("krb5", default=False, description="Build with KRB5 support")
variant("python", default=False, description="Build pyxroot Python extension")

variant("readline", default=True, description="Use readline")

variant("krb5", default=False, description="Build with KRB5 support")
variant(
"cxxstd",
default="98",
values=("98", "11", "14", "17", "20"),
multi=False,
description="Use the specified C++ standard when building",
when="@:4.5.99",
)

variant(
"cxxstd",
default="11",
values=("98", "11", "14", "17"),
values=("98", "11", "14", "17", "20"),
multi=False,
description="Use the specified C++ standard when building",
when="@4.6.0:5.1.99",
)

variant(
"cxxstd",
default="14",
values=("98", "11", "14", "17", "20"),
multi=False,
description="Use the specified C++ standard when building.",
description="Use the specified C++ standard when building",
when="@5.2.0:"
)

variant(
"scitokens-cpp", default=False, when="@5.1.0:", description="Enable support for SciTokens"
)

variant("client_only", default=False, description="Build and install client only", when="@4.10.0:")

conflicts("cxxstd=98", when="@4.7.0:")
# C++ standard is not honored without
# https://github.com/xrootd/xrootd/pull/1929
# Related: C++>14 causes compilation errors with ~client_only. See
# also https://github.com/xrootd/xrootd/pull/1933.
conflicts("cxxstd=17", when="@5.0:5.5.2")
conflicts("cxxstd=20", when="@5.0:5.5.2")
conflicts("cxxstd=17", when="@5 ~client_only")
conflicts("cxxstd=20", when="@5 ~client_only")
conflicts("scitokens-cpp", when="@:5.5.2 +client_only")

depends_on("bzip2")
depends_on("cmake@2.6:", type="build")
depends_on("cmake@2.6:", type="build", when="@3.1.0:")
conflicts("cmake@:3.0", when="@5.0.0")
conflicts("cmake@:3.15.99", when="@5.5.4:")
depends_on("davix", when="+davix")
depends_on("libxml2", when="+http")
depends_on("uuid", when="@4.11.0:")
depends_on("openssl@:1")
depends_on("openssl")
depends_on("python", when="+python")
depends_on("py-setuptools", type="build", when="+python")
depends_on("readline", when="+readline")
depends_on("xz")
depends_on("zlib")
depends_on("curl")
depends_on("krb5", when="+krb5")
depends_on("json-c")
depends_on("scitokens-cpp", when="+scitokens-cpp")
conflicts("openssl@3:", when="@:5.3.99")

extends("python", when="+python")
patch("python-support.patch", level=1, when="@:4.8+python")
Expand All @@ -92,35 +125,68 @@ class Xrootd(CMakePackage):
sha256="2655e2d609d80bf9c9ab58557f4f6940408a1af9c686e7aa214ac0348c89c8fa",
when="@5.5.1",
)
# https://github.com/xrootd/xrootd/pull/1930
patch(
"https://patch-diff.githubusercontent.com/raw/xrootd/xrootd/pull/1930.patch?full_index=1",
sha256="969f8b07edff42449ad76b02f3e57d93b8d6c829be1ba14bccf831c27bc971e1",
when="@5.5.3",
)
# https://github.com/xrootd/xrootd/pull/1929
patch(
"https://patch-diff.githubusercontent.com/raw/xrootd/xrootd/pull/1929.patch?full_index=1",
sha256="0c7abb0fc0f0ae3c012be84d1aebd67fc00021aee37c2e0d8d315bd108b5dbec",
when="@5.0.0:5.5.3 +client_only",
)

def patch(self):
# Do not use systemd
filter_file(
r"(add_definitions\(\s*-DHAVE_SYSTEMD\s*\))", r"#\1", "cmake/XRootDFindLibs.cmake"
)
# do not use systemd
patch("no-systemd-pre-5.5.2.patch", when="@:5.5.1")
patch("no-systemd-5.5.2.patch", when="@5.5.2:")

# Remove hardcoded -std=c++0x flag
if self.spec.satisfies("@4.7.0:"):
filter_file(r"\-std=c\+\+0x", r"", "cmake/XRootDOSDefs.cmake")
@when("@4.7.0:5.1.99")
def patch(self):
"""Remove hardcoded -std=c++0x flag"""
filter_file(r"\-std=c\+\+0x", r"", "cmake/XRootDOSDefs.cmake")

def cmake_args(self):
spec = self.spec
options = [
"-DENABLE_HTTP:BOOL={0}".format("ON" if "+http" in spec else "OFF"),
"-DENABLE_PYTHON:BOOL={0}".format("ON" if "+python" in spec else "OFF"),
"-DENABLE_READLINE:BOOL={0}".format("ON" if "+readline" in spec else "OFF"),
"-DENABLE_KRB5:BOOL={0}".format("ON" if "+krb5" in spec else "OFF"),
"-DENABLE_CEPH:BOOL=OFF",
define = self.define
define_from_variant = self.define_from_variant
options = []
if (spec.satisfies("@5.2.0: +client_only") or
spec.satisfies("@6:")):
options+=[
define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
define("CMAKE_CXX_STANDARD_REQUIRED", True)
]

options += [
define_from_variant("ENABLE_HTTP", "http"),
define_from_variant("ENABLE_XRDCLHTTP", "davix"),
define_from_variant("ENABLE_PYTHON", "python"),
define_from_variant("ENABLE_READLINE", "readline"),
define_from_variant("ENABLE_KRB5", "krb5"),
define_from_variant("ENABLE_SCITOKENS", "scitokens-cpp"),
define_from_variant("XRDCL_ONLY", "client_only"),
define("ENABLE_CEPH", False),
define("ENABLE_CRYPTO", True),
define("ENABLE_FUSE", False),
define("ENABLE_MACAROONS", False),
define("ENABLE_VOMS", False),
define("FORCE_ENABLED", True),
]
# see https://github.com/spack/spack/pull/11581
if "+python" in self.spec:
options.append("-DPYTHON_EXECUTABLE=%s" % spec["python"].command.path)
options.extend([
define("PYTHON_EXECUTABLE", spec["python"].command.path),
define("XRD_PYTHON_REQ_VERSION", spec["python"].version.up_to(2)),
])

if "+scitokens-cpp" in self.spec:
options.append("-DSCITOKENS_CPP_DIR=%s" % spec["scitokens-cpp"].prefix)

return options

@when("@:5.1.99")
def setup_build_environment(self, env):
cxxstdflag = ""
if self.spec.variants["cxxstd"].value == "98":
Expand Down

0 comments on commit 6ec252e

Please sign in to comment.