Skip to content
Snippets Groups Projects
Forked from atlas / athena
137760 commits behind, 3112 commits ahead of the upstream repository.
  • Graeme A Stewart's avatar
    a609f8e9
    Add override environment variables for AtlasExternals and Gaudi checkouts · a609f8e9
    Graeme A Stewart authored
    Add some environment variables with a standard pattern of
    External_URL and External_REF that control the repository
    URL and refrence used in the checkout scripts. This makes
    it much easier to test changes to these repositories
    before they are merged into the main repos. The special
    value "current" for the URL signals no clone or checkout
    and leaves the current checkout in place, so that even
    uncommitted changes can be tested.
    
    
    Former-commit-id: 061edbfd49e1c4a58724ef6817f6cf0e3ed84652
    a609f8e9
    History
    Add override environment variables for AtlasExternals and Gaudi checkouts
    Graeme A Stewart authored
    Add some environment variables with a standard pattern of
    External_URL and External_REF that control the repository
    URL and refrence used in the checkout scripts. This makes
    it much easier to test changes to these repositories
    before they are merged into the main repos. The special
    value "current" for the URL signals no clone or checkout
    and leaves the current checkout in place, so that even
    uncommitted changes can be tested.
    
    
    Former-commit-id: 061edbfd49e1c4a58724ef6817f6cf0e3ed84652
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
checkout_Gaudi.sh 2.54 KiB
#!/bin/bash
#
# Script for automating the checkout of the Gaudi repository when
# building the whole software stack in a nightly/release.
#
# The script must receive the tag/branch that should be checked out of the
# Gaudi repository. And it can write the commit hash that the
# checkout ended up with, into another file.
#

# Stop on errors:
set -e

# Function printing the usage information for the script
usage() {
    echo "Usage: checkout_Gaudi.sh [options]"
    echo "  Options:"
    echo "    -t branch/tag: Mandatory branch/tag/hash to check out"
    echo "    -s directory: Mandatory source directory to use"
    echo "    -e url: Optional source URL to use for the checkout"
    echo
    echo "  This script will allow the environment variables"
    echo "  Gaudi_URL and Gaudi_REF to override"
    echo "  other values (even those on the command line)"
    echo "  If Gaudi_URL is set to 'current' then"
	echo "  no clone or checkout is done and the working copy"
	echo "  in the source directory is left untouched."
}

# Parse the command line arguments:
TAGBRANCH=""
SOURCEDIR=""
GAUDIURL="https://gitlab.cern.ch/atlas/Gaudi.git"
while getopts ":t:o:s:e:h" opt; do
    case $opt in
        t)
            TAGBRANCH=$OPTARG
            ;;
        s)
            SOURCEDIR=$OPTARG
            ;;
        e)
            GAUDIURL=$OPTARG
            ;;
        h)
            usage
            exit 0
            ;;
        :)
            echo "Argument -$OPTARG requires a parameter!"
            usage
            exit 1
            ;;
        ?)
            echo "Unknown argument: -$OPTARG"
            usage
            exit 1
            ;;
    esac
done

if [ "$Gaudi_URL" != "" ]; then
	GAUDIURL=$Gaudi_URL
	echo "Gaudi URL overridden to $GAUDIURL from environment"
	if [ "$Gaudi_URL" = "current" ]; then
		echo "Leaving current checkout in place for build"
		exit 0
	fi 
fi

if [ "$Gaudi_REF" != "" ]; then
	TAGBRANCH=$Gaudi_REF
	echo "Gaudi ref overridden to $TAGBRANCH from environment"
fi

# The tag/branch and a source directory must have been specified:
if [ "$TAGBRANCH" = "" ] || [ "$SOURCEDIR" = "" ]; then
    echo "Not all required arguments were provided!"
    usage
    exit 1
fi

# Tell the user what will happen:
echo "Checking out Gaudi tag/branch: $TAGBRANCH"
echo "   from: $GAUDIURL"

if [ ! -d "${SOURCEDIR}" ]; then
    # Clone the repository:
    git clone ${GAUDIURL} ${SOURCEDIR}
else
    echo "${SOURCEDIR} already exists -> assume previous checkout"
fi

# Get the appropriate version of it:
cd ${SOURCEDIR}
git fetch --prune origin
git checkout -f ${TAGBRANCH}