Blame Scripts/Bash/Functions/Render/render_doIdentityImageDm.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
#
7cd8e9
# Usage:
eb0e14
#
7cd8e9
# ACTIONS[0]='BASE:renderImage'
7cd8e9
# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION'
eb0e14
#
7cd8e9
# Where:
eb0e14
#
7cd8e9
# TYPE = GNOME or KDE
7cd8e9
# RESOLUTION = Any screen resolution available as background
7cd8e9
# (e.g., 800x600, 1024x768, 2048x1536, etc.)
eb0e14
#
7cd8e9
# For example, to produce GNOME display manager theme in 2048x1536,
7cd8e9
# 1360x768, and 3271x1227 screen resolutions, for all major releases
7cd8e9
# available, use the following definition inside GDM pre-rendering
7cd8e9
# configuration script:
eb0e14
#
7cd8e9
# ACTIONS[0]='BASE:renderImage'
7cd8e9
# ACTIONS[1]='LAST:renderDm:GNOME:2048x1536 1360x768 3271x1227'
ae8a10
#
72c8a5
# Copyright (C) 2009-2011  Alain Reguera Delgado
ae8a10
# 
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.
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
07c2fe
        cli_printMessage "`eval_gettext "The display manager \\\`\\\$DM' is not supported."`" 'AsErrorLine'
eb0e14
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
eb0e14
    fi
eb0e14
eb0e14
    # Check absolute path to display manager design models.
b76c02
    cli_checkFiles "$TPL" 'd'
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
07c2fe
        cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine'
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.
8b5668
    VERSIONS=$(find $ACTIONVAL -regextype posix-egrep -maxdepth 1 \
8b5668
        -type d -regex "^.*/${RELEASE_FORMAT}$")
ae8a10
eb0e14
    # Check release numbers list.
eb0e14
    if [[ "$VERSIONS" == '' ]];then
07c2fe
        cli_printMessage "`gettext "There is no release number to work with"`" 'AsErrorLine'
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.
6e2366
    BGS=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getThemeName)/Backgrounds/Img/Png
d991f5
d991f5
    # Define directory where temporal files are stored. Remember that
d991f5
    # cli_getThemeName may return branch enumeration if we are
d991f5
    # rendering under branches/ directory structure. In order to build
d991f5
    # the theme directory we only use the thame name, not the numerial
d991f5
    # information, so be sure to remove it here.
d991f5
    TMP=$(cli_getThemeName | cut -d/ -f1)
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.
0d7fc5
    SYMBOL=/home/centos/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/48.png
b76c02
    cli_checkFiles "$SYMBOL" 'f'
ae8a10
ae8a10
    for VERSION in $VERSIONS;do
ae8a10
ae8a10
        VERSION=$(basename $VERSION)
ae8a10
ae8a10
        # Define directory to store release-specific images.
8219f0
        IMG=$ACTIONVAL/$VERSION/Img
ae8a10
eb0e14
        # Check existence of release-specific image directory.
b76c02
        cli_checkFiles "$IMG" 'd'
eb0e14
ae8a10
        # Define directory to store release-specific tar.gz files. 
8219f0
        TGZ=$ACTIONVAL/$VERSION/Tgz
ae8a10
eb0e14
        # Check existence of release-specific tar.gz directory.
b76c02
        cli_checkFiles "$TGZ" 'd'
ae8a10
ae8a10
        # Move into working directory.
ae8a10
        pushd $TGZ > /dev/null
ae8a10
        
ae8a10
        for RESOLUTION in $RESOLUTIONS;do
ae8a10
8b5668
            # Check background existence for specified resolution. If
8b5668
            # the background resolution doesn't exist, skip it and
8b5668
            # continue with the next resolution in the list.
8b5668
            if [[ -f "$BGS/${RESOLUTION}-final.png" ]];then
8b5668
                cli_printMessage "$TGZ/${TMP}-${RESOLUTION}-final.tar.gz" "AsCreatingLine"
8b5668
            else
8b5668
                continue
8b5668
            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
ec641d
        # Output division rule.
ec641d
        echo '----------------------------------------------------------------------'
ec641d
ae8a10
    done
ae8a10
ae8a10
}