Blame Scripts/Bash/Functions/Render/render.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# render.sh -- This function initializes rendition variables and
878a2b
# actions to centos-art.sh script.
878a2b
#
c3ee98
# Copyright (C) 2009-2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function render {
878a2b
878a2b
    local ACTIONNAM=''
878a2b
    local ACTIONVAL=''
878a2b
878a2b
    # Initialize `--releasever' option. The release version option
878a2b
    # controls the release number used to produce release-specific
878a2b
    # content.  By default, the release number of The CentOS
878a2b
    # Distribution you have installed in your workstation is used.
878a2b
    local FLAG_RELEASEVER=$(cat /etc/redhat-release \
878a2b
        | gawk '{ print $3 }')
878a2b
878a2b
    # Initialize `--basearch' option. The base architecture option
878a2b
    # controls the architecture type used to produce
878a2b
    # architecture-specific content.  By default, the hardware
878a2b
    # platform of your workstation is used.
878a2b
    local FLAG_BASEARCH=$(uname -i)
878a2b
878a2b
    # Initialize `--theme-model' option. The theme model option
878a2b
    # specifies the the theme model name used to produce theme
878a2b
    # artistic motifs.
878a2b
    local FLAG_THEME_MODEL='Default'
878a2b
878a2b
    # Initialize `--post-rendition' option. This option defines what
878a2b
    # command to use as post-rendition. Post-rendition takes palce
878a2b
    # over base-rendition output.
878a2b
    local FLAG_POSTRENDITION=''
878a2b
878a2b
    # Initialize `--last-rendition' option. This option defines what
878a2b
    # command to use as last-rendition. Last-rendition takes palce
878a2b
    # once both base-rendition and post-rendition has been performed
878a2b
    # in the same directory structure.
878a2b
    local FLAG_LASTRENDITION=''
878a2b
878a2b
    # Initialize `--dont-dirspecific' option. This option can take two
878a2b
    # values only (e.g., `true' or `false') and controls whether to
878a2b
    # perform or not directory-specific rendition.  Directory-specific
878a2b
    # rendition may use any of the three types of renditions (e.g.,
878a2b
    # base-rendition, post-rendition and last-rendition) to accomplish
878a2b
    # specific tasks when specific directory structures are detected
878a2b
    # in the rendition flow. By default, the centos-art.sh script
878a2b
    # performs directory-specific rendition.
878a2b
    local FLAG_DONT_DIRSPECIFIC='false'
878a2b
878a2b
    # Initialize `--with-brands' option. This option controls whether
878a2b
    # to brand output images or not. By default output images are not
878a2b
    # branded.
878a2b
    local FLAG_WITH_BRANDS='false'
878a2b
24ece8
    # Initialize name of rendition format as an empty value. The name
24ece8
    # of rendition format is determined automatically based on
878a2b
    # template file extension, later, at rendition time. 
24ece8
    local RENDER_FORMAT=''
878a2b
24ece8
    # Initialize absolute path to format's base directory, the place
24ece8
    # where format-specific directories are stored in.
24ece8
    local RENDER_FORMAT_DIR="${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}"
878a2b
878a2b
    # Initialize list of supported file extensions. These file
878a2b
    # extensions are used by design model files, the files used as
878a2b
    # base-rendition input. In order for design model files to be
878a2b
    # correclty rendered, they must end with one of the file
878a2b
    # extensions listed here.
56cf52
    local RENDER_EXTENSIONS='svg svgz docbook'
878a2b
878a2b
    # Interpret arguments and options passed through command-line.
878a2b
    render_getOptions
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS. At this point,
878a2b
    # option arguments have been removed from ARGUMENTS variable and
878a2b
    # only non-option arguments remain in it. 
878a2b
    eval set -- "$ARGUMENTS"
878a2b
878a2b
    # Define action value. We use non-option arguments to define the
878a2b
    # action value (ACTIONVAL) variable.
878a2b
    for ACTIONVAL in "$@";do
878a2b
        
878a2b
        # Check action value. Be sure the action value matches the
878a2b
        # convenctions defined for source locations inside the working
878a2b
        # copy.
878a2b
        ACTIONVAL=$(cli_checkRepoDirSource "$ACTIONVAL")
878a2b
878a2b
        # Syncronize changes between repository and working copy. At
878a2b
        # this point, changes in the repository are merged in the
878a2b
        # working copy and changes in the working copy committed up to
878a2b
        # repository.
878a2b
        cli_syncroRepoChanges
878a2b
878a2b
        # Define renderable directories and the way they are produced.
878a2b
        # To describe the way renderable directories are produced, we
878a2b
        # take the action value (ACTIONVAL) as reference and describe
878a2b
        # the production through an action name (ACTIONNAM).
878a2b
        if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/Images/Themes" ]];then
878a2b
            ACTIONNAM="render_doThemeActions"
878a2b
        elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/Images" ]];then
878a2b
            ACTIONNAM="render_doBaseActions"
c3ee98
        elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Documentation" ]];then
878a2b
            ACTIONNAM="render_doBaseActions"
878a2b
        else
878a2b
            cli_printMessage "`gettext "The path provided doesn't support rendition."`" --as-error-line
878a2b
        fi
878a2b
878a2b
        # Execute action name.
878a2b
        ${ACTIONNAM}
878a2b
878a2b
        # Syncronize changes between repository and working copy. At
878a2b
        # this point, changes in the repository are merged in the
878a2b
        # working copy and changes in the working copy committed up to
878a2b
        # repository.
878a2b
        cli_syncroRepoChanges
878a2b
878a2b
    done
878a2b
878a2b
}