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

878a2b
#!/bin/bash
878a2b
#
878a2b
# render_getDirOutput.sh -- This function defines the final
878a2b
# absolute path the centos-art.sh script uses to store identity
878a2b
# contents produced at rendition time.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 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_getDirOutput {
878a2b
878a2b
    # Define base output directory using design model path as
878a2b
    # reference.
878a2b
    OUTPUT=$(dirname $FILE | sed -r \
c664d4
        -e "s!Identity/Models!Identity/Images!" \
c664d4
        -e "s!Themes/${FLAG_THEME_MODEL}!Themes/$(cli_getPathComponent $ACTIONVAL --motif)!" \
1a5a18
        -e "s!Documentation/Models!Documentation/Manuals!" \
878a2b
        -e "s!/Tpl!!")
878a2b
9d913a
    # By default rendered identity content is stored immediately under
878a2b
    # identity entry structure,  but if `Img/' directory exists use it
878a2b
    # instead.
878a2b
    if [[ -d "${OUTPUT}/Img" ]];then
878a2b
        OUTPUT=${OUTPUT}/Img
878a2b
    fi
878a2b
878a2b
    # Redefine base output directory to introduce specific information
878a2b
    # like release number and architecture. This information is
878a2b
    # require by directories (e.g., the `Media' directory inside
819c26
    # themes and the `Documentation/Manuals/Docbook/Distro' directory
819c26
    # ) whose need this information to be passed explicitly at the
819c26
    # command-line through the `--releasever' and `--basearch'
b665d9
    # options.  Other directories take such information from the path
b665d9
    # they are stored in (e.g., the `Distro/5/Anaconda' directory
b665d9
    # inside themes.). So, we need to differentiate the way
e9b476
    # information like release numbers and architectures are retrieved
b665d9
    # in order to build the output path correctly at rendition time.
878a2b
    if [[ $OUTPUT =~ "^${MOTIF_DIR}/Media$" ]];then
878a2b
        OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH}
819c26
    elif [[ $OUTPUT =~ 'Documentation/Manuals/Docbook/Distro$' ]];then
878a2b
        OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}
878a2b
    else
878a2b
        OUTPUT=${OUTPUT}
878a2b
    fi
878a2b
878a2b
    # Define whether to use or not locale-specific directory to store
878a2b
    # content, using current locale information as reference. As
e9b476
    # convection, when we produce content, only specific locations
878a2b
    # use locale-specific directories to organize language-specific
878a2b
    # content (e.g., Manuals, Anaconda, Installation media, etc.). All
878a2b
    # other locations do not use locale-specific directories to
e9b476
    # organize content. This convection is important in order for
878a2b
    # the `prepare' functionality of centos-art.sh script to produce
878a2b
    # content in the correct location. Otherwise, we might end up
878a2b
    # duplicating content (e.g., icons, brands, etc.) which doesn't
878a2b
    # have any translation, nor any need to be translated.
0d0e7a
    if [[ ! ${CLI_LANG_LC} =~ '^en' ]];then
e9b476
        cli_runFnEnvironment locale --is-localizable ${TEMPLATE}
d1ab27
        if [[ $? -eq 0 ]];then
0d0e7a
            OUTPUT=${OUTPUT}/${CLI_LANG_LC}
878a2b
        fi
878a2b
    fi
878a2b
878a2b
    # Create final output directory, if it doesn't exist yet.
878a2b
    if [[ ! -d ${OUTPUT} ]];then
878a2b
        mkdir -p ${OUTPUT}
878a2b
    fi
878a2b
878a2b
}