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

ae8a10
#!/bin/bash
ae8a10
#
eb0e14
# render_doIdentityImageDm.sh -- This function porvides last-rendering
eb0e14
# action to create gdm or kdm themes tar.gz files for different
eb0e14
# motifs, screen resolutions, and major releases of CentOS
eb0e14
# distribution. 
eb0e14
#
eb0e14
#   Usage:
eb0e14
#
eb0e14
#       ACTIONS[0]='BASE:renderImage'
eb0e14
#       ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION'
eb0e14
#
eb0e14
#   Where:
eb0e14
#
eb0e14
#            TYPE = GNOME or KDE
eb0e14
#      RESOLUTION = Any screen resolution available as background
eb0e14
#                   (e.g., 800x600, 1024x768, 2048x1536, etc.)
eb0e14
#
eb0e14
#   For example, to produce GNOME display manager theme in 2048x1536,
eb0e14
#   1360x768, and 3271x1227 screen resolutions, for all major releases
eb0e14
#   available, use the following definition inside GDM pre-rendering
eb0e14
#   configuration script:
eb0e14
#
eb0e14
#       ACTIONS[0]='BASE:renderImage'
eb0e14
#       ACTIONS[1]='LAST:renderDm:GNOME:2048x1536 1360x768 3271x1227'
ae8a10
#
ae8a10
# Copyright (C) 2009-2010 Alain Reguera Delgado
ae8a10
# 
ae8a10
# This program is free software; you can redistribute it and/or modify
ae8a10
# it under the terms of the GNU General Public License as published by
ae8a10
# the Free Software Foundation; either version 2 of the License, or
ae8a10
# (at your option) any later version.
ae8a10
# 
ae8a10
# This program is distributed in the hope that it will be useful, but
ae8a10
# WITHOUT ANY WARRANTY; without even the implied warranty of
ae8a10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ae8a10
# General Public License for more details.
ae8a10
#
ae8a10
# You should have received a copy of the GNU General Public License
ae8a10
# along with this program; if not, write to the Free Software
ae8a10
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
ae8a10
# USA.
ae8a10
# 
ae8a10
# ----------------------------------------------------------------------
ae8a10
# $Id$
ae8a10
# ----------------------------------------------------------------------
ae8a10
eb0e14
function render_doIdentityImageDm {
ae8a10
ae8a10
    local RESOLUTIONS=''
ae8a10
    local VERSIONS=''
ae8a10
    local TPL=''
ae8a10
    local BGS=''
ae8a10
    local TMP=''
ae8a10
    local SYMBOL=''
eb0e14
    local DM=''
ae8a10
eb0e14
    # Get display manager passed from render.conf.sh pre-rendering
ae8a10
    # configuration script.
eb0e14
    DM=$(render_getConfOption "$1" '2')
eb0e14
eb0e14
    # Sanitate display manager possible values and define absolute
eb0e14
    # path to display manager design models (i.e., the place where
eb0e14
    # GdmGreeterTheme.xml and GdmGreeterTheme.desktop files are
eb0e14
    # stored) using display manager information passed from
eb0e14
    # render.conf.sh pre-rendering configuration script.
eb0e14
    if [[ $DM =~ '^GNOME$' ]];then
eb0e14
        TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/GDM
eb0e14
    elif [[ $DM =~ '^KDE$' ]];then
eb0e14
        TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/KDM
eb0e14
    else
eb0e14
        cli_printMessage "`eval_gettext "The display manager \\\"\\\$DM\\\" is not supported."`"
eb0e14
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
eb0e14
    fi
eb0e14
eb0e14
    # Check absolute path to display manager design models.
eb0e14
    cli_checkFiles $TPL 'd'
eb0e14
    if [[ $? -ne 0 ]];then
eb0e14
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
eb0e14
    fi
ae8a10
eb0e14
    # Get screen resolutions passed from render.conf.sh pre-rendering
eb0e14
    # configuration script.
eb0e14
    RESOLUTIONS=$(render_getConfOption "$1" '3')
ae8a10
ae8a10
    # Check sanitated screen resolutions.
eb0e14
    if [[ "$RESOLUTIONS" == '' ]];then
eb0e14
        cli_printMessage "`gettext "There is no resolution information to process."`"
ae8a10
        cli_printMessage $(caller) "AsToKnowMoreLine"
ae8a10
    fi
ae8a10
eb0e14
    # Build release numbers list we want to produce display manager
eb0e14
    # for. The release numbers are defined inside GDM and KDM
eb0e14
    # directories under
eb0e14
    # trunk/Translations/Identity/Themes/Distro/BootUp/ structure,
eb0e14
    # using the centos-art.sh script.
ae8a10
    VERSIONS=$(find $OPTIONVAL -regextype posix-egrep \
ae8a10
        -maxdepth 1 -type d -regex "^.*/${RELEASE_FORMAT}$" \
ae8a10
        | egrep $REGEX)
ae8a10
eb0e14
    # Check release numbers list.
eb0e14
    if [[ "$VERSIONS" == '' ]];then
eb0e14
        cli_printMessage "`gettext "There is no release number to work with"`" 
eb0e14
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
eb0e14
    fi
ae8a10
eb0e14
    # Define directory storing different screen resolution backgrounds
eb0e14
    # images used to build display manager in different resolutions.
ee4d8b
    BGS=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(cli_getThemeName)/Backgrounds/Img/Png
ae8a10
ae8a10
    # Define directory where temporal files are stored.
ae8a10
    TMP=$(cli_getThemeName)
ae8a10
eb0e14
    # Define png image file used as CentOS symbol. As convenction,
eb0e14
    # inside all CentOS art works (e.g., anaconda, firstboot, etc.),
eb0e14
    # we are using CentOS symbol at 48x48 pixels. This value seems to
eb0e14
    # be the middle dimension that fits all situations.
0dca57
    SYMBOL=/home/centos/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/Png/48.png
ae8a10
    cli_checkFiles $SYMBOL 'f'
eb0e14
    if [[ $? -ne 0 ]];then
eb0e14
        cli_printMessage "$(caller)" "AsToKnowMoreLine"
eb0e14
    fi
ae8a10
ae8a10
    for VERSION in $VERSIONS;do
ae8a10
ae8a10
        VERSION=$(basename $VERSION)
ae8a10
ae8a10
        # Define directory to store release-specific images.
ae8a10
        IMG=$OPTIONVAL/$VERSION/Img
ae8a10
eb0e14
        # Check existence of release-specific image directory.
eb0e14
        cli_checkFiles $IMG '-d' '' '--quiet'
eb0e14
        if [[ $? -ne 0 ]];then
eb0e14
            mkdir -p $IMG
eb0e14
        fi
eb0e14
ae8a10
        # Define directory to store release-specific tar.gz files. 
ae8a10
        TGZ=$OPTIONVAL/$VERSION/Tgz
ae8a10
eb0e14
        # Check existence of release-specific tar.gz directory.
ae8a10
        cli_checkFiles $TGZ 'd' '' '--quiet'
ae8a10
        if [[ $? -ne 0 ]];then
ae8a10
            mkdir -p $TGZ
ae8a10
        fi
ae8a10
ae8a10
        # Move into working directory.
ae8a10
        pushd $TGZ > /dev/null
ae8a10
        
ae8a10
        for RESOLUTION in $RESOLUTIONS;do
ae8a10
ae8a10
            cli_printMessage "$TGZ/${TMP}-${RESOLUTION}.tar.gz" "AsCreatingLine"
ae8a10
ae8a10
            # Check background existence for specified resolution.
ae8a10
            cli_checkFiles $BGS/$RESOLUTION.png 'f' '' '--quiet'
ae8a10
            if [[ $? -ne 0 ]];then
eb0e14
                cli_printMessage "`eval_gettext "There is not background for \\\"\\\$RESOLUTION\\\" resolution."`"
ae8a10
                cli_printMessage "$(caller)" "AsToKnowMoreLine"
ae8a10
            fi
ae8a10
ae8a10
            # Create temporal directory.
ae8a10
            if [[ ! -d $TMP ]]; then
ae8a10
                mkdir $TMP
ae8a10
            fi
ae8a10
eb0e14
            # Copy display manager theme files into temporal
eb0e14
            # directory.
ae8a10
            cp $SYMBOL	         		            $TMP/centos-symbol.png
ae8a10
            cp $IMG/release.png                     $TMP/centos-release.png
ae8a10
            cp $IMG/screenshot.png                  $TMP/screenshot.png
d296cd
            cp $BGS/${RESOLUTION}-final.png         $TMP/background.png
eb0e14
            if [[ $DM == 'GNOME' ]];then
eb0e14
                cp $TPL/*.png                       $TMP/
eb0e14
            fi
ae8a10
            cp $TPL/GdmGreeterTheme.xml             $TMP/${TMP}.xml
ae8a10
            cp $TPL/GdmGreeterTheme.desktop         $TMP/
ae8a10
ae8a10
            # Translate markers from design model files.
ae8a10
            sed -i "s!=THEME=!${TMP}!g" \
ae8a10
                $TMP/GdmGreeterTheme.desktop \
ae8a10
                $TMP/${TMP}.xml
ae8a10
ae8a10
            # Create tar.gz file.
ae8a10
            tar -czf "${TMP}-${RESOLUTION}.tar.gz" $TMP
ae8a10
ae8a10
            # Remove temporal directory.
ae8a10
            rm -r $TMP
ae8a10
ae8a10
        done
ae8a10
ae8a10
        # Return to where we were initially.
ae8a10
        popd > /dev/null
ae8a10
ae8a10
    done
ae8a10
ae8a10
}