Blob Blame History Raw
#!/bin/bash
#
# 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
# 
# 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_doIdentityImageDm {

    local RESOLUTIONS=''
    local VERSIONS=''
    local TPL=''
    local BGS=''
    local TMP=''
    local SYMBOL=''
    local DM=''

    # Get display manager passed from render.conf.sh pre-rendering
    # configuration script.
    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

    # 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 "There is no resolution information to process."`"
        cli_printMessage $(caller) "AsToKnowMoreLine"
    fi

    # 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)

    # 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 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. 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

        VERSION=$(basename $VERSION)

        # 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 tar.gz directory.
        cli_checkFiles $TGZ 'd' '' '--quiet'
        if [[ $? -ne 0 ]];then
            mkdir -p $TGZ
        fi

        # Move into working directory.
        pushd $TGZ > /dev/null
        
        for RESOLUTION in $RESOLUTIONS;do

            cli_printMessage "$TGZ/${TMP}-${RESOLUTION}.tar.gz" "AsCreatingLine"

            # 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 "$(caller)" "AsToKnowMoreLine"
            fi

            # Create temporal directory.
            if [[ ! -d $TMP ]]; then
                mkdir $TMP
            fi

            # 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
            if [[ $DM == 'GNOME' ]];then
                cp $TPL/*.png                       $TMP/
            fi
            cp $TPL/GdmGreeterTheme.xml             $TMP/${TMP}.xml
            cp $TPL/GdmGreeterTheme.desktop         $TMP/

            # Translate markers from design model files.
            sed -i "s!=THEME=!${TMP}!g" \
                $TMP/GdmGreeterTheme.desktop \
                $TMP/${TMP}.xml

            # Create tar.gz file.
            tar -czf "${TMP}-${RESOLUTION}.tar.gz" $TMP

            # Remove temporal directory.
            rm -r $TMP

        done

        # Return to where we were initially.
        popd > /dev/null

    done

}