diff --git a/Automation/Scripts/tcar_expandTMarkers.sh b/Automation/Scripts/tcar_expandTMarkers.sh deleted file mode 100755 index 1cb75e4..0000000 --- a/Automation/Scripts/tcar_expandTMarkers.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar_expandTMarkers.sh -- This function standardizes construction -# of translation markers and their related expansion. As convention, -# translation markers must be set inside source files (e.g., -# Docbook, Svg, etc.) and expanded inside temporal instances used to -# produce final contents. -# -# 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_expandTMarkers { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - local COUNTSRC=0 - local COUNTDST=0 - - # Define source location on which sed replacements take place. - local LOCATION="${1}" - - # Verify that source location does exist. - tcar_checkFiles -e ${LOCATION} - - # Define copyright translation markers. - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(_LAST)?=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(S)?_LIST=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --years-list)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --holder)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --holder-predicate)" - - # Define license translation markers. - SRC[((++${#SRC[*]}))]='=LICENSE=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --license)" - SRC[((++${#SRC[*]}))]='=LICENSE_URL=' - DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --license-url)" - - # Define theme translation markers. - SRC[((++${#SRC[*]}))]='=THEME=' - DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif)" - SRC[((++${#SRC[*]}))]='=THEMENAME=' - DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif-name)" - SRC[((++${#SRC[*]}))]='=THEMERELEASE=' - DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif-release)" - - # Define release-specific translation markers. - SRC[((++${#SRC[*]}))]='=RELEASE=' - DST[((++${#DST[*]}))]="${FLAG_RELEASEVER}" - SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f1)" - SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f2)" - - # Define architectures translation markers. - SRC[((++${#SRC[*]}))]='=ARCH=' - DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${FLAG_BASEARCH} --architecture)" - - # Define url translation markers. - SRC[((++${#SRC[*]}))]='=URL=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--home' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_WIKI=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--wiki' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_LISTS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--lists' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_FORUMS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--forums' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--mirrors' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_DOCS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--docs' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_PROJECTS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--projects' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_BUGS=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--bugs' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_SVN=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--svn' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_TRAC=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--trac' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_PLANET=' - DST[((++${#DST[*]}))]=$(tcar_printUrl '--planet' '--with-locale') - - # Define emails translation markers. - SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' - DST[((++${#DST[*]}))]="$(tcar_printMailingList --docs)" - - # Define locale translation markers. - SRC[((++${#SRC[*]}))]='=LOCALE=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LC}" - SRC[((++${#SRC[*]}))]='=LOCALE_LL=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" - SRC[((++${#SRC[*]}))]='=LOCALE_CC=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_CC}" - - # Define domain translation markers for domains. - SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' - if [[ ! ${TCAR_SCRIPT_LANG_LL} =~ '^en' ]];then - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" - else - DST[((++${#DST[*]}))]="" - fi - - # Define repository translation markers. - SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_BASEDIR)=' - DST[((++${#DST[*]}))]="${TCAR_BASEDIR}" - - # Do replacement of nested translation markers. - while [[ ${COUNTDST} -lt ${#DST[@]} ]];do - - # Verify existence of translation markers. If there is no - # translation marker on replacement, continue with the next - # one in the list. - if [[ ! ${DST[${COUNTDST}]} =~ '=[A-Z_]+=' ]];then - # Increment destination counter. - COUNTDST=$((${COUNTDST} + 1)) - # The current replacement value doesn't have translation - # marker inside, so skip it and evaluate the next - # replacement value in the list. - continue - fi - - while [[ ${COUNTSRC} -lt ${#SRC[*]} ]];do - - # Update replacements. - DST[${COUNTDST}]=$(echo ${DST[${COUNTDST}]} \ - | sed -r "s!${SRC[${COUNTSRC}]}!${DST[${COUNTSRC}]}!g") - - # Increment source counter. - COUNTSRC=$((${COUNTSRC} + 1)) - - done - - # Reset source counter - COUNTSRC=0 - - # Increment destination counter. - COUNTDST=$((${COUNTDST} + 1)) - - done - - # Apply replacements for translation markers. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - - # Use sed to replace translation markers inside the design - # model instance. - sed -r -i "s!${SRC[${COUNT}]}!${DST[${COUNT}]}!g" ${LOCATION} - - # Increment counter. - COUNT=$((${COUNT} + 1)) - - done - - # Remove escaped character from translation markers. This is one - # of the reasons why translation marker should be expanded in - # source files instances not the source files themselves. - # Escaping translation markers provides a way of talking about - # them without expanding them. - sed -r -i 's/(=)\\([A-Z_]+=)/\1\2/g' ${LOCATION} - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may remain from one file to another. - unset SRC - unset DST - -} diff --git a/Automation/Scripts/tcar_exportFunctions.sh b/Automation/Scripts/tcar_exportFunctions.sh deleted file mode 100755 index 8b3c047..0000000 --- a/Automation/Scripts/tcar_exportFunctions.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar_exportFunctions.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_exportFunctions { - - # 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_getModule.sh b/Automation/Scripts/tcar_getModule.sh new file mode 100755 index 0000000..40ccee1 --- /dev/null +++ b/Automation/Scripts/tcar_getModule.sh @@ -0,0 +1,81 @@ +#!/bin/bash +###################################################################### +# +# tcar_getModule.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_getModule { + + # 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_getModuleScripts + # function calling after all variables and arguments definitions. + tcar_getModuleScripts "${MODULE_INIT_FILE}" + + # Execute function. + ${MODULE_NAME} "${@}" + +} diff --git a/Automation/Scripts/tcar_getModuleScripts.sh b/Automation/Scripts/tcar_getModuleScripts.sh new file mode 100755 index 0000000..047a3d4 --- /dev/null +++ b/Automation/Scripts/tcar_getModuleScripts.sh @@ -0,0 +1,85 @@ +#!/bin/bash +###################################################################### +# +# tcar_getModuleScripts.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_getModuleScripts { + + # 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_initModule.sh b/Automation/Scripts/tcar_initModule.sh deleted file mode 100755 index a338faa..0000000 --- a/Automation/Scripts/tcar_initModule.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar_initModule.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_initModule { - - # 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_exportFunctions - # function calling after all variables and arguments definitions. - tcar_exportFunctions "${MODULE_INIT_FILE}" - - # Execute function. - ${MODULE_NAME} "${@}" - -} diff --git a/Automation/Scripts/tcar_setTranslationMarkers.sh b/Automation/Scripts/tcar_setTranslationMarkers.sh new file mode 100755 index 0000000..77f826c --- /dev/null +++ b/Automation/Scripts/tcar_setTranslationMarkers.sh @@ -0,0 +1,190 @@ +#!/bin/bash +###################################################################### +# +# tcar_setTranslationMarkers.sh -- This function standardizes construction +# of translation markers and their related expansion. As convention, +# translation markers must be set inside source files (e.g., +# Docbook, Svg, etc.) and expanded inside temporal instances used to +# produce final contents. +# +# 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_setTranslationMarkers { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 + + # Define source location on which sed replacements take place. + local LOCATION="${1}" + + # Verify that source location does exist. + tcar_checkFiles -e ${LOCATION} + + # Define copyright translation markers. + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(_LAST)?=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(S)?_LIST=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --years-list)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --holder)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --holder-predicate)" + + # Define license translation markers. + SRC[((++${#SRC[*]}))]='=LICENSE=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --license)" + SRC[((++${#SRC[*]}))]='=LICENSE_URL=' + DST[((++${#DST[*]}))]="$(tcar_printCopyrightInfo --license-url)" + + # Define theme translation markers. + SRC[((++${#SRC[*]}))]='=THEME=' + DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif)" + SRC[((++${#SRC[*]}))]='=THEMENAME=' + DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif-name)" + SRC[((++${#SRC[*]}))]='=THEMERELEASE=' + DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${OUTPUT} --motif-release)" + + # Define release-specific translation markers. + SRC[((++${#SRC[*]}))]='=RELEASE=' + DST[((++${#DST[*]}))]="${FLAG_RELEASEVER}" + SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f1)" + SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f2)" + + # Define architectures translation markers. + SRC[((++${#SRC[*]}))]='=ARCH=' + DST[((++${#DST[*]}))]="$(tcar_getPathComponent ${FLAG_BASEARCH} --architecture)" + + # Define url translation markers. + SRC[((++${#SRC[*]}))]='=URL=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--home' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_WIKI=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--wiki' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_LISTS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--lists' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_FORUMS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--forums' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--mirrors' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_DOCS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--docs' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_PROJECTS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--projects' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_BUGS=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--bugs' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_SVN=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--svn' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_TRAC=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--trac' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_PLANET=' + DST[((++${#DST[*]}))]=$(tcar_printUrl '--planet' '--with-locale') + + # Define emails translation markers. + SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' + DST[((++${#DST[*]}))]="$(tcar_printMailingList --docs)" + + # Define locale translation markers. + SRC[((++${#SRC[*]}))]='=LOCALE=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LC}" + SRC[((++${#SRC[*]}))]='=LOCALE_LL=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" + SRC[((++${#SRC[*]}))]='=LOCALE_CC=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_CC}" + + # Define domain translation markers for domains. + SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' + if [[ ! ${TCAR_SCRIPT_LANG_LL} =~ '^en' ]];then + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" + else + DST[((++${#DST[*]}))]="" + fi + + # Define repository translation markers. + SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_BASEDIR)=' + DST[((++${#DST[*]}))]="${TCAR_BASEDIR}" + + # Do replacement of nested translation markers. + while [[ ${COUNTDST} -lt ${#DST[@]} ]];do + + # Verify existence of translation markers. If there is no + # translation marker on replacement, continue with the next + # one in the list. + if [[ ! ${DST[${COUNTDST}]} =~ '=[A-Z_]+=' ]];then + # Increment destination counter. + COUNTDST=$((${COUNTDST} + 1)) + # The current replacement value doesn't have translation + # marker inside, so skip it and evaluate the next + # replacement value in the list. + continue + fi + + while [[ ${COUNTSRC} -lt ${#SRC[*]} ]];do + + # Update replacements. + DST[${COUNTDST}]=$(echo ${DST[${COUNTDST}]} \ + | sed -r "s!${SRC[${COUNTSRC}]}!${DST[${COUNTSRC}]}!g") + + # Increment source counter. + COUNTSRC=$((${COUNTSRC} + 1)) + + done + + # Reset source counter + COUNTSRC=0 + + # Increment destination counter. + COUNTDST=$((${COUNTDST} + 1)) + + done + + # Apply replacements for translation markers. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + + # Use sed to replace translation markers inside the design + # model instance. + sed -r -i "s!${SRC[${COUNT}]}!${DST[${COUNT}]}!g" ${LOCATION} + + # Increment counter. + COUNT=$((${COUNT} + 1)) + + done + + # Remove escaped character from translation markers. This is one + # of the reasons why translation marker should be expanded in + # source files instances not the source files themselves. + # Escaping translation markers provides a way of talking about + # them without expanding them. + sed -r -i 's/(=)\\([A-Z_]+=)/\1\2/g' ${LOCATION} + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may remain from one file to another. + unset SRC + unset DST + +} diff --git a/Automation/Scripts/tcar_unsetFunctions.sh b/Automation/Scripts/tcar_unsetFunctions.sh index cc13631..5e897a3 100755 --- a/Automation/Scripts/tcar_unsetFunctions.sh +++ b/Automation/Scripts/tcar_unsetFunctions.sh @@ -34,13 +34,13 @@ function tcar_unsetFunctions { local FUNCTION_EXPORTID=$(basename "${1}") # Verify suffix value used to retrieve function files. - if [[ ${FUNCTION_EXPORTID} == '' ]];then + if [[ -z ${FUNCTION_EXPORTID} ]];then tcar_printMessage "`gettext "The export id was not provided."`" --as-error-line fi # Define list of format-specific functionalities. This is the # list of function definitions previously exported by - # `tcar_exportFunctions'. Be sure to limit the list to function + # `tcar_getModuleScripts'. 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 a62432c..9724bc2 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_initModule "${@}" + tcar_getModule "${@}" ;;