Blame Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh

ae8a10
#!/bin/bash
ae8a10
#
c2645e
# render_svg_convertPngToDm.sh -- This function standardize production
c2645e
# of display managers (e.g., Gdm and Kdm). This function copies all
c2645e
# files needed into a temporal directory, realize expansion of
c2645e
# translation markers and packs all the files into a tar.gz package
c2645e
# that is used for installation. This function must be used as
c2645e
# last-rendition action for Gdm and Kdm directory specific
c2645e
# base-rendition actions.
ae8a10
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
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
c2645e
function render_svg_convertPngToDm {
ae8a10
8af4d8
    # Print separator line.
0ff158
    cli_printMessage '-' --as-separator-line
8af4d8
44b2ba
    # Initialize source and destination local variables.
44b2ba
    local SRC=''
44b2ba
    local DST=''
ae8a10
44b2ba
    # Initialize display manager type.
44b2ba
    local DM=$(render_getConfigOption "${ACTION}" '2')
ae8a10
44b2ba
    # Initialize screen resolutions the display manager theme will be
44b2ba
    # built for.
44b2ba
    local RESOLUTION=''
44b2ba
    local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3')
ae8a10
44b2ba
    # Verify screen resolutions. We cannot produce display manager
44b2ba
    # theme if no screen resolution has been specified.
44b2ba
    if [[ "$RESOLUTIONS" == '' ]];then
44b2ba
        cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line
44b2ba
    fi
ae8a10
44b2ba
    # Initialize theme information we are going to build the display
44b2ba
    # manager theme for.
334459
    local THEME=$(cli_getPathComponent $ACTIONVAL --motif)
334459
    local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name)
44b2ba
44b2ba
    # Initialize temporal directory where we collect all files needed
44b2ba
    # in order to create the tar.gz file. This intermediate step is
44b2ba
    # also needed in order to expand translation markers from XML and
44b2ba
    # Desktop definitions.
44b2ba
    local TMPDIR=$(cli_getTemporalFile 'dm')
44b2ba
44b2ba
    # Initialize source location for brands. This is the place where
44b2ba
    # brand information needed to build the display manager theme is
44b2ba
    # retrived from.
44b2ba
    local BRANDS=$(cli_getRepoTLDir)/Identity/Images/Brands
44b2ba
44b2ba
    # Initialize source location for backgrounds. This is the place
44b2ba
    # where background information needed to ubild the display manager
44b2ba
    # theme is retrived from. 
44b2ba
    local BGS=$(cli_getRepoTLDir)/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png
44b2ba
44b2ba
    # Initialize file variables. File variables are used build and
44b2ba
    # process the file relation between source and target locations. 
44b2ba
    local FILE=''
44b2ba
    local FILES=''
44b2ba
44b2ba
    # Define file relation between source and target locations, based
44b2ba
    # on whether we are producing GDM or KDM. Presently, both GDM and
44b2ba
    # KDM are very similar on files with the exception that GDM does
44b2ba
    # use icons near actions buttons (e.g., shutdown, reboot, session,
44b2ba
    # language) and KDM doesn't.
44b2ba
    case ${DM} in
44b2ba
44b2ba
        Gdm )
44b2ba
            FILES="\
44b2ba
            ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png
44b2ba
            ${OUTPUT}/release.png:centos-release.png
44b2ba
            ${OUTPUT}/screenshot.png:screenshot.png
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop
44b2ba
            $(dirname $TEMPLATE)/icon-language.png:icon-language.png
44b2ba
            $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png
44b2ba
            $(dirname $TEMPLATE)/icon-session.png:icon-session.png
44b2ba
            $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png
44b2ba
            "
44b2ba
            ;;
44b2ba
            
44b2ba
        Kdm )
44b2ba
            FILES="\
44b2ba
            ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png
44b2ba
            ${OUTPUT}/release.png:centos-release.png
44b2ba
            ${OUTPUT}/screenshot.png:screenshot.png
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop
44b2ba
            "
44b2ba
            ;;
44b2ba
44b2ba
        * )
44b2ba
            cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line
44b2ba
            ;;
44b2ba
    esac
44b2ba
44b2ba
    for FILE in $FILES;do
44b2ba
44b2ba
        # Define source location.
44b2ba
        SRC=$(echo $FILE | cut -d: -f1)
44b2ba
44b2ba
        # Define target location.
44b2ba
        DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2)
44b2ba
44b2ba
        # Verify source files.
44b2ba
        cli_checkFiles $SRC
44b2ba
44b2ba
        # Verify parent directory for target file.
44b2ba
        if [[ ! -d $(dirname $DST) ]];then
44b2ba
            mkdir -p $(dirname $DST)
44b2ba
        fi
eb0e14
44b2ba
        # Copy files from source to target location.
44b2ba
        cp ${SRC} ${DST}
ae8a10
44b2ba
        # Expand translation markers.
44b2ba
        if [[ ${DST} =~ "\.(xml|desktop)$"  ]];then
44b2ba
            cli_replaceTMarkers "${DST}"
44b2ba
        fi
ae8a10
44b2ba
    done
ae8a10
44b2ba
    # Move into temporal directory.
44b2ba
    pushd $TMPDIR > /dev/null
ae8a10
44b2ba
    for RESOLUTION in $RESOLUTIONS;do
ae8a10
44b2ba
        # Verify background information. If it doesn't exist go on
44b2ba
        # with the next one in the list.
44b2ba
        if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then
44b2ba
            continue
44b2ba
        fi
ae8a10
643925
        # Print action message.
44b2ba
        if [[ -f ${RESOLUTION}.tar.gz ]];then
0ff158
            cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line
0ff158
        else
0ff158
            cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line
0ff158
        fi
ae8a10
44b2ba
        # Copy background information.
44b2ba
        cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png
ae8a10
44b2ba
        # Create tar.gz file.
44b2ba
        tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME}
ae8a10
44b2ba
        # Move from temporal directory to its final location.
44b2ba
        mv ${RESOLUTION}.tar.gz ${OUTPUT}
ae8a10
44b2ba
    done
ec641d
d856c1
    # Return to where we were initially.
d856c1
    popd > /dev/null
d856c1
44b2ba
    # Remove temporal directory.
44b2ba
    rm -r ${TMPDIR}
44b2ba
ae8a10
}