diff --git a/tcar-scripts-render/Locales/es_ES/render.sh.po b/tcar-scripts-render/Locales/es_ES/render.sh.po new file mode 100644 index 0000000..ea0585c --- /dev/null +++ b/tcar-scripts-render/Locales/es_ES/render.sh.po @@ -0,0 +1,20 @@ +msgid "" +msgstr "" +"Project-Id-Version: render.sh 0.6\n" +"Report-Msgid-Bugs-To: centos-l10n-es@centos.org.cu\n" +"POT-Creation-Date: 2013-10-07 15:12-0400\n" +"PO-Revision-Date: 2013-10-07 15:12-0400\n" +"Last-Translator: Localization SIG \n" +"Language-Team: Spanish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: Automation/Modules/Render/render_setRenderType.sh:76 +msgid "hasn't render-type set in." +msgstr "no tiene el ajuste render-type." + +#: Automation/Modules/Render/render_setRenderType.sh:81 +msgid "hasn't render-from set in." +msgstr "no tiene el ajuste render-from." diff --git a/tcar-scripts-render/Modules/Directories/directories.sh b/tcar-scripts-render/Modules/Directories/directories.sh new file mode 100755 index 0000000..8f132c9 --- /dev/null +++ b/tcar-scripts-render/Modules/Directories/directories.sh @@ -0,0 +1,51 @@ +#!/bin/bash +###################################################################### +# +# directories.sh -- This module initializes processing of +# configuration files when the argument provided in the command-line +# points to a directory. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 directories { + + local DIRECTORY=$(tcar_checkRepoDirSource "${1}") + + local CONFIGURATION_FILES=$(tcar_getFilesList ${DIRECTORY} \ + --pattern=".+/.+\.conf$" --type='f') + + local CONFIGURATION_SYMLINKS=$(tcar_getFilesList ${DIRECTORY} \ + --pattern=".+/.+\.conf$" --type='l') + + local CONFIGURATIONS="${CONFIGURATION_FILES} ${CONFIGURATION_SYMLINKS}" + + # Verify existence of configuration files. Take care that + # tcar_getFilesList might return empty values sometimes (e.g., + # when no file is found). + tcar_checkFiles -e "${CONFIGURATIONS}" + + # Process configuration file, one by one. + for CONFIGURATION in ${CONFIGURATIONS};do + tcar_setModuleEnvironment -m 'files' -t 'sibling' -g "${CONFIGURATION}" + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Archive/archive.sh b/tcar-scripts-render/Modules/Files/Modules/Archive/archive.sh new file mode 100755 index 0000000..68e67dd --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Archive/archive.sh @@ -0,0 +1,51 @@ +#!/bin/bash +###################################################################### +# +# archive.sh -- This file standardizes file archiving inside the +# centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 archive { + + tcar_printMessage "${RENDER_TARGET}" --as-creating-line + + COMMAND=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "command") + if [[ -z ${COMMAND} ]];then + COMMAND="/bin/tar --remove-files -czf" + fi + + # Let file names to be changed before compressing them. + for SOURCE in ${SOURCES[*]};do + FILE_LH=$(echo ${SOURCE} | gawk -F: '{ print $1 }') + tcar_checkFiles -ef ${FILE_LH} + FILE_RH=$(echo ${SOURCE} | gawk -F: '{ print $2 }') + cp ${FILE_LH} ${TCAR_SCRIPT_TEMPDIR}/${FILE_RH} + done + + pushd ${TCAR_SCRIPT_TEMPDIR} > /dev/null + + ${COMMAND} ${RENDER_TARGET} * + + popd > /dev/null + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Article/article.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Article/article.sh new file mode 100755 index 0000000..cddf9e5 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Article/article.sh @@ -0,0 +1,32 @@ +#!/bin/bash +###################################################################### +# +# article.sh -- This module produces docbook documents using article +# document type. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 article { + + asciidoc_setFormatsRendition + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Book/book.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Book/book.sh new file mode 100755 index 0000000..50feb02 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Book/book.sh @@ -0,0 +1,32 @@ +#!/bin/bash +###################################################################### +# +# book.sh -- This module produces docbook documents using book +# document type. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 book { + + asciidoc_setFormatsRendition + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Manpage/manpage.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Manpage/manpage.sh new file mode 100755 index 0000000..7aab945 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/Modules/Manpage/manpage.sh @@ -0,0 +1,66 @@ +#!/bin/bash +###################################################################### +# +# manpage.sh -- This module produces docbook documents using manpage +# document type. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 manpage { + + local MANSECT=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "mansect") + + tcar_checkFiles -m '[1-9]' "${MANSECT}" + + # xml2po (gnome-doc-utils-0.8.0-2.fc6) bug? For some reason xml2po + # is not adding the lang attribute to refentry tag when it + # produces manpage document types. This make intrinsic docbook + # construction like Name and Synopsis to be rendered without + # localization. This doesn't happens with article and book + # document types. + sed -i -r "s///" ${TARGET_INSTANCES[${COUNTER}]} + + for FORMAT in ${FORMATS};do + + tcar_checkFiles -m '(xhtml|manpage)' "${FORMAT}" + + case ${FORMAT} in + + 'xhtml' ) + local HTML_TARGET="$(dirname ${RENDER_TARGET})/htmlman${MANSECT}/$(basename ${RENDER_TARGET}).${MANSECT}.html" + asciidoc_setXhtmlRendition "${HTML_TARGET}" + ;; + + 'manpage' ) + local MAN_TARGET="$(dirname ${RENDER_TARGET})/man${MANSECT}/$(basename ${RENDER_TARGET}).${MANSECT}" + if [[ ! -d $(dirname ${MAN_TARGET}) ]];then + mkdir -p $(dirname ${MAN_TARGET}) + fi + tcar_printMessage "${MAN_TARGET}" --as-creating-line + /usr/bin/xsltproc -o ${MAN_TARGET} --nonet \ + ${DOCBOOK_XSL}/docbook2manpage.xsl ${TARGET_INSTANCES[${COUNTER}]} + ;; + esac + + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc.sh new file mode 100755 index 0000000..3ebfbf7 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc.sh @@ -0,0 +1,53 @@ +#!/bin/bash +###################################################################### +# +# asciidoc.sh -- This function standardizes rendition of asciidoc +# files inside the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 asciidoc { + + local DOCBOOK_VER="1.69.1" + local DOCBOOK_XSL="${TCAR_BASEDIR}/Artworks/Webenv/Docbook/${DOCBOOK_VER}/Xsl" + local DOCBOOK_CSS="${TCAR_BASEDIR}/Artworks/Webenv/Docbook/${DOCBOOK_VER}/Css" + + RENDER_FLOW=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'render-flow') + if [[ -z ${RENDER_FLOW} ]];then + RENDER_FLOW="article" + fi + tcar_checkFiles -m '^(article|book|manpage)$' "${RENDER_FLOW}" + + FORMATS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'formats') + if [[ -z ${FORMATS} ]];then + FORMATS='xhtml' + fi + + RELEASE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'release') + if [[ -z ${RELEASE} ]];then + RELEASE=$(cut -f3 -d' ' /etc/redhat-release) + fi + MAJOR_RELEASE=$(echo ${RELEASE} | cut -d. -f1) + + asciidoc_setBaseRendition + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRendition.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRendition.sh new file mode 100755 index 0000000..abe81bc --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRendition.sh @@ -0,0 +1,55 @@ +#!/bin/bash +###################################################################### +# +# asciidoc_setBaseRendition.sh -- This function standardizes +# transformation of asciidoc files into docbook files. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 asciidoc_setBaseRendition { + + local COUNTER=0 + + local -a SOURCE_INSTANCES + local -a TARGET_INSTANCES + + while [[ ${COUNTER} -lt ${#SOURCES[*]} ]];do + + render_setInstances "${SOURCES[${COUNTER}]}" 'asciidoc' 'docbook' + + /usr/bin/asciidoc --backend="docbook" --doctype="${RENDER_FLOW}" \ + --out-file="${SOURCE_INSTANCES[${COUNTER}]}" ${SOURCES[${COUNTER}]} + + render_setLocalizedXml "${SOURCE_INSTANCES[${COUNTER}]}" "${TARGET_INSTANCES[${COUNTER}]}" + + tcar_setTranslationMarkers ${TARGET_INSTANCES[${COUNTER}]} + + tcar_setModuleEnvironment -m "${RENDER_FLOW}" -t "child" + + COUNTER=$(( ${COUNTER} + 1 )) + + done + + unset TARGET_INSTANCES + unset SOURCE_INSTANCES + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh new file mode 100755 index 0000000..5c71014 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setBaseRenditionCommand.sh @@ -0,0 +1,36 @@ +#!/bin/bash +###################################################################### +# +# asciidoc_setBaseRenditionCommand.sh -- This function standardizes +# the way Asciidoc files are rendered inside the centos-art.sh +# script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 asciidoc_setBaseRenditionCommand { + + tcar_checkFiles -m '^(article|book|manpage)$' ${RENDER_TYPE} + + asciidoc --backend='docbook' --doctype="${RENDER_TYPE}" \ + --out-file="${RENDER_TARGET}" + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setFormatsRendition.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setFormatsRendition.sh new file mode 100755 index 0000000..6a8371c --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setFormatsRendition.sh @@ -0,0 +1,45 @@ +#!/bin/bash +###################################################################### +# +# asciidoc_setFormatsRendition.sh -- This function standardizes the +# rendition formats supported by asciidoc module. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 asciidoc_setFormatsRendition { + + for FORMAT in ${FORMATS};do + + case ${FORMAT} in + + 'xhtml' ) + asciidoc_setXhtmlRendition "${RENDER_TARGET}" + ;; + + * ) + tcar_printMessage "`gettext "The format you specified isn't supported, yet."`" --as-error-line + ;; + esac + + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh new file mode 100755 index 0000000..bbe02e8 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh @@ -0,0 +1,73 @@ +#!/bin/bash +###################################################################### +# +# asciidoc_setXhtmlRendition.sh -- This function standardizes the way +# docbook files are transformed in XHTML format. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 asciidoc_setXhtmlRendition { + + local LOCATION=$(tcar_checkRepoDirSource "${1}") + + RENDER_PAGES=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-page") + if [[ -z ${RENDER_PAGES} ]];then + RENDER_PAGES='single' + fi + tcar_checkFiles -m '^(single-notoc|single|chunks)$' "${RENDER_PAGES}" + + IMAGES_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "images-from") + if [[ -z ${IMAGES_FROM} ]];then + IMAGES_FROM="${TCAR_BASEDIR}/Artworks/Icons/Webenv/Final" + fi + + STYLES_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "styles-from") + if [[ -z ${STYLES_FROM} ]];then + STYLES_FROM="${TCAR_BASEDIR}/Artworks/Webenv/Docbook/1.69.1/Css" + fi + + # When producing chunks, take into consideration that both single + # and chunks share images produced in the root location. If we + # create another level of directories to store chunks, that would + # make impossible to use one unique image path for both single and + # chunks from one unique asciidoc document. So, to reuse image + # files, produce both chunks and single XHTML output in the same + # directory. + if [[ ${RENDER_PAGES} == 'chunks' ]];then + LOCATION="$(dirname ${LOCATION})/" + fi + + if [[ ! -d $(dirname ${LOCATION}) ]];then + mkdir -p $(dirname ${LOCATION}) + fi + + ln -sfn ${IMAGES_FROM} $(dirname ${LOCATION})/Images + ln -sfn ${STYLES_FROM} $(dirname ${LOCATION})/Css + + tcar_printMessage "${LOCATION}" --as-creating-line + + for RENDER_PAGE in ${RENDER_PAGES};do + /usr/bin/xsltproc -o ${LOCATION} --nonet \ + ${DOCBOOK_XSL}/docbook2xhtml-${RENDER_PAGE}.xsl ${TARGET_INSTANCES[${COUNTER}]} + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Compress/compress.sh b/tcar-scripts-render/Modules/Files/Modules/Compress/compress.sh new file mode 100755 index 0000000..f164d80 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Compress/compress.sh @@ -0,0 +1,41 @@ +#!/bin/bash +###################################################################### +# +# compress.sh -- This file standardize file compression inside the +# centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 compress { + + tcar_printMessage "${RENDER_TARGET}" --as-creating-line + + COMMAND=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "command") + if [[ -z ${COMMAND} ]];then + COMMAND="/bin/gzip" + fi + + tcar_checkFiles -ef ${SOURCES[*]} + + ${COMMAND} ${SOURCES[*]} + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Images/images.sh b/tcar-scripts-render/Modules/Files/Modules/Images/images.sh new file mode 100755 index 0000000..ba0e463 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Images/images.sh @@ -0,0 +1,49 @@ +#!/bin/bash +###################################################################### +# +# images.sh -- This module standardizes production of image files +# from other image files. There is no intermediate process here. +# The image or images provided as value to render-from variable are +# used to create the image specified in the section line using the +# command specified in the command variable, without any +# intermediate process. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 images { + + tcar_checkFiles -i "image" ${SOURCES[*]} + + COMMAND=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "command") + if [[ -z ${COMMAND} ]];then + COMMAND="/usr/bin/images -append" + fi + + if [[ ! -d $(dirname ${RENDER_TARGET}) ]];then + mkdir -p $(dirname ${RENDER_TARGET}) + fi + + tcar_printMessage "${RENDER_TARGET}" --as-creating-line + + eval ${COMMAND} ${SOURCES[*]} ${RENDER_TARGET} + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Palette/palette.sh b/tcar-scripts-render/Modules/Files/Modules/Palette/palette.sh new file mode 100755 index 0000000..20fb82c --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Palette/palette.sh @@ -0,0 +1,104 @@ +#!/bin/bash +###################################################################### +# +# palette.sh -- This function standardizes the way palette of colors +# are applied to image files in order to produce images with +# specific number of colors. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 palette { + + local FILENAME=$(tcar_getTemporalFile "$(echo ${SOURCES[0]} \ + | sed -r 's/\.[[:alpha:]]+$//')") + + local LOGS=${RENDER_TARGET}.log + + # Define absolute path to GPL palette. This file is the reference + # taken to set the max number of colors the final image will be + # produced for. + local PALETTE_GPL=$(tcar_getConfigValue ${CONFIGURATION} ${SECTION} 'palette-gpl') + tcar_checkFiles -ef ${PALETTE_GPL} + + local PALETTE_GPL_COLORS=$(palette_getColors "${PALETTE_GPL}") + + # 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=$(tcar_getTemporalFile 'palette.ppm') + + # Verify format of colors returned in the list. + palette_checkColorFormats "${PALETTE_GPL_COLORS}" + + # 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. + pngtopnm -verbose \ + < ${SOURCES[0]} 2>${LOGS} > ${FILENAME}.pnm + + # Create PPM palette using GPL palette. + palette_convertGplToPpm + + # 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. + pnmremap -verbose -mapfile=${PALETTE_PPM} -floyd \ + < ${FILENAME}.pnm 2>>${LOGS} > ${FILENAME}.ppm + + # Print action message. + tcar_printMessage "${RENDER_TARGET}" --as-creating-line + + if [[ ${RENDER_TARGET} =~ '\.lss$' ]];then + + # 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=$(tcar_getTemporalFile "palette.hex") + + # Create HEX palette using GPL palette. + palette_convertGplToHex + + # Create LSS16 image. + ppmtolss16 $(cat ${PALETTE_HEX}) \ + < ${FILENAME}.ppm 2>>${LOGS} > ${RENDER_TARGET} + + # 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. + lss16toppm -map \ + < ${RENDER_TARGET} 2>>${LOGS} > ${RENDER_TARGET}.ppm + + else + + # Create final file. + /usr/bin/convert ${FILENAME}.ppm ${RENDER_TARGET} + + fi + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Palette/palette_checkColorFormat.sh b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_checkColorFormat.sh new file mode 100755 index 0000000..b11b16c --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_checkColorFormat.sh @@ -0,0 +1,39 @@ +#!/bin/bash +###################################################################### +# +# palette_checkColorFormats.sh -- This function verifies formats of +# colors (i.e., the way color information is specified). +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 palette_checkColorFormats { + + local COLOR='' + local PALETTE_COLORS=${1} + + # Loop through colors and perform format verification as specified + # by pattern. + for COLOR in ${PALETTE_COLORS};do + tcar_checkFiles -m '^#[0-9a-f]{6}$' "${COLOR}" + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToHex.sh b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToHex.sh new file mode 100755 index 0000000..d78a00a --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToHex.sh @@ -0,0 +1,37 @@ +#!/bin/bash +###################################################################### +# +# palette_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]). +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 palette_convertGplToHex { + + # Create list of colors to be processed by `pnmtolss16'. + echo "${PALETTE_GPL_COLORS}" | nl | gawk '{ printf "%s=%d ", $2, $1 - 1 }' \ + > ${PALETTE_HEX} + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToPpm.sh b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToPpm.sh new file mode 100755 index 0000000..0619f68 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_convertGplToPpm.sh @@ -0,0 +1,52 @@ +#!/bin/bash +###################################################################### +# +# palette_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). +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 palette_convertGplToPpm { + + local -a FILES + local COUNT=0 + + # Create temporal images (of 1x1 pixel each) to store each color + # retrieved from Gimp's palette. + for COLOR in ${PALETTE_GPL_COLORS};do + FILES[${COUNT}]=$(tcar_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. + tcar_checkFiles -ef "${PALETTE_PPM}" + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Palette/palette_getColors.sh b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_getColors.sh new file mode 100755 index 0000000..4363cdd --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Palette/palette_getColors.sh @@ -0,0 +1,63 @@ +#!/bin/bash +###################################################################### +# +# palette_getColors.sh -- This function takes one palette produced +# by Gimp (e.g., syslinux.gpl) as input and outputs a list of colors +# in #rrggbb format set in the fourth column of it. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 palette_getColors { + + local COLOR='' + local PALETTE_COLORS='' + local PALETTE=${1} + + if [[ -f ${PALETTE} ]];then + + # 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. + PALETTE_COLORS=$(sed -r '1,/^#/d' ${PALETTE} \ + | gawk '{ printf "%s\n", $4 }') + + else + + # Redefine default background color using The CentOS Project + # default color then. + PALETTE_COLORS='#204c8d' + + fi + + # Be sure all color information be output in the #rrggbb format. + for COLOR in ${PALETTE_COLORS};do + if [[ ! ${COLOR} =~ '^#' ]];then + COLOR="#${COLOR}" + fi + echo "${COLOR}" + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Base/base.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Base/base.sh new file mode 100755 index 0000000..e1614b8 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Base/base.sh @@ -0,0 +1,33 @@ +#!/bin/bash +###################################################################### +# +# base.sh -- This function standardizes base rendition of PNG files. +# Base rendition consists on producing one PNG image for each SVG +# file provided as source. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 base { + + svg_setBaseRendition + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended.sh new file mode 100755 index 0000000..8f7636f --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended.sh @@ -0,0 +1,90 @@ +#!/bin/bash +###################################################################### +# +# extended.sh -- This function standardize extended production of +# PNG files from SVG files. The extended production consists on +# producing PNG images in in different formats, heights, foreground +# colors and background colors. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 extended { + + # 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=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "formats") + if [[ -z ${FORMATS} ]];then + FORMATS="png" + 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=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "heights") + if [[ -z ${HEIGHTS} ]];then + HEIGHTS="16 20 22 24 26 32 36 38 40 48 52 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=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "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=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "bgcolors") + if [[ -z ${BGCOLORS} ]];then + BGCOLORS="ffffff-0 ffffff-1" + fi + + for BGCOLOR in ${BGCOLORS};do + + # Verify value passed as background color. + tcar_checkFiles -m '^[a-fA-F0-9]{6}-(0|1)$' ${BGCOLOR} + + for FGCOLOR in ${FGCOLORS};do + + # Verify value passed as foreground color. + tcar_checkFiles -m '^[a-fA-F0-9]{3,6}$' ${FGCOLOR} + + for HEIGHT in ${HEIGHTS};do + + # Verify value passed as height. + tcar_checkFiles -m '^[[:digit:]]+$' ${HEIGHT} + + # Do base rendition actions. + extended_setBaseRendition + + done + done + done + + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended_setBaseRendition.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended_setBaseRendition.sh new file mode 100755 index 0000000..2097b22 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Extended/extended_setBaseRendition.sh @@ -0,0 +1,49 @@ +#!/bin/bash +###################################################################### +# +# extended_setBaseRendition.sh -- This function standardize base +# rendition tasks needed to perform the extended production of PNG +# files from SVG files. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 extended_setBaseRendition { + + local RENDER_TARGET=$(dirname ${RENDER_TARGET})/${BGCOLOR}/${FGCOLOR}/${HEIGHT}/$(basename ${RENDER_TARGET}) + + svg_setBaseRendition + + # Create path for different image formats creation using PNG image + # extension as reference. + RENDER_TARGET=$(echo ${RENDER_TARGET} | sed -r "s/\.png$//") + + # Convert images from PNG to those formats specified in the + # configuration file. + for FORMAT in ${FORMATS};do + if [[ ${FORMAT} =~ 'png' ]];then + continue + fi + tcar_printMessage "${RENDER_TARGET}.${FORMAT}" --as-creating-line + convert ${RENDER_TARGET}.png ${RENDER_TARGET}.${FORMAT} + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Media/media.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Media/media.sh new file mode 100755 index 0000000..50fe025 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/Modules/Media/media.sh @@ -0,0 +1,91 @@ +#!/bin/bash +###################################################################### +# +# media.sh -- This module produces artwork for installation media. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 media { + + local MEDIA_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'media-type') + tcar_checkFiles -m '^[[:alnum:]]+$' "${MEDIA_TYPE}" + + local MEDIA_NUMBER=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'media-number') + tcar_checkFiles -m '^[[:digit:]]+$' "${MEDIA_NUMBER}" + + local MEDIA_RELEASE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'media-release') + tcar_checkFiles -m '^[[:digit:].]+$' "${MEDIA_RELEASE}" + + local MEDIA_ARCH=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'media-arch') + tcar_checkFiles -m '^[[:alnum:]_-]+$' "${MEDIA_ARCH}" + + local MEDIA_SOURCES=${SOURCES[*]} + local MEDIA_SOURCES_MAX=${#SOURCES[*]} + + local MEDIA_NUMBER_CURRENT=1 + + while [[ ${MEDIA_NUMBER_CURRENT} -le ${MEDIA_NUMBER} ]];do + + local COUNTER=0 + local -a SOURCE_INSTANCES + local -a TARGET_INSTANCES + + for RELEASE in ${MEDIA_RELEASE};do + + for ARCH in ${MEDIA_ARCH};do + + for MEDIA_SOURCE in ${MEDIA_SOURCES};do + + render_setInstances "${MEDIA_SOURCE}" '(svgz|svg)' 'svg' + + render_setLocalizedXml "${MEDIA_SOURCE}" "${TARGET_INSTANCES[${COUNTER}]}" + + sed -i -r -e "s/=MEDIUM=/${MEDIA_TYPE}/g" \ + -e "s/=CURRENT=/${MEDIA_NUMBER_CURRENT}/g" \ + -e "s/=RELEASE=/${RELEASE}/g" \ + -e "s/=ARCH=/${ARCH}/g" \ + -e "s/=LAST=/${MEDIA_NUMBER}/g" \ + ${TARGET_INSTANCES[${COUNTER}]} + + RENDER_TARGET="$(dirname ${RENDER_TARGET})/${SECTION}-${RELEASE}-${ARCH}-${MEDIA_NUMBER_CURRENT}of${MEDIA_NUMBER}.png" + + SOURCES[${COUNTER}]=${TARGET_INSTANCES[${COUNTER}]} + + svg_setBaseRendition + + rm ${TARGET_INSTANCES[${COUNTER}]} + + if [[ ${MEDIA_SOURCES_MAX} -gt 1 ]];then + COUNTER=$(( ${COUNTER} + 1 )) + fi + + done + + done + + done + + MEDIA_NUMBER_CURRENT=$(( ${MEDIA_NUMBER_CURRENT} + 1 )) + + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg.sh new file mode 100755 index 0000000..96e0e36 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg.sh @@ -0,0 +1,62 @@ +#!/bin/bash +###################################################################### +# +# svg.sh -- This file initializes the svg module. The svg module +# takes SVG fies as input and produces different kind of images +# based on either simple or advanced rendition flow. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg { + + # Define command used to create final images from instance images. + COMMAND=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "command") + if [[ -z ${COMMAND} ]];then + if [[ ${#SOURCES[*]} -gt 1 ]];then + COMMAND="/usr/bin/convert +append" + else + COMMAND="/bin/cp" + fi + fi + + RENDER_FLOWS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-flow") + if [[ -z ${RENDER_FLOWS} ]];then + RENDER_FLOWS='base' + fi + + BRANDS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "brand") + + COMMENT=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "comment") + + EXPORTID=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "export-id") + + RELEASE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" 'release') + if [[ -z ${RELEASE} ]];then + RELEASE=$(cut -f3 -d' ' /etc/redhat-release) + fi + MAJOR_RELEASE=$(echo ${RELEASE} | cut -d. -f1) + + for RENDER_FLOW in ${RENDER_FLOWS} ;do + tcar_setModuleEnvironment -m "${RENDER_FLOW}" -t "child" + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_checkModelAbsref.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_checkModelAbsref.sh new file mode 100755 index 0000000..a41cee8 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_checkModelAbsref.sh @@ -0,0 +1,139 @@ +#!/bin/bash +###################################################################### +# +# svg_checkModelAbsref.sh -- This function retrieves absolute pahts +# from source 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.png). If this +# isn't possible either, then create the background image using a +# plain color and crop from it then. We can't go on without the +# required background information. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 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 retrieve absolute paths from. + tcar_checkFiles -ef "${FILE}" + + # Retrieve 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 retrieved from file. + for BG_DST_FILE in ${BG_DST_FILES};do + + # Verify parent directory of absolute files retrieved 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 temporally. 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. + tcar_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 information be + # available for using. Generally, this is the most + # reusable background file inside the artistic motifs + # (e.g,. the `2048x1536.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:]]+!\1/2048x1536!") + + # 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='#204C8D' + + # 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:]]+\.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:]]+)\.png!\1!') + + # Print action message. + tcar_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 + + # Define the width of the required background information. + BG_DST_FILE_WIDTH=$(echo ${BG_DST_FILE} \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+\.png!\1!') + + # Define the height of the required background information. + BG_DST_FILE_HEIGHT=$(echo ${BG_DST_FILE} \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)\.png!\1!') + + # Print action message. + tcar_printMessage "${BG_SRC_FILE} (${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT})" --as-cropping-line + + # Create required background 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. + tcar_checkFiles -ef ${BG_DST_FILE} + + fi + + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_checkModelExportId.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_checkModelExportId.sh new file mode 100755 index 0000000..bd80a4b --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/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. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg_checkModelExportId { + + local INSTANCE="${1}" + local EXPORTID="${2}" + + # Verify instance. + tcar_checkFiles -ef ${INSTANCE} + + # Verify export id. + tcar_checkFiles -m '[[:alnum:]]+' ${EXPORTID} + + # Check export id inside design templates. + grep "id=\"${EXPORTID}\"" ${INSTANCE} > /dev/null + if [[ $? -gt 0 ]];then + tcar_printMessage "`gettext "The design model doesn't contain the export-id you specified."`" --as-error-line + fi + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRendition.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRendition.sh new file mode 100755 index 0000000..f41cd71 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRendition.sh @@ -0,0 +1,92 @@ +#!/bin/bash +###################################################################### +# +# svg_setBaseRendition.sh -- This function standardizes the base +# rendition tasks needed to produce PNG files from SVG files. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg_setBaseRendition { + + local COUNTER=0 + + local -a SOURCE_INSTANCES + local -a TARGET_INSTANCES + local -a INKSCAPE_OPTIONS + + while [[ ${COUNTER} -lt ${#SOURCES[*]} ]];do + + render_setInstances "${SOURCES[${COUNTER}]}" '(svgz|svg)' 'png' + + render_setLocalizedXml "${SOURCES[${COUNTER}]}" "${SOURCE_INSTANCES[${COUNTER}]}" + + tcar_setTranslationMarkers ${SOURCE_INSTANCES[${COUNTER}]} + + svg_checkModelAbsref "${SOURCE_INSTANCES[${COUNTER}]}" + + svg_setBaseRenditionOptions + + svg_setBaseRenditionCommand + + COUNTER=$(( ${COUNTER} + 1 )) + + done + + # Verify existence of output directory. + if [[ ! -d $(dirname ${RENDER_TARGET}) ]];then + mkdir -p $(dirname ${RENDER_TARGET}) + fi + + tcar_printMessage "${RENDER_TARGET}" --as-creating-line + + # Apply command to PNG images produced from design models to + # construct the final PNG image. + if [[ -n ${COMMAND} ]];then + ${COMMAND} ${TARGET_INSTANCES[*]} ${RENDER_TARGET} + fi + + # Apply branding images to final PNG image. + if [[ -n ${BRANDS} ]];then + svg_setBrandInformation + fi + + # Apply comment to final PNG image. + if [[ -n ${COMMENT} ]];then + /usr/bin/mogrify -comment "${COMMENT}" ${RENDER_TARGET} + fi + + # 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 ${TARGET_INSTANCES[*]} ${SOURCE_INSTANCES[*]} + + # Unset array variables and their counter to prevent undesired + # concatenations. + unset SOURCE_INSTANCES + unset TARGET_INSTANCES + unset INKSCAPE_OPTIONS + unset COUNTER + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionCommand.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionCommand.sh new file mode 100755 index 0000000..10ded06 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionCommand.sh @@ -0,0 +1,32 @@ +#!/bin/bash +###################################################################### +# +# svg_setBaseRenditionCommand.sh -- This function standardizes the +# way SVG files are produced inside the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg_setBaseRenditionCommand { + + /usr/bin/inkscape ${SOURCE_INSTANCES[${COUNTER}]} ${INKSCAPE_OPTIONS[${COUNTER}]} > /dev/null + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionOptions.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionOptions.sh new file mode 100755 index 0000000..a7efeb2 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBaseRenditionOptions.sh @@ -0,0 +1,52 @@ +#!/bin/bash +###################################################################### +# +# svg_setBaseRenditionOptions.sh -- This function standardizes the +# way base rendition options are set. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg_setBaseRenditionOptions { + + if [[ ! -z ${FGCOLOR} ]] && [[ ${FGCOLOR} != '000000' ]];then + sed -i -r "s/((fill|stroke):#)000000/\1${FGCOLOR}/g" ${SOURCE_INSTANCES[${COUNTER}]} + fi + + INKSCAPE_OPTIONS[${COUNTER}]="--export-png=${TARGET_INSTANCES[${COUNTER}]}" + + if [[ -z ${EXPORTID} ]];then + INKSCAPE_OPTIONS[${COUNTER}]="${INKSCAPE_OPTIONS[${COUNTER}]} --export-area-drawing " + else + svg_checkModelExportId "${SOURCE_INSTANCES[${COUNTER}]}" "${EXPORTID}" + INKSCAPE_OPTIONS[${COUNTER}]="${INKSCAPE_OPTIONS[${COUNTER}]} --export-id=${EXPORTID} " + fi + + if [[ ! -z ${BGCOLOR} ]];then + INKSCAPE_OPTIONS[${COUNTER}]="${INKSCAPE_OPTIONS[${COUNTER}]} --export-background=$(echo ${BGCOLOR} | cut -d'-' -f1) " + INKSCAPE_OPTIONS[${COUNTER}]="${INKSCAPE_OPTIONS[${COUNTER}]} --export-background-opacity=$(echo ${BGCOLOR} | cut -d'-' -f2) " + fi + + if [[ ! -z ${HEIGHT} ]];then + INKSCAPE_OPTIONS[${COUNTER}]="${INKSCAPE_OPTIONS[${COUNTER}]} --export-height=${HEIGHT} " + fi + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBrandInformation.sh b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBrandInformation.sh new file mode 100755 index 0000000..1f420ce --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Svg/svg_setBrandInformation.sh @@ -0,0 +1,42 @@ +#!/bin/bash +###################################################################### +# +# svg_setBrandInformation.sh -- This function takes brand +# information from configuration files, processes it, and apply it +# on final PNG image file. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 svg_setBrandInformation { + + for BRAND in ${BRANDS};do + + local FILENAME=$(echo ${BRAND} | cut -d: -f1) + local GEOMETRY=$(echo ${BRAND} | cut -d: -f2) + + tcar_checkFiles -ef ${FILENAME} + + /usr/bin/composite -geometry ${GEOMETRY} ${FILENAME} ${RENDER_TARGET} ${RENDER_TARGET} + + done + +} diff --git a/tcar-scripts-render/Modules/Files/Modules/Symlink/symlink.sh b/tcar-scripts-render/Modules/Files/Modules/Symlink/symlink.sh new file mode 100755 index 0000000..1accc29 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/Modules/Symlink/symlink.sh @@ -0,0 +1,63 @@ +#!/bin/bash +###################################################################### +# +# symlink.sh -- This function provides an interface for ln command. +# It mainly exists to creates symbolic links based on information +# set in configuration files that have symlink as value to +# render-type option. In these sections, the render-from and +# link-target options are used to specify the link locations. The +# link-options option might be used to pass additional options to ln +# command. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 symlink { + + # Define absolute path to command used to create symbolic links. + local LN=/bin/ln + + # Retrieve command options (values are not required here). Just + # grant you are always creating symbolic links. + local LN_OPTIONS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "link-options") + LN_OPTIONS="-si ${LN_OPTIONS}" + + # Retrieve link source. This is the file you want to link. This + # file is generally inside the repository. + local LN_SOURCE=${RENDER_FROM} + tcar_checkFiles -ef ${LN_SOURCE} + + # Retrieve link target. This is the link you want to create. This + # link may be inside or outside the repository. The value passed + # to this value must be a directory because it is concatenated + # with the section name to build the final path where link will be + # created. + local LN_TARGET=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "link-target") + tcar_checkFiles -ed ${LN_TARGET} + LN_TARGET=${LN_TARGET}/${SECTION} + + # Print action message. + tcar_printMessage "${LN_TARGET}" --as-creating-line + + # Create link interactively. + ${LN} ${LN_OPTIONS} ${LN_SOURCE} ${LN_TARGET} + +} diff --git a/tcar-scripts-render/Modules/Files/files.sh b/tcar-scripts-render/Modules/Files/files.sh new file mode 100755 index 0000000..14a5f29 --- /dev/null +++ b/tcar-scripts-render/Modules/Files/files.sh @@ -0,0 +1,133 @@ +#!/bin/bash +###################################################################### +# +# files.sh -- This module initializes processing of configuration +# files when the argument passed in the command-line points to a +# regular file or symbolic link. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 files { + + local CONFIGURATION=$(tcar_checkRepoDirSource "${1}") + + local -a SECTIONS + local SECTION='' + + # Define motif-specific environment variables, based on + # configuration file path. These variables might save + # configuration file writers from typing motif-specific + # information when they produce motif-specific content. These + # variables will be empty if the configuration file isn't inside + # a motif-specific directory structure. + local MOTIF=$(tcar_getPathComponent ${CONFIGURATION} --motif) + local MOTIF_NAME=$(tcar_getPathComponent ${CONFIGURATION} --motif-name) + local MOTIF_VERSION=$(tcar_getPathComponent ${CONFIGURATION} --motif-version) + + # Use arrays to store section names. This make possible to make + # use of post-rendition and last-rendition concepts. Otherwise it + # would be difficult to predict information about sections inside + # deeper environments. + for SECTION in $(tcar_getConfigSectionNames "${CONFIGURATION}" \ + | egrep ${TCAR_FLAG_FILTER});do + SECTIONS[++${#SECTIONS[*]}]="${SECTION}" + done + + # Verify the configuration file has one section entry at least. + if [[ ${#SECTIONS[*]} -eq 0 ]];then + tcar_printMessage "`eval_gettext "No section definition was found in \\\$CONFIGURATION."`" --as-error-line + fi + + local COUNTER=0 + + while [[ ${COUNTER} -lt ${#SECTIONS[*]} ]];do + + # Initialize array variables locally. + local -a TRANSLATIONS + local -a SOURCES + + SECTION=${SECTIONS[${COUNTER}]} + + if [[ ${SECTION} =~ "^/" ]];then + RENDER_TARGET=${SECTION} + else + RENDER_TARGET=$(dirname ${CONFIGURATION})/Final/${TCAR_SCRIPT_LANG_LC}/${SECTION} + fi + + RENDER_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type") + if [[ -z ${RENDER_TYPE} ]];then + tcar_printMessage "${CONFIGURATION} `gettext "hasn't render-type set in."`" --as-error-line + fi + + RENDER_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-from") + if [[ -z ${RENDER_TYPE} ]];then + tcar_printMessage "${CONFIGURATION} `gettext "hasn't render-from set in."`" --as-error-line + fi + + for SOURCE in ${RENDER_FROM};do + if [[ ${SOURCE} =~ "^/" ]];then + SOURCES[++${#SOURCES[*]}]=${SOURCE} + else + SOURCES[++${#SOURCES[*]}]=$(dirname ${CONFIGURATION})/${SOURCE} + fi + done + + if [[ -z ${RENDER_TYPE} ]];then + RENDER_TYPE=$(echo ${SOURCES[0]} | sed -r 's/.+\.([[:alpha:]]+)$/\1/') + fi + + LOCALE_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "locale-from") + if [[ -z ${LOCALE_FROM} ]] || [[ ${LOCALE_FROM} == 'no-locale' ]] ;then + RENDER_FLAG_NO_LOCALE='true' + RENDER_TARGET=$(echo ${RENDER_TARGET} | sed "s,${TCAR_SCRIPT_LANG_LC}/,,") + else + for TRANSLATION in ${LOCALE_FROM};do + if [[ ${TRANSLATION} =~ "^/" ]];then + TRANSLATIONS[++${#TRANSLATIONS[*]}]=${TRANSLATION} + else + TRANSLATIONS[++${#TRANSLATIONS[*]}]=$(dirname ${CONFIGURATION})/${TRANSLATION} + fi + done + fi + + # Execute module for processing type-specific files. + tcar_setModuleEnvironment -m "${RENDER_TYPE}" -t "child" + + # Increment section's counter. + COUNTER=$(( ${COUNTER} + 1 )) + + # Reset array variable to avoid undesired concatenations + # between sections blocks. + unset TRANSLATIONS + unset SOURCES + + done + + # Reset array variables and their counters to avoid undesired + # concatenations between configuration files. + unset COUNTER + unset SECTIONS + + # Tuneup final files. + tcar_setModuleEnvironment -m 'tuneup' -t 'parent' -g $(dirname ${RENDER_TARGET}) + +} diff --git a/tcar-scripts-render/render.sh b/tcar-scripts-render/render.sh new file mode 100755 index 0000000..e9edb20 --- /dev/null +++ b/tcar-scripts-render/render.sh @@ -0,0 +1,56 @@ +#!/bin/bash +###################################################################### +# +# render.sh -- This function standardizes the way source files are +# processed inside the working copy. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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 { + + # Define flag to control whether final content is produced inside + # locale directories or not. + LOACLE_FLAG_NO_LOCALE='false' + + # Interpret arguments and options passed through command-line. + render_getOptions + + # Define action value. We use non-option arguments to define the + # action value (ACTIONVAL) variable. + for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do + + # Sanitate non-option arguments to be sure they match the + # directory conventions established by centos-art.sh script + # against source directory locations in the working copy. + local ARGUMENT=$(tcar_checkRepoDirSource ${ARGUMENT}) + + if [[ -d ${ARGUMENT} ]];then + tcar_setModuleEnvironment -m 'directories' -t 'child' -g ${ARGUMENT} + elif [[ -f ${ARGUMENT} ]] && [[ ${ARGUMENT} =~ '\.conf$' ]];then + tcar_setModuleEnvironment -m 'files' -t 'child' -g ${ARGUMENT} + else + tcar_printMessage "${ARGUMENT} `gettext "isn't supported."`" --as-error-line + fi + + done + +} diff --git a/tcar-scripts-render/render_getOptions.sh b/tcar-scripts-render/render_getOptions.sh new file mode 100755 index 0000000..9b7977f --- /dev/null +++ b/tcar-scripts-render/render_getOptions.sh @@ -0,0 +1,80 @@ +#!/bin/bash +###################################################################### +# +# render_getOptions.sh -- This function interprets option arguments +# passed to `render' module and calls actions accordingly. +# +# Written by: +# * Alain Reguera Delagdo , 2009-2013 +# +# 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_getOptions { + + # Define short options we want to support. + local ARGSS="h::,v,f:" + + # Define long options we want to support. + local ARGSL="help::,version,filter:,no-locale" + + # Redefine arguments using getopt(1) command parser. + tcar_setModuleArguments + + # Reset positional parameters on this function, using output + # produced from (getopt) arguments parser. + eval set -- "${TCAR_MODULE_ARGUMENT}" + + # Look for options passed through command-line. + while true; do + case "${1}" in + + -h | --help ) + tcar_printHelp "${2}" + ;; + + -v | --version ) + tcar_printVersion "${TCAR_MODULE_NAME}" + ;; + + -f | --filter ) + TCAR_FLAG_FILTER="${2:-${TCAR_FLAG_FILTER}}" + shift 2 + ;; + + -- ) + # 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 using current positional parameters. Only + # paths should remain as arguments, at this point. + TCAR_MODULE_ARGUMENT="${@}" + +} diff --git a/tcar-scripts-render/render_setInstances.sh b/tcar-scripts-render/render_setInstances.sh new file mode 100755 index 0000000..83ad63c --- /dev/null +++ b/tcar-scripts-render/render_setInstances.sh @@ -0,0 +1,47 @@ +#!/bin/bash +###################################################################### +# +# render_setInstances.sh -- This function standardizes definition of +# file instances inside the render module. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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_setInstances { + + local FILE=${1} + local FILE_EXTENSION_PATTERN=${2:-asciidoc} + local FILE_EXTENSION_REPLACE=${3:-docbook} + + # Verify existence and extension of design model. + tcar_checkFiles -ef -m "\.${FILE_EXTENSION_PATTERN}$" "${FILE}" + + # Define file base name. + local FILE_BASENAME=$(basename ${FILE}) + + # Define absolute path to source instance. + SOURCE_INSTANCES[${COUNTER}]=$(tcar_getTemporalFile ${FILE_BASENAME}) + + # Define absolute path to target instance. + TARGET_INSTANCES[${COUNTER}]=$(tcar_getTemporalFile ${FILE_BASENAME} \ + | sed -r "s/\.${FILE_EXTENSION_PATTERN}$/.${FILE_EXTENSION_REPLACE}/") + +} diff --git a/tcar-scripts-render/render_setLocalizedXml.sh b/tcar-scripts-render/render_setLocalizedXml.sh new file mode 100755 index 0000000..8420583 --- /dev/null +++ b/tcar-scripts-render/render_setLocalizedXml.sh @@ -0,0 +1,101 @@ +#!/bin/bash +###################################################################### +# +# render_setLocalizedXml.sh -- This function standardizes the way +# (.po) translation files are applied to XML files (e.g., .docbook, +# .svg) in order to produce their related translated instances, used +# to expand translation markers and produce the final file format in +# different languages. 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. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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_setLocalizedXml { + + # Define absolute path to source instance. + local SOURCE="${1}" + + # Define absolute path to target instance. + local TARGET="${2}" + + # Verify source instance and the no-locale flag. When source + # instance already exists, don't create a new file for it. + # Instead, link it using a symbolic link. Be careful, such + # behavior only applies when the source file has no locale. + # Otherwise, the source file needs to go through the translation + # process inevitably. + if [[ -f ${SOURCE} ]];then + if [[ ${SOURCE} =~ "^${TCAR_SCRIPT_TEMPDIR}" ]];then + if [[ ${RENDER_FLAG_NO_LOCALE} == 'true' ]];then + tcar_checkFiles -i 'text/xml' ${SOURCE} + /bin/ln -s ${SOURCE} ${TARGET} + return + fi + elif [[ ${RENDER_FLAG_NO_LOCALE} == 'true' ]];then + tcar_printFile ${SOURCE} > ${TARGET} + tcar_checkFiles -i 'text/xml' ${TARGET} + return + fi + fi + + # Verify existence of translation files. + tcar_checkFiles -efi 'text/x-po' ${TRANSLATIONS[*]} + + # Define absolute path to translation instance. + local TRANSLATION=$(tcar_getTemporalFile "messages.po") + + # Combine available translations file into one translation + # instance. + msgcat -u -o ${TRANSLATION} ${TRANSLATIONS[*]} + + # Verify existence of final location. In case it doesn't exist, + # create it. + if [[ $(dirname ${RENDER_TARGET}) ]];then + mkdir -p $(dirname ${RENDER_TARGET}) + fi + + # Move to final location before processing source file in order + # for relative calls (e.g., image files) inside the source files + # can be found by xml2po and no warning be printed from it. + pushd $(dirname ${RENDER_TARGET}) > /dev/null + + # Create the localized instance from design model. + tcar_printFile ${SOURCE} | xml2po -a -l ${TCAR_SCRIPT_LANG_LC} \ + -p ${TRANSLATION} -o ${TARGET} - + + # Remove .xml2po.mo temporal file. + if [[ -f ./.xml2po.mo ]];then + rm ./.xml2po.mo + fi + + # Return to previous location. + popd > /dev/null + + # Remove instance created to store template translations. + if [[ -f ${TRANSLATION} ]];then + rm ${TRANSLATION} + fi + +}