diff --git a/cmake/scripts/install_binary_tarfile.py b/cmake/scripts/install_binary_tarfile.py
index feeb1822ccd112980bcfa864ed1c2be3ebd36caa..e0d47667a464abe59757ea62ee0ac359942cd7e3 100755
--- a/cmake/scripts/install_binary_tarfile.py
+++ b/cmake/scripts/install_binary_tarfile.py
@@ -69,7 +69,8 @@ def install_tarfile(urltarfile, prefix, lcgprefix, with_hash=True, with_link=Tru
   if os.path.exists(postinstall) :
     #---Replace the old post-install script with new one
     with open(postinstall) as f:
-      if '#!/bin/sh' in f.read():
+      script = f.read()
+      if '#!/bin/sh' in script or 'RPM_INSTALL_PREFIX' not in script:
         f.close()
         shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)),'post-install.sh'), postinstall)
     os.environ['INSTALLDIR'] = prefix
diff --git a/jenkins/Jenkinsfile-release b/jenkins/Jenkinsfile-release
index 010c5164ee37cf17bcd6eac6adbf7995f9f2c0d4..6eee79fb8ed9088eaba6b9781958aa068d8bf057 100644
--- a/jenkins/Jenkinsfile-release
+++ b/jenkins/Jenkinsfile-release
@@ -39,6 +39,7 @@ pipeline {
     choice(name:       'RPM_DRYRUN',           choices: ['no', 'yes'], description: 'RPMs publish dryrun')
     booleanParam(name: 'RPM_TEST',             defaultValue: false, description: 'RPMs tests')
     string(name:       'RPM_REPOSITORY',       defaultValue: '', description: 'RPM repository e.g /eos/project/l/lcg/www/lcgpackages/lcg/repo/7/LCG_97/ or empty')
+    string(name:       'RPM_REVISION_NUMBER',  defaultValue: '', description: 'RPM revision number (default is the LCG numeric version)')
   }
   //---Options----------------------------------------------------------------------------------------------------------
   options {
diff --git a/jenkins/Jenkinsfunctions.groovy b/jenkins/Jenkinsfunctions.groovy
index 4cdde877bd439ee8a0d4232f60748d600746b324..31877a56e25b65ede80dc7635294fe276f3f26e4 100644
--- a/jenkins/Jenkinsfunctions.groovy
+++ b/jenkins/Jenkinsfunctions.groovy
@@ -24,6 +24,11 @@ def buildPackages() {
       ctest -VV -DCTEST_LABELS=Release  -S lcgcmake/jenkins/lcgcmake-build.cmake
     """
   }
+  //---Fail the release if the build stage fails-------------------------------------------------------------------------
+  if ( params.BUILDMODE == 'release' && currentBuild.result == 'UNSTABLE') {
+    echo 'Setting the build state to FAILURE for BUILDMODE equal to release'
+    currentBuild.result = 'FAILURE'
+  }
   //---Update a number of variables after the build step-----------------------------------------------------------------
   PLATFORM = sh(returnStdout: true, script: 'lcgcmake/jenkins/getPlatform.py').trim()
   barePLATFORM = ([PLATFORM.split('-')[0].split('\\+')[0]]+PLATFORM.split('-')[1..3]).join('-').replace('gcc7','gcc8').replace('dbg','opt')
@@ -181,6 +186,7 @@ def testPythonImport() {
 def createRPMS() {
   sh  label: 'create-rpms', script: """
     cd ${WORKSPACE}/install
+    export RPM_REVISION_NUMBER=${RPM_REVISION_NUMBER}
     ${WORKSPACE}/lcgcmake/jenkins/package_release.py ${WORKSPACE} ${LCG_VERSION} ${PLATFORM} ${TARGET} ${BUILDMODE} ${COMPILER}
   """
 }