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

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# render_doIdentityImageGrub.sh -- This function provides
15b1d2
# post-rendition action used to produce GRUB images.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
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.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function render_doIdentityImageGrub {
4c79b5
4c79b5
    local FILE=$1
f16762
    local ACTION="$2"
f16762
    local OPTIONS=''
f16762
f16762
    # Define 16 colors images default file name prefix.
f16762
    local PREFIX='-14c'
f16762
15b1d2
    # Define options using those passed to actions from pre-rendition
f16762
    # configuration script. These options are applied to pnmremap when
f16762
    # doing color reduction, so any option available for pnmremap
f16762
    # command can be passed to renderSyslinux functionality.
eb0e14
    OPTIONS=$(render_getConfOption "$ACTION" '2-')
f16762
f16762
    # Re-define 16 colors images default file name prefix using
f16762
    # options as reference. This is useful to differenciate final
f16762
    # files produced using Floyd-Steinberg dithering and files which
f16762
    # do not.
f16762
    if [[ "$OPTIONS" =~ '-floyd' ]];then
f16762
        PREFIX="${PREFIX}-floyd"
f16762
    fi
f16762
f16762
    # Check options passed to action. This is required in order to
f16762
    # aviod using options used already in this script. For example
f16762
    # -verbose and -mapfile options.
f16762
    for OPTION in $OPTIONS;do
f16762
        # Remove anything after equal sign inside option.
eb0e14
        OPTION=$(echo -n $OPTION | cut -d'=' -f1)
f16762
        if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then
f16762
            cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`"
f16762
            cli_printMessage "$(caller)" "AsToKnowMoreLine"
f16762
        fi
f16762
    done
4c79b5
db52a8
    # Define motif's palette location.
6e2366
    local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getThemeName)/Colors
db52a8
    
4c79b5
    # Define the Netpbm color palettes used when reducing colors.
4c79b5
    # These palettes should be 14 colors based. For more information
4c79b5
    # on this see the GRUB's documentation.
4c79b5
    local PALETTE_PPM=$PALETTES/grub.ppm
4c79b5
db52a8
    # Print which palette of colors centos-art.sh script is using to
db52a8
    # produce grub content. This is relevant in order to know if we
476434
    # are using whether trunk or branches palette of colors.
db52a8
    cli_printMessage "$PALETTE_PPM" 'AsPaletteLine'
db52a8
4c79b5
    # Check GRUB's palettes existence:  If there is no palette assume
15b1d2
    # that this is the first time you are rendition GRUB images. If
4c79b5
    # that is the case the script will provide you with the PNG format
4c79b5
    # which should be used as base to produce (using GIMP) the .gpl
4c79b5
    # palette.  The .gpl palette information is used to produced
4c79b5
    # (using GIMP) the colormap (.ppm) which is used to automate the
15b1d2
    # GRUB's 14 colors image (splash.png) rendition.  If there is no
4c79b5
    # palette available, do not apply color reduction, show a message,
4c79b5
    # and continue.
e4d34a
    cli_checkFiles $PALETTE_PPM
4c79b5
4c79b5
    # Create Netpbm superformat (PNM). PNM file is created from the
4c79b5
    # PNG image rendered previously. PNM is a common point for image
4c79b5
    # manipulation using Netpbm tools.
4c79b5
    cli_printMessage "$FILE.pnm" "AsSavedAsLine"
4c79b5
    pngtopnm -verbose \
4c79b5
        < $FILE.png \
4c79b5
        2>$FILE.log \
4c79b5
        > $FILE.pnm
4c79b5
743971
    # Reduce colors as specified in ppm palette of colors.
f16762
    cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine"
379ebf
    pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \
4c79b5
        < $FILE.pnm \
4c79b5
        2>>$FILE.log \
f16762
        > ${FILE}${PREFIX}.ppm
4c79b5
f16762
    # Create the 14 colors xpm.gz file.
f16762
    cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine"
4c79b5
    ppmtoxpm \
f16762
        < ${FILE}${PREFIX}.ppm \
4c79b5
        2>>$FILE.log \
4c79b5
        > $FILE.xpm \
743971
        && gzip --force $FILE.xpm \
f16762
        && mv $FILE.xpm.gz ${FILE}${PREFIX}.xpm.gz
743971
4c79b5
}