From 5813a02d6fe19814cbd7cece46a59fa6d5b9204c Mon Sep 17 00:00:00 2001
From: Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
Date: Wed, 12 Apr 2017 16:42:50 +0200
Subject: [PATCH 1/2] Taking Marcin's implementation as a starting point,
 updated the AtlasLCG code to allow the user to override the release number
 requested by a project by setting the LCG_NIGHTLY environment variable. So
 that LCG nightlies wouldn't need a separate branch in the repository. And so
 that we could set a different day of the week for the nightlies from the
 build script itself.

---
 Build/AtlasLCG/LCGConfig-version.cmake | 39 ++++++++++++++++++--------
 Build/AtlasLCG/LCGConfig.cmake         |  4 +--
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/Build/AtlasLCG/LCGConfig-version.cmake b/Build/AtlasLCG/LCGConfig-version.cmake
index 9795667a..873dd461 100644
--- a/Build/AtlasLCG/LCGConfig-version.cmake
+++ b/Build/AtlasLCG/LCGConfig-version.cmake
@@ -11,15 +11,19 @@
 #
 
 # Set the LCG root directory:
-if( NOT LCG_RELEASE_BASE )
-   if( NOT "$ENV{LCG_RELEASE_BASE}" STREQUAL "" )
-      set( LCG_RELEASE_BASE $ENV{LCG_RELEASE_BASE} CACHE
-         PATH "Directory holding LCG releases" )
-   else()
-      set( LCG_RELEASE_BASE "/afs/cern.ch/sw/lcg/releases" CACHE
-         PATH "Directory holding LCG releases" )
-   endif()
+if( NOT "$ENV{LCG_NIGHTLY}" STREQUAL "" )
+   set( LCG_RELEASE_BASE "/cvmfs/sft.cern.ch/lcg/nightlies" CACHE
+      PATH "Directory holding LCG nightlies" )
+   set( LCG_NIGHTLY "$ENV{LCG_NIGHTLY}" CACHE STRING
+      "The LCG nightly to use for the build" )
+elseif( NOT "$ENV{LCG_RELEASE_BASE}" STREQUAL "" )
+   set( LCG_RELEASE_BASE $ENV{LCG_RELEASE_BASE} CACHE
+      PATH "Directory holding LCG releases" )
+else()
+   set( LCG_RELEASE_BASE "/cvmfs/sft.cern.ch/lcg/releases" CACHE
+      PATH "Directory holding LCG releases" )
 endif()
+
 # Variable used by Gaudi:
 set( LCG_releases_base ${LCG_RELEASE_BASE}
    CACHE PATH "Directory holding LCG releases" FORCE )
@@ -30,6 +34,7 @@ if( PACKAGE_FIND_VERSION EQUAL 0 )
    message( STATUS "Using the LCG modules without setting up a release" )
    set( PACKAGE_VERSION 0 )
    set( PACKAGE_VERSION_NUMBER 0 )
+   set( PACKAGE_VERSION_STRING "" )
    set( PACKAGE_VERSION_COMPATIBLE TRUE )
    set( PACKAGE_VERSION_EXACT FALSE )
 elseif( NOT PACKAGE_FIND_VERSION )
@@ -37,6 +42,7 @@ elseif( NOT PACKAGE_FIND_VERSION )
    message( STATUS "No LCG version requested. Not setting up release." )
    set( PACKAGE_VERSION 0 )
    set( PACKAGE_VERSION_NUMBER 0 )
+   set( PACKAGE_VERSION_STRING "" )
    set( PACKAGE_VERSION_COMPATIBLE TRUE )
    set( PACKAGE_VERSION_EXACT FALSE )
 # If a directory with the requested version string exists, then we're
@@ -45,6 +51,14 @@ elseif( EXISTS
       ${LCG_RELEASE_BASE}/LCG_${PACKAGE_FIND_VERSION}${LCG_VERSION_POSTFIX} )
    set( PACKAGE_VERSION ${PACKAGE_FIND_VERSION}${LCG_VERSION_POSTFIX} )
    set( PACKAGE_VERSION_NUMBER ${PACKAGE_FIND_VERSION} )
+   set( PACKAGE_VERSION_STRING "LCG_${PACKAGE_VERSION}" )
+   set( PACKAGE_VERSION_COMPATIBLE TRUE )
+   set( PACKAGE_VERSION_EXACT TRUE )
+# If a nightly was requested:
+elseif( EXISTS ${LCG_RELEASE_BASE}/${LCG_NIGHTLY} )
+   set( PACKAGE_VERSION ${LCG_NIGHTLY} )
+   set( PACKAGE_VERSION_NUMBER ${PACKAGE_FIND_VERSION} )
+   set( PACKAGE_VERSION_STRING "${PACKAGE_VERSION}" )
    set( PACKAGE_VERSION_COMPATIBLE TRUE )
    set( PACKAGE_VERSION_EXACT TRUE )
 else()
@@ -52,12 +66,13 @@ else()
    # newer than the one requested.
    message( WARNING "Can't find the requested LCG version. "
       "Falling back to LCG_84." )
-   set( PACKAGE_VERSION "84" )
+   set( PACKAGE_VERSION 84 )
    set( PACKAGE_VERSION_NUMBER ${PACKAGE_VERSION} )
-   if( "${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+   set( PACKAGE_VERSION_STRING "LCG_${PACKAGE_VERSION}" )
+   if( "${PACKAGE_VERSION_NUMBER}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
       set( PACKAGE_VERSION_COMPATIBLE FALSE )
    else()
-      # Apparently the latest release will work...
+      # Apparently this release will work...
       set( PACKAGE_VERSION_COMPATIBLE TRUE )
       set( PACKAGE_VERSION_EXACT FALSE )
    endif()
@@ -70,6 +85,8 @@ set( LCG_VERSION_NUMBER ${PACKAGE_VERSION_NUMBER}
    CACHE STRING "LCG version (just the number) used" FORCE )
 set( LCG_VERSION_POSTFIX ${LCG_VERSION_POSTFIX}
    CACHE STRING "LCG version postfix used" FORCE )
+set( LCG_VERSION_STRING ${PACKAGE_VERSION_STRING}
+   CACHE STRING "LCG directory name to use" FORCE )
 
 # Mark all these cache variables as advanced options:
 mark_as_advanced( LCG_releases_base LCG_VERSION LCG_VERSION_NUMBER
diff --git a/Build/AtlasLCG/LCGConfig.cmake b/Build/AtlasLCG/LCGConfig.cmake
index 70eb11f3..2272cac4 100644
--- a/Build/AtlasLCG/LCGConfig.cmake
+++ b/Build/AtlasLCG/LCGConfig.cmake
@@ -367,7 +367,7 @@ if( NOT LCG_VERSION EQUAL 0 )
    # Tell the user what's happening:
    if( NOT LCG_FIND_QUIETLY )
       message( STATUS
-         "Setting up LCG release \"${LCG_VERSION}\" for platform: "
+         "Setting up LCG release \"${LCG_VERSION_STRING}\" for platform: "
          "${LCG_PLATFORM}" )
    endif()
 
@@ -378,7 +378,7 @@ if( NOT LCG_VERSION EQUAL 0 )
    endif()
 
    # Construct the path to pick up the release from:
-   set( LCG_RELEASE_DIR ${LCG_RELEASE_BASE}/LCG_${LCG_VERSION}
+   set( LCG_RELEASE_DIR ${LCG_RELEASE_BASE}/${LCG_VERSION_STRING}
       CACHE PATH "Directory holding the LCG release" )
 
    # Start out with the assumption that LCG is now found:
-- 
GitLab


From ccae3663f73d9b418a351009ef04467e7a30a64a Mon Sep 17 00:00:00 2001
From: Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
Date: Wed, 12 Apr 2017 16:59:43 +0200
Subject: [PATCH 2/2] The environment setup now remembers which LCG nightly was
 used for the build, in case a nightly was used. This should also allow for a
 convenient release setup from CVMFS.

---
 Build/AtlasLCG/modules/LCGFunctions.cmake | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Build/AtlasLCG/modules/LCGFunctions.cmake b/Build/AtlasLCG/modules/LCGFunctions.cmake
index ca8ee0f9..d83d025c 100644
--- a/Build/AtlasLCG/modules/LCGFunctions.cmake
+++ b/Build/AtlasLCG/modules/LCGFunctions.cmake
@@ -491,6 +491,13 @@ function( lcg_generate_env )
             "   export LCG_PLATFORM=${LCG_PLATFORM}\n"
             "fi\n" )
       endif()
+      # Set the LCG_NIGHTLY variable if necessary:
+      if( LCG_NIGHTLY )
+         file( APPEND ${ARG_SH_FILE}.in
+            "if [ -z \"\${LCG_NIGHTLY}\" ]; then\n"
+            "   export LCG_NIGHTLY=${LCG_NIGHTLY}\n"
+            "fi\n" )
+      endif()
 
       # List of configured environment variables:
       set( _envVarNamesAndValues )
@@ -643,6 +650,13 @@ function( lcg_generate_env )
             "   setenv LCG_PLATFORM ${LCG_PLATFORM}\n"
             "endif\n" )
       endif()
+      # Set LCG_NIGHTLY if necessary:
+      if( LCG_NIGHTLY )
+         file( APPEND ${ARG_CSH_FILE}.in
+            "if (! \$?LCG_NIGHTLY ) then\n"
+            "   setenv LCG_NIGHTLY ${LCG_NIGHTLY}\n"
+            "endif\n" )
+      endif()
 
       # List of configured environment variables:
       set( _envVarNamesAndValues )
@@ -796,6 +810,12 @@ function( lcg_generate_env )
             "   <env:default variable=\"LCG_PLATFORM\">"
             "${LCG_PLATFORM}</env:default>\n" )
       endif()
+      # Set LCG_NIGHTLY if necessary:
+      if( LCG_NIGHTLY )
+         file( APPEND ${ARG_XENV_FILE}.in
+            "   <env:default variable=\"LCG_NIGHTLY\">"
+            "${LCG_NIGHTLY}</env:default>\n" )
+      endif()
 
       # Set the general environment variables:
       set( _envCopy ${_environments} )
-- 
GitLab