diff --git a/utils/ci/scripts/pull_gtgen.sh b/utils/ci/scripts/pull_gtgen.sh new file mode 100755 index 0000000000000000000000000000000000000000..7e0146f1b4fd7537bcb2ff4d7df043cc6e84b3f6 --- /dev/null +++ b/utils/ci/scripts/pull_gtgen.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +################################################################################ +# Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License 2.0 which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +################################################################################ +# This Script pull the gtgen binaries and installs them +################################################################################ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +#ToDo: Set this variable at the top level +if [[ -z "${OP_GTGEN_CLI_DIR}" ]]; then + # If not defined, set a default value + OP_GTGEN_CLI_DIR="$SCRIPT_DIR/../../../../gtgen_cli" + echo "WARN: OP_GTGEN_CLI_DIR variable is not set. Setting it to: + OP_GTGEN_CLI_DIR is ${OP_GTGEN_CLI_DIR}" +fi + +mkdir -p "$OP_GTGEN_CLI_DIR" && cd "$OP_GTGEN_CLI_DIR" || exit 1 +rm -rf -- * || { echo "Failed to clean $OP_GTGEN_CLI_DIR directory"; exit 1; } + +# ToDo: Make it generic +GTGEN_CORE_URL="https://ci.eclipse.org/openpass/job/GT-Gen-Simulator-PreMerge-Gate/job/main/lastSuccessfulBuild/artifact/artifacts/gtgen-simulator_11.1.0_amd64.deb" +GTGEN_CLI_URL="https://ci.eclipse.org/openpass/job/GT-Gen-Simulator-PreMerge-Gate/job/main/lastSuccessfulBuild/artifact/artifacts/gtgen-cli_1.1.0_amd64.deb" + +GTGEN_CORE_FILE=$(basename "$GTGEN_CORE_URL") +GTGEN_CLI_FILE=$(basename "$GTGEN_CLI_URL") + +#download gtgen_core and gtgen_cli +download_deb() { + echo "============================== Downloading $GTGEN_CORE_FILE ==============================" + wget "${GTGEN_CORE_URL}" || { echo "Unable to download astas core $GTGEN_CORE_FILE from ddad artifactory"; exit 1; } + echo "============================== Download Successful ==============================" + echo "============================== Downloading $GTGEN_CLI_FILE ==============================" + wget "${GTGEN_CLI_URL}" || { echo "Unable to download astas cli $GTGEN_CLI_FILE from ddad artifactory"; exit 1; } + echo "============================== Download Successful ==============================" +} + +#Installs gtgen_core and gtgen_cli +install_deb() { + echo "============================== Installing $GTGEN_CORE_FILE ==============================" + sudo apt-get install -y ./"$GTGEN_CORE_FILE" || { echo "Unable to install astas core $GTGEN_CORE_FILE package"; exit 1; } + echo "============================== Installation Successful ==============================" + echo "============================== Installing $GTGEN_CORE_FILE ==============================" + sudo apt-get install -y ./"$GTGEN_CLI_FILE" || { echo "Unable to install astas cli $GTGEN_CLI_FILE package"; exit 1; } + echo "============================== Installation Successful ==============================" +} + +#Dry run gtgen_cli +install_and_verify_deb() { + download_deb + install_deb + mv /opt/gtgen_cli/* . || { echo "Unable to move astas cli to $OP_GTGEN_CLI_DIR directory"; exit 1; } + mv /opt/astas_core/lib/* . || { echo "Unable to move astas core to $OP_GTGEN_CLI_DIR directory"; exit 1; } + ./gtgen_cli -v || { echo "Unable to execute astas cli with '-v' option"; exit 1; } +} + +# uninstall (removing gtgen_core also removes gtgen_cli) +uninstall_deb(){ + echo "============================== Removing $GTGEN_CORE_FILE ==============================" + sudo apt remove -y astas-core || { echo "Unable to remove astas core"; exit 1; } + echo "============================== Removed Successfully ==============================" +} + +install_and_verify_deb \ No newline at end of file