Blame Scripts/Bash/Functions/Identity/identity_getDirOutput.sh

4c79b5
#!/bin/bash
4c79b5
#
130f90
# identity_getDirOutput.sh -- This function defines the final
5fc0b7
# absolute path the centos-art.sh script uses to store identity
5fc0b7
# contents produced at rendition time.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
130f90
function identity_getDirOutput {
4c79b5
72b5da
    # Define base output directory using design model path as
72b5da
    # reference.  By default rendered identity content is stored
72b5da
    # immediatly under identity entry structure,  but if `Img/'
72b5da
    # directory exists use it instead.
5fc0b7
    OUTPUT=$(dirname $FILE | sed -r \
72b5da
        -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \
72b5da
        -e "s!/Tpl!/Img!")
f59354
5fc0b7
    # Redefine base output directory to introduce specific information
5fc0b7
    # like release number, architecture, etc.
5fc0b7
    OUTPUT=${OUTPUT}/${FLAG_RELEASE}/${FLAG_ARCHITECTURE}
5fc0b7
5fc0b7
    # Define whether to use or not locale-specific directory to store
5fc0b7
    # content, using current locale information as reference. As
5fc0b7
    # convenction, when we produce content in English language, we do
5fc0b7
    # not add a laguage-specific directory to organize content.
5fc0b7
    # However, when we produce language-specific content in a language
5fc0b7
    # different from English we do use language-specific directory to
5fc0b7
    # organize content.
5fc0b7
    if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then
5fc0b7
        OUTPUT=${OUTPUT}/$(cli_getCurrentLocale)
f59354
    fi
f59354
5fc0b7
    # Remove two or more consecutive slashes as well as the last
5fc0b7
    # remaining slash in the path.
5fc0b7
    OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!')
f59354
f59354
    # Create final output directory, if it doesn't exist yet.
f59354
    if [[ ! -d ${OUTPUT} ]];then
f59354
        mkdir -p ${OUTPUT}
4c79b5
    fi
4c79b5
4c79b5
}