From 786ac08e2d0947472e93ddbc11f7641b3e27a03c Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 06 2013 00:54:23 +0000 Subject: Update automation scripts directory structure. --- diff --git a/Automation/Manuals/centos-art.sh-locale.asciidoc b/Automation/Manuals/centos-art.sh-locale.asciidoc index 0850f63..0c6e85f 100644 --- a/Automation/Manuals/centos-art.sh-locale.asciidoc +++ b/Automation/Manuals/centos-art.sh-locale.asciidoc @@ -3,21 +3,88 @@ centos-art.sh-locale(1) Name ---- -centos-art.sh-locale - hello +centos-art.sh-locale - Retrieve, edit and delete translation files for +images, documents and automation scripts. Synopsis -------- -centos-art.sh locale DIRECTORY [OPTIONS] + +centos-art.sh locale [OPTIONS] [DIRECTORY ...|FILE ...] Description ----------- -hi +The *locale* produces translations files for images, documents and +automation scripts based on the current locale information. In order +to produce locale-specific translation files, the current language +information set by the LANG environment variable must be different to +English (`en'). If the current language is English, the *locale* +module ends its execution with an error message. When the current +language is different to English, the *locale* looks for source files, +based on the arguments you passed through the command-line. + +When the argument you provided is a ``DIRECTORY'', the *locale* module +looks for configuration files inside it and produces translation files +based on the *render-from* and *locale-from* variables set in there. +On the other hand, when a ``FILE'' is provided, it takes the file +extension (i.e., the characters after the last dot in the file name) +and looks recursively in the file's directory for all the files that +have the same file extension the ``FILE'' does, and builds the list of +source files that will be used to produce the translation files. In +this case, the translation files are stored in a ``Locales'' +directory, at the same level of the ``FILE'' you provided as argument +to *locale* module's command-line. + +Translation files are the files we use to store translatable strings. +These files can be either portable objects (`.po'), machine objects +(`.po') or portable object templates (`.pot'). Machine objects are +built from portable objects. Portable objects are built from portable +object templates (`.pot'). Portable object templates are built using +*xgettext* or *xml2po* programs, according to the source files you are +retrieving translatable strings from. From these files, portable +objects (`.po') are used by *render* module to produce both localized +images and localized documentation while machine objects (`.mo') are +used by *gettext* program to produce localized output messages from +automation scripts. + +Options +------- + +The *locale* module accepts the following options: + +*-h, --help*:: +*--filter="REGEX"*:: + When ``DIRECTORY'' is passed as argument, this option reduces the + number of section blocks inside configuration files the *locale* + module will take for processing by using the ``REGEX'' value is a + regular expression pattern to match one or more section names + inside the configuration files found under ``DIRECTORY''. When + ``FILE'' is passed as argument, in the other hand, it limits the + number of files that will be set in the list of source files used + to build the final translation files. +*--update*:: +*--edit*:: +*--delete*:: + +Localizing Image Files +---------------------- + +Hi + +Localizing Documentation Files +------------------------------ + +Hi + +Localizing Automation Scripts +----------------------------- + +Hi Author ------ -Written by Alain Reguera Delgado +Written by mailto:al@centos.org.cu[Alain Reguera Delgado] Copyright --------- @@ -38,4 +105,9 @@ 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. +See Also +-------- + +centos-art.sh(1), centos-art.sh-render(1), gettext(1) + // vim: set syntax=asciidoc: diff --git a/Automation/Manuals/render.conf b/Automation/Manuals/render.conf index c0b6156..7171b13 100644 --- a/Automation/Manuals/render.conf +++ b/Automation/Manuals/render.conf @@ -2,7 +2,7 @@ render-type = "asciidoc" render-flow = "manpage" render-from = "centos-art.sh-render.asciidoc" -locale-from = "${TCAR_SCRIPT_LANG_LC}/$(basename ${TARGET}).po" +locale-from = "${TCAR_SCRIPT_LANG_LC}/centos-art.sh-render.po" formats = "xhtml manpage" mansect = "1" @@ -10,6 +10,6 @@ mansect = "1" render-type = "asciidoc" render-flow = "manpage" render-from = "centos-art.sh-locale.asciidoc" -locale-from = "${TCAR_SCRIPT_LANG_LC}/$(basename ${TARGET}).po" +locale-from = "${TCAR_SCRIPT_LANG_LC}/centos-art.sh-locale.po" formats = "xhtml manpage" mansect = "1" diff --git a/Automation/Modules/Locale/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Delete/delete.sh index b6a44f3..162b823 100755 --- a/Automation/Modules/Locale/Modules/Delete/delete.sh +++ b/Automation/Modules/Locale/Modules/Delete/delete.sh @@ -6,6 +6,7 @@ function delete { for TRANSLATION in ${TRANSLATIONS[*]};do tcar_printMessage "${TRANSLATION}" --as-deleting-line + tcar_checkFiles -ef ${TRANSLATION} /bin/rm ${TRANSLATION} done diff --git a/Automation/Modules/Locale/Modules/Edit/edit.sh b/Automation/Modules/Locale/Modules/Edit/edit.sh index 06913a7..3951411 100755 --- a/Automation/Modules/Locale/Modules/Edit/edit.sh +++ b/Automation/Modules/Locale/Modules/Edit/edit.sh @@ -6,6 +6,7 @@ function edit { for TRANSLATION in ${TRANSLATIONS[*]};do tcar_printMessage "${TRANSLATION}" --as-editing-line + tcar_checkFiles -ef "${TRANSLATION}" ${TCAR_USER_EDITOR} ${TRANSLATION} done diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh index 439d1a6..793dc16 100755 --- a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh +++ b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh @@ -50,7 +50,7 @@ function asciidoc { # Verify, initialize or merge portable objects from portable # object templates. - locale_updateMessagePObjects "${POT_FILE}" + locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" done diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh b/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh new file mode 100755 index 0000000..d063500 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Modules/Locale/Modules/Update/Modules/Sh/sh.sh -- This function +# parses shell scripts source files under action value and retrieves +# translatable strings in order to creates/updates both the portable +# object template (.pot) and the portable object (.po) related. +# +# Written by: +# * Alain Reguera Delgado +# +# 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 sh { + + # Print action message. + tcar_printMessage "${POT_FILE}" --as-updating-line + + # Retrieve translatable strings from shell script files and create + # the portable object template (.pot) from them. + xgettext --output=${POT_FILE} --width=70 \ + --package-name=${TCAR_SCRIPT_NAME} \ + --package-version=${TCAR_SCRIPT_VERSION} \ + --msgid-bugs-address="centos-l10n-${TCAR_SCRIPT_LANG_LL}@centos.org.cu" \ + --copyright-holder="$(tcar_printCopyrightInfo --holder)" \ + --sort-by-file ${SOURCES[*]} + + # Verify, initialize or update portable objects from portable + # object templates. + locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" + + # At this point some changes might be realized inside the PO file, + # so we need to update the related MO file based on recently + # updated PO files here in order for `centos-art.sh' script to + # print out the most up to date revision of localized messages. + # Notice that this is required only if we were localizing shell + # scripts. + locale_updateMessageBinary + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh index 58fced2..f5e6ffe 100755 --- a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh +++ b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh @@ -48,7 +48,7 @@ function svg { # Verify, initialize or merge portable objects from portable # object templates. - locale_updateMessagePObjects "${POT_FILE}" + locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" done diff --git a/Automation/Modules/Locale/locale.sh b/Automation/Modules/Locale/locale.sh index b896fc4..9f639c1 100755 --- a/Automation/Modules/Locale/locale.sh +++ b/Automation/Modules/Locale/locale.sh @@ -42,32 +42,17 @@ function locale { tcar_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line fi - # Process directories passed as arguments. - for DIRECTORY in "$@";do - - # Sanitate non-option arguments to be sure they match the - # directory conventions established by centos-art.sh script - # against source directory locations in the working copy. - DIRECTORY=$(tcar_checkRepoDirSource ${DIRECTORY}) - - # Retrieve list of configuration files from directory. - CONFIGURATIONS=$(tcar_getFilesList ${DIRECTORY} \ - --pattern=".+/.+\.conf$" --type="f") - - # Verify non-option arguments passed to centos-art.sh - # command-line. The path provided as argument must exist in - # the repository. Otherwise, it would be possible to create - # arbitrary directories inside the repository without any - # meaning. In order to be sure all required directories are - # available in the repository it is necessary use the prepare - # functionality. - tcar_checkFiles ${CONFIGURATIONS} -f - - # Process each configuration file. - for CONFIGURATION in ${CONFIGURATIONS};do - locale_setLocaleType "${@}" - done - + # Process arguments based on whether they are files or + # directories. + for ARGUMENT in ${@};do + ARGUMENT=$(tcar_checkRepoDirSource "${ARGUMENT}") + if [[ -f ${ARGUMENT} ]];then + locale_setFileProcessing "${ARGUMENT}" + elif [[ -d ${ARGUMENT} ]];then + locale_setDirProcessing "${ARGUMENT}" + else + tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line + fi done } diff --git a/Automation/Modules/Locale/locale_getOptions.sh b/Automation/Modules/Locale/locale_getOptions.sh index 5da74fb..9eb3d34 100755 --- a/Automation/Modules/Locale/locale_getOptions.sh +++ b/Automation/Modules/Locale/locale_getOptions.sh @@ -1,8 +1,12 @@ #!/bin/bash +###################################################################### # -# locale_getOptions.sh -- This function interprets option parameters -# passed to `locale' functionality and defines action names -# accordingly. +# locale_getOptions.sh -- This function interprets option parameters +# passed to `locale' functionality and defines action names +# accordingly. +# +# Written by: +# * Alain Reguera Delgado # # Copyright (C) 2009-2013 The CentOS Project # @@ -20,9 +24,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function locale_getOptions { diff --git a/Automation/Modules/Locale/locale_setDirProcessing.sh b/Automation/Modules/Locale/locale_setDirProcessing.sh new file mode 100755 index 0000000..4bcc369 --- /dev/null +++ b/Automation/Modules/Locale/locale_setDirProcessing.sh @@ -0,0 +1,26 @@ +#!/bin/bash +function locale_setDirProcessing { + + # Sanitate non-option arguments to be sure they match the + # directory conventions established by centos-art.sh script + # against source directory locations in the working copy. + local DIRECTORY=$(tcar_checkRepoDirSource ${1}) + + # Retrieve list of configuration files from directory. + local CONFIGURATIONS=$(tcar_getFilesList ${DIRECTORY} \ + --pattern=".+/.+\.conf$" --type="f") + + # Verify non-option arguments passed to centos-art.sh + # command-line. The path provided as argument must exist in the + # repository. Otherwise, it would be possible to create arbitrary + # directories inside the repository without any meaning. In order + # to be sure all required directories are available in the + # repository it is necessary use the prepare functionality. + tcar_checkFiles -ef ${CONFIGURATIONS} + + # Process each configuration file. + for CONFIGURATION in ${CONFIGURATIONS};do + locale_setLocaleType "${@}" + done + +} diff --git a/Automation/Modules/Locale/locale_setFileProcessing.sh b/Automation/Modules/Locale/locale_setFileProcessing.sh new file mode 100755 index 0000000..1ff2c70 --- /dev/null +++ b/Automation/Modules/Locale/locale_setFileProcessing.sh @@ -0,0 +1,40 @@ +#!/bin/bash +function locale_setFileProcessing { + + local FILE=$(tcar_checkRepoDirSource "${1}") + + local FILE_NAME="$(basename ${FILE})" + + local FILE_EXTENSION=$(echo ${FILE} | sed -r 's/.+\.([[:alnum:]]+)$/\1/') + + local DIRECTORY=$(dirname ${FILE}) + + local RENDER_FROM=$(tcar_getFilesList ${DIRECTORY} \ + --pattern="^.+/.+\.${FILE_EXTENSION}$" --type="f") + + local LOCALE_FROM=${DIRECTORY}/Locales + + local POT_FILE=${LOCALE_FROM}/${FILE_NAME}.pot + local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${FILE_NAME}.po + local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${FILE_NAME}.mo + + # The locale's modules require specific environment variables we + # need to define here in order for such modules to work as + # expected. From this point on we set such variables using the + # information set above. + + local RENDER_TYPE=${FILE_EXTENSION} + + local -a TRANSLATIONS + TRANSLATIONS[0]=${PO_FILE} + + for SOURCE in ${RENDER_FROM};do + SOURCES[((++${#SOURCES[*]}))]=${SOURCE} + done + + # Initialize locale's action modules. + for LOCALE_ACTION in ${LOCALE_ACTIONS};do + tcar_setModuleEnvironment "${LOCALE_ACTION}" "${@}" + done + +} diff --git a/Automation/Modules/Locale/locale_setLocaleType.sh b/Automation/Modules/Locale/locale_setLocaleType.sh index 62f0b40..77c4190 100755 --- a/Automation/Modules/Locale/locale_setLocaleType.sh +++ b/Automation/Modules/Locale/locale_setLocaleType.sh @@ -42,7 +42,7 @@ function locale_setLocaleType { SOURCES[((++${#SOURCES[*]}))]=$(dirname ${CONFIGURATION})/${SOURCE} fi done - + local RENDER_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type") if [[ -z ${RENDER_TYPE} ]];then RENDER_TYPE=$(echo ${SOURCES[0]} | sed -r 's/.+\.([[:alpha:]]+)$/\1/') @@ -62,6 +62,8 @@ function locale_setLocaleType { RENDER_FLOW='article' fi + PO_FILE=${TRANSLATIONS[0]} + # Initialize locale's modules. for LOCALE_ACTION in ${LOCALE_ACTIONS};do tcar_setModuleEnvironment "${LOCALE_ACTION}" "${@}" diff --git a/Automation/Modules/Locale/locale_updateMessageBinary.sh b/Automation/Modules/Locale/locale_updateMessageBinary.sh index 7085e97..10bfeb9 100755 --- a/Automation/Modules/Locale/locale_updateMessageBinary.sh +++ b/Automation/Modules/Locale/locale_updateMessageBinary.sh @@ -25,39 +25,13 @@ function locale_updateMessageBinary { - # Verify machine object creation flag. - if [[ ${FLAG_DONT_CREATE_MO} == 'true' ]];then - return - fi - - # Define absolute path to final portable object. This is the file - # that contains all the individual function translation messages - # and is used to build the machine object (.mo) file. - local PO_FILE=${TRANSLATION[0]} - - # Define absolute path to machine object directory. - local MO_DIR="$(dirame ${CONFIGURATION})/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES" - - # Define absolute path to machine object file. - local MO_FILE="${MO_DIR}/${TEXTDOMAIN}.mo" - - # Print action message. - cli_printMessage "${PO_FILE}" --as-creating-line - - # Combine all the function individual portable objects into just - # one portable object. Be sure to use just the first translation - # found, otherwise the automated flow will be broken for you to - # decide which one of two or more variants should remain in the - # portable object. - msgcat ${PO_FILES} --use-first --output-file=${PO_FILE} - # Print action message. - cli_printMessage "${MO_FILE}" --as-creating-line + tcar_printMessage "${MO_FILE}" --as-creating-line # Verify absolute path to machine object directory, if it doesn't # exist create it. - if [[ ! -d ${MO_DIR} ]];then - mkdir -p ${MO_DIR} + if [[ ! -d $(dirname ${MO_FILE}) ]];then + mkdir -p $(dirname ${MO_FILE}) fi # Create machine object from portable object. diff --git a/Automation/Modules/Locale/locale_updateMessageMetadata.sh b/Automation/Modules/Locale/locale_updateMessageMetadata.sh index be07ab6..2dea683 100755 --- a/Automation/Modules/Locale/locale_updateMessageMetadata.sh +++ b/Automation/Modules/Locale/locale_updateMessageMetadata.sh @@ -37,7 +37,7 @@ function locale_updateMessageMetadata { local PO_FILE="${1}" # Check existence of file before work with it. - tcar_checkFiles "${PO_FILE}" -f + tcar_checkFiles -ef "${PO_FILE}" # Define pattern lines. The pattern lines are put inside portable # objects through xgettext and xml2po commands. In the case of @@ -45,37 +45,25 @@ function locale_updateMessageMetadata { # or refer the Documentation SIG only. This way translators' names # will survive metadata updates. We don't want they have to type # their name each time they edit a file. - SRC[0]="\"Project-Id-Version:" - SRC[1]="\"Report-Msgid-Bugs-To:" - SRC[2]="\"Last-Translator: (.+)?" - SRC[3]="\"Language-Team:" - SRC[4]="\"PO_FILE-Revision-Date:" + SRC[0]="\"Project-Id-Version: (.+)?" + SRC[1]="\"Last-Translator: (.+)?" + SRC[2]="\"Language-Team: (.+)?" + SRC[3]="\"PO-Revision-Date: (.+)?" # Define replacement lines for pattern line. DST[0]="\"Project-Id-Version: ${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}\\\n\"" - DST[1]="\"Report-Msgid-Bugs-To: Documentation SIG \\\n\"" - DST[2]="\"Last-Translator: Documentation SIG \\\n\"" - DST[3]="\"Language-Team: $(locale_getLanguageName)\\\n\"" - DST[4]="\"PO_FILE-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" + DST[1]="\"Last-Translator: Localization SIG \\\n\"" + DST[2]="\"Language-Team: $(locale_getLanguageName)\\\n\"" + DST[3]="\"PO-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" # Change pattern lines with their replacement lines. - while [[ $COUNT -lt ${#SRC[*]} ]];do - sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${PO_FILE} - COUNT=$(($COUNT + 1)) + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + sed -i -r "/${SRC[${COUNT}]}/c${DST[${COUNT}]}" ${PO_FILE} + COUNT=$((${COUNT} + 1)) done - # When the .pot file is created using xml2po the - # `Report-Msgid-Bugs-To:' metadata field isn't created like it - # does when xgettext is used. So, in order to have such metadata - # field in all .pot files, verify its existence and add it if it - # doesn't exist. - egrep "^\"${SRC[1]}" ${PO_FILE} > /dev/null - if [[ $? -ne 0 ]];then - sed -i -r "/^\"${SRC[0]}/a${DST[1]}" ${PO_FILE} - fi - # Replace package information using gettext domain information. - sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}/g" ${PO_FILE} + sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME}-${TCAR_SCRIPT_VERSION}/g" ${PO_FILE} # Remove absolute path to the working copy so it doesn't appear on # comments related to locations. Remember that people can download diff --git a/Automation/Modules/Locale/locale_updateMessagePObjects.sh b/Automation/Modules/Locale/locale_updateMessagePObjects.sh index 0261b9f..664e0e8 100755 --- a/Automation/Modules/Locale/locale_updateMessagePObjects.sh +++ b/Automation/Modules/Locale/locale_updateMessagePObjects.sh @@ -31,14 +31,12 @@ function locale_updateMessagePObjects { local POT_FILE="${1}" + local PO_FILE="${2}" # Verify the portable object template. The portable object # template is used to create the portable object. We cannot # continue without it. - tcar_checkFiles ${POT_FILE} -f - - # Define PO's location using first translation file as reference. - local PO_FILE=${TRANSLATIONS[0]} + tcar_checkFiles -ef ${POT_FILE} # Create the PO's parent directory if it doesn't exist. if [[ ! -d $(dirname ${PO_FILE}) ]];then diff --git a/Automation/Modules/Locale/locale_updateMessageShell.sh b/Automation/Modules/Locale/locale_updateMessageShell.sh deleted file mode 100755 index ad7614f..0000000 --- a/Automation/Modules/Locale/locale_updateMessageShell.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageShell.sh -- This function parses shell scripts -# source files under action value and retrives translatable strings in -# order to creates/updates both the portable object template (.pot) -# and the portable object (.po) related. -# -# 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageShell { - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Define regular expression to match extensions of shell scripts - # we use inside the repository. - local EXTENSION='sh' - - # Define list of absolute paths to function directories. - local FNDIRS=$(cli_getFilesList ${ACTIONVAL}/Functions \ - --maxdepth=1 --mindepth=1 --type='d' --pattern="${ACTIONVAL}/${FLAG_FILTER}") - - for FNDIR in $FNDIRS;do - - # Define absolute path to directory used as reference to store - # portable objects. - local L10N_WORKDIR=$(cli_getLocalizationDir "${FNDIR}") - - # Prepare working directory to receive translation files. - locale_prepareWorkingDirectory ${L10N_WORKDIR} - - # Define absolute path to file used as reference to create - # portable objects. - local MESSAGES="${L10N_WORKDIR}/messages" - - # Print action message. - cli_printMessage "${MESSAGES}.pot" --as-updating-line - - # Build list of files to process. When you build the pattern, - # be sure the value passed through `--filter' will be exactly - # evaluated with the extension as prefix. Otherwise it would - # be difficult to match files that share the same characters - # in their file names (e.g., it would be difficult to match - # only `hello.sh' if `hello-world.sh' also exists in the same - # location). - local FILES=$(cli_getFilesList ${FNDIR} --pattern="^.+\.${EXTENSION}$") - - # Retrieve translatable strings from shell script files and - # create the portable object template (.pot) from them. - xgettext --output=${MESSAGES}.pot \ - --copyright-holder="$(cli_printCopyrightInfo --holder)" \ - --width=70 --sort-by-file ${FILES} - - # Sanitate metadata inside the POT file. - locale_updateMessageMetadata "${MESSAGES}.pot" - - # Verify, initialize or update portable objects from portable - # object templates. - locale_updateMessagePObjects "${MESSAGES}" - - done - - # At this point some changes might be realized inside the PO file, - # so we need to update the related MO file based on recently - # updated PO files here in order for `centos-art.sh' script to - # print out the most up to date revision of localized messages. - # Notice that this is required only if we were localizaing shell - # scripts. - locale_updateMessageBinary - -} diff --git a/Automation/Modules/Render/Modules/Archive/archive.sh b/Automation/Modules/Render/Modules/Archive/archive.sh index 8b70141..1a1a91f 100755 --- a/Automation/Modules/Render/Modules/Archive/archive.sh +++ b/Automation/Modules/Render/Modules/Archive/archive.sh @@ -37,7 +37,7 @@ function archive { # Let file names to be changed before compressing them. for SOURCE in ${SOURCES[*]};do FILE_LH=$(echo ${SOURCE} | gawk -F: '{ print $1}') - tcar_checkFiles ${FILE_LH} -f + tcar_checkFiles -ef ${FILE_LH} FILE_RH=$(echo ${SOURCE} | gawk -F: '{ print $2}') cp ${FILE_LH} ${TCAR_SCRIPT_TEMPDIR}/${FILE_RH} done diff --git a/Automation/Modules/Render/Modules/Asciidoc/Modules/Manpage/manpage.sh b/Automation/Modules/Render/Modules/Asciidoc/Modules/Manpage/manpage.sh index e5e7ae7..bb2b4c7 100755 --- a/Automation/Modules/Render/Modules/Asciidoc/Modules/Manpage/manpage.sh +++ b/Automation/Modules/Render/Modules/Asciidoc/Modules/Manpage/manpage.sh @@ -4,11 +4,11 @@ function manpage { local MANSECT=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "mansect") - tcar_checkFiles ${MANSECT} --match='[1-9]' + tcar_checkFiles -m '[1-9]' "${MANSECT}" for FORMAT in ${FORMATS};do - tcar_checkFiles ${FORMAT} --match='(xhtml|manpage)' + tcar_checkFiles -m '(xhtml|manpage)' "${FORMAT}" case ${FORMAT} in diff --git a/Automation/Modules/Render/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Render/Modules/Asciidoc/asciidoc.sh index 89cfef4..d2ab7d7 100755 --- a/Automation/Modules/Render/Modules/Asciidoc/asciidoc.sh +++ b/Automation/Modules/Render/Modules/Asciidoc/asciidoc.sh @@ -32,7 +32,7 @@ function asciidoc { if [[ -z ${RENDER_FLOW} ]];then RENDER_FLOW="article" fi - tcar_checkFiles "${RENDER_FLOW}" --match='^(article|book|manpage)$' + tcar_checkFiles -m '^(article|book|manpage)$' "${RENDER_FLOW}" FORMATS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'formats') if [[ -z ${FORMATS} ]];then diff --git a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRendition.sh b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRendition.sh index d08a659..713ec4e 100755 --- a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRendition.sh +++ b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRendition.sh @@ -32,7 +32,7 @@ function asciidoc_setBaseRendition { while [[ ${COUNTER} -lt ${#SOURCES[*]} ]];do - tcar_checkFiles "${SOURCES[${COUNTER}]}" -f --match='\.asciidoc$' + tcar_checkFiles -ef -m '\.asciidoc$' "${SOURCES[${COUNTER}]}" # Define file name for design model instances. We need to use # a random string in from of it to prevent duplication. @@ -57,7 +57,7 @@ function asciidoc_setBaseRendition { # Make your best to be sure the source instance you are # processing is a valid DocBook file. - tcar_checkFiles ${TARGET_INSTANCES[${COUNTER}]} --mime='^text/xml$' + tcar_checkFiles -i 'text/xml' ${TARGET_INSTANCES[${COUNTER}]} # Expand any translation file that might exist. tcar_setTranslationMarkers ${TARGET_INSTANCES[${COUNTER}]} diff --git a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh index 27656b7..c18457c 100755 --- a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh +++ b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh @@ -28,7 +28,7 @@ function asciidoc_setBaseRenditionCommand { - tcar_checkFiles ${RENDER_TYPE} --match="^(article|book|manpage)$" + tcar_checkFiles -m '^(article|book|manpage)$' ${RENDER_TYPE} asciidoc --backend docbook --doctype ${RENDER_TYPE} -o ${TARGET} diff --git a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh index 855664c..74378e4 100755 --- a/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh +++ b/Automation/Modules/Render/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh @@ -4,11 +4,11 @@ function asciidoc_setXhtmlRendition { local TARGET="${1}" - RENDER_PAGE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-page") + RENDER_PAGES=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-page") if [[ -z ${RENDER_PAGE} ]];then RENDER_PAGE='single' fi - tcar_checkFiles ${RENDER_PAGE} --match='^(single|chunks)$' + tcar_checkFiles -m '^(single|chunks)$' "${RENDER_PAGE}" IMAGES_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "images-from") if [[ -z ${IMAGES_FROM} ]];then @@ -20,24 +20,29 @@ function asciidoc_setXhtmlRendition { STYLES_FROM="${TCAR_BASEDIR}/Artworks/Webenv/Docbook/1.69.1/Css" fi + # When producing chunks, take into consideration that both single + # and chunks share images produced in the root location. If we + # create another level of directories to store chunks, that would + # make impossible to use one unique image path for both single and + # chunks from one unique asciidoc document. So, to reuse image + # files, produce both chunks and single XHTML output in the same + # directory. if [[ ${RENDER_PAGE} == 'chunks' ]];then - TARGET="${TARGET}/" - if [[ ! -d ${TARGET} ]];then - mkdir -p ${TARGET} - fi - ln -sfn ${IMAGES_FROM} ${TARGET}/Images - ln -sfn ${STYLES_FROM} ${TARGET}/Css - else - if [[ ! -d $(dirname ${TARGET}) ]];then - mkdir -p $(dirname ${TARGET}) - fi - ln -sfn ${IMAGES_FROM} $(dirname ${TARGET})/Images - ln -sfn ${STYLES_FROM} $(dirname ${TARGET})/Css + TARGET="$(dirname ${TARGET})/" fi + if [[ ! -d $(dirname ${TARGET}) ]];then + mkdir -p $(dirname ${TARGET}) + fi + + ln -sfn ${IMAGES_FROM} $(dirname ${TARGET})/Images + ln -sfn ${STYLES_FROM} $(dirname ${TARGET})/Css + tcar_printMessage "${TARGET}" --as-creating-line - /usr/bin/xsltproc -o ${TARGET} --nonet \ - ${DOCBOOK_XSL}/docbook2xhtml-${RENDER_PAGE}.xsl ${DOCBOOK_FILE} + for RENDER_PAGE in ${RENDER_PAGES};do + /usr/bin/xsltproc -o ${TARGET} --nonet \ + ${DOCBOOK_XSL}/docbook2xhtml-${RENDER_PAGE}.xsl ${DOCBOOK_FILE} + done } diff --git a/Automation/Modules/Render/Modules/Compress/compress.sh b/Automation/Modules/Render/Modules/Compress/compress.sh index 7f2439e..1c3488a 100755 --- a/Automation/Modules/Render/Modules/Compress/compress.sh +++ b/Automation/Modules/Render/Modules/Compress/compress.sh @@ -34,7 +34,7 @@ function compress { COMMAND="/bin/gzip" fi - tcar_checkFiles ${SOURCES[*]} -f + tcar_checkFiles -ef ${SOURCES[*]} ${COMMAND} ${SOURCES[*]} diff --git a/Automation/Modules/Render/Modules/Images/images.sh b/Automation/Modules/Render/Modules/Images/images.sh index 61d7a70..2e7f348 100755 --- a/Automation/Modules/Render/Modules/Images/images.sh +++ b/Automation/Modules/Render/Modules/Images/images.sh @@ -31,7 +31,7 @@ function images { - tcar_checkFiles ${SOURCE[*]} --mime="^image" + tcar_checkFiles -i "image" ${SOURCE[*]} COMMAND=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "command") if [[ -z ${COMMAND} ]];then diff --git a/Automation/Modules/Render/Modules/Palette/palette_checkColorFormat.sh b/Automation/Modules/Render/Modules/Palette/palette_checkColorFormat.sh index d4a6c7f..a471f85 100755 --- a/Automation/Modules/Render/Modules/Palette/palette_checkColorFormat.sh +++ b/Automation/Modules/Render/Modules/Palette/palette_checkColorFormat.sh @@ -34,7 +34,7 @@ function palette_checkColorFormats { # Loop through colors and perform format verification as specified # by pattern. for COLOR in ${PALETTE_COLORS};do - tcar_checkFiles ${COLOR} --match='#[0-9a-f]{6}$' + tcar_checkFiles -m '^#[0-9a-f]{6}$' "${COLOR}" done } diff --git a/Automation/Modules/Render/Modules/Palette/palette_convertGplToPpm.sh b/Automation/Modules/Render/Modules/Palette/palette_convertGplToPpm.sh index 7e4e832..53d0a3d 100755 --- a/Automation/Modules/Render/Modules/Palette/palette_convertGplToPpm.sh +++ b/Automation/Modules/Render/Modules/Palette/palette_convertGplToPpm.sh @@ -48,6 +48,6 @@ function palette_convertGplToPpm { rm ${FILES[*]} # Verify PPM palette existence. - tcar_checkFiles -e "${PALETTE_PPM}" + tcar_checkFiles -ef "${PALETTE_PPM}" } diff --git a/Automation/Modules/Render/Modules/Svg/Modules/Extended/extended.sh b/Automation/Modules/Render/Modules/Svg/Modules/Extended/extended.sh index d740c6c..feeb1ee 100755 --- a/Automation/Modules/Render/Modules/Svg/Modules/Extended/extended.sh +++ b/Automation/Modules/Render/Modules/Svg/Modules/Extended/extended.sh @@ -68,17 +68,17 @@ function extended { for FGCOLOR in ${FGCOLORS};do # Verify value passed as foreground color. - tcar_checkFiles ${FGCOLOR} --match="^[a-fA-F0-9]{3,6}$" + tcar_checkFiles -m '^[a-fA-F0-9]{3,6}$' ${FGCOLOR} for BGCOLOR in ${BGCOLORS};do # Verify value passed as background color. - tcar_checkFiles ${BGCOLOR} --match="^[a-fA-F0-9]{6}-(0|1)$" + tcar_checkFiles -m '^[a-fA-F0-9]{6}-(0|1)$' ${BGCOLOR} for HEIGHT in ${HEIGHTS};do # Verify value passed as height. - tcar_checkFiles ${HEIGHT} --match="^[[:digit:]]+$" + tcar_checkFiles -m '^[[:digit:]]+$' ${HEIGHT} # Do base rendition actions. extended_setBaseRendition diff --git a/Automation/Modules/Render/Modules/Svg/svg_checkModelAbsref.sh b/Automation/Modules/Render/Modules/Svg/svg_checkModelAbsref.sh index 3e98a6d..94af11c 100755 --- a/Automation/Modules/Render/Modules/Svg/svg_checkModelAbsref.sh +++ b/Automation/Modules/Render/Modules/Svg/svg_checkModelAbsref.sh @@ -51,7 +51,7 @@ function svg_checkModelAbsref { FILE="${1}" # Verify existence of file we need to retrieve absolute paths from. - tcar_checkFiles -e "${FILE}" + tcar_checkFiles -ef "${FILE}" # Retrieve absolute paths from file. BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" ${FILE} \ @@ -134,7 +134,7 @@ function svg_checkModelAbsref { ${BG_SRC_FILE} ${BG_DST_FILE} # Verify required background information. - tcar_checkFiles -e ${BG_DST_FILE} + tcar_checkFiles -ef ${BG_DST_FILE} fi diff --git a/Automation/Modules/Render/Modules/Svg/svg_checkModelExportId.sh b/Automation/Modules/Render/Modules/Svg/svg_checkModelExportId.sh index 42ba0f3..2daed11 100755 --- a/Automation/Modules/Render/Modules/Svg/svg_checkModelExportId.sh +++ b/Automation/Modules/Render/Modules/Svg/svg_checkModelExportId.sh @@ -32,10 +32,10 @@ function svg_checkModelExportId { local EXPORTID="$2" # Verify instance. - tcar_checkFiles -e ${INSTANCE} + tcar_checkFiles -ef ${INSTANCE} # Verify export id. - tcar_checkFiles ${EXPORTID} --match="[[:alnum:]]+" + tcar_checkFiles -m '[[:alnum:]]+' ${EXPORTID} # Check export id inside design templates. grep "id=\"${EXPORTID}\"" ${INSTANCE} > /dev/null diff --git a/Automation/Modules/Render/Modules/Svg/svg_setBaseRendition.sh b/Automation/Modules/Render/Modules/Svg/svg_setBaseRendition.sh index 47d980c..8191211 100755 --- a/Automation/Modules/Render/Modules/Svg/svg_setBaseRendition.sh +++ b/Automation/Modules/Render/Modules/Svg/svg_setBaseRendition.sh @@ -38,7 +38,7 @@ function svg_setBaseRendition { while [[ ${COUNTER} -lt ${#SOURCES[*]} ]];do # Verify existence and extension of design models. - tcar_checkFiles ${SOURCES[${COUNTER}]} -f --match='\.(svgz|svg)$' + tcar_checkFiles -ef -m '\.(svgz|svg)$' ${SOURCES[${COUNTER}]} # Define file name for design model instances. We need to use # a random string in from of it to prevent duplication. @@ -59,7 +59,7 @@ function svg_setBaseRendition { # Make your best to be sure the source instance you are # processing is a valid Scalable Vector Graphic (SVG) file. - tcar_checkFiles ${SOURCE_INSTANCES[${COUNTER}]} --mime='^text/xml$' + tcar_checkFiles -i 'text/xml' ${SOURCE_INSTANCES[${COUNTER}]} # Expand any translation file that might exist. tcar_setTranslationMarkers ${SOURCE_INSTANCES[${COUNTER}]} diff --git a/Automation/Modules/Render/Modules/Svg/svg_setBrandInformation.sh b/Automation/Modules/Render/Modules/Svg/svg_setBrandInformation.sh index 68f5c39..f72ed8c 100755 --- a/Automation/Modules/Render/Modules/Svg/svg_setBrandInformation.sh +++ b/Automation/Modules/Render/Modules/Svg/svg_setBrandInformation.sh @@ -33,7 +33,7 @@ function svg_setBrandInformation { local FILENAME=$(echo ${BRAND} | cut -d: -f1) local GEOMETRY=$(echo ${BRAND} | cut -d: -f2) - tcar_checkFiles ${FILENAME} -f + tcar_checkFiles -ef ${FILENAME} /usr/bin/composite -geometry ${GEOMETRY} ${FILENAME} ${TARGET} ${TARGET} diff --git a/Automation/Modules/Render/render.sh b/Automation/Modules/Render/render.sh index c2dab14..8ef8699 100755 --- a/Automation/Modules/Render/render.sh +++ b/Automation/Modules/Render/render.sh @@ -56,7 +56,7 @@ function render { # meaning. In order to be sure all required directories are # available in the repository it is necessary use the prepare # functionality. - tcar_checkFiles ${CONFIGURATIONS} -f + tcar_checkFiles -ef ${CONFIGURATIONS} # Process each configuration file. for CONFIGURATION in ${CONFIGURATIONS};do diff --git a/Automation/Modules/Render/render_setRenderType.sh b/Automation/Modules/Render/render_setRenderType.sh index 9f43a31..820b8fa 100755 --- a/Automation/Modules/Render/render_setRenderType.sh +++ b/Automation/Modules/Render/render_setRenderType.sh @@ -116,7 +116,7 @@ function render_setRenderType { fi done - tcar_checkFiles "${TRANSLATIONS[*]}" -f + tcar_checkFiles -ef ${TRANSLATIONS[*]} fi diff --git a/Automation/Scripts/tcar_checkFiles.sh b/Automation/Scripts/tcar_checkFiles.sh index 6c3f019..c46682c 100755 --- a/Automation/Scripts/tcar_checkFiles.sh +++ b/Automation/Scripts/tcar_checkFiles.sh @@ -33,12 +33,6 @@ function tcar_checkFiles { - # Define short options. - local ARGSS='i:,r,m:,n,d,e,f,h,x' - - # Define long options. - local ARGSL='mime:,is-versioned,match:,is-installed' - # Initialize local array variables. local -a CONDITION_COMMAND local -a CONDITION_PATTERN @@ -47,95 +41,67 @@ function tcar_checkFiles { # Initialize local counter. local COUNTER=0 - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. This - # variable is shared for different function environments. - local TCAR_ARGUMENTS='' - - # Redefine arguments using current positional parameters. - tcar_setArguments "${@}" - - # Redefine positional parameters using arguments variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Look for options passed through positional parameters. - while true; do + OPTIND=1 + while getopts "i:,r,m:,n,d,e,f,h,x" OPTION ${@}; do - case "${1}" in + case "${OPTION}" in - -d ) + d ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-d' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a directory."`" - shift 1 ;; - -e ) + e ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-e' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "doesn't exist."`" - shift 1 ;; - -f ) + f ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-f' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a regular file."`" - shift 1 ;; - -h ) + h ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-h' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a symbolic link."`" - shift 1 ;; - -x ) + x ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-x' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't an executable file."`" - shift 1 ;; - -i | --mime ) - local MIME=${2} + i ) + local MIME=${OPTARG} CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='file' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-bi' CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "isn't a \\\"\\\${MIME}\\\" file."`" - shift 2 ;; - -m | --match ) + m ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='match' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="${2}" + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="${OPTARG}" CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "doesn't match its pattern."`" - shift 2 - ;; - - -r | --is-versioned ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="centos-art" - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="vcs --is-versioned" - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="" - shift 1 ;; - -n | --is-installed ) + n ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="rpm" CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="-q --quiet" CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't installed in the system."`" - shift 1 - ;; - - -- ) - shift 1 - break ;; esac done + # Clean up positional parameters to reflect the fact that options + # have been processed already. + shift $(( ${OPTIND} - 1 )) + # Define list of files we want to apply verifications to, now that # all option-like arguments have been removed from positional # parameters list so we are free to go with the verifications. @@ -162,7 +128,7 @@ function tcar_checkFiles { ;; "file" ) - if [[ ! $(${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE}) =~ "${MIME}" ]];then + if [[ ! $(${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE}) =~ "^${MIME}" ]];then tcar_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line fi ;; diff --git a/Automation/Scripts/tcar_getConfigSectionNames.sh b/Automation/Scripts/tcar_getConfigSectionNames.sh index bb61d97..251ffaf 100755 --- a/Automation/Scripts/tcar_getConfigSectionNames.sh +++ b/Automation/Scripts/tcar_getConfigSectionNames.sh @@ -35,7 +35,7 @@ function tcar_getConfigSectionNames { local CONFIGURATION_FILE=${1} # Verify existence of configuration file. - tcar_checkFiles ${CONFIGURATION_FILE} -f + tcar_checkFiles -ef ${CONFIGURATION_FILE} # Define regular expression pattern used to retrieve section names # from configuration files. Don't permit any regular expression diff --git a/Automation/Scripts/tcar_printMessage.sh b/Automation/Scripts/tcar_printMessage.sh index 89e4ea0..554ba25 100755 --- a/Automation/Scripts/tcar_printMessage.sh +++ b/Automation/Scripts/tcar_printMessage.sh @@ -42,7 +42,7 @@ function tcar_printMessage { local MESSAGE_WIDTH=66 # Remove empty spaces from message. - MESSAGE=$(echo ${MESSAGE} | sed -r -e 's!^[[:space:]]+!!') + MESSAGE=$(printf %s "${MESSAGE}" | sed -r -e 's!^[[:space:]]+!!') # Print messages that will always be printed no matter what value # the TCAR_FLAG_QUIET variable has. @@ -55,7 +55,7 @@ function tcar_printMessage { # convenience, we transform absolute paths into relative # paths in order to free horizontal space on final output # messages. - echo "${MESSAGE}" | sed -r \ + printf %s "${MESSAGE}" | sed -r \ -e "s!${TCAR_BASEDIR}/!!g" \ -e "s!> /!> !g" \ -e "s!/{2,}!/!g" \ @@ -80,7 +80,6 @@ function tcar_printMessage { tcar_printMessage '-' --as-separator-line tcar_printMessage "$(tcar_printCaller 1) ${MESSAGE}" --as-stdout-line tcar_printMessage '-' --as-separator-line - tcar_printMessage "${MODULE_NAME}" --as-toknowmore-line # Finish script execution with exit status 1 (SIGHUP) to # imply the script finished because an error. We are diff --git a/Automation/Scripts/tcar_printVersion.sh b/Automation/Scripts/tcar_printVersion.sh index 2232df9..d39edc3 100755 --- a/Automation/Scripts/tcar_printVersion.sh +++ b/Automation/Scripts/tcar_printVersion.sh @@ -28,7 +28,7 @@ function tcar_printVersion { - tcar_printMessage "`eval_gettext "Running module $MODULE_NAME (v$MODULE_VERSION) through $TCAR_SCRIPT_NAME (v$TCAR_SCRIPT_VERSION)."`" --as-stdout-line + tcar_printMessage "`eval_gettext "Running module \\\${MODULE_NAME} (v\\\${MODULE_VERSION}) through \\\${TCAR_SCRIPT_NAME} (v\\\${TCAR_SCRIPT_VERSION})."`" --as-stdout-line exit 0 } diff --git a/Automation/Scripts/tcar_setArguments.sh b/Automation/Scripts/tcar_setArguments.sh index 0a5c8b9..77af0f8 100755 --- a/Automation/Scripts/tcar_setArguments.sh +++ b/Automation/Scripts/tcar_setArguments.sh @@ -45,12 +45,6 @@ function tcar_setArguments { - # Verify existence of arguments that will be processed. If there - # is none, return to caller. - if [[ -z "${@}" ]];then - return - fi - local ARGUMENT='' # Fill up arguments global variable with current positional @@ -62,7 +56,7 @@ function tcar_setArguments { # Remove any single quote from arguments passed to # centos-art.sh script. We will use single quotes for grouping # option values so white space can be passed through them. - ARGUMENT=$(echo "${ARGUMENT}" | tr -d "'") + ARGUMENT=$(printf %s "${ARGUMENT}" | tr -d "'") # Concatenate arguments and enclose them to let getopt to # process them when they have spaces inside. diff --git a/Automation/Scripts/tcar_setModuleEnvironment.sh b/Automation/Scripts/tcar_setModuleEnvironment.sh index f462677..1406371 100755 --- a/Automation/Scripts/tcar_setModuleEnvironment.sh +++ b/Automation/Scripts/tcar_setModuleEnvironment.sh @@ -51,7 +51,7 @@ function tcar_setModuleEnvironment { local MODULE_INIT_FILE=${MODULE_DIR}/${MODULE_NAME}.sh # Check function script execution rights. - tcar_checkFiles -x ${MODULE_INIT_FILE} + tcar_checkFiles -ex ${MODULE_INIT_FILE} # Remove the first argument passed to centos-art.sh command-line # in order to build optional arguments inside functionalities. We diff --git a/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh index 95e0d98..1f05871 100755 --- a/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh +++ b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh @@ -38,8 +38,7 @@ function tcar_setModuleEnvironmentScripts { if [[ -d ${MODULE_DIR} ]];then MODULE_SCRIPTS="${MODULE_SCRIPTS} $(tcar_getFilesList ${MODULE_DIR} \ - --pattern="${MODULE_DIR}/${MODULE_NAME}_.+\.sh$" --maxdepth='1' \ - --mindepth='1' --type='f')" + --pattern="${MODULE_DIR}/${MODULE_NAME}_[[:alnum:]]+\.sh$" --type='f')" fi # Verify the list of files. If no function file exists for the @@ -54,7 +53,7 @@ function tcar_setModuleEnvironmentScripts { for MODULE_SCRIPT in ${MODULE_SCRIPTS};do # Verify the execution rights for function file. - tcar_checkFiles -x ${MODULE_SCRIPT} + tcar_checkFiles -ex ${MODULE_SCRIPT} # Verify that function files have not been already exported. # If they have been already exported don't export them again. diff --git a/Automation/Scripts/tcar_setTranslationMarkers.sh b/Automation/Scripts/tcar_setTranslationMarkers.sh index 99499a6..0cb4bcd 100755 --- a/Automation/Scripts/tcar_setTranslationMarkers.sh +++ b/Automation/Scripts/tcar_setTranslationMarkers.sh @@ -42,7 +42,7 @@ function tcar_setTranslationMarkers { local LOCATION="${1}" # Verify that source location does exist. - tcar_checkFiles -f ${LOCATION} + tcar_checkFiles -ef ${LOCATION} # Define copyright translation markers. SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(_LAST)?=' diff --git a/Automation/centos-art.conf.sh b/Automation/centos-art.conf.sh index 88f1e30..4b12a3e 100755 --- a/Automation/centos-art.conf.sh +++ b/Automation/centos-art.conf.sh @@ -78,14 +78,14 @@ declare -xr TCAR_SCRIPT_LANG_CC=$(echo ${TCAR_SCRIPT_LANG_LC} | cut -d'_' -f2) # with this name. This variable is reset each time a new module is # loaded, so the correct files can be used. # -declare -x TEXTDOMAIN=${TCAR_SCRIPT_NAME} +declare -xr TEXTDOMAIN="${TCAR_SCRIPT_NAME}" # # Set the script text domain directory. This information is used by # gettext system to know where the machine objects are stored in. This # variable is reset each time a new module is loaded, so the correct # files can be used. # -declare -x TEXTDOMAINDIR=${TCAR_SCRIPT_BASEDIR}/Locales +declare -xr TEXTDOMAINDIR=${TCAR_SCRIPT_BASEDIR}/Locales # -------------------------------------------------------------------- # Module-specific configuration variables. diff --git a/Automation/centos-art.sh b/Automation/centos-art.sh index e507970..832384d 100755 --- a/Automation/centos-art.sh +++ b/Automation/centos-art.sh @@ -64,7 +64,7 @@ case ${1} in --version ) # Print script's name and version. - echo "`eval_gettext "Running $TCAR_SCRIPT_NAME (v$TCAR_SCRIPT_VERSION)."`" + echo "`eval_gettext "Running \\\${TCAR_SCRIPT_NAME} (v\\\${TCAR_SCRIPT_VERSION})."`" ;; * ) @@ -91,7 +91,6 @@ case ${1} in # Export script's module environment. tcar_setModuleEnvironment "${@}" - ;; esac