diff --git a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/build-targz.sh b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/build-targz.sh deleted file mode 100755 index ca9c0fb..0000000 --- a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/build-targz.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# -# GDM Display Manager tar.gz building script. -# -# Copyright (C) 2009-2010 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: build-targz.sh 42 2010-09-17 05:51:32Z al $ -# ---------------------------------------------------------------------- - -# Define artwork component -ARTCOMP="Themes/Distro/BootUp/GDM" - -# Define directory holding GdmGreeterTheme.xml and -# GdmGreeterTheme.desktop design model files. -XML=/home/centos/artwork/trunk/Identity/Themes/Models/Default/Distro/BootUp/GDM/Xml - -# Define image directory. -IMG=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(getThemeName)/Distro/BootUp/GDM/ - -# Define tar.gz directory. Use the current location because the -# build.sh script is (and it should be) inside `tgz/' direcotry. -TGZ='.' - -# Define directory holding backgrounds. -BGS=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(getThemeName)/Backgrounds/Img - -# Define file holding CentOS Symbol. -SYMBOL=/home/centos/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/64.png -checkFiles $SYMBOL - -# Define VERSIONS list. -VERSIONS=$(getThemeVersion "$1") - -# Define RESOLUTION list. -RESOLUTIONS=$(getThemeResolution "$2") - -for VERSION in $VERSIONS;do - - # Strip directory from $VERSION. - VERSION=$(basename $VERSION) - - for RESOLUTION in $RESOLUTIONS;do - - # There are some resolutions available inside backgrounds that - # we don't need to build tar.gz files for. - case $RESOLUTION in - 200x150 | 160x600 ) - continue - esac - - # Check tar.gz directory existence. - if [ ! -d $TGZ/$VERSION/$RESOLUTION ];then - mkdir -p $TGZ/$VERSION/$RESOLUTION - fi - - cli_printMessage "$TGZ/$VERSION/$RESOLUTION/$(getThemeName).tar.gz" "AsCreatingLine" - - # Create temporal directory. - if [ ! -d $(getThemeName) ]; then - mkdir $(getThemeName) - fi - - # Copy files into temporal directory. - cp $SYMBOL $(getThemeName)/centos-symbol.png - cp $IMG/$VERSION/release.png $(getThemeName)/centos-release.png - cp $IMG/$VERSION/screenshot.png $(getThemeName)/screenshot.png - cp $BGS/$RESOLUTION.png $(getThemeName)/background.png - cp $IMG/*.png $(getThemeName)/ - cp $XML/$(getThemeName).xml $(getThemeName)/ - cp $XML/GdmGreeterTheme.desktop $(getThemeName)/ - - # Create tar.gz package. - tar -czf $(getThemeName).tar.gz $(getThemeName) - - # Remove temporal directory. - rm -r $(getThemeName) - - # Move the tar.gz file to its directory. - mv $(getThemeName).tar.gz $TGZ/$VERSION/$RESOLUTION - - done -done diff --git a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/render.conf.sh b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/render.conf.sh index 76b3f3b..161185c 100755 --- a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/render.conf.sh +++ b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/GDM/render.conf.sh @@ -28,7 +28,7 @@ function render_loadConfig { # Define rendering actions. ACTIONS[0]='BASE:renderImage' - ACTIONS[1]="LAST:renderGdmTgz: 800x600 1024x768 1280x1024 1360x768 \ + ACTIONS[1]="LAST:renderDm:GNOME:800x600 1024x768 1280x1024 1360x768 \ 1680x1050 2048x1536 2560x960 2560x1240 3271x1227" # Define matching list. diff --git a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/build-targz.sh b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/build-targz.sh deleted file mode 100755 index 0d1cd99..0000000 --- a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/build-targz.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# KDE Display Manager tar.gz building script. -# -# Copyright (C) 2009-2010 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: build-targz.sh 42 2010-09-17 05:51:32Z al $ -# ---------------------------------------------------------------------- - -# Initialize functions -. ~/artwork/trunk/Scripts/Bash/initFunctions.sh - -# Define artwork component -ARTCOMP="Themes/Distro/BootUp/KDM" - -# Define xml directory. -XML=../xml - -# Define image directory. -IMG=../img - - -# Define tar.gz directory. Use the current location because the -# build.sh script is (and it should be) inside `tgz/' direcotry. -TGZ='.' - -# Define directory holding backgrounds. -BACKGROUNDS=~/artwork/trunk/Identity/Themes/$(getThemeName)/Distro/Backgrounds/img - -# Define file holding CentOS Symbol. -SYMBOL=~/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/64.png -checkFiles $SYMBOL - -# Define VERSIONS list. -VERSIONS=$(getThemeVersion "$1") - -# Define RESOLUTION list. -RESOLUTIONS=$(getThemeResolution "$2") - -for VERSION in $VERSIONS;do - - # Strip directory from $VERSION. - VERSION=$(basename $VERSION) - - for RESOLUTION in $RESOLUTIONS;do - - # There are some resolutions available inside backgrounds that - # we don't need to build tar.gz files for. - case $RESOLUTION in - 200x150 | 160x600 ) - continue - esac - - # Check tar.gz directory existence. - if [ ! -d $TGZ/$VERSION/$RESOLUTION ];then - mkdir -p $TGZ/$VERSION/$RESOLUTION - fi - - cli_printMessage "$TGZ/$VERSION/$RESOLUTION/$(getThemeName).tar.gz" "AsCreatingLine" - - # Create temporal directory. - if [ ! -d $(getThemeName) ]; then - mkdir $(getThemeName) - fi - - # Copy files into temporal directory. - cp $SYMBOL $(getThemeName)/centos-symbol.png - cp $IMG/$VERSION/release.png $(getThemeName)/centos-release.png - cp $IMG/$VERSION/screenshot.png $(getThemeName)/screenshot.png - cp $BACKGROUNDS/$RESOLUTION.png $(getThemeName)/background.png - cp $IMG/*.png $(getThemeName)/ - cp $XML/$(getThemeName).xml $(getThemeName)/ - cp $XML/GdmGreeterTheme.desktop $(getThemeName)/ - - # Create tar.gz package. - tar -czf $(getThemeName).tar.gz $(getThemeName) - - # Remove temporal directory. - rm -r $(getThemeName) - - # Move the tar.gz file to its directory. - mv $(getThemeName).tar.gz $TGZ/$VERSION/$RESOLUTION - - done -done diff --git a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/render.conf.sh b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/render.conf.sh index d67dace..b95289e 100755 --- a/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/render.conf.sh +++ b/Scripts/Bash/Functions/Render/Config/Identity/Themes/Distro/BootUp/KDM/render.conf.sh @@ -28,6 +28,8 @@ function render_loadConfig { # Define rendering actions. ACTIONS[0]='BASE:renderImage' + ACTIONS[1]="LAST:renderDm:KDE:800x600 1024x768 1280x1024 1360x768 \ + 1680x1050 2048x1536 2560x960 2560x1240 3271x1227" # Define matching list. MATCHINGLIST='' diff --git a/Scripts/Bash/Functions/Render/render_checkConfig.sh b/Scripts/Bash/Functions/Render/render_checkConfig.sh index 201f785..d3dab89 100755 --- a/Scripts/Bash/Functions/Render/render_checkConfig.sh +++ b/Scripts/Bash/Functions/Render/render_checkConfig.sh @@ -38,19 +38,19 @@ function render_checkConfig { # Define base-rendering actions. if [[ $ACTION =~ '^BASE:render(Text|Image)$' ]];then - ACTION=$(echo "$ACTION" | cut -d: -f2-) + ACTION=$(render_getConfOption "$ACTION" '2-') BASEACTIONS[$BASECOUNT]="$ACTION" BASECOUNT=$(($BASECOUNT + 1)) # Define post-rendering actions. elif [[ $ACTION =~ '^POST:' ]];then - ACTION=$(echo "$ACTION" | cut -d: -f2-) + ACTION=$(render_getConfOption "$ACTION" '2-') POSTACTIONS[$POSTCOUNT]="$ACTION" POSTCOUNT=$(($POSTCOUNT + 1)) # Define last-rendering actions. elif [[ $ACTION =~ '^LAST:' ]];then - ACTION=$(echo "$ACTION" | cut -d: -f2-) + ACTION=$(render_getConfOption "$ACTION" '2-') LASTACTIONS[$LASTCOUNT]="$ACTION" LASTCOUNT=$(($LASTCOUNT + 1)) fi diff --git a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh index 9bf6a51..f848293 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh @@ -87,16 +87,12 @@ function render_doIdentityGroupByType { # Sanitate file types passed from render.conf.sh pre-rendering # configuration script. - FORMATS=$(echo "${FORMATS}" \ - | cut -d: -f2- \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |:|,|;) *! !g' \ - | sed -r 's! *$!!g') + FORMATS=$(render_getConfOption "$FORMATS" '2-') # Check file types passed from render.conf.sh pre-rendering # configuration script. if [[ "$FORMATS" == "" ]];then - cli_printMessage "`gettext "groupByType: There is no file type information to process."`" + cli_printMessage "`gettext "There is no file type information to process."`" cli_printMessage $(caller) "AsToKnowMoreLine" fi diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh index 087753c..48cf294 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh @@ -33,13 +33,7 @@ function render_doIdentityImageFormats { local FILE="$1" # Get image formats. - local FORMATS=$(echo "$2" | cut -d: -f2-) - - # Sanitate image formats. - FORMATS=$(echo "${FORMATS}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |:|,|;) *! !g' \ - | sed -r 's! *$!!g') + local FORMATS=$(render_getConfOption "$2" '2-') # Check base file existence. if [[ -f ${FILE}.png ]];then diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageGdm.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageGdm.sh index 651836d..2a8a3c7 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageGdm.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageGdm.sh @@ -1,8 +1,28 @@ #!/bin/bash # -# render_doIdentityImageGdm.sh -- This function creates gdm tar.gz -# files for different motifs, screen resolutions and major releases of -# CentOS distribution. +# render_doIdentityImageDm.sh -- This function porvides last-rendering +# action to create gdm or kdm themes tar.gz files for different +# motifs, screen resolutions, and major releases of CentOS +# distribution. +# +# Usage: +# +# ACTIONS[0]='BASE:renderImage' +# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION' +# +# Where: +# +# TYPE = GNOME or KDE +# RESOLUTION = Any screen resolution available as background +# (e.g., 800x600, 1024x768, 2048x1536, etc.) +# +# For example, to produce GNOME display manager theme in 2048x1536, +# 1360x768, and 3271x1227 screen resolutions, for all major releases +# available, use the following definition inside GDM pre-rendering +# configuration script: +# +# ACTIONS[0]='BASE:renderImage' +# ACTIONS[1]='LAST:renderDm:GNOME:2048x1536 1360x768 3271x1227' # # Copyright (C) 2009-2010 Alain Reguera Delgado # @@ -25,7 +45,7 @@ # $Id$ # ---------------------------------------------------------------------- -function render_doIdentityImageGdm { +function render_doIdentityImageDm { local RESOLUTIONS='' local VERSIONS='' @@ -33,42 +53,73 @@ function render_doIdentityImageGdm { local BGS='' local TMP='' local SYMBOL='' + local DM='' - # Get screen resolutions passed from render.conf.sh pre-rendering + # Get display manager passed from render.conf.sh pre-rendering # configuration script. - RESOLUTIONS=$(echo "$1" | cut -d: -f2-) + DM=$(render_getConfOption "$1" '2') + + # Sanitate display manager possible values and define absolute + # path to display manager design models (i.e., the place where + # GdmGreeterTheme.xml and GdmGreeterTheme.desktop files are + # stored) using display manager information passed from + # render.conf.sh pre-rendering configuration script. + if [[ $DM =~ '^GNOME$' ]];then + TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/GDM + elif [[ $DM =~ '^KDE$' ]];then + TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/KDM + else + cli_printMessage "`eval_gettext "The display manager \\\"\\\$DM\\\" is not supported."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check absolute path to display manager design models. + cli_checkFiles $TPL 'd' + if [[ $? -ne 0 ]];then + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi - # Sanitate screen resolutions. - RESOLUTIONS=$(echo "${RESOLUTIONS}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |:|,|;) *! !g' \ - | sed -r 's! *$!!g') + # Get screen resolutions passed from render.conf.sh pre-rendering + # configuration script. + RESOLUTIONS=$(render_getConfOption "$1" '3') # Check sanitated screen resolutions. - if [[ "$RESOLUTIONS" == "" ]];then - cli_printMessage "`gettext "render_doIdentityImageGdm: There is no resolution information to process."`" + if [[ "$RESOLUTIONS" == '' ]];then + cli_printMessage "`gettext "There is no resolution information to process."`" cli_printMessage $(caller) "AsToKnowMoreLine" fi - # Define release-specific directories we want to produce gdm for. + # Build release numbers list we want to produce display manager + # for. The release numbers are defined inside GDM and KDM + # directories under + # trunk/Translations/Identity/Themes/Distro/BootUp/ structure, + # using the centos-art.sh script. VERSIONS=$(find $OPTIONVAL -regextype posix-egrep \ -maxdepth 1 -type d -regex "^.*/${RELEASE_FORMAT}$" \ | egrep $REGEX) - # Define directory where design models (e.g., GdmGreeterTheme.xml, - # GdmGreeterTheme.desktop) are stored. - TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/GDM/ + # Check release numbers list. + if [[ "$VERSIONS" == '' ]];then + cli_printMessage "`gettext "There is no release number to work with"`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi - # Define directory holding backgrounds. + # Define directory storing different screen resolution backgrounds + # images used to build display manager in different resolutions. BGS=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(cli_getThemeName)/Backgrounds/Img/Png # Define directory where temporal files are stored. TMP=$(cli_getThemeName) - # Define png image file used as CentOS symbol. We are using the - # symbol at 48x48 pixels. + # Define png image file used as CentOS symbol. As convenction, + # inside all CentOS art works (e.g., anaconda, firstboot, etc.), + # we are using CentOS symbol at 48x48 pixels. This value seems to + # be the middle dimension that fits all situations. SYMBOL=/home/centos/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/48.png cli_checkFiles $SYMBOL 'f' + if [[ $? -ne 0 ]];then + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi for VERSION in $VERSIONS;do @@ -77,10 +128,16 @@ function render_doIdentityImageGdm { # Define directory to store release-specific images. IMG=$OPTIONVAL/$VERSION/Img + # Check existence of release-specific image directory. + cli_checkFiles $IMG '-d' '' '--quiet' + if [[ $? -ne 0 ]];then + mkdir -p $IMG + fi + # Define directory to store release-specific tar.gz files. TGZ=$OPTIONVAL/$VERSION/Tgz - # Check existence of release-specific directory. + # Check existence of release-specific tar.gz directory. cli_checkFiles $TGZ 'd' '' '--quiet' if [[ $? -ne 0 ]];then mkdir -p $TGZ @@ -96,7 +153,7 @@ function render_doIdentityImageGdm { # Check background existence for specified resolution. cli_checkFiles $BGS/$RESOLUTION.png 'f' '' '--quiet' if [[ $? -ne 0 ]];then - cli_printMessage "`eval_gettext "There is not background for \\\$RESOLUTION resolution."`" + cli_printMessage "`eval_gettext "There is not background for \\\"\\\$RESOLUTION\\\" resolution."`" cli_printMessage "$(caller)" "AsToKnowMoreLine" fi @@ -105,12 +162,15 @@ function render_doIdentityImageGdm { mkdir $TMP fi - # Copy gdm theme files into temporal directory. + # Copy display manager theme files into temporal + # directory. cp $SYMBOL $TMP/centos-symbol.png cp $IMG/release.png $TMP/centos-release.png cp $IMG/screenshot.png $TMP/screenshot.png cp $BGS/${RESOLUTION}-final.png $TMP/background.png - cp $TPL/*.png $TMP/ + if [[ $DM == 'GNOME' ]];then + cp $TPL/*.png $TMP/ + fi cp $TPL/GdmGreeterTheme.xml $TMP/${TMP}.xml cp $TPL/GdmGreeterTheme.desktop $TMP/ diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh index 1748114..9b53868 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh @@ -37,7 +37,7 @@ function render_doIdentityImageGrub { # configuration script. These options are applied to pnmremap when # doing color reduction, so any option available for pnmremap # command can be passed to renderSyslinux functionality. - OPTIONS=$(echo -n "$ACTION" | cut -d: -f2-) + OPTIONS=$(render_getConfOption "$ACTION" '2-') # Re-define 16 colors images default file name prefix using # options as reference. This is useful to differenciate final @@ -52,7 +52,7 @@ function render_doIdentityImageGrub { # -verbose and -mapfile options. for OPTION in $OPTIONS;do # Remove anything after equal sign inside option. - OPTION=$(echo $OPTION | cut -d'=' -f1) + OPTION=$(echo -n $OPTION | cut -d'=' -f1) if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" cli_printMessage "$(caller)" "AsToKnowMoreLine" diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh index 99910f9..3128df0 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh @@ -37,7 +37,7 @@ function render_doIdentityImageSyslinux { # configuration script. These options are applied to pnmremap when # doing color reduction, so any option available for pnmremap # command can be passed to renderSyslinux functionality. - OPTIONS=$(echo -n "$ACTION" | cut -d: -f2-) + OPTIONS=$(render_getConfOption "$ACTION" '2-') # Check options passed to action. This is required in order to # aviod using options used already in this script. For example diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImages.sh b/Scripts/Bash/Functions/Render/render_doIdentityImages.sh index b065712..742062a 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImages.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImages.sh @@ -132,7 +132,8 @@ function render_doIdentityImages { done \ | awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk - # Execute post-rendering actions. + # Define and execute posible last-rendering actions for image + # rendeirng base action. for ACTION in "${LASTACTIONS[@]}"; do case "$ACTION" in @@ -141,15 +142,14 @@ function render_doIdentityImages { render_doIdentityImageKsplash ;; - renderGdmTgz:* ) - render_doIdentityImageGdm "$ACTION" + renderDm:* ) + render_doIdentityImageDm "$ACTION" ;; groupByType:* ) render_doIdentityGroupByType "$ACTION" ;; - esac done diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh b/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh index e93fc5e..5194394 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh @@ -30,7 +30,7 @@ function render_doIdentityTextFormats { local FILE="$1" # Get action to do over text file. - local OPTIONS=$(echo "$2" | cut -d: -f2-) + local OPTIONS=$(render_getConfOption "$2" '2-') # Remove some fmt's options. As we are applying fmt's options to a # file directly, there are some options like --version and --help diff --git a/Scripts/Bash/Functions/Render/render_getConfOption.sh b/Scripts/Bash/Functions/Render/render_getConfOption.sh new file mode 100755 index 0000000..0b436ce --- /dev/null +++ b/Scripts/Bash/Functions/Render/render_getConfOption.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# render_doIdentityImageDm.sh -- This function standardize the way of +# retrive option values from pre-rendering configuration files. Use +# this function whenever you need to retrive option values from +# pre-rendering configuration script. +# +# Usage: +# +# VAR=$(render_getConfOption "ACTION" "FIELD") +# +# Where: +# +# VAR is the name of the variable you want to store the option +# value retrived from your specification, using +# render_getConfOption's ACTION and FIELD arguments. If there is +# no variable assignment, the function outputs the option value +# to standard output without trailing newline. +# +# ACTION is the string definition set in the pre-rendering +# configuration script holding the action name and its options +# fields. +# +# FIELD is field number in the action string you want to +# retrive option from. By default options start from third field +# on. The first field is reserved for the action type (i.e., +# BASE, POST, LAST), and the second field is reserved for the +# action itself (e.g., renderImage, renderFormats, etc.). Note +# that this convenction can be altered if the action string has +# been modified (e.g., you stript the BASE field from action +# string) and passed the modified action string to another +# function for processing. +# +# Copyright (C) 2009-2010 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 render_getConfOption { + + 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-rendering configuration action definition. + VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate option value passed from pre-rendering configuration + # action definition. + VALUE=$(echo -n "${VALUE}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Output option value without trailing newline. + echo -n "$VALUE" + +}