From b5b711c6dd4e32fb02ce4a5a63a2901c6c3cfee4 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sylvester.joosten@gmail.com>
Date: Thu, 1 Jul 2021 21:18:56 +0000
Subject: [PATCH] Update spack, dd4hep & podio

---
 .gitlab-ci.yml                              |   6 +-
 containers/jug/dev.Dockerfile               |  12 +-
 containers/jug/xl.Dockerfile                |   1 -
 spack.yaml                                  |   6 +-
 spack/README.md                             |   4 +-
 spack/packages/acts/package.py              |   3 +
 spack/packages/dd4hep/cmake_language.patch  |  12 ++
 spack/packages/dd4hep/package.py            | 132 ++++++++++++++++++++
 spack/packages/dd4hep/tbb-workarounds.patch |  41 ++++++
 spack/packages/dd4hep/tbb2.patch            |  14 +++
 spack/packages/podio/cmake.patch            |  15 +++
 spack/packages/podio/cpack.patch            |  11 ++
 spack/packages/podio/dictloading.patch      |  20 +++
 spack/packages/podio/package.py             |  92 ++++++++++++++
 14 files changed, 358 insertions(+), 11 deletions(-)
 create mode 100644 spack/packages/dd4hep/cmake_language.patch
 create mode 100644 spack/packages/dd4hep/package.py
 create mode 100644 spack/packages/dd4hep/tbb-workarounds.patch
 create mode 100644 spack/packages/dd4hep/tbb2.patch
 create mode 100644 spack/packages/podio/cmake.patch
 create mode 100644 spack/packages/podio/cpack.patch
 create mode 100644 spack/packages/podio/dictloading.patch
 create mode 100644 spack/packages/podio/package.py

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6a06aca03..91b692478 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,14 +2,14 @@ image: eicweb.phy.anl.gov:4567/containers/image_recipes/ubuntu_dind:latest
 
 variables:
   ## Application versions used for the main release ## note: nightly builds will always use the master branch
-  JUGGLER_VERSION: "v1.6.0"
+  JUGGLER_VERSION: "v1.8.0"
   NPDET_VERSION: "v0.5.0"
-  EICD_VERSION: "v0.1.0"
+  EICD_VERSION: "v0.2.0"
   DETECTOR_VERSION: "v0.1.0"
   IP6_VERSION: "v0.2.0"
 
   ## Spack github version
-  SPACK_VERSION: "63915de99b6d4bc7c8b8a22dc45e5c3dd7ee4f26"
+  SPACK_VERSION: "175e6e8c1e9644c6a92db8b338b36dcc0bf88af0"
 
   ## We need to enable Docker Buildkit to use cache mounts and better
   ## build performance overal
diff --git a/containers/jug/dev.Dockerfile b/containers/jug/dev.Dockerfile
index 8c5237e5d..bd2a58e57 100644
--- a/containers/jug/dev.Dockerfile
+++ b/containers/jug/dev.Dockerfile
@@ -89,9 +89,10 @@ ARG CACHE_BUST="hash"
 RUN --mount=type=cache,target=/var/cache/spack-mirror                   \
     cd /opt/spack-environment                                           \
  && ls /var/cache/spack-mirror                                          \
+ && rm -r /usr/local                                                    \
  && spack env activate .                                                \
  && spack install -j64 --no-check-signature                             \
- && spack clean -a
+ && spack clean -a                                                  
 
 ## Update the local build cache if needed. Consists of 3 steps:
 ## 1. Remove the B010 network buildcache (silicon)
@@ -173,7 +174,7 @@ RUN cd /opt/spack-environment && spack env activate . && spack gc -y
 RUN find -L /usr/local/*                                                \
          -type d -name site-packages -prune -false -o                   \
          -type f -not -name "zdll.lib"                                  \
-         -exec readlink -f '{}' \;                                      \
+         -exec realpath '{}' \;                                      \
       | xargs file -i                                                   \
       | grep 'charset=binary'                                           \
       | grep 'x-executable\|x-archive\|x-sharedlib'                     \
@@ -216,7 +217,12 @@ LABEL maintainer="Sylvester Joosten <sjoosten@anl.gov>" \
 RUN --mount=from=staging,target=/staging                                \
     rm -rf /usr/local                                                   \
  && cp -r /staging/opt/software /opt/software                           \
- && cp -r /staging/usr/local /usr/local                                 \
+ && cp -r /staging/usr/._local /usr/._local                             \
+ && cd /usr/._local                                                     \
+ && PREFIX_PATH=$(realpath $(ls | tail -n1))                            \
+ && echo "Found spack true prefix path to be $PREFIX_PATH"              \
+ && cd -                                                                \
+ && ln -s ${PREFIX_PATH} /usr/local                                     \
  && cp /staging/etc/profile.d/*.sh /etc/profile.d/                      \
  && cp /staging/etc/eic-env.sh /etc/eic-env.sh                          \
  && cp /staging/etc/jug_info /etc/jug_info                              \
diff --git a/containers/jug/xl.Dockerfile b/containers/jug/xl.Dockerfile
index f8f47b173..a46369fff 100644
--- a/containers/jug/xl.Dockerfile
+++ b/containers/jug/xl.Dockerfile
@@ -86,7 +86,6 @@ RUN cd /tmp
  && echo "export LD_LIBRARY_PATH=/opt/detector/lib:\$LD_LIBRARY_PATH"           \
          > /opt/detector/setup.sh
 
-
 ## Install benchmarks into the container
 
 ARG BENCHMARK_DET_VERSION="master"
diff --git a/spack.yaml b/spack.yaml
index e197f4ce5..84db57b02 100644
--- a/spack.yaml
+++ b/spack.yaml
@@ -22,10 +22,10 @@ spack:
     - hepmc3@3.2.2 +python +rootio 
     - stow@2.3.1
     - cairo@1.16.0 +fc+ft+X+pdf+gobject
-    - podio@0.13
+    - podio@0.13.1
     - geant4@10.7.1 cxxstd=17 +opengl +vecgeom +x11 +qt +threads ^qt +opengl
-    - dd4hep@1.16.1 +geant4 +assimp +hepmc3 +ipo
-    - acts@8.02.0p1 +dd4hep +digitization +identification +json +tgeo +ipo
+    - dd4hep@1.17 +geant4 +assimp +hepmc3 +ipo
+    - acts@8.03.0p1 +dd4hep +digitization +identification +json +tgeo +ipo
     - genfit@2.00.00
     - gaudi@34.0
     - dawn@3_91a
diff --git a/spack/README.md b/spack/README.md
index aef60c8fd..40b709143 100644
--- a/spack/README.md
+++ b/spack/README.md
@@ -16,10 +16,12 @@ Then use spack as you normally would.
     - `dawn`: A tool to visualize detector geometries.
     - `dawncut`: A tool to edit detector visualizations.
   * Package overrides
-    * `acts`: Add version 8.0 and 8.1
+    * `acts`: Patch bug for simple disk geometries
+    * `dd4hep`: Fix package hash which somehow is wrong in spack...
     * `fmt`: Modified compiler flags to build shared library version.
     * `madx`: Add madx package
     * `mesa`: fix issue in meson step
+    * `podio`: add v0.13.1, also patch issue in cmake setup to allow build under /tmp/root, as needed by spack
     * `qt`: Added gcc10.patch to fix issues compiling QT with gcc10
     * `root`: Re-enabled http module as this builds fine on modern Linux systems and we use this heavily.
 
diff --git a/spack/packages/acts/package.py b/spack/packages/acts/package.py
index eb788a546..a8bbf5c7f 100644
--- a/spack/packages/acts/package.py
+++ b/spack/packages/acts/package.py
@@ -37,6 +37,8 @@ class Acts(CMakePackage, CudaPackage):
 
     # Supported Acts versions
     version('master', branch='master')
+    version('8.03.0p1', commit='601c0a18b6738cae81c3e23422cfeb3ec7bddce9')
+    version('8.03.0', commit='601c0a18b6738cae81c3e23422cfeb3ec7bddce9')
     version('8.02.0p1', commit='f25cf639915fc2ac65b03882ad3eb11fb037ed00')
     version('8.02.0', commit='f25cf639915fc2ac65b03882ad3eb11fb037ed00')
     version('8.01.0', commit='ccc8c77bbc011f3adc020c565a509815be0ea029')
@@ -124,6 +126,7 @@ class Acts(CMakePackage, CudaPackage):
     ## Temporary patch for ACTS to address
     ## https://github.com/acts-project/acts/issues/822
     patch('acts-822.patch', when='@8.02.0p1')
+    patch('acts-822.patch', when='@8.03.0p1')
 
     # Build dependencies
     # FIXME: Use spack's autodiff package once there is one
diff --git a/spack/packages/dd4hep/cmake_language.patch b/spack/packages/dd4hep/cmake_language.patch
new file mode 100644
index 000000000..096f4d805
--- /dev/null
+++ b/spack/packages/dd4hep/cmake_language.patch
@@ -0,0 +1,12 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9d800190..121fa7fe 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -46,6 +46,7 @@ ENDIF()
+ #############################################################
+ 
+ ENABLE_LANGUAGE(CXX)
++ENABLE_LANGUAGE(C)
+ 
+ # Set C++ standard
+ set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard used for compiling")
diff --git a/spack/packages/dd4hep/package.py b/spack/packages/dd4hep/package.py
new file mode 100644
index 000000000..2748bba80
--- /dev/null
+++ b/spack/packages/dd4hep/package.py
@@ -0,0 +1,132 @@
+# Copyright 2013-2021 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)
+
+from spack import *
+
+
+class Dd4hep(CMakePackage):
+    """DD4hep is a software framework for providing a complete solution for
+       full detector description (geometry, materials, visualization, readout,
+       alignment, calibration, etc.) for the full experiment life cycle
+       (detector concept development, detector optimization, construction,
+       operation). It offers a consistent description through a single source
+       of detector information for simulation, reconstruction, analysis, etc.
+       It distributed under the LGPLv3 License."""
+
+    homepage = "https://dd4hep.web.cern.ch/dd4hep/"
+    url      = "https://github.com/AIDASoft/DD4hep/archive/v01-12-01.tar.gz"
+    git      = "https://github.com/AIDASoft/DD4hep.git"
+
+    maintainers = ['vvolkl', 'drbenmorgan']
+
+    tags = ['hep']
+
+    version('master', branch='master')
+    version('1.17', sha256='036a9908aaf1e13eaf5f2f43b6f5f4a8bdda8183ddc5befa77a4448dbb485826')
+    version('1.16.1', sha256='c8b1312aa88283986f89cc008d317b3476027fd146fdb586f9f1fbbb47763f1a')
+    version('1.16', sha256='ea9755cd255cf1b058e0e3cd743101ca9ca5ff79f4c60be89f9ba72b1ae5ec69')
+    version('1.15', sha256='992a24bd4b3dfaffecec9d1c09e8cde2c7f89d38756879a47b23208242f4e352')
+    version('1.14.1', sha256='5b5742f1e23c2b36d3174cca95f810ce909c0eb66f3d6d7acb0ba657819e6717')
+    version('1.14', sha256='b603aa3c0db8dda392253aa71fa4a0f0c3c9715d47df0b895d45c1e8849f4895')
+    version('1.13.1', sha256='83fa70cd74ce93b2f52f098388dff58d179f05ace5b50aea3f408bb8abf7cb73')
+    version('1.13', sha256='0b1f9d902ebe21a9178c1e41204c066b29f68c8836fd1d03a9ce979811ddb295')
+    version('1.12.1', sha256='85e8c775ec03c499ce10911e228342e757c81ce9ef2a9195cb253b85175a2e93')
+    version('1.12', sha256='133a1fb8ce0466d2482f3ebb03e60b3bebb9b2d3e33d14ba15c8fbb91706b398')
+    version('1.11.2', sha256='96a53dd26cb8df11c6dae54669fbc9cc3c90dd47c67e07b24be9a1341c95abc4')
+    version('1.11.1', sha256='d7902dd7f6744bbda92f6e303ad5a3410eec4a0d2195cdc86f6c1167e72893f0')
+    version('1.11', sha256='25643296f15f9d11ad4ad550b7c3b92e8974fc56f1ee8e4455501010789ae7b6')
+    version('1.10', sha256='1d6b5d1c368dc8bcedd9c61b7c7e1a44bad427f8bd34932516aff47c88a31d95')
+
+    generator = 'Ninja'
+
+    # Workarounds for various TBB issues in DD4hep v1.11
+    # See https://github.com/AIDASoft/DD4hep/pull/613 .
+    patch('tbb-workarounds.patch', when='@1.11')
+    patch('tbb2.patch', when='@1.12.1')
+    # Workaround for failing build file generation in some cases
+    # See https://github.com/spack/spack/issues/24232
+    patch('cmake_language.patch', when='@:1.17')
+
+    variant('xercesc', default=False, description="Enable 'Detector Builders' based on XercesC")
+    variant('geant4', default=False, description="Enable the simulation part based on Geant4")
+    variant('assimp', default=False, description="Enable CAD interface based on Assimp")
+    variant('hepmc3', default=False, description="Enable build with hepmc3")
+    variant('lcio', default=False, description="Enable build with lcio")
+    variant('edm4hep', default=True, description="Enable build with edm4hep")
+    variant('geant4units', default=False, description="Use geant4 units throughout")
+    variant('debug', default=False,
+            description="Enable debug build flag - adds extra info in"
+            " some places in addtion to the debug build type")
+
+    depends_on('cmake @3.12:', type='build')
+    depends_on('ninja', type='build')
+    depends_on('boost @1.49:')
+    depends_on('root @6.08: +gdml +math +opengl +python +x')
+    extends('python')
+    depends_on('xerces-c', when='+xercesc')
+    depends_on('geant4@10.2.2:', when='+geant4')
+    depends_on('assimp@5.0.2:', when='+assimp')
+    depends_on('hepmc3', when="+hepmc3")
+    depends_on('lcio', when="+lcio")
+    depends_on('edm4hep', when="+edm4hep")
+
+    # See https://github.com/AIDASoft/DD4hep/pull/771
+    conflicts('^cmake@3.16:3.17.0', when='@1.15',
+              msg='cmake version with buggy FindPython breaks dd4hep cmake config')
+
+    def cmake_args(self):
+        spec = self.spec
+        cxxstd = spec['root'].variants['cxxstd'].value
+        # root can be built with cxxstd=11, but dd4hep requires 14
+        if cxxstd == "11":
+            cxxstd = "14"
+        args = [
+            self.define_from_variant('DD4HEP_USE_EDM4HEP', 'edm4hep'),
+            self.define_from_variant('DD4HEP_USE_XERCESC', 'xercesc'),
+            self.define_from_variant('DD4HEP_USE_GEANT4', 'geant4'),
+            self.define_from_variant('DD4HEP_USE_LCIO', 'lcio'),
+            self.define_from_variant('DD4HEP_USE_HEPMC3', 'hepmc3'),
+            self.define_from_variant('DD4HEP_USE_GEANT4_UNITS', 'geant4units'),
+            self.define_from_variant('DD4HEP_BUILD_DEBUG', 'debug'),
+            # Downloads assimp from github and builds it on the fly.
+            # However, with spack it is preferrable to have a proper external
+            # dependency, so we disable it.
+            self.define('DD4HEP_LOAD_ASSIMP', False),
+            "-DCMAKE_CXX_STANDARD={0}".format(cxxstd),
+            "-DBUILD_TESTING={0}".format(self.run_tests),
+            "-DBOOST_ROOT={0}".format(spec['boost'].prefix),
+            "-DBoost_NO_BOOST_CMAKE=ON",
+            "-DPYTHON_EXECUTABLE={0}".format(spec['python'].command.path),
+        ]
+        return args
+
+    def setup_run_environment(self, env):
+        # used p.ex. in ddsim to find DDDetectors dir
+        env.set("DD4hepINSTALL", self.prefix)
+        env.set("DD4HEP", self.prefix.examples)
+        env.set("DD4hep_DIR", self.prefix)
+        env.set("DD4hep_ROOT", self.prefix)
+
+    def url_for_version(self, version):
+        # dd4hep releases are dashes and padded with a leading zero
+        # the patch version is omitted when 0
+        # so for example v01-12-01, v01-12 ...
+        base_url = self.url.rsplit('/', 1)[0]
+        if len(version) == 1:
+            major = version[0]
+            minor, patch = 0, 0
+        elif len(version) == 2:
+            major, minor = version
+            patch = 0
+        else:
+            major, minor, patch = version
+        # By now the data is normalized enough to handle it easily depending
+        # on the value of the patch version
+        if patch == 0:
+            version_str = 'v%02d-%02d.tar.gz' % (major, minor)
+        else:
+            version_str = 'v%02d-%02d-%02d.tar.gz' % (major, minor, patch)
+
+        return base_url + '/' + version_str
diff --git a/spack/packages/dd4hep/tbb-workarounds.patch b/spack/packages/dd4hep/tbb-workarounds.patch
new file mode 100644
index 000000000..659232977
--- /dev/null
+++ b/spack/packages/dd4hep/tbb-workarounds.patch
@@ -0,0 +1,41 @@
+diff --git a/DDDigi/CMakeLists.txt b/DDDigi/CMakeLists.txt
+index e6fb1096..88eb5c92 100644
+--- a/DDDigi/CMakeLists.txt
++++ b/DDDigi/CMakeLists.txt
+@@ -34,12 +34,10 @@ target_include_directories(DDDigi
+ 
+ FIND_PACKAGE(TBB QUIET)
+ if(TBB_FOUND)
+-  dd4hep_print( "|++> TBB_INCLUDE_DIR -->  ${TBB_INCLUDE_DIR}")
+-  dd4hep_print( "|++> TBB_LIBRARY     -->  ${TBB_LIBRARY}")
++  dd4hep_print( "|++> TBB_IMPORTED_TARGETS -->  ${TBB_IMPORTED_TARGETS}")
+   dd4hep_print( "|++> TBB found. DDDigi will run multi threaded.")
+   target_compile_definitions(DDDigi PUBLIC DD4HEP_USE_TBB)
+-  target_link_libraries(DDDigi ${TBB_LIBRARY})
+-  target_include_directories(DDDigi ${TBB_INCLUDE_DIRS})
++  target_link_libraries(DDDigi PUBLIC ${TBB_IMPORTED_TARGETS})
+ else()
+   dd4hep_print( "|++> TBB not found. DDDigi will only work single threaded.")
+ endif()
+diff --git a/DDDigi/src/DigiKernel.cpp b/DDDigi/src/DigiKernel.cpp
+index d62c6694..f2c2e86c 100644
+--- a/DDDigi/src/DigiKernel.cpp
++++ b/DDDigi/src/DigiKernel.cpp
+@@ -91,7 +91,7 @@ public:
+   DigiEventAction*  action = 0;
+   Wrapper(DigiContext& c, DigiEventAction* a)
+     : context(c), action(a) {}
+-  Wrapper(Wrapper&& copy) = delete;
++  Wrapper(Wrapper&& copy) = default;
+   Wrapper(const Wrapper& copy) = default;
+   Wrapper& operator=(Wrapper&& copy) = delete;
+   Wrapper& operator=(const Wrapper& copy) = delete;
+@@ -111,7 +111,7 @@ class DigiKernel::Processor {
+   DigiKernel& kernel;
+ public: 
+   Processor(DigiKernel& k) : kernel(k) {}
+-  Processor(Processor&& l) = delete;
++  Processor(Processor&& l) = default;
+   Processor(const Processor& l) = default;
+   void operator()()  const {
+     int todo = 1;
diff --git a/spack/packages/dd4hep/tbb2.patch b/spack/packages/dd4hep/tbb2.patch
new file mode 100644
index 000000000..932458001
--- /dev/null
+++ b/spack/packages/dd4hep/tbb2.patch
@@ -0,0 +1,14 @@
+diff --git a/DDDigi/src/DigiKernel.cpp b/DDDigi/src/DigiKernel.cpp
+index f2c2e86c..f168ef9b 100644
+--- a/DDDigi/src/DigiKernel.cpp
++++ b/DDDigi/src/DigiKernel.cpp
+@@ -273,7 +273,7 @@ void DigiKernel::submit(const DigiAction::Actors<DigiEventAction>& actions, Digi
+   if ( parallel )   {
+     tbb::task_group que;
+     for ( auto* i : actions )
+-      que.run(Wrapper(context, *i));
++      que.run(Wrapper(context, i));
+     que.wait();
+     goto print_stamp;
+   }
+
diff --git a/spack/packages/podio/cmake.patch b/spack/packages/podio/cmake.patch
new file mode 100644
index 000000000..46f2ab248
--- /dev/null
+++ b/spack/packages/podio/cmake.patch
@@ -0,0 +1,15 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 07a21a2..cf0d819 100755
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -13,8 +13,8 @@ endif()
+ 
+ # Remove SIO and ROOT related things from the core library
+ LIST(FILTER sources EXCLUDE REGEX SIO.*)
+-LIST(FILTER sources EXCLUDE REGEX ROOT.*|PythonEventStore.*|root.* )
+-LIST(FILTER root_sources INCLUDE REGEX ROOT.*|PythonEventStore.*|root.* )
++LIST(FILTER sources EXCLUDE REGEX ROOT.*|PythonEventStore.*|root[a-z|A-z|0-9].* )
++LIST(FILTER root_sources INCLUDE REGEX ROOT.*|PythonEventStore.*|root[a-z|A-z|0-9].* )
+ 
+ # Main Library, no external dependencies
+ add_library(podio SHARED ${sources})
diff --git a/spack/packages/podio/cpack.patch b/spack/packages/podio/cpack.patch
new file mode 100644
index 000000000..e685f9bc1
--- /dev/null
+++ b/spack/packages/podio/cpack.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -86,7 +86,7 @@ include(cmake/podioMacros.cmake)
+ include(CTest)
+ 
+ #--- enable CPack --------------------------------------------------------------
+-include(cmake/podioCPack.cmake)
++#include(cmake/podioCPack.cmake)
+ 
+ #--- target for Doxygen documentation ------------------------------------------
+ if(CREATE_DOC)
diff --git a/spack/packages/podio/dictloading.patch b/spack/packages/podio/dictloading.patch
new file mode 100644
index 000000000..15ec301b1
--- /dev/null
+++ b/spack/packages/podio/dictloading.patch
@@ -0,0 +1,20 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 120a899..05991f1 100755
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -41,7 +41,7 @@ SET(headers
+   ${CMAKE_SOURCE_DIR}/include/podio/PythonEventStore.h
+   )
+ PODIO_GENERATE_DICTIONARY(podioDict ${headers} SELECTION selection.xml
+-  OPTIONS --library ${CMAKE_SHARED_LIBRARY_PREFIX}podio${CMAKE_SHARED_LIBRARY_SUFFIX}
++  OPTIONS --library ${CMAKE_SHARED_LIBRARY_PREFIX}podioDict${CMAKE_SHARED_LIBRARY_SUFFIX}
+   )
+ # prevent generating dictionary twice
+ set_target_properties(podioDict-dictgen PROPERTIES EXCLUDE_FROM_ALL TRUE)
+@@ -58,5 +58,5 @@ install(TARGETS podio podioDict podioRootIO
+ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/podio DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+ install(FILES
+   ${CMAKE_CURRENT_BINARY_DIR}/podioDictDict.rootmap
+-  ${CMAKE_CURRENT_BINARY_DIR}/libpodio_rdict.pcm
++  ${CMAKE_CURRENT_BINARY_DIR}/libpodioDict_rdict.pcm
+   DESTINATION "${CMAKE_INSTALL_LIBDIR}")
diff --git a/spack/packages/podio/package.py b/spack/packages/podio/package.py
new file mode 100644
index 000000000..c35f2a711
--- /dev/null
+++ b/spack/packages/podio/package.py
@@ -0,0 +1,92 @@
+# Copyright 2013-2021 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)
+
+
+class Podio(CMakePackage):
+    """PODIO, or plain-old-data I/O, is a C++ library to support the creation
+    and handling of data models in particle physics."""
+
+    homepage = "https://github.com/AIDASoft/podio"
+    url      = "https://github.com/AIDASoft/podio/archive/v00-09-02.tar.gz"
+    git      = "https://github.com/AIDASoft/podio.git"
+
+    maintainers = ['vvolkl', 'drbenmorgan']
+
+    tags = ["hep", "key4hep"]
+
+    version('master', branch='master')
+    version('0.13.1', sha256='2ae561c2a0e46c44245aa2098772374ad246c9fcb1956875c95c69c963501353')
+    version('0.13', sha256='e9cbd4e25730003d3706ad82e28b15cb5bdc524a78b0a26e90b89ea852101498')
+    version('0.12', sha256='1729a2ce21e8b307fc37dfb9a9f5ae031e9f4be4992385cf99dba3e5fdf5323a')
+    version('0.11', sha256='4b2765566a14f0ddece2c894634e0a8e4f42f3e44392addb9110d856f6267fb6')
+    version('0.10', sha256='b5b42770ec8b96bcd2748abc05669dd3e4d4cc84f81ed57d57d2eda1ade90ef2')
+    version('0.9.2', sha256='8234d1b9636029124235ef81199a1220968dcc7fdaeab81cdc96a47af332d240')
+    version('0.9', sha256='3cde67556b6b76fd2d004adfaa3b3b6173a110c0c209792bfdb5f9353e21076f')
+    version('0.8', sha256='9d035a7f5ebfae5279a17405003206853271af692f762e2bac8e73825f2af327')
+
+    variant('build_type', default='Release',
+            description='The build type to build',
+            values=('Debug', 'Release'))
+
+    variant('sio', default=False,
+            description='Build the SIO I/O backend')
+
+    # cpack config throws an error on some systems
+    patch('cpack.patch', when="@:0.10.0")
+    patch('dictloading.patch', when="@0.10.0")
+
+    # issue with build braking for spack as the search-and-replace for "root" 
+    # erroneously selects the all files as the build happens under /tmp/root
+    patch('cmake.patch', when="@0.13.1")
+
+    depends_on('root@6.08.06: cxxstd=17')
+
+    depends_on('cmake@3.8:', type='build')
+    depends_on('python', type=('build', 'run'))
+    depends_on('py-pyyaml', type=('build', 'run'))
+    depends_on('py-jinja2@2.10.1:', type=('build', 'run'), when='@0.12.0:')
+    depends_on('sio', type=('build', 'link'), when='+sio')
+
+    conflicts('+sio', when='@:0.12', msg='sio support requires at least podio@0.13')
+
+    def cmake_args(self):
+        args = [
+            self.define_from_variant('ENABLE_SIO', 'sio')
+        ]
+        return args
+
+    def setup_run_environment(self, env):
+        env.prepend_path('PYTHONPATH', self.prefix.python)
+
+    def url_for_version(self, version):
+        """Translate version numbers to ilcsoft conventions.
+        in spack, the convention is: 0.1 (or 0.1.0) 0.1.1, 0.2, 0.2.1 ...
+        in ilcsoft, releases are dashed and padded with a leading zero
+        the patch version is omitted when 0
+        so for example v01-12-01, v01-12 ...
+        :param self: spack package class that has a url
+        :type self: class: `spack.PackageBase`
+        :param version: version
+        :type param: str
+        """
+        base_url = self.url.rsplit('/', 1)[0]
+
+        if len(version) == 1:
+            major = version[0]
+            minor, patch = 0, 0
+        elif len(version) == 2:
+            major, minor = version
+            patch = 0
+        else:
+            major, minor, patch = version
+
+        # By now the data is normalized enough to handle it easily depending
+        # on the value of the patch version
+        if patch == 0:
+            version_str = 'v%02d-%02d.tar.gz' % (major, minor)
+        else:
+            version_str = 'v%02d-%02d-%02d.tar.gz' % (major, minor, patch)
+
+        return base_url + '/' + version_str
-- 
GitLab