diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74c36c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +\#*\# diff --git a/KinKal_to_UPS/README.md b/KinKal_to_UPS/README.md new file mode 100644 index 0000000..b6c0adf --- /dev/null +++ b/KinKal_to_UPS/README.md @@ -0,0 +1,99 @@ +# KinKal_to_UPS +Tools to build the KinKal package and install it in UPS. + +## Introduction + +There are two extreme ways to use this package: + 1) If you already have an exisiting build, you can create a UPS repository and install the existing build there. + 2) Start with nothing, clone, checkout, and, for both build prof and debug, build, test and install. + +There are command line options to choose intermediate amounts of work. + +## Instructions for case 1 + +The simplest example is that you have a working directory that contains 2 directories: + +> KinKal build_debug + + +and you already have a UPS **debug** version of root set up in the environment. In that directory do +the following: + +* setup mu2e +* setup codetools +* kk2ups -h # to see the help +* kk2ups -v -i + +This will look for the source in the subdirectory KinKal and for the built debug version in +the subdirectory build_debug. It will install the already built git tag and into the default UPS +repository, which is ./artexternals; the UPS repository will be created if necessary. The git tag +is needed in order to name the UPS product version. + +For example, if git_tag_name is v0.1.1, the UPS installation will be located at: + + artexternals/KinKal/v00_01_01 + +and the UPS qualifiers will be copied from the underlying root UPS pacakge. + +To use this UPS product: + +* export PRODUCTS=${PWD}/artexternals:${PRODUCTS} +* ups list -aK+ KinKal +* setup -B KinKal VERSION -qQUALIFIERS + +You can access the headers and libraries with the usual -I$KINKAL_INC and -L$KINKAL_LIB. An include directive within a .cc file should look like: + + #include "KinKal/Fit/Track.hh" + + +## Instructions for Case 2 + +Start in a clean working directory with no UPS version of root or cmake already setup. + +* setup mu2e +* setup codetools +* kk2ups -v "v0.1.1" -n -b -t -i -z -c "v3_18_2" -r "v6_20_08a -q+e20:+p383b:+prof" -j 24 -d ${PWD}/artexternals + +This will do the following +* For the requested git tag of KinKal this will clone, checkout, cmake, make, make tests, install into UPS, and make tar files for installation on cvmfs. +* The ups repository into which it is installed is given by the -d option; the default is ${PWD}/artexternals. +* It will use the indicated versions of cmake and root; there is a default for cmake but only sort-of for root (see below). +* The make step will do a 24 way parallel build, which is appropriate for mu2ebuild01; the default is a one thread build. +* It will build both prof and debug; it knows that cmake spells these Release and Debug. +* It assumes that debug version of ROOT differs from the prof version by the exchange prof->debug in the qualifier string +* If you omit the -r qualifier, and if there is already a UPS version of root set up in the environment, this command will only build and install one of prof/debug, the one matching the version of root already set up. +* If you omit the -r qualifier, and if there is no UPS version of root setup in the environment, it is an error. + +When this is complete you will see the following subdirectories of clean_working_dir +* KinKal_to_UPS - this package +* KinKal - the cloned source +* kinkal_profile - the working space for the Release (prof) build +* kinkal_debug - the working space for the Debug (debug) build +* artexternals - the UPS repo into which the code is installed. + +You will also see two files: +* KinKal_prof.tar.bz2 +* KinKal_debug.tar.bz2 + +These tar.bz2 files are formatted to be unwound into /cvmfs/mu2e.opensciencegrid.org/artexternals . + +You can point the UPS repo at an arbitrary directory using the -d option but the other four directory names are hard coded. + +The default behaviour is to abort if the KinKal directory already exists; it will overwrite existing files in kinkal_profile, kinkal_debug +and artexternals/KinKal. + +## Fixmes, Todos and questions + +* For Jenkins, Ray prefers separate commands for prof/debug not one command to do both +* For the development environment, Dave is OK with separate commands for prof/debug but would like to do both with a single command. +* Do not needlessly rerun cmake; check for one of it's artifacts and skip. +* git clone will fail if the directory KinKal exists and is non-empty. Is it acceptable to count on this or do we want our own check? +* Is there a better name than KinKal_to_UPS? +* Should KinKal_to_UPS be installed in UPS? +* In the case of installing a prebuilt version of KinKal, is there a way to automatically determine the git tag so that it does not need to be given by hand in the install command? +* Add an option to add additional qualifiers to the KinKal product +* What additional checks for corner cases are needed? +* I need to roll up the return statuses to one overall exit status and update the exit message. +* Rename the tar.bz2 files to match the scisoft standard. +* If we do a git checkout of the named tag, we assume that \_branch is a valid git branch name. Is that safe? +* What else? diff --git a/KinKal_to_UPS/exclude_for_include.txt b/KinKal_to_UPS/exclude_for_include.txt new file mode 100644 index 0000000..9dd0fe3 --- /dev/null +++ b/KinKal_to_UPS/exclude_for_include.txt @@ -0,0 +1,12 @@ +.git +.gitignore +*.cc +*~ +*.sh +*.old +*.sav +.clang-format +.clang-tidy +.travis.yml +CMakeLists.txt +README.md diff --git a/KinKal_to_UPS/exclude_for_source.txt b/KinKal_to_UPS/exclude_for_source.txt new file mode 100644 index 0000000..febaac8 --- /dev/null +++ b/KinKal_to_UPS/exclude_for_source.txt @@ -0,0 +1,5 @@ +.git +.gitignore +*~ +*.old +*.sav diff --git a/KinKal_to_UPS/funcs b/KinKal_to_UPS/funcs new file mode 100644 index 0000000..da48640 --- /dev/null +++ b/KinKal_to_UPS/funcs @@ -0,0 +1,17 @@ +# +# Convert the git tag into UPS version number style +# Examples: v0.1.1 to v00_01_01 +# v0.100.1 to v00_100_01 +# Note: awk printf will expand field width to support numbers larger than 99. +# Fixme: add more error checking and support other style tags, for example +# a suffix after the version number? +# +setUPSVersion() { + nn=`echo $gitVersion | awk 'BEGIN{FS="."} { print NF }'` + if [ "${nn}" != "3" ]; then + echo "Git version is not in a supported style: " ${gitVersion} + return 1 + fi + ups_style_version=`echo $gitVersion | sed 's/v//' | awk 'BEGIN{FS="."} { printf ( "v%02d_%02d_%02d\n", $1, $2, $3) }'`"$versionSuffix" + return 0 +} diff --git a/KinKal_to_UPS/kk2ups b/KinKal_to_UPS/kk2ups new file mode 100755 index 0000000..8f34ad5 --- /dev/null +++ b/KinKal_to_UPS/kk2ups @@ -0,0 +1,428 @@ +#! /bin/bash +# +# Master script to build and install KinKal. +# + +usage() { +echo " + +Script to build, test, install and cleanup the KinKal UPS product. + +usage: build + +Option Value Description + -b build code (optional, default = no ) + -C clean up working directories ( optional, default=no) + -c VALUE cmake version and qualifiers ( optional, default=\"v3_26_6\", used only for the build step) + -d upsRoot path to the root of the target UPS directory (required if -i selected) + -D buildDirDebug name of the directory that holds the debug build (default=kinkal_debug) + -i install as a UPS product ( optional, default=no) + -j value maximum number of build threads (optional, default =1) + -m setup args Use muse mode to discover root version; in compatible with -r + -n do a new clone; if absent expect on to be present (optional, default=no) + -P buildDirProf name of the directory that holds the profile build (default=kinkal_profile) + -r value root version and qualifiers (optional, if not specfied it will use UPS active); + incompatible with -m. + -s versionSuffix Quals additional qualifiers to add as a suffix to the UPS version of the product ( optional, default = "" ) + -t run the tests (optional, default=no, only works if -b is also specified ) + -v gitVersion name of the git tag (required) + -V make this script verbose (optional, default = no ) + -z make the a tar.bz2 file(s) (optional, default = no ) + -h print this help + +For additional details see: https://github.com/Mu2e/KinKal_to_UPS +" +} + +checkConfiguration(){ + + if [[ -n "$doInstall" && -z "$gitVersion" ]]; then + echo "ERROR - you must supply a version when requesting an install." + return 2 + fi + + if [[ -n "$doBuild" && -z "$cmakever" ]]; then + echo "ERROR - you must supply a cmake version when requesting a build." + return 3 + fi + + if [[ -z "$doBuild" && -z "$doInstall" && -z "$doClean" && -z "$doTar" && -z "$doTest" ]]; then + echo "WARNING - no actions requested; hope that's OK" + fi + + return 0 +} + +# Gymnastics with root qualifiers to predefine several variants that will be needed. +processROOTQualifiers(){ + + # Fixme: allow this to proceed if the two agree. + if [[ -n "${rootCmdLineOption}" && -n "${SETUP_ROOT}" ]]; then + echo "Error - root is already setup and a root version is also supplied via the command line. Pick one." + return 1 + fi + + # If a root version was not specified by command line argument, then see + # if there is a root already setup in the environment and use that. + if [[ -n "${rootCmdLineOption}" ]]; then + rootQuals=`echo ${rootCmdLineOption} | awk '{print $2}' | sed 's/-q//' | sed 's/+//g'` + rootVer=`echo ${rootCmdLineOption} | awk '{print $1}' ` + elif [[ -n "${SETUP_ROOT}" ]]; then + rootQuals=`echo ${SETUP_ROOT} | awk '{print $NF}'` + rootVer=${ROOT_VERSION} + rootCmdLineOption="$ROOT_VERSION -q$rootQuals" + echo ${rootQuals} | grep -q prof + if [[ "$?" == "0" ]]; then + doDebug="" + else + echo ${rootQuals} | grep -q debug + if [[ "$?" == "0" ]]; then + doProf="" + fi + fi + else + # If we are only cleaning or making tar files then we do not need root + if [[ -n "$doBuild" || -n "$doInstall" ]]; then + echo "Error - you must either supply the -r option or have an already setup version of ROOT in your shell." + return 2 + fi + fi + + # Define both the debug and prof versions of the qualifer strings. + echo ${rootQuals} | grep -q prof + if [[ "$?" == "0" ]]; then + profRootQuals=${rootQuals} + debugRootQuals=`echo ${rootQuals} | sed 's/prof/debug/' | sed 's/:/ /g' | tr " " "\n" | sort | tr "\n" " " | xargs | tr " " ":"` + profColonQuals=${qualifiers_colons} + debugColonQuals=`echo ${profColonQuals} | sed 's/prof/debug/' | sed 's/:/ /g' | tr " " "\n" | sort | tr "\n" " " | xargs | tr " " ":"` + else + echo ${rootQuals} | grep -q debug + if [[ "$?" == "0" ]]; then + debugRootQuals=${rootQuals} + profRootQuals=`echo ${rootQuals} | sed 's/debug/prof/' | sed 's/:/ /g' | tr " " "\n" | sort | tr "\n" " " | xargs | tr " " ":"` + debugColonQuals=${qualifiers_colons} + profColonQuals=`echo ${debugColonQuals} | sed 's/debug/prof/' | sed 's/:/ /g' | tr " " "\n" | sort | tr "\n" " " | xargs | tr " " ":"` + else + # Expect one of prof or debug; if we are only cleaning then we do not need root + if [[ -n "$doBuild" || -n "$doInstall" ]]; then + echo "Error - Expected root to have either a prof or a debug qualifier" + return 3 + fi + fi + fi + + # Qualifier string with plus signs, needed to setup root + plusProfRootQuals=`echo "+"${profRootQuals} | sed 's/:/:+/g'` + plusDebugRootQuals=`echo "+"${debugRootQuals} | sed 's/:/:+/g'` + + return 0 +} + +# Fetch the code to be built. If no version is specified, use the head of the default branch. +getCode() { + if [[ -n "${doClone}" ]]; then + echo "Begin clone and checkout for KinKal tag "$gitVersion + git clone https://github.com/KFTrack/KinKal.git + if [[ "$?" != "0" ]]; then + return 1 + fi + cd KinKal + if [[ -n "$gitVersion" ]]; then + git checkout -b ${gitVersion}_build_branch ${gitVersion} + if [[ "$?" != "0" ]]; then + return 2 + fi + fi + cd .. + else + echo "Using existing clone of KinKal: " + fi # End test on doClone defined + + # Report the commit to be built + if [[ -d KinKal ]]; then + cd KinKal + git log -n 1 --decorate=full | cat # Need the pipe cat or it may pipe to less + git status + cd .. + else + echo "Error - The directory KinKal does not exist. " + return 3 + fi + + return 0 +} + +clean(){ + echo "Begin clean up. " + for dir in ${buildDirProf} ${buildDirDebug}; do + if [[ -d ${dir} ]]; then + echo "Removing " ${dir} + /bin/rm -rf ${dir} + fi + done +} + + +install() { + echo "Begin install." + + retval=0 + + if [[ -n ${doProf} ]]; then + if [[ -d ${buildDirProf} ]]; then + echo "Begin install of prof version." + ${thisDir}/kk2ups_install ${gitVersion} ${upsRoot} ${rootVer} ${profRootQuals} ${buildDirProf} ${versionSuffix} + else + echo "ERROR - requested to install " ${buildDirProf} " but this directory does not exist." + retval=1 + fi + fi + + if [[ -n ${doDebug} ]]; then + if [[ -d ${buildDirDebug} ]]; then + echo "Begin install of debug version." + ${thisDir}/kk2ups_install ${gitVersion} ${upsRoot} ${rootVer} ${debugRootQuals} ${buildDirDebug} ${versionSuffix} + else + echo "ERROR - requested to install " ${buildDirDebug} " but this directory does not exist." + retval=1 + fi + fi + + return ${retval} +} + +makeTarFiles() { + echo "Begin making tar files." + + setUPSVersion + echo "Version is: " $ups_style_version " " $ups_style_version + + if [[ -d artexternals/KinKal/${ups_style_version} ]]; then + if [[ -n "$doProf" ]]; then + echo "Begin making tar file for prof version." + tar cjf KinKal_prof.tar.bz2 --exclude="*debug*" -C artexternals KinKal/${ups_style_version} KinKal/${ups_style_version}.version + fi + + if [[ -n "$doDebug" ]]; then + echo "Begin making tar file for debug version." + tar cjf KinKal_debug.tar.bz2 --exclude="*prof*" -C artexternals KinKal/${ups_style_version} KinKal/${ups_style_version}.version + fi + else + echo "ERROR - could not find the ups product to tar: " artexternals/KinKal/${ups_style_version} + return 1 + fi + + return 0 +} + +# Discover the version of root that will be setup by +# the envset specified by the -m argument +# The argument may be an empty string to select the +# default muse behaviour. +discoverRootFromMuse(){ + + # Check for consistent arguments. + if [[ -n "$rootCmdLineOption" ]]; then + echo "ERROR - you must not supply both -m and -r." + exit 9 + fi + + if [[ -z "${SETUP_MUSE}" ]]; then + echo "ERROR - Muse must be setup in your environment to use the -m option." + exit 10 + fi + + export -f muse + tmp=`${thisDir}/kk2ups_discover_root_ver ${museArgs} ` + rval=$? + if [[ "${rval}" != "0" ]]; then + echo ${tmp} + exit "${rval}" + fi + rootCmdLineOption="${tmp}" + + if [[ -n "$KinKal_Installer_Verbose" ]]; then + echo "Root version discovered from muse: " ${rootCmdLineOption} + fi + unset tmp +} + + +# ********** main ********** + +productName=KinKal + +# The directory that contains this script (and others that it will run). +thisDir=`dirname $(readlink -f $0)` + +source ${thisDir}/funcs + +# Default values for command line argument options +cmakever="v3_26_4" +doClone="" +doBuild="" +doClean="" +doInstall="" +doTar="" +doTest="" +gitVersion="" +nBuildThreads="1" +useMuse="" +museArgs="" +upsRoot="${PWD}/artexternals" +buildDirProf="kinkal_profile" +buildDirDebug="kinkal_debug" +rootCmdLineOption="" +versionSuffix="" + + +export KinKal_Installer_Verbose="" + +while getopts abCc:d:D:ij:m:nP:r:s:tv:Vzh OPT; do + case $OPT in + b) + doBuild=true + ;; + C) doClean=true + ;; + c) cmakever=$OPTARG + ;; + d) + upsRoot=$OPTARG + ;; + D) + buildDirDebug=$OPTARG + ;; + i) + doInstall=true + ;; + j) nBuildThreads=$OPTARG + ;; + m) useMuse=true + museArgs=$OPTARG + ;; + n) doClone=true + ;; + P) + buildDirProf=$OPTARG + ;; + r) rootCmdLineOption=$OPTARG + ;; + s) + versionSuffix=$OPTARG + ;; + t) doTest="true" + ;; + v) + gitVersion=$OPTARG + ;; + V) + KinKal_Installer_Verbose="true" + ;; + z) + doTar="true" + ;; + h) + usage + exit 0 + ;; + *) + echo "Error - unknown option, exiting" + usage + exit 1 + ;; + esac +done + +# Control build and install of both prof/debug or just one of them. +# One of these is disabled if a version of root is found in the environment. +doProf="true" +doDebug="true" + +if [[ -n "$useMuse" ]]; then + + export -f muse + discoverRootFromMuse + if [[ "$?" != "0" ]]; then + exit 11 + fi +fi + + +processROOTQualifiers +if [[ "$?" != "0" ]]; then + exit 1 +fi + +if [[ -n "$KinKal_Installer_Verbose" ]]; then + echo "Parsed command line arguments: " + echo "productName: " ${productName} + echo "thisDir: " ${thisDir} + echo "doClone: " ${doClone} + echo "doBuild: " ${doBuild} + echo "doClean: " ${doClean} + echo "cmakever: " ${cmakever} + echo "doInstall: " ${doInstall} + echo "upsRoot: " ${upsRoot} + echo "buildDirProf: " ${buildDirProf} + echo "buildDirDebug: " ${buildDirDebug} + echo "rootCmdLineOption: " ${rootCmdLineOption} + echo "doTest: " ${doTest} + echo "gitVersion: " ${gitVersion} + echo "nBuildThreads: " ${nBuildThreads} + echo "useMuse: " ${useMuse} + echo "museArgs: " ${museArgs} + echo " " + echo "Resolved root information:" + echo "Root version: " ${rootVer} + echo "Root qualifiers (prof): " ${profRootQuals} + echo "Root qualifiers (debug): " ${debugRootQuals} + echo " " + echo "Other:" + echo "Prof enabled: " ${doProf} + echo "Debug enabled: " ${doDebug} +fi + +if ! checkConfiguration ; then + usage + exit 2 +fi + +if [ -n "$doBuild" ]; then + if ! getCode ; then + exit 3 + fi + if [[ -n "${doProf}" ]]; then + ${thisDir}/kk2ups_build_one_version ${cmakever} "${rootVer} -q${plusProfRootQuals}" ${buildDirProf} ${nBuildThreads} ${doTest} + if [[ "$?" != "0" ]]; then + exit 4 + fi + fi + if [[ -n "${doDebug}" ]]; then + ${thisDir}/kk2ups_build_one_version ${cmakever} "${rootVer} -q${plusDebugRootQuals}" ${buildDirDebug} ${nBuildThreads} ${doTest} + if [[ "$?" != "0" ]]; then + exit 5 + fi + fi +fi + +if [ -n "$doInstall" ]; then + if ! install ; then + exit 6 + fi +fi + +if [ -n "$doTar" ]; then + if ! makeTarFiles ; then + exit 7 + fi +fi + +if [ -n "$doClean" ]; then + if ! clean ; then + exit 8 + fi +fi + +echo "KinKal_to_UPS/build completed with status 0" +exit 0 diff --git a/KinKal_to_UPS/kk2ups_build_one_version b/KinKal_to_UPS/kk2ups_build_one_version new file mode 100755 index 0000000..e26021d --- /dev/null +++ b/KinKal_to_UPS/kk2ups_build_one_version @@ -0,0 +1,70 @@ +#! /bin/bash +# +# Helper script for KinKal_build - build either prof or debug +# +# This is a separate script, not a bash function so that it will +# run in a sub-shell and not modify the environment of its parent shell. +# +# Arguments +# cmakever = version + qualifer string for cmake +# root_for_this_build = version + qualifier string for root +# local_build_dir = directory that will hold the build +# nbuildthreads = number of threads to use for make +# dotest = if true then do the tests after the build + +cmake_ver=$1 +root_for_this_build=$2 +local_build_dir=$3 +nbuildthreads=$4 +dotest=$5 + +# The convention suggested in the KinKal docs is that +# cmake build type Release is built in the directory kinkal_profile +# cmake build type Debug is built in the directory kinkal_debug +cmake_build_type="" +local_build_suffix="" +if grep -q "prof" <<< "$root_for_this_build"; then + cmake_build_type="Release" + local_build_suffix="profile" +elif grep -q "debug" <<< "$root_for_this_build"; then + cmake_build_type="Debug" + local_build_suffix="debug" +else + echo "Could not understand requested build type derived from the ups ROOT product" + echo "The ups root version is: " $root_for_this_build + exit 1 +fi + +echo " Begin ${local_build_suffix} build " + +setup mu2e +setup cmake ${cmake_ver} +if [[ "$?" != "0" ]]; then + exit 2 +fi +setup -B root ${root_for_this_build} +if [[ "$?" != "0" ]]; then + exit 3 +fi +ups active + +mkdir -p ${local_build_dir} +cd ${local_build_dir} +cmake ../KinKal -DCMAKE_BUILD_TYPE=${cmake_build_type} +if [[ "$?" != "0" ]]; then + exit 4 +fi + +make -j ${nbuildthreads} +if [[ "$?" != "0" ]]; then + exit 5 +fi + +if [[ -n "${dotest}" ]]; then + make -j ${nbuildthreads} test + if [[ "$?" != "0" ]]; then + exit 6 + fi +fi + +exit 0 diff --git a/KinKal_to_UPS/kk2ups_discover_root_ver b/KinKal_to_UPS/kk2ups_discover_root_ver new file mode 100755 index 0000000..47532a0 --- /dev/null +++ b/KinKal_to_UPS/kk2ups_discover_root_ver @@ -0,0 +1,15 @@ +#!/bin/bash +# +# Print the root version the comes with a particular muse setup. +# + +muse setup $@ >& /dev/null +tmp=`ups active | awk '$1 == "root" {print $2 " " $5$6}'` + +if [[ -z "$tmp" ]]; then + exit 1 +fi + +echo "$tmp" + +exit 0 diff --git a/KinKal_to_UPS/kk2ups_install b/KinKal_to_UPS/kk2ups_install new file mode 100755 index 0000000..d5cc285 --- /dev/null +++ b/KinKal_to_UPS/kk2ups_install @@ -0,0 +1,199 @@ +#! /bin/bash +# +# Copy files from the source and build areas to create a UPS product. +# +# Arguments: +# 1 - The git style version number +# 2 - root of the UPS repo into which the product will be installed +# 3 - The version of root on which this depends +# 4 - The qualifier string for the root version +# 5 - The path to the directory that contains the libs and bins to be installed. +# 6 - Optional. Suffix to append to the UPS style vesion number. +# +# This script unconditionally deletes previously existing installs of the +# same product+version+qualifiers: use with care. +# +# The UPS qualifiers of the new product will be those of the version of +# root on which it depends. +# +# Fixme: add support for additional qualifiers + +# Create the UPS qualifiers for the prof and debug versions +# - 3 versions, needed for different places in UPSology +# - colon separated +# - dot separated +# - underscore separated +setQualifiers(){ + # Sort qualifiers by alphabetical order; xargs is used to strip trailing whitespace + qualifiers_colons=`echo $rootQuals | sed 's/:/ /g' | tr " " "\n" | sort | tr "\n" " " | xargs | tr " " ":"` + qualifiers_dots=`echo $qualifiers_colons | sed 's/:/./g'` + qualifiers_underscores=`echo $qualifiers_colons | sed 's/:/_/g'` + return 0 +} + +#--- main --- + +gitVersion=$1 +upsRoot=$2 +rootVer=$3 +rootQuals=$4 +build_path=$5 +versionSuffix=$6 + +package_name=KinKal +package_source=${PWD}/${package_name} + +# The directory that contains this script. +thisDir=`dirname $(readlink -f $0)` + +# Define some shell functions. +source ${thisDir}/funcs + +setUPSVersion +if [[ "$?" != 0 ]]; then + echo "ERROR - Could not convert the git tag to a UPS version number. The git tag was: " ${gitVersion} + exit 1 +fi + +setQualifiers +if [[ "$?" != 0 ]]; then + echo "ERROR - setQualifiers failed: " + exit 2 +fi + +# Where to find the files in the installer package +KINKAL_TO_UPS_DIR=`dirname $(readlink -f $0)` + +# Where to find example .upsfiles and .updfiles. +exampleExternals="/cvmfs/mu2e.opensciencegrid.org/artexternals/" + +# Intialize UPS repo if needed. +if ! [ -e ${upsRoot} ]; then + mkdir ${upsRoot} + cp -r ${exampleExternals}/.upsfiles ${upsRoot} + cp -r ${exampleExternals}/.updfiles ${upsRoot} +fi + +if ! [ -d ${upsRoot}/.upsfiles ]; then + cp -r ${exampleExternals}/.upsfiles ${upsRoot} +fi + +if ! [ -d ${upsRoot}/.updfiles ]; then + cp -r ${exampleExternals}/.updfiles ${upsRoot} +fi + + +# Need this for get-directory-name +setup cetpkgsupport + + +# There are two representations of operating system UPS flavor: +# old style, for example: Linux64bit+2.6-2.12_e7 +# new style, for example: slf6.x86_64 +# We need them both. +old_flavour=`ups flavor -4` +new_flavour=`get-directory-name subdir` + +# Build the names of the directories into which we will write things +fq=${new_flavour}.${qualifiers_dots} +topdir=${upsRoot}/${package_name} +proddir=${upsRoot}/${package_name}/${ups_style_version} +verdir=${upsRoot}/${package_name}/${ups_style_version}.version +bindir=${upsRoot}/${package_name}/${ups_style_version}/${fq} +incdir=${upsRoot}/${package_name}/${ups_style_version}/include +upsdir=${upsRoot}/${package_name}/${ups_style_version}/ups + +# I am not sure what this file is properly called. +# I am calling it the fqfile, which is short for flavor qualifier file. +fqfile=${verdir}/${old_flavour}_${qualifiers_underscores} + +# Make directories, if needed. +if ! [ -e ${topdir} ];then + mkdir ${topdir} +fi + +if ! [ -e ${proddir} ];then + mkdir ${proddir} +fi + +if ! [ -e ${verdir} ];then + mkdir ${verdir} +fi + +# Remove all content that we will recreate. +# Create required directories. +if [ -e ${bindir} ];then + /bin/rm -rf ${bindir} +fi +mkdir ${bindir} + +if [ -e ${incdir} ];then + /bin/rm -rf ${incdir} +fi +mkdir ${incdir} + +if [ -e ${upsdir} ];then + /bin/rm -rf ${upsdir} +fi +mkdir ${upsdir} + +if [ -e ${fqfile} ];then + /bin/rm -rf ${fqfile} +fi + +# Copy the required parts of the source directory to the installation area: + +# Header files: +rsync -ar --exclude-from ${KINKAL_TO_UPS_DIR}/exclude_for_include.txt \ + ${package_source} ${proddir}/include + +# UPS table file +${KINKAL_TO_UPS_DIR}/kk2ups_installTableFile ${package_name} ${upsdir}/${package_name}.table ${rootVer} ${rootQuals} + +# Libaries and executable binaries +rsync -ar ${build_path}/bin ${bindir} +if [[ "$?" != 0 ]]; then + echo "ERROR - could not copy the bin directory: " + exit 3 +fi +rsync -ar ${build_path}/lib ${bindir} +if [[ "$?" != 0 ]]; then + echo "ERROR - could not copy the lib directory: " + exit 4 +fi + +# A copy of the full source +rsync -ar --exclude-from ${KINKAL_TO_UPS_DIR}/exclude_for_source.txt \ + ${package_source} ${proddir}/source + +# Create the ups fq file. +cat > ${fqfile} < ${destination_file} < $DD/ups/codetools.table # install scripts - cp -r $SOURCEDIR/bin $SOURCEDIR/clangtools_utilities $DD + cp -r $SOURCEDIR/bin $SOURCEDIR/clangtools_utilities $SOURCEDIR/KinKal_to_UPS $DD RC=$? if [ $RC -ne 0 ]; then echo "ERROR - failed to cp scripts from $SOURCEDIR to $DD" diff --git a/prd/codetools.table b/prd/codetools.table index d822876..3cffce8 100644 --- a/prd/codetools.table +++ b/prd/codetools.table @@ -17,6 +17,7 @@ Common: # add the bin directory to the path pathPrepend(PATH, ${UPS_PROD_DIR}/bin ) + pathPrepend(PATH, ${UPS_PROD_DIR}/KinKal_to_UPS ) End: # End Group definition