Blame Automation/centos-art.sh-render/render.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# render.sh -- This function standardizes the way source files are
Alain Reguera Delgado 8f60cb
# rendered inside the working copy.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function render {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    local ACTIONNAM=''
Alain Reguera Delgado 8f60cb
    local ACTIONVAL=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--releasever' option. The release version option
Alain Reguera Delgado 8f60cb
    # controls the release number used to produce release-specific
Alain Reguera Delgado 8f60cb
    # content.  By default, the release number of The CentOS
Alain Reguera Delgado 8f60cb
    # Distribution you have installed in your workstation is used.
Alain Reguera Delgado 8f60cb
    local FLAG_RELEASEVER=$(cat /etc/redhat-release \
Alain Reguera Delgado 8f60cb
        | gawk '{ print $3 }')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--basearch' option. The base architecture option
Alain Reguera Delgado 8f60cb
    # controls the architecture type used to produce
Alain Reguera Delgado 8f60cb
    # architecture-specific content.  By default, the hardware
Alain Reguera Delgado 8f60cb
    # platform of your workstation is used.
Alain Reguera Delgado 8f60cb
    local FLAG_BASEARCH=$(uname -i)
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--theme-model' option. The theme model option
Alain Reguera Delgado 8f60cb
    # specifies the theme model name used to produce theme
Alain Reguera Delgado 8f60cb
    # artistic motifs.
Alain Reguera Delgado 8f60cb
    local FLAG_THEME_MODEL='Default'
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--post-rendition' option. This option defines what
Alain Reguera Delgado 8f60cb
    # command to use as post-rendition. Post-rendition takes place
Alain Reguera Delgado 8f60cb
    # over base-rendition output.
Alain Reguera Delgado 8f60cb
    local FLAG_POSTRENDITION=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--last-rendition' option. This option defines what
Alain Reguera Delgado 8f60cb
    # command to use as last-rendition. Last-rendition takes place
Alain Reguera Delgado 8f60cb
    # once both base-rendition and post-rendition has been performed
Alain Reguera Delgado 8f60cb
    # in the same directory structure.
Alain Reguera Delgado 8f60cb
    local FLAG_LASTRENDITION=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--dont-dirspecific' option. This option can take two
Alain Reguera Delgado 8f60cb
    # values only (e.g., `true' or `false') and controls whether to
Alain Reguera Delgado 8f60cb
    # perform or not directory-specific rendition.  Directory-specific
Alain Reguera Delgado 8f60cb
    # rendition may use any of the three types of renditions (e.g.,
Alain Reguera Delgado 8f60cb
    # base-rendition, post-rendition and last-rendition) to accomplish
Alain Reguera Delgado 8f60cb
    # specific tasks when specific directory structures are detected
Alain Reguera Delgado 8f60cb
    # in the rendition flow. By default, the centos-art.sh script
Alain Reguera Delgado 8f60cb
    # performs directory-specific rendition.
Alain Reguera Delgado 8f60cb
    local FLAG_DONT_DIRSPECIFIC='false'
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize `--with-brands' option. This option controls whether
Alain Reguera Delgado 8f60cb
    # to brand output images or not. By default output images are not
Alain Reguera Delgado 8f60cb
    # branded.
Alain Reguera Delgado 8f60cb
    local FLAG_WITH_BRANDS='false'
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize list of supported file extensions. These file
Alain Reguera Delgado 8f60cb
    # extensions are used to build the list of source files we'll use
Alain Reguera Delgado 8f60cb
    # to create images from. The order in which these extensions are
Alain Reguera Delgado 8f60cb
    # listed here determines the order in which they are process if
Alain Reguera Delgado 8f60cb
    # more than one is found in the same location.
Alain Reguera Delgado 8f60cb
    local RENDER_EXTENSIONS='svgz svg docbook conf'
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize the rendition format name as an empty value. The name
Alain Reguera Delgado 8f60cb
    # of rendition format is determined later at rendition time, based
Alain Reguera Delgado 8f60cb
    # on template file extension.
Alain Reguera Delgado 8f60cb
    local RENDER_FORMAT=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize absolute path to format's base directory, the place
Alain Reguera Delgado 8f60cb
    # where format-specific directories are stored in.
Alain Reguera Delgado 8f60cb
    local RENDER_FORMAT_DIR="${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Interpret arguments and options passed through command-line.
Alain Reguera Delgado 8f60cb
    render_getOptions
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Redefine positional parameters using ARGUMENTS. At this point,
Alain Reguera Delgado 8f60cb
    # option arguments have been removed from ARGUMENTS variable and
Alain Reguera Delgado 8f60cb
    # only non-option arguments remain in it. 
Alain Reguera Delgado 8f60cb
    eval set -- "$ARGUMENTS"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define action value. We use non-option arguments to define the
Alain Reguera Delgado 8f60cb
    # action value (ACTIONVAL) variable.
Alain Reguera Delgado 8f60cb
    for ACTIONVAL in "$@";do
Alain Reguera Delgado 8f60cb
        
Alain Reguera Delgado 8f60cb
        # Sanitate non-option arguments to be sure they match the
Alain Reguera Delgado 8f60cb
        # directory conventions established by centos-art.sh script
Alain Reguera Delgado 8f60cb
        # against source directory locations in the working copy.
Alain Reguera Delgado 8f60cb
        ACTIONVAL=$(cli_checkRepoDirSource ${ACTIONVAL})
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Verify non-option arguments passed to centos-art.sh
Alain Reguera Delgado 8f60cb
        # command-line. The path provided as argument must exist in
Alain Reguera Delgado 8f60cb
        # the repository.  Otherwise, it would be possible to create
Alain Reguera Delgado 8f60cb
        # arbitrary directories inside the repository without any
Alain Reguera Delgado 8f60cb
        # meaning. In order to be sure all required directories are
Alain Reguera Delgado 8f60cb
        # available in the repository it is necessary use the prepare
Alain Reguera Delgado 8f60cb
        # functionality.
Alain Reguera Delgado 8f60cb
        #cli_checkFiles ${ACTIONVAL} -d
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define render-able directories and the way they are
Alain Reguera Delgado 8f60cb
        # produced.  To describe the way render-able directories are
Alain Reguera Delgado 8f60cb
        # produced, we take the action value (ACTIONVAL) as reference
Alain Reguera Delgado 8f60cb
        # and describe the production through an action name
Alain Reguera Delgado 8f60cb
        # (ACTIONNAM).
Alain Reguera Delgado 8f60cb
        if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Identity/Images/Themes" ]];then
Alain Reguera Delgado 8f60cb
            ACTIONNAM="render_setThemes"
Alain Reguera Delgado 8f60cb
        elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Identity/Images/Brands" ]];then
Alain Reguera Delgado 8f60cb
            ACTIONNAM="render_setBrands"
Alain Reguera Delgado 8f60cb
        elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Identity/Images" ]];then
Alain Reguera Delgado 8f60cb
            ACTIONNAM="render_setBaseRendition"
Alain Reguera Delgado 8f60cb
        elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Documentation/Manuals/(Docbook|Svg)/[[:alnum:]-]+" ]];then
Alain Reguera Delgado 8f60cb
            ACTIONNAM="render_setBaseRendition"
Alain Reguera Delgado 8f60cb
        else
Alain Reguera Delgado 8f60cb
            cli_printMessage "`gettext "The path provided doesn't support rendition."`" --as-error-line
Alain Reguera Delgado 8f60cb
        fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Synchronize changes between repository and working copy. At
Alain Reguera Delgado 8f60cb
        # this point, changes in the repository are merged in the
Alain Reguera Delgado 8f60cb
        # working copy and changes in the working copy committed up to
Alain Reguera Delgado 8f60cb
        # repository.
Alain Reguera Delgado 8f60cb
        cli_synchronizeRepoChanges "${ACTIONVAL}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Execute action name.
Alain Reguera Delgado 8f60cb
        ${ACTIONNAM}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Synchronize changes between repository and working copy. At
Alain Reguera Delgado 8f60cb
        # this point, changes in the repository are merged in the
Alain Reguera Delgado 8f60cb
        # working copy and changes in the working copy committed up to
Alain Reguera Delgado 8f60cb
        # repository.
Alain Reguera Delgado 8f60cb
        cli_synchronizeRepoChanges "${ACTIONVAL}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}