Blame tcar-scripts-locale/Modules/Files/Modules/Update/Modules/Conf/conf.sh

Alain Reguera Delgado f72cfe
#!/bin/bash
Alain Reguera Delgado f72cfe
######################################################################
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
#   conf.sh -- This module processes configuration files provided as
Alain Reguera Delgado f72cfe
#   argument in the command-line of locale module. Basically, it
Alain Reguera Delgado f72cfe
#   redefines values previously set in the files function using the
Alain Reguera Delgado f72cfe
#   configuration file provided in the command-line.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
#   Written by:
Alain Reguera Delgado f72cfe
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado f72cfe
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado f72cfe
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado f72cfe
# your option) any later version.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado f72cfe
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado f72cfe
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado f72cfe
# General Public License for more details.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado f72cfe
# along with this program; if not, write to the Free Software
Alain Reguera Delgado f72cfe
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
######################################################################
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
function conf {
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    local CONFIGURATION=${RENDER_FROM}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Use arrays to store section names. This make possible to make
Alain Reguera Delgado f72cfe
    # use of post-rendition and last-rendition concepts. Otherwise it
Alain Reguera Delgado f72cfe
    # would be difficult to predict information about sections inside
Alain Reguera Delgado f72cfe
    # deeper environments.
Alain Reguera Delgado f72cfe
    local -a SECTIONS
Alain Reguera Delgado f72cfe
    for SECTION in $(tcar_getConfigSectionNames "${CONFIGURATION}" \
Alain Reguera Delgado f72cfe
        | egrep ${TCAR_FLAG_FILTER});do
Alain Reguera Delgado f72cfe
        SECTIONS[++${#SECTIONS[*]}]="${SECTION}"
Alain Reguera Delgado f72cfe
    done
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Verify the configuration file has one section entry at least.
Alain Reguera Delgado f72cfe
    if [[ ${#SECTIONS[*]} -eq 0 ]];then
Alain Reguera Delgado f72cfe
        tcar_printMessage "`eval_gettext "No section definition was found in \\\$CONFIGURATION."`" --as-error-line
Alain Reguera Delgado f72cfe
    fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    local COUNTER=0
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    while [[ ${COUNTER} -lt ${#SECTIONS[*]} ]];do
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        local SECTION=${SECTIONS[${COUNTER}]}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        local RENDER_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type")
Alain Reguera Delgado f72cfe
        if [[ -z ${RENDER_TYPE} ]];then
Alain Reguera Delgado f72cfe
            tcar_printMessage "${CONFIGURATION} `gettext "hasn't render-type set in."`" --as-error-line
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        local RENDER_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-from")
Alain Reguera Delgado f72cfe
        if [[ -z ${RENDER_FROM} ]];then
Alain Reguera Delgado f72cfe
            tcar_printMessage "${CONFIGURATION} `gettext "hasn't render-from set in."`" --as-error-line
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
        if [[ ! ${RENDER_FROM} =~ "^/" ]];then
Alain Reguera Delgado f72cfe
            RENDER_FROM=$(dirname ${CONFIGURATION})/${RENDER_FROM}
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        local RENDER_FLOW=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-flow")
Alain Reguera Delgado f72cfe
        if [[ -z ${RENDER_FLOW} ]];then
Alain Reguera Delgado f72cfe
            tcar_printMessage "${CONFIGURATION} `gettext "hasn't render-flow set in."`" --as-error-line
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        local LOCALE_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "locale-from")
Alain Reguera Delgado f72cfe
        if [[ -z ${LOCALE_FROM} ]];then
Alain Reguera Delgado f72cfe
            tcar_printMessage "${CONFIGURATION} `gettext "hasn't locale-from set in."`" --as-error-line
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
        if [[ ! ${LOCALE_FROM} =~ "^/" ]];then
Alain Reguera Delgado f72cfe
            LOCALE_FROM=$(dirname ${CONFIGURATION})/${LOCALE_FROM}
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Re-define package name written in POT and PO files. This is
Alain Reguera Delgado f72cfe
        # the name of the initialization file you provided as argument
Alain Reguera Delgado f72cfe
        # to the command line to provide localization for.
Alain Reguera Delgado f72cfe
        local PACKAGE_NAME=$(basename ${RENDER_FROM})
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Re-define absolute path to portable and machine objects.
Alain Reguera Delgado f72cfe
        local POT_FILE=$(tcar_getTemporalFile "${PACKAGE_NAME}.pot")
Alain Reguera Delgado f72cfe
        local PO_FILE=${LOCALE_FROM}
Alain Reguera Delgado f72cfe
        local MO_FILE=$(dirname ${RENDER_FROM})/Locales/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${PACKAGE_NAME}.mo
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Execute type-specific module for processing files.
Alain Reguera Delgado f72cfe
        tcar_setModuleEnvironment -m "${RENDER_TYPE}" -t "sibling"
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Increment section's counter.
Alain Reguera Delgado f72cfe
        COUNTER=$(( ${COUNTER} + 1 ))
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    done
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Reset array variables and their counters to avoid undesired
Alain Reguera Delgado f72cfe
    # concatenations between configuration files.
Alain Reguera Delgado f72cfe
    unset COUNTER
Alain Reguera Delgado f72cfe
    unset SECTIONS
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
}