|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
ab1d67 |
# render_doGrub.sh -- This function provides post-rendition
|
|
|
ce597a |
# action used to produce GRUB images.
|
|
|
4c79b5 |
#
|
|
|
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
|
|
|
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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
ab1d67 |
function render_doGrub {
|
|
|
4c79b5 |
|
|
|
80d088 |
# Define number of colors the images will be produced on.
|
|
|
80d088 |
local COLOR_NUMBER='14'
|
|
|
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.
|
|
|
ab1d67 |
local OPTIONS=$(render_getConfigOption "$ACTION" '2-')
|
|
|
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."`"
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine"
|
|
|
f16762 |
fi
|
|
|
f16762 |
done
|
|
|
4c79b5 |
|
|
|
80d088 |
# Define file name prefix.
|
|
|
80d088 |
local PREFIX="-${COLOR_NUMBER}c"
|
|
|
80d088 |
|
|
|
80d088 |
# Redefine file name prefix using options as reference. This is
|
|
|
80d088 |
# useful to differenciate final files produced using
|
|
|
80d088 |
# Floyd-Steinberg dithering and files which are not.
|
|
|
80d088 |
if [[ "$OPTIONS" =~ '-floyd' ]];then
|
|
|
80d088 |
PREFIX="${PREFIX}-floyd"
|
|
|
80d088 |
fi
|
|
|
80d088 |
|
|
|
80d088 |
# Define theme-specific palettes directory.
|
|
|
4478a0 |
local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes
|
|
|
b09897 |
|
|
|
80d088 |
# Define absolute path to GPL palette. This palettes should have
|
|
|
80d088 |
# 14 colors only. For more information on this see the GRUB's
|
|
|
80d088 |
# documentation.
|
|
|
80d088 |
local PALETTE_GPL=${PALETTES}/grub.gpl
|
|
|
80d088 |
|
|
|
80d088 |
# Verify GPL palette existence.
|
|
|
80d088 |
cli_checkFiles $PALETTE_GPL 'f'
|
|
|
80d088 |
|
|
|
80d088 |
# Define absolute path to PPM palette. The PPM palette is built
|
|
|
80d088 |
# from source palette (PALETTE_GPL) and provides the color
|
|
|
80d088 |
# information understood by `ppmremap', the program used to
|
|
|
80d088 |
# produce images in a specific amount of colors.
|
|
|
80d088 |
local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm")
|
|
|
80d088 |
|
|
|
80d088 |
# Create image in Netpbm superformat (PNM). The PNM image file is
|
|
|
80d088 |
# created from the PNG image rendered previously as centos-art
|
|
|
80d088 |
# base-rendition output. The PNM image is an intermediate format
|
|
|
80d088 |
# used to manipulate images through Netpbm tools.
|
|
|
9b4d7d |
cli_printMessage "${FILE}.pnm" "AsSavedAsLine"
|
|
|
4c79b5 |
pngtopnm -verbose \
|
|
|
9b4d7d |
< ${FILE}.png 2>${FILE}.log > ${FILE}.pnm
|
|
|
4c79b5 |
|
|
|
80d088 |
# Print the path to GPL palette.
|
|
|
80d088 |
cli_printMessage "$PALETTE_GPL" 'AsPaletteLine'
|
|
|
80d088 |
|
|
|
80d088 |
# Create PPM palette using GPL palette.
|
|
|
80d088 |
render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER"
|
|
|
80d088 |
|
|
|
80d088 |
# Reduce colors as specified in PPM palette. Here we use the PPM
|
|
|
80d088 |
# palette to enforce the color position in the image index and the
|
|
|
80d088 |
# Floyd-Steinberg dithering in order to improve color reduction.
|
|
|
f16762 |
cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine"
|
|
|
379ebf |
pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \
|
|
|
9b4d7d |
< ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm
|
|
|
4c79b5 |
|
|
|
80d088 |
# Remove PPM palette. It is no longer needed.
|
|
|
80d088 |
if [[ -f ${PALETTE_PPM} ]];then
|
|
|
80d088 |
rm $PALETTE_PPM
|
|
|
80d088 |
fi
|
|
|
80d088 |
|
|
|
f16762 |
# Create the 14 colors xpm.gz file.
|
|
|
f16762 |
cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine"
|
|
|
4c79b5 |
ppmtoxpm \
|
|
|
9b4d7d |
< ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \
|
|
|
9b4d7d |
&& gzip --force ${FILE}.xpm \
|
|
|
9b4d7d |
&& mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz
|
|
|
743971 |
|
|
|
4c79b5 |
}
|