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

ae8a10
#!/bin/bash
ae8a10
#
ae8a10
# render_doIdentityImageGdm.sh -- This function creates gdm tar.gz
ae8a10
# files for different motifs, screen resolutions and major releases of
ae8a10
# CentOS distribution.
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
ae8a10
function render_doIdentityImageGdm {
ae8a10
ae8a10
    local RESOLUTIONS=''
ae8a10
    local VERSIONS=''
ae8a10
    local TPL=''
ae8a10
    local BGS=''
ae8a10
    local TMP=''
ae8a10
    local SYMBOL=''
ae8a10
ae8a10
    # Get screen resolutions passed from render.conf.sh pre-rendering
ae8a10
    # configuration script.
ae8a10
    RESOLUTIONS=$(echo "$1" | cut -d: -f2-)
ae8a10
ae8a10
    # Sanitate screen resolutions.
ae8a10
    RESOLUTIONS=$(echo "${RESOLUTIONS}" \
ae8a10
        | sed -r 's!^ *!!g' \
ae8a10
        | sed -r 's!( |:|,|;) *! !g' \
ae8a10
        | sed -r 's! *$!!g')
ae8a10
ae8a10
    # Check sanitated screen resolutions.
ae8a10
    if [[ "$RESOLUTIONS" == "" ]];then
ae8a10
        cli_printMessage "`gettext "render_doIdentityImageGdm: There is no resolution information to process."`"
ae8a10
        cli_printMessage $(caller) "AsToKnowMoreLine"
ae8a10
    fi
ae8a10
ae8a10
    # Define release-specific directories we want to produce gdm for.
ae8a10
    VERSIONS=$(find $OPTIONVAL -regextype posix-egrep \
ae8a10
        -maxdepth 1 -type d -regex "^.*/${RELEASE_FORMAT}$" \
ae8a10
        | egrep $REGEX)
ae8a10
ae8a10
    # Define directory where design models (e.g., GdmGreeterTheme.xml,
ae8a10
    # GdmGreeterTheme.desktop) are stored.
ae8a10
    TPL=/home/centos/artwork/trunk/Identity/Themes/Models/${THEMEMODEL}/Distro/BootUp/GDM/
ae8a10
ae8a10
    # Define directory holding backgrounds.
ae8a10
    BGS=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(cli_getThemeName)/Backgrounds/Img
ae8a10
ae8a10
    # Define directory where temporal files are stored.
ae8a10
    TMP=$(cli_getThemeName)
ae8a10
ae8a10
    # Define png image file used as CentOS symbol. We are using the
ae8a10
    # symbol at 48x48 pixels.
ae8a10
    SYMBOL=/home/centos/artwork/trunk/Identity/Brands/Img/CentOS/Symbol/5c-a/48.png
ae8a10
    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.
ae8a10
        IMG=$OPTIONVAL/$VERSION/Img
ae8a10
ae8a10
        # Define directory to store release-specific tar.gz files. 
ae8a10
        TGZ=$OPTIONVAL/$VERSION/Tgz
ae8a10
ae8a10
        # Check existence of release-specific 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
ae8a10
                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
ae8a10
            # Copy gdm theme files into temporal 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
ae8a10
            cp $BGS/$RESOLUTION.png                 $TMP/background.png
ae8a10
            cp $TPL/*.png         		            $TMP/
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
}