Blame Scripts/Functions/Render/render_doDm.sh

ae8a10
#!/bin/bash
ae8a10
#
ab1d67
# render_doDm.sh -- This function collects Display Manager (DM)
ce597a
# required files and creates a tar.gz package that groups them all
ce597a
# together. Use this function as last-rendition action for Gdm and Kdm
ce597a
# base-rendition actions.
eb0e14
#
7cd8e9
# Usage:
eb0e14
#
fa95b1
# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION'
eb0e14
#
7cd8e9
# Where:
eb0e14
#
fa95b1
# TYPE can be either `Gdm' or `Kdm'. These values correspond to the
fa95b1
# directory names used to store related design models.
eb0e14
#
fa95b1
# RESOLUTION represents the screen resolution tar.gz files are
fa95b1
# produced for (e.g., 800x600, 1024x768, 2048x1536, etc.). 
eb0e14
#
d856c1
# In order to produce tar.gz files correctly, both screen resolution
d856c1
# definition inside pre-rendition configuration script and background
d856c1
# name inside theme directory structure need to match one another.  If
d856c1
# one screen resolution is defined correctly, but there is no
d856c1
# background information for it, the related tar.gz file is not
d856c1
# produced and the next file in the list of files to process is
d856c1
# evaluated.
ae8a10
#
2d3646
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# 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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
ae8a10
# ----------------------------------------------------------------------
ae8a10
# $Id$
ae8a10
# ----------------------------------------------------------------------
ae8a10
ab1d67
function render_doDm {
ae8a10
d856c1
    local -a SRC
d856c1
    local -a DST
eb0e14
    local DM=''
d856c1
    local TGZ=''
d856c1
    local COUNT=0
d856c1
    local RESOLUTION=''
d856c1
    local RESOLUTIONS=''
ae8a10
8af4d8
    # Print separator line.
8af4d8
    cli_printMessage '-' 'AsSeparatorLine'
8af4d8
15b1d2
    # Get display manager passed from render.conf.sh pre-rendition
ae8a10
    # configuration script.
ab1d67
    DM=$(render_getConfigOption "${ACTION}" '2')
643925
 
d856c1
    # Sanitate display manager passed from render.conf.sh
d856c1
    # pre-rendition configuration script. Whatever value be retrived
d856c1
    # as display manager configuration option is converted to
643925
    # uppercase in order to match either Gdm or Kdm design model
d856c1
    # directory structures.
643925
    DM=$(cli_getRepoName "$DM" 'd')
ae8a10
15b1d2
    # Get screen resolutions passed from render.conf.sh pre-rendition
eb0e14
    # configuration script.
ab1d67
    RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3')
ae8a10
d856c1
    # Check screen resolutions passed from render.conf.sh
d856c1
    # pre-rendition configuration script.
eb0e14
    if [[ "$RESOLUTIONS" == '' ]];then
07c2fe
        cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine'
eee226
        cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine"
ae8a10
    fi
ae8a10
d856c1
    # Define source files using absolute paths.
47e16e
    SRC[0]=$(cli_getRepoTLDir)/Identity/Images/Brands/centos-symbol-resized-48.png
643925
    SRC[1]=${OUTPUT}/release.png
643925
    SRC[2]=${OUTPUT}/screenshot.png
86c3d1
    SRC[3]=$(dirname $TEMPLATE)/GdmGreeterTheme.xml
86c3d1
    SRC[4]=$(dirname $TEMPLATE)/GdmGreeterTheme.desktop
cff13a
    SRC[5]=$(cli_getRepoTLDir)/Identity/Images/Themes/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png
86c3d1
    SRC[6]=$(dirname $TEMPLATE)/icon-language.png
86c3d1
    SRC[7]=$(dirname $TEMPLATE)/icon-reboot.png
86c3d1
    SRC[8]=$(dirname $TEMPLATE)/icon-session.png
86c3d1
    SRC[9]=$(dirname $TEMPLATE)/icon-shutdown.png
d856c1
d856c1
    # Define name used as temporal holder to build tar.gz file. 
d856c1
    TGZ=$(cli_getPathComponent '--theme-name')
d856c1
d856c1
    # Define target files using relative paths.
d856c1
    DST[0]=${TGZ}/centos-symbol.png
d856c1
    DST[1]=${TGZ}/centos-release.png
d856c1
    DST[2]=${TGZ}/screenshot.png
d856c1
    DST[3]=${TGZ}/${TGZ}.xml
d856c1
    DST[4]=${TGZ}/GdmGreeterTheme.desktop
d856c1
    DST[5]=${TGZ}/background.png
d856c1
    DST[6]=${TGZ}/icon-language.png
d856c1
    DST[7]=${TGZ}/icon-reboot.png
d856c1
    DST[8]=${TGZ}/icon-session.png
d856c1
    DST[9]=${TGZ}/icon-shutdown.png
d856c1
d856c1
    # Move into the working directory.
643925
    pushd ${OUTPUT} > /dev/null
d856c1
d856c1
    # Create directory used as temporal holder to build tar.gz file.
d856c1
    if [[ ! -d ${TGZ} ]];then
d856c1
        mkdir ${TGZ}
eb0e14
    fi
ae8a10
d856c1
    for RESOLUTION in $RESOLUTIONS;do
d991f5
d856c1
        while [[ $COUNT -lt ${#SRC[*]} ]];do
ae8a10
d856c1
            if [[ $COUNT -eq 5 ]];then
ae8a10
d856c1
                # Redefine background information using resolution as
d856c1
                # reference. Avoid concatenation.
d856c1
                SRC[$COUNT]=$(echo "${SRC[$COUNT]}" | cut -d/ -f-13)/${RESOLUTION}-final.png
ae8a10
d856c1
                # If background information defined inside
d856c1
                # pre-rendition configuration script doesn't match
d856c1
                # background information inside theme-specific
d856c1
                # backgrounds directory structure, try the next
d856c1
                # background definition.
d856c1
                if [[ ! -f ${SRC[$COUNT]} ]];then
d856c1
                    continue 2
d856c1
                fi
d856c1
        
d856c1
            elif [[ $COUNT =~ '^[6-9]$' ]];then
ae8a10
643925
                # If display manager is Kdm, then increment counter and
643925
                # resume the next iteration. Icons aren't used on Kdm,
d856c1
                # so there's no need to have them inside it.
643925
                if [[ $DM =~ '^Kdm$' ]];then
d856c1
                    COUNT=$(($COUNT + 1))
d856c1
                    continue
d856c1
                fi
ae8a10
d856c1
            fi
eb0e14
d856c1
            # Check existence of source files.
d856c1
            cli_checkFiles ${SRC[$COUNT]}
ae8a10
d856c1
            # Copy files from source to target location.
d856c1
            cp ${SRC[$COUNT]} ${DST[$COUNT]}
ae8a10
d856c1
            # Replace common translation markers from design model
d856c1
            # files with appropriate information.
d856c1
            if [[ $COUNT =~ '^(3|4)$'  ]];then
79e54d
                cli_replaceTMarkers "${DST[$COUNT]}"
8b5668
            fi
ae8a10
d856c1
            # Increment counter.
d856c1
            COUNT=$(($COUNT + 1))
ae8a10
d856c1
        done
ae8a10
d856c1
        # Reset counter.
d856c1
        COUNT=0
ae8a10
643925
        # Print action message.
643925
        cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" "AsCreatingLine"
ae8a10
d856c1
        # Create tar.gz file.
d856c1
        tar -czf "${RESOLUTION}.tar.gz" $TGZ
ae8a10
d856c1
    done
ae8a10
d856c1
    # Remove directory used as temporal holder to build targ.gz
d856c1
    # file.
d856c1
    rm -r $TGZ
ae8a10
d856c1
    # Remove release-specific images.
d856c1
    cli_printMessage "${SRC[1]}" "AsDeletingLine"
d856c1
    rm ${SRC[1]}
d856c1
    cli_printMessage "${SRC[2]}" "AsDeletingLine"
d856c1
    rm ${SRC[2]}
ec641d
d856c1
    # Return to where we were initially.
d856c1
    popd > /dev/null
d856c1
ae8a10
}