Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:06

0001 #!/bin/bash
0002 
0003 # This file is part of the ACTS project.
0004 #
0005 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0006 #
0007 # This Source Code Form is subject to the terms of the Mozilla Public
0008 # License, v. 2.0. If a copy of the MPL was not distributed with this
0009 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0010 
0011 # Script downloading the detray data file(s) through HTTPS, and unpacking them.
0012 
0013 # Stop on errors.
0014 set -e
0015 set -o pipefail
0016 
0017 # Function printing the usage information for the script.
0018 usage() {
0019    echo "Script downloading/unpacking data TGZ/MD5 files"
0020    echo ""
0021    echo "Usage: detray_data_get_files.sh [options]"
0022    echo ""
0023    echo "Options:"
0024    echo "  -f <filename>        Name of the data file, without its extension"
0025    echo "  -d <webDirectory>    Directory holding the data and MD5 files"
0026    echo "  -o <dataDirectory>   Main data directory"
0027    echo "  -c <cmakeExecutable> CMake executable to use in the script"
0028    echo "  -w <curlExecutable>  Curl executable to use in the script"
0029    echo ""
0030    return 0
0031 }
0032 
0033 # Default script arguments.
0034 DETRAY_DATA_NAME=${DETRAY_DATA_NAME:-"detray-data-v2"}
0035 DETRAY_WEB_DIRECTORY=${DETRAY_WEB_DIRECTORY:-"https://acts.web.cern.ch/traccc/data"}
0036 DETRAY_DATA_DIRECTORY=${DETRAY_DATA_DIRECTORY:-$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)}
0037 DETRAY_CMAKE_EXECUTABLE=${DETRAY_CMAKE_EXECUTABLE:-cmake}
0038 DETRAY_CURL_EXECUTABLE=${DETRAY_CURL_EXECUTABLE:-curl}
0039 
0040 # Parse the command line argument(s).
0041 while getopts ":f:d:o:c:wh" opt; do
0042    case $opt in
0043       f)
0044          DETRAY_DATA_NAME=$OPTARG
0045          ;;
0046       d)
0047          DETRAY_WEB_DIRECTORY=$OPTARG
0048          ;;
0049       o)
0050          DETRAY_DATA_DIRECTORY=$OPTARG
0051          ;;
0052       c)
0053          DETRAY_CMAKE_EXECUTABLE=$OPTARG
0054          ;;
0055       w)
0056          DETRAY_CURL_EXECUTABLE=$OPTARG
0057          ;;
0058       h)
0059          usage
0060          exit 0
0061          ;;
0062       :)
0063          echo "Argument -$OPTARG requires a parameter!"
0064          usage
0065          exit 1
0066          ;;
0067       ?)
0068          echo "Unknown argument: -$OPTARG"
0069          usage
0070          exit 1
0071          ;;
0072       *)
0073          echo "Unknown argument: -$OPTARG"
0074          usage
0075          exit 1
0076          ;;
0077    esac
0078 done
0079 
0080 # Go into the target directory.
0081 cd "${DETRAY_DATA_DIRECTORY}"
0082 
0083 # Download the TGZ and MD5 files.
0084 "${DETRAY_CURL_EXECUTABLE}" --retry 5 --retry-delay 10 \
0085    --output "${DETRAY_DATA_NAME}.tar.gz"               \
0086    "${DETRAY_WEB_DIRECTORY}/${DETRAY_DATA_NAME}.tar.gz"
0087 "${DETRAY_CURL_EXECUTABLE}" --retry 5 --retry-delay 10 \
0088    --output "${DETRAY_DATA_NAME}.md5"                  \
0089    "${DETRAY_WEB_DIRECTORY}/${DETRAY_DATA_NAME}.md5"
0090 
0091 # Verify that the download succeeded.
0092 "${DETRAY_CMAKE_EXECUTABLE}" -E md5sum "${DETRAY_DATA_NAME}.tar.gz" > \
0093    "${DETRAY_DATA_NAME}.md5-test"
0094 "${DETRAY_CMAKE_EXECUTABLE}" -E compare_files "${DETRAY_DATA_NAME}.md5" \
0095    "${DETRAY_DATA_NAME}.md5-test"
0096 
0097 # Extract the data files.
0098 "${DETRAY_CMAKE_EXECUTABLE}" -E tar xf "${DETRAY_DATA_NAME}.tar.gz"
0099 
0100 # Clean up.
0101 "${DETRAY_CMAKE_EXECUTABLE}" -E remove "${DETRAY_DATA_NAME}.tar.gz" \
0102    "${DETRAY_DATA_NAME}.md5" "${DETRAY_DATA_NAME}.md5-test"
0103 
0104 # Leave the user with a message.
0105 "${DETRAY_CMAKE_EXECUTABLE}" -E echo \
0106    "Files from ${DETRAY_DATA_NAME} unpacked under '${DETRAY_DATA_DIRECTORY}'"