From beebb5ebe62645f333e59c88c3c54cc94951fd45 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 18 2013 04:40:13 +0000 Subject: Update render module's directory structure. --- diff --git a/Automation/Modules/Render/Conf/conf.sh b/Automation/Modules/Render/Conf/conf.sh deleted file mode 100755 index 269e016..0000000 --- a/Automation/Modules/Render/Conf/conf.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# -# conf.sh -- This function standardizes the way images are produced -# from configuration files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function conf { - - # Initialize local variables. - local MODEL='' - local -a MODELS - local FORMAT='' - local HEIGHT='' - local FGCOLOR='' - local BGCOLOR='' - - # Define list with all section names. These are the final file - # names we want to produce images for. - local FILENAME='' - local FILENAMES=$(cli_getConfigSectionNames $TEMPLATE) - - for FILENAME in $FILENAMES;do - - # Retrieve models you want to produce the image from. Notice - # that relative path passed in this option must point to one - # existent file inside the working copy. - for MODEL in $(cli_getConfigValue "$TEMPLATE" "$FILENAME" "models");do - MODELS[((++${#MODELS[*]}))]=${TCAR_WORKDIR}/${MODEL} - done - - # Retrieve formats you want to produce the image for. This - # variable contains one or more image format supported by - # ImageMagick. For example, `xpm', `jpg', 'tiff', etc. - local FORMATS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "formats") - if [[ -z ${FORMATS} ]];then - FORMATS="xpm pdf jpg tif" - fi - - # Retrieve heights you want to produce the image for. This - # variable contains one or more numerical values. For example, - # `16', `24', `32', etc. - local HEIGHTS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "heights") - if [[ -z ${HEIGHTS} ]];then - HEIGHTS="16 20 22 24 32 36 38 40 48 64 72 78 96 112 124 128 148 164 196 200 512" - fi - - # Retrieve foreground colors you want to produce the image - # for. This variable contains one or more color number in - # hexadecimal format. For example, `000000', `ffffff', etc. - local FGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "fgcolors") - if [[ -z ${FGCOLORS} ]];then - FGCOLORS="000000" - fi - - # Retrieve background colors you want to produce the image - # for. This variable contains one or more color number in - # hexadecimal format with opacity information included. - # Opacity is specified between 0.0 and 1.0 where 0.0 is full - # transparency and 1.0 full opacity. For example, the - # following values are accepted: `000000-0', `ffffff-1', etc. - local BGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "bgcolors") - if [[ -z ${BGCOLORS} ]];then - BGCOLORS="000000-0" - fi - - # Retrieve command-line you want execute to produce the image. - # For example, `/usr/bin/convert +append' - local COMMAND=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "command") - if [[ -z ${COMMAND} ]];then - COMMAND=/bin/cp - fi - - for FGCOLOR in $FGCOLORS;do - - # Verify value passed as foreground color. - cli_checkFiles ${FGCOLOR} --match="^[a-fA-F0-9]{3,6}$" - - for BGCOLOR in $BGCOLORS;do - - # Verify value passed as background color. - cli_checkFiles ${BGCOLOR} --match="^[a-fA-F0-9]{6}-(0|1)$" - - for HEIGHT in $HEIGHTS;do - - # Verify value passed as height. - cli_checkFiles ${HEIGHT} --match="^[[:digit:]]+$" - - # Do base rendition actions. - conf_setBaseRendition - - done - done - done - - # Reset models list to prevent it from growing for each file - # name (configuration section) iteration and create this way - # unexpected images as final result. - unset MODELS - - done - -} diff --git a/Automation/Modules/Render/Conf/conf_setBaseRendition.sh b/Automation/Modules/Render/Conf/conf_setBaseRendition.sh deleted file mode 100755 index 4962373..0000000 --- a/Automation/Modules/Render/Conf/conf_setBaseRendition.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# -# conf_setBaseRendition.sh -- This function standardizes base actions -# related to image production through configuration files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function conf_setBaseRendition { - - local COUNTER=0 - local EXPORTID="CENTOSARTWORK" - local -a MODEL_INSTANCES - local -a IMAGE_INSTANCES - local -a IMAGE_COMMANDS - - # Define absolute path to output location. This is the location - # inside the working copy all images will be stored in. - local OUTPUT=${OUTPUT}/${FGCOLOR}/${BGCOLOR}/${HEIGHT}/${FILENAME} - - # Define which command will be used to output the template - # content. This is required because template files might be found - # as compressed files inside the repository. - local VIEWER="/bin/cat" - - while [[ $COUNTER -lt ${#MODELS[*]} ]];do - - # Verify existence and extension of design models. - cli_checkFiles ${MODELS[$COUNTER]} -f --match='\.(svgz|svg)$' - - # Define file name for design model instances. We need to use - # a random string in from of it to prevent duplication. - # Remember that different files can have the same name in - # different locations. Use the correct file information. - MODEL_INSTANCES[$COUNTER]=${TMPDIR}/${RANDOM}-$(basename ${MODELS[$COUNTER]}) - - # Define file name for image instances. We need to use a - # random string in from of it to prevent duplication. - # Remember that different files can have the same name in - # different locations. Use the correct file information. - IMAGE_INSTANCES[$COUNTER]=${TMPDIR}/${RANDOM}-$(basename ${MODELS[$COUNTER]} \ - | sed -r 's/\.(svgz|svg)$/.png/') - - # Redefine command used to read design models. - if [[ $(file -b -i ${MODELS[$COUNTER]}) =~ '^application/x-gzip$' ]];then - VIEWER="/bin/zcat" - fi - - # Create uncompressed design model instances in order to make - # color replacements without affecting original design models. - $VIEWER ${MODELS[$COUNTER]} > ${MODEL_INSTANCES[$COUNTER]} - - # Make your best to be sure the design model instance you are - # processing is a valid scalable vector graphic. - cli_checkFiles ${MODEL_INSTANCES[$COUNTER]} --mime="text/xml" - - # Make color replacements to each design model instance before - # render them using Inkscape. - if [[ ${FGCOLOR} != '000000' ]];then - sed -i -r "s/((fill|stroke):#)000000/\1${FGCOLOR}/g" ${MODEL_INSTANCES[$COUNTER]} - fi - - # Create list of Inkscape commands based for each design model - # set in the configuration file. - IMAGE_COMMANDS[${COUNTER}]="${MODEL_INSTANCES[$COUNTER]} \ - --export-id=${EXPORTID} \ - --export-png=${IMAGE_INSTANCES[$COUNTER]} \ - --export-background=$(echo ${BGCOLOR} | cut -d'-' -f1) \ - --export-background-opacity=$(echo ${BGCOLOR} | cut -d'-' -f2) \ - --export-height=${HEIGHT}" - - # Create PNG image based on design models. - inkscape ${IMAGE_COMMANDS[$COUNTER]} > /dev/null - - COUNTER=$(( $COUNTER + 1 )) - - done - - cli_printMessage "${OUTPUT}" --as-creating-line - - # Verify existence of output directory. - if [[ ! -d $(dirname ${OUTPUT}) ]];then - mkdir -p $(dirname ${OUTPUT}) - fi - - # Apply command to PNG images produced from design models to - # construct the final PNG image. - ${COMMAND} ${IMAGE_INSTANCES[*]} ${OUTPUT} - - # Remove instances to save disk space. There is no need to have - # unused files inside the temporal directory. They would be - # consuming space unnecessarily. Moreover, there is a remote - # chance of name collapsing (because the huge number of files that - # would be in place and the week random string we are putting in - # front of files) which may produce unexpected results. - rm ${IMAGE_INSTANCES[*]} ${MODEL_INSTANCES[*]} - - # Create path for different image formats creation using PNG image - # extension as reference. - local TARGET=$(echo ${OUTPUT} | sed -r "s/\.png$//") - - # Convert images from PNG to those formats specified in the - # configuration file. - for FORMAT in ${FORMATS};do - cli_printMessage "${TARGET}.${FORMAT}" --as-creating-line - convert ${OUTPUT} ${TARGET}.${FORMAT} - done - -} diff --git a/Automation/Modules/Render/Docbook/docbook.sh b/Automation/Modules/Render/Docbook/docbook.sh deleted file mode 100755 index 0cb4d7f..0000000 --- a/Automation/Modules/Render/Docbook/docbook.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -# docbook.sh -- This function performs base-rendition actions for -# DocBook files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook { - - # Define absolute path to XSL files used for transforming DocBook - # into other formats. - local DOCBOOK_XSL="${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Xsl" - - # Define absolute path to DocBook models. This path must take - # until the directory which holds the main documentation docbook - # file. - local DOCBOOK_MODELS="$(dirname ${TEMPLATE})" - - # Verify absolute path to DocBook models. - cli_checkFiles ${DOCBOOK_MODELS} -d - - # Create the non-translated instance of design model. - cp ${TEMPLATE} ${INSTANCE} - - # Expand common contents inside instance. - docbook_setExpansionLicenses ${INSTANCE} - - # When translated instances are rendered, system entities (e.g., - # `%entity-name;') don't appear in the translated instance (it - # seems that xml2po removes them) and this provokes DocBook - # validation to fail. So in order to pass the validation - # successfully and automate the whole creation of system entities, - # don't let this duty ion users'. Instead, make centos-art.sh - # script responsible of it. - docbook_setExpansionSystemEntities ${INSTANCE} - - # Print validating action. - cli_printMessage "${INSTANCE}" --as-validating-line - - # Validate translated instance before processing it. This step is - # very important in order to detect document's malformations and - # warn you about it, so you can correct them. It is also necessary - # to save them in a new file in order to make translation markers - # expansion possible before transforming the DocBook instance into - # other formats. - xmllint --valid --noent ${INSTANCE} > ${INSTANCE}.tmp - if [[ $? -ne 0 ]];then - cli_printMessage "`gettext "Validation failed."`" --as-error-line - fi - - # Update instance to add translation markers expansion. - mv ${INSTANCE}.tmp ${INSTANCE} - - # Expand translation markers on the temporal instance with - # entities already expanded. - cli_expandTMarkers ${INSTANCE} - - # Verify translation file existence apply translation to docbook - # design model instance in order to produce the translated design - # model instance. - if [[ -f ${TRANSLATION} ]];then - docbook_setTranslation ${INSTANCE} - fi - - # Convert DocBook source files to other formats. - docbook_setConversionXhtmlChunks ${INSTANCE} - docbook_setConversionXhtml ${INSTANCE} - docbook_setConversionText - - # NOTE: The current transformation from DocBook to PDF fails when - # we started to use DocBook tags inside DocBook files. - # Probably we need to test what happen when a newer release of XSL - # is used. Thus, comment production of PDF files until it can be - # produced correctly. - #docbook_setConversionXml2Pdf - - # NOTE: From version 5.0 on, DocBook specification is no longer a - # SGML specification but an XML specification only. Thus, - # transformations related to DocBook SGML specification won't be - # supported in `centos-art.sh' script. - - # Perform format post-rendition. - docbook_setPostRendition - - # Perform format last-rendition. - docbook_setLastRendition - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setConversionText.sh b/Automation/Modules/Render/Docbook/docbook_setConversionText.sh deleted file mode 100755 index 7c4673c..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setConversionText.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# svg_convertToText.sh -- This function takes the XHTML file produced -# by docbook_setConversionXhtml and produces one plain-text file (i.e., -# without markup inside). -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setConversionText { - - # Verify existence of HTML file. If `.xhtml' file doesn't exist - # don't create text file. The `.xhtml' file is required in order - # to create the `.txt' file. - if [[ ! -f ${FILE}.xhtml ]];then - return - fi - - local COMMAND='' - local OPTIONS='' - - # Define the command path to text-based web browser and options - # used to produce plain-text files. Most of these programs have a - # dump option that print formatted plain-text versions of given - # HTML file to stdout. - if [[ -x '/usr/bin/lynx' ]];then - COMMAND='/usr/bin/lynx' - OPTIONS='-force_html -nolist -width 70 -dump' - elif [[ -x '/usr/bin/elinks' ]];then - COMMAND='/usr/bin/elinks' - OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' - elif [[ -x '/usr/bin/w3m' ]];then - COMMAND='/usr/bin/w3m' - OPTIONS='-dump' - fi - - if [[ $COMMAND != '' ]];then - - # Print action message. - if [[ -f ${FILE}.txt ]];then - cli_printMessage "${FILE}.txt" --as-updating-line - else - cli_printMessage "${FILE}.txt" --as-creating-line - fi - - # Convert from HTML to plain-text without markup. - ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt - - else - cli_printMessage "`gettext "No way to convert from XHTML to plain-text found."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setConversionXhtml.sh b/Automation/Modules/Render/Docbook/docbook_setConversionXhtml.sh deleted file mode 100755 index 1c9f0a6..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setConversionXhtml.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# docbook_setConversionXhtml.sh -- This function uses DocBook XML as input -# and applies XSL stylesheets to produce a big XHTML files as output. -# The procedure was taken from the documentation of -# `docbook-style-xsl-1.69.1-5.1' package, which says: ---To publish -# HTML from your XML documents, you just need an XSL engine.---. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setConversionXhtml { - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SOURCE_FILE=${1} - - # Define absolute path to xhtml target file. This is the final - # location the xhtml file produced as result of DocBook to xhtml - # transformation will be stored in. - local TARGET_FILE=${FILE}-xhtml/$(basename ${FILE}).xhtml - - # Define absolute path to xhtml target file directory. This is the - # location the xhtml target file will be sotred in. - local TARGET_FILE_DIR=$(dirname ${TARGET_FILE}) - - # Print action message. - if [[ -f ${FILE}.xhtml ]];then - cli_printMessage "${TARGET_FILE}" --as-updating-line - else - cli_printMessage "${TARGET_FILE}" --as-creating-line - fi - - # Prepare XSL final instances used in transformations. - docbook_setStyles $(cli_getFilesList \ - ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(single|common)\.xsl$') - - # Clean up output directory. This is required in order to prevent - # old files from remaining therein when they are no longer needed. - if [[ -d ${TARGET_FILE_DIR} ]];then - rm -r "${TARGET_FILE_DIR}" - fi - mkdir ${TARGET_FILE_DIR} - - # Transform DocBook XML to XHTML suppressing all stderr output. - xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null - - # Create `css' and `images' directories. In order to save disk - # space, these directories are linked (symbolically) to their - # respective locations inside the working copy. - ln -fs ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE_DIR}/Css - ln -fs ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE_DIR}/Images - - # Remove XSL instance files. - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setConversionXhtmlChunks.sh b/Automation/Modules/Render/Docbook/docbook_setConversionXhtmlChunks.sh deleted file mode 100755 index 4caf61f..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setConversionXhtmlChunks.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# docbook_setConversionXhtmlChunks.sh -- This function uses DocBook XML as -# input and applies XSL stylesheets to produce a directory with many -# XHTML files as output. The procedure was taken from the -# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says: -# ---To publish HTML from your XML documents, you just need an XSLT -# engine.---. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setConversionXhtmlChunks { - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SOURCE_FILE=${1} - - # Define absolute path to XHTML target file. This is the final - # location the XHTML file produced as result of DocBook to PDF - # transformation will be stored in. - local TARGET_FILE="${FILE}-xhtml-chunks/" - - # Clean up output directory. This is required in order to prevent - # old files from remaining therein when they are no longer needed. - if [[ -d ${TARGET_FILE} ]];then - rm -r "${TARGET_FILE}" - fi - mkdir ${TARGET_FILE} - - # Print action message. - cli_printMessage "${TARGET_FILE}" --as-creating-line - - # Prepare XSL final instances used in transformations. - docbook_setStyles $(cli_getFilesList \ - ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(chunks|common)\.xsl$') - - # Transform DocBook XML to XHTML suppressing all stderr output. - xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null - - # Create `css' and `images' directories. In order to save disk - # space, these directories are linked (symbolically) to their - # respective locations inside the working copy. Be sure to remove - # previous links first to prevent a recursive creation of links. - ln -sf ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE}/Css - ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE}/Images - - # Remove XSL instance files. - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setConversionXml2Pdf.sh b/Automation/Modules/Render/Docbook/docbook_setConversionXml2Pdf.sh deleted file mode 100755 index f639e93..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setConversionXml2Pdf.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# -# docbook_setConversionXml2Pdf.sh -- This function transforms DocBook -# files which have set the XML DTD in them. To produce PDF from -# DocBook XML DTD, we need an XSLT engine (e.g., through `xsltproc' -# command) to produce formatting objects (FO), which then must be -# processed with an FO engine (e.g., through `pdfxmltex' command, -# which uses PassiveTex) to produce the PDF output. -# -# In this configuration and using default configuration settings, I've -# presented the following problems: -# -# 1. Something is wrong with headings. They are not expanded along the -# whole page-body. They seem to be rendered in a reduced width (1 inch -# approximately). This provokes the heading to be broken in a -# two-to-five letters column and sometimes it overlaps the sectioning -# titles (e.g., chapter, section). I tried to customize the value of -# `header.column.widths' and `page.margin.top' but it seems to be not -# there where I need to touch. -# -# 2. TOC's indentation is not rendered. Even the `toc.indent.width' -# property is set to 24 by default. -# -# 3. Inside lists, when items are more than one line, the indentation -# seems to work for the first line only. All other lines in the same -# item are not indented and begin completely unaligned. -# -# 4. Long file paths near the end of page-body aren't hyphenated. -# Even the `hyphenate' property is set to `true' by default. -# -# In this configuration and using default configuration settings, I've -# presented the following advantages: -# -# 1. It is possible to produce localized PDF outputs through -# `xml2po', the default way of producing localized content inside -# the `centos-art.sh' script. -# -# To make the whole process transparent, a temporal directory is -# created for intermediate works and final files are moved then to -# their final location. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setConversionXml2Pdf { - - # Print action message. - cli_printMessage "${FILE}.pdf" --as-creating-line - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SRC=${INSTANCE} - - # Define absolute path to PDF target file. This is the final - # location the PDF file produced as result of DocBook to PDF - # transformation will be stored in. - local DST="${FILE}.pdf" - - # Define file name of formatting object (.fo) file. This file is - # an intermediate file needed to produced the PDF. - local FO=$(echo ${INSTANCE} | sed -r 's/docbook$/fo/g') - - # Define file name of PDF file. This is the file we were looking - # for and the one moved, once produced. - local PDF=$(echo ${INSTANCE} | sed -r 's/docbook$/pdf/g') - - # Prepare XSL final instances used in transformations. - docbook_setStyles "${DOCBOOK_XSL}/docbook2fo.xsl" - - # Create link to `Images' directory. This is the directory where - # images used by documentation are stored in. Be sure to remove - # previous links first to prevent a recursive creation of links. - ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv $(dirname ${INSTANCE})/Images - - # Create formatting object suppressing output from stderr. - xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} 2> /dev/null - - # Create PDF format from formatting object. Because we are using - # relative path to access `Images', it is necessary to move the - # directory stack into the temporal directory where instance files - # are created. Otherwise, the location used to load images will - # fail. - if [[ $? -eq 0 ]];then - pushd $(dirname ${INSTANCE}) > /dev/null - xmlto -o $(dirname ${FILE}) pdf ${FO} - popd > /dev/null - else - cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setExpansionLicenses.sh b/Automation/Modules/Render/Docbook/docbook_setExpansionLicenses.sh deleted file mode 100755 index cb3a032..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setExpansionLicenses.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# docbook_setExpansionLicenses.sh -- This function modifies the final -# DocBook instance to add license information. We are doing this way -# because using XInclude doesn't work and we want to reuse license -# information in all documents. So, if we cannot link the files, we -# modify the final instance and append the license information to it. -# Later, to reuse translation messages, the locale functionality takes -# care of merging po files related to licenses into documentation po -# file so changes made to licenses translations will also be available -# to documentation manuals in different languages. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setExpansionLicenses { - - local INSTANCE=$1 - - # Define absolute path to DocBook models. - local DOCBOOK_MODELS="${TCAR_WORKDIR}/Documentation/Models/Docbook" - - # Define list of files holding licenses you want to include. Note - # even this files are not inside the documentation structure - # itself, they are connected with it. The files holding license - # information does contain id information used inside the - # documentation structure at cross references. - local LICENSES="${DOCBOOK_MODELS}/Default/Licenses/Gpl/gpl.docbook \ - ${DOCBOOK_MODELS}/Default/Licenses/Gfdl/gfdl.docbook" - - # Define top level structure in the instance. This is the tag - # defined in the second field of DOCTYPE definition. - local DOCTYPE=$(egrep '^\n" - BLOCK="${BLOCK}\n\n" - BLOCK="${BLOCK}\n`gettext "Licenses"`\n" - BLOCK="${BLOCK}\n$(cat ${LICENSES} | sed -r '/<\?xml/,/]>/d')\n" - BLOCK="${BLOCK}\n\n" - BLOCK="${BLOCK}\n\n" - - # Expand the licenses section. Remove everything in-between - # Licenses and Back matter comment. Recreate the comments to - # support further actualizations and concatenate license - # information without their document type definitions preamble. - # This is required in order to prevent validation errors and reuse - # (through locale functionality) the translation messages already - # available for these license files. Finally, close any open tag. - sed -r -i -e "//,//c$(echo ${BLOCK})" $INSTANCE - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setExpansionSystemEntities.sh b/Automation/Modules/Render/Docbook/docbook_setExpansionSystemEntities.sh deleted file mode 100755 index 090e09c..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setExpansionSystemEntities.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# docbook_setExpansionSystemEntities.sh -- This function expands system -# entities required by DocBook projects stored under -# `Documentation/Manuals' directory. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setExpansionSystemEntities { - - # Define absolute path to instance where all operations will take - # place in. - local INSTANCE=$1 - - # Define absolute path to both common and specific system - # entities. - local ENTITIES_PATHS="$(cli_getFilesList ${TCAR_WORKDIR}/Documentation/Models/Docbook/Default/Book $(dirname ${TEMPLATE}) \ - --pattern='^.*/[[:alpha:]-]+\.ent$' --maxdepth=1 --mindepth=1 --type='f')" - - # Build definition of both common and specific system entities. - local ENTITIES="$(\ - for ENTITY_PATH in $ENTITIES_PATHS;do - local ENTITY_NAME=$(basename ${ENTITY_PATH}) - echo '\n\t\n' - echo '\t%'${ENTITY_NAME}';' - done)" - - # Define both xml and docbook public definition. - local PREAMBLE="" - PREAMBLE="${PREAMBLE}\n" - - # Remove both xml and docbook preamble from instance and insert - # it again with definitions of required common and specific system - # entities. - sed -r -i "1,2c$(echo $PREAMBLE)" ${INSTANCE} - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setLastRendition.sh b/Automation/Modules/Render/Docbook/docbook_setLastRendition.sh deleted file mode 100755 index 7205cd8..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setLastRendition.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# docbook_setLastRendition.sh -- This function performs last-rendition -# actions for DocBook files. These are the actions that take -# base-rendition and post-rendition output as input to produce output -# from it. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setLastRendition { - - # Presently, there is no last-rendition action for DocBook base - # rendition but the function should exist for consistency with - # other formats. - return - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setPostRendition.sh b/Automation/Modules/Render/Docbook/docbook_setPostRendition.sh deleted file mode 100755 index 30afef9..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setPostRendition.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# docbook_setPostRendition.sh -- This function performs post-rendition -# actions for DocBook files. These are the actions that take -# base-rendition output as input to producing output from it. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setPostRendition { - - # Presently, there is no post-rendition action for DocBook base - # rendition but the function should exist for consistency with - # other formats. - return - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setStyles.sh b/Automation/Modules/Render/Docbook/docbook_setStyles.sh deleted file mode 100755 index 8700f0f..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setStyles.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# docbook_setStyles.sh -- This function prepares styles' final -# instances, used in transformations and based on XSL or DSL -# templates. There might be translation markers inside the XSL and -# DSL templates that need to be expanded before they can be used for -# transformations. This function creates temporal instances of XSL -# and DSL templates with translation markers expanded inside so as for -# transformation commands (e.g., `xmltproc' or `openjade' through -# `docbook2pdf') to use as style definition. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setStyles { - - local STYLE_TEMPLATE_FILE='' - local STYLE_TEMPLATE_FILES=$@ - local STYLE_INSTANCE_COMMON='' - local COUNT=0 - - for STYLE_TEMPLATE_FILE in $STYLE_TEMPLATE_FILES;do - - STYLE_TEMPLATE[((++${#STYLE_TEMPLATE[*]}))]="${STYLE_TEMPLATE_FILE}" - STYLE_INSTANCE[((++${#STYLE_INSTANCE[*]}))]="$(cli_getTemporalFile ${STYLE_TEMPLATE_FILE})" - - # Keep track of array's real index value. Remember, it starts - # at zero but counting starts at 1 instead. So, subtracting 1 - # from counting we have the real index value we need to work - # with the information stored in the array. - COUNT=$(( ${#STYLE_INSTANCE[*]} - 1 )) - - # Create style instance from style template. - cp ${STYLE_TEMPLATE[$COUNT]} ${STYLE_INSTANCE[$COUNT]} - - # Define both final an common style instances based on style - # templates. - if [[ $STYLE_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[$COUNT]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2pdf\.dsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-common\.xsl$' ]];then - STYLE_INSTANCE_COMMON=${STYLE_INSTANCE[${COUNT}]} - fi - - done - - # Verify style final instance. This is the file used by - # transformation command (`xsltproc' or `openjade') to produce the - # specified output. We cannot continue without it. - cli_checkFiles -e $STYLE_INSTANCE_FINAL - - # Expand common translation markers in the common style instance, - # if it exists. - if [[ -f $STYLE_INSTANCE_COMMON ]];then - cli_expandTMarkers $STYLE_INSTANCE_COMMON - fi - - # Expand specific translation markers in final style instance. - sed -r -i "s!=STYLE_XHTML_COMMON=!${STYLE_INSTANCE_COMMON}!" ${STYLE_INSTANCE_FINAL} - -} diff --git a/Automation/Modules/Render/Docbook/docbook_setTranslation.sh b/Automation/Modules/Render/Docbook/docbook_setTranslation.sh deleted file mode 100755 index 1d6bad7..0000000 --- a/Automation/Modules/Render/Docbook/docbook_setTranslation.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# -# docbook_setTranslation.sh -- This function standardizes the way -# translation files are applied to DocBook design models in order to -# produce the translated instance that is used to expand translation -# markers and produce different output formats. -# -# Assuming no translation file exists, an untranslated instance is -# taken from the design model and created (i.e., just a copy) from it. -# Using a design model instance (translated or not) is required in -# order to expand translation markers safely. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function docbook_setTranslation { - - # Print final location of translation file. - cli_printMessage "${TRANSLATION}" --as-translation-line - - # Create translation instance to combine both template translation - # and licenses translations. - local TRANSLATION_INSTANCE=${TMPDIR}/messages.po - - # Define path to DocBook locales using models as reference. - local DOCBOOK_LOCALES=$(cli_getLocalizationDir "$DOCBOOK_MODELS") - - # Define list of all locale files you want to combine. This - # include the localization files related to all different kind of - # licenses you want to use in the main documentation file and the - # localization file of the main documentation file, as well. - local DOCBOOK_PO_FILES="${TCAR_WORKDIR}/Locales/Documentation/Models/Docbook/Default/Licenses/Gfdl/${CLI_LANG_LC}/messages.po \ - ${TCAR_WORKDIR}/Locales/Documentation/Models/Docbook/Default/Licenses/Gpl/${CLI_LANG_LC}/messages.po \ - ${TRANSLATION}" - - # Be sure the files we want to combine do exist. - cli_checkFiles -e ${DOCBOOK_PO_FILES} - - # Combine license translations with template translation in order - # to reuse licenses translations in template files without - # including them in template portable objects. In the case of - # DocBook templates, translations related to licenses are required - # because license content is expanded at execution time inside the - # DocBook instance used by XSL processor during transformation. - msgcat --output=${TRANSLATION_INSTANCE} \ - --width=70 --no-location --use-first ${DOCBOOK_PO_FILES} - - # At this point the translation instance with both licenses and - # manual translations have been saved. Now it is required to - # expand entities so it could be possible to create a translated - # instance with all the content inside. - - # Print action message. - cli_printMessage "${INSTANCE}" --as-translating-line - - # Create the translated instance of design model instance with all - # entities and translation markers expanded. - xml2po -a -l ${CLI_LANG_LL} \ - -p ${TRANSLATION_INSTANCE} \ - -o ${INSTANCE}-${CLI_LANG_LL}.tmp ${INSTANCE} - - # Rename final instance so it can be treated as just instance. - mv ${INSTANCE}-${CLI_LANG_LL}.tmp ${INSTANCE} - - # Remove .xml2po.mo temporal file. - if [[ -f ${PWD}/.xml2po.mo ]];then - rm ${PWD}/.xml2po.mo - fi - - # Verify instance existence. - cli_checkFiles -e $INSTANCE - -} diff --git a/Automation/Modules/Render/Modules/Conf/Scripts/conf_setBaseRendition.sh b/Automation/Modules/Render/Modules/Conf/Scripts/conf_setBaseRendition.sh new file mode 100755 index 0000000..4962373 --- /dev/null +++ b/Automation/Modules/Render/Modules/Conf/Scripts/conf_setBaseRendition.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# +# conf_setBaseRendition.sh -- This function standardizes base actions +# related to image production through configuration files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function conf_setBaseRendition { + + local COUNTER=0 + local EXPORTID="CENTOSARTWORK" + local -a MODEL_INSTANCES + local -a IMAGE_INSTANCES + local -a IMAGE_COMMANDS + + # Define absolute path to output location. This is the location + # inside the working copy all images will be stored in. + local OUTPUT=${OUTPUT}/${FGCOLOR}/${BGCOLOR}/${HEIGHT}/${FILENAME} + + # Define which command will be used to output the template + # content. This is required because template files might be found + # as compressed files inside the repository. + local VIEWER="/bin/cat" + + while [[ $COUNTER -lt ${#MODELS[*]} ]];do + + # Verify existence and extension of design models. + cli_checkFiles ${MODELS[$COUNTER]} -f --match='\.(svgz|svg)$' + + # Define file name for design model instances. We need to use + # a random string in from of it to prevent duplication. + # Remember that different files can have the same name in + # different locations. Use the correct file information. + MODEL_INSTANCES[$COUNTER]=${TMPDIR}/${RANDOM}-$(basename ${MODELS[$COUNTER]}) + + # Define file name for image instances. We need to use a + # random string in from of it to prevent duplication. + # Remember that different files can have the same name in + # different locations. Use the correct file information. + IMAGE_INSTANCES[$COUNTER]=${TMPDIR}/${RANDOM}-$(basename ${MODELS[$COUNTER]} \ + | sed -r 's/\.(svgz|svg)$/.png/') + + # Redefine command used to read design models. + if [[ $(file -b -i ${MODELS[$COUNTER]}) =~ '^application/x-gzip$' ]];then + VIEWER="/bin/zcat" + fi + + # Create uncompressed design model instances in order to make + # color replacements without affecting original design models. + $VIEWER ${MODELS[$COUNTER]} > ${MODEL_INSTANCES[$COUNTER]} + + # Make your best to be sure the design model instance you are + # processing is a valid scalable vector graphic. + cli_checkFiles ${MODEL_INSTANCES[$COUNTER]} --mime="text/xml" + + # Make color replacements to each design model instance before + # render them using Inkscape. + if [[ ${FGCOLOR} != '000000' ]];then + sed -i -r "s/((fill|stroke):#)000000/\1${FGCOLOR}/g" ${MODEL_INSTANCES[$COUNTER]} + fi + + # Create list of Inkscape commands based for each design model + # set in the configuration file. + IMAGE_COMMANDS[${COUNTER}]="${MODEL_INSTANCES[$COUNTER]} \ + --export-id=${EXPORTID} \ + --export-png=${IMAGE_INSTANCES[$COUNTER]} \ + --export-background=$(echo ${BGCOLOR} | cut -d'-' -f1) \ + --export-background-opacity=$(echo ${BGCOLOR} | cut -d'-' -f2) \ + --export-height=${HEIGHT}" + + # Create PNG image based on design models. + inkscape ${IMAGE_COMMANDS[$COUNTER]} > /dev/null + + COUNTER=$(( $COUNTER + 1 )) + + done + + cli_printMessage "${OUTPUT}" --as-creating-line + + # Verify existence of output directory. + if [[ ! -d $(dirname ${OUTPUT}) ]];then + mkdir -p $(dirname ${OUTPUT}) + fi + + # Apply command to PNG images produced from design models to + # construct the final PNG image. + ${COMMAND} ${IMAGE_INSTANCES[*]} ${OUTPUT} + + # Remove instances to save disk space. There is no need to have + # unused files inside the temporal directory. They would be + # consuming space unnecessarily. Moreover, there is a remote + # chance of name collapsing (because the huge number of files that + # would be in place and the week random string we are putting in + # front of files) which may produce unexpected results. + rm ${IMAGE_INSTANCES[*]} ${MODEL_INSTANCES[*]} + + # Create path for different image formats creation using PNG image + # extension as reference. + local TARGET=$(echo ${OUTPUT} | sed -r "s/\.png$//") + + # Convert images from PNG to those formats specified in the + # configuration file. + for FORMAT in ${FORMATS};do + cli_printMessage "${TARGET}.${FORMAT}" --as-creating-line + convert ${OUTPUT} ${TARGET}.${FORMAT} + done + +} diff --git a/Automation/Modules/Render/Modules/Conf/conf.sh b/Automation/Modules/Render/Modules/Conf/conf.sh new file mode 100755 index 0000000..269e016 --- /dev/null +++ b/Automation/Modules/Render/Modules/Conf/conf.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# +# conf.sh -- This function standardizes the way images are produced +# from configuration files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function conf { + + # Initialize local variables. + local MODEL='' + local -a MODELS + local FORMAT='' + local HEIGHT='' + local FGCOLOR='' + local BGCOLOR='' + + # Define list with all section names. These are the final file + # names we want to produce images for. + local FILENAME='' + local FILENAMES=$(cli_getConfigSectionNames $TEMPLATE) + + for FILENAME in $FILENAMES;do + + # Retrieve models you want to produce the image from. Notice + # that relative path passed in this option must point to one + # existent file inside the working copy. + for MODEL in $(cli_getConfigValue "$TEMPLATE" "$FILENAME" "models");do + MODELS[((++${#MODELS[*]}))]=${TCAR_WORKDIR}/${MODEL} + done + + # Retrieve formats you want to produce the image for. This + # variable contains one or more image format supported by + # ImageMagick. For example, `xpm', `jpg', 'tiff', etc. + local FORMATS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "formats") + if [[ -z ${FORMATS} ]];then + FORMATS="xpm pdf jpg tif" + fi + + # Retrieve heights you want to produce the image for. This + # variable contains one or more numerical values. For example, + # `16', `24', `32', etc. + local HEIGHTS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "heights") + if [[ -z ${HEIGHTS} ]];then + HEIGHTS="16 20 22 24 32 36 38 40 48 64 72 78 96 112 124 128 148 164 196 200 512" + fi + + # Retrieve foreground colors you want to produce the image + # for. This variable contains one or more color number in + # hexadecimal format. For example, `000000', `ffffff', etc. + local FGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "fgcolors") + if [[ -z ${FGCOLORS} ]];then + FGCOLORS="000000" + fi + + # Retrieve background colors you want to produce the image + # for. This variable contains one or more color number in + # hexadecimal format with opacity information included. + # Opacity is specified between 0.0 and 1.0 where 0.0 is full + # transparency and 1.0 full opacity. For example, the + # following values are accepted: `000000-0', `ffffff-1', etc. + local BGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "bgcolors") + if [[ -z ${BGCOLORS} ]];then + BGCOLORS="000000-0" + fi + + # Retrieve command-line you want execute to produce the image. + # For example, `/usr/bin/convert +append' + local COMMAND=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "command") + if [[ -z ${COMMAND} ]];then + COMMAND=/bin/cp + fi + + for FGCOLOR in $FGCOLORS;do + + # Verify value passed as foreground color. + cli_checkFiles ${FGCOLOR} --match="^[a-fA-F0-9]{3,6}$" + + for BGCOLOR in $BGCOLORS;do + + # Verify value passed as background color. + cli_checkFiles ${BGCOLOR} --match="^[a-fA-F0-9]{6}-(0|1)$" + + for HEIGHT in $HEIGHTS;do + + # Verify value passed as height. + cli_checkFiles ${HEIGHT} --match="^[[:digit:]]+$" + + # Do base rendition actions. + conf_setBaseRendition + + done + done + done + + # Reset models list to prevent it from growing for each file + # name (configuration section) iteration and create this way + # unexpected images as final result. + unset MODELS + + done + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionText.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionText.sh new file mode 100755 index 0000000..7c4673c --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionText.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# svg_convertToText.sh -- This function takes the XHTML file produced +# by docbook_setConversionXhtml and produces one plain-text file (i.e., +# without markup inside). +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setConversionText { + + # Verify existence of HTML file. If `.xhtml' file doesn't exist + # don't create text file. The `.xhtml' file is required in order + # to create the `.txt' file. + if [[ ! -f ${FILE}.xhtml ]];then + return + fi + + local COMMAND='' + local OPTIONS='' + + # Define the command path to text-based web browser and options + # used to produce plain-text files. Most of these programs have a + # dump option that print formatted plain-text versions of given + # HTML file to stdout. + if [[ -x '/usr/bin/lynx' ]];then + COMMAND='/usr/bin/lynx' + OPTIONS='-force_html -nolist -width 70 -dump' + elif [[ -x '/usr/bin/elinks' ]];then + COMMAND='/usr/bin/elinks' + OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' + elif [[ -x '/usr/bin/w3m' ]];then + COMMAND='/usr/bin/w3m' + OPTIONS='-dump' + fi + + if [[ $COMMAND != '' ]];then + + # Print action message. + if [[ -f ${FILE}.txt ]];then + cli_printMessage "${FILE}.txt" --as-updating-line + else + cli_printMessage "${FILE}.txt" --as-creating-line + fi + + # Convert from HTML to plain-text without markup. + ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt + + else + cli_printMessage "`gettext "No way to convert from XHTML to plain-text found."`" --as-error-line + fi + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtml.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtml.sh new file mode 100755 index 0000000..1c9f0a6 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtml.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# docbook_setConversionXhtml.sh -- This function uses DocBook XML as input +# and applies XSL stylesheets to produce a big XHTML files as output. +# The procedure was taken from the documentation of +# `docbook-style-xsl-1.69.1-5.1' package, which says: ---To publish +# HTML from your XML documents, you just need an XSL engine.---. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setConversionXhtml { + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SOURCE_FILE=${1} + + # Define absolute path to xhtml target file. This is the final + # location the xhtml file produced as result of DocBook to xhtml + # transformation will be stored in. + local TARGET_FILE=${FILE}-xhtml/$(basename ${FILE}).xhtml + + # Define absolute path to xhtml target file directory. This is the + # location the xhtml target file will be sotred in. + local TARGET_FILE_DIR=$(dirname ${TARGET_FILE}) + + # Print action message. + if [[ -f ${FILE}.xhtml ]];then + cli_printMessage "${TARGET_FILE}" --as-updating-line + else + cli_printMessage "${TARGET_FILE}" --as-creating-line + fi + + # Prepare XSL final instances used in transformations. + docbook_setStyles $(cli_getFilesList \ + ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(single|common)\.xsl$') + + # Clean up output directory. This is required in order to prevent + # old files from remaining therein when they are no longer needed. + if [[ -d ${TARGET_FILE_DIR} ]];then + rm -r "${TARGET_FILE_DIR}" + fi + mkdir ${TARGET_FILE_DIR} + + # Transform DocBook XML to XHTML suppressing all stderr output. + xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null + + # Create `css' and `images' directories. In order to save disk + # space, these directories are linked (symbolically) to their + # respective locations inside the working copy. + ln -fs ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE_DIR}/Css + ln -fs ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE_DIR}/Images + + # Remove XSL instance files. + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtmlChunks.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtmlChunks.sh new file mode 100755 index 0000000..4caf61f --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXhtmlChunks.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# docbook_setConversionXhtmlChunks.sh -- This function uses DocBook XML as +# input and applies XSL stylesheets to produce a directory with many +# XHTML files as output. The procedure was taken from the +# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says: +# ---To publish HTML from your XML documents, you just need an XSLT +# engine.---. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setConversionXhtmlChunks { + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SOURCE_FILE=${1} + + # Define absolute path to XHTML target file. This is the final + # location the XHTML file produced as result of DocBook to PDF + # transformation will be stored in. + local TARGET_FILE="${FILE}-xhtml-chunks/" + + # Clean up output directory. This is required in order to prevent + # old files from remaining therein when they are no longer needed. + if [[ -d ${TARGET_FILE} ]];then + rm -r "${TARGET_FILE}" + fi + mkdir ${TARGET_FILE} + + # Print action message. + cli_printMessage "${TARGET_FILE}" --as-creating-line + + # Prepare XSL final instances used in transformations. + docbook_setStyles $(cli_getFilesList \ + ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(chunks|common)\.xsl$') + + # Transform DocBook XML to XHTML suppressing all stderr output. + xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null + + # Create `css' and `images' directories. In order to save disk + # space, these directories are linked (symbolically) to their + # respective locations inside the working copy. Be sure to remove + # previous links first to prevent a recursive creation of links. + ln -sf ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE}/Css + ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE}/Images + + # Remove XSL instance files. + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXml2Pdf.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXml2Pdf.sh new file mode 100755 index 0000000..f639e93 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setConversionXml2Pdf.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# docbook_setConversionXml2Pdf.sh -- This function transforms DocBook +# files which have set the XML DTD in them. To produce PDF from +# DocBook XML DTD, we need an XSLT engine (e.g., through `xsltproc' +# command) to produce formatting objects (FO), which then must be +# processed with an FO engine (e.g., through `pdfxmltex' command, +# which uses PassiveTex) to produce the PDF output. +# +# In this configuration and using default configuration settings, I've +# presented the following problems: +# +# 1. Something is wrong with headings. They are not expanded along the +# whole page-body. They seem to be rendered in a reduced width (1 inch +# approximately). This provokes the heading to be broken in a +# two-to-five letters column and sometimes it overlaps the sectioning +# titles (e.g., chapter, section). I tried to customize the value of +# `header.column.widths' and `page.margin.top' but it seems to be not +# there where I need to touch. +# +# 2. TOC's indentation is not rendered. Even the `toc.indent.width' +# property is set to 24 by default. +# +# 3. Inside lists, when items are more than one line, the indentation +# seems to work for the first line only. All other lines in the same +# item are not indented and begin completely unaligned. +# +# 4. Long file paths near the end of page-body aren't hyphenated. +# Even the `hyphenate' property is set to `true' by default. +# +# In this configuration and using default configuration settings, I've +# presented the following advantages: +# +# 1. It is possible to produce localized PDF outputs through +# `xml2po', the default way of producing localized content inside +# the `centos-art.sh' script. +# +# To make the whole process transparent, a temporal directory is +# created for intermediate works and final files are moved then to +# their final location. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setConversionXml2Pdf { + + # Print action message. + cli_printMessage "${FILE}.pdf" --as-creating-line + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SRC=${INSTANCE} + + # Define absolute path to PDF target file. This is the final + # location the PDF file produced as result of DocBook to PDF + # transformation will be stored in. + local DST="${FILE}.pdf" + + # Define file name of formatting object (.fo) file. This file is + # an intermediate file needed to produced the PDF. + local FO=$(echo ${INSTANCE} | sed -r 's/docbook$/fo/g') + + # Define file name of PDF file. This is the file we were looking + # for and the one moved, once produced. + local PDF=$(echo ${INSTANCE} | sed -r 's/docbook$/pdf/g') + + # Prepare XSL final instances used in transformations. + docbook_setStyles "${DOCBOOK_XSL}/docbook2fo.xsl" + + # Create link to `Images' directory. This is the directory where + # images used by documentation are stored in. Be sure to remove + # previous links first to prevent a recursive creation of links. + ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv $(dirname ${INSTANCE})/Images + + # Create formatting object suppressing output from stderr. + xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} 2> /dev/null + + # Create PDF format from formatting object. Because we are using + # relative path to access `Images', it is necessary to move the + # directory stack into the temporal directory where instance files + # are created. Otherwise, the location used to load images will + # fail. + if [[ $? -eq 0 ]];then + pushd $(dirname ${INSTANCE}) > /dev/null + xmlto -o $(dirname ${FILE}) pdf ${FO} + popd > /dev/null + else + cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line + fi + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionLicenses.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionLicenses.sh new file mode 100755 index 0000000..cb3a032 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionLicenses.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# docbook_setExpansionLicenses.sh -- This function modifies the final +# DocBook instance to add license information. We are doing this way +# because using XInclude doesn't work and we want to reuse license +# information in all documents. So, if we cannot link the files, we +# modify the final instance and append the license information to it. +# Later, to reuse translation messages, the locale functionality takes +# care of merging po files related to licenses into documentation po +# file so changes made to licenses translations will also be available +# to documentation manuals in different languages. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setExpansionLicenses { + + local INSTANCE=$1 + + # Define absolute path to DocBook models. + local DOCBOOK_MODELS="${TCAR_WORKDIR}/Documentation/Models/Docbook" + + # Define list of files holding licenses you want to include. Note + # even this files are not inside the documentation structure + # itself, they are connected with it. The files holding license + # information does contain id information used inside the + # documentation structure at cross references. + local LICENSES="${DOCBOOK_MODELS}/Default/Licenses/Gpl/gpl.docbook \ + ${DOCBOOK_MODELS}/Default/Licenses/Gfdl/gfdl.docbook" + + # Define top level structure in the instance. This is the tag + # defined in the second field of DOCTYPE definition. + local DOCTYPE=$(egrep '^\n" + BLOCK="${BLOCK}\n\n" + BLOCK="${BLOCK}\n`gettext "Licenses"`\n" + BLOCK="${BLOCK}\n$(cat ${LICENSES} | sed -r '/<\?xml/,/]>/d')\n" + BLOCK="${BLOCK}\n\n" + BLOCK="${BLOCK}\n\n" + + # Expand the licenses section. Remove everything in-between + # Licenses and Back matter comment. Recreate the comments to + # support further actualizations and concatenate license + # information without their document type definitions preamble. + # This is required in order to prevent validation errors and reuse + # (through locale functionality) the translation messages already + # available for these license files. Finally, close any open tag. + sed -r -i -e "//,//c$(echo ${BLOCK})" $INSTANCE + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionSystemEntities.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionSystemEntities.sh new file mode 100755 index 0000000..090e09c --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setExpansionSystemEntities.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# docbook_setExpansionSystemEntities.sh -- This function expands system +# entities required by DocBook projects stored under +# `Documentation/Manuals' directory. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setExpansionSystemEntities { + + # Define absolute path to instance where all operations will take + # place in. + local INSTANCE=$1 + + # Define absolute path to both common and specific system + # entities. + local ENTITIES_PATHS="$(cli_getFilesList ${TCAR_WORKDIR}/Documentation/Models/Docbook/Default/Book $(dirname ${TEMPLATE}) \ + --pattern='^.*/[[:alpha:]-]+\.ent$' --maxdepth=1 --mindepth=1 --type='f')" + + # Build definition of both common and specific system entities. + local ENTITIES="$(\ + for ENTITY_PATH in $ENTITIES_PATHS;do + local ENTITY_NAME=$(basename ${ENTITY_PATH}) + echo '\n\t\n' + echo '\t%'${ENTITY_NAME}';' + done)" + + # Define both xml and docbook public definition. + local PREAMBLE="" + PREAMBLE="${PREAMBLE}\n" + + # Remove both xml and docbook preamble from instance and insert + # it again with definitions of required common and specific system + # entities. + sed -r -i "1,2c$(echo $PREAMBLE)" ${INSTANCE} + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setLastRendition.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setLastRendition.sh new file mode 100755 index 0000000..7205cd8 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setLastRendition.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# docbook_setLastRendition.sh -- This function performs last-rendition +# actions for DocBook files. These are the actions that take +# base-rendition and post-rendition output as input to produce output +# from it. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setLastRendition { + + # Presently, there is no last-rendition action for DocBook base + # rendition but the function should exist for consistency with + # other formats. + return + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setPostRendition.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setPostRendition.sh new file mode 100755 index 0000000..30afef9 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setPostRendition.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# docbook_setPostRendition.sh -- This function performs post-rendition +# actions for DocBook files. These are the actions that take +# base-rendition output as input to producing output from it. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setPostRendition { + + # Presently, there is no post-rendition action for DocBook base + # rendition but the function should exist for consistency with + # other formats. + return + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setStyles.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setStyles.sh new file mode 100755 index 0000000..8700f0f --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setStyles.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# docbook_setStyles.sh -- This function prepares styles' final +# instances, used in transformations and based on XSL or DSL +# templates. There might be translation markers inside the XSL and +# DSL templates that need to be expanded before they can be used for +# transformations. This function creates temporal instances of XSL +# and DSL templates with translation markers expanded inside so as for +# transformation commands (e.g., `xmltproc' or `openjade' through +# `docbook2pdf') to use as style definition. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setStyles { + + local STYLE_TEMPLATE_FILE='' + local STYLE_TEMPLATE_FILES=$@ + local STYLE_INSTANCE_COMMON='' + local COUNT=0 + + for STYLE_TEMPLATE_FILE in $STYLE_TEMPLATE_FILES;do + + STYLE_TEMPLATE[((++${#STYLE_TEMPLATE[*]}))]="${STYLE_TEMPLATE_FILE}" + STYLE_INSTANCE[((++${#STYLE_INSTANCE[*]}))]="$(cli_getTemporalFile ${STYLE_TEMPLATE_FILE})" + + # Keep track of array's real index value. Remember, it starts + # at zero but counting starts at 1 instead. So, subtracting 1 + # from counting we have the real index value we need to work + # with the information stored in the array. + COUNT=$(( ${#STYLE_INSTANCE[*]} - 1 )) + + # Create style instance from style template. + cp ${STYLE_TEMPLATE[$COUNT]} ${STYLE_INSTANCE[$COUNT]} + + # Define both final an common style instances based on style + # templates. + if [[ $STYLE_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[$COUNT]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2pdf\.dsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-common\.xsl$' ]];then + STYLE_INSTANCE_COMMON=${STYLE_INSTANCE[${COUNT}]} + fi + + done + + # Verify style final instance. This is the file used by + # transformation command (`xsltproc' or `openjade') to produce the + # specified output. We cannot continue without it. + cli_checkFiles -e $STYLE_INSTANCE_FINAL + + # Expand common translation markers in the common style instance, + # if it exists. + if [[ -f $STYLE_INSTANCE_COMMON ]];then + cli_expandTMarkers $STYLE_INSTANCE_COMMON + fi + + # Expand specific translation markers in final style instance. + sed -r -i "s!=STYLE_XHTML_COMMON=!${STYLE_INSTANCE_COMMON}!" ${STYLE_INSTANCE_FINAL} + +} diff --git a/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setTranslation.sh b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setTranslation.sh new file mode 100755 index 0000000..1d6bad7 --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/Scripts/docbook_setTranslation.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# docbook_setTranslation.sh -- This function standardizes the way +# translation files are applied to DocBook design models in order to +# produce the translated instance that is used to expand translation +# markers and produce different output formats. +# +# Assuming no translation file exists, an untranslated instance is +# taken from the design model and created (i.e., just a copy) from it. +# Using a design model instance (translated or not) is required in +# order to expand translation markers safely. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook_setTranslation { + + # Print final location of translation file. + cli_printMessage "${TRANSLATION}" --as-translation-line + + # Create translation instance to combine both template translation + # and licenses translations. + local TRANSLATION_INSTANCE=${TMPDIR}/messages.po + + # Define path to DocBook locales using models as reference. + local DOCBOOK_LOCALES=$(cli_getLocalizationDir "$DOCBOOK_MODELS") + + # Define list of all locale files you want to combine. This + # include the localization files related to all different kind of + # licenses you want to use in the main documentation file and the + # localization file of the main documentation file, as well. + local DOCBOOK_PO_FILES="${TCAR_WORKDIR}/Locales/Documentation/Models/Docbook/Default/Licenses/Gfdl/${CLI_LANG_LC}/messages.po \ + ${TCAR_WORKDIR}/Locales/Documentation/Models/Docbook/Default/Licenses/Gpl/${CLI_LANG_LC}/messages.po \ + ${TRANSLATION}" + + # Be sure the files we want to combine do exist. + cli_checkFiles -e ${DOCBOOK_PO_FILES} + + # Combine license translations with template translation in order + # to reuse licenses translations in template files without + # including them in template portable objects. In the case of + # DocBook templates, translations related to licenses are required + # because license content is expanded at execution time inside the + # DocBook instance used by XSL processor during transformation. + msgcat --output=${TRANSLATION_INSTANCE} \ + --width=70 --no-location --use-first ${DOCBOOK_PO_FILES} + + # At this point the translation instance with both licenses and + # manual translations have been saved. Now it is required to + # expand entities so it could be possible to create a translated + # instance with all the content inside. + + # Print action message. + cli_printMessage "${INSTANCE}" --as-translating-line + + # Create the translated instance of design model instance with all + # entities and translation markers expanded. + xml2po -a -l ${CLI_LANG_LL} \ + -p ${TRANSLATION_INSTANCE} \ + -o ${INSTANCE}-${CLI_LANG_LL}.tmp ${INSTANCE} + + # Rename final instance so it can be treated as just instance. + mv ${INSTANCE}-${CLI_LANG_LL}.tmp ${INSTANCE} + + # Remove .xml2po.mo temporal file. + if [[ -f ${PWD}/.xml2po.mo ]];then + rm ${PWD}/.xml2po.mo + fi + + # Verify instance existence. + cli_checkFiles -e $INSTANCE + +} diff --git a/Automation/Modules/Render/Modules/Docbook/docbook.sh b/Automation/Modules/Render/Modules/Docbook/docbook.sh new file mode 100755 index 0000000..0cb4d7f --- /dev/null +++ b/Automation/Modules/Render/Modules/Docbook/docbook.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +# docbook.sh -- This function performs base-rendition actions for +# DocBook files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function docbook { + + # Define absolute path to XSL files used for transforming DocBook + # into other formats. + local DOCBOOK_XSL="${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Xsl" + + # Define absolute path to DocBook models. This path must take + # until the directory which holds the main documentation docbook + # file. + local DOCBOOK_MODELS="$(dirname ${TEMPLATE})" + + # Verify absolute path to DocBook models. + cli_checkFiles ${DOCBOOK_MODELS} -d + + # Create the non-translated instance of design model. + cp ${TEMPLATE} ${INSTANCE} + + # Expand common contents inside instance. + docbook_setExpansionLicenses ${INSTANCE} + + # When translated instances are rendered, system entities (e.g., + # `%entity-name;') don't appear in the translated instance (it + # seems that xml2po removes them) and this provokes DocBook + # validation to fail. So in order to pass the validation + # successfully and automate the whole creation of system entities, + # don't let this duty ion users'. Instead, make centos-art.sh + # script responsible of it. + docbook_setExpansionSystemEntities ${INSTANCE} + + # Print validating action. + cli_printMessage "${INSTANCE}" --as-validating-line + + # Validate translated instance before processing it. This step is + # very important in order to detect document's malformations and + # warn you about it, so you can correct them. It is also necessary + # to save them in a new file in order to make translation markers + # expansion possible before transforming the DocBook instance into + # other formats. + xmllint --valid --noent ${INSTANCE} > ${INSTANCE}.tmp + if [[ $? -ne 0 ]];then + cli_printMessage "`gettext "Validation failed."`" --as-error-line + fi + + # Update instance to add translation markers expansion. + mv ${INSTANCE}.tmp ${INSTANCE} + + # Expand translation markers on the temporal instance with + # entities already expanded. + cli_expandTMarkers ${INSTANCE} + + # Verify translation file existence apply translation to docbook + # design model instance in order to produce the translated design + # model instance. + if [[ -f ${TRANSLATION} ]];then + docbook_setTranslation ${INSTANCE} + fi + + # Convert DocBook source files to other formats. + docbook_setConversionXhtmlChunks ${INSTANCE} + docbook_setConversionXhtml ${INSTANCE} + docbook_setConversionText + + # NOTE: The current transformation from DocBook to PDF fails when + # we started to use DocBook tags inside DocBook files. + # Probably we need to test what happen when a newer release of XSL + # is used. Thus, comment production of PDF files until it can be + # produced correctly. + #docbook_setConversionXml2Pdf + + # NOTE: From version 5.0 on, DocBook specification is no longer a + # SGML specification but an XML specification only. Thus, + # transformations related to DocBook SGML specification won't be + # supported in `centos-art.sh' script. + + # Perform format post-rendition. + docbook_setPostRendition + + # Perform format last-rendition. + docbook_setLastRendition + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorAmount.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorAmount.sh new file mode 100755 index 0000000..8d25900 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorAmount.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# svg_checkColorAmount.sh -- This function verifies whether the list +# of colors provided in the first argument matches the amount of +# colors specified by the second argument. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_checkColorAmount { + + # Define list of colors. + local COLORS=$1 + + # Define the amount of colors the list provided must have, in + # order to be considered as valid. + local NUMBER=$2 + + # Verify amount of colors provided in the list. + if [[ $(echo "$COLORS" | wc -l) -ne $NUMBER ]];then + cli_printMessage "`gettext "The palette does not have the correct number of colors."`" --as-error-line + fi + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorFormats.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorFormats.sh new file mode 100755 index 0000000..19ddd9d --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkColorFormats.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# svg_checkColorFormats.sh -- This function verifies formats of colors +# (i.e., the way color information is specified). +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_checkColorFormats { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='format:' + + # Initialize pattern used for color sanitation. + local PATTERN='^#[0-9a-f]{6}$' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local ARGUMENTS='' + + # Prepare ARGUMENTS variable for getopt. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS using getopt(1) command parser. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + --format ) + + case "$2" in + + rrggbb|*) + PATTERN='^#[0-9a-f]{6}$' + ;; + + esac + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Define the location we want to apply verifications to. + local COLOR='' + local COLORS="$@" + + # Loop through colors and perform format verification as specified + # by pattern. + for COLOR in $COLORS;do + + if [[ ! $COLOR =~ $PATTERN ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$COLOR\\\" string is not a valid color code."`" --as-error-line + fi + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelAbsref.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelAbsref.sh new file mode 100755 index 0000000..4775e26 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelAbsref.sh @@ -0,0 +1,141 @@ +#!/bin/bash +# +# svg_checkModelAbsref.sh -- This function retrives absolute files and +# checks their existence. In order for design templates to point +# different artistic motifs, design templates make use of external +# files which point to specific artistic motif background images. If +# such external files don't exist, try to create the background image +# required by cropping a higher background image (e.g., +# 2048x1536-final.png). If this isn't possible neither, then create +# the background image using a plain color and crop from it then. We +# can't go on without the required background information. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_checkModelAbsref { + + local FILE='' + local BG_DST_FILES='' + local BG_DST_FILE='' + local BG_DST_FILE_WIDTH='' + local BG_DST_FILE_HEIGHT='' + local BG_SRC_FILE='' + local BG_SRC_FILE_COLOR='' + local BG_SRC_FILE_WIDTH='' + local BG_SRC_FILE_HEIGHT='' + + # Define absolute path to the translated instance of design model. + FILE="$1" + + # Verify existence of file we need to retrive absolute paths from. + cli_checkFiles -e "$FILE" + + # Retrive absolute paths from file. + BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ + | sed -r "s,.+=\"(${HOME}.+\.png)\".*,\1," | sort | uniq) + + # Verify absolute paths retrived from file. + for BG_DST_FILE in $BG_DST_FILES;do + + # Print action message. + cli_printMessage "$BG_DST_FILE" --as-checking-line + + # Verify parent directory of absolute files retrived from + # file. This is required to prevent the construction of paths + # to locations that don't exist. For example, when including + # background images in SVG files, it is possible that the path + # information inside SVG files get outdated temporarly. If in + # that exact moment, you try to render the SVG file it won't + # be possible to create the image used for cropping because + # the path build from the location inside SVG file doesn't + # exist. In this case, centos-art.sh script will end up with + # `file ... doesn't exist' errors. + cli_checkFiles -d "$(dirname ${BG_DST_FILE})" + + if [[ ! -a $BG_DST_FILE ]];then + + # Define the source background file, the image file will + # crop when no specific background informatio be available + # for using. Generally, this is the most reusable + # background file inside the artistic motifs (e.g,. the + # `2048x1536-final.png' file). We can use this image file + # to create almost all artworks inside The CentOS + # Distribution visual manifestation when + # resolution-specific backgrounds don't exist. + BG_SRC_FILE=$(echo $BG_DST_FILE \ + | sed -r "s!(.+)/[[:digit:]]+x[[:digit:]]+(-final\.png)!\1/2048x1536\2!") + + # Verify existence of source background file. If the file + # doesn't exist create it using The CentOS Project default + # background color information, as specified in its + # corporate identity manual. + if [[ ! -f $BG_SRC_FILE ]];then + + # Define plain color that will be used as background. + BG_SRC_FILE_COLOR=$(svg_getColors) + + # Verify format of color value. + svg_checkColorFormats $BG_SRC_FILE_COLOR --format='rrggbb' + + # Define width for the source background file the + # required background information is cropped from. + BG_SRC_FILE_WIDTH=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define height for the source background file the + # required background information is cropped from. + BG_SRC_FILE_HEIGHT=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Print action message. + cli_printMessage "${BG_SRC_FILE} ($BG_SRC_FILE_COLOR)" --as-creating-line + + # Create the source background file. + ppmmake -quiet ${BG_SRC_FILE_COLOR} \ + ${BG_SRC_FILE_WIDTH} ${BG_SRC_FILE_HEIGHT} \ + | pnmtopng > ${BG_SRC_FILE} + + fi + + # Print action message. + cli_printMessage "$BG_SRC_FILE" --as-cropping-line + + # Define the width of the required background information. + BG_DST_FILE_WIDTH=$(echo $BG_DST_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define the height of the required background information. + BG_DST_FILE_HEIGHT=$(echo $BG_DST_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Create required backgrounnd information. + convert -quiet \ + -crop ${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT}+0+0 \ + ${BG_SRC_FILE} ${BG_DST_FILE} + + # Verify required background information. + cli_checkFiles -e $BG_DST_FILE + + fi + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelExportId.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelExportId.sh new file mode 100755 index 0000000..2944195 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_checkModelExportId.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# svg_checkModelExportId.sh -- This function standardizes the export +# id used inside svg files and the way of verify them. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_checkModelExportId { + + local INSTANCE="$1" + local EXPORTID="$2" + + # Verify instance. + cli_checkFiles -e $INSTANCE + + # Verify export id. + if [[ $EXPORTID == '' ]];then + cli_printMessage "`gettext "The export id value cannot be empty."`" --as-error-line + fi + + # Check export id inside design templates. + grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null + if [[ $? -gt 0 ]];then + cli_printMessage "`eval_gettext "There is not export id (\\\$EXPORTID) inside \\\"\\\$TEMPLATE\\\"."`" --as-error-line + fi + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToHex.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToHex.sh new file mode 100755 index 0000000..51efe26 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToHex.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# svg_convertGplToHex.sh -- This function takes one palette produced +# by Gimp (e.g., syslinux.gpl) as input and outputs the list of +# hexadecimal colors and their respective index position the +# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all +# values in the same line]). +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertGplToHex { + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to HEX palette. This is the palette used to stored + # the color information the `ppmtolss16' program needs. + local PALETTE_HEX="$2" + + # Define the number of colors this function should return. + local NUMBER="$3" + + # Define list of colors from GPL palette. + local COLORS=$(svg_getColors $PALETTE_GPL --head=$NUMBER --tail=$NUMBER) + + # Verify number of colors returned in the list. They must match + # exactly the amount specified, no more no less. Sometimes, the + # list of colors may have less colors than it should have, so we + # need to prevent such palettes from being used. + svg_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + svg_checkColorFormats "$COLORS" --format='rrggbb' + + # Create list of colors to be processed by `pnmtolss16'. + echo "$COLORS" | nl | gawk '{ printf "%s=%d ", $2, $1 - 1 }' \ + > $PALETTE_HEX + + # Verify HEX palette existence. + cli_checkFiles -e $PALETTE_HEX + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToPpm.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToPpm.sh new file mode 100755 index 0000000..559127b --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertGplToPpm.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# svg_convertGplToPpm.sh -- This function takes one palette produced +# by Gimp (e.g., syslinux.gpl) as input and outputs one PPM file based +# on it (e.g., syslinux.ppm). +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertGplToPpm { + + local -a FILES + local COUNT=0 + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to PPM palette. This is the .ppm file we'll save + # color information to. + local PALETTE_PPM="$2" + + # Define the number of colors this function should return. + local NUMBER="$3" + + # Define list of colors from GPL palette. + local COLOR='' + local COLORS=$(svg_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') + + # Verify amount of colors in the list of colors. + svg_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + svg_checkColorFormats $COLORS --format='rrggbb' + + # Create temporal images (of 1x1 pixel each) to store each color + # retrived from Gimp's palette. + for COLOR in $COLORS;do + FILES[$COUNT]=$(cli_getTemporalFile ${COUNT}.ppm) + ppmmake $COLOR 1 1 > ${FILES[$COUNT]} + COUNT=$(($COUNT + 1)) + done + + # Concatenate each temporal image from left to right to create the + # PPM file. + pnmcat -lr ${FILES[*]} > $PALETTE_PPM + + # Remove temporal images used to build the PPM palette file. + rm ${FILES[*]} + + # Verify PPM palette existence. + cli_checkFiles -e "$PALETTE_PPM" + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngTo.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngTo.sh new file mode 100755 index 0000000..9fad7ba --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngTo.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# svg_convertPngTo.sh -- This function provides post-rendition actions +# to use the `convert' command of ImageMagick tool set. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngTo { + + # Initialize image formats. + local FORMAT='' + local FORMATS=$(render_getConfigOption "$ACTION" '2') + + # Convert from PNG to specified formats. + for FORMAT in $FORMATS;do + cli_printMessage "${FILE}.${FORMAT}" --as-savedas-line + convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToBranded.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToBranded.sh new file mode 100755 index 0000000..8ffba47 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToBranded.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# +# svg_convertPngToBranded.sh -- This function standardizes image +# branding. Once the base PNG image is rendered and the +# `--with-brands' option is provided, this function composites a new +# branded image using the preferences set in the related +# `branding.conf' file. The `branding.conf' file must be stored +# inside the related design model component used as reference to +# produce the base PNG image. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToBranded { + + # Verify whether the option `--with-brands' was provided or not to + # `centos-art.sh' script command-line. + if [[ $FLAG_WITH_BRANDS == 'false' ]];then + return + fi + + local BRANDING_CONF_FILE='' + local BRANDING_CONF_SECTION='' + local BRANDING_CONF_VALUES='' + local BRANDING_CONF_VALUE='' + local BRANDFILE='' + local POSITION='' + local POSITIONS='' + + # Define absolute path to branding configuration file. + BRANDING_CONF_FILE="$(dirname ${TEMPLATE})/branding.conf" + + # Verify absolute path to branding configuration file. This is + # required in order to avoid trying to render branded content + # which doesn't have an associated `branding.conf' file. If there + # is no associated `branding.conf' file don't stop the script + # execution. Instead, continue with the next action in the list. + # This is required in order to perform massive rendition inside + # structures like themes where components might or might not have + # `branding.conf' files associated. For example, the `Concept' + # component doesn't have branding information associated but most + # elements inside `Distro' component do. + if [[ ! -f "$BRANDING_CONF_FILE" ]];then + continue + fi + + # Define regular expression matching the variable name (i.e., the + # left column), inside the configuration line, you want to match + # on. + BRANDING_CONF_VARNAME=$(basename ${TEMPLATE}) + + # Define list of configuration lines related to current design + # model. This are the lines that tell us how and where to apply + # branding information on base PNG image. Be sure that only + # configuration lines from supported section names (e.g., + # `symbol', `type', `logo') be read, no need to waste resources + # with others. + BRANDING_CONF_VALUES=$(\ + for BRANDING_CONF_SECTION in $(echo "types symbols logos");do + cli_getConfigValue "${BRANDING_CONF_FILE}" "${BRANDING_CONF_SECTION}" "${BRANDING_CONF_VARNAME}" + done) + + for BRANDING_CONF_VALUE in $BRANDING_CONF_VALUES;do + + # Define absolute path to image file used as brand. This is + # the image put over the PNG image produced as result of + # design models base rendition. + BRANDFILE=${TCAR_WORKDIR}/Identity/Images/Brands/$(echo $BRANDING_CONF_VALUE \ + | gawk 'BEGIN{ FS=":" } { print $1 }' ) + + # Verify absolute path to image file used as brand. Assuming + # no brand image file is found, continue with the next + # configuration line. + if [[ ! -f $BRANDFILE ]];then + continue + fi + + # Define list of positions using the format of ImageMagick + # `-geometry' option argument. + POSITIONS=$(echo "$BRANDING_CONF_VALUE" | cut -d: -f2- | tr ':' ' ') + + # Loop through list of brand image positions and use the + # composite command from ImageMagick, to overlap the unbranded + # image just rendered with the branded version of itself. + for POSITION in $POSITIONS;do + composite -geometry ${POSITION} ${BRANDFILE} ${FILE}.png ${FILE}.png + done + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToDm.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToDm.sh new file mode 100755 index 0000000..4ba8b10 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToDm.sh @@ -0,0 +1,183 @@ +#!/bin/bash +# +# svg_convertPngToDm.sh -- This function standardize production of +# display managers (e.g., Gdm and Kdm). This function copies all files +# needed into a temporal directory, realize expansion of translation +# markers and packs all the files into a tar.gz package that is used +# for installation. This function must be used as last-rendition +# action for Gdm and Kdm directory specific base-rendition actions. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToDm { + + # Print separator line. + cli_printMessage '-' --as-separator-line + + # Initialize source and destination local variables. + local SRC='' + local DST='' + + # Initialize display manager type. + local DM=$(render_getConfigOption "${ACTION}" '2') + + # Initialize screen resolutions used by display manager theme. + # These are the different screen resolutions a display manager + # theme is built for. The amount of screen resolution a display + # manager theme can be built for is limited to the amount of + # background files provided by the artistic motif used to build + # the display manager theme. + local RESOLUTION='' + local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') + + # Verify screen resolutions. We cannot produce display manager + # theme if no screen resolution has been specified. + if [[ "$RESOLUTIONS" == '' ]];then + cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line + fi + + # Initialize theme information we are going to build the display + # manager theme for. + local THEME=$(cli_getPathComponent $ACTIONVAL --motif) + local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name) + + # Initialize temporal directory where we collect all files needed + # in order to create the tar.gz file. This intermediate step is + # also needed in order to expand translation markers from XML and + # Desktop definitions. + local TMPDIR=$(cli_getTemporalFile 'dm') + + # Initialize source location for brands. This is the place where + # brand information, needed to build the display manager theme, is + # retrieved from. + local BRAND_BASEDIR=${TCAR_WORKDIR}/Identity/Images/Brands + + # Initialize source location for artistic motif's backgrounds. + # This is the place where background information needed to ubild + # the display manager theme is retrieved from. + local BGS=${TCAR_WORKDIR}/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png + + # Initialize file variables. File variables are used build and + # process the file relation between source and target locations. + local FILE='' + local FILES='' + + # Define major release from template. + local MAJOR_RELEASE=$(cli_getPathComponent "$TEMPLATE" "--release-major") + + # Define file relation between source and target locations, based + # on whether we are producing GDM or KDM. Use the colon character + # (`:') as separator; on the left side we put the file's source + # location and in the right side the file's target location. + # Presently, both GDM and KDM are very similar on files with the + # exception that GDM does use icons near actions buttons (e.g., + # shutdown, reboot, session, language) and KDM doesn't. + case ${DM} in + + Gdm ) + FILES="\ + ${BRAND_BASEDIR}/Symbols/48/${TCAR_BRAND}.png:${TCAR_BRAND}-symbol.png + ${OUTPUT}/screenshot.png:screenshot.png + $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml + $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop + $(dirname $TEMPLATE)/icon-language.png:icon-language.png + $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png + $(dirname $TEMPLATE)/icon-session.png:icon-session.png + $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png + " + ;; + + Kdm ) + FILES="\ + ${BRAND_BASEDIR}/Symbols/48/${TCAR_BRAND}.png:${TCAR_BRAND}-symbol.png + ${OUTPUT}/screenshot.png:screenshot.png + $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml + $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop + " + ;; + + * ) + cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line + ;; + esac + + for FILE in $FILES;do + + # Define source location. + SRC=$(echo $FILE | cut -d: -f1) + + # Define target location. + DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2) + + # Verify source files. + cli_checkFiles -e $SRC + + # Verify parent directory for target file. + if [[ ! -d $(dirname $DST) ]];then + mkdir -p $(dirname $DST) + fi + + # Copy files from source to target location. + cp ${SRC} ${DST} + + # Expand translation markers. + if [[ ${DST} =~ "\.(xml|desktop)$" ]];then + cli_expandTMarkers "${DST}" + fi + + done + + # Move into temporal directory. + pushd $TMPDIR > /dev/null + + for RESOLUTION in $RESOLUTIONS;do + + # Verify background information. If it doesn't exist go on + # with the next one in the list. + if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then + continue + fi + + # Print action message. + if [[ -f ${RESOLUTION}.tar.gz ]];then + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line + else + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line + fi + + # Copy background information. + cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png + + # Create tar.gz file. + tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME} + + # Move from temporal directory to its final location. + mv ${RESOLUTION}.tar.gz ${OUTPUT} + + done + + # Return to where we were initially. + popd > /dev/null + + # Remove temporal directory. + rm -r ${TMPDIR} + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToGrub.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToGrub.sh new file mode 100755 index 0000000..00da4d6 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToGrub.sh @@ -0,0 +1,148 @@ +#!/bin/bash +# +# svg_convertPngToGrub.sh -- This function provides post-rendition +# action used to produce GRUB images. +# +# Initially, the color information is defined with GIMP (The GNU Image +# Manipulation Program) as a `.gpl' palette of color. This palette of +# colors contains 14 colors only and is saved in a file named +# `grub.gpl. The `grub.gpl' file is used to build the `grub.ppm' file +# which provide the color information needed to reduce the full color +# PNG image, produced as result of SVG base-rendition, to the amount +# of colors specified (i.e., 14 colors). Later, with the 14 color PNG +# image already created, the `grub.ppm' file is used to build the +# `splash.xpm.gz' file. +# +# In order for this function to work, the `grub.gpl' file should have +# a format similar to the following: +# +# GIMP Palette +# Name: CentOS-TreeFlower-4-Syslinux +# Columns: 14 +# # +# 32 76 141 204c8d +# 36 82 146 245292 +# 52 93 152 345d98 +# 72 108 162 486ca2 +# 102 131 176 6683b0 +# 126 153 190 7e99be +# 146 170 200 92aac8 +# 161 182 209 a1b6d1 +# 182 199 219 b6c7db +# 202 214 228 cad6e4 +# 221 230 238 dde6ee +# 235 241 245 ebf1f5 +# 246 251 254 f6fbfe +# 254 255 252 fefffc +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToGrub { + + # Define number of colors the images will be produced on. + local COLORS='14' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options used already in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo -n $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line + fi + done + + # Define file name prefix. + local PREFIX="-${COLORS}c" + + # Redefine file name prefix using options as reference. This is + # useful to differenciate final files produced using + # Floyd-Steinberg dithering and files which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define logs' file. Log files are stored in the same place of + # images and are used to store output information produced by + # programs when the image files are built up. + local LOGS=${FILE}${PREFIX}.log + + # Define absolute path to GPL palette. This palettes should have + # 14 colors only. For more information on this see the GRUB's + # documentation. + local PALETTE_GPL=${MOTIF_DIR}/Palettes/grub.gpl + + # Verify GPL palette existence. If it doesn't exist copy the one + # provided by the design model through subversion (to keep track + # of the change) and expand translation markers in the copied + # instance. + if [[ ! -f $PALETTE_GPL ]];then + cli_runFnEnvironment vcs --copy ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} + cli_expandTMarkers ${PALETTE_GPL} + fi + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" --as-savedas-line + pngtopnm -verbose \ + < ${FILE}.png 2>${LOGS} > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" --as-palette-line + + # Create PPM palette using GPL palette. + svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.ppm + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + + # Create the 14 colors xpm.gz file. + cli_printMessage "${FILE}${PREFIX}.xpm.gz" --as-savedas-line + ppmtoxpm \ + < ${FILE}${PREFIX}.ppm 2>>${LOGS} > ${FILE}.xpm \ + && gzip --force ${FILE}.xpm \ + && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToIcons.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToIcons.sh new file mode 100755 index 0000000..1c4a1af --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToIcons.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# svg_convertPngToIcons.sh -- This function provides post-rendition +# actions to produce icon images in different sizes and formats from +# the same SVG design model. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToIcons { + + # Define height dimensions you want to produce brands for. + local SIZE="" + local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" + + # Define image formats you want to produce brands for. + local FORMAT="" + local FORMATS="" + + for SIZE in ${SIZES};do + + # Redefine absolute path to file location where size-specific + # images will be stored in. + local FINALFILE=$(dirname $FILE)/${SIZE}/$(basename $FILE) + + # Prepare directory where size-specific images will be stored + # in. If it doesn't exist create it. + if [[ ! -d $(dirname $FINALFILE) ]];then + mkdir -p $(dirname $FINALFILE) + fi + + # Print action message. + cli_printMessage "${FINALFILE}.png" --as-creating-line + + # Create size-specific PNG image ommiting all output. + inkscape $INSTANCE --export-id=$EXPORTID \ + --export-png=${FINALFILE}.png --export-height=${SIZE} \ + &> /dev/null + + #for FORMAT in ${FORMATS};do + # + # # Print action message. + # cli_printMessage "${FINALFILE}.${FORMAT}" --as-creating-line + # + # # Convert size-specific PNG image into different formats. + # convert ${FINALFILE}.png ${FINALFILE}.${FORMAT} + # + #done + + # Create copy of size-specific image in 2 colors. + #cli_printMessage "${FINALFILE}.xbm" --as-creating-line + #convert -colorspace gray -colors 2 ${FINALFILE}.png ${FINALFILE}.xbm + + # Create copy of size-specific image with emboss effect. + #cli_printMessage "${FINALFILE}-emboss.png" --as-creating-line + #convert -emboss 1 ${FINALFILE}.png ${FINALFILE}-emboss.png + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToKsplash.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToKsplash.sh new file mode 100755 index 0000000..091245d --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToKsplash.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# svg_convertPngToKsplash.sh -- This function collects KDE splash +# (KSplash) required files and creates a tar.gz package that groups +# them all together. Use this function as last-rendition action for +# KSplash base-rendition action. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToKsplash { + + local -a SRC + local -a DST + local FONT='' + local COUNT=0 + + # Define font used to print bottom splash message. + FONT=$(svg_getTTFont "DejaVuLGCSans-Bold") + + # Check existence of font file. + cli_checkFiles -e "$FONT" + + # Define absolute source location of files. + SRC[0]="${OUTPUT}/splash_top.png" + SRC[1]="${OUTPUT}/splash_active_bar.png" + SRC[2]="${OUTPUT}/splash_inactive_bar.png" + SRC[3]="${OUTPUT}/splash_bottom.png" + SRC[4]="$(dirname $TEMPLATE)/Theme.rc" + + # Check absolute source location of files. + cli_checkFiles -e "${SRC[@]}" + + # Define relative target location of files. + DST[0]="${OUTPUT}/splash_top.png" + DST[1]="${OUTPUT}/splash_active_bar.png" + DST[2]="${OUTPUT}/splash_inactive_bar.png" + DST[3]="${OUTPUT}/splash_bottom.png" + DST[4]="${OUTPUT}/Theme.rc" + + # Print action message. + cli_printMessage "${OUTPUT}/Preview.png" --as-creating-line + + # Create `Preview.png' image. + convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png + + # Add bottom text to Preview.png image. The text position was set + # inside an image of 400x300 pixels. If you change the final + # preview image dimension, you probably need to change the text + # position too. + mogrify -draw 'text 6,295 "KDE is up and running."' \ + -fill \#ffffff \ + -font $FONT \ + ${OUTPUT}/Preview.png + + # Copy `Theme.rc' file. + cp ${SRC[4]} ${DST[4]} + + # Apply common translation markers to Theme.rc file. + cli_expandTMarkers "${DST[4]}" + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToSyslinux.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToSyslinux.sh new file mode 100755 index 0000000..d04b0a0 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToSyslinux.sh @@ -0,0 +1,189 @@ +#!/bin/bash +# +# svg_convertPngToSyslinux.sh -- This function provides post-rendition +# action used to produce LSS16 images, the images used by isolinux. +# +# Initially, the color information is defined with GIMP (The GNU Image +# Manipulation Program) as a `.gpl' palette of color. This palette of +# colors contains 16 colors only and is saved in a file named +# `syslinux.gpl. The `syslinux.gpl' file is used to build two other +# files: the `syslinux.ppm' file and the `syslinux.hex' file. The +# `syslinux.ppm' provides the color information needed to reduce the +# full color PNG image, produced as result of SVG base-rendition, to +# the amount of colors specified (i.e., 16 colors). Later, with the 16 +# color PNG image already created, the `syslinux.hex' file is used to +# build the LSS16 image. +# +# In order to produce images in LSS16 format correctly, it is required +# that both the `syslinux.ppm' and `syslinux.hex' files do contain the +# same color information. This is, both `syslinux.ppm' and +# `syslinux.hex' must represent the same color values and in the same +# color index. +# +# In order for this function to work, the `syslinux.gpl' file should +# have a format similar to the following: +# +# GIMP Palette +# Name: CentOS-TreeFlower-4-Syslinux +# Columns: 16 +# # +# 32 76 141 204c8d +# 37 82 146 255292 +# 52 94 153 345e99 +# 73 110 162 496ea2 +# 91 124 172 5b7cac +# 108 136 180 6c88b4 +# 120 146 186 7892ba +# 131 158 193 839ec1 +# 255 255 255 ffffff +# 146 170 200 92aac8 +# 162 182 209 a2b6d1 +# 183 199 219 b7c7db +# 204 216 230 ccd8e6 +# 221 229 238 dde5ee +# 235 241 245 ebf1f5 +# 246 251 254 f6fbfe +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToSyslinux { + + # Define number of colors the images will be produced on. + local COLORS='16' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options already used in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line + fi + done + + # Define default file name prefix for 16 colors images. + local PREFIX="-${COLORS}c" + + # Re-define 16 colors images default file name prefix using + # options as reference. This is useful to differenciate final + # files produced using Floyd-Steinberg dithering and final files + # which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define logs' file. Log files are stored in the same place of + # images and are used to store output information produced by + # programs when the image files are built up. + local LOGS=${FILE}${PREFIX}.log + + # Define absolute path to GPL palette. The GPL palette defines the + # color information used to build syslinux images. This palette + # should be set to 16 colors and, as specified in isolinux + # documentation, the background color should be indexed on + # position 0 and the forground in position 7 (see + # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more + # information.) + local PALETTE_GPL=${MOTIF_DIR}/Palettes/syslinux.gpl + + # Verify GPL palette existence. If it doesn't exist copy the one + # provided by the design model through subversion (to keep track + # of the change) and expand translation markers in the copied + # instance. + if [[ ! -f $PALETTE_GPL ]];then + cli_runFnEnvironment vcs --copy ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/syslinux.gpl ${PALETTE_GPL} + cli_expandTMarkers ${PALETTE_GPL} + fi + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") + + # Define the HEX palette. The HEX palette is built from source + # palette (PALETTE_GPL) and provides the color information in the + # format understood by `ppmtolss16', the program used to produce + # images in LSS16 format. The HEX palette stores just one line + # with the color information as described in isolinux + # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the + # same line]) + local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" --as-savedas-line + pngtopnm -verbose \ + < ${FILE}.png 2>${LOGS} > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" --as-palette-line + + # Create PPM palette using GPL palette. + svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" + + # Create HEX palette using GPL palette. + svg_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLORS" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.pnm" --as-savedas-line + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>> ${LOGS} > ${FILE}${PREFIX}.pnm + + # Create LSS16 image. + cli_printMessage "${FILE}${PREFIX}.lss" --as-savedas-line + ppmtolss16 $(cat $PALETTE_HEX) \ + < ${FILE}${PREFIX}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.lss + + # Remove HEX palette. It is no longer needed. + if [[ -f ${PALETTE_HEX} ]];then + rm $PALETTE_HEX + fi + + # Create PPM image indexed to 16 colors. Also the colormap used in + # the LSS16 image is saved on ${FILE}.log; this is useful to + # verify the correct order of colors in the image index. + cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line + lss16toppm -map \ + < ${FILE}${PREFIX}.lss 2>>${LOGS} > ${FILE}${PREFIX}.ppm + + # Create PNG image indexed to 16 colors. + cli_printMessage "${FILE}${PREFIX}.png" --as-savedas-line + pnmtopng -verbose \ + < ${FILE}${PREFIX}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.png + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToThumbnail.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToThumbnail.sh new file mode 100755 index 0000000..52dcf3b --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_convertPngToThumbnail.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# svg_convertPngToThumbnail.sh -- This function provides +# post-rendition to create thumbnails from images produced by +# centos-art base-rendition. Thumbnails are created in PNG and JPG +# format for you to decide which is the more appropriate one. When no +# size is specified, thumbnails are created at 250 pixels width and +# height is automatically calculated to match the image ratio. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_convertPngToThumbnail { + + # Get image size. + local SIZE='' + local SIZES=$(render_getConfigOption "$ACTION" '2-') + + # Check image sizes and do convertion. + if [[ "$SIZES" == "" ]];then + SIZES='250' + fi + + # Check base file existence. + cli_checkFiles -e "${FILE}.png" + + # Create thumbnails. + for SIZE in $SIZES;do + cli_printMessage "${FILE}-thumb-${SIZE}.png" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}.png ${FILE}-thumb-${SIZE}.png + cli_printMessage "${FILE}-thumb-${SIZE}.jpg" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.jpg + cli_printMessage "${FILE}-thumb-${SIZE}.pdf" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.pdf + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastActions.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastActions.sh new file mode 100755 index 0000000..5562eeb --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastActions.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# svg_doLastActions.sh -- This function performs last-rendition +# actions for SVG files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_doLastActions { + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then + return + fi + + local ACTION='' + + # Redefine SVG last-rendition actions as local to avoid undesired + # concatenation when massive rendition is performed. + local -a LASTACTIONS + + # Define SVG directory-specific actions. This is required in order + # to provide a predictable way of producing content inside the + # repository and save you the time of writing long several + # commands each time you need to produce images inside the + # repository. + if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then + if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Gdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToKsplash:' + fi + fi + + # Define SVG last-rendition actions. Since last-rendition makes + # use of all files in the output directory structure and + # directory-specific rendition modifies all the files in the + # output directory structure as well, these actions must be + # defined after the directory-specific definition. Otherwise, + # modifications impossed by these actions may interfier the whole + # purpose of having a directory-specific rendition. + [[ $FLAG_LASTRENDITION != '' ]] && LASTACTIONS[((++${#LASTACTIONS[*]}))]="doLastActions:(png|jpg):${FLAG_LASTRENDITION}" + + # At this point centos-art.sh should be producing the last file + # from the same unique directory structure, so, before producing + # images for the next directory structure lets execute the list of + # last-rendition actions for the current directory structure. + for ACTION in "${LASTACTIONS[@]}"; do + svg_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastCommand.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastCommand.sh new file mode 100755 index 0000000..458ec6b --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doLastCommand.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# svg_doLastCommand.sh -- This function standardizes the way +# last-rendition commands are applied to base-rendition and +# post-rendition outputs. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_doLastCommand { + + # Define the file extensions. This value is a regular expression + # pattern which must match the file extensions that last-rendition + # actions will be applied to. + local EXTENSION=$(render_getConfigOption "$ACTION" '2') + + # Define the command string that will be evaluated as + # last-rendition action. Only commands that perform in-place + # modifications can be passed here. + local COMMAND=$(render_getConfigOption "$ACTION" '3-') + + # Define the list of files to process. This value contain all the + # files in the output directory which extension match the + # extension pattern previously defined. + local FILE='' + local FILES=$(cli_getFilesList $OUTPUT --pattern="^.+\.${EXTENSION}$") + + for FILE in $FILES;do + + # Identify file before processing it. Only formats recognized + # by ImageMagick are supported. In case the file isn't + # supported by ImageMagick, continue with the next file in the + # list. + identify -quiet ${FILE} > /dev/null + if [[ $? -ne 0 ]];then + continue + fi + + # Print action message. + cli_printMessage "${FILE}" --as-updating-line + + # Execute mogrify action on all files inside the same + # directory structure. + eval ${COMMAND} ${FILE} + + # Be sure the command was executed correctly. Otherwise stop + # script execution. + if [[ $? -ne 0 ]];then + exit + fi + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostActions.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostActions.sh new file mode 100755 index 0000000..86b998e --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostActions.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# svg_doPostActions.sh -- This function performs post-rendition +# actions for SVG files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_doPostActions { + + local ACTION='' + + # Redefine SVG post-rendition actions as local to avoid undesired + # concatenation when massive rendition is performed. + local -a POSTACTIONS + + # Define default comment written to base-rendition output. + local COMMENT="`gettext "Created in CentOS Artwork Repository"` ($(cli_printUrl '--svn')artwork/)" + + # Define SVG post-rendition actions. Since these actions are + # applied to base-rendition output and base-rendition output is + # used as reference to perform directory-specific rendition, these + # action must be defined before directory-specific rendition. + # Otherwise it wouldn't be possible to propagate changes imposed + # by these actions to new files produced as result of + # directory-specific rendition. + POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:mogrify -comment '$COMMENT'" + [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:${FLAG_POSTRENDITION}" + + # Define SVG directory-specific rendition. Directory-specfic + # rendition provides a predictable way of producing content inside + # the repository. + if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then + + if [[ $TEMPLATE =~ "Identity/(Models|Images)/Themes/.+\.${RENDER_EXTENSION}$" ]];then + + POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngToBranded" + + if [[ $TEMPLATE =~ "Backgrounds/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupBy:png jpg' + + elif [[ $TEMPLATE =~ "Concept/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToThumbnail:250' + + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:-floyd' + + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:-floyd' + + elif [[ $TEMPLATE =~ "Posters/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + fi + + elif [[ $TEMPLATE =~ "Identity/Models/Icons/.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToIcons' + + elif [[ $TEMPLATE =~ "Identity/Models/Manuals.+\.${RENDER_EXTENSION}$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + + fi + + fi + + # Execute SVG post-rendition actions. + for ACTION in "${POSTACTIONS[@]}"; do + svg_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostCommand.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostCommand.sh new file mode 100755 index 0000000..42c7738 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doPostCommand.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# svg_doPostCommand.sh -- This function standardizes the way +# post-rendition commands are applied to base-rendition output. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_doPostCommand { + + # Define the file extension of base-rendition output. + local EXTENSION=$(render_getConfigOption "$ACTION" '2') + + # Define the command string. + local COMMAND=$(render_getConfigOption "$ACTION" '3-') + + # Verify the absolute path of base-rendition output. + cli_checkFiles -e ${FILE}.${EXTENSION} + + # Execute the command string on base-rendition output. + eval $COMMAND ${FILE}.${EXTENSION} + + # Be sure the command string was executed correctly. Otherwise + # stop the script execution. + if [[ $? -ne 0 ]];then + exit + fi + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_doTranslation.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doTranslation.sh new file mode 100755 index 0000000..2dc359e --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_doTranslation.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# +# svg_doTranslation.sh -- This function standardizes the way +# translation files are applied to SVG design models in order to +# produce the translated instance that is used to expand translation +# markers and produce PNG output in different languages. +# +# Assuming no translation file exists, an untranslated instace is +# taken from the design model and created (i.e., just a copy) from it. +# Using a design model instance (translated or not) is required in +# order to expand translation markers safetly. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_doTranslation { + + # Define which command will be used to output the template + # content. This is required because template files might be found + # as compressed files inside the repository. + local COMMAND="/bin/cat" + if [[ $(file -b -i $TEMPLATE) =~ '^application/x-gzip$' ]];then + COMMAND="/bin/zcat" + fi + + # Move into template's directory in order to satisfy relative + # entities. Take care that some XML documents (e.g., DocBook + # documents) can use entities relatively from their base + # locations. In order to process such documents, it is necessary + # to put the template directory up in the directory stack and + # create the instance from there. Thus, it is possible to expand + # relative entities correctly when validating the document. + pushd $(dirname $TEMPLATE) > /dev/null + + # Verify translation file existence and create template + # instance accordingly. + if [[ -f ${TRANSLATION} ]];then + + # Print final location of translation file. + cli_printMessage "${TRANSLATION}" --as-translation-line + + # Create translation instance to combine both template + # translation and licenses translations. + local TRANSLATION_INSTANCE=${TMPDIR}/message.po + + # In the case of SVG and other files, license translations is + # not required so we don't combine it into the template + # translation. + cp ${TRANSLATION} ${TRANSLATION_INSTANCE} + + # Create the translated instance of design model. + ${COMMAND} ${TEMPLATE} | xml2po -a -l ${CLI_LANG_LL} \ + -p ${TRANSLATION_INSTANCE} -o ${INSTANCE} - + + # Remove .xml2po.mo temporal file. + if [[ -f ${PWD}/.xml2po.mo ]];then + rm ${PWD}/.xml2po.mo + fi + + # Remove instance created to store both licenses and template + # translations. + if [[ -f ${TRANSLATION_INSTANCE} ]];then + rm ${TRANSLATION_INSTANCE} + fi + + else + + # Create the non-translated instance of design model. + ${COMMAND} ${TEMPLATE} > ${INSTANCE} + + fi + + # Return to where we were. + popd > /dev/null + + # Verify instance existence. + cli_checkFiles -e $INSTANCE + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_getColors.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_getColors.sh new file mode 100755 index 0000000..2b4ccd9 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_getColors.sh @@ -0,0 +1,154 @@ +#!/bin/bash +# +# svg_getColors.sh -- This function takes one palette produced by Gimp +# (e.g., syslinux.gpl) as input and outputs a list of colors in the +# specified format. In order for this function to output the color in +# the format specified, it is needed that the fourth column in the gpl +# palette be set in the `rrggbb' format and the appropriate conversion +# be implemented here. +# +# Notice that using both the `--head' and `--tail' options it is +# possible to control how many consecutive items does the list of +# colors is going to have. It is possible to output all colors in the +# list, or a consecutive range of them. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_getColors { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='head:,tail:,format:' + + # Initialize both head and tail values to return the first line of + # color information from the palette. + local HEAD=1 + local TAIL=1 + + # Initialize format value used as default when no format option be + # provided. + local FORMAT='rrggbb' + + # Initialize list of colors. + local COLORS='' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local ARGUMENTS='' + + # Prepare ARGUMENTS variable for getopt. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS using getopt(1) command parser. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + --head ) + HEAD=$2 + shift 2 + ;; + + --tail ) + TAIL=$2 + shift 2 + ;; + + --format ) + FORMAT=$2 + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Define path to gpl palette. This is the first file we use to + # retrieve color information from. Only the first file provided + # will be used. + local PALETTE=$(echo $@ | cut -d' ' -f1) + + if [[ ! -f $PALETTE ]];then + + # Define palette path inside the theme's artistic motif. + local MOTIF_PALETTE=${TCAR_WORKDIR}/Identity/Images/Themes/$(cli_getPathComponent $ACTIONVAL --motif)/Palettes/grub.gpl + + # Define palette path inside the theme's design model. + local MODEL_PALETTE=${TCAR_WORKDIR}/Identity/Models/Themes/${THEME_MODEL_NAME}/Palettes/grub.gpl + + # Redefine default background color using palettes provided by + # artistic motif first, and design model later. Assuming none + # of them is present, use The CentOS Project default color + # then. + if [[ -f $MOTIF_PALETTE ]];then + COLORS=$(svg_getColors $MOTIF_PALETTE --head=1 --tail=1) + elif [[ -f $MODEL_PALETTE ]];then + COLORS=$(svg_getColors $MODEL_PALETTE --head=1 --tail=1) + else + COLORS='#204c8d' + fi + + else + + # Retrieve the fourth column from GPL palette. The fourth + # column of a GPL palette contains the palette commentary + # field. The palette commentary field can be anything, but for + # the sake of our own convenience we use it to store the color + # value in hexadecimal format (e.g., rrggbb). Notice that you + # can put your comments from the fifth column on using an + # space as field separator. + COLORS=$(sed -r '1,/^#/d' $PALETTE \ + | awk '{ printf "%s\n", $4 }' | head -n $HEAD | tail -n $TAIL) + + fi + + # Implement color formats conversions from rrggbb to other formats + # that you might need to use. + for COLOR in $COLORS;do + + case $FORMAT in + + rrggbb|* ) + if [[ ! $COLOR =~ '^#' ]];then + COLOR="#${COLOR}" + fi + ;; + + esac + + # Output color value. + echo "$COLOR" + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_getTTFont.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_getTTFont.sh new file mode 100755 index 0000000..78b6050 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_getTTFont.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# cli_getFont.sh -- This function creates a list of all True Type +# Fonts (TTF) installed in your workstation and returns the absolute +# path of the file matching the pattern passed as first argument. +# Assuming more than one value matches, the first one in the list is +# used. In case no match is found, the function verifies if there is +# any file in the list that can be used (giving preference to sans +# files). If no file is found at this point, an error will be printed +# out. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_getTTFont { + + local -a FONT_PATTERNS + local FONT_PATTERN='' + local FONT_FILE='' + + # Define list of patterns used to build the list of TTF files. + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="/${1}\.ttf$" + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="sans\.ttf$" + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="\.ttf$" + + # Define directory location where fonts are installed in your + # workstation. + local FONT_DIR='/usr/share/fonts' + + # Define list of all TTF files installed in your workstation. + local FONT_FILES=$(cli_getFilesList ${FONT_DIR} --pattern="^.+\.ttf$") + + # Define TTF absolute path based on pattern. Notice that if the + # pattern matches more than one value, only the first one of a + # sorted list will be used. + for FONT_PATTERN in ${FONT_PATTERNS[@]};do + + FONT_FILE=$(echo "$FONT_FILES" | egrep ${FONT_PATTERN} \ + | head -n 1) + + if [[ -f $FONT_FILE ]];then + break + fi + + done + + # Output TTF absolute path. + if [[ -f $FONT_FILE ]];then + echo $FONT_FILE + else + cli_printMessage "`gettext "The font provided doesn't exist."`" --as-error-line + fi + +} diff --git a/Automation/Modules/Render/Modules/Svg/Scripts/svg_groupBy.sh b/Automation/Modules/Render/Modules/Svg/Scripts/svg_groupBy.sh new file mode 100755 index 0000000..25d334c --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/Scripts/svg_groupBy.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# svg_groupBy.sh -- This function provides post-rendition action to +# group files inside directories named as their file extensions. For +# example: if the current file is a .png file, it is moved inside a +# Png/ directory; if the current file is a .jpg file, it is stored +# inside a Jpg/ directory, and so on. +# +# For this function to work correctly, you need to specify which file +# type you want to group. This is done in the post-rendition ACTIONS +# array inside the appropriate `render.conf.sh' pre-configuration +# script. This function cannot be used as last-rendition action. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_groupBy { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + local FORMAT='' + local FORMATS=$(render_getConfigOption "$ACTION" '2-') + + for FORMAT in $FORMATS;do + + # Redifine source file we want to move. + SOURCE=${FILE}.${FORMAT} + + # Define target directory where source file will be moved + # into. + TARGET=$(dirname "$FILE")/$(cli_getRepoName $FORMAT -d) + + # Check existence of source file. + cli_checkFiles -e $SOURCE + + # Check existence of target directory. + if [[ ! -d $TARGET ]];then + mkdir -p $TARGET + fi + + # Redifine file path to add file and its type. + TARGET=${TARGET}/$(cli_getRepoName $FILE -f).${FORMAT} + + # Move file into its final location. + cli_printMessage "$TARGET" --as-movedto-line + mv ${SOURCE} ${TARGET} + + done + +} diff --git a/Automation/Modules/Render/Modules/Svg/svg.sh b/Automation/Modules/Render/Modules/Svg/svg.sh new file mode 100755 index 0000000..df419c6 --- /dev/null +++ b/Automation/Modules/Render/Modules/Svg/svg.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# +# svg.sh -- This function performs base-rendition action for SVG +# files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg { + + # Apply translation to design model in order to produce the + # translated design model instance. + svg_doTranslation + + # Expand translation markers inside design model instance. + cli_expandTMarkers ${INSTANCE} + + # Initialize the export id used inside design templates. This + # value defines the design area we want to export. + local EXPORTID='CENTOSARTWORK' + + # Verify the export id. + svg_checkModelExportId "$INSTANCE" "$EXPORTID" + + # Check existence of external files. Inside design templates and + # their instances, external files are used to refer the background + # information required by the design template. If such background + # information is not available the image is produced without + # background information. This is something that need to be + # avoided. + svg_checkModelAbsref "$INSTANCE" + + # Render template instance using inkscape and save the output. + local INKSCAPE_OUTPUT="$(\ + inkscape $INSTANCE --export-id=$EXPORTID --export-png=${FILE}.png)" + + # Modify output from inkscape to fit the centos-art.sh script + # output visual style. + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Area' \ + | sed -r "s!^Area!`gettext "Area"`:!")" --as-inkscape-line + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Background' \ + | sed -r "s!^Background (RRGGBBAA):(.*)!`gettext "Background"`: \1 \2!")" --as-inkscape-line + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Bitmap saved as' \ + | sed -r "s!^Bitmap saved as:!`gettext "Saved as"`:!")" --as-inkscape-line + + # Perform format post-rendition. + svg_doPostActions + + # Perform format last-rendition. + svg_doLastActions + +} diff --git a/Automation/Modules/Render/Scripts/render_getConfigOption.sh b/Automation/Modules/Render/Scripts/render_getConfigOption.sh new file mode 100755 index 0000000..dbf1937 --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_getConfigOption.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# render_getConfigOption.sh -- This function standardizes the +# configuration fields are retrived from some action-specific +# definitions. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getConfigOption { + + # Initialize action string. + local ACTION="$1" + + # Initialize field definition. + local FIELD="$2" + + # Initialize configuration options. + local OPTION='' + + # Check action string. The action string must be present in order + # for this function to work. It provides the information needed to + # retrive configurantion options from. + if [[ "$ACTION" == '' ]];then + cli_printMessage "`gettext "There is no action string to work with."`" --as-error-line + fi + + # Check field definition. The field definition must match any of + # the formats specified by the `-f' option of `cut' command. + if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then + cli_printMessage "`gettext "The field definition is not valid."`" --as-error-line + fi + + # Get configuration option from action string. + OPTION=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate configuration option retrived from action string. + OPTION=$(echo -n "${OPTION}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Print out the configuration option retrived from action string, + # only if it is not an empty value. Do not use `echo' or `printf' + # built-in commands here. Use the `cli_printMessage' functionality + # instead. This is required in order to reverse the apostrophe + # codification accomplished when options were retrived from + # command-line (cli_parseArgumentsReDef) in the argument of + # options like `--post-rendition' and `--last-rendition'. + if [[ $OPTION != '' ]];then + cli_printMessage "$OPTION" --as-stdout-line + fi + +} diff --git a/Automation/Modules/Render/Scripts/render_getDirOutput.sh b/Automation/Modules/Render/Scripts/render_getDirOutput.sh new file mode 100755 index 0000000..ffc475e --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_getDirOutput.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# +# render_getDirOutput.sh -- This function defines the final +# absolute path the centos-art.sh script uses to store identity +# contents produced at rendition time. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirOutput { + + # Define base output directory using design model path as + # reference. + OUTPUT=$(dirname $FILE | sed -r \ + -e "s!Identity/Models!Identity/Images!" \ + -e "s!Themes/${FLAG_THEME_MODEL}!Themes/$(cli_getPathComponent $ACTIONVAL --motif)!" \ + -e "s!Documentation/Models!Documentation/Manuals!" \ + -e "s!/Models!!") + + # By default, images rendered are stored under Identity/Images + # directory structure. But if an `Images/' directory exists in the + # current location use it instead. + if [[ -d "${OUTPUT}/Images" ]];then + OUTPUT=${OUTPUT}/Images + fi + + # Redefine base output directory to introduce specific information + # like release number and architecture. This information is + # require by directories (e.g., the `Media' directory inside + # themes and the `Documentation/Manuals/Docbook/Distro' directory + # ) whose need this information to be passed explicitly at the + # command-line through the `--releasever' and `--basearch' + # options. Other directories take such information from the path + # they are stored in (e.g., the `Distro/5/Anaconda' directory + # inside themes.). So, we need to differentiate the way + # information like release numbers and architectures are retrieved + # in order to build the output path correctly at rendition time. + if [[ $OUTPUT =~ "^${MOTIF_DIR}/Media$" ]];then + OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH} + elif [[ $OUTPUT =~ 'Documentation/Manuals/Docbook/Distro$' ]];then + OUTPUT=${OUTPUT}/${FLAG_RELEASEVER} + else + OUTPUT=${OUTPUT} + fi + + # Define whether to use or not locale-specific directory to store + # content, using current locale information as reference. As + # convection, when we produce content, only specific locations + # use locale-specific directories to organize language-specific + # content (e.g., Manuals, Anaconda, Installation media, etc.). All + # other locations do not use locale-specific directories to + # organize content. This convection is important in order for + # the `prepare' functionality of centos-art.sh script to produce + # content in the correct location. Otherwise, we might end up + # duplicating content (e.g., icons, brands, etc.) which doesn't + # have any translation, nor any need to be translated. + if [[ ! ${CLI_LANG_LC} =~ '^en' ]];then + OUTPUT=${OUTPUT}/${CLI_LANG_LC} + fi + + # Create final output directory, if it doesn't exist yet. + if [[ ! -d ${OUTPUT} ]];then + mkdir -p ${OUTPUT} + fi + +} diff --git a/Automation/Modules/Render/Scripts/render_getDirTemplate.sh b/Automation/Modules/Render/Scripts/render_getDirTemplate.sh new file mode 100755 index 0000000..9c6058a --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_getDirTemplate.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# render_getDirTemplate.sh -- This function defines the way renderable +# directories are processed inside the repository. Inside the +# repository, renderable directories are processed either through +# direct or theme-specific rendition. +# +# Direct rendition takes one XML file from design model +# (`Identity/Models') directory structure and produces one file +# in `Identity/Images' directory strucutre. In this +# configuration, the organization used to stored the design model is +# taken as reference to build the path required to store the image +# related to it under `Identity/Images' directory structure. +# +# Theme-specific rendition takes one design model from +# `Identity/Models/Themes' directory structure to produce one or +# more images in `Identity/Images/Themes/$THEME/$VERSION/$MODEL' +# directory structure. In this configuration we have many different +# artistic motifs that use one unique design model directory structure +# as reference to produce images. +# +# Since theme design models are unified to be reused by more +# than one artistic motif, it is not possible to render artistic +# motifs in a lineal manner (i.e., as we do with direct rendition) +# because we need to establish the relation between the artistic motif +# renderable directory structure and the design model first and that +# relation happens when renderable directory structures inside +# artistic motifs are processed individually. +# +# In the first rendition category, we use a design model directory +# structure as reference to produce images one by one. In the second +# rendition category, we can't use the same procedure because one +# design model directory structure is used to produce several +# renderable directory structures, not just one. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirTemplate { + + # Initialize design models location used as reference to process + # renderable directory structures. + TEMPLATE=$ACTIONVAL + + # Define absolute path to input files using absolute path from + # output files. + if [[ -d ${TEMPLATE}/Models ]];then + TEMPLATE=${TEMPLATE}/Models + else + TEMPLATE=$(echo "$TEMPLATE" | sed -r \ + -e "s!/Themes/$(cli_getPathComponent $ACTIONVAL --motif)!/Themes/${FLAG_THEME_MODEL}!" \ + -e "s!/(Manuals|Images)!/Models!") + fi + + # Verify absolute path to input file. This verification is + # specially needed in those situations when the artistic motif + # directory structure has an organization different to that in + # design models directory structure. Since the path to design + # models is built from artistic motif directory structure, if + # artistic motifs directory structure is different from design + # model directory structure, as result we'll have a path to a + # design model that may not exist and that would make + # centos-art.sh script to fail. So, verify the absolute path to + # the input file and stop script execution if it doesn't exist. + cli_checkFiles -e $TEMPLATE + +} diff --git a/Automation/Modules/Render/Scripts/render_getOptions.sh b/Automation/Modules/Render/Scripts/render_getOptions.sh new file mode 100755 index 0000000..6598f99 --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_getOptions.sh @@ -0,0 +1,131 @@ +#!/bin/bash +# +# render_getOptions.sh -- This function interprets option parameters +# passed to `render' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getOptions { + + # Define short options we want to support. + local ARGSS="h,q" + + # Define long options we want to support. + local ARGSL="help,quiet,filter:,answer-yes,dont-dirspecific,releasever:,basearch:,post-rendition:,last-rendition:,theme-model:,with-brands,synchronize" + + # Redefine ARGUMENTS using getopt(1) command parser. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + -h | --help ) + cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-render" + shift 1 + exit + ;; + + -q | --quiet ) + FLAG_QUIET="true" + shift 1 + ;; + + --filter ) + FLAG_FILTER="$2" + shift 2 + ;; + + --answer-yes ) + FLAG_ANSWER="true" + shift 1 + ;; + + --dont-dirspecific ) + FLAG_DONT_DIRSPECIFIC="true" + shift 1 + ;; + + --post-rendition ) + FLAG_POSTRENDITION="$2" + shift 2 + ;; + + --last-rendition ) + FLAG_LASTRENDITION="$2" + shift 2 + ;; + + --basearch ) + FLAG_BASEARCH="$2" + if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent --architecture-pattern) ]];then + cli_printMessage "`gettext "The architecture provided is not supported."`" --as-error-line + fi + shift 2 + ;; + + --releasever ) + FLAG_RELEASEVER="$2" + if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent --release-pattern) ]];then + cli_printMessage "`gettext "The release version provided is not supported."`" --as-error-line + fi + shift 2 + ;; + + --theme-model ) + FLAG_THEME_MODEL=$(cli_getRepoName $2 -d) + shift 2 + ;; + + --with-brands ) + FLAG_WITH_BRANDS='true' + shift 1 + ;; + + --synchronize ) + FLAG_SYNCHRONIZE='true' + shift 1 + ;; + + -- ) + # Remove the `--' argument from the list of arguments + # in order for processing non-option arguments + # correctly. At this point all option arguments have + # been processed already but the `--' argument still + # remains to mark ending of option arguments and + # beginning of non-option arguments. The `--' argument + # needs to be removed here in order to avoid + # centos-art.sh script to process it as a path inside + # the repository, which obviously is not. + shift 1 + break + ;; + esac + done + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + +} diff --git a/Automation/Modules/Render/Scripts/render_setBaseRendition.sh b/Automation/Modules/Render/Scripts/render_setBaseRendition.sh new file mode 100755 index 0000000..8591dec --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setBaseRendition.sh @@ -0,0 +1,276 @@ +#!/bin/bash +# +# render_setBaseRendition.sh -- This function performs base-rendition +# action for all files. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_setBaseRendition { + + local -a FILES + local FILE='' + local OUTPUT='' + local TEMPLATE='' + local TEMPLATES='' + local PARENTDIR='' + local TRANSLATION='' + local EXTERNALFILE='' + local EXTERNALFILES='' + local THIS_FILE_DIR='' + local NEXT_FILE_DIR='' + local RENDER_EXTENSION='' + local EXPORTID='' + local COUNT=0 + + # Verify default directory where design models are stored in. + cli_checkFiles -e "${TCAR_WORKDIR}/Identity/Models/Themes/${FLAG_THEME_MODEL}" + + # Redefine parent directory for current workplace. + PARENTDIR=$(basename "${ACTIONVAL}") + + # Loop through list of supported file extensions. + for RENDER_EXTENSION in ${RENDER_EXTENSIONS};do + + # Redefine rendition format name based on supported file + # extension. + if [[ $RENDER_EXTENSION =~ '^(svgz|svg)$' ]];then + RENDER_FORMAT='svg' + elif [[ $RENDER_EXTENSION =~ '^(docbook)$' ]];then + RENDER_FORMAT='docbook' + elif [[ $RENDER_EXTENSION =~ '^(conf)$' ]];then + RENDER_FORMAT='conf' + else + cli_printMessage "`eval_gettext "The \\\"\\\$RENDER_EXTENSION\\\" file extension is not supported yet."`" --as-error-line + fi + + # Redefine specific function export id. + EXPORTID="${CLI_FUNCDIRNAM}/$(cli_getRepoName ${RENDER_FORMAT} -d)/$(cli_getRepoName ${RENDER_FORMAT} -f)" + + # Define base location of template files using paths passed to + # centos-art.sh script as argument to. + render_getDirTemplate + + # Verify whether or not the source location of the path + # provided as argument to centos-art.sh script accepts or not + # localization messages. Don't produce localized content for + # repository components that don't accept it. + if [[ ! ${CLI_LANG_LC} =~ '^en' ]];then + cli_runFnEnvironment locale --is-localizable ${TEMPLATE} + fi + + # Define the list of files to process. Use an array variable + # to store the list of files to process. This make possible to + # realize verifications like: is the current base directory + # equal to the next one in the list of files to process? + # Questions like this let us to know when centos-art.sh is + # leaving a directory structure and entering another. This + # information is required in order for centos-art.sh to know + # when to apply last-rendition actions. + # + # Another issue is that some directories might be named as if + # they were files (e.g., using a render able extension like + # .docbook). In these situations we need to avoid such + # directories from being interpreted as a render able file. + # For this, pass the `--type="f"' option when building the + # list of files to process in order to retrieve regular files + # only. + # + # Another issue to consider here is that, in some cases, both + # templates and outputs might be in the same location. In + # these cases localized content are stored in the same + # location where template files are retrieved from and we need + # to avoid using localized content from being interpreted as + # design models. In that sake, build the list of files to + # process using the files directly stored in the directory + # passed as argument to centos-art.sh command-line. Don't go + # recursively here. + # + # Another issue to consider here, is the way of restricting + # the list of files to process. We cannot expand the pattern + # specified by FLAG_FILTER with a `.*' here (e.g., + # "${FLAG_FILTER}.*\.${RENDER_EXTENSION}") because that would + # suppress any possibility from the user to specify just one + # file name in locations where more than one file with the + # same name as prefix exists (e.g., `repository.docbook', + # `repository-preamble.docbook' and + # `repository-parts.docbook'). Instead, pass filtering + # control to the user whom can use regular expression markup + # in the `--filter' option to decide whether to match + # `repository.docbook' only (e.g., through + # `--filter="repository"') or `repository-preamble.docbook' + # and `repository-parts.docbook' but not `repository.docbook' + # (e.g., through `--filter="repository-.*"'). + if [[ ${RENDER_FORMAT} =~ "^docbook$" ]];then + + # When the render format is docbook, don't build a list of + # files to process. Instead, build the absolute path of + # the main file used to render docbook from models to + # final output manuals. This file must be stored directly + # inside the main manual's directory and named as it but + # with all letters in lowercase. + for FILE in $(cli_getFilesList ${TEMPLATE} \ + --maxdepth="1" --mindepth="1" \ + --pattern="^.*$(cli_getRepoName ${TEMPLATE} -f)\.${RENDER_EXTENSION}$" \ + --type="f");do + FILES[((++${#FILES[*]}))]=$FILE + done + + elif [[ ${RENDER_FORMAT} =~ "^conf$" ]];then + + # When the render format is conf, be sure it refers to + # image.conf files only. Other configuration files (e.g., + # branding.conf) cannot be processed this way because + # their configuration options and values haven't any + # meaning in this context. + for FILE in $(cli_getFilesList ${TEMPLATE} \ + --pattern="^.+/images\.${RENDER_EXTENSION}$" \ + --type="f");do + FILES[((++${#FILES[*]}))]=$FILE + done + + else + + # For all other cases, build a list of files to process + # using the path value pass as argument. + for FILE in $(cli_getFilesList ${TEMPLATE} \ + --pattern="^.+/${FLAG_FILTER}.*\.${RENDER_EXTENSION}$" \ + --type="f");do + FILES[((++${#FILES[*]}))]=$FILE + done + + fi + + # Verify list of files to process. Assuming no file was found, + # evaluate the next supported file extension. + if [[ ${#FILES[*]} -eq 0 ]];then + continue + fi + + # Initialize format-specific functionalities. + cli_exportFunctions "${EXPORTID}" + + # Start processing the base rendition list of FILES. Fun part + # approaching :-). + while [[ $COUNT -lt ${#FILES[*]} ]];do + + # Define base file. + FILE=${FILES[$COUNT]} + + # Define the base directory path for the current file being + # process. + THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) + + # Define the base directory path for the next file that will + # be process. + if [[ $(($COUNT + 1)) -lt ${#FILES[*]} ]];then + NEXT_FILE_DIR=$(dirname ${FILES[$(($COUNT + 1))]}) + else + NEXT_FILE_DIR='' + fi + + # Print separator line. + cli_printMessage '-' --as-separator-line + + # Print action message based on file extension. + if [[ ${FILE} =~ 'images\.conf$' ]] && [[ $FLAG_WITH_BRANDS == 'true' ]];then + cli_printMessage "${FILE}" --as-processing-line + elif [[ ${FILE} =~ 'brands\.conf$' ]];then + continue + else + cli_printMessage "${FILE}" --as-template-line + fi + + # Verify design models file existence. We cannot continue + # with out it. + cli_checkFiles ${FILE} -f + + # Define final location of translation file. + TRANSLATION=$(dirname ${FILE} \ + | sed -r 's!(Documentation|Identity)!Locales/\1!')/${CLI_LANG_LC}/messages.po + + # Define final location of template file. + TEMPLATE=${FILE} + + # Define final location of output directory. + render_getDirOutput + + # Get relative path to file. The path string (stored in + # FILE) has two parts: 1. the variable path and 2. the + # common path. The variable path is before the common + # point in the path string. The common path is after the + # common point in the path string. The common point is the + # name of the parent directory (stored in PARENTDIR). + # + # Identity/Models/Themes/.../Firstboot/3/splash-small.svg + # -------------------------^| the |^------------^ + # variable path | common | common path + # -------------------------v| point | v------------v + # Identity/Images/Themes/.../Firstboot/Img/3/splash-small.png + # + # What we do here is remove the variable path, the common + # point, and the file extension parts in the string + # holding the path retrieved from design models directory + # structure. Then we use the common path as relative path + # to store the final image file. + # + # The file extension is removed from the common path + # because it is set when we create the final image file. + # This configuration let us use different extensions for + # the same file name. + # + # When we render using base-rendition action, the + # structure of files under the output directory will be + # the same used after the common point in the related + # design model directory structure. + FILE=$(echo ${FILE} \ + | sed -r "s!.*${PARENTDIR}/!!" \ + | sed -r "s/\.${RENDER_EXTENSION}$//") + + # Define absolute path to final file (without extension). + FILE=${OUTPUT}/$(basename "${FILE}") + + # Define instance name from design model. + INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) + + # Perform format base-rendition. + ${RENDER_FORMAT} + + # Remove template instance. + if [[ -f $INSTANCE ]];then + rm $INSTANCE + fi + + # Increment file counter. + COUNT=$(($COUNT + 1)) + + done + + # Reset counter to prevent accumulation of values. + COUNT=0 + + # Unset format-specific functionalities. + cli_unsetFunctions "${EXPORTID}" + + # Unset files list to prevent accumulation of values. + unset FILES + + done +} diff --git a/Automation/Modules/Render/Scripts/render_setBrands.sh b/Automation/Modules/Render/Scripts/render_setBrands.sh new file mode 100755 index 0000000..187c4df --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setBrands.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# render_setBrands.sh -- This function performs brand-specific +# rendition. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_setBrands { + + local BRANDS_MODELS_DIR=${TCAR_WORKDIR}/Identity/Models/Brands + local BRANDS_IMAGES_DIR=${TCAR_WORKDIR}/Identity/Images/Brands + + render_setBrandsDirValidates ${BRANDS_IMAGES_DIR} ${ACTIONVAL} + render_setBrandsDirStructure ${BRANDS_MODELS_DIR} ${BRANDS_IMAGES_DIR} + + render_setBaseRendition + +} diff --git a/Automation/Modules/Render/Scripts/render_setBrandsDirStructure.sh b/Automation/Modules/Render/Scripts/render_setBrandsDirStructure.sh new file mode 100755 index 0000000..453e90c --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setBrandsDirStructure.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# render_setBrandsDirectoryStructure.sh -- This function verifies the +# directory structure of brands images using the directory structure +# of brands models as reference. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_setBrandsDirStructure { + + local BRANDS_SOURCE_DIR=$(cli_checkRepoDirSource ${1}) + local BRANDS_TARGET_DIR=$(cli_checkRepoDirSource ${2}) + + cli_printMessage "${BRANDS_TARGET_DIR} `gettext "directory structures..."`" --as-checking-line + + cli_runFnEnvironment prepare ${BRANDS_SOURCE_DIR} ${BRANDS_TARGET_DIR} --directories + +} diff --git a/Automation/Modules/Render/Scripts/render_setBrandsDirValidates.sh b/Automation/Modules/Render/Scripts/render_setBrandsDirValidates.sh new file mode 100755 index 0000000..8622474 --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setBrandsDirValidates.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# render_setBrandsDirVerification.sh -- This function standardize path +# verification between path provided in the command line and +# repository directory structure. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + + +function render_setBrandsDirValidates { + + local BRANDS_PATH_OK=$(cli_checkRepoDirSource ${1}) + local BRANDS_PATH_UNKNOWN=$(cli_checkRepoDirSource ${2}) + + cli_checkFiles ${BRANDS_PATH_UNKNOWN} --match="^${BRANDS_PATH_OK}" + + local BRANDS_PATH_UNKNOWN_MODEL=$(echo ${BRANDS_PATH_UNKNOWN} \ + | sed -r "s,/Images/,/Models/,") + + cli_checkFiles ${BRANDS_PATH_UNKNOWN_MODEL} -d + +} diff --git a/Automation/Modules/Render/Scripts/render_setDirStructure.sh b/Automation/Modules/Render/Scripts/render_setDirStructure.sh new file mode 100755 index 0000000..8064b59 --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setDirStructure.sh @@ -0,0 +1,100 @@ +#!/bin/bash +###################################################################### +# +# render_setDirStructure.sh -- This function standardizes the +# relation between source and target directory structures inside the +# repository. +# +# This function takes two arguments. The first is the source +# directory and the second is the target directory where you wan to +# reproduce the source directory structure. In order for this to +# work, all source directory structures provided to this function +# must have one level of directories more than its related target +# directory. The purpose of this level is content categorization. +# For example, consider the following path: +# +# ----------++++++++++++++++++++++++ +# ${SOURCE}/${CATEGORY}/${COMPONENT} +# ----------++++++++++++++++++++++++ +# +++++++++++++++++++++++++++++------------ +# ${TARGET}/${NAME}/${VERSION}/${COMPONENT} +# +++++++++++++++++++++++++++++------------ +# +# So we end with the following path: +# +# ${TARGET}/${CATEGORY}/${COMPONENT} +# +# In this path, ${CATEGORY} makes reference to a categorization +# directory used to describe source components related to target +# components. However, in the target side, such ${CATEGORY} +# directory is not needed and should be removed from it in order to +# get the final target path, which is: +# +# ${TARGET}/${COMPONENT} +# +# ${CATEGORY} is always a one-level directory, but ${COMPONENT} +# might have several levels deep inside. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function render_setDirStructure { + + # Define absolute path to design models' directory structure. This + # directory contains the directory structure you want to verify + # inside target path. + local SOURCE_DIRECTORY=$(tcar_checkRepoDirSource "${1}") + + # Verify existence source path, just to be sure it was passed and + # it is a valid directory. + tcar_checkFiles ${SOURCE_DIR} -d + + # Define absolute path to directory inside the repository where + # you want to replicate the source path directory structure. + local TARGET_DIRECTORY=$(tcar_checkRepoDirSource "${2}") + + # NOTE: It is possible that target path doesn't exist. So verify + # the relation between target and source path. If there is a + # source path for the target, create an empty directory as target, + # using the related source directory as reference. + + # Define list of directories inside source path. + local DIRECTORIES=$(tcar_getFilesList ${SOURCE_DIRECTORY} \ + --pattern='.+/[[:alpha:]]+$' --type='d') + + # Iterate through directories inside source path and verify + # whether or not they exist in the target path. If they don't + # exist create them. + for DIRECTORY in ${DIRECTORIES};do + + local DIRECTORY_BASENAME=$(echo ${DIRECTORY} \ + | sed -r "s,${SOURCE_DIRECTORY}/,,") + + if [[ ${DIRECTORY} == ${DIRECTORY_BASENAME} ]];then + continue + fi + + local DIRECTORY_TARGET=${TARGET_DIRECTORY}/${DIRECTORY_BASENAME} + + if [[ ! -d ${DIRECTORY_TARGET} ]];then + mkdir -p ${DIRECTORY_TARGET} + fi + + done + +} diff --git a/Automation/Modules/Render/Scripts/render_setThemes.sh b/Automation/Modules/Render/Scripts/render_setThemes.sh new file mode 100755 index 0000000..134d6aa --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setThemes.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# render_setThemes.sh -- This function performs theme-specific +# rendition. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_setThemes { + + local -a DIRS + local COUNT=0 + local NEXTDIR='' + local MOTIF_NAME='' + local MOTIF_DIR='' + + # Define base directory of artistic motifs. This is the location + # where all artistic motifs are stored in. + local MOTIF_BASEDIR="${TCAR_WORKDIR}/Identity/Images/Themes" + + # Define base directory of design models. This is the location + # where all design models are stored in. + local MODEL_BASEDIR="${TCAR_WORKDIR}/Identity/Models/Themes" + + # Verify directory structure for all theme-specific directories. + render_setThemesDirStructure "${MODEL_BASEDIR}/${FLAG_THEME_MODEL}" "${MOTIF_BASEDIR}" + + # Define directory structure of design models. Design models + # directory structures are used as reference to create artistic + # motifs directory structure. Use the `--pattern' option to be + # sure any modification to FLAG_FILTER won't affect the output + # result. We need to make matching everything here, no matter what + # the FLAG_FILTER value be. + local MODEL_DIR='' + local MODEL_DIRS="$(cli_getFilesList ${MODEL_BASEDIR}/${FLAG_THEME_MODEL} \ + --pattern='^.+/[^.svn][[:alnum:]_/-]+$' --type="d" \ + | sed -e "s!^.*/${FLAG_THEME_MODEL}!!" \ + -e '/^[[:space:]]*$/d' \ + -e 's!^/!!')" + + # Define design model regular expression patterns from design + # models directory structure. + local MODEL_PATTERN=$(echo "$MODEL_DIRS" | tr "\n" '|' \ + | sed -e 's!^|!!' -e 's!|$!!') + + # Define regular expression pattern that match the theme artistic + # motif component inside the path strings. + local MOTIF_PATTERN=$(cli_getPathComponent --motif-pattern) + + # Define list of render-able directory structures inside the + # artistic motif. As reference, to build this list, use design + # model directory structure. The more specific you be in the path + # specification the more specific theme rendition will be. Thus, + # we use the path provided as argument and the --filter option as + # reference to control the amount of directories considered + # render-able directory. + local MOTIF_RENDERABLE_DIR='' + local MOTIF_RENDERABLE_DIRS=$(cli_getFilesList ${MOTIF_BASEDIR} \ + --pattern="^${TCAR_WORKDIR}/${MOTIF_PATTERN}/($MODEL_PATTERN)$" --type="d" \ + | grep "$(echo ${ACTIONVAL} | sed -r 's,/$,,')") + + # When no render-able directories are found, finish the script + # execution with an error message. There is an obvious typo in the + # path provided. + if [[ -z ${MOTIF_RENDERABLE_DIRS} ]];then + cli_printMessage "`gettext "No related model was found for the path provided."`" --as-error-line + fi + + # Rebuild list of render-able directory structures using an array + # variable. This let us to predict what directory is one step + # forward or backward from the current directory structure. + for MOTIF_RENDERABLE_DIR in $MOTIF_RENDERABLE_DIRS;do + DIRS[((++${#DIRS[*]}))]=${MOTIF_RENDERABLE_DIR} + done + + # Define total number of directories to process. This is required + # in order to correct the counting value and so, make it to match + # the zero based nature of bash array variables. + local DIRS_TOTAL=$((${#DIRS[*]} - 1)) + + while [[ $COUNT -le ${DIRS_TOTAL} ]];do + + # Redefine action value to refer the theme-specific render-able + # directory. + ACTIONVAL=${DIRS[$COUNT]} + + # Refine artistic motif name using the current action value. + MOTIF_NAME=$(cli_getPathComponent $ACTIONVAL --motif) + + # Verify artistic motif name. The name of the artistic motif + # must be present in order for theme rendition to happen. + # Theme rendition takes place inside artistic motifs and the + # artistic motif name is an indispensable part of it. Take + # care of not using design models directory structure as name + # for artistic motifs. They, sometimes, match the pattern used + # to verify artistic motifs names but must not be confused. + if [[ $MOTIF_NAME == '' ]] || [[ $MOTIF_NAME =~ "^($MODEL_PATTERN)" ]];then + COUNT=$(($COUNT + 1)) + continue + fi + + # Refine artistic motif directory. This is the top directory + # where all visual manifestations of an artistic motif are + # stored in (e.g., Backgrounds, Brushes, Concept, Distro, + # etc.). + MOTIF_DIR="${MOTIF_BASEDIR}/${MOTIF_NAME}" + + # Define what is the next directory in the list, so we could + # verify whether to render or not the current theme-specific + # render-able directory. + if [[ $COUNT -lt ${DIRS_TOTAL} ]];then + NEXTDIR=$(dirname ${DIRS[(($COUNT + 1))]}) + else + NEXTDIR='' + fi + + # Verify whether to render or not the current theme's + # render-able directory. This verification is needed in order + # to avoid unnecessary rendition loops. For example, don't + # render `path/to/dir/A' when `path/to/dir/A/B' does exist, + # that configuration would produce `/path/to/dir/A/B twice. + if [[ $ACTIONVAL =~ '[[:digit:]]$' ]] || [[ $ACTIONVAL == $NEXTDIR ]];then + COUNT=$(($COUNT + 1)) + continue + fi + + # Execute direct rendition on theme specific render-able + # directory as specified by action value. + render_setBaseRendition + + # Increment counter to match the correct count value. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Automation/Modules/Render/Scripts/render_setThemesDirStructure.sh b/Automation/Modules/Render/Scripts/render_setThemesDirStructure.sh new file mode 100755 index 0000000..ed98d3d --- /dev/null +++ b/Automation/Modules/Render/Scripts/render_setThemesDirStructure.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# render_setThemeDirectoryStructre.sh -- This function verifies +# theme-specific directory structures using common theme models +# directory structure as pattern. If there are missing directories inside +# theme-specific directories, this function will create it. This is a +# requisite of rendition process, so be sure to call this function +# before building the list of render-able theme directories. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + + +function render_setThemesDirStructure { + + local THEMES_SOURCE_DIR=$(cli_checkRepoDirSource "${1}") + local THEMES_TARGET_DIR=$(cli_checkRepoDirSource "${2}") + + local THEMES_FILTER=${THEMES_TARGET_DIR}/$(cli_getPathComponent --motif ${ACTIONVAL}) + + THEMES_TARGET_DIRS=$(cli_getFilesList ${THEMES_TARGET_DIR} \ + --pattern=".+/[[:digit:]]+$" --maxdepth=2 --mindepth=2 \ + | grep "${THEMES_FILTER}") + + for THEMES_TARGET_DIR in $THEMES_TARGET_DIRS;do + cli_printMessage "$THEMES_TARGET_DIR `gettext "directory structure..."`" --as-checking-line + cli_runFnEnvironment prepare ${THEMES_SOURCE_DIR} ${THEMES_TARGET_DIR} --directories + done + +} diff --git a/Automation/Modules/Render/Svg/svg.sh b/Automation/Modules/Render/Svg/svg.sh deleted file mode 100755 index df419c6..0000000 --- a/Automation/Modules/Render/Svg/svg.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# -# svg.sh -- This function performs base-rendition action for SVG -# files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg { - - # Apply translation to design model in order to produce the - # translated design model instance. - svg_doTranslation - - # Expand translation markers inside design model instance. - cli_expandTMarkers ${INSTANCE} - - # Initialize the export id used inside design templates. This - # value defines the design area we want to export. - local EXPORTID='CENTOSARTWORK' - - # Verify the export id. - svg_checkModelExportId "$INSTANCE" "$EXPORTID" - - # Check existence of external files. Inside design templates and - # their instances, external files are used to refer the background - # information required by the design template. If such background - # information is not available the image is produced without - # background information. This is something that need to be - # avoided. - svg_checkModelAbsref "$INSTANCE" - - # Render template instance using inkscape and save the output. - local INKSCAPE_OUTPUT="$(\ - inkscape $INSTANCE --export-id=$EXPORTID --export-png=${FILE}.png)" - - # Modify output from inkscape to fit the centos-art.sh script - # output visual style. - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Area' \ - | sed -r "s!^Area!`gettext "Area"`:!")" --as-inkscape-line - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Background' \ - | sed -r "s!^Background (RRGGBBAA):(.*)!`gettext "Background"`: \1 \2!")" --as-inkscape-line - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Bitmap saved as' \ - | sed -r "s!^Bitmap saved as:!`gettext "Saved as"`:!")" --as-inkscape-line - - # Perform format post-rendition. - svg_doPostActions - - # Perform format last-rendition. - svg_doLastActions - -} diff --git a/Automation/Modules/Render/Svg/svg_checkColorAmount.sh b/Automation/Modules/Render/Svg/svg_checkColorAmount.sh deleted file mode 100755 index 8d25900..0000000 --- a/Automation/Modules/Render/Svg/svg_checkColorAmount.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# svg_checkColorAmount.sh -- This function verifies whether the list -# of colors provided in the first argument matches the amount of -# colors specified by the second argument. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_checkColorAmount { - - # Define list of colors. - local COLORS=$1 - - # Define the amount of colors the list provided must have, in - # order to be considered as valid. - local NUMBER=$2 - - # Verify amount of colors provided in the list. - if [[ $(echo "$COLORS" | wc -l) -ne $NUMBER ]];then - cli_printMessage "`gettext "The palette does not have the correct number of colors."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Render/Svg/svg_checkColorFormats.sh b/Automation/Modules/Render/Svg/svg_checkColorFormats.sh deleted file mode 100755 index 19ddd9d..0000000 --- a/Automation/Modules/Render/Svg/svg_checkColorFormats.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# -# svg_checkColorFormats.sh -- This function verifies formats of colors -# (i.e., the way color information is specified). -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_checkColorFormats { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='format:' - - # Initialize pattern used for color sanitation. - local PATTERN='^#[0-9a-f]{6}$' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS variable for getopt. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - --format ) - - case "$2" in - - rrggbb|*) - PATTERN='^#[0-9a-f]{6}$' - ;; - - esac - shift 2 - ;; - - -- ) - shift 1 - break - ;; - esac - done - - # Define the location we want to apply verifications to. - local COLOR='' - local COLORS="$@" - - # Loop through colors and perform format verification as specified - # by pattern. - for COLOR in $COLORS;do - - if [[ ! $COLOR =~ $PATTERN ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$COLOR\\\" string is not a valid color code."`" --as-error-line - fi - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_checkModelAbsref.sh b/Automation/Modules/Render/Svg/svg_checkModelAbsref.sh deleted file mode 100755 index 4775e26..0000000 --- a/Automation/Modules/Render/Svg/svg_checkModelAbsref.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# -# svg_checkModelAbsref.sh -- This function retrives absolute files and -# checks their existence. In order for design templates to point -# different artistic motifs, design templates make use of external -# files which point to specific artistic motif background images. If -# such external files don't exist, try to create the background image -# required by cropping a higher background image (e.g., -# 2048x1536-final.png). If this isn't possible neither, then create -# the background image using a plain color and crop from it then. We -# can't go on without the required background information. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_checkModelAbsref { - - local FILE='' - local BG_DST_FILES='' - local BG_DST_FILE='' - local BG_DST_FILE_WIDTH='' - local BG_DST_FILE_HEIGHT='' - local BG_SRC_FILE='' - local BG_SRC_FILE_COLOR='' - local BG_SRC_FILE_WIDTH='' - local BG_SRC_FILE_HEIGHT='' - - # Define absolute path to the translated instance of design model. - FILE="$1" - - # Verify existence of file we need to retrive absolute paths from. - cli_checkFiles -e "$FILE" - - # Retrive absolute paths from file. - BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ - | sed -r "s,.+=\"(${HOME}.+\.png)\".*,\1," | sort | uniq) - - # Verify absolute paths retrived from file. - for BG_DST_FILE in $BG_DST_FILES;do - - # Print action message. - cli_printMessage "$BG_DST_FILE" --as-checking-line - - # Verify parent directory of absolute files retrived from - # file. This is required to prevent the construction of paths - # to locations that don't exist. For example, when including - # background images in SVG files, it is possible that the path - # information inside SVG files get outdated temporarly. If in - # that exact moment, you try to render the SVG file it won't - # be possible to create the image used for cropping because - # the path build from the location inside SVG file doesn't - # exist. In this case, centos-art.sh script will end up with - # `file ... doesn't exist' errors. - cli_checkFiles -d "$(dirname ${BG_DST_FILE})" - - if [[ ! -a $BG_DST_FILE ]];then - - # Define the source background file, the image file will - # crop when no specific background informatio be available - # for using. Generally, this is the most reusable - # background file inside the artistic motifs (e.g,. the - # `2048x1536-final.png' file). We can use this image file - # to create almost all artworks inside The CentOS - # Distribution visual manifestation when - # resolution-specific backgrounds don't exist. - BG_SRC_FILE=$(echo $BG_DST_FILE \ - | sed -r "s!(.+)/[[:digit:]]+x[[:digit:]]+(-final\.png)!\1/2048x1536\2!") - - # Verify existence of source background file. If the file - # doesn't exist create it using The CentOS Project default - # background color information, as specified in its - # corporate identity manual. - if [[ ! -f $BG_SRC_FILE ]];then - - # Define plain color that will be used as background. - BG_SRC_FILE_COLOR=$(svg_getColors) - - # Verify format of color value. - svg_checkColorFormats $BG_SRC_FILE_COLOR --format='rrggbb' - - # Define width for the source background file the - # required background information is cropped from. - BG_SRC_FILE_WIDTH=$(echo $BG_SRC_FILE \ - | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') - - # Define height for the source background file the - # required background information is cropped from. - BG_SRC_FILE_HEIGHT=$(echo $BG_SRC_FILE \ - | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') - - # Print action message. - cli_printMessage "${BG_SRC_FILE} ($BG_SRC_FILE_COLOR)" --as-creating-line - - # Create the source background file. - ppmmake -quiet ${BG_SRC_FILE_COLOR} \ - ${BG_SRC_FILE_WIDTH} ${BG_SRC_FILE_HEIGHT} \ - | pnmtopng > ${BG_SRC_FILE} - - fi - - # Print action message. - cli_printMessage "$BG_SRC_FILE" --as-cropping-line - - # Define the width of the required background information. - BG_DST_FILE_WIDTH=$(echo $BG_DST_FILE \ - | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') - - # Define the height of the required background information. - BG_DST_FILE_HEIGHT=$(echo $BG_DST_FILE \ - | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') - - # Create required backgrounnd information. - convert -quiet \ - -crop ${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT}+0+0 \ - ${BG_SRC_FILE} ${BG_DST_FILE} - - # Verify required background information. - cli_checkFiles -e $BG_DST_FILE - - fi - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_checkModelExportId.sh b/Automation/Modules/Render/Svg/svg_checkModelExportId.sh deleted file mode 100755 index 2944195..0000000 --- a/Automation/Modules/Render/Svg/svg_checkModelExportId.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# svg_checkModelExportId.sh -- This function standardizes the export -# id used inside svg files and the way of verify them. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_checkModelExportId { - - local INSTANCE="$1" - local EXPORTID="$2" - - # Verify instance. - cli_checkFiles -e $INSTANCE - - # Verify export id. - if [[ $EXPORTID == '' ]];then - cli_printMessage "`gettext "The export id value cannot be empty."`" --as-error-line - fi - - # Check export id inside design templates. - grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null - if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "There is not export id (\\\$EXPORTID) inside \\\"\\\$TEMPLATE\\\"."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Render/Svg/svg_convertGplToHex.sh b/Automation/Modules/Render/Svg/svg_convertGplToHex.sh deleted file mode 100755 index 51efe26..0000000 --- a/Automation/Modules/Render/Svg/svg_convertGplToHex.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# svg_convertGplToHex.sh -- This function takes one palette produced -# by Gimp (e.g., syslinux.gpl) as input and outputs the list of -# hexadecimal colors and their respective index position the -# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all -# values in the same line]). -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertGplToHex { - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to HEX palette. This is the palette used to stored - # the color information the `ppmtolss16' program needs. - local PALETTE_HEX="$2" - - # Define the number of colors this function should return. - local NUMBER="$3" - - # Define list of colors from GPL palette. - local COLORS=$(svg_getColors $PALETTE_GPL --head=$NUMBER --tail=$NUMBER) - - # Verify number of colors returned in the list. They must match - # exactly the amount specified, no more no less. Sometimes, the - # list of colors may have less colors than it should have, so we - # need to prevent such palettes from being used. - svg_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - svg_checkColorFormats "$COLORS" --format='rrggbb' - - # Create list of colors to be processed by `pnmtolss16'. - echo "$COLORS" | nl | gawk '{ printf "%s=%d ", $2, $1 - 1 }' \ - > $PALETTE_HEX - - # Verify HEX palette existence. - cli_checkFiles -e $PALETTE_HEX - -} diff --git a/Automation/Modules/Render/Svg/svg_convertGplToPpm.sh b/Automation/Modules/Render/Svg/svg_convertGplToPpm.sh deleted file mode 100755 index 559127b..0000000 --- a/Automation/Modules/Render/Svg/svg_convertGplToPpm.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# svg_convertGplToPpm.sh -- This function takes one palette produced -# by Gimp (e.g., syslinux.gpl) as input and outputs one PPM file based -# on it (e.g., syslinux.ppm). -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertGplToPpm { - - local -a FILES - local COUNT=0 - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to PPM palette. This is the .ppm file we'll save - # color information to. - local PALETTE_PPM="$2" - - # Define the number of colors this function should return. - local NUMBER="$3" - - # Define list of colors from GPL palette. - local COLOR='' - local COLORS=$(svg_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') - - # Verify amount of colors in the list of colors. - svg_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - svg_checkColorFormats $COLORS --format='rrggbb' - - # Create temporal images (of 1x1 pixel each) to store each color - # retrived from Gimp's palette. - for COLOR in $COLORS;do - FILES[$COUNT]=$(cli_getTemporalFile ${COUNT}.ppm) - ppmmake $COLOR 1 1 > ${FILES[$COUNT]} - COUNT=$(($COUNT + 1)) - done - - # Concatenate each temporal image from left to right to create the - # PPM file. - pnmcat -lr ${FILES[*]} > $PALETTE_PPM - - # Remove temporal images used to build the PPM palette file. - rm ${FILES[*]} - - # Verify PPM palette existence. - cli_checkFiles -e "$PALETTE_PPM" - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngTo.sh b/Automation/Modules/Render/Svg/svg_convertPngTo.sh deleted file mode 100755 index 9fad7ba..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngTo.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# svg_convertPngTo.sh -- This function provides post-rendition actions -# to use the `convert' command of ImageMagick tool set. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngTo { - - # Initialize image formats. - local FORMAT='' - local FORMATS=$(render_getConfigOption "$ACTION" '2') - - # Convert from PNG to specified formats. - for FORMAT in $FORMATS;do - cli_printMessage "${FILE}.${FORMAT}" --as-savedas-line - convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} - done - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToBranded.sh b/Automation/Modules/Render/Svg/svg_convertPngToBranded.sh deleted file mode 100755 index 8ffba47..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToBranded.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToBranded.sh -- This function standardizes image -# branding. Once the base PNG image is rendered and the -# `--with-brands' option is provided, this function composites a new -# branded image using the preferences set in the related -# `branding.conf' file. The `branding.conf' file must be stored -# inside the related design model component used as reference to -# produce the base PNG image. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToBranded { - - # Verify whether the option `--with-brands' was provided or not to - # `centos-art.sh' script command-line. - if [[ $FLAG_WITH_BRANDS == 'false' ]];then - return - fi - - local BRANDING_CONF_FILE='' - local BRANDING_CONF_SECTION='' - local BRANDING_CONF_VALUES='' - local BRANDING_CONF_VALUE='' - local BRANDFILE='' - local POSITION='' - local POSITIONS='' - - # Define absolute path to branding configuration file. - BRANDING_CONF_FILE="$(dirname ${TEMPLATE})/branding.conf" - - # Verify absolute path to branding configuration file. This is - # required in order to avoid trying to render branded content - # which doesn't have an associated `branding.conf' file. If there - # is no associated `branding.conf' file don't stop the script - # execution. Instead, continue with the next action in the list. - # This is required in order to perform massive rendition inside - # structures like themes where components might or might not have - # `branding.conf' files associated. For example, the `Concept' - # component doesn't have branding information associated but most - # elements inside `Distro' component do. - if [[ ! -f "$BRANDING_CONF_FILE" ]];then - continue - fi - - # Define regular expression matching the variable name (i.e., the - # left column), inside the configuration line, you want to match - # on. - BRANDING_CONF_VARNAME=$(basename ${TEMPLATE}) - - # Define list of configuration lines related to current design - # model. This are the lines that tell us how and where to apply - # branding information on base PNG image. Be sure that only - # configuration lines from supported section names (e.g., - # `symbol', `type', `logo') be read, no need to waste resources - # with others. - BRANDING_CONF_VALUES=$(\ - for BRANDING_CONF_SECTION in $(echo "types symbols logos");do - cli_getConfigValue "${BRANDING_CONF_FILE}" "${BRANDING_CONF_SECTION}" "${BRANDING_CONF_VARNAME}" - done) - - for BRANDING_CONF_VALUE in $BRANDING_CONF_VALUES;do - - # Define absolute path to image file used as brand. This is - # the image put over the PNG image produced as result of - # design models base rendition. - BRANDFILE=${TCAR_WORKDIR}/Identity/Images/Brands/$(echo $BRANDING_CONF_VALUE \ - | gawk 'BEGIN{ FS=":" } { print $1 }' ) - - # Verify absolute path to image file used as brand. Assuming - # no brand image file is found, continue with the next - # configuration line. - if [[ ! -f $BRANDFILE ]];then - continue - fi - - # Define list of positions using the format of ImageMagick - # `-geometry' option argument. - POSITIONS=$(echo "$BRANDING_CONF_VALUE" | cut -d: -f2- | tr ':' ' ') - - # Loop through list of brand image positions and use the - # composite command from ImageMagick, to overlap the unbranded - # image just rendered with the branded version of itself. - for POSITION in $POSITIONS;do - composite -geometry ${POSITION} ${BRANDFILE} ${FILE}.png ${FILE}.png - done - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToDm.sh b/Automation/Modules/Render/Svg/svg_convertPngToDm.sh deleted file mode 100755 index 4ba8b10..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToDm.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToDm.sh -- This function standardize production of -# display managers (e.g., Gdm and Kdm). This function copies all files -# needed into a temporal directory, realize expansion of translation -# markers and packs all the files into a tar.gz package that is used -# for installation. This function must be used as last-rendition -# action for Gdm and Kdm directory specific base-rendition actions. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToDm { - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Initialize source and destination local variables. - local SRC='' - local DST='' - - # Initialize display manager type. - local DM=$(render_getConfigOption "${ACTION}" '2') - - # Initialize screen resolutions used by display manager theme. - # These are the different screen resolutions a display manager - # theme is built for. The amount of screen resolution a display - # manager theme can be built for is limited to the amount of - # background files provided by the artistic motif used to build - # the display manager theme. - local RESOLUTION='' - local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') - - # Verify screen resolutions. We cannot produce display manager - # theme if no screen resolution has been specified. - if [[ "$RESOLUTIONS" == '' ]];then - cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line - fi - - # Initialize theme information we are going to build the display - # manager theme for. - local THEME=$(cli_getPathComponent $ACTIONVAL --motif) - local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name) - - # Initialize temporal directory where we collect all files needed - # in order to create the tar.gz file. This intermediate step is - # also needed in order to expand translation markers from XML and - # Desktop definitions. - local TMPDIR=$(cli_getTemporalFile 'dm') - - # Initialize source location for brands. This is the place where - # brand information, needed to build the display manager theme, is - # retrieved from. - local BRAND_BASEDIR=${TCAR_WORKDIR}/Identity/Images/Brands - - # Initialize source location for artistic motif's backgrounds. - # This is the place where background information needed to ubild - # the display manager theme is retrieved from. - local BGS=${TCAR_WORKDIR}/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png - - # Initialize file variables. File variables are used build and - # process the file relation between source and target locations. - local FILE='' - local FILES='' - - # Define major release from template. - local MAJOR_RELEASE=$(cli_getPathComponent "$TEMPLATE" "--release-major") - - # Define file relation between source and target locations, based - # on whether we are producing GDM or KDM. Use the colon character - # (`:') as separator; on the left side we put the file's source - # location and in the right side the file's target location. - # Presently, both GDM and KDM are very similar on files with the - # exception that GDM does use icons near actions buttons (e.g., - # shutdown, reboot, session, language) and KDM doesn't. - case ${DM} in - - Gdm ) - FILES="\ - ${BRAND_BASEDIR}/Symbols/48/${TCAR_BRAND}.png:${TCAR_BRAND}-symbol.png - ${OUTPUT}/screenshot.png:screenshot.png - $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml - $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop - $(dirname $TEMPLATE)/icon-language.png:icon-language.png - $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png - $(dirname $TEMPLATE)/icon-session.png:icon-session.png - $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png - " - ;; - - Kdm ) - FILES="\ - ${BRAND_BASEDIR}/Symbols/48/${TCAR_BRAND}.png:${TCAR_BRAND}-symbol.png - ${OUTPUT}/screenshot.png:screenshot.png - $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml - $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop - " - ;; - - * ) - cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line - ;; - esac - - for FILE in $FILES;do - - # Define source location. - SRC=$(echo $FILE | cut -d: -f1) - - # Define target location. - DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2) - - # Verify source files. - cli_checkFiles -e $SRC - - # Verify parent directory for target file. - if [[ ! -d $(dirname $DST) ]];then - mkdir -p $(dirname $DST) - fi - - # Copy files from source to target location. - cp ${SRC} ${DST} - - # Expand translation markers. - if [[ ${DST} =~ "\.(xml|desktop)$" ]];then - cli_expandTMarkers "${DST}" - fi - - done - - # Move into temporal directory. - pushd $TMPDIR > /dev/null - - for RESOLUTION in $RESOLUTIONS;do - - # Verify background information. If it doesn't exist go on - # with the next one in the list. - if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then - continue - fi - - # Print action message. - if [[ -f ${RESOLUTION}.tar.gz ]];then - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line - else - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line - fi - - # Copy background information. - cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png - - # Create tar.gz file. - tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME} - - # Move from temporal directory to its final location. - mv ${RESOLUTION}.tar.gz ${OUTPUT} - - done - - # Return to where we were initially. - popd > /dev/null - - # Remove temporal directory. - rm -r ${TMPDIR} - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToGrub.sh b/Automation/Modules/Render/Svg/svg_convertPngToGrub.sh deleted file mode 100755 index 00da4d6..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToGrub.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToGrub.sh -- This function provides post-rendition -# action used to produce GRUB images. -# -# Initially, the color information is defined with GIMP (The GNU Image -# Manipulation Program) as a `.gpl' palette of color. This palette of -# colors contains 14 colors only and is saved in a file named -# `grub.gpl. The `grub.gpl' file is used to build the `grub.ppm' file -# which provide the color information needed to reduce the full color -# PNG image, produced as result of SVG base-rendition, to the amount -# of colors specified (i.e., 14 colors). Later, with the 14 color PNG -# image already created, the `grub.ppm' file is used to build the -# `splash.xpm.gz' file. -# -# In order for this function to work, the `grub.gpl' file should have -# a format similar to the following: -# -# GIMP Palette -# Name: CentOS-TreeFlower-4-Syslinux -# Columns: 14 -# # -# 32 76 141 204c8d -# 36 82 146 245292 -# 52 93 152 345d98 -# 72 108 162 486ca2 -# 102 131 176 6683b0 -# 126 153 190 7e99be -# 146 170 200 92aac8 -# 161 182 209 a1b6d1 -# 182 199 219 b6c7db -# 202 214 228 cad6e4 -# 221 230 238 dde6ee -# 235 241 245 ebf1f5 -# 246 251 254 f6fbfe -# 254 255 252 fefffc -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToGrub { - - # Define number of colors the images will be produced on. - local COLORS='14' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options used already in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo -n $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line - fi - done - - # Define file name prefix. - local PREFIX="-${COLORS}c" - - # Redefine file name prefix using options as reference. This is - # useful to differenciate final files produced using - # Floyd-Steinberg dithering and files which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define logs' file. Log files are stored in the same place of - # images and are used to store output information produced by - # programs when the image files are built up. - local LOGS=${FILE}${PREFIX}.log - - # Define absolute path to GPL palette. This palettes should have - # 14 colors only. For more information on this see the GRUB's - # documentation. - local PALETTE_GPL=${MOTIF_DIR}/Palettes/grub.gpl - - # Verify GPL palette existence. If it doesn't exist copy the one - # provided by the design model through subversion (to keep track - # of the change) and expand translation markers in the copied - # instance. - if [[ ! -f $PALETTE_GPL ]];then - cli_runFnEnvironment vcs --copy ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} - cli_expandTMarkers ${PALETTE_GPL} - fi - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" --as-savedas-line - pngtopnm -verbose \ - < ${FILE}.png 2>${LOGS} > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" --as-palette-line - - # Create PPM palette using GPL palette. - svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.ppm - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - - # Create the 14 colors xpm.gz file. - cli_printMessage "${FILE}${PREFIX}.xpm.gz" --as-savedas-line - ppmtoxpm \ - < ${FILE}${PREFIX}.ppm 2>>${LOGS} > ${FILE}.xpm \ - && gzip --force ${FILE}.xpm \ - && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToIcons.sh b/Automation/Modules/Render/Svg/svg_convertPngToIcons.sh deleted file mode 100755 index 1c4a1af..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToIcons.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToIcons.sh -- This function provides post-rendition -# actions to produce icon images in different sizes and formats from -# the same SVG design model. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToIcons { - - # Define height dimensions you want to produce brands for. - local SIZE="" - local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" - - # Define image formats you want to produce brands for. - local FORMAT="" - local FORMATS="" - - for SIZE in ${SIZES};do - - # Redefine absolute path to file location where size-specific - # images will be stored in. - local FINALFILE=$(dirname $FILE)/${SIZE}/$(basename $FILE) - - # Prepare directory where size-specific images will be stored - # in. If it doesn't exist create it. - if [[ ! -d $(dirname $FINALFILE) ]];then - mkdir -p $(dirname $FINALFILE) - fi - - # Print action message. - cli_printMessage "${FINALFILE}.png" --as-creating-line - - # Create size-specific PNG image ommiting all output. - inkscape $INSTANCE --export-id=$EXPORTID \ - --export-png=${FINALFILE}.png --export-height=${SIZE} \ - &> /dev/null - - #for FORMAT in ${FORMATS};do - # - # # Print action message. - # cli_printMessage "${FINALFILE}.${FORMAT}" --as-creating-line - # - # # Convert size-specific PNG image into different formats. - # convert ${FINALFILE}.png ${FINALFILE}.${FORMAT} - # - #done - - # Create copy of size-specific image in 2 colors. - #cli_printMessage "${FINALFILE}.xbm" --as-creating-line - #convert -colorspace gray -colors 2 ${FINALFILE}.png ${FINALFILE}.xbm - - # Create copy of size-specific image with emboss effect. - #cli_printMessage "${FINALFILE}-emboss.png" --as-creating-line - #convert -emboss 1 ${FINALFILE}.png ${FINALFILE}-emboss.png - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToKsplash.sh b/Automation/Modules/Render/Svg/svg_convertPngToKsplash.sh deleted file mode 100755 index 091245d..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToKsplash.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToKsplash.sh -- This function collects KDE splash -# (KSplash) required files and creates a tar.gz package that groups -# them all together. Use this function as last-rendition action for -# KSplash base-rendition action. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToKsplash { - - local -a SRC - local -a DST - local FONT='' - local COUNT=0 - - # Define font used to print bottom splash message. - FONT=$(svg_getTTFont "DejaVuLGCSans-Bold") - - # Check existence of font file. - cli_checkFiles -e "$FONT" - - # Define absolute source location of files. - SRC[0]="${OUTPUT}/splash_top.png" - SRC[1]="${OUTPUT}/splash_active_bar.png" - SRC[2]="${OUTPUT}/splash_inactive_bar.png" - SRC[3]="${OUTPUT}/splash_bottom.png" - SRC[4]="$(dirname $TEMPLATE)/Theme.rc" - - # Check absolute source location of files. - cli_checkFiles -e "${SRC[@]}" - - # Define relative target location of files. - DST[0]="${OUTPUT}/splash_top.png" - DST[1]="${OUTPUT}/splash_active_bar.png" - DST[2]="${OUTPUT}/splash_inactive_bar.png" - DST[3]="${OUTPUT}/splash_bottom.png" - DST[4]="${OUTPUT}/Theme.rc" - - # Print action message. - cli_printMessage "${OUTPUT}/Preview.png" --as-creating-line - - # Create `Preview.png' image. - convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png - - # Add bottom text to Preview.png image. The text position was set - # inside an image of 400x300 pixels. If you change the final - # preview image dimension, you probably need to change the text - # position too. - mogrify -draw 'text 6,295 "KDE is up and running."' \ - -fill \#ffffff \ - -font $FONT \ - ${OUTPUT}/Preview.png - - # Copy `Theme.rc' file. - cp ${SRC[4]} ${DST[4]} - - # Apply common translation markers to Theme.rc file. - cli_expandTMarkers "${DST[4]}" - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToSyslinux.sh b/Automation/Modules/Render/Svg/svg_convertPngToSyslinux.sh deleted file mode 100755 index d04b0a0..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToSyslinux.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToSyslinux.sh -- This function provides post-rendition -# action used to produce LSS16 images, the images used by isolinux. -# -# Initially, the color information is defined with GIMP (The GNU Image -# Manipulation Program) as a `.gpl' palette of color. This palette of -# colors contains 16 colors only and is saved in a file named -# `syslinux.gpl. The `syslinux.gpl' file is used to build two other -# files: the `syslinux.ppm' file and the `syslinux.hex' file. The -# `syslinux.ppm' provides the color information needed to reduce the -# full color PNG image, produced as result of SVG base-rendition, to -# the amount of colors specified (i.e., 16 colors). Later, with the 16 -# color PNG image already created, the `syslinux.hex' file is used to -# build the LSS16 image. -# -# In order to produce images in LSS16 format correctly, it is required -# that both the `syslinux.ppm' and `syslinux.hex' files do contain the -# same color information. This is, both `syslinux.ppm' and -# `syslinux.hex' must represent the same color values and in the same -# color index. -# -# In order for this function to work, the `syslinux.gpl' file should -# have a format similar to the following: -# -# GIMP Palette -# Name: CentOS-TreeFlower-4-Syslinux -# Columns: 16 -# # -# 32 76 141 204c8d -# 37 82 146 255292 -# 52 94 153 345e99 -# 73 110 162 496ea2 -# 91 124 172 5b7cac -# 108 136 180 6c88b4 -# 120 146 186 7892ba -# 131 158 193 839ec1 -# 255 255 255 ffffff -# 146 170 200 92aac8 -# 162 182 209 a2b6d1 -# 183 199 219 b7c7db -# 204 216 230 ccd8e6 -# 221 229 238 dde5ee -# 235 241 245 ebf1f5 -# 246 251 254 f6fbfe -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToSyslinux { - - # Define number of colors the images will be produced on. - local COLORS='16' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options already used in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line - fi - done - - # Define default file name prefix for 16 colors images. - local PREFIX="-${COLORS}c" - - # Re-define 16 colors images default file name prefix using - # options as reference. This is useful to differenciate final - # files produced using Floyd-Steinberg dithering and final files - # which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define logs' file. Log files are stored in the same place of - # images and are used to store output information produced by - # programs when the image files are built up. - local LOGS=${FILE}${PREFIX}.log - - # Define absolute path to GPL palette. The GPL palette defines the - # color information used to build syslinux images. This palette - # should be set to 16 colors and, as specified in isolinux - # documentation, the background color should be indexed on - # position 0 and the forground in position 7 (see - # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more - # information.) - local PALETTE_GPL=${MOTIF_DIR}/Palettes/syslinux.gpl - - # Verify GPL palette existence. If it doesn't exist copy the one - # provided by the design model through subversion (to keep track - # of the change) and expand translation markers in the copied - # instance. - if [[ ! -f $PALETTE_GPL ]];then - cli_runFnEnvironment vcs --copy ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/syslinux.gpl ${PALETTE_GPL} - cli_expandTMarkers ${PALETTE_GPL} - fi - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") - - # Define the HEX palette. The HEX palette is built from source - # palette (PALETTE_GPL) and provides the color information in the - # format understood by `ppmtolss16', the program used to produce - # images in LSS16 format. The HEX palette stores just one line - # with the color information as described in isolinux - # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the - # same line]) - local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" --as-savedas-line - pngtopnm -verbose \ - < ${FILE}.png 2>${LOGS} > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" --as-palette-line - - # Create PPM palette using GPL palette. - svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" - - # Create HEX palette using GPL palette. - svg_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLORS" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.pnm" --as-savedas-line - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>> ${LOGS} > ${FILE}${PREFIX}.pnm - - # Create LSS16 image. - cli_printMessage "${FILE}${PREFIX}.lss" --as-savedas-line - ppmtolss16 $(cat $PALETTE_HEX) \ - < ${FILE}${PREFIX}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.lss - - # Remove HEX palette. It is no longer needed. - if [[ -f ${PALETTE_HEX} ]];then - rm $PALETTE_HEX - fi - - # Create PPM image indexed to 16 colors. Also the colormap used in - # the LSS16 image is saved on ${FILE}.log; this is useful to - # verify the correct order of colors in the image index. - cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line - lss16toppm -map \ - < ${FILE}${PREFIX}.lss 2>>${LOGS} > ${FILE}${PREFIX}.ppm - - # Create PNG image indexed to 16 colors. - cli_printMessage "${FILE}${PREFIX}.png" --as-savedas-line - pnmtopng -verbose \ - < ${FILE}${PREFIX}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.png - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - -} diff --git a/Automation/Modules/Render/Svg/svg_convertPngToThumbnail.sh b/Automation/Modules/Render/Svg/svg_convertPngToThumbnail.sh deleted file mode 100755 index 52dcf3b..0000000 --- a/Automation/Modules/Render/Svg/svg_convertPngToThumbnail.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToThumbnail.sh -- This function provides -# post-rendition to create thumbnails from images produced by -# centos-art base-rendition. Thumbnails are created in PNG and JPG -# format for you to decide which is the more appropriate one. When no -# size is specified, thumbnails are created at 250 pixels width and -# height is automatically calculated to match the image ratio. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_convertPngToThumbnail { - - # Get image size. - local SIZE='' - local SIZES=$(render_getConfigOption "$ACTION" '2-') - - # Check image sizes and do convertion. - if [[ "$SIZES" == "" ]];then - SIZES='250' - fi - - # Check base file existence. - cli_checkFiles -e "${FILE}.png" - - # Create thumbnails. - for SIZE in $SIZES;do - cli_printMessage "${FILE}-thumb-${SIZE}.png" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}.png ${FILE}-thumb-${SIZE}.png - cli_printMessage "${FILE}-thumb-${SIZE}.jpg" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.jpg - cli_printMessage "${FILE}-thumb-${SIZE}.pdf" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.pdf - done - -} diff --git a/Automation/Modules/Render/Svg/svg_doLastActions.sh b/Automation/Modules/Render/Svg/svg_doLastActions.sh deleted file mode 100755 index 5562eeb..0000000 --- a/Automation/Modules/Render/Svg/svg_doLastActions.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# svg_doLastActions.sh -- This function performs last-rendition -# actions for SVG files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_doLastActions { - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then - return - fi - - local ACTION='' - - # Redefine SVG last-rendition actions as local to avoid undesired - # concatenation when massive rendition is performed. - local -a LASTACTIONS - - # Define SVG directory-specific actions. This is required in order - # to provide a predictable way of producing content inside the - # repository and save you the time of writing long several - # commands each time you need to produce images inside the - # repository. - if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then - if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Gdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToKsplash:' - fi - fi - - # Define SVG last-rendition actions. Since last-rendition makes - # use of all files in the output directory structure and - # directory-specific rendition modifies all the files in the - # output directory structure as well, these actions must be - # defined after the directory-specific definition. Otherwise, - # modifications impossed by these actions may interfier the whole - # purpose of having a directory-specific rendition. - [[ $FLAG_LASTRENDITION != '' ]] && LASTACTIONS[((++${#LASTACTIONS[*]}))]="doLastActions:(png|jpg):${FLAG_LASTRENDITION}" - - # At this point centos-art.sh should be producing the last file - # from the same unique directory structure, so, before producing - # images for the next directory structure lets execute the list of - # last-rendition actions for the current directory structure. - for ACTION in "${LASTACTIONS[@]}"; do - svg_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Automation/Modules/Render/Svg/svg_doLastCommand.sh b/Automation/Modules/Render/Svg/svg_doLastCommand.sh deleted file mode 100755 index 458ec6b..0000000 --- a/Automation/Modules/Render/Svg/svg_doLastCommand.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# svg_doLastCommand.sh -- This function standardizes the way -# last-rendition commands are applied to base-rendition and -# post-rendition outputs. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_doLastCommand { - - # Define the file extensions. This value is a regular expression - # pattern which must match the file extensions that last-rendition - # actions will be applied to. - local EXTENSION=$(render_getConfigOption "$ACTION" '2') - - # Define the command string that will be evaluated as - # last-rendition action. Only commands that perform in-place - # modifications can be passed here. - local COMMAND=$(render_getConfigOption "$ACTION" '3-') - - # Define the list of files to process. This value contain all the - # files in the output directory which extension match the - # extension pattern previously defined. - local FILE='' - local FILES=$(cli_getFilesList $OUTPUT --pattern="^.+\.${EXTENSION}$") - - for FILE in $FILES;do - - # Identify file before processing it. Only formats recognized - # by ImageMagick are supported. In case the file isn't - # supported by ImageMagick, continue with the next file in the - # list. - identify -quiet ${FILE} > /dev/null - if [[ $? -ne 0 ]];then - continue - fi - - # Print action message. - cli_printMessage "${FILE}" --as-updating-line - - # Execute mogrify action on all files inside the same - # directory structure. - eval ${COMMAND} ${FILE} - - # Be sure the command was executed correctly. Otherwise stop - # script execution. - if [[ $? -ne 0 ]];then - exit - fi - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_doPostActions.sh b/Automation/Modules/Render/Svg/svg_doPostActions.sh deleted file mode 100755 index 86b998e..0000000 --- a/Automation/Modules/Render/Svg/svg_doPostActions.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# -# svg_doPostActions.sh -- This function performs post-rendition -# actions for SVG files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_doPostActions { - - local ACTION='' - - # Redefine SVG post-rendition actions as local to avoid undesired - # concatenation when massive rendition is performed. - local -a POSTACTIONS - - # Define default comment written to base-rendition output. - local COMMENT="`gettext "Created in CentOS Artwork Repository"` ($(cli_printUrl '--svn')artwork/)" - - # Define SVG post-rendition actions. Since these actions are - # applied to base-rendition output and base-rendition output is - # used as reference to perform directory-specific rendition, these - # action must be defined before directory-specific rendition. - # Otherwise it wouldn't be possible to propagate changes imposed - # by these actions to new files produced as result of - # directory-specific rendition. - POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:mogrify -comment '$COMMENT'" - [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:${FLAG_POSTRENDITION}" - - # Define SVG directory-specific rendition. Directory-specfic - # rendition provides a predictable way of producing content inside - # the repository. - if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then - - if [[ $TEMPLATE =~ "Identity/(Models|Images)/Themes/.+\.${RENDER_EXTENSION}$" ]];then - - POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngToBranded" - - if [[ $TEMPLATE =~ "Backgrounds/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupBy:png jpg' - - elif [[ $TEMPLATE =~ "Concept/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToThumbnail:250' - - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:-floyd' - - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:-floyd' - - elif [[ $TEMPLATE =~ "Posters/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - fi - - elif [[ $TEMPLATE =~ "Identity/Models/Icons/.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToIcons' - - elif [[ $TEMPLATE =~ "Identity/Models/Manuals.+\.${RENDER_EXTENSION}$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - - fi - - fi - - # Execute SVG post-rendition actions. - for ACTION in "${POSTACTIONS[@]}"; do - svg_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Automation/Modules/Render/Svg/svg_doPostCommand.sh b/Automation/Modules/Render/Svg/svg_doPostCommand.sh deleted file mode 100755 index 42c7738..0000000 --- a/Automation/Modules/Render/Svg/svg_doPostCommand.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# svg_doPostCommand.sh -- This function standardizes the way -# post-rendition commands are applied to base-rendition output. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_doPostCommand { - - # Define the file extension of base-rendition output. - local EXTENSION=$(render_getConfigOption "$ACTION" '2') - - # Define the command string. - local COMMAND=$(render_getConfigOption "$ACTION" '3-') - - # Verify the absolute path of base-rendition output. - cli_checkFiles -e ${FILE}.${EXTENSION} - - # Execute the command string on base-rendition output. - eval $COMMAND ${FILE}.${EXTENSION} - - # Be sure the command string was executed correctly. Otherwise - # stop the script execution. - if [[ $? -ne 0 ]];then - exit - fi - -} diff --git a/Automation/Modules/Render/Svg/svg_doTranslation.sh b/Automation/Modules/Render/Svg/svg_doTranslation.sh deleted file mode 100755 index 2dc359e..0000000 --- a/Automation/Modules/Render/Svg/svg_doTranslation.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# -# svg_doTranslation.sh -- This function standardizes the way -# translation files are applied to SVG design models in order to -# produce the translated instance that is used to expand translation -# markers and produce PNG output in different languages. -# -# Assuming no translation file exists, an untranslated instace is -# taken from the design model and created (i.e., just a copy) from it. -# Using a design model instance (translated or not) is required in -# order to expand translation markers safetly. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_doTranslation { - - # Define which command will be used to output the template - # content. This is required because template files might be found - # as compressed files inside the repository. - local COMMAND="/bin/cat" - if [[ $(file -b -i $TEMPLATE) =~ '^application/x-gzip$' ]];then - COMMAND="/bin/zcat" - fi - - # Move into template's directory in order to satisfy relative - # entities. Take care that some XML documents (e.g., DocBook - # documents) can use entities relatively from their base - # locations. In order to process such documents, it is necessary - # to put the template directory up in the directory stack and - # create the instance from there. Thus, it is possible to expand - # relative entities correctly when validating the document. - pushd $(dirname $TEMPLATE) > /dev/null - - # Verify translation file existence and create template - # instance accordingly. - if [[ -f ${TRANSLATION} ]];then - - # Print final location of translation file. - cli_printMessage "${TRANSLATION}" --as-translation-line - - # Create translation instance to combine both template - # translation and licenses translations. - local TRANSLATION_INSTANCE=${TMPDIR}/message.po - - # In the case of SVG and other files, license translations is - # not required so we don't combine it into the template - # translation. - cp ${TRANSLATION} ${TRANSLATION_INSTANCE} - - # Create the translated instance of design model. - ${COMMAND} ${TEMPLATE} | xml2po -a -l ${CLI_LANG_LL} \ - -p ${TRANSLATION_INSTANCE} -o ${INSTANCE} - - - # Remove .xml2po.mo temporal file. - if [[ -f ${PWD}/.xml2po.mo ]];then - rm ${PWD}/.xml2po.mo - fi - - # Remove instance created to store both licenses and template - # translations. - if [[ -f ${TRANSLATION_INSTANCE} ]];then - rm ${TRANSLATION_INSTANCE} - fi - - else - - # Create the non-translated instance of design model. - ${COMMAND} ${TEMPLATE} > ${INSTANCE} - - fi - - # Return to where we were. - popd > /dev/null - - # Verify instance existence. - cli_checkFiles -e $INSTANCE - -} diff --git a/Automation/Modules/Render/Svg/svg_getColors.sh b/Automation/Modules/Render/Svg/svg_getColors.sh deleted file mode 100755 index 2b4ccd9..0000000 --- a/Automation/Modules/Render/Svg/svg_getColors.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash -# -# svg_getColors.sh -- This function takes one palette produced by Gimp -# (e.g., syslinux.gpl) as input and outputs a list of colors in the -# specified format. In order for this function to output the color in -# the format specified, it is needed that the fourth column in the gpl -# palette be set in the `rrggbb' format and the appropriate conversion -# be implemented here. -# -# Notice that using both the `--head' and `--tail' options it is -# possible to control how many consecutive items does the list of -# colors is going to have. It is possible to output all colors in the -# list, or a consecutive range of them. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_getColors { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='head:,tail:,format:' - - # Initialize both head and tail values to return the first line of - # color information from the palette. - local HEAD=1 - local TAIL=1 - - # Initialize format value used as default when no format option be - # provided. - local FORMAT='rrggbb' - - # Initialize list of colors. - local COLORS='' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS variable for getopt. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - --head ) - HEAD=$2 - shift 2 - ;; - - --tail ) - TAIL=$2 - shift 2 - ;; - - --format ) - FORMAT=$2 - shift 2 - ;; - - -- ) - shift 1 - break - ;; - esac - done - - # Define path to gpl palette. This is the first file we use to - # retrieve color information from. Only the first file provided - # will be used. - local PALETTE=$(echo $@ | cut -d' ' -f1) - - if [[ ! -f $PALETTE ]];then - - # Define palette path inside the theme's artistic motif. - local MOTIF_PALETTE=${TCAR_WORKDIR}/Identity/Images/Themes/$(cli_getPathComponent $ACTIONVAL --motif)/Palettes/grub.gpl - - # Define palette path inside the theme's design model. - local MODEL_PALETTE=${TCAR_WORKDIR}/Identity/Models/Themes/${THEME_MODEL_NAME}/Palettes/grub.gpl - - # Redefine default background color using palettes provided by - # artistic motif first, and design model later. Assuming none - # of them is present, use The CentOS Project default color - # then. - if [[ -f $MOTIF_PALETTE ]];then - COLORS=$(svg_getColors $MOTIF_PALETTE --head=1 --tail=1) - elif [[ -f $MODEL_PALETTE ]];then - COLORS=$(svg_getColors $MODEL_PALETTE --head=1 --tail=1) - else - COLORS='#204c8d' - fi - - else - - # Retrieve the fourth column from GPL palette. The fourth - # column of a GPL palette contains the palette commentary - # field. The palette commentary field can be anything, but for - # the sake of our own convenience we use it to store the color - # value in hexadecimal format (e.g., rrggbb). Notice that you - # can put your comments from the fifth column on using an - # space as field separator. - COLORS=$(sed -r '1,/^#/d' $PALETTE \ - | awk '{ printf "%s\n", $4 }' | head -n $HEAD | tail -n $TAIL) - - fi - - # Implement color formats conversions from rrggbb to other formats - # that you might need to use. - for COLOR in $COLORS;do - - case $FORMAT in - - rrggbb|* ) - if [[ ! $COLOR =~ '^#' ]];then - COLOR="#${COLOR}" - fi - ;; - - esac - - # Output color value. - echo "$COLOR" - - done - -} diff --git a/Automation/Modules/Render/Svg/svg_getTTFont.sh b/Automation/Modules/Render/Svg/svg_getTTFont.sh deleted file mode 100755 index 78b6050..0000000 --- a/Automation/Modules/Render/Svg/svg_getTTFont.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# cli_getFont.sh -- This function creates a list of all True Type -# Fonts (TTF) installed in your workstation and returns the absolute -# path of the file matching the pattern passed as first argument. -# Assuming more than one value matches, the first one in the list is -# used. In case no match is found, the function verifies if there is -# any file in the list that can be used (giving preference to sans -# files). If no file is found at this point, an error will be printed -# out. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_getTTFont { - - local -a FONT_PATTERNS - local FONT_PATTERN='' - local FONT_FILE='' - - # Define list of patterns used to build the list of TTF files. - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="/${1}\.ttf$" - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="sans\.ttf$" - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="\.ttf$" - - # Define directory location where fonts are installed in your - # workstation. - local FONT_DIR='/usr/share/fonts' - - # Define list of all TTF files installed in your workstation. - local FONT_FILES=$(cli_getFilesList ${FONT_DIR} --pattern="^.+\.ttf$") - - # Define TTF absolute path based on pattern. Notice that if the - # pattern matches more than one value, only the first one of a - # sorted list will be used. - for FONT_PATTERN in ${FONT_PATTERNS[@]};do - - FONT_FILE=$(echo "$FONT_FILES" | egrep ${FONT_PATTERN} \ - | head -n 1) - - if [[ -f $FONT_FILE ]];then - break - fi - - done - - # Output TTF absolute path. - if [[ -f $FONT_FILE ]];then - echo $FONT_FILE - else - cli_printMessage "`gettext "The font provided doesn't exist."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Render/Svg/svg_groupBy.sh b/Automation/Modules/Render/Svg/svg_groupBy.sh deleted file mode 100755 index 25d334c..0000000 --- a/Automation/Modules/Render/Svg/svg_groupBy.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# svg_groupBy.sh -- This function provides post-rendition action to -# group files inside directories named as their file extensions. For -# example: if the current file is a .png file, it is moved inside a -# Png/ directory; if the current file is a .jpg file, it is stored -# inside a Jpg/ directory, and so on. -# -# For this function to work correctly, you need to specify which file -# type you want to group. This is done in the post-rendition ACTIONS -# array inside the appropriate `render.conf.sh' pre-configuration -# script. This function cannot be used as last-rendition action. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_groupBy { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMAT='' - local FORMATS=$(render_getConfigOption "$ACTION" '2-') - - for FORMAT in $FORMATS;do - - # Redifine source file we want to move. - SOURCE=${FILE}.${FORMAT} - - # Define target directory where source file will be moved - # into. - TARGET=$(dirname "$FILE")/$(cli_getRepoName $FORMAT -d) - - # Check existence of source file. - cli_checkFiles -e $SOURCE - - # Check existence of target directory. - if [[ ! -d $TARGET ]];then - mkdir -p $TARGET - fi - - # Redifine file path to add file and its type. - TARGET=${TARGET}/$(cli_getRepoName $FILE -f).${FORMAT} - - # Move file into its final location. - cli_printMessage "$TARGET" --as-movedto-line - mv ${SOURCE} ${TARGET} - - done - -} diff --git a/Automation/Modules/Render/render_getConfigOption.sh b/Automation/Modules/Render/render_getConfigOption.sh deleted file mode 100755 index dbf1937..0000000 --- a/Automation/Modules/Render/render_getConfigOption.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# render_getConfigOption.sh -- This function standardizes the -# configuration fields are retrived from some action-specific -# definitions. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getConfigOption { - - # Initialize action string. - local ACTION="$1" - - # Initialize field definition. - local FIELD="$2" - - # Initialize configuration options. - local OPTION='' - - # Check action string. The action string must be present in order - # for this function to work. It provides the information needed to - # retrive configurantion options from. - if [[ "$ACTION" == '' ]];then - cli_printMessage "`gettext "There is no action string to work with."`" --as-error-line - fi - - # Check field definition. The field definition must match any of - # the formats specified by the `-f' option of `cut' command. - if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then - cli_printMessage "`gettext "The field definition is not valid."`" --as-error-line - fi - - # Get configuration option from action string. - OPTION=$(echo -n "$ACTION" | cut -d: -f${FIELD}) - - # Sanitate configuration option retrived from action string. - OPTION=$(echo -n "${OPTION}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |,|;) *! !g' \ - | sed -r 's! *$!!g') - - # Print out the configuration option retrived from action string, - # only if it is not an empty value. Do not use `echo' or `printf' - # built-in commands here. Use the `cli_printMessage' functionality - # instead. This is required in order to reverse the apostrophe - # codification accomplished when options were retrived from - # command-line (cli_parseArgumentsReDef) in the argument of - # options like `--post-rendition' and `--last-rendition'. - if [[ $OPTION != '' ]];then - cli_printMessage "$OPTION" --as-stdout-line - fi - -} diff --git a/Automation/Modules/Render/render_getDirOutput.sh b/Automation/Modules/Render/render_getDirOutput.sh deleted file mode 100755 index ffc475e..0000000 --- a/Automation/Modules/Render/render_getDirOutput.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# -# render_getDirOutput.sh -- This function defines the final -# absolute path the centos-art.sh script uses to store identity -# contents produced at rendition time. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getDirOutput { - - # Define base output directory using design model path as - # reference. - OUTPUT=$(dirname $FILE | sed -r \ - -e "s!Identity/Models!Identity/Images!" \ - -e "s!Themes/${FLAG_THEME_MODEL}!Themes/$(cli_getPathComponent $ACTIONVAL --motif)!" \ - -e "s!Documentation/Models!Documentation/Manuals!" \ - -e "s!/Models!!") - - # By default, images rendered are stored under Identity/Images - # directory structure. But if an `Images/' directory exists in the - # current location use it instead. - if [[ -d "${OUTPUT}/Images" ]];then - OUTPUT=${OUTPUT}/Images - fi - - # Redefine base output directory to introduce specific information - # like release number and architecture. This information is - # require by directories (e.g., the `Media' directory inside - # themes and the `Documentation/Manuals/Docbook/Distro' directory - # ) whose need this information to be passed explicitly at the - # command-line through the `--releasever' and `--basearch' - # options. Other directories take such information from the path - # they are stored in (e.g., the `Distro/5/Anaconda' directory - # inside themes.). So, we need to differentiate the way - # information like release numbers and architectures are retrieved - # in order to build the output path correctly at rendition time. - if [[ $OUTPUT =~ "^${MOTIF_DIR}/Media$" ]];then - OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH} - elif [[ $OUTPUT =~ 'Documentation/Manuals/Docbook/Distro$' ]];then - OUTPUT=${OUTPUT}/${FLAG_RELEASEVER} - else - OUTPUT=${OUTPUT} - fi - - # Define whether to use or not locale-specific directory to store - # content, using current locale information as reference. As - # convection, when we produce content, only specific locations - # use locale-specific directories to organize language-specific - # content (e.g., Manuals, Anaconda, Installation media, etc.). All - # other locations do not use locale-specific directories to - # organize content. This convection is important in order for - # the `prepare' functionality of centos-art.sh script to produce - # content in the correct location. Otherwise, we might end up - # duplicating content (e.g., icons, brands, etc.) which doesn't - # have any translation, nor any need to be translated. - if [[ ! ${CLI_LANG_LC} =~ '^en' ]];then - OUTPUT=${OUTPUT}/${CLI_LANG_LC} - fi - - # Create final output directory, if it doesn't exist yet. - if [[ ! -d ${OUTPUT} ]];then - mkdir -p ${OUTPUT} - fi - -} diff --git a/Automation/Modules/Render/render_getDirTemplate.sh b/Automation/Modules/Render/render_getDirTemplate.sh deleted file mode 100755 index 9c6058a..0000000 --- a/Automation/Modules/Render/render_getDirTemplate.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# render_getDirTemplate.sh -- This function defines the way renderable -# directories are processed inside the repository. Inside the -# repository, renderable directories are processed either through -# direct or theme-specific rendition. -# -# Direct rendition takes one XML file from design model -# (`Identity/Models') directory structure and produces one file -# in `Identity/Images' directory strucutre. In this -# configuration, the organization used to stored the design model is -# taken as reference to build the path required to store the image -# related to it under `Identity/Images' directory structure. -# -# Theme-specific rendition takes one design model from -# `Identity/Models/Themes' directory structure to produce one or -# more images in `Identity/Images/Themes/$THEME/$VERSION/$MODEL' -# directory structure. In this configuration we have many different -# artistic motifs that use one unique design model directory structure -# as reference to produce images. -# -# Since theme design models are unified to be reused by more -# than one artistic motif, it is not possible to render artistic -# motifs in a lineal manner (i.e., as we do with direct rendition) -# because we need to establish the relation between the artistic motif -# renderable directory structure and the design model first and that -# relation happens when renderable directory structures inside -# artistic motifs are processed individually. -# -# In the first rendition category, we use a design model directory -# structure as reference to produce images one by one. In the second -# rendition category, we can't use the same procedure because one -# design model directory structure is used to produce several -# renderable directory structures, not just one. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getDirTemplate { - - # Initialize design models location used as reference to process - # renderable directory structures. - TEMPLATE=$ACTIONVAL - - # Define absolute path to input files using absolute path from - # output files. - if [[ -d ${TEMPLATE}/Models ]];then - TEMPLATE=${TEMPLATE}/Models - else - TEMPLATE=$(echo "$TEMPLATE" | sed -r \ - -e "s!/Themes/$(cli_getPathComponent $ACTIONVAL --motif)!/Themes/${FLAG_THEME_MODEL}!" \ - -e "s!/(Manuals|Images)!/Models!") - fi - - # Verify absolute path to input file. This verification is - # specially needed in those situations when the artistic motif - # directory structure has an organization different to that in - # design models directory structure. Since the path to design - # models is built from artistic motif directory structure, if - # artistic motifs directory structure is different from design - # model directory structure, as result we'll have a path to a - # design model that may not exist and that would make - # centos-art.sh script to fail. So, verify the absolute path to - # the input file and stop script execution if it doesn't exist. - cli_checkFiles -e $TEMPLATE - -} diff --git a/Automation/Modules/Render/render_getOptions.sh b/Automation/Modules/Render/render_getOptions.sh deleted file mode 100755 index 6598f99..0000000 --- a/Automation/Modules/Render/render_getOptions.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# -# render_getOptions.sh -- This function interprets option parameters -# passed to `render' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getOptions { - - # Define short options we want to support. - local ARGSS="h,q" - - # Define long options we want to support. - local ARGSL="help,quiet,filter:,answer-yes,dont-dirspecific,releasever:,basearch:,post-rendition:,last-rendition:,theme-model:,with-brands,synchronize" - - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - -h | --help ) - cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-render" - shift 1 - exit - ;; - - -q | --quiet ) - FLAG_QUIET="true" - shift 1 - ;; - - --filter ) - FLAG_FILTER="$2" - shift 2 - ;; - - --answer-yes ) - FLAG_ANSWER="true" - shift 1 - ;; - - --dont-dirspecific ) - FLAG_DONT_DIRSPECIFIC="true" - shift 1 - ;; - - --post-rendition ) - FLAG_POSTRENDITION="$2" - shift 2 - ;; - - --last-rendition ) - FLAG_LASTRENDITION="$2" - shift 2 - ;; - - --basearch ) - FLAG_BASEARCH="$2" - if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent --architecture-pattern) ]];then - cli_printMessage "`gettext "The architecture provided is not supported."`" --as-error-line - fi - shift 2 - ;; - - --releasever ) - FLAG_RELEASEVER="$2" - if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent --release-pattern) ]];then - cli_printMessage "`gettext "The release version provided is not supported."`" --as-error-line - fi - shift 2 - ;; - - --theme-model ) - FLAG_THEME_MODEL=$(cli_getRepoName $2 -d) - shift 2 - ;; - - --with-brands ) - FLAG_WITH_BRANDS='true' - shift 1 - ;; - - --synchronize ) - FLAG_SYNCHRONIZE='true' - shift 1 - ;; - - -- ) - # Remove the `--' argument from the list of arguments - # in order for processing non-option arguments - # correctly. At this point all option arguments have - # been processed already but the `--' argument still - # remains to mark ending of option arguments and - # beginning of non-option arguments. The `--' argument - # needs to be removed here in order to avoid - # centos-art.sh script to process it as a path inside - # the repository, which obviously is not. - shift 1 - break - ;; - esac - done - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - -} diff --git a/Automation/Modules/Render/render_setBaseRendition.sh b/Automation/Modules/Render/render_setBaseRendition.sh deleted file mode 100755 index 8591dec..0000000 --- a/Automation/Modules/Render/render_setBaseRendition.sh +++ /dev/null @@ -1,276 +0,0 @@ -#!/bin/bash -# -# render_setBaseRendition.sh -- This function performs base-rendition -# action for all files. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_setBaseRendition { - - local -a FILES - local FILE='' - local OUTPUT='' - local TEMPLATE='' - local TEMPLATES='' - local PARENTDIR='' - local TRANSLATION='' - local EXTERNALFILE='' - local EXTERNALFILES='' - local THIS_FILE_DIR='' - local NEXT_FILE_DIR='' - local RENDER_EXTENSION='' - local EXPORTID='' - local COUNT=0 - - # Verify default directory where design models are stored in. - cli_checkFiles -e "${TCAR_WORKDIR}/Identity/Models/Themes/${FLAG_THEME_MODEL}" - - # Redefine parent directory for current workplace. - PARENTDIR=$(basename "${ACTIONVAL}") - - # Loop through list of supported file extensions. - for RENDER_EXTENSION in ${RENDER_EXTENSIONS};do - - # Redefine rendition format name based on supported file - # extension. - if [[ $RENDER_EXTENSION =~ '^(svgz|svg)$' ]];then - RENDER_FORMAT='svg' - elif [[ $RENDER_EXTENSION =~ '^(docbook)$' ]];then - RENDER_FORMAT='docbook' - elif [[ $RENDER_EXTENSION =~ '^(conf)$' ]];then - RENDER_FORMAT='conf' - else - cli_printMessage "`eval_gettext "The \\\"\\\$RENDER_EXTENSION\\\" file extension is not supported yet."`" --as-error-line - fi - - # Redefine specific function export id. - EXPORTID="${CLI_FUNCDIRNAM}/$(cli_getRepoName ${RENDER_FORMAT} -d)/$(cli_getRepoName ${RENDER_FORMAT} -f)" - - # Define base location of template files using paths passed to - # centos-art.sh script as argument to. - render_getDirTemplate - - # Verify whether or not the source location of the path - # provided as argument to centos-art.sh script accepts or not - # localization messages. Don't produce localized content for - # repository components that don't accept it. - if [[ ! ${CLI_LANG_LC} =~ '^en' ]];then - cli_runFnEnvironment locale --is-localizable ${TEMPLATE} - fi - - # Define the list of files to process. Use an array variable - # to store the list of files to process. This make possible to - # realize verifications like: is the current base directory - # equal to the next one in the list of files to process? - # Questions like this let us to know when centos-art.sh is - # leaving a directory structure and entering another. This - # information is required in order for centos-art.sh to know - # when to apply last-rendition actions. - # - # Another issue is that some directories might be named as if - # they were files (e.g., using a render able extension like - # .docbook). In these situations we need to avoid such - # directories from being interpreted as a render able file. - # For this, pass the `--type="f"' option when building the - # list of files to process in order to retrieve regular files - # only. - # - # Another issue to consider here is that, in some cases, both - # templates and outputs might be in the same location. In - # these cases localized content are stored in the same - # location where template files are retrieved from and we need - # to avoid using localized content from being interpreted as - # design models. In that sake, build the list of files to - # process using the files directly stored in the directory - # passed as argument to centos-art.sh command-line. Don't go - # recursively here. - # - # Another issue to consider here, is the way of restricting - # the list of files to process. We cannot expand the pattern - # specified by FLAG_FILTER with a `.*' here (e.g., - # "${FLAG_FILTER}.*\.${RENDER_EXTENSION}") because that would - # suppress any possibility from the user to specify just one - # file name in locations where more than one file with the - # same name as prefix exists (e.g., `repository.docbook', - # `repository-preamble.docbook' and - # `repository-parts.docbook'). Instead, pass filtering - # control to the user whom can use regular expression markup - # in the `--filter' option to decide whether to match - # `repository.docbook' only (e.g., through - # `--filter="repository"') or `repository-preamble.docbook' - # and `repository-parts.docbook' but not `repository.docbook' - # (e.g., through `--filter="repository-.*"'). - if [[ ${RENDER_FORMAT} =~ "^docbook$" ]];then - - # When the render format is docbook, don't build a list of - # files to process. Instead, build the absolute path of - # the main file used to render docbook from models to - # final output manuals. This file must be stored directly - # inside the main manual's directory and named as it but - # with all letters in lowercase. - for FILE in $(cli_getFilesList ${TEMPLATE} \ - --maxdepth="1" --mindepth="1" \ - --pattern="^.*$(cli_getRepoName ${TEMPLATE} -f)\.${RENDER_EXTENSION}$" \ - --type="f");do - FILES[((++${#FILES[*]}))]=$FILE - done - - elif [[ ${RENDER_FORMAT} =~ "^conf$" ]];then - - # When the render format is conf, be sure it refers to - # image.conf files only. Other configuration files (e.g., - # branding.conf) cannot be processed this way because - # their configuration options and values haven't any - # meaning in this context. - for FILE in $(cli_getFilesList ${TEMPLATE} \ - --pattern="^.+/images\.${RENDER_EXTENSION}$" \ - --type="f");do - FILES[((++${#FILES[*]}))]=$FILE - done - - else - - # For all other cases, build a list of files to process - # using the path value pass as argument. - for FILE in $(cli_getFilesList ${TEMPLATE} \ - --pattern="^.+/${FLAG_FILTER}.*\.${RENDER_EXTENSION}$" \ - --type="f");do - FILES[((++${#FILES[*]}))]=$FILE - done - - fi - - # Verify list of files to process. Assuming no file was found, - # evaluate the next supported file extension. - if [[ ${#FILES[*]} -eq 0 ]];then - continue - fi - - # Initialize format-specific functionalities. - cli_exportFunctions "${EXPORTID}" - - # Start processing the base rendition list of FILES. Fun part - # approaching :-). - while [[ $COUNT -lt ${#FILES[*]} ]];do - - # Define base file. - FILE=${FILES[$COUNT]} - - # Define the base directory path for the current file being - # process. - THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) - - # Define the base directory path for the next file that will - # be process. - if [[ $(($COUNT + 1)) -lt ${#FILES[*]} ]];then - NEXT_FILE_DIR=$(dirname ${FILES[$(($COUNT + 1))]}) - else - NEXT_FILE_DIR='' - fi - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Print action message based on file extension. - if [[ ${FILE} =~ 'images\.conf$' ]] && [[ $FLAG_WITH_BRANDS == 'true' ]];then - cli_printMessage "${FILE}" --as-processing-line - elif [[ ${FILE} =~ 'brands\.conf$' ]];then - continue - else - cli_printMessage "${FILE}" --as-template-line - fi - - # Verify design models file existence. We cannot continue - # with out it. - cli_checkFiles ${FILE} -f - - # Define final location of translation file. - TRANSLATION=$(dirname ${FILE} \ - | sed -r 's!(Documentation|Identity)!Locales/\1!')/${CLI_LANG_LC}/messages.po - - # Define final location of template file. - TEMPLATE=${FILE} - - # Define final location of output directory. - render_getDirOutput - - # Get relative path to file. The path string (stored in - # FILE) has two parts: 1. the variable path and 2. the - # common path. The variable path is before the common - # point in the path string. The common path is after the - # common point in the path string. The common point is the - # name of the parent directory (stored in PARENTDIR). - # - # Identity/Models/Themes/.../Firstboot/3/splash-small.svg - # -------------------------^| the |^------------^ - # variable path | common | common path - # -------------------------v| point | v------------v - # Identity/Images/Themes/.../Firstboot/Img/3/splash-small.png - # - # What we do here is remove the variable path, the common - # point, and the file extension parts in the string - # holding the path retrieved from design models directory - # structure. Then we use the common path as relative path - # to store the final image file. - # - # The file extension is removed from the common path - # because it is set when we create the final image file. - # This configuration let us use different extensions for - # the same file name. - # - # When we render using base-rendition action, the - # structure of files under the output directory will be - # the same used after the common point in the related - # design model directory structure. - FILE=$(echo ${FILE} \ - | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r "s/\.${RENDER_EXTENSION}$//") - - # Define absolute path to final file (without extension). - FILE=${OUTPUT}/$(basename "${FILE}") - - # Define instance name from design model. - INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) - - # Perform format base-rendition. - ${RENDER_FORMAT} - - # Remove template instance. - if [[ -f $INSTANCE ]];then - rm $INSTANCE - fi - - # Increment file counter. - COUNT=$(($COUNT + 1)) - - done - - # Reset counter to prevent accumulation of values. - COUNT=0 - - # Unset format-specific functionalities. - cli_unsetFunctions "${EXPORTID}" - - # Unset files list to prevent accumulation of values. - unset FILES - - done -} diff --git a/Automation/Modules/Render/render_setBrands.sh b/Automation/Modules/Render/render_setBrands.sh deleted file mode 100755 index 187c4df..0000000 --- a/Automation/Modules/Render/render_setBrands.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# render_setBrands.sh -- This function performs brand-specific -# rendition. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_setBrands { - - local BRANDS_MODELS_DIR=${TCAR_WORKDIR}/Identity/Models/Brands - local BRANDS_IMAGES_DIR=${TCAR_WORKDIR}/Identity/Images/Brands - - render_setBrandsDirValidates ${BRANDS_IMAGES_DIR} ${ACTIONVAL} - render_setBrandsDirStructure ${BRANDS_MODELS_DIR} ${BRANDS_IMAGES_DIR} - - render_setBaseRendition - -} diff --git a/Automation/Modules/Render/render_setBrandsDirStructure.sh b/Automation/Modules/Render/render_setBrandsDirStructure.sh deleted file mode 100755 index 453e90c..0000000 --- a/Automation/Modules/Render/render_setBrandsDirStructure.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# render_setBrandsDirectoryStructure.sh -- This function verifies the -# directory structure of brands images using the directory structure -# of brands models as reference. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_setBrandsDirStructure { - - local BRANDS_SOURCE_DIR=$(cli_checkRepoDirSource ${1}) - local BRANDS_TARGET_DIR=$(cli_checkRepoDirSource ${2}) - - cli_printMessage "${BRANDS_TARGET_DIR} `gettext "directory structures..."`" --as-checking-line - - cli_runFnEnvironment prepare ${BRANDS_SOURCE_DIR} ${BRANDS_TARGET_DIR} --directories - -} diff --git a/Automation/Modules/Render/render_setBrandsDirValidates.sh b/Automation/Modules/Render/render_setBrandsDirValidates.sh deleted file mode 100755 index 8622474..0000000 --- a/Automation/Modules/Render/render_setBrandsDirValidates.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# render_setBrandsDirVerification.sh -- This function standardize path -# verification between path provided in the command line and -# repository directory structure. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - - -function render_setBrandsDirValidates { - - local BRANDS_PATH_OK=$(cli_checkRepoDirSource ${1}) - local BRANDS_PATH_UNKNOWN=$(cli_checkRepoDirSource ${2}) - - cli_checkFiles ${BRANDS_PATH_UNKNOWN} --match="^${BRANDS_PATH_OK}" - - local BRANDS_PATH_UNKNOWN_MODEL=$(echo ${BRANDS_PATH_UNKNOWN} \ - | sed -r "s,/Images/,/Models/,") - - cli_checkFiles ${BRANDS_PATH_UNKNOWN_MODEL} -d - -} diff --git a/Automation/Modules/Render/render_setDirStructure.sh b/Automation/Modules/Render/render_setDirStructure.sh deleted file mode 100755 index 8064b59..0000000 --- a/Automation/Modules/Render/render_setDirStructure.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -###################################################################### -# -# render_setDirStructure.sh -- This function standardizes the -# relation between source and target directory structures inside the -# repository. -# -# This function takes two arguments. The first is the source -# directory and the second is the target directory where you wan to -# reproduce the source directory structure. In order for this to -# work, all source directory structures provided to this function -# must have one level of directories more than its related target -# directory. The purpose of this level is content categorization. -# For example, consider the following path: -# -# ----------++++++++++++++++++++++++ -# ${SOURCE}/${CATEGORY}/${COMPONENT} -# ----------++++++++++++++++++++++++ -# +++++++++++++++++++++++++++++------------ -# ${TARGET}/${NAME}/${VERSION}/${COMPONENT} -# +++++++++++++++++++++++++++++------------ -# -# So we end with the following path: -# -# ${TARGET}/${CATEGORY}/${COMPONENT} -# -# In this path, ${CATEGORY} makes reference to a categorization -# directory used to describe source components related to target -# components. However, in the target side, such ${CATEGORY} -# directory is not needed and should be removed from it in order to -# get the final target path, which is: -# -# ${TARGET}/${COMPONENT} -# -# ${CATEGORY} is always a one-level directory, but ${COMPONENT} -# might have several levels deep inside. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -###################################################################### - -function render_setDirStructure { - - # Define absolute path to design models' directory structure. This - # directory contains the directory structure you want to verify - # inside target path. - local SOURCE_DIRECTORY=$(tcar_checkRepoDirSource "${1}") - - # Verify existence source path, just to be sure it was passed and - # it is a valid directory. - tcar_checkFiles ${SOURCE_DIR} -d - - # Define absolute path to directory inside the repository where - # you want to replicate the source path directory structure. - local TARGET_DIRECTORY=$(tcar_checkRepoDirSource "${2}") - - # NOTE: It is possible that target path doesn't exist. So verify - # the relation between target and source path. If there is a - # source path for the target, create an empty directory as target, - # using the related source directory as reference. - - # Define list of directories inside source path. - local DIRECTORIES=$(tcar_getFilesList ${SOURCE_DIRECTORY} \ - --pattern='.+/[[:alpha:]]+$' --type='d') - - # Iterate through directories inside source path and verify - # whether or not they exist in the target path. If they don't - # exist create them. - for DIRECTORY in ${DIRECTORIES};do - - local DIRECTORY_BASENAME=$(echo ${DIRECTORY} \ - | sed -r "s,${SOURCE_DIRECTORY}/,,") - - if [[ ${DIRECTORY} == ${DIRECTORY_BASENAME} ]];then - continue - fi - - local DIRECTORY_TARGET=${TARGET_DIRECTORY}/${DIRECTORY_BASENAME} - - if [[ ! -d ${DIRECTORY_TARGET} ]];then - mkdir -p ${DIRECTORY_TARGET} - fi - - done - -} diff --git a/Automation/Modules/Render/render_setThemes.sh b/Automation/Modules/Render/render_setThemes.sh deleted file mode 100755 index 134d6aa..0000000 --- a/Automation/Modules/Render/render_setThemes.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# render_setThemes.sh -- This function performs theme-specific -# rendition. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_setThemes { - - local -a DIRS - local COUNT=0 - local NEXTDIR='' - local MOTIF_NAME='' - local MOTIF_DIR='' - - # Define base directory of artistic motifs. This is the location - # where all artistic motifs are stored in. - local MOTIF_BASEDIR="${TCAR_WORKDIR}/Identity/Images/Themes" - - # Define base directory of design models. This is the location - # where all design models are stored in. - local MODEL_BASEDIR="${TCAR_WORKDIR}/Identity/Models/Themes" - - # Verify directory structure for all theme-specific directories. - render_setThemesDirStructure "${MODEL_BASEDIR}/${FLAG_THEME_MODEL}" "${MOTIF_BASEDIR}" - - # Define directory structure of design models. Design models - # directory structures are used as reference to create artistic - # motifs directory structure. Use the `--pattern' option to be - # sure any modification to FLAG_FILTER won't affect the output - # result. We need to make matching everything here, no matter what - # the FLAG_FILTER value be. - local MODEL_DIR='' - local MODEL_DIRS="$(cli_getFilesList ${MODEL_BASEDIR}/${FLAG_THEME_MODEL} \ - --pattern='^.+/[^.svn][[:alnum:]_/-]+$' --type="d" \ - | sed -e "s!^.*/${FLAG_THEME_MODEL}!!" \ - -e '/^[[:space:]]*$/d' \ - -e 's!^/!!')" - - # Define design model regular expression patterns from design - # models directory structure. - local MODEL_PATTERN=$(echo "$MODEL_DIRS" | tr "\n" '|' \ - | sed -e 's!^|!!' -e 's!|$!!') - - # Define regular expression pattern that match the theme artistic - # motif component inside the path strings. - local MOTIF_PATTERN=$(cli_getPathComponent --motif-pattern) - - # Define list of render-able directory structures inside the - # artistic motif. As reference, to build this list, use design - # model directory structure. The more specific you be in the path - # specification the more specific theme rendition will be. Thus, - # we use the path provided as argument and the --filter option as - # reference to control the amount of directories considered - # render-able directory. - local MOTIF_RENDERABLE_DIR='' - local MOTIF_RENDERABLE_DIRS=$(cli_getFilesList ${MOTIF_BASEDIR} \ - --pattern="^${TCAR_WORKDIR}/${MOTIF_PATTERN}/($MODEL_PATTERN)$" --type="d" \ - | grep "$(echo ${ACTIONVAL} | sed -r 's,/$,,')") - - # When no render-able directories are found, finish the script - # execution with an error message. There is an obvious typo in the - # path provided. - if [[ -z ${MOTIF_RENDERABLE_DIRS} ]];then - cli_printMessage "`gettext "No related model was found for the path provided."`" --as-error-line - fi - - # Rebuild list of render-able directory structures using an array - # variable. This let us to predict what directory is one step - # forward or backward from the current directory structure. - for MOTIF_RENDERABLE_DIR in $MOTIF_RENDERABLE_DIRS;do - DIRS[((++${#DIRS[*]}))]=${MOTIF_RENDERABLE_DIR} - done - - # Define total number of directories to process. This is required - # in order to correct the counting value and so, make it to match - # the zero based nature of bash array variables. - local DIRS_TOTAL=$((${#DIRS[*]} - 1)) - - while [[ $COUNT -le ${DIRS_TOTAL} ]];do - - # Redefine action value to refer the theme-specific render-able - # directory. - ACTIONVAL=${DIRS[$COUNT]} - - # Refine artistic motif name using the current action value. - MOTIF_NAME=$(cli_getPathComponent $ACTIONVAL --motif) - - # Verify artistic motif name. The name of the artistic motif - # must be present in order for theme rendition to happen. - # Theme rendition takes place inside artistic motifs and the - # artistic motif name is an indispensable part of it. Take - # care of not using design models directory structure as name - # for artistic motifs. They, sometimes, match the pattern used - # to verify artistic motifs names but must not be confused. - if [[ $MOTIF_NAME == '' ]] || [[ $MOTIF_NAME =~ "^($MODEL_PATTERN)" ]];then - COUNT=$(($COUNT + 1)) - continue - fi - - # Refine artistic motif directory. This is the top directory - # where all visual manifestations of an artistic motif are - # stored in (e.g., Backgrounds, Brushes, Concept, Distro, - # etc.). - MOTIF_DIR="${MOTIF_BASEDIR}/${MOTIF_NAME}" - - # Define what is the next directory in the list, so we could - # verify whether to render or not the current theme-specific - # render-able directory. - if [[ $COUNT -lt ${DIRS_TOTAL} ]];then - NEXTDIR=$(dirname ${DIRS[(($COUNT + 1))]}) - else - NEXTDIR='' - fi - - # Verify whether to render or not the current theme's - # render-able directory. This verification is needed in order - # to avoid unnecessary rendition loops. For example, don't - # render `path/to/dir/A' when `path/to/dir/A/B' does exist, - # that configuration would produce `/path/to/dir/A/B twice. - if [[ $ACTIONVAL =~ '[[:digit:]]$' ]] || [[ $ACTIONVAL == $NEXTDIR ]];then - COUNT=$(($COUNT + 1)) - continue - fi - - # Execute direct rendition on theme specific render-able - # directory as specified by action value. - render_setBaseRendition - - # Increment counter to match the correct count value. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Automation/Modules/Render/render_setThemesDirStructure.sh b/Automation/Modules/Render/render_setThemesDirStructure.sh deleted file mode 100755 index ed98d3d..0000000 --- a/Automation/Modules/Render/render_setThemesDirStructure.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# render_setThemeDirectoryStructre.sh -- This function verifies -# theme-specific directory structures using common theme models -# directory structure as pattern. If there are missing directories inside -# theme-specific directories, this function will create it. This is a -# requisite of rendition process, so be sure to call this function -# before building the list of render-able theme directories. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - - -function render_setThemesDirStructure { - - local THEMES_SOURCE_DIR=$(cli_checkRepoDirSource "${1}") - local THEMES_TARGET_DIR=$(cli_checkRepoDirSource "${2}") - - local THEMES_FILTER=${THEMES_TARGET_DIR}/$(cli_getPathComponent --motif ${ACTIONVAL}) - - THEMES_TARGET_DIRS=$(cli_getFilesList ${THEMES_TARGET_DIR} \ - --pattern=".+/[[:digit:]]+$" --maxdepth=2 --mindepth=2 \ - | grep "${THEMES_FILTER}") - - for THEMES_TARGET_DIR in $THEMES_TARGET_DIRS;do - cli_printMessage "$THEMES_TARGET_DIR `gettext "directory structure..."`" --as-checking-line - cli_runFnEnvironment prepare ${THEMES_SOURCE_DIR} ${THEMES_TARGET_DIR} --directories - done - -}