]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
CMake: Retrieve Git information
authoragrigora <alina.grigoras@cern.ch>
Wed, 25 Feb 2015 11:55:12 +0000 (12:55 +0100)
committeragrigora <alina.grigoras@cern.ch>
Tue, 3 Mar 2015 09:16:29 +0000 (10:16 +0100)
3 Git modes: BRANCH, TAG and DETACHED
ALIROOT_VERSION: Branch name, tag name, short hash for detached mode
ALIROOT_REVISION: short hash
ALIROOT_SERIAL: number of commits

20 files changed:
ALIROOT/aliroot.cxx
GRP/MakeCosmicTriggersEntry.C
GRP/UpdateCDBIdealGeom.C
GRP/UpdateCDBVertexDiamond.C
HLT/doc/doxygen.conf.in
HLT/global/AliHLTGlobalPreprocessor.cxx
MUON/macros/UpdateCDBCTPConfig.C
STEER/CDB/AliDCSGenDB.cxx
STEER/STEER/AliReconstruction.cxx
STEER/STEERBase/AliVersion.cxx
TPC/TPCbase/AliTPCPreprocessor.cxx
cmake/ARVersion.h.tmp
cmake/AliRoot-config.cmake.in
cmake/CheckGitVersion.cmake
cmake/da.spec.in
macros/DiffGeomBeforeTagging.C
macros/MakeAlignmentObjs.C
macros/MakeAllDETsFullMisAlignment.C
macros/MakeAllDETsResMisAlignment.C
macros/MakeAllDETsZeroMisAlignment.C

index f33931ac17a7550b734429f4c350539b821e333f..54b8032fe65ba3337fd7d2559433b0e425bbaa04 100644 (file)
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
     
     if (argument=="--version")
     {      
-      cout << "aliroot " << ALIROOT_REVISION << " " << ALIROOT_BRANCH << endl;
+      cout << "aliroot " << ALIROOT_REVISION << " " << ALIROOT_VERSION << endl;
       return 0;
     }    
   }
index 3917ae1a860e838b06b407361e263d784f607f63..0d2c26e1dbf5efc7eec3417602732df7e0ab87da 100644 (file)
@@ -69,7 +69,7 @@ Bool_t MakeCosmicTriggersEntry(const char *fileName, const char* cdbUri)
   md->SetComment("List of the defined cosmic triggers. It is used in order to steer the reconstruction, namely in the selection of the proper event specie. It is maintained and updated by the trigger coordinator.");
   // Get root and AliRoot versions and set them in the metadata
   const char* rootv = gROOT->GetVersion();
-  TString av(ALIROOT_BRANCH);
+  TString av(ALIROOT_VERSION);
   TString revnum(ALIROOT_REVISION);
   av+=" - revision: ";
   av+=revnum;
index 2a22b2d6ae7f48f57f2d89898cb37a86a51a56d2..813619f1874d5abba15aa905dd9e272cef6286e3 100644 (file)
@@ -37,7 +37,7 @@ void UpdateCDBIdealGeom(const char* cdbUri, const char* cfgFile){
 
        // Get root and AliRoot versions
        const char* rootv = gROOT->GetVersion();
-       TString av(ALIROOT_BRANCH);
+       TString av(ALIROOT_VERSION);
        TString revnum(ALIROOT_REVISION);
 
        Printf("root version: %s.  AliRoot %s, revision number %s",rootv,av.Data(),revnum);
index c34acd0ef7b930cbb761ff7a9f65d1c3e5c22cd3..d2a7cac3a389d589f922d117923dc5a67f3820c7 100644 (file)
@@ -40,7 +40,7 @@ void UpdateCDBVertexDiamond(const char* objName, Double_t xmed, Double_t ymed, D
 
   // Get root and AliRoot versions
   const char* rootv = gROOT->GetVersion();
-  TString av(ALIROOT_BRANCH);
+  TString av(ALIROOT_VERSION);
   TString revnum(ALIROOT_REVISION);
 
   metadata->SetResponsible("prino@to.infn.it");
@@ -82,7 +82,7 @@ void UpdateCDBVertexDiamondOld(Double_t xmed = 0., Double_t ymed = 0., Double_t
 
   // Get root and AliRoot versions
   const char* rootv = gROOT->GetVersion();
-  TString av(ALIROOT_BRANCH);
+  TString av(ALIROOT_VERSION);
   TString revnum(ALIROOT_REVISION);
 
   metadata->SetResponsible("prino@to.infn.it");
index d9e8f1fb823b11d70440c96aaa3acd0ee17665d4..89ad8d8f587d2dd081498ae4c70010627fe78186 100644 (file)
@@ -12,7 +12,7 @@
 
 DOXYFILE_ENCODING      = UTF-8
 PROJECT_NAME           = "ALICE HLT"
-PROJECT_NUMBER         = @ALIROOT_BRANCH@
+PROJECT_NUMBER         = @ALIROOT_VERSION@
 OUTPUT_DIRECTORY       = @HLT_doxy_output_root@
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
index 4d00a7f6bc618c4a6758be9028d11ef4b4d428a1..21d74e816a312582f4e4177413000f4ae5778c77 100644 (file)
@@ -166,7 +166,7 @@ Int_t AliHLTGlobalPreprocessor::ProcessStreamerInfo() {
                        metaData->SetBeamPeriod(0);
                        metaData->SetResponsible("ALICE HLT alice-hlt-core@cern.ch");
                        metaData->SetComment("Streamer info for HLTOUT payload");
-                       //metaData->SetAliRootVersion(ALIROOT_BRANCH);
+                       //metaData->SetAliRootVersion(ALIROOT_VERSION);
                } else {
                        return -ENOMEM;
                }
index 99db67c351a825a91546e4e05027dde3cda4956d..2d6231da2ea89d7f2130d0055cd86d71967a6960 100644 (file)
@@ -116,7 +116,7 @@ void UpdateCDBCTPConfig(Bool_t check = false) {
 
   // ROOT and AliRoot versions
   const char* rootv = gROOT->GetVersion();
-  TString av(ALIROOT_BRANCH);
+  TString av(ALIROOT_VERSION);
   TString revnum(ALIROOT_REVISION);
 
   Printf("root version: %s.  AliRoot %s, revision number %s",rootv,av.Data(),revnum.Data());
index c2478ae52847172e0360c6d563e8f52848235903..bccf29c4ab137779d6d1783edb619eb80451d9f1 100644 (file)
@@ -171,7 +171,7 @@ AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
   md1->SetObjectClassName(objectClassName);
   md1->SetResponsible("Haavard Helstrup");
   md1->SetBeamPeriod(kBeamPeriod);
-  md1->SetAliRootVersion(ALIROOT_BRANCH);
+  md1->SetAliRootVersion(ALIROOT_VERSION);
 
   return md1;
 }
index e5accdfd7d89170592d41836d641e09edf82c29e..8f930f454c78fdf1a3a831f31a07396ae0afcd69 100644 (file)
@@ -2634,7 +2634,7 @@ void AliReconstruction::SlaveTerminate()
 
    // Add the AliRoot version that created this file
    TString sVersion("aliroot ");
-   sVersion += ALIROOT_BRANCH;
+   sVersion += ALIROOT_VERSION;
    sVersion += ":";
    sVersion += ALIROOT_REVISION;
    sVersion += "; root ";
index 533958606483b20dd6c2c3bdae67f6d6ec6e79d7..5694fb268461ae30dc3894a95a75ac5576021135 100644 (file)
@@ -13,7 +13,7 @@ AliVersion* AliVersion::Instance()
 AliVersion::AliVersion()
   : TNamed("alirootVersion", "AliROOT Version"),
     fHash(ALIROOT_REVISION),
-    fTag(ALIROOT_BRANCH)
+    fTag(ALIROOT_VERSION)
 {   SetUniqueID(ALIROOT_SERIAL); }
 
 Int_t AliVersion::Compare(const TObject* o) const
index 40d1b9358463ef422e0314b828b9c9db50e7981d..52b48dbd3bafc0756ae50cf6c81007cfdd33f657 100644 (file)
@@ -520,7 +520,7 @@ UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
   AliCDBMetaData metaData;
   metaData.SetBeamPeriod(0);
   metaData.SetResponsible("Haavard Helstrup");
-  metaData.SetAliRootVersion(ALIROOT_BRANCH);
+  metaData.SetAliRootVersion(ALIROOT_VERSION);
   metaData.SetComment("Preprocessor AliTPC status.");
   Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0,  kFALSE);
   if (!storeOK) Log ("Unable to store preprocessor status entry");
@@ -560,7 +560,7 @@ UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
         AliCDBMetaData metaData;
        metaData.SetBeamPeriod(0);
        metaData.SetResponsible("Haavard Helstrup");
-       metaData.SetAliRootVersion(ALIROOT_BRANCH);
+       metaData.SetAliRootVersion(ALIROOT_VERSION);
        metaData.SetComment("Preprocessor AliTPC data base entries.");
 
        Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
@@ -638,7 +638,7 @@ UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
         AliCDBMetaData metaData;
        metaData.SetBeamPeriod(0);
        metaData.SetResponsible("Haavard Helstrup");
-       metaData.SetAliRootVersion(ALIROOT_BRANCH);
+       metaData.SetAliRootVersion(ALIROOT_VERSION);
        metaData.SetComment("Preprocessor AliTPC data base entries.");
 
        Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
@@ -674,7 +674,7 @@ UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
         AliCDBMetaData metaData;
        metaData.SetBeamPeriod(0);
        metaData.SetResponsible("Haavard Helstrup");
-        metaData.SetAliRootVersion(ALIROOT_BRANCH);
+        metaData.SetAliRootVersion(ALIROOT_VERSION);
        metaData.SetComment("Preprocessor AliTPC data base entries.");
 
        Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
@@ -711,7 +711,7 @@ UInt_t AliTPCPreprocessor::MapGasComposition(TMap* dcsAliasMap)
         AliCDBMetaData metaData;
        metaData.SetBeamPeriod(0);
        metaData.SetResponsible("Haavard Helstrup");
-       metaData.SetAliRootVersion(ALIROOT_BRANCH);
+       metaData.SetAliRootVersion(ALIROOT_VERSION);
        metaData.SetComment("Preprocessor AliTPC data base entries.");
 
        Bool_t storeOK = Store("Calib", "GasComposition", fGasComposition, &metaData, 0, kFALSE);
@@ -882,7 +882,7 @@ UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
      AliCDBMetaData metaData;
      metaData.SetBeamPeriod(0);
      metaData.SetResponsible("Haavard Helstrup");
-     metaData.SetAliRootVersion(ALIROOT_BRANCH);
+     metaData.SetAliRootVersion(ALIROOT_VERSION);
      metaData.SetComment("Preprocessor AliTPC data base entries."); 
  
      Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
@@ -1065,7 +1065,7 @@ if (pulserObjectsOCDB) {
      AliCDBMetaData metaData;
      metaData.SetBeamPeriod(0);
      metaData.SetResponsible("Haavard Helstrup");
-     metaData.SetAliRootVersion(ALIROOT_BRANCH);
+     metaData.SetAliRootVersion(ALIROOT_VERSION);
      metaData.SetComment("Preprocessor AliTPC data base entries.");
 
      Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
@@ -1131,7 +1131,7 @@ UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
      AliCDBMetaData metaData;
      metaData.SetBeamPeriod(0);
      metaData.SetResponsible("Haavard Helstrup");
-     metaData.SetAliRootVersion(ALIROOT_BRANCH);
+     metaData.SetAliRootVersion(ALIROOT_VERSION);
      metaData.SetComment("Preprocessor AliTPC data base entries.");
 
      Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
@@ -1324,7 +1324,7 @@ UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
     AliCDBMetaData metaData;
     metaData.SetBeamPeriod(0);
     metaData.SetResponsible("Haavard Helstrup");
-    metaData.SetAliRootVersion(ALIROOT_BRANCH);
+    metaData.SetAliRootVersion(ALIROOT_VERSION);
     metaData.SetComment("Preprocessor AliTPC data base entries.");
     
     if ( result == 0 ) {
@@ -1381,7 +1381,7 @@ UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
            AliCDBMetaData metaData;
            metaData.SetBeamPeriod(0);
            metaData.SetResponsible("Haavard Helstrup");
-          metaData.SetAliRootVersion(ALIROOT_BRANCH);
+          metaData.SetAliRootVersion(ALIROOT_VERSION);
            metaData.SetComment("Preprocessor AliTPC data base entries.");
 
            Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
@@ -1674,7 +1674,7 @@ UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS, TMap* dcsMap)
      AliCDBMetaData metaData;
      metaData.SetBeamPeriod(0);
      metaData.SetResponsible("Haavard Helstrup");
-     metaData.SetAliRootVersion(ALIROOT_BRANCH);
+     metaData.SetAliRootVersion(ALIROOT_VERSION);
      metaData.SetComment("Preprocessor AliTPC data base entries.");
 
      Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
index 0402e382c78b0a029dcc90bd90974eedbcfa363e..ddeec29deba79765e09fd5c349d0c8dc983e1407 100644 (file)
@@ -1,6 +1,12 @@
+/* 
+   ALIROOT_VERSION: branch or tag name, short hash in detached mode
+   ALIROOT_REVISION: 0 if branch, short revision tag and detached mode
+   ALIROOT_SERIAL: 0 if branch, number if commits for tag and detached mode
+   TODO: change this to Doxygen
+*/
 #ifndef ALIROOT_ARVersion
 #define ALIROOT_ARVersion
-#define ALIROOT_REVISION "@ALIROOT_REVISION@"
-#define ALIROOT_BRANCH "@ALIROOT_BRANCH@"
-#define ALIROOT_SERIAL @ALIROOT_SERIAL@
+#define ALIROOT_VERSION "@ALIROOT_AR_VERSION@"
+#define ALIROOT_REVISION "@ALIROOT_AR_REVISION@"
+#define ALIROOT_SERIAL @ALIROOT_AR_SERIAL@
 #endif
index 8c49e9aa2277f6181417f02db1c665654f5419fa..30241b353e1dd15fbcfeef48e6876eeebd20a45d 100644 (file)
@@ -7,13 +7,8 @@
 ############################################################################
 # Version
 set(AliRoot_VERSION @ALIROOT_VERSION@)
-set(AliRoot_BRANCH_TYPE @BRANCH_TYPE@)
-set(AliRoot_VERSION_MAJOR @ALIROOT_VERSION_MAJOR@)
-set(AliRoot_VERSION_MINOR @ALIROOT_VERSION_MINOR@)
-set(AliRoot_VERSION_PATCH @ALIROOT_VERSION_PATCH@)
-
-# Git revision
-set(AliRoot_REVISION @GIT_SHORT_SHA1@)
+set(AliRoot_BRANCH_TYPE @ALIROOT_GITREFTYPE@)
+set(AliRoot_REVISION @ALIROOT_REVISION@)
 
 # Information about architecture and compiler
 set(AliRoot_ARCH @CMAKE_SYSTEM@)
index b22ed986bc8e90c900ec48177e1a481550cfe565..0b68255e108e8059082ff8f4599629d42fde8d66 100644 (file)
-# **************************************************************************
-# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
-# *                                                                        *
-# * Author: The ALICE Off-line Project.                                    *
-# * Contributors are mentioned in the code where appropriate.              *
-# *                                                                        *
-# * Permission to use, copy, modify and distribute this software and its   *
-# * documentation strictly for non-commercial purposes is hereby granted   *
-# * without fee, provided that the above copyright notice appears in all   *
-# * copies and that both the copyright notice and this permission notice   *
-# * appear in the supporting documentation. The authors make no claims     *
-# * about the suitability of this software for any purpose. It is          *
-# * provided "as is" without express or implied warranty.                  *
-# **************************************************************************
-
-# Configure ARVerion.h using Git informatiion
-# Sets 4 git variables
-#  - GIT_REFSPEC - complete name of the current reference
-#  - ALIROOT_BRANCH - name of the branch or tag extracted from the current reference
-#  - GIT_SHA1 - current hash in the long format
-#  - GIT_SHORT_SHA1 - current hash in the short format
-#
-#  - ALIROOT_VERSION - name of the branch/tag
-#  - ALIROOT_VERSION_RPM - name of the branch/tag in rpm format, - replaced with .
+# 1. Extracts versioning information from the Git repository
+# 2. Enables rerun of cmake configuration on each pull: GetGitRevisionDescription
+#  - ALIROOT_VERSION - branch/tag name or short hash if detached at randon hash
 #  - ALIROOT_REVISION - short sha1
-if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
-    include(GetGitRevisionDescription)
-    
-    find_package(Git)
-    
-    if(GIT_FOUND)
-        message(STATUS "Git version = ${GIT_VERSION_STRING}")
-        
-        get_git_head_revision(GIT_REFSPEC GIT_SHA1)
-
-        # generate the short version of the revision hash
-        execute_process(COMMAND git rev-parse --short ${GIT_SHA1}
-                          WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
-                          OUTPUT_STRIP_TRAILING_WHITESPACE
-                          RESULT_VARIABLE res
-                          OUTPUT_VARIABLE GIT_SHORT_SHA1)
-
-        # if the rev-parse fails we set the short sha to the long initial one
-        if(NOT res EQUAL 0)
-            set(GIT_SHORT_SHA1 ${GIT_SHA1})
-        endif()
+#  - ALIROOT_SERIAL - number of commits
+#  - ALIROOT_VERSION_RPM - name of the branch/tag in rpm format, - replaced with .
+#  - ALIROOT_GITREFTYPE - BRANCH/TAG/DETACHED
 
-        # Older Git version < 1.7.3 do not have --count option for rev-list
-        # We use simple rev-list and we count the lines of the output
-        string(COMPARE GREATER "${GIT_VERSION_STRING}" "1.7.3" NEWGIT)
-        
-        if(NEWGIT)
-            # generate the short version of the revision hash using --count
-            execute_process(COMMAND git rev-list --count ${GIT_SHA1}
-                            WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
-                            OUTPUT_STRIP_TRAILING_WHITESPACE
-                            RESULT_VARIABLE revcount
-                            OUTPUT_VARIABLE ALIROOT_SERIAL_ORIGINAL)
-        else()
-            # generate the short version of the revision hash using -wc -l
-            execute_process(COMMAND git rev-list ${GIT_SHA1}
-                            COMMAND wc -l
-                            WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
-                            OUTPUT_STRIP_TRAILING_WHITESPACE
-                            RESULT_VARIABLE revcount
-                            OUTPUT_VARIABLE ALIROOT_SERIAL_ORIGINAL)
-        endif()
+# Setting default values
+set(ALIROOT_VERSION "")
+set(ALIROOT_REVISION "")
+set(ALIROOT_SERIAL 0)
+set(ALIROOT_GITREFTYPE "")
 
-        # GIT_REFSPEC is empty for detached mode = tags in detached mode or checkout to specific hash
-
-        # returns the closest reference to the current hash
-        # name of the current tag or heads/branch in the case of branches
-        # Older git version of Git report only the name of the tag
-        # Newer version report tags/vAN-20141215
-        # Just in case we replace tags/ with nothing
-        git_describe(ALIROOT_GIT_TAG "--all" "--abbrev=0")
-        
-        if(ALIROOT_GIT_TAG)
-            string(STRIP ${ALIROOT_GIT_TAG} ALIROOT_GIT_TAG)
-            string(REPLACE "tags/" ""  ALIROOT_GIT_TAG ${ALIROOT_GIT_TAG})
-        endif(ALIROOT_GIT_TAG)
-        
-        # using the closest tag for branches
-        git_describe(ALIROOT_CLOSEST_GIT_TAG "--abbrev=0")
-
-        if(ALIROOT_GIT_TAG)
-            string(STRIP ${ALIROOT_GIT_TAG} ALIROOT_GIT_TAG)
-            string(REPLACE "tags/" ""  ALIROOT_GIT_TAG ${ALIROOT_GIT_TAG})
-        endif(ALIROOT_GIT_TAG)
-        
-        STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
-        
-        # the revision is not set in the case of a branch, it means we are doing development
-        # and the revision will trigger a reconfiguration
-        if(BRANCH_TYPE STREQUAL "heads")
-            set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
-            set(ALIROOT_SERIAL 0)
-            set(ALIROOT_GIT_TAG ${ALIROOT_CLOSEST_GIT_TAG})
-            STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
-            message(STATUS "This is a working branch, ARVersion will not contain the revision and the serial number")
-        else()
-            set(BRANCH_TYPE "tags")
-            set(SHORT_BRANCH ${ALIROOT_GIT_TAG})
-            set(ALIROOT_REVISION ${GIT_SHORT_SHA1})
-            set(ALIROOT_SERIAL ${ALIROOT_SERIAL_ORIGINAL})
-        endif()
+# Checks if the sources where cloned as a full git repository
+if(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
+  # Git installation mandatory
+  find_package(Git REQUIRED)
+
+  # The simple include will not trigger the reconfiguration
+  # get_git_head_revision has to be called at least once
+  include(GetGitRevisionDescription)
+  # GIT_SHA1 - current long hash
+  # GIT_REFSPEC
+  #     1. branches: refs/heads/master
+  #     2. detached mode(tags or hashes) empty string
+  get_git_head_revision(GIT_REFSPEC GIT_SHA1)
+
+  if(CMAKEDEBUG)
+    message(STATUS "DEBUG: GIT_REFSPEC = \"${GIT_REFSPEC}\", GIT_SHA1 = \"${GIT_SHA1}\"")
+  endif(CMAKEDEBUG)
+
+  # Setting ALIROOT_REVISION as the long hash
+  set(ALIROOT_REVISION ${GIT_SHA1})
+
+  # Generate the short version of the revision hash
+  execute_process(COMMAND git rev-parse --short ${GIT_SHA1} 
+                  WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+                  OUTPUT_VARIABLE GIT_SHORT_SHA1
+                  RESULT_VARIABLE process_result
+                  ERROR_VARIABLE process_error
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  ERROR_STRIP_TRAILING_WHITESPACE
+                )
+  # Set ALIROOT_REVISION to short hash if no error
+  if(process_result EQUAL 0)
+    if(CMAKEDEBUG)
+      message(STATUS "DEBUG: Short SHA1 = \"${GIT_SHORT_SHA1}\"")
+    endif(CMAKEDEBUG)
+
+    set(ALIROOT_REVISION ${GIT_SHORT_SHA1})
+  else()
+    if(CMAKEDEBUG)
+      message(STATUS "DEBUG: result = \"${process_result}\",  parse-rev error : ${ERROR_VARIABLE}")
+    endif()
+
+    message(WARNING "Could not retrieve the short hash, using the long version : \"${ALIROOT_REVISION}\"")
+  endif()
 
-        set(ALIROOT_BRANCH ${SHORT_BRANCH})
-        set(ALIROOT_VERSION ${SHORT_BRANCH})
-        
-        # extract major minor and patch from AliRoot tag
-        string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ALIROOT_VERSION_MAJOR "${ALIROOT_GIT_TAG}")
-        string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ALIROOT_VERSION_MINOR "${ALIROOT_GIT_TAG}")
-        string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ALIROOT_VERSION_PATCH "${ALIROOT_GIT_TAG}")
-        message(STATUS "Found ALIROOT version ${ALIROOT_VERSION_MAJOR}.${ALIROOT_VERSION_MINOR}.${ALIROOT_VERSION_PATCH}")
-        
-        # Replace - with . for rpm creation
-        string(REPLACE "-" "." ALIROOT_VERSION_RPM ${ALIROOT_VERSION})
+  # Generate ALIROOT_VERSION
+  # 1. Branch -> Branch name
+  # 2. Detached mode
+  #    2.1 Tags -> Tag name
+  #    2.2 Detached hash -> Short hash
+  
+  # Check if dettached mode
+  # rev-parse will return:
+  # 1. Branch -> Branch name, ex: master
+  # 2. Detached mode: "HEAD" for both tags and random hashes
+  execute_process(COMMAND git rev-parse --abbrev-ref HEAD
+                  WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+                  OUTPUT_VARIABLE ref_output
+                  RESULT_VARIABLE ref_result
+                  ERROR_VARIABLE ref_error
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  ERROR_STRIP_TRAILING_WHITESPACE
+                )
 
-        message(STATUS "Aliroot branch/tag: \"${ALIROOT_VERSION}\" - Revision:  \"${GIT_SHORT_SHA1}\" - Serial: \"${ALIROOT_SERIAL_ORIGINAL}\"")
+  if(ref_result EQUAL 0)
+    if(CMAKEDEBUG)
+      message(STATUS "DEBUG: rev-parse HEAD result = \"${ref_output}\"")
+    endif()
 
+    # detached mode
+    if(ref_output STREQUAL "HEAD")
+      # Checking if this is a tag in detached mode
+      #  1. If tag the OUTPUT_VARIABLE will contain the tag name
+      #  2. If random hash the RESULT_VARIABLE is 128 and ERROR_VARIABLE contains the error message
+      execute_process(COMMAND git describe --exact-match
+                      WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+                      OUTPUT_VARIABLE tag_output
+                      RESULT_VARIABLE tag_result
+                      ERROR_VARIABLE tag_error
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                      ERROR_STRIP_TRAILING_WHITESPACE
+                    )
+
+      if(tag_result EQUAL 0)
+      
+        if(CMAKEDEBUG)
+          message(STATUS "DEBUG: git describe tag_result = ${tag_output}")
+        endif()
+
+        set(ALIROOT_VERSION ${tag_output})
+        set(ALIROOT_GITREFTYPE "TAG")
+      else()
+        # Detached at a random hash, the version is the short SHA1
+        if(CMAKEDEBUG)
+          message(STATUS "DEBUG: git describe tar_error = ${tag_error}")
+        endif()  
+
+        set(ALIROOT_VERSION ${ALIROOT_REVISION})
+        set(ALIROOT_GITREFTYPE "DETACHED")
+      endif()
     else()
-        message(STATUS "Git not installed. I can't tell you which revision you are using!")
-    endif(GIT_FOUND)
-else()
-    message("AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
-endif(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
+      # Branch
+      set(ALIROOT_VERSION ${ref_output})
+      set(ALIROOT_GITREFTYPE "BRANCH")
+    endif()
+  else(ref_result EQUAL 0)
+    message(FATAL_ERROR "Could not retreive information about the current git hash: ${ref_error}")
+  endif(ref_result EQUAL 0)
+  
+  # Generating the ALIROOT_SERIAL using git rev-list
+  # Older Git version < 1.7.3 do not have --count option for rev-list
+  # We use simple rev-list and count the lines of the output 
+  
+  # extract major minor and patch from Git version
+  string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" GIT_VERSION_MAJOR "${GIT_VERSION_STRING}")
+  string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" GIT_VERSION_MINOR "${GIT_VERSION_STRING}")
+  string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" GIT_VERSION_PATCH "${GIT_VERSION_STRING}")
+
+  if(${GIT_VERSION_MAJOR} EQUAL 1 AND ${GIT_VERSION_MINOR} LESS 3)
+    if(CMAKEDEBUG)
+      message(STATUS "DEBUG: cmake version less that 1.7.3!")
+    endif()
+    
+    execute_process(COMMAND git rev-list ${GIT_SHA1}
+                    COMMAND wc -l
+                    WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+                    RESULT_VARIABLE serial_result
+                    ERROR_VARIABLE serial_error
+                    OUTPUT_VARIABLE serial_output
+                    OUTPUT_STRIP_TRAILING_WHITESPACE
+                    ERROR_STRIP_TRAILING_WHITESPACE
+                  )
+  else()
+    execute_process(COMMAND git rev-list --count ${GIT_SHA1}
+                    WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+                    RESULT_VARIABLE serial_result
+                    ERROR_VARIABLE serial_error
+                    OUTPUT_VARIABLE serial_output
+                    OUTPUT_STRIP_TRAILING_WHITESPACE
+                    ERROR_STRIP_TRAILING_WHITESPACE
+      )
 
+  endif()
+
+  if(serial_result EQUAL 0)
+    if(CMAKEDEBUG)
+      message(STATUS "DEBUG: AliRoot serial: ${serial_output}")
+    endif()
+    
+    set(ALIROOT_SERIAL ${serial_output})
+  else()
+    message(FATAL_ERROR "Could not retrieve serial number: ${serial_error}")
+  endif()
+
+  if(${ALIROOT_GITREFTYPE} STREQUAL "DETACHED")
+    message(STATUS "Found AliRoot in detached mode, hash \"${ALIROOT_REVISION}\", serial \"${ALIROOT_SERIAL}\"")
+  elseif(${ALIROOT_GITREFTYPE} STREQUAL "BRANCH")
+    message(STATUS "Found AliRoot branch \"${ALIROOT_VERSION}\", hash \"${ALIROOT_REVISION}\", serial \"${ALIROOT_SERIAL}\"")
+  elseif(${ALIROOT_GITREFTYPE} STREQUAL "TAG")
+    message(STATUS "Found AliRoot tag \"${ALIROOT_VERSION}\", hash \"${ALIROOT_REVISION}\", serial \"${ALIROOT_SERIAL}\"")
+  else()
+    # it does not get here
+    message(FATAL_ERROR "Git type error")
+  endif()
+else(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
+    message(WARNING "AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
+endif(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
+
+# ALIROOT_VERSION_RPM
+# Replacing -/ with . , normally it should not contain / 
+# - and / are forbidden characters in rpm creation
+string(REPLACE "-" "." ALIROOT_VERSION_RPM ${ALIROOT_VERSION})
+string(REPLACE "/" "." ALIROOT_VERSION_RPM ${ALIROOT_VERSION_RPM})
+if(CMAKEDEBUG)
+  message(STATUS "DEBUG: ALIROOT_VERSION_RPM = ${ALIROOT_VERSION_RPM}")
+endif()
+
+# Generating ARVersion.h from ARVersion.h.tmp
+set(ALIROOT_AR_VERSION ${ALIROOT_VERSION})
+if(${ALIROOT_GITREFTYPE} STREQUAL "BRANCH")
+  set(ALIROOT_AR_REVISION "")
+  set(ALIROOT_AR_SERIAL 0)
+else()
+  set(ALIROOT_AR_REVISION ${ALIROOT_REVISION})
+  set(ALIROOT_AR_SERIAL ${ALIROOT_SERIAL})
+endif()
 configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_BINARY_DIR}/version/ARVersion.h @ONLY)
-install(FILES ${PROJECT_BINARY_DIR}/version/ARVersion.h DESTINATION include)
\ No newline at end of file
+install(FILES ${PROJECT_BINARY_DIR}/version/ARVersion.h DESTINATION include)
index 270e4d372fc2a5d1d18c52f66f8b0e9087350280..adab0409edc37d71202af3cf6e88cfa32959a5d9 100644 (file)
@@ -2,7 +2,7 @@
 Summary: @DETECTOR@ Detector Algorithm
 Name: @DA_NAME@
 Version: @ALIROOT_VERSION_RPM@
-Release: @GIT_SHORT_SHA1@
+Release: @ALIROOT_REVISION@
 License: CERN Alice DAQ/Offine
 Group: Applications/Alice
 Prefix: /opt/%{name}
@@ -30,4 +30,4 @@ Requires: date, daqDA-lib
 # list of files to be installed
 %files
 %defattr (-,root,root)
-%{prefix}/@DA_EXECUTABLE@
\ No newline at end of file
+%{prefix}/@DA_EXECUTABLE@
index 06c890e1b743e68c26f4ebabb0baee6e5203eedf..5351bc73b47bc33d3f80f7c1527d7bae299f7c68 100644 (file)
@@ -77,7 +77,7 @@ Bool_t DiffGeomBeforeTagging(const char* recipient, const char* cdbUri="local://
 
                // Get root and AliRoot versions
                const char* rootv = gROOT->GetVersion();
-               TString av(ALIROOT_BRANCH);
+               TString av(ALIROOT_VERSION);
                TString revnum(ALIROOT_REVISION);
                Printf("root version: %s.  AliRoot %s, revision number %s",rootv,av.Data(),revnum);
 
index a7a7f8da1c86d5d2556d1921c707423b5cfa8c7e..cce8f16ba5deaf30e3597f2d150849bf6e47d957 100644 (file)
@@ -149,7 +149,7 @@ void MakeAlignmentObjs(const char* detList="ALL", const char* ocdbOrDir = "local
                        strId+="/Align/Data";
                        AliCDBId id(strId.Data(),0,AliCDBRunRange::Infinity());
                        AliCDBMetaData *md = misAligner->GetCDBMetaData();
-                       md->SetAliRootVersion(ALIROOT_BRANCH);
+                       md->SetAliRootVersion(ALIROOT_VERSION);
                        md->AddDateToComment();
                        storage->Put(objsArray, id, md);
                }else{
index 16e4182cd767968dc4327323adf2a569b040c6a7..f38739c1ff696aa5c1a43cd42e8788f4c7973157 100644 (file)
@@ -17,7 +17,7 @@ void MakeAllDETsFullMisAlignment(Char_t* CDBstorage = "local://$HOME/FullMisAlig
   }else{  
     gSystem->Setenv("TOCDB","kTRUE");
     gSystem->Setenv("STORAGE",strStorage.Data());
-    gSystem->Setenv("ARVERSION",ALIROOT_BRANCH);
+    gSystem->Setenv("ARVERSION",ALIROOT_VERSION);
   }
   if(partialGeom){
     gSystem->Setenv("REALSETUP","kTRUE");
index 5ed2f3a331adf3ce60c248f6e804c3cce6f4c6ac..702d2e88246144f2d71ac73ddf605169905ac268 100644 (file)
@@ -17,7 +17,7 @@ void MakeAllDETsResMisAlignment(Char_t* CDBstorage = "local://$HOME/ResidualMisA
   }else{  
     gSystem->Setenv("TOCDB","kTRUE");
     gSystem->Setenv("STORAGE",strStorage.Data());
-    gSystem->Setenv("ARVERSION",ALIROOT_BRANCH);
+    gSystem->Setenv("ARVERSION",ALIROOT_VERSION);
   }
   if(partialGeom){
     gSystem->Setenv("REALSETUP","kTRUE");
index 27342c6a8b4d2b17cf2d4fe470424a798d0c1ab5..7dccf35f5ffa8b3fff1a52ea0ff31ba604fc4058 100644 (file)
@@ -14,7 +14,7 @@ void MakeAllDETsZeroMisAlignment(Char_t* CDBstorage = "local://$HOME/ZeroMisAlig
   }else{  
     gSystem->Setenv("TOCDB","kTRUE");
     gSystem->Setenv("STORAGE",strStorage.Data());
-    gSystem->Setenv("ARVERSION",ALIROOT_BRANCH);
+    gSystem->Setenv("ARVERSION",ALIROOT_VERSION);
   }
   if(partialGeom){
     gSystem->Setenv("REALSETUP","kTRUE");