Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:34

0001 #!/bin/bash
0002 #
0003 # Script to create sqlite files with single-IOV tags from files with
0004 # multi-IOV tags.
0005 # The multi-IOV tags are kept in the resulting 'split' db file.
0006 #
0007 ################################################################################
0008 
0009 if [ x${1} = 'x-h' ] || [ x${1} = 'x--help' ] || [ ${#} -ne 2 ]
0010 then
0011     echo "Usage: ${0} <input db name> <output db name>"
0012     exit 1
0013 elif [ x${CMSSW_BASE} = 'x' ]
0014 then
0015     echo "Please source a CMSSW environment."
0016     exit 1
0017 fi
0018 
0019 cp ${1} ${2}
0020 
0021 tags=$(sqlite3 ${1} "SELECT NAME FROM TAG;")
0022 
0023 count_copied_iovs=0
0024 for tag in ${tags}
0025 do
0026     tag_info_query="SELECT SINCE,PAYLOAD_HASH FROM IOV
0027                     WHERE TAG_NAME IS '${tag}';"
0028     tag_infos=$(sqlite3 ${1} "${tag_info_query}" | sort)
0029     if [ $(echo "${tag_infos}" | wc -l) -eq 1 ] # Is already a single-IOV tag?
0030     then
0031         continue
0032     fi
0033 
0034     count=0
0035     for tag_info in ${tag_infos}
0036     do
0037         since=$(echo ${tag_info} | cut -d'|' -f1)
0038         payload_hash=$(echo ${tag_info} | cut -d'|' -f2)
0039         new_tag=${tag}_${count}
0040         count=$(( count + 1 ))
0041 
0042         exists_query="SELECT EXISTS (
0043                         SELECT * FROM IOV
0044                         WHERE TAG_NAME IS '${new_tag}'
0045                         AND SINCE IS 1
0046                         AND PAYLOAD_HASH IS '${payload_hash}');"
0047         if [ $(sqlite3 ${1} "${exists_query}") -ne 0 ]
0048         then
0049             continue
0050         fi
0051 
0052         conddb_copy_iov -c sqlite_file:${2} -s ${since} -d 1 -t ${new_tag} -i ${tag}
0053         count_copied_iovs=$(( count_copied_iovs + 1 ))
0054     done
0055 done
0056 
0057 if [ ${count_copied_iovs} -eq 0 ]
0058 then
0059     echo "   >>> '${1}' is already a 'split' db file or contains only single-IOV tags."
0060     echo "   >>> The created db file '${2}' is therefore just a copy of '${1}'."
0061 fi