From fc7a766e4ebc87724479bd13492dda06bb44e9ca Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 20 2011 20:22:45 +0000 Subject: Update names inside identity functionality. --- diff --git a/Scripts/Bash/Functions/Identity/identity_getConfig.sh b/Scripts/Bash/Functions/Identity/identity_getConfig.sh new file mode 100755 index 0000000..2143fa7 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getConfig.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# identity_renderConfig.sh -- This function checks/validates variables +# passed from artwork-specific pre-rendition configuration files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderConfig { + + local POSTCOUNT=0 + local LASTCOUNT=0 + + # Re-define action variables in separated array variables. Once + # verification is done, we remove the BASE, POST, LAST parts from + # action definition in order to have the plain name of function to + # call. + for ACTION in "${ACTIONS[@]}"; do + + # Define post-rendition actions. + if [[ $ACTION =~ '^POST:' ]];then + ACTION=$(identity_renderConfigOption "$ACTION" '2-') + POSTACTIONS[$POSTCOUNT]="$ACTION" + POSTCOUNT=$(($POSTCOUNT + 1)) + + # Define last-rendition actions. + elif [[ $ACTION =~ '^LAST:' ]];then + ACTION=$(identity_renderConfigOption "$ACTION" '2-') + LASTACTIONS[$LASTCOUNT]="$ACTION" + LASTCOUNT=$(($LASTCOUNT + 1)) + fi + + done + + # Sanitate theme model value using repository directory name + # convenction. + THEMEMODEL=$(cli_getRepoName "$THEMEMODEL" 'd') + + # Check theme model directory. + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}" 'd' + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getConfigOption.sh b/Scripts/Bash/Functions/Identity/identity_getConfigOption.sh new file mode 100755 index 0000000..fb4f95a --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getConfigOption.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# identity_renderConfigOption.sh -- This function standardizes the way +# action values are retrived from pre-rendition configuration files. +# Use this function whenever you need to retrive action values from +# pre-rendition configuration script. +# +# Usage: VAR=$(identity_renderConfigOption "ACTION" "FIELD") +# +# VAR is the name of the variable where we store the option named +# returned by identity_renderConfigOption. +# +# ACTION is the string definition set in the pre-rendition +# configuration script that holds the action name and its options +# fields. +# +# FIELD is the field number in the action string we want to retrive +# option from. By default options start from third field on. The first +# field is reserved for the action type (i.e., POST or LAST), and the +# second field is reserved for the action itself (e.g., renderFormats, +# renderSyslinux, renderKsplash, etc.). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderConfigOption { + + local ACTION="$1" + local FIELD="$2" + local VALUE='' + + # Check action value. The action's value must be present in order + # for this function to work. It provides the string needed to + # retrive options from. + if [[ "$ACTION" == '' ]];then + cli_printMessage "`gettext "There is no action to work with."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check field value. The field's value must match the cut's + # command specification of its -f option. + if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then + cli_printMessage "`gettext "The field specified is not valid."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Get option from pre-rendition configuration action definition. + VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate action value passed from pre-rendition configuration + # action definition. + VALUE=$(echo -n "${VALUE}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Output action value without trailing newline. + echo -n "$VALUE" + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getDirOutput.sh b/Scripts/Bash/Functions/Identity/identity_getDirOutput.sh new file mode 100644 index 0000000..58ec731 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getDirOutput.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# identity_renderDirOutput.sh -- This function defines the final +# absolute path the centos-art.sh script uses to store identity +# contents produced at rendition time. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderDirOutput { + + # Define base output directory using design model path as reference. + OUTPUT=$(dirname $FILE | sed -r \ + -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!") + + # By default rendered identity content is stored immediatly under + # identity entry structure, but if `Img/' directory exists use it + # instead. + if [[ -d ${OUTPUT}/Img ]]; then + OUTPUT=${OUTPUT}/Img + fi + + # Redefine base output directory to introduce specific information + # like release number, architecture, etc. + OUTPUT=${OUTPUT}/${FLAG_RELEASE}/${FLAG_ARCHITECTURE} + + # Define whether to use or not locale-specific directory to store + # content, using current locale information as reference. As + # convenction, when we produce content in English language, we do + # not add a laguage-specific directory to organize content. + # However, when we produce language-specific content in a language + # different from English we do use language-specific directory to + # organize content. + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) + fi + + # Remove two or more consecutive slashes as well as the last + # remaining slash in the path. + OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') + + # Create final output directory, if it doesn't exist yet. + if [[ ! -d ${OUTPUT} ]];then + mkdir -p ${OUTPUT} + fi + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getDirTemplate.sh b/Scripts/Bash/Functions/Identity/identity_getDirTemplate.sh new file mode 100644 index 0000000..88c563e --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getDirTemplate.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# identity_renderDirTemplate.sh -- This function re-defines absolute +# path to artwork's related design templates directory. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderDirTemplate { + + # Initialize design models location using action value as + # reference. + TEMPLATE=$ACTIONVAL + + # Sanitate design models location. Be sure design models do + # always point to trunk directory structure. This is useful to let + # `centos-art.sh' script do rendition under branches directory + # structure, reusing design models under trunk directory + # structure. + TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") + + # Sanitate design models location using or not Tpl/ directory. + if [[ -d $TEMPLATE/Tpl ]];then + # Using Tpl/ directory is an obsolete practice that should be + # avoided. The concept of Tpl/ directory per artwork directory + # has been replaced by a common design model directory + # structure where we centralize design models for all + # different artistic motifs. However, there are some cases + # that we may need to use Tpl/ directory still, so we verify + # its existence and use it if present. + TEMPLATE=$TEMPLATE/Tpl + else + # Redefine design model location based on theme model + # (THEMEMODEL) variable value. The theme model variable is + # defined in the associated pre-rendition configuration script + # and can be used to set which design model to use among a + # list of different design models that we can choose from. + TEMPLATE=$(echo "$TEMPLATE" \ + | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$THEMEMODEL!") + fi + +} diff --git a/Scripts/Bash/Functions/Identity/identity_renderConfig.sh b/Scripts/Bash/Functions/Identity/identity_renderConfig.sh deleted file mode 100755 index 2143fa7..0000000 --- a/Scripts/Bash/Functions/Identity/identity_renderConfig.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# identity_renderConfig.sh -- This function checks/validates variables -# passed from artwork-specific pre-rendition configuration files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderConfig { - - local POSTCOUNT=0 - local LASTCOUNT=0 - - # Re-define action variables in separated array variables. Once - # verification is done, we remove the BASE, POST, LAST parts from - # action definition in order to have the plain name of function to - # call. - for ACTION in "${ACTIONS[@]}"; do - - # Define post-rendition actions. - if [[ $ACTION =~ '^POST:' ]];then - ACTION=$(identity_renderConfigOption "$ACTION" '2-') - POSTACTIONS[$POSTCOUNT]="$ACTION" - POSTCOUNT=$(($POSTCOUNT + 1)) - - # Define last-rendition actions. - elif [[ $ACTION =~ '^LAST:' ]];then - ACTION=$(identity_renderConfigOption "$ACTION" '2-') - LASTACTIONS[$LASTCOUNT]="$ACTION" - LASTCOUNT=$(($LASTCOUNT + 1)) - fi - - done - - # Sanitate theme model value using repository directory name - # convenction. - THEMEMODEL=$(cli_getRepoName "$THEMEMODEL" 'd') - - # Check theme model directory. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}" 'd' - -} diff --git a/Scripts/Bash/Functions/Identity/identity_renderConfigOption.sh b/Scripts/Bash/Functions/Identity/identity_renderConfigOption.sh deleted file mode 100755 index fb4f95a..0000000 --- a/Scripts/Bash/Functions/Identity/identity_renderConfigOption.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# identity_renderConfigOption.sh -- This function standardizes the way -# action values are retrived from pre-rendition configuration files. -# Use this function whenever you need to retrive action values from -# pre-rendition configuration script. -# -# Usage: VAR=$(identity_renderConfigOption "ACTION" "FIELD") -# -# VAR is the name of the variable where we store the option named -# returned by identity_renderConfigOption. -# -# ACTION is the string definition set in the pre-rendition -# configuration script that holds the action name and its options -# fields. -# -# FIELD is the field number in the action string we want to retrive -# option from. By default options start from third field on. The first -# field is reserved for the action type (i.e., POST or LAST), and the -# second field is reserved for the action itself (e.g., renderFormats, -# renderSyslinux, renderKsplash, etc.). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderConfigOption { - - local ACTION="$1" - local FIELD="$2" - local VALUE='' - - # Check action value. The action's value must be present in order - # for this function to work. It provides the string needed to - # retrive options from. - if [[ "$ACTION" == '' ]];then - cli_printMessage "`gettext "There is no action to work with."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Check field value. The field's value must match the cut's - # command specification of its -f option. - if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then - cli_printMessage "`gettext "The field specified is not valid."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Get option from pre-rendition configuration action definition. - VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) - - # Sanitate action value passed from pre-rendition configuration - # action definition. - VALUE=$(echo -n "${VALUE}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |,|;) *! !g' \ - | sed -r 's! *$!!g') - - # Output action value without trailing newline. - echo -n "$VALUE" - -} diff --git a/Scripts/Bash/Functions/Identity/identity_renderDirOutput.sh b/Scripts/Bash/Functions/Identity/identity_renderDirOutput.sh deleted file mode 100644 index 58ec731..0000000 --- a/Scripts/Bash/Functions/Identity/identity_renderDirOutput.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# identity_renderDirOutput.sh -- This function defines the final -# absolute path the centos-art.sh script uses to store identity -# contents produced at rendition time. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderDirOutput { - - # Define base output directory using design model path as reference. - OUTPUT=$(dirname $FILE | sed -r \ - -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!") - - # By default rendered identity content is stored immediatly under - # identity entry structure, but if `Img/' directory exists use it - # instead. - if [[ -d ${OUTPUT}/Img ]]; then - OUTPUT=${OUTPUT}/Img - fi - - # Redefine base output directory to introduce specific information - # like release number, architecture, etc. - OUTPUT=${OUTPUT}/${FLAG_RELEASE}/${FLAG_ARCHITECTURE} - - # Define whether to use or not locale-specific directory to store - # content, using current locale information as reference. As - # convenction, when we produce content in English language, we do - # not add a laguage-specific directory to organize content. - # However, when we produce language-specific content in a language - # different from English we do use language-specific directory to - # organize content. - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) - fi - - # Remove two or more consecutive slashes as well as the last - # remaining slash in the path. - OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') - - # Create final output directory, if it doesn't exist yet. - if [[ ! -d ${OUTPUT} ]];then - mkdir -p ${OUTPUT} - fi - -} diff --git a/Scripts/Bash/Functions/Identity/identity_renderDirTemplate.sh b/Scripts/Bash/Functions/Identity/identity_renderDirTemplate.sh deleted file mode 100644 index 88c563e..0000000 --- a/Scripts/Bash/Functions/Identity/identity_renderDirTemplate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# identity_renderDirTemplate.sh -- This function re-defines absolute -# path to artwork's related design templates directory. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderDirTemplate { - - # Initialize design models location using action value as - # reference. - TEMPLATE=$ACTIONVAL - - # Sanitate design models location. Be sure design models do - # always point to trunk directory structure. This is useful to let - # `centos-art.sh' script do rendition under branches directory - # structure, reusing design models under trunk directory - # structure. - TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") - - # Sanitate design models location using or not Tpl/ directory. - if [[ -d $TEMPLATE/Tpl ]];then - # Using Tpl/ directory is an obsolete practice that should be - # avoided. The concept of Tpl/ directory per artwork directory - # has been replaced by a common design model directory - # structure where we centralize design models for all - # different artistic motifs. However, there are some cases - # that we may need to use Tpl/ directory still, so we verify - # its existence and use it if present. - TEMPLATE=$TEMPLATE/Tpl - else - # Redefine design model location based on theme model - # (THEMEMODEL) variable value. The theme model variable is - # defined in the associated pre-rendition configuration script - # and can be used to set which design model to use among a - # list of different design models that we can choose from. - TEMPLATE=$(echo "$TEMPLATE" \ - | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$THEMEMODEL!") - fi - -}