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
#
878a2b
# Copyright (C) 2009, 2010, 2011 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 \
878a2b
        -e "s!/Themes/${FLAG_THEME_MODEL}!/Themes/$(cli_getPathComponent $ACTIONVAL --motif)!" \
878a2b
        -e "s!/Models!/Images!" \
878a2b
        -e "s!/Tpl!!")
878a2b
878a2b
    # By default rendered identity content is stored immediatly 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
878a2b
    # themes and the `trunk/Manuals/Distro' directory ) whose need
878a2b
    # this information to be passed explicitly at the command-line
878a2b
    # through the `--releasever' and `--basearch' options.  Other
878a2b
    # directories take such information from the path they are stored
878a2b
    # in (e.g., the `Distro/5/Anaconda' directory inside themes.). So,
878a2b
    # we need to differentiate the way information like release
878a2b
    # numbers and architectures are retrived in order to build the
878a2b
    # output path correctly at rendition time.
878a2b
    if [[ $OUTPUT =~ "^${MOTIF_DIR}/Media$" ]];then
878a2b
        OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH}
878a2b
    elif [[ $OUTPUT =~ 'trunk/Manuals/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
878a2b
    # convenction, 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
878a2b
    # organize content. This convenction 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.
878a2b
    if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then
878a2b
        if [[ $(cli_isLocalized $TEMPLATE) == 'true' ]];then
878a2b
            OUTPUT=${OUTPUT}/$(cli_getCurrentLocale)
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
}