From d431fb1a9390c9b7fdc570f727619bae86e0077e Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sylvester.joosten@gmail.com>
Date: Sun, 10 Jan 2021 18:48:48 -0600
Subject: [PATCH] Fixed issue with corrupt build-cache that led to an
 incomplete build

Addresses #14

Other changes:
- updated the root version
- use specific Podio release version
- fixed issue where release build would always trigger the no-cache version
---
 .gitlab-ci.yml                                |   2 +-
 README.md                                     |   4 +-
 .../build_and_deploy.yml.in                   |   0
 containers/builder/Dockerfile                 |   5 +
 containers/builder/spack.yaml                 |   4 +-
 containers/builder/update_buildcache.sh       |  65 ++++++
 gitlab-ci/configure.sh                        |  12 +-
 spack/packages/acts/package.py                | 214 ------------------
 spack/packages/podio/cpack.patch              |  11 +
 spack/packages/podio/dictloading.patch        |  20 ++
 spack/packages/podio/package.py               |  87 +++++++
 spack/packages/root/package.py                |  16 +-
 12 files changed, 213 insertions(+), 227 deletions(-)
 rename {gitlab-ci => containers}/build_and_deploy.yml.in (100%)
 create mode 100755 containers/builder/update_buildcache.sh
 delete mode 100644 spack/packages/acts/package.py
 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 586d567f2..e9997ad5e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -37,7 +37,7 @@ detect_changes:release:
 init:
   stage: config
   script:
-    - ./gitlab-ci/configure.sh gitlab-ci/build_and_deploy.yml.in
+    - ./gitlab-ci/configure.sh containers/build_and_deploy.yml.in
   artifacts:
     paths:
       - build_and_deploy.yml
diff --git a/README.md b/README.md
index 17b1a11a1..d1bd3132c 100644
--- a/README.md
+++ b/README.md
@@ -111,11 +111,11 @@ Included software:
     - eigen@3.3.8
     - python@3.7.8 with pip, numpy, pyyaml, pyafp,  matplotlib, ipython, scipy
     - xrootd@4.12.3
-    - root@6.22.00
+    - root@6.22.06
     - pythia8@8303
     - hepmc3@3.2.2 +python +rootio
     - stow@2.3.1
-    - podio@master
+    - podio@0.13
     - geant4@10.6.2
     - dd4hep@1.14.1
     - acts@1.00.0
diff --git a/gitlab-ci/build_and_deploy.yml.in b/containers/build_and_deploy.yml.in
similarity index 100%
rename from gitlab-ci/build_and_deploy.yml.in
rename to containers/build_and_deploy.yml.in
diff --git a/containers/builder/Dockerfile b/containers/builder/Dockerfile
index 343109069..3dec480d8 100644
--- a/containers/builder/Dockerfile
+++ b/containers/builder/Dockerfile
@@ -17,6 +17,7 @@ ENV DOCKERFILE_BASE=debian            \
     CURRENTLY_BUILDING_DOCKER_IMAGE=1 \
     container=docker
 
+
 ## install ghostview/ghostscript needed by some of the tools
 RUN apt-get -yqq update \
  && apt-get -yqq install --no-install-recommends \
@@ -27,6 +28,10 @@ RUN apt-get -yqq update \
 ## Setup our environment definition
 COPY spack.yaml /opt/spack-environment/spack.yaml
 
+## Utility script to update the build cache
+## TODO: move this upstream to debian_spack
+COPY update_buildcache.sh /usr/sbin/update_buildcache
+
 ## Ensure an up-to-date custom package list
 ## TODO: We should just remove this from the upstream container
 ##       and only initialize the custom packages here for more
diff --git a/containers/builder/spack.yaml b/containers/builder/spack.yaml
index 20b006106..50dd5e81d 100644
--- a/containers/builder/spack.yaml
+++ b/containers/builder/spack.yaml
@@ -12,7 +12,7 @@ spack:
     - py-numpy
     - py-pyyaml
     - xrootd@4.12.3 cxxstd=17 +python
-    - root@6.22.00 cxxstd=17 
+    - root@6.22.06 cxxstd=17 
           +fftw +fortran +gdml +http +mlp +pythia8 
           +root7 +tmva +vc +xrootd +ssl ^mesa+opengl 
           -llvm -osmesa
@@ -20,7 +20,7 @@ spack:
     - hepmc3@3.2.2 +python +rootio 
     - stow@2.3.1
     - cairo+fc+ft+X+pdf+gobject
-    - podio@master
+    - podio@0.13
     - geant4@10.6.2 cxxstd=17 +opengl +vecgeom +x11 +qt ^qt +opengl
     - dd4hep@1.14.1 +geant4 +assimp +hepmc3 +ipo
     - acts@1.02.0 +dd4hep +digitization +identification +json +tgeo +ipo
diff --git a/containers/builder/update_buildcache.sh b/containers/builder/update_buildcache.sh
new file mode 100755
index 000000000..a82d9c7a9
--- /dev/null
+++ b/containers/builder/update_buildcache.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+## Update the spack buildcache with the contents of this image
+## Note: this needs to be run manually from the CI machine with
+##       all relevant directories mounted into the image.
+
+## info of spack installation on CI machine
+GLOBAL_SPACK_ROOT=/lab/opt/spack
+LOCAL_SPACK_ROOT=/opt/spack
+SPACK_MIRROR=$GLOBAL_SPACK_ROOT/var/mirror
+
+## two use cases:
+## 1. arguments supplied --> update the packages in the arguments
+## 2. no arguments supplied --> update all packages
+
+function print_the_help() {
+  echo "USAGE: $0 [-h] [packages ...]"
+  echo ""
+  echo "        Update the spack buildcache with contents of this image."
+  echo "        If no packages are supplied on the command line, create"
+  echo "        cache for *all* packages in this image"
+  exit
+}
+
+
+positional=("$@")
+while [ $# -gt 0 ]; do
+  key="$1"
+  case $key in
+    *-h|--help) 
+      print_the_help
+      exit 0
+      shift
+      ;;
+    *)    # unknown option, do nothing
+      shift
+      ;;
+  esac
+done
+set -- "${positional[@]}"
+
+## setup GPG to sign packages
+rm -rf $LOCAL_SPACK_ROOT/opt/spack/gpg
+cp -r $GLOBAL_SPACK_ROOT/opt/spack/gpg $LOCAL_SPACK_ROOT/opt/spack/gpg
+
+## case 1: no argument --> export all
+if [ $# -eq 0 ]; then
+  ## list all available packages
+  spack find > tmp.manifest.txt
+
+  ## trim off the first line, trim off the version info 
+  ## and replace newlines with spaces
+  tail -n +2 tmp.manifest.txt | sed "s/@.+//" | tr '\n' ' ' > tmp.packages.txt
+  rm tmp.manifest.txt
+## case 2: update requested packages only
+else
+  echo $@ > tmp.packages.txt
+fi
+
+## now generate the buildcache (this will take a while)
+cat tmp.packages.txt | xargs spack buildcache create -a -f -d $SPACK_MIRROR
+spack buildcache update-index -d /lab/opt/spack/var/mirror
+rm tmp.packages.txt
+
+## That's all!
diff --git a/gitlab-ci/configure.sh b/gitlab-ci/configure.sh
index fc8732dbc..9d99e8bf6 100755
--- a/gitlab-ci/configure.sh
+++ b/gitlab-ci/configure.sh
@@ -47,11 +47,17 @@ fi
 TARGET_BUILDER=$TARGET
 TARGET_RELEASE=$TARGET
 
-if [ ! -f .ci_env/buider-nc ]; then
+if [ ! -f .ci-env/builder-nc ]; then
+  echo "Can use cached build directive for builder"
   TARGET_BUILDER="${TARGET_BUILDER}-cached"
+else
+  echo "No-cache required for builder"
 fi
-if [ ! -f .ci_env/release-nc ]; then
-  TARGET_BUILDER="${TARGET_RELEASE}-cached"
+if [ ! -f .ci-env/release-nc ]; then
+  echo "Can use cached build directive for release"
+  TARGET_RELEASE="${TARGET_RELEASE}-cached"
+else
+  echo "No-cache required for release"
 fi
 
 sed "s/@TAG@/$TAG/g" $TEMPLATE_FILE | \
diff --git a/spack/packages/acts/package.py b/spack/packages/acts/package.py
deleted file mode 100644
index 05271a088..000000000
--- a/spack/packages/acts/package.py
+++ /dev/null
@@ -1,214 +0,0 @@
-# Copyright 2013-2020 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 Acts(CMakePackage, CudaPackage):
-    """
-    A Common Tracking Software (Acts)
-
-    This project contains an experiment-independent set of track reconstruction
-    tools. The main philosophy is to provide high-level track reconstruction
-    modules that can be used for any tracking detector. The description of the
-    tracking detector's geometry is optimized for efficient navigation and
-    quick extrapolation of tracks. Converters for several common geometry
-    description languages exist. Having a highly performant, yet largely
-    customizable implementation of track reconstruction algorithms was a
-    primary objective for the design of this toolset. Additionally, the
-    applicability to real-life HEP experiments plays major role in the
-    development process. Apart from algorithmic code, this project also
-    provides an event data model for the description of track parameters and
-    measurements.
-
-    Key features of this project include: tracking geometry description which
-    can be constructed from TGeo, DD4Hep, or GDML input, simple and efficient
-    event data model, performant and highly flexible algorithms for track
-    propagation and fitting, basic seed finding algorithms.
-    """
-
-    homepage = "http://acts.web.cern.ch/ACTS/"
-    git      = "https://github.com/acts-project/acts.git"
-    maintainers = ['HadrienG2']
-
-    tags = ['hep']
-
-    # Supported Acts versions
-    version('master', branch='master')
-    version('3.00.0', commit='e20260fccb469f4253519d3f0ddb3191b7046db3')
-    version('2.00.0', commit='8708eae2b2ccdf57ab7b451cfbba413daa1fc43c')
-    version('1.02.1', commit='f6ebeb9a28297ba8c54fd08b700057dd4ff2a311')
-    version('1.02.0', commit='e69b95acc9a264e63aded7d1714632066e090542')
-    version('1.01.0', commit='836fddd02c3eff33825833ff97d6abda5b5c20a0')
-    version('1.00.0', commit='ec9ce0bcdc837f568d42a12ddf3fc9c80db62f5d')
-    version('0.32.0', commit='a4cedab7e727e1327f2835db29d147cc86b21054')
-    version('0.31.0', commit='cfbd901555579a2f32f4efe2b76a7048442b42c3')
-    version('0.30.0', commit='a71ef0a9c742731611645214079884585a92b15e')
-    version('0.29.0', commit='33aa3e701728112e8908223c4a7fd521907c8ea4')
-    version('0.28.0', commit='55626b7401eeb93fc562e79bcf385f0ad0ac48bf')
-    version('0.27.1', commit='8ba3010a532137bc0ab6cf83a38b483cef646a01')
-    version('0.27.0', commit='f7b1a1c27d5a95d08bb67236ad0e117fcd1c679f')
-    version('0.26.0', commit='cf542b108b31fcc349fc18fb0466f889e4e42aa6')
-    version('0.25.2', commit='76bf1f3e4be51d4d27126b473a2caa8d8a72b320')
-    version('0.25.1', commit='6e8a1ea6d2c7385a78e3e190efb2a8a0c1fa957f')
-    version('0.25.0', commit='0aca171951a214299e8ff573682b1c5ecec63d42')
-    version('0.24.0', commit='ef4699c8500bfea59a5fe88bed67fde2f00f0adf')
-    version('0.23.0', commit='dc443dd7e663bc4d7fb3c1e3f1f75aaf57ffd4e4')
-    version('0.22.1', commit='ca1b8b1645db6b552f44c48d2ff34c8c29618f3a')
-    version('0.22.0', commit='2c8228f5843685fc0ae69a8b95dd8fc001139efb')
-    version('0.21.0', commit='10b719e68ddaca15b28ac25b3daddce8c0d3368d')
-    version('0.20.0', commit='1d37a849a9c318e8ca4fa541ef8433c1f004637b')
-    version('0.19.0', commit='408335636486c421c6222a64372250ef12544df6')
-    version('0.18.0', commit='d58a68cf75b52a5e0f563bc237f09250aa9da80c')
-    version('0.17.0', commit='0789f654ff484b013fd27e5023cf342785ea8d97')
-    version('0.16.0', commit='b3d965fe0b8ae335909d79114ef261c6b996773a')
-    version('0.15.0', commit='267c28f69c561e64369661a6235b03b5a610d6da')
-    version('0.14.0', commit='38d678fcb205b77d60326eae913fbb1b054acea1')
-    version('0.13.0', commit='b33f7270ddbbb33050b7ec60b4fa255dc2bfdc88')
-    version('0.12.1', commit='a8b3d36e7c6cb86487637589e0eff7bbe626054a')
-    version('0.12.0', commit='f9cda77299606d78c889fb1db2576c1971a271c4')
-    version('0.11.1', commit='c21196cd6c3ecc6da0f14d0a9ef227a274be584b')
-    version('0.11.0', commit='22bcea1f19adb0021ca61b843b95cfd2462dd31d')
-    version('0.10.5', commit='b6f7234ca8f18ee11e57709d019c14bf41cf9b19')
-    version('0.10.4', commit='42cbc359c209f5cf386e620b5a497192c024655e')
-    version('0.10.3', commit='a3bb86b79a65b3d2ceb962b60411fd0df4cf274c')
-    version('0.10.2', commit='64cbf28c862d8b0f95232b00c0e8c38949d5015d')
-    version('0.10.1', commit='0692dcf7824efbc504fb16f7aa00a50df395adbc')
-    version('0.10.0', commit='30ef843cb00427f9959b7de4d1b9843413a13f02')
-    version('0.09.5', commit='12b11fe8b0d428ccb8e92dda7dc809198f828672')
-    version('0.09.4', commit='e5dd9fbe179201e70347d1a3b9fa1899c226798f')
-    version('0.09.3', commit='a8f31303ee8720ed2946bfe2d59e81d0f70e307e')
-    version('0.09.2', commit='4e1f7fa73ffe07457080d787e206bf6466fe1680')
-    version('0.09.1', commit='69c451035516cb683b8f7bc0bab1a25893e9113d')
-    version('0.09.0', commit='004888b0a412f5bbaeef2ffaaeaf2aa182511494')
-    version('0.08.2', commit='c5d7568714e69e7344582b93b8d24e45d6b81bf9')
-    version('0.08.1', commit='289bdcc320f0b3ff1d792e29e462ec2d3ea15df6')
-    version('0.08.0', commit='99eedb38f305e3a1cd99d9b4473241b7cd641fa9')
-
-    # Variants that affect the core Acts library
-    variant('benchmarks', default=False, description='Build the performance benchmarks')
-    variant('examples', default=False, description='Build the examples')
-    variant('integration_tests', default=False, description='Build the integration tests')
-    variant('unit_tests', default=False, description='Build the unit tests')
-
-    # Variants that enable / disable Acts plugins
-    variant('autodiff', default=False, description='Build the auto-differentiation plugin')
-    variant('dd4hep', default=False, description='Build the DD4hep plugin')
-    variant('digitization', default=False, description='Build the geometric digitization plugin')
-    variant('fatras', default=False, description='Build the FAst TRAcking Simulation package')
-    variant('identification', default=False, description='Build the Identification plugin')
-    variant('json', default=False, description='Build the Json plugin')
-    variant('legacy', default=False, description='Build the Legacy package')
-    # FIXME: Cannot build SyCL plugin yet as Spack doesn't have SyCL support
-    variant('tgeo', default=False, description='Build the TGeo plugin')
-
-    # Variants that only affect Acts examples for now
-    variant('geant4', default=False, description='Build the Geant4-based examples')
-    variant('hepmc3', default=False, description='Build the HepMC3-based examples')
-    variant('pythia8', default=False, description='Build the Pythia8-based examples')
-
-    # Build dependencies
-    # FIXME: Use spack's autodiff package once there is one
-    depends_on('boost @1.62:1.69.99 +program_options +test', when='@:0.10.3')
-    depends_on('boost @1.69: +filesystem +program_options +test', when='@0.10.4:')
-    depends_on('cmake @3.11:', type='build')
-    depends_on('dd4hep @1.10:', when='+dd4hep')
-    depends_on('dd4hep @1.10: +geant4', when='+dd4hep +geant4')
-    depends_on('eigen @3.2.9:', type='build')
-    depends_on('geant4', when='+geant4')
-    depends_on('hepmc3@3.1:', when='+hepmc3')
-    depends_on('heppdt', when='+hepmc3')
-    depends_on('intel-tbb', when='+examples')
-    depends_on('nlohmann-json @3.2.0:', when='@0.14: +json')
-    depends_on('pythia8', when='+pythia8')
-    depends_on('root @6.10: cxxstd=14', when='+tgeo @:0.8.0')
-    depends_on('root @6.10: cxxstd=17', when='+tgeo @0.8.1:')
-
-    # Some variant combinations do not make sense
-    conflicts('+autodiff', when='@:1.01')
-    conflicts('+benchmarks', when='@:0.15')
-    conflicts('+dd4hep', when='-tgeo')
-    conflicts('+examples', when='@:0.22')
-    conflicts('+examples', when='-digitization')
-    conflicts('+examples', when='-fatras')
-    conflicts('+examples', when='-identification')
-    conflicts('+examples', when='-json')
-    conflicts('+examples', when='-tgeo')
-    conflicts('+fatras', when='@:0.15')
-    conflicts('+geant4', when='@:0.22')
-    conflicts('+geant4', when='-examples')
-    conflicts('+hepmc3', when='@:0.22')
-    conflicts('+hepmc3', when='-examples')
-    conflicts('+pythia8', when='@:0.22')
-    conflicts('+pythia8', when='-examples')
-    conflicts('+tgeo', when='-identification')
-    conflicts('%gcc@:7', when='@0.23:')
-
-    def cmake_args(self):
-        spec = self.spec
-
-        def cmake_variant(cmake_label, spack_variant):
-            enabled = spec.satisfies('+' + spack_variant)
-            return "-DACTS_BUILD_{0}={1}".format(cmake_label, enabled)
-
-        def example_cmake_variant(cmake_label, spack_variant):
-            enabled = spec.satisfies('+examples +' + spack_variant)
-            return "-DACTS_BUILD_EXAMPLES_{0}={1}".format(cmake_label, enabled)
-
-        def plugin_label(plugin_name):
-            if spec.satisfies('@0.33:'):
-                return "PLUGIN_" + plugin_name
-            else:
-                return plugin_name + "_PLUGIN"
-
-        def plugin_cmake_variant(plugin_name, spack_variant):
-            return cmake_variant(plugin_label(plugin_name), spack_variant)
-
-        integration_tests_label = "INTEGRATIONTESTS"
-        unit_tests_label = "UNITTESTS"
-        legacy_plugin_label = "LEGACY_PLUGIN"
-        if spec.satisfies('@:0.15'):
-            integration_tests_label = "INTEGRATION_TESTS"
-            unit_tests_label = "TESTS"
-        if spec.satisfies('@:0.32'):
-            legacy_plugin_label = "LEGACY"
-
-        args = [
-            plugin_cmake_variant("AUTODIFF", "autodiff"),
-            cmake_variant("BENCHMARKS", "benchmarks"),
-            plugin_cmake_variant("CUDA", "cuda"),
-            plugin_cmake_variant("DD4HEP", "dd4hep"),
-            plugin_cmake_variant("DIGITIZATION", "digitization"),
-            cmake_variant("EXAMPLES", "examples"),
-            example_cmake_variant("DD4HEP", "dd4hep"),
-            example_cmake_variant("GEANT4", "geant4"),
-            example_cmake_variant("HEPMC3", "hepmc3"),
-            example_cmake_variant("PYTHIA8", "pythia8"),
-            cmake_variant("FATRAS", "fatras"),
-            plugin_cmake_variant("IDENTIFICATION", "identification"),
-            cmake_variant(integration_tests_label, "integration_tests"),
-            plugin_cmake_variant("JSON", "json"),
-            cmake_variant(unit_tests_label, "unit_tests"),
-            cmake_variant(legacy_plugin_label, "legacy"),
-            plugin_cmake_variant("TGEO", "tgeo")
-        ]
-
-        cuda_arch = spec.variants['cuda_arch'].value
-        if cuda_arch != 'none':
-            args.append('-DCUDA_FLAGS=-arch=sm_{0}'.format(cuda_arch[0]))
-
-        if 'root' in spec:
-            cxxstd = spec['root'].variants['cxxstd'].value
-            args.append("-DCMAKE_CXX_STANDARD={0}".format(cxxstd))
-
-        # FIXME: Once we can use spack's autodiff package, set
-        #        ACTS_USE_SYSTEM_AUTODIFF too.
-        if spec.satisfies('@0.33: +json'):
-            args.append("-DACTS_USE_SYSTEM_NLOHMANN_JSON=ON")
-        elif spec.satisfies('@0.14.0: +json'):
-            args.append("-DACTS_USE_BUNDLED_NLOHMANN_JSON=OFF")
-
-        return args
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..360547a80
--- /dev/null
+++ b/spack/packages/podio/package.py
@@ -0,0 +1,87 @@
+# 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', 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")
+
+    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', 'run'), 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
diff --git a/spack/packages/root/package.py b/spack/packages/root/package.py
index 8f5e505c3..15a7e15cd 100644
--- a/spack/packages/root/package.py
+++ b/spack/packages/root/package.py
@@ -1,4 +1,4 @@
-# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# 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)
@@ -15,6 +15,8 @@ class Root(CMakePackage):
     homepage = "https://root.cern.ch"
     url      = "https://root.cern/download/root_v6.16.00.source.tar.gz"
 
+    tags = ['hep']
+
     maintainers = ['chissg', 'HadrienG2', 'drbenmorgan', 'vvolkl']
 
     # ###################### Versions ##########################
@@ -26,9 +28,10 @@ class Root(CMakePackage):
     # Development version (when more recent than production).
 
     # Production version
+    version('6.22.06', sha256='c4688784a7e946cd10b311040b6cf0b2f75125a7520e04d1af0b746505911b57')
+    version('6.22.02', sha256='89784afa9c9047e9da25afa72a724f32fa8aa646df267b7731e4527cc8a0c340')
     version('6.22.00', sha256='efd961211c0f9cd76cf4a486e4f89badbcf1d08e7535bba556862b3c1a80beed')
-    version('6.20.08', sha256='d02f224b4908c814a99648782b927c353d44db79dea2cadea86138c1afc23ae9',
-            preferred=True)
+    version('6.20.08', sha256='d02f224b4908c814a99648782b927c353d44db79dea2cadea86138c1afc23ae9')
     version('6.20.06', sha256='9a734758a91598d8a58a3d64d7d606aeb17bdf6fd8214e33f5c4d9947d391951')
     version('6.20.04', sha256='1f8c76ccdb550e64e6ddb092b4a7e9d0a10655ef80044828cba12d5e7c874472')
     version('6.20.02', sha256='0997586bf097c0afbc6f08edbffcebf5eb6a4237262216114ba3f5c8087dcba6')
@@ -136,12 +139,14 @@ class Root(CMakePackage):
             description='Enable R ROOT bindings')
     variant('rpath', default=True,
             description='Enable RPATH')
-    variant('rootfit', default=True,
+    variant('roofit', default=True,
             description='Build the libRooFit advanced fitting package')
     variant('root7', default=False,
             description='Enable ROOT 7 support')
     variant('shadow', default=False,
             description='Enable shadow password support')
+    variant('spectrum', default=False,
+            description='Enable support for TSpectrum')
     variant('sqlite', default=False,
             description='Enable SQLite support')
     variant('ssl', default=False,
@@ -390,11 +395,12 @@ class Root(CMakePackage):
             define_from_variant('qtgsi', 'qt4'),  # See conflicts
             define_from_variant('r'),
             define('rfio', False),
-            define('roofit', False),
+            define_from_variant('roofit'),
             define_from_variant('root7'),  # See conflicts
             define('ruby', False),
             define('sapdb', False),
             define_from_variant('shadowpw', 'shadow'),
+            define_from_variant('spectrum'),
             define_from_variant('sqlite'),
             define('srp', False),
             define_from_variant('ssl'),
-- 
GitLab