From 9c1e5e8bbc4d20beb5967153f255a6bbfb22b239 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 17 2013 01:41:23 +0000 Subject: Update filenames inside centos-art.sh script. --- diff --git a/Automation/Scripts/tcar_setModule.sh b/Automation/Scripts/tcar_setModule.sh deleted file mode 100755 index 0e9fc7a..0000000 --- a/Automation/Scripts/tcar_setModule.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar_setModule.sh -- This function initiates module environments -# inside the centos-art.sh script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -###################################################################### - -function tcar_setModule { - - # Define module's name (MODULE_NAME) using the first argument - # in the command-line. - local MODULE_NAME=$(tcar_getRepoName "${1}" "-f" | cut -d '-' -f1) - - # Define regular expression to match available modules. - local MODULE_NAME_LIST=$(ls ${TCAR_SCRIPT_MODULES_BASEDIR} \ - | tr '\n' '|' | sed -r 's/\|$//' | tr '[[:upper:]]' '[[:lower:]]') - - # Check module's name possible values. - if [[ ! ${MODULE_NAME} =~ "^(${MODULE_NAME_LIST})$" ]];then - tcar_printMessage "`gettext "The module provided isn't valid."`" --as-error-line - fi - - # Define function directory. - local MODULE_DIR=${TCAR_SCRIPT_MODULES_BASEDIR}/$(tcar_getRepoName "${MODULE_NAME}" "-d") - - # Define function file name. - local MODULE_INIT_FILE=${MODULE_DIR}/${MODULE_NAME}.sh - - # Check function script execution rights. - tcar_checkFiles -x ${MODULE_INIT_FILE} - - # Remove the first argument passed to centos-art.sh command-line - # in order to build optional arguments inside functionalities. We - # start counting from second argument (inclusive) on. - shift 1 - - # Verify number of arguments passed to centos-art.sh script. By - # default, to all modules, when no option is provided the version - # information is printed. - if [[ $# -lt 1 ]];then - tcar_printVersion - fi - - # Redefine internationalization configuration variables. - declare -x TEXTDOMAIN=${MODULE_NAME} - declare -x TEXTDOMAINDIR=${MODULE_DIR}/Locales - - # Redefine manuals configuration values. - declare -x TCAR_MANUAL_FILE=${MODULE_DIR}/${MODULE_NAME}.asciidoc - declare -x TCAR_MANUAL_SEARCHPATH=${MODULE_DIR}/Manuals - declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" - - # Go for function initialization. Keep the tcar_setModuleScripts - # function calling after all variables and arguments definitions. - tcar_setModuleScripts "${MODULE_INIT_FILE}" - - # Execute function. - ${MODULE_NAME} "${@}" - -} diff --git a/Automation/Scripts/tcar_setModuleEnvironment.sh b/Automation/Scripts/tcar_setModuleEnvironment.sh new file mode 100755 index 0000000..1a6d9fd --- /dev/null +++ b/Automation/Scripts/tcar_setModuleEnvironment.sh @@ -0,0 +1,82 @@ +#!/bin/bash +###################################################################### +# +# tcar_setModuleEnvironment.sh -- This function initiates module +# environments inside the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function tcar_setModuleEnvironment { + + # Define module's name (MODULE_NAME) using the first argument + # in the command-line. + local MODULE_NAME=$(tcar_getRepoName "${1}" "-f" | cut -d '-' -f1) + + # Define regular expression to match available modules. + local MODULE_NAME_LIST=$(ls ${TCAR_SCRIPT_MODULES_BASEDIR} \ + | tr '\n' '|' | sed -r 's/\|$//' | tr '[[:upper:]]' '[[:lower:]]') + + # Check module's name possible values. + if [[ ! ${MODULE_NAME} =~ "^(${MODULE_NAME_LIST})$" ]];then + tcar_printMessage "`gettext "The module provided isn't valid."`" --as-error-line + fi + + # Define function directory. + local MODULE_DIR=${TCAR_SCRIPT_MODULES_BASEDIR}/$(tcar_getRepoName "${MODULE_NAME}" "-d") + + # Define function file name. + local MODULE_INIT_FILE=${MODULE_DIR}/${MODULE_NAME}.sh + + # Check function script execution rights. + tcar_checkFiles -x ${MODULE_INIT_FILE} + + # Remove the first argument passed to centos-art.sh command-line + # in order to build optional arguments inside functionalities. We + # start counting from second argument (inclusive) on. + shift 1 + + # Verify number of arguments passed to centos-art.sh script. By + # default, to all modules, when no option is provided the version + # information is printed. + if [[ $# -lt 1 ]];then + tcar_printVersion + fi + + # Redefine internationalization configuration variables. + declare -x TEXTDOMAIN=${MODULE_NAME} + declare -x TEXTDOMAINDIR=${MODULE_DIR}/Locales + + # Redefine manuals configuration values. + declare -x TCAR_MANUAL_FILE=${MODULE_DIR}/${MODULE_NAME}.asciidoc + declare -x TCAR_MANUAL_SEARCHPATH=${MODULE_DIR}/Manuals + declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" + + # Go for function initialization. Keep the + # tcar_setModuleEnvironmentScripts function calling after all + # variables and arguments definitions. + tcar_setModuleEnvironmentScripts "${MODULE_INIT_FILE}" + + # Execute function. + ${MODULE_NAME} "${@}" + +} diff --git a/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh new file mode 100755 index 0000000..39c5231 --- /dev/null +++ b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh @@ -0,0 +1,85 @@ +#!/bin/bash +###################################################################### +# +# tcar_setModuleEnvironmentScripts.sh -- This function standardizes +# the way specific functionalities are exported to centos-art.sh +# script environment. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function tcar_setModuleEnvironmentScripts { + + # Retrieve export identifier for the function we want to export. + local MODULE_INIT_FILE="${1}" + + # Verify the export identification existence. + tcar_checkFiles -x ${MODULE_INIT_FILE} + + # Define the source location where function files are placed in. + local MODULE_SCRIPTS_DIR=$(dirname ${MODULE_INIT_FILE})/Scripts + + # Define suffix used to retrieve function files. + local MODULE_INIT_FILENAME=$(basename "${MODULE_INIT_FILE}" | sed -r 's/\.sh$//') + + # Define the pattern used to retrieve function names from function + # files. + local FUNCTION_PATTERN="^function[[:space:]]+${MODULE_INIT_FILENAME}(_[[:alnum:]]+)?[[:space:]]+{[[:space:]]*$" + + # Define the list of files. + local MODULE_SCRIPTS="${MODULE_INIT_FILE} + $(tcar_getFilesList ${MODULE_SCRIPTS_DIR} \ + --pattern="${MODULE_DIR}/.+\.sh$" --maxdepth='1' \ + --mindepth='1' --type='f')" + + # Verify the list of files. If no function file exists for the + # location specified stop the script execution. Otherwise the + # script will surely try to execute a function that haven't been + # exported yet and report an error about it. + if [[ -z ${MODULE_SCRIPTS} ]];then + tcar_printMessage "${FUNCNAME}: `gettext "No function file was found."`" --as-error-line + fi + + # Process the list of files. + for MODULE_SCRIPT in ${MODULE_SCRIPTS};do + + # Verify the execution rights for function file. + tcar_checkFiles -x ${MODULE_SCRIPT} + + # Verify that function files have not been already exported. + # If they have been already exported don't export them again. + # Instead, continue with the next function file in the list. + declare -F | gawk '{ print $3 }' | egrep "^${MODULE_SCRIPT}$" > /dev/null + if [[ $? -eq 0 ]];then + continue + fi + + # Initialize the function file. + . ${MODULE_SCRIPT} + + # Export the function names inside the file to current shell + # script environment. + export -f $(egrep "${FUNCTION_PATTERN}" ${MODULE_SCRIPT} | gawk '{ print $2 }') + + done + +} diff --git a/Automation/Scripts/tcar_setModuleScripts.sh b/Automation/Scripts/tcar_setModuleScripts.sh deleted file mode 100755 index 7342be9..0000000 --- a/Automation/Scripts/tcar_setModuleScripts.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar_setModuleScripts.sh -- This function standardizes the way -# specific functionalities are exported to centos-art.sh script -# environment. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -###################################################################### - -function tcar_setModuleScripts { - - # Retrieve export identifier for the function we want to export. - local MODULE_INIT_FILE="${1}" - - # Verify the export identification existence. - tcar_checkFiles -x ${MODULE_INIT_FILE} - - # Define the source location where function files are placed in. - local MODULE_SCRIPTS_DIR=$(dirname ${MODULE_INIT_FILE})/Scripts - - # Define suffix used to retrieve function files. - local MODULE_INIT_FILENAME=$(basename "${MODULE_INIT_FILE}" | sed -r 's/\.sh$//') - - # Define the pattern used to retrieve function names from function - # files. - local FUNCTION_PATTERN="^function[[:space:]]+${MODULE_INIT_FILENAME}(_[[:alnum:]]+)?[[:space:]]+{[[:space:]]*$" - - # Define the list of files. - local MODULE_SCRIPTS="${MODULE_INIT_FILE} - $(tcar_getFilesList ${MODULE_SCRIPTS_DIR} \ - --pattern="${MODULE_DIR}/.+\.sh$" --maxdepth='1' \ - --mindepth='1' --type='f')" - - # Verify the list of files. If no function file exists for the - # location specified stop the script execution. Otherwise the - # script will surely try to execute a function that haven't been - # exported yet and report an error about it. - if [[ -z ${MODULE_SCRIPTS} ]];then - tcar_printMessage "${FUNCNAME}: `gettext "No function file was found."`" --as-error-line - fi - - # Process the list of files. - for MODULE_SCRIPT in ${MODULE_SCRIPTS};do - - # Verify the execution rights for function file. - tcar_checkFiles -x ${MODULE_SCRIPT} - - # Verify that function files have not been already exported. - # If they have been already exported don't export them again. - # Instead, continue with the next function file in the list. - declare -F | gawk '{ print $3 }' | egrep "^${MODULE_SCRIPT}$" > /dev/null - if [[ $? -eq 0 ]];then - continue - fi - - # Initialize the function file. - . ${MODULE_SCRIPT} - - # Export the function names inside the file to current shell - # script environment. - export -f $(egrep "${FUNCTION_PATTERN}" ${MODULE_SCRIPT} | gawk '{ print $2 }') - - done - -} diff --git a/Automation/Scripts/tcar_unsetFunctions.sh b/Automation/Scripts/tcar_unsetFunctions.sh index e11d7ca..d9ce81e 100755 --- a/Automation/Scripts/tcar_unsetFunctions.sh +++ b/Automation/Scripts/tcar_unsetFunctions.sh @@ -40,7 +40,7 @@ function tcar_unsetFunctions { # Define list of format-specific functionalities. This is the # list of function definitions previously exported by - # `tcar_setModuleScripts'. Be sure to limit the list to function + # `tcar_setModuleEnvironmentScripts'. Be sure to limit the list to function # names that start with the suffix specified only. local FUNCTION_DEF='' local FUNCTION_DEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${FUNCTION_EXPORTID}") diff --git a/Automation/centos-art.sh b/Automation/centos-art.sh index effaed7..f862691 100755 --- a/Automation/centos-art.sh +++ b/Automation/centos-art.sh @@ -90,7 +90,7 @@ case ${1} in trap tcar_terminateScriptExecution 0 # Export script's module environment. - tcar_setModule "${@}" + tcar_setModuleEnvironment "${@}" ;;