From 51cb4f98bd6e117894f927f37ec17fd2ce4ac590 Mon Sep 17 00:00:00 2001
From: mbajdel <mbajdel@gmail.com>
Date: Mon, 12 Feb 2024 12:46:41 +0100
Subject: [PATCH] remove bash scripts

---
 Dockerfile         |   7 ---
 create_release.sh  | 104 ---------------------------------------
 install_ioc.sh     | 119 ---------------------------------------------
 install_modules.sh |  36 --------------
 4 files changed, 266 deletions(-)
 delete mode 100755 create_release.sh
 delete mode 100755 install_ioc.sh
 delete mode 100755 install_modules.sh

diff --git a/Dockerfile b/Dockerfile
index 46af095..435a06a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -43,13 +43,6 @@ RUN mkdir /opt/src \
     && mkdir /opt/epics \
     && mkdir /opt/epics/base
 
-# Copy ioc scripts
-COPY create_release.sh /opt/epics/create_release.sh
-RUN chmod +x /opt/epics/create_release.sh
-COPY install_ioc.sh /opt/epics/install_ioc.sh
-RUN chmod +x /opt/epics/install_ioc.sh
-COPY install_modules.sh /opt/epics/install_modules.sh
-RUN chmod +x /opt/epics/install_modules.sh
 
 ## setting the timezone
 RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone  
diff --git a/create_release.sh b/create_release.sh
deleted file mode 100755
index 433718a..0000000
--- a/create_release.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-# Define files
-MODULES_FILE="/opt/epics/modules.yml"
-RELEASE_LOCAL_FILE="RELEASE.local"
-
-# Function to extract .dbd values using yq
-extract_all_dbd_values() {
-    local modules=($(yq eval '.modules | keys | .[]' "$MODULES_FILE"))
-    local dbd_values=()
-
-    for module in "${modules[@]}"; do
-        local dbd=$(yq e ".modules.${module}.folder_name" "$MODULES_FILE")
-        dbd_values+=("$dbd")
-        echo "$dbd"
-    done
-
-    echo "${dbd_values[@]}"
-}
-
-# Function to update RELEASE.local file based on folder_name
-update_release_local() {
-    local folder_name=$1
-    local module_name=$2
-
-    if [[ $folder_name == *"$module_name"* ]]; then
-        echo "$(echo "${module_name}" | tr '[:lower:]' '[:upper:]')=/opt/epics/support/$module_name" >> "$RELEASE_LOCAL_FILE"
-    fi
-}
-
-# Function to add "undefine $2" if not added already
-add_undefine() {
-    local module_name=$1
-
-    if ! grep -q "undefine $module_name" "$RELEASE_LOCAL_FILE"; then
-        echo "undefine $module_name" >> "$RELEASE_LOCAL_FILE"
-    fi
-}
-
-# Function to add "undefine" if not added already
-add_undefine_if_not_added() {
-    local module_name=$1
-    local undefine_added=false
-    # Extract .dbd values for all modules
-    all_dbd_values=($(extract_all_dbd_values))
-    # Update RELEASE.local based on folder_name
-    for value in "${all_dbd_values[@]}"; do
-        if [[ $value == *"$module_name"* ]]; then
-            echo "folder_name: $value"
-            update_release_local "$value" "$module_name"
-            undefine_added=true
-            break
-        fi
-    done
-
-    # Add "undefine" if not added already
-    if [ "$undefine_added" = false ]; then
-        echo "undefine $(echo "${module_name}" | tr '[:lower:]' '[:upper:]')" >> "$RELEASE_LOCAL_FILE"
-    fi
-}
-
-# Function to add module if not added already
-add_module_if_not_added() {
-    local module_name=$1
-
-    if ! grep -q "^$(echo "${module_name}" | tr '[:lower:]' '[:upper:]')" "$RELEASE_LOCAL_FILE"; then
-        echo "$(echo "${module_name}" | tr '[:lower:]' '[:upper:]')=/opt/epics/support/$module_name" >> "$RELEASE_LOCAL_FILE"
-    fi
-}
-
-
-# Extract .dbd values for all modules
-all_dbd_values=($(extract_all_dbd_values))
-
-
-echo "EPICS_BASE=/opt/epics/base" > RELEASE.local
-echo "SUPPORT=/opt/epics/support" >> RELEASE.local
-
-# Keep track of processed modules
-processed_modules=()
-
-# For all other modules, add them to the file
-for module_name in "${all_dbd_values[@]}"; do
-    case "$module_name" in
-        "sscan" | "seq" | "pcre" )
-            # Skip these modules
-            ;;
-        * )
-            # Add other modules
-            if ! [[ "${processed_modules[*]}" =~ "$module_name" ]]; then
-                add_undefine_if_not_added "$module_name"
-                add_module_if_not_added "$module_name"
-                processed_modules+=("$module_name")
-            fi
-            ;;
-    esac
-done
-# Check three modules
-add_undefine_if_not_added "sscan"
-add_undefine_if_not_added "seq"
-sed -i 's/\<SEQ\>/SNCSEQ/' "RELEASE.local"
-add_undefine_if_not_added "pcre"
-
-
-cp RELEASE.local /opt/epics/ioc/RELEASE.local
-cp RELEASE.local /opt/epics/support/RELEASE.local
\ No newline at end of file
diff --git a/install_ioc.sh b/install_ioc.sh
deleted file mode 100755
index 516608c..0000000
--- a/install_ioc.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-
-# Define the input file
-MODULES_FILE="/opt/epics/modules.yml"
-
-# Function to display error messages and exit
-die() {
-    echo "Error: $1" >&2
-    exit 1
-}
-
-# Check if the file exists
-check_file_existence() {
-    [ -f "$1" ] || die "$1 not found."
-}
-
-# Fetch values for specific modules from the YAML file using yq
-extract_ioc_values() {
-    yq e ".ioc.folder_name + \",\" + .ioc.source + \",\" + .ioc.tag + \",\" + .ioc.user" "$1"
-}
-
-
-# Retrieve and copy source files
-retrieve_and_copy_source_files() {
-    git clone --depth 1 --recursive --branch "$3" "$2" "$1/${4}IOC"
-    # mv $1/${4}IOC/${4}IOC/* $1/${4}IOC/
-    # rm -rf $1/${4}IOC/${4}IOC
-    chmod +x "$1/${4}IOC/iocBoot/ioc${4}IOC/st.cmd"
-}
-
-
-# Update Makefile with files from the specified folder
-update_makefile_with_files() {
-    local folder_path="$1/${2}IOC/${2}IOCApp/Db"
-    local makefile_path_db="$1/${2}IOC/${2}IOCApp/Db/Makefile"
-
-    # Find all files with .db and .sub* extensions in the specified folder
-    local files=$(find "$folder_path" -type f \( -name "*.db" -o -name "*.sub*" -o -name "*.template" \))
-    # Check if there are any files
-    if [ -z "$files" ]; then
-        echo "No .db or .sub* files found in the specified folder."
-        exit 1
-    fi
-
-    # Add the files to the Makefile
-    for file in $files; do
-        echo "Adding $file to Makefile..."
-
-        # Extract the base name of the file
-        base_file="$(basename "$file")"
-
-        # Check if the file ends with ".template"
-        if [[ $base_file == *.template ]]; then
-            # If it's a template file, replace ".template" with ".db"
-            target_file="${base_file%.template}.db"
-        else
-            # If it's not a template file, use the original file name
-            target_file="$base_file"
-        fi
-
-        # Add the entry to the Makefile
-        sed -i "/^#DB += xxx.db/ a\\DB += $target_file" "$makefile_path_db"
-done
-
-}
-
-# Update Makefile with .dbd values
-update_makefile_with_dbd_values() {
-    local modules=($(yq eval '.modules | keys | .[]' "$1"))
-    local makefile_path_src="$2/${3}IOC/${3}IOCApp/src/Makefile"
-
-    # Extract .dbd values for all modules
-    local dbd_values=()
-    for ((i=${#modules[@]}-1; i>=0; i--)); do
-        local module="${modules[$i]}"
-        local dbd=$(yq e ".modules.${module}.dbd" "$1")
-
-        # Add the module to the Makefile
-        sed -i '/'"${3}_LIBS += \$(EPICS_BASE_IOC_LIBS)"'/ a\'"${3}_LIBS += ${module}" "$makefile_path_src"
-
-        # Add each value to the dbd_values array
-        IFS=' ' read -r -a dbd_values_array <<< "$dbd"
-        dbd_values+=("${dbd_values_array[@]}")
-    done
-
-    # Add lines to Makefile for each .dbd value
-    for dbd_value in "${dbd_values[@]}"; do
-        if [ -n "$dbd_value" ]; then
-            sed -i "/#${3}_DBD += xxx.dbd/ a\\${3}_DBD += $dbd_value" "$makefile_path_src"
-        fi
-    done
-}
-
-# Main script
-
-# Check if the modules file exists
-check_file_existence "$MODULES_FILE"
-
-# Fetch values for specific modules from the YAML file using yq
-IOC_INFO=$(extract_ioc_values "$MODULES_FILE")
-
-# Assign extracted YAML values to Bash variables
-IFS=',' read -r IOC_FOLDER_NAME IOC_REPO IOC_TAG IOC_USER <<< "$IOC_INFO"
-
-# Display extracted values
-echo "IOC_FOLDER_NAME: $IOC_FOLDER_NAME, IOC_REPO: $IOC_REPO"
-echo "IOC_TAG: $IOC_TAG, IOC_USER: $IOC_USER"
-
-#Retrieve and copy source files
-retrieve_and_copy_source_files "$IOC" "$IOC_REPO" "$IOC_TAG" "$IOC_FOLDER_NAME"
-
-# #Update Makefile with files from the specified folder
-update_makefile_with_files "$IOC" "$IOC_FOLDER_NAME"
-
-# #Update Makefile with .dbd values
-update_makefile_with_dbd_values "$MODULES_FILE" "$IOC" "$IOC_FOLDER_NAME"
-
-cd $IOC/${IOC_FOLDER_NAME}IOC
-make
diff --git a/install_modules.sh b/install_modules.sh
deleted file mode 100755
index 71aac3b..0000000
--- a/install_modules.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-
-# Define the input file
-MODULES_FILE="/opt/epics/modules.yml"
-
-# Check if the file exists
-if [ ! -f "$MODULES_FILE" ]; then
-    echo "Error: $MODULES_FILE not found."
-    exit 1
-fi
-
-# Load modules from the YAML file
-while IFS=": " read -r key value || [ -n "$key" ]; do
-    if [[ $key == "repo" ]]; then
-        repo=$value
-    elif [[ $key == "tag" ]]; then
-        tag=$value
-    elif [[ $key == "folder_name" ]]; then
-        folder_name=$value
-    elif [[ $key == "dbd" ]]; then
-        dbd=$value
-        # Perform actions here with the extracted values
-
-        echo "Cloning $repo with tag $tag into folder $folder_name"
-        git clone --depth 1 --recursive --branch "$tag" "$repo" "${SUPPORT}/${folder_name}"
-        if [ "$folder_name" = "asyn" ]; then
-            echo "Modifying asyn configuration"
-            sed -i '/TIRPC/s/^#//g' "${SUPPORT}/${folder_name}/configure/CONFIG_SITE"
-        fi
-        make -C ${SUPPORT}/${folder_name} -j $(nproc)
-    fi
-done < <(yq eval '.modules | to_entries | .[] | .value | to_entries | .[] | .key + ": " + .value' $MODULES_FILE)
-
-
-
-- 
GitLab