diff --git a/Scripts/Bash/Cli/Functions/Identity/identity.sh b/Scripts/Bash/Cli/Functions/Identity/identity.sh deleted file mode 100644 index a0e8a8d..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# identity.sh -- This function initializes rendition variables and -# actions to centos-art.sh script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity { - - # Define default value to target flag. The target flag (--to) - # controls final destination used by copy related actions. - local FLAG_TO='' - - # Define release number flag. The relesase number flag (--release) - # specifies the release number identity images are rendered for. - # By default no release number is used. - local FLAG_RELEASE='' - - # Define architecture flag. The architecture flag (--architecture) - # specifies the architecture type identity images are rendered - # for. By default no architecture type is used. - local FLAG_ARCHITECTURE='' - - # Define theme model flag. The theme model flag (--theme-model) - # specifies the theme model used when no one is specified. - local FLAG_THEME_MODEL='Default' - - # Define convert-to flag. The convert-to flag (--convert-to) - # specifies the post-rendition image convertion action to perform - # upon PNG images. By default there is no image convertion. - local FLAG_CONVERT_TO='' - - # Define grouped-by flag. The grouped-by flag (--grouped-by) - # specifies the post-rendition image grouping action to perform - # upon images produced. By default there is no grouping action. - local FLAG_GROUPED_BY='' - - # Define rendition actions. - identity_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_checkSvgAbsref.sh b/Scripts/Bash/Cli/Functions/Identity/identity_checkSvgAbsref.sh deleted file mode 100755 index 7cb27bd..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_checkSvgAbsref.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# identity_checkSvgAbsref.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 that point to specific artistic motif background images. If -# such external files doesn't exist, print a message and stop script -# execution. We cannot continue without background information. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_checkSvgAbsref { - - local FILE='' - local ABSPATHS='' - - # Define absolute path of file we need to retrive absolute paths - # from. - FILE="$1" - - # Verify existence of file we need to retrive absolute paths from. - cli_checkFiles $FILE 'f' - - # Retrive absolute paths from file. - ABSPATHS=$(egrep '="/[a-zA-Z0-9_./-]+" ' $FILE \ - | sed -r "s/ /\n/g" | egrep '(sodipodi:absref|xlink:href)=' \ - | sed -r "s/.+=\"(\/.+)\".*/\1/" | sort | uniq) - - # Verify absolute paths retrived from file. - for FILE in $ABSPATHS;do - cli_checkFiles $FILE - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_convertDocbookToXhtml.sh b/Scripts/Bash/Cli/Functions/Identity/identity_convertDocbookToXhtml.sh deleted file mode 100755 index 1b91f2d..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_convertDocbookToXhtml.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -# identity_convertDocbookToXhtml.sh -- This function produces XHTML -# output from docbook template instance using XSL stylesheets as -# reference. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_convertDocbookToXhtml { - - # Print action message. - if [[ -f ${FILE}.xhtml ]];then - cli_printMessage "${FILE}.xhtml" 'AsUpdatingLine' - else - cli_printMessage "${FILE}.xhtml" 'AsCreatingLine' - fi - - # Define list of XSL stylesheets. - local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_convertHtmlToText.sh b/Scripts/Bash/Cli/Functions/Identity/identity_convertHtmlToText.sh deleted file mode 100755 index 5667719..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_convertHtmlToText.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# identity_convertHtmlToText.sh -- This function takes one HTML file -# and produces one plain-text file (i.e., without markup inside). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_convertHtml2Text { - - # Verify existence of HTML file. - cli_checkFiles ${FILE}.xhtml 'f' - - 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" 'AsUpdatingLine' - else - cli_printMessage "${FILE}.txt" 'AsCreatingLine' - fi - - # Convert from HTML to plain-text without markup. - ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt - - else - cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_convertPngTo.sh b/Scripts/Bash/Cli/Functions/Identity/identity_convertPngTo.sh deleted file mode 100644 index 1ce969a..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_convertPngTo.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# identity_convertPngTo.sh -- This function provides post-rendition -# action used to convert images from PNG to different image formats. -# This function uses ImageMagick command line image manipulation tool -# set to convert the base PNG image to as many formats as ImageMagick -# supports. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_convertPngTo { - - # Get image formats. - local FORMATS=$(identity_getConfigOption "$ACTION" '2-') - - # Check base file existence. - if [[ -f ${FILE}.png ]];then - - # Check image formats. - if [[ "$FORMATS" != "" ]];then - - # Loop through image formats and do format convertion using - # PNG file as base. - for FORMAT in $FORMATS;do - cli_printMessage "${FILE}.${FORMAT}" "AsSavedAsLine" - convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} - done - - fi - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_copy.sh b/Scripts/Bash/Cli/Functions/Identity/identity_copy.sh deleted file mode 100755 index b87d8bf..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_copy.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# identity_copy.sh -- This function duplicates rendition stuff. -# Rendition stuff is formed by design models, design images and -# pre-rendition configuration scripts (which includes translations -# files). This way, when we say to duplicate rendition stuff we are -# saying to duplicate these four directory structures (i.e., design -# models, design images, pre-rendition configuration scripts, and -# related translations files). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_copy { - - # Verify target directory. - cli_checkRepoDirTarget - - # Determine what directory structure we are duplicating. - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh deleted file mode 100644 index 4f0e5cd..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# -# identity_getActions.sh -- This function interprets arguments passed to -# render functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="render:,releasever:,basearch:,copy:,to:,convert-to:,group-by:,theme-model:" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - --releasever ) - FLAG_RELEASE="$2" - if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then - cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - shift 2 - ;; - - --basearch ) - FLAG_ARCHITECTURE="$2" - if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then - cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - shift 2 - ;; - - --to ) - FLAG_TO="$2" - shift 2 - ;; - - --convert-to ) - FLAG_CONVERT_TO="$2" - shift 2 - ;; - - --group-by ) - FLAG_GROUPED_BY="$2" - shift 2 - ;; - - --theme-model ) - FLAG_THEME_MODEL=$(cli_getRepoName "$2" 'd') - shift 2 - ;; - - * ) - # Break options loop. - break - esac - done - - # Read remaining arguments and build the action value from them. - # At this point all options should be processed. - for ACTIONVAL in "$@";do - - if [[ $ACTIONVAL == '--' ]];then - continue - fi - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_syncroRepoChanges - - # Execute action name. - eval ${FUNCNAM}_render - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getConfigOption.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getConfigOption.sh deleted file mode 100755 index 9edb5de..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getConfigOption.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# identity_getConfigOption.sh -- This function standardizes the way -# action values are retrived from pre-rendition configuration files. -# Use this function whenever you need to retrive action values from -# pre-rendition configuration script. -# -# Usage: VAR=$(identity_getConfigOption "ACTION" "FIELD") -# -# VAR is the name of the variable where we store the option named -# returned by identity_getConfigOption. -# -# ACTION is the string definition set in the pre-rendition -# configuration script that holds the action name and its options -# fields. -# -# FIELD is the field number in the action string we want to retrive -# option from. By default options start from third field on. The first -# field is reserved for the action type (i.e., POST or LAST), and the -# second field is reserved for the action itself (e.g., convertPngTo, -# renderSyslinux, renderKsplash, etc.). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_getConfigOption { - - local ACTION="$1" - local FIELD="$2" - local VALUE='' - - # Check action value. The action's value must be present in order - # for this function to work. It provides the string needed to - # retrive options from. - if [[ "$ACTION" == '' ]];then - cli_printMessage "`gettext "There is no action to work with."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Check field value. The field's value must match the cut's - # command specification of its -f option. - if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then - cli_printMessage "`gettext "The field specified is not valid."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Get option from pre-rendition configuration action definition. - VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) - - # Sanitate action value passed from pre-rendition configuration - # action definition. - VALUE=$(echo -n "${VALUE}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |,|;) *! !g' \ - | sed -r 's! *$!!g') - - # Output action value without trailing newline. - echo -n "$VALUE" - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh deleted file mode 100644 index 2149416..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# -# identity_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-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_getDirOutput { - - # Define base output directory using design model path as - # reference. By default rendered identity content is stored - # immediatly under identity entry structure, but if `Img/' - # directory exists use it instead. - OUTPUT=$(dirname $FILE | sed -r \ - -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ - -e "s!/Tpl!/Img!") - - # Redefine base output directory to introduce specific information - # like release number, architecture, etc. - OUTPUT=${OUTPUT}/${FLAG_RELEASE}/${FLAG_ARCHITECTURE} - - # Define whether to use or not locale-specific directory to store - # content, using current locale information as reference. As - # convenction, when we produce content in English language, we do - # not add a laguage-specific directory to organize content. - # However, when we produce language-specific content in a language - # different from English we do use language-specific directory to - # organize content. - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) - fi - - # Remove two or more consecutive slashes as well as the last - # remaining slash in the path. - OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') - - # Create final output directory, if it doesn't exist yet. - if [[ ! -d ${OUTPUT} ]];then - mkdir -p ${OUTPUT} - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh deleted file mode 100644 index fa63110..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# identity_getDirTemplate.sh -- This function re-defines absolute -# path to artwork's related design templates directory. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_getDirTemplate { - - # Initialize design models location using action value as - # reference. - TEMPLATE=$ACTIONVAL - - # Sanitate design models location. Be sure design models do - # always point to trunk directory structure. This is useful to let - # `centos-art.sh' script do rendition under branches directory - # structure, reusing design models under trunk directory - # structure. - TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") - - # Sanitate design models location using or not Tpl/ directory. - if [[ -d $TEMPLATE/Tpl ]];then - # Using Tpl/ directory is an obsolete practice that should be - # avoided. The concept of Tpl/ directory per artwork directory - # has been replaced by a common design model directory - # structure where we centralize design models for all - # different artistic motifs. However, there are some cases - # that we may need to use Tpl/ directory still, so we verify - # its existence and use it if present. - TEMPLATE=$TEMPLATE/Tpl - else - # Redefine design model location based on theme model - # (FLAG_THEME_MODEL) variable value. The theme model variable is - # defined in the associated pre-rendition configuration script - # and can be used to set which design model to use among a - # list of different design models that we can choose from. - TEMPLATE=$(echo "$TEMPLATE" \ - | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$FLAG_THEME_MODEL!") - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh b/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh deleted file mode 100755 index ed555be..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# identity_groupSimilarFiles.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-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_groupSimilarFiles { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMATS=$(identity_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 $SOURCE 'f' - - # 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" 'AsMovedToLine' - mv ${SOURCE} ${TARGET} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh b/Scripts/Bash/Cli/Functions/Identity/identity_render.sh deleted file mode 100755 index bb174fc..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/bash -# -# identity_render.sh -- This function performs base-rendition action -# for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_render { - - local -a FILES - local FILE='' - local OUTPUT='' - local TEMPLATE='' - local PARENTDIR='' - local EXTENSION='' - local TRANSLATION='' - local EXTERNALFILE='' - local EXTERNALFILES='' - local THIS_FILE_DIR='' - local NEXT_FILE_DIR='' - local COUNT=0 - - # Initialize post-rendition list of actions, the specification of - # what actions does centos-art execute immediatly after producing - # the base file in the same directory structure. - local -a POSTACTIONS - - # Initialize last-rendition list of actions, the specification of - # what actions does centos-art execute once all base files in the - # same directory structure have been produced, this is just - # immediatly before passing to produce the next directory - # structure. - local -a LASTACTIONS - - # Check theme model directory structure. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' - - # Verify post-rendition actions passed from command-line and add - # them, if any, to post-rendition list of actions. - if [[ $FLAG_GROUPED_BY != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="groupSimilarFiles:${FLAG_GROUPED_BY}" - fi - - # Define the extension pattern for template files. This is the - # file extensions that centos-art will look for in order to build - # the list of files to process. The list of files to process - # contains the files that match this extension pattern. - EXTENSION='\.(svgz|svg|docbook)' - - # Redefine parent directory for current workplace. - PARENTDIR=$(basename "${ACTIONVAL}") - - # Define base location of template files. - identity_getDirTemplate - - # Define list of files to process as array variable. This make - # posible to realize verifications like: is the current base - # directory equal to the next one in the list of files to process? - # This is used to know when centos-art.sh is leaving a directory - # structure and entering into another. This information is - # required in order for centos-art.sh to know when to apply - # last-rendition actions. - for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do - FILES[((++${#FILES[*]}))]=$FILE - done - - # Set action preamble. - cli_printActionPreamble "${FILES[*]}" '' '' - - # Start processing the base rendition list of FILES. Fun part - # approching :-). - 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 '-' 'AsSeparatorLine' - - # Define final location of translation file. - TRANSLATION=$(dirname $FILE \ - | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po - - # Print final location of translation file. - if [[ ! -f "$TRANSLATION" ]];then - cli_printMessage "`gettext "None"`" "AsTranslationLine" - else - cli_printMessage "$TRANSLATION" 'AsTranslationLine' - fi - - # Define final location of template file. - TEMPLATE=${FILE} - - # Print final location of template file. - if [[ ! -f "$TEMPLATE" ]];then - cli_printMessage "`gettext "None"`" "AsDesignLine" - else - cli_printMessage "$TEMPLATE" 'AsDesignLine' - fi - - # Define final location of output directory. - identity_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). - # - # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg - # -------------------------^| the |^------------^ - # variable path | common | common path - # -------------------------v| point | v------------v - # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png - # - # What we do here is remove the varibale path, the common - # point, and the file extension parts in the string holding - # the path retrived from design models directory structure. - # Then we use the common path as relative path to store the - # 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 renderImage function, 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/${EXTENSION}$//") - - # Define absolute path to final file (without extension). - FILE=${OUTPUT}/$(basename "${FILE}") - - # Define instance name from design model. - INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) - - # Verify translation file existence and create template - # instance accordingly. - if [[ -f ${TRANSLATION} ]];then - - # Create translated instance from design model. - /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} - - # Remove .xml2po.mo temporal file. - if [[ -f ${PWD}/.xml2po.mo ]];then - rm ${PWD}/.xml2po.mo - fi - - else - # Create non-translated instance form design model. - /bin/cp ${TEMPLATE} ${INSTANCE} - fi - - # Apply translation markers replacements to template instance. - cli_replaceTMarkers ${INSTANCE} - - # Verify the extension of template instance and render content - # accordingly. - if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then - - # Perform base-rendition action for svg files. - identity_renderSvg - - # Perform post-rendition action for svg files. - identity_renderSvgPostActions - - # Perform last-rendition action for svg files. - identity_renderSvgLastActions - - elif [[ $INSTANCE =~ '\.docbook$' ]];then - - # Perform base-rendition action for docbook files. - identity_renderDocbook - - # Perform post-rendition action for docbook files. - #identity_renderDocbookPostActions - - # Perform base-rendition action for docbook files. - #identity_renderDocbookLastActions - - else - cli_printMessage "`gettext "The template file you try to render is not supported yet."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Remove template instance. - if [[ -f $INSTANCE ]];then - rm $INSTANCE - fi - - # Perform post-rendition actions for all files. - identity_renderPostActions - - # Perform last-rendition actions for all files. - identity_renderLastActions - - # Increment file counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderBrands.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderBrands.sh deleted file mode 100644 index 16a1049..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderBrands.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# identity_renderBrands.sh -- This function provides last-rendition -# actions to produce CentOS brands. This function takes both The -# CentOS Symbol and The CentOS Type images and produces variation of -# them in different dimensions and formats using ImageMagick tool-set. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderBrands { - - local SOURCEFILE='' - local TARGETDIR='' - local TARGETFILE='' - local NEWFILE='' - - # Define absolute path to image file. - local FILE="$1" - - # Define height dimensions you want to produce brands for. - 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 FORMATS="png xpm pdf jpg tif" - - # Redefine absolute path to directory where final brand images - # will be stored. Notice how both final image directory and design - # model have the same name, this is intentional in order to keep - # images and design models related and organized inside their own - # directory structures. - local DIRNAME=$(cli_getRepoName "$FILE" 'd')/$(cli_getRepoName "$FILE" 'fd') - - # Check directory where final brand images will be stored. - if [[ ! -d $DIRNAME ]];then - mkdir -p ${DIRNAME} - fi - - for SIZE in ${SIZES};do - - # Redefine name of new file. - NEWFILE=${DIRNAME}/${SIZE} - - for FORMAT in ${FORMATS};do - - # Output action information. - cli_printMessage "${NEWFILE}.${FORMAT}" "AsCreatingLine" - - # Convert and resize to create new file. - convert -resize x${SIZE} ${FILE}.png ${NEWFILE}.${FORMAT} - - done - - # Create logo copy in 2 colors. - cli_printMessage "${NEWFILE}.xbm (`gettext "2 colors grayscale"`)" "AsCreatingLine" - convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${NEWFILE}.xbm - - # Create logo copy in emboss effect. - cli_printMessage "${NEWFILE}-emboss.png" "AsCreatingLine" - convert -resize x${SIZE} -emboss 1 ${FILE}.png ${NEWFILE}-emboss.png - - done - - # Output division line. - cli_printMessage '-' 'AsSeparatorLine' -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh deleted file mode 100755 index f2935a1..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/bash -# -# identity_renderDm.sh -- This function collects Display Manager (DM) -# required files and creates a tar.gz package that groups them all -# together. Use this function as last-rendition action for Gdm and Kdm -# base-rendition actions. -# -# Usage: -# -# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION' -# -# Where: -# -# TYPE can be either `Gdm' or `Kdm'. These values correspond to the -# directory names used to store related design models. -# -# RESOLUTION represents the screen resolution tar.gz files are -# produced for (e.g., 800x600, 1024x768, 2048x1536, etc.). -# -# In order to produce tar.gz files correctly, both screen resolution -# definition inside pre-rendition configuration script and background -# name inside theme directory structure need to match one another. If -# one screen resolution is defined correctly, but there is no -# background information for it, the related tar.gz file is not -# produced and the next file in the list of files to process is -# evaluated. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderDm { - - local -a SRC - local -a DST - local DM='' - local TGZ='' - local COUNT=0 - local RESOLUTION='' - local RESOLUTIONS='' - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Get display manager passed from render.conf.sh pre-rendition - # configuration script. - DM=$(identity_getConfigOption "${ACTION}" '2') - - # Sanitate display manager passed from render.conf.sh - # pre-rendition configuration script. Whatever value be retrived - # as display manager configuration option is converted to - # uppercase in order to match either Gdm or Kdm design model - # directory structures. - DM=$(cli_getRepoName "$DM" 'd') - - # Get screen resolutions passed from render.conf.sh pre-rendition - # configuration script. - RESOLUTIONS=$(identity_getConfigOption "${ACTION}" '3') - - # Check screen resolutions passed from render.conf.sh - # pre-rendition configuration script. - if [[ "$RESOLUTIONS" == '' ]];then - cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine' - cli_printMessage $(caller) "AsToKnowMoreLine" - fi - - # Define source files using absolute paths. - SRC[0]=$(cli_getRepoTLDir)/Identity/Brands/Img/Symbol/48.png - SRC[1]=${OUTPUT}/release.png - SRC[2]=${OUTPUT}/screenshot.png - SRC[3]=$(dirname $TEMPLATE)/GdmGreeterTheme.xml - SRC[4]=$(dirname $TEMPLATE)/GdmGreeterTheme.desktop - SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png - SRC[6]=$(dirname $TEMPLATE)/icon-language.png - SRC[7]=$(dirname $TEMPLATE)/icon-reboot.png - SRC[8]=$(dirname $TEMPLATE)/icon-session.png - SRC[9]=$(dirname $TEMPLATE)/icon-shutdown.png - - # Define name used as temporal holder to build tar.gz file. - TGZ=$(cli_getPathComponent '--theme-name') - - # Define target files using relative paths. - DST[0]=${TGZ}/centos-symbol.png - DST[1]=${TGZ}/centos-release.png - DST[2]=${TGZ}/screenshot.png - DST[3]=${TGZ}/${TGZ}.xml - DST[4]=${TGZ}/GdmGreeterTheme.desktop - DST[5]=${TGZ}/background.png - DST[6]=${TGZ}/icon-language.png - DST[7]=${TGZ}/icon-reboot.png - DST[8]=${TGZ}/icon-session.png - DST[9]=${TGZ}/icon-shutdown.png - - # Move into the working directory. - pushd ${OUTPUT} > /dev/null - - # Create directory used as temporal holder to build tar.gz file. - if [[ ! -d ${TGZ} ]];then - mkdir ${TGZ} - fi - - for RESOLUTION in $RESOLUTIONS;do - - while [[ $COUNT -lt ${#SRC[*]} ]];do - - if [[ $COUNT -eq 5 ]];then - - # Redefine background information using resolution as - # reference. Avoid concatenation. - SRC[$COUNT]=$(echo "${SRC[$COUNT]}" | cut -d/ -f-13)/${RESOLUTION}-final.png - - # If background information defined inside - # pre-rendition configuration script doesn't match - # background information inside theme-specific - # backgrounds directory structure, try the next - # background definition. - if [[ ! -f ${SRC[$COUNT]} ]];then - continue 2 - fi - - elif [[ $COUNT =~ '^[6-9]$' ]];then - - # If display manager is Kdm, then increment counter and - # resume the next iteration. Icons aren't used on Kdm, - # so there's no need to have them inside it. - if [[ $DM =~ '^Kdm$' ]];then - COUNT=$(($COUNT + 1)) - continue - fi - - fi - - # Check existence of source files. - cli_checkFiles ${SRC[$COUNT]} - - # Copy files from source to target location. - cp ${SRC[$COUNT]} ${DST[$COUNT]} - - # Replace common translation markers from design model - # files with appropriate information. - if [[ $COUNT =~ '^(3|4)$' ]];then - cli_replaceTMarkers "${DST[$COUNT]}" - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Reset counter. - COUNT=0 - - # Print action message. - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" "AsCreatingLine" - - # Create tar.gz file. - tar -czf "${RESOLUTION}.tar.gz" $TGZ - - done - - # Remove directory used as temporal holder to build targ.gz - # file. - rm -r $TGZ - - # Remove release-specific images. - cli_printMessage "${SRC[1]}" "AsDeletingLine" - rm ${SRC[1]} - cli_printMessage "${SRC[2]}" "AsDeletingLine" - rm ${SRC[2]} - - # Return to where we were initially. - popd > /dev/null - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh deleted file mode 100755 index 3670891..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# identity_renderDocbook.sh -- This function performs base-rendition -# action for DocBook files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderDocbook { - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - identity_convertDocbookToXhtml - - # Produce plaintext output from html outout. - identity_convertHtml2Text - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderGrub.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderGrub.sh deleted file mode 100644 index c9ebecb..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderGrub.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# identity_renderGrub.sh -- This function provides post-rendition -# action used to produce GRUB images. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderGrub { - - # Define 16 colors images default file name prefix. - local PREFIX='-14c' - - # 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=$(identity_getConfigOption "$ACTION" '2-') - - # 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 files which - # do not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # 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."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - done - - # Define motif's palette location. - local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Colors - - # Define the Netpbm color palettes used when reducing colors. - # These palettes should be 14 colors based. For more information - # on this see the GRUB's documentation. - local PALETTE_PPM=$PALETTES/grub.ppm - - # Print which palette of colors centos-art.sh script is using to - # produce grub content. This is relevant in order to know if we - # are using whether trunk or branches palette of colors. - cli_printMessage "$PALETTE_PPM" 'AsPaletteLine' - - # Check GRUB's palettes existence: If there is no palette assume - # that this is the first time you are rendition GRUB images. If - # that is the case the script will provide you with the PNG format - # which should be used as base to produce (using GIMP) the .gpl - # palette. The .gpl palette information is used to produced - # (using GIMP) the colormap (.ppm) which is used to automate the - # GRUB's 14 colors image (splash.png) rendition. If there is no - # palette available, do not apply color reduction, show a message, - # and continue. - cli_checkFiles $PALETTE_PPM - - # Create Netpbm superformat (PNM). PNM file is created from the - # PNG image rendered previously. PNM is a common point for image - # manipulation using Netpbm tools. - cli_printMessage "${FILE}.pnm" "AsSavedAsLine" - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Reduce colors as specified in ppm palette of colors. - cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Create the 14 colors xpm.gz file. - cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine" - ppmtoxpm \ - < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ - && gzip --force ${FILE}.xpm \ - && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh deleted file mode 100755 index e08d197..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# -# identity_renderKsplash.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-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderKsplash { - - local -a SRC - local -a DST - local FONT='' - local COUNT=0 - - # Define font used to print bottom splash message. - FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf - - # Check existence of font file. - cli_checkFiles "$FONT" 'f' - - # 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 "${SRC[@]}" 'f' - - # 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" 'AsCreatingLine' - - # 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_replaceTMarkers "${DST[4]}" - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh deleted file mode 100755 index 02f1930..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# identity_renderLastActions.sh -- This function performs -# last-rendition actions for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderLastActions { - - local ACTION='' - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then - - # 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 last-rendition actions for the current directory - # structure. - for ACTION in "${LASTACTIONS[@]}"; do - - case "${ACTION}" in - - groupSimilarFiles:* ) - identity_groupSimilarFiles - ;; - esac - - done - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh deleted file mode 100755 index 2388b83..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# identity_renderPostActions.sh -- This function performs -# post-rendition actions for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderPostActions { - - local ACTION='' - - for ACTION in "${POSTACTIONS[@]}"; do - - case "${ACTION}" in - - groupSimilarFiles:* ) - identity_groupSimilarFiles - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh deleted file mode 100644 index 01b6558..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# identity_renderSvg.sh -- This function performs base-rendition -# action for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderSvg { - - # Define export id used inside design templates. This value - # defines the design area we want to export. - local EXPORTID='CENTOSARTWORK' - - # Check export id inside design templates. - grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null - if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" - cli_printMessage '-' 'AsSeparatorLine' - continue - fi - - # Check existence of external files. Inside design templates and - # their instances, external files are used to refere 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. - identity_checkSvgAbsref "$INSTANCE" - - # Render template instance using inkscape. Modify the inkscape - # output to reduce the amount of characters used in description - # column at final output. - cli_printMessage "$(inkscape $INSTANCE \ - --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ - -e "s!Area !`gettext "Area"`: !" \ - -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ - -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" 'AsRegularLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh deleted file mode 100644 index a9a0c43..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# identity_renderSvgLastActions.sh -- This function performs -# last-rendition actions for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderSvgLastActions { - - local ACTION='' - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then - return - fi - - # Define SVG-directory-specific last-rendition actions processing - # as local to this function. Otherwise it may confuse command-line - # last-rendition actions. - local -a LASTACTIONS - - # Add directory-specific last-rendition actions to the list of - # post actions and last 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 option - # combinations each time you need to produce images inside the - # repository. - if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Gdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Kdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderKsplash' - fi - - # 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 - # last-rendition actions for the current directory structure. - for ACTION in "${LASTACTIONS[@]}"; do - - case "${ACTION}" in - - renderKsplash ) - identity_renderKsplash - ;; - - renderDm:* ) - identity_renderDm - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh deleted file mode 100644 index 1b1acaa..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# -# identity_renderSvgPostActions.sh -- This function performs -# post-rendition actions for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderSvgPostActions { - - local ACTION='' - - # Define SVG-directory-specific post-rendition actions processing - # as local to this function. Otherwise it may confuse command-line - # post-rendition actions. - local -a POSTACTIONS - - # Execute SVG directory-specific post-rendition actions to the - # list of post actions and last 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 option - # combinations each time you need to produce images inside the - # repository. - if [[ $TEMPLATE =~ "Distro/Backgrounds/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo: jpg' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupSimilarFiles: png jpg' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Syslinux/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux:-floyd' - elif [[ $TEMPLATE =~ "Grub" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub:-floyd' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderKsplash' - fi - - # Execute SVG command-line-specific post-rendition actions passed - # from command-line and add them, if any, to post-rendition list - # of actions. - if [[ $FLAG_CONVERT_TO != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngTo:${FLAG_CONVERT_TO}" - fi - - for ACTION in "${POSTACTIONS[@]}"; do - - case "${ACTION}" in - - convertPngTo:* ) - identity_convertPngTo - ;; - - renderSyslinux* ) - identity_renderSyslinux - ;; - - renderGrub* ) - identity_renderGrub - ;; - - renderBrands ) - identity_renderBrands - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSyslinux.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSyslinux.sh deleted file mode 100755 index 1346ac3..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSyslinux.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# -# identity_renderSyslinux.sh -- This function provides post-rendition -# action used to produce syslinux images. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderSyslinux { - - # Define 16 colors images default file name prefix. - local PREFIX='-16c' - - # 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=$(identity_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 $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - done - - # 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 motif's palette location. - local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Colors - - # Define the Netpbm color palette used when reducing colors. This - # palette should be 16 colors based. For more information on this - # see the isolinux documentation. - local PALETTE_PPM=$PALETTES/syslinux.ppm - - # Define hexadecimal color information used by ppmtolss16. Color - # information and order used on PALETTE_HEX and PALETTE_PPM should - # match exactly. - local PALETTE_HEX=$PALETTES/syslinux.hex - - # Print which palette of colors centos-art.sh script is using to - # produce grub content. This is relevant in order to know if we - # are using whether trunk or branches palette of colors. - cli_printMessage "$PALETTE_PPM" 'AsPaletteLine' - cli_printMessage "$PALETTE_HEX" 'AsPaletteLine' - - # Check syslinux's palettes existence: If there is no palette - # assume that this is the first time you are rendition syslinux - # images. If that is the case the script will provide you with the - # PNG format which should be used as base to produce (using GIMP) - # the .gpl palette. The .gpl palette information is used to - # produced (using GIMP) the colormap (.ppm) which is used to - # automate the syslinux's 16 colors image (syslinux-splash.png) - # rendition. If there is no palette available, do not apply color - # reduction, show a message, and continue. - cli_checkFiles $PALETTE_PPM - cli_checkFiles $PALETTE_HEX - - # Create Netpbm superformat (PNM). PNM file is created from the - # PNG image rendered previously. PNM is a common point for image - # manipulation using Netpbm tools. - cli_printMessage "${FILE}.pnm" "AsSavedAsLine" - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Reduce colors. Here we use the Netpbm color $PALETTE_PPM 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" "AsSavedAsLine" - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm - - # Create LSS16 image. As specified in isolinux documentation the - # background color should be indexed on position 0 and forground - # in position 7 (see /usr/share/doc/syslinux-X.XX/isolinux.doc). - # This order of colors is specified in $PALETTE_PPM and redefined - # here again for the LSS16 image format. Both $PALETTE_PPM and - # LSS16 color map redefinition ($PALETTE_HEX) should have the same - # colors and index order. PALETTE_HEX should return just one line - # with the color information as described in isolinux - # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the - # same line]). - cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine" - PALETTE_HEX=$(cat $PALETTE_HEX | tr "\n" ' ' | tr -s ' ') - ppmtolss16 $PALETTE_HEX \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss - - # Create the 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" "AsSavedAsLine" - lss16toppm -map \ - < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Create the 16 colors PNG image. - cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine" - pnmtopng -verbose -palette=$PALETTE_PPM \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/render.sh b/Scripts/Bash/Cli/Functions/Identity/render.sh new file mode 100644 index 0000000..c729696 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# render.sh -- This function initializes rendition variables and +# actions to centos-art.sh script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render { + + # Define default value to target flag. The target flag (--to) + # controls final destination used by copy related actions. + local FLAG_TO='' + + # Define release number flag. The relesase number flag (--release) + # specifies the release number identity images are rendered for. + # By default no release number is used. + local FLAG_RELEASE='' + + # Define architecture flag. The architecture flag (--architecture) + # specifies the architecture type identity images are rendered + # for. By default no architecture type is used. + local FLAG_ARCHITECTURE='' + + # Define theme model flag. The theme model flag (--theme-model) + # specifies the theme model used when no one is specified. + local FLAG_THEME_MODEL='Default' + + # Define convert-to flag. The convert-to flag (--convert-to) + # specifies the post-rendition image convertion action to perform + # upon PNG images. By default there is no image convertion. + local FLAG_CONVERT_TO='' + + # Define grouped-by flag. The grouped-by flag (--grouped-by) + # specifies the post-rendition image grouping action to perform + # upon images produced. By default there is no grouping action. + local FLAG_GROUPED_BY='' + + # Define rendition actions. + render_getActions + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_checkSvgAbsref.sh b/Scripts/Bash/Cli/Functions/Identity/render_checkSvgAbsref.sh new file mode 100755 index 0000000..7f8252b --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_checkSvgAbsref.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# render_checkSvgAbsref.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 that point to specific artistic motif background images. If +# such external files doesn't exist, print a message and stop script +# execution. We cannot continue without background information. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_checkSvgAbsref { + + local FILE='' + local ABSPATHS='' + + # Define absolute path of file we need to retrive absolute paths + # from. + FILE="$1" + + # Verify existence of file we need to retrive absolute paths from. + cli_checkFiles $FILE 'f' + + # Retrive absolute paths from file. + ABSPATHS=$(egrep '="/[a-zA-Z0-9_./-]+" ' $FILE \ + | sed -r "s/ /\n/g" | egrep '(sodipodi:absref|xlink:href)=' \ + | sed -r "s/.+=\"(\/.+)\".*/\1/" | sort | uniq) + + # Verify absolute paths retrived from file. + for FILE in $ABSPATHS;do + cli_checkFiles $FILE + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_convertDocbookToXhtml.sh b/Scripts/Bash/Cli/Functions/Identity/render_convertDocbookToXhtml.sh new file mode 100755 index 0000000..e5f818a --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_convertDocbookToXhtml.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# render_convertDocbookToXhtml.sh -- This function produces XHTML +# output from docbook template instance using XSL stylesheets as +# reference. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertDocbookToXhtml { + + # Print action message. + if [[ -f ${FILE}.xhtml ]];then + cli_printMessage "${FILE}.xhtml" 'AsUpdatingLine' + else + cli_printMessage "${FILE}.xhtml" 'AsCreatingLine' + fi + + # Define list of XSL stylesheets. + local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_convertHtmlToText.sh b/Scripts/Bash/Cli/Functions/Identity/render_convertHtmlToText.sh new file mode 100755 index 0000000..a84adbf --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_convertHtmlToText.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# render_convertHtmlToText.sh -- This function takes one HTML file +# and produces one plain-text file (i.e., without markup inside). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertHtml2Text { + + # Verify existence of HTML file. + cli_checkFiles ${FILE}.xhtml 'f' + + 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" 'AsUpdatingLine' + else + cli_printMessage "${FILE}.txt" 'AsCreatingLine' + fi + + # Convert from HTML to plain-text without markup. + ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt + + else + cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_convertPngTo.sh b/Scripts/Bash/Cli/Functions/Identity/render_convertPngTo.sh new file mode 100644 index 0000000..691fadb --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_convertPngTo.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# render_convertPngTo.sh -- This function provides post-rendition +# action used to convert images from PNG to different image formats. +# This function uses ImageMagick command line image manipulation tool +# set to convert the base PNG image to as many formats as ImageMagick +# supports. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertPngTo { + + # Get image formats. + local FORMATS=$(render_getConfigOption "$ACTION" '2-') + + # Check base file existence. + if [[ -f ${FILE}.png ]];then + + # Check image formats. + if [[ "$FORMATS" != "" ]];then + + # Loop through image formats and do format convertion using + # PNG file as base. + for FORMAT in $FORMATS;do + cli_printMessage "${FILE}.${FORMAT}" "AsSavedAsLine" + convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} + done + + fi + + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_copy.sh b/Scripts/Bash/Cli/Functions/Identity/render_copy.sh new file mode 100755 index 0000000..e54abe9 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_copy.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# render_copy.sh -- This function duplicates rendition stuff. +# Rendition stuff is formed by design models, design images and +# pre-rendition configuration scripts (which includes translations +# files). This way, when we say to duplicate rendition stuff we are +# saying to duplicate these four directory structures (i.e., design +# models, design images, pre-rendition configuration scripts, and +# related translations files). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_copy { + + # Verify target directory. + cli_checkRepoDirTarget + + # Determine what directory structure we are duplicating. + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_do.sh b/Scripts/Bash/Cli/Functions/Identity/render_do.sh new file mode 100755 index 0000000..584e66a --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_do.sh @@ -0,0 +1,238 @@ +#!/bin/bash +# +# render_do.sh -- This function performs base-rendition action +# for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_do { + + local -a FILES + local FILE='' + local OUTPUT='' + local TEMPLATE='' + local PARENTDIR='' + local EXTENSION='' + local TRANSLATION='' + local EXTERNALFILE='' + local EXTERNALFILES='' + local THIS_FILE_DIR='' + local NEXT_FILE_DIR='' + local COUNT=0 + + # Initialize post-rendition list of actions, the specification of + # what actions does centos-art execute immediatly after producing + # the base file in the same directory structure. + local -a POSTACTIONS + + # Initialize last-rendition list of actions, the specification of + # what actions does centos-art execute once all base files in the + # same directory structure have been produced, this is just + # immediatly before passing to produce the next directory + # structure. + local -a LASTACTIONS + + # Check theme model directory structure. + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' + + # Verify post-rendition actions passed from command-line and add + # them, if any, to post-rendition list of actions. + if [[ $FLAG_GROUPED_BY != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="groupSimilarFiles:${FLAG_GROUPED_BY}" + fi + + # Define the extension pattern for template files. This is the + # file extensions that centos-art will look for in order to build + # the list of files to process. The list of files to process + # contains the files that match this extension pattern. + EXTENSION='\.(svgz|svg|docbook)' + + # Redefine parent directory for current workplace. + PARENTDIR=$(basename "${ACTIONVAL}") + + # Define base location of template files. + render_getDirTemplate + + # Define list of files to process as array variable. This make + # posible to realize verifications like: is the current base + # directory equal to the next one in the list of files to process? + # This is used to know when centos-art.sh is leaving a directory + # structure and entering into another. This information is + # required in order for centos-art.sh to know when to apply + # last-rendition actions. + for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do + FILES[((++${#FILES[*]}))]=$FILE + done + + # Set action preamble. + cli_printActionPreamble "${FILES[*]}" '' '' + + # Start processing the base rendition list of FILES. Fun part + # approching :-). + 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 '-' 'AsSeparatorLine' + + # Define final location of translation file. + TRANSLATION=$(dirname $FILE \ + | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po + + # Print final location of translation file. + if [[ ! -f "$TRANSLATION" ]];then + cli_printMessage "`gettext "None"`" "AsTranslationLine" + else + cli_printMessage "$TRANSLATION" 'AsTranslationLine' + fi + + # Define final location of template file. + TEMPLATE=${FILE} + + # Print final location of template file. + if [[ ! -f "$TEMPLATE" ]];then + cli_printMessage "`gettext "None"`" "AsDesignLine" + else + cli_printMessage "$TEMPLATE" 'AsDesignLine' + fi + + # 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). + # + # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg + # -------------------------^| the |^------------^ + # variable path | common | common path + # -------------------------v| point | v------------v + # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png + # + # What we do here is remove the varibale path, the common + # point, and the file extension parts in the string holding + # the path retrived from design models directory structure. + # Then we use the common path as relative path to store the + # 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 renderImage function, 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/${EXTENSION}$//") + + # Define absolute path to final file (without extension). + FILE=${OUTPUT}/$(basename "${FILE}") + + # Define instance name from design model. + INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) + + # Verify translation file existence and create template + # instance accordingly. + if [[ -f ${TRANSLATION} ]];then + + # Create translated instance from design model. + /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} + + # Remove .xml2po.mo temporal file. + if [[ -f ${PWD}/.xml2po.mo ]];then + rm ${PWD}/.xml2po.mo + fi + + else + # Create non-translated instance form design model. + /bin/cp ${TEMPLATE} ${INSTANCE} + fi + + # Apply translation markers replacements to template instance. + cli_replaceTMarkers ${INSTANCE} + + # Verify the extension of template instance and render content + # accordingly. + if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then + + # Perform base-rendition action for svg files. + render_doSvg + + # Perform post-rendition action for svg files. + render_doSvgPostActions + + # Perform last-rendition action for svg files. + render_doSvgLastActions + + elif [[ $INSTANCE =~ '\.docbook$' ]];then + + # Perform base-rendition action for docbook files. + render_doDocbook + + # Perform post-rendition action for docbook files. + #render_doDocbookPostActions + + # Perform base-rendition action for docbook files. + #render_doDocbookLastActions + + else + cli_printMessage "`gettext "The template file you try to render is not supported yet."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Remove template instance. + if [[ -f $INSTANCE ]];then + rm $INSTANCE + fi + + # Perform post-rendition actions for all files. + render_doPostActions + + # Perform last-rendition actions for all files. + render_doLastActions + + # Increment file counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doBrands.sh b/Scripts/Bash/Cli/Functions/Identity/render_doBrands.sh new file mode 100644 index 0000000..f9afa94 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doBrands.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# render_doBrands.sh -- This function provides last-rendition +# actions to produce CentOS brands. This function takes both The +# CentOS Symbol and The CentOS Type images and produces variation of +# them in different dimensions and formats using ImageMagick tool-set. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doBrands { + + local SOURCEFILE='' + local TARGETDIR='' + local TARGETFILE='' + local NEWFILE='' + + # Define absolute path to image file. + local FILE="$1" + + # Define height dimensions you want to produce brands for. + 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 FORMATS="png xpm pdf jpg tif" + + # Redefine absolute path to directory where final brand images + # will be stored. Notice how both final image directory and design + # model have the same name, this is intentional in order to keep + # images and design models related and organized inside their own + # directory structures. + local DIRNAME=$(cli_getRepoName "$FILE" 'd')/$(cli_getRepoName "$FILE" 'fd') + + # Check directory where final brand images will be stored. + if [[ ! -d $DIRNAME ]];then + mkdir -p ${DIRNAME} + fi + + for SIZE in ${SIZES};do + + # Redefine name of new file. + NEWFILE=${DIRNAME}/${SIZE} + + for FORMAT in ${FORMATS};do + + # Output action information. + cli_printMessage "${NEWFILE}.${FORMAT}" "AsCreatingLine" + + # Convert and resize to create new file. + convert -resize x${SIZE} ${FILE}.png ${NEWFILE}.${FORMAT} + + done + + # Create logo copy in 2 colors. + cli_printMessage "${NEWFILE}.xbm (`gettext "2 colors grayscale"`)" "AsCreatingLine" + convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${NEWFILE}.xbm + + # Create logo copy in emboss effect. + cli_printMessage "${NEWFILE}-emboss.png" "AsCreatingLine" + convert -resize x${SIZE} -emboss 1 ${FILE}.png ${NEWFILE}-emboss.png + + done + + # Output division line. + cli_printMessage '-' 'AsSeparatorLine' +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doDm.sh b/Scripts/Bash/Cli/Functions/Identity/render_doDm.sh new file mode 100755 index 0000000..ab38838 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doDm.sh @@ -0,0 +1,191 @@ +#!/bin/bash +# +# render_doDm.sh -- This function collects Display Manager (DM) +# required files and creates a tar.gz package that groups them all +# together. Use this function as last-rendition action for Gdm and Kdm +# base-rendition actions. +# +# Usage: +# +# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION' +# +# Where: +# +# TYPE can be either `Gdm' or `Kdm'. These values correspond to the +# directory names used to store related design models. +# +# RESOLUTION represents the screen resolution tar.gz files are +# produced for (e.g., 800x600, 1024x768, 2048x1536, etc.). +# +# In order to produce tar.gz files correctly, both screen resolution +# definition inside pre-rendition configuration script and background +# name inside theme directory structure need to match one another. If +# one screen resolution is defined correctly, but there is no +# background information for it, the related tar.gz file is not +# produced and the next file in the list of files to process is +# evaluated. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doDm { + + local -a SRC + local -a DST + local DM='' + local TGZ='' + local COUNT=0 + local RESOLUTION='' + local RESOLUTIONS='' + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Get display manager passed from render.conf.sh pre-rendition + # configuration script. + DM=$(render_getConfigOption "${ACTION}" '2') + + # Sanitate display manager passed from render.conf.sh + # pre-rendition configuration script. Whatever value be retrived + # as display manager configuration option is converted to + # uppercase in order to match either Gdm or Kdm design model + # directory structures. + DM=$(cli_getRepoName "$DM" 'd') + + # Get screen resolutions passed from render.conf.sh pre-rendition + # configuration script. + RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') + + # Check screen resolutions passed from render.conf.sh + # pre-rendition configuration script. + if [[ "$RESOLUTIONS" == '' ]];then + cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine' + cli_printMessage $(caller) "AsToKnowMoreLine" + fi + + # Define source files using absolute paths. + SRC[0]=$(cli_getRepoTLDir)/Identity/Brands/Img/Symbol/48.png + SRC[1]=${OUTPUT}/release.png + SRC[2]=${OUTPUT}/screenshot.png + SRC[3]=$(dirname $TEMPLATE)/GdmGreeterTheme.xml + SRC[4]=$(dirname $TEMPLATE)/GdmGreeterTheme.desktop + SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png + SRC[6]=$(dirname $TEMPLATE)/icon-language.png + SRC[7]=$(dirname $TEMPLATE)/icon-reboot.png + SRC[8]=$(dirname $TEMPLATE)/icon-session.png + SRC[9]=$(dirname $TEMPLATE)/icon-shutdown.png + + # Define name used as temporal holder to build tar.gz file. + TGZ=$(cli_getPathComponent '--theme-name') + + # Define target files using relative paths. + DST[0]=${TGZ}/centos-symbol.png + DST[1]=${TGZ}/centos-release.png + DST[2]=${TGZ}/screenshot.png + DST[3]=${TGZ}/${TGZ}.xml + DST[4]=${TGZ}/GdmGreeterTheme.desktop + DST[5]=${TGZ}/background.png + DST[6]=${TGZ}/icon-language.png + DST[7]=${TGZ}/icon-reboot.png + DST[8]=${TGZ}/icon-session.png + DST[9]=${TGZ}/icon-shutdown.png + + # Move into the working directory. + pushd ${OUTPUT} > /dev/null + + # Create directory used as temporal holder to build tar.gz file. + if [[ ! -d ${TGZ} ]];then + mkdir ${TGZ} + fi + + for RESOLUTION in $RESOLUTIONS;do + + while [[ $COUNT -lt ${#SRC[*]} ]];do + + if [[ $COUNT -eq 5 ]];then + + # Redefine background information using resolution as + # reference. Avoid concatenation. + SRC[$COUNT]=$(echo "${SRC[$COUNT]}" | cut -d/ -f-13)/${RESOLUTION}-final.png + + # If background information defined inside + # pre-rendition configuration script doesn't match + # background information inside theme-specific + # backgrounds directory structure, try the next + # background definition. + if [[ ! -f ${SRC[$COUNT]} ]];then + continue 2 + fi + + elif [[ $COUNT =~ '^[6-9]$' ]];then + + # If display manager is Kdm, then increment counter and + # resume the next iteration. Icons aren't used on Kdm, + # so there's no need to have them inside it. + if [[ $DM =~ '^Kdm$' ]];then + COUNT=$(($COUNT + 1)) + continue + fi + + fi + + # Check existence of source files. + cli_checkFiles ${SRC[$COUNT]} + + # Copy files from source to target location. + cp ${SRC[$COUNT]} ${DST[$COUNT]} + + # Replace common translation markers from design model + # files with appropriate information. + if [[ $COUNT =~ '^(3|4)$' ]];then + cli_replaceTMarkers "${DST[$COUNT]}" + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + + # Reset counter. + COUNT=0 + + # Print action message. + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" "AsCreatingLine" + + # Create tar.gz file. + tar -czf "${RESOLUTION}.tar.gz" $TGZ + + done + + # Remove directory used as temporal holder to build targ.gz + # file. + rm -r $TGZ + + # Remove release-specific images. + cli_printMessage "${SRC[1]}" "AsDeletingLine" + rm ${SRC[1]} + cli_printMessage "${SRC[2]}" "AsDeletingLine" + rm ${SRC[2]} + + # Return to where we were initially. + popd > /dev/null + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doDocbook.sh b/Scripts/Bash/Cli/Functions/Identity/render_doDocbook.sh new file mode 100755 index 0000000..86f738d --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doDocbook.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# render_doDocbook.sh -- This function performs base-rendition +# action for DocBook files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doDocbook { + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + render_convertDocbookToXhtml + + # Produce plaintext output from html outout. + render_convertHtml2Text + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doGrub.sh b/Scripts/Bash/Cli/Functions/Identity/render_doGrub.sh new file mode 100644 index 0000000..144c0fc --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doGrub.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# render_doGrub.sh -- This function provides post-rendition +# action used to produce GRUB images. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doGrub { + + # Define 16 colors images default file name prefix. + local PREFIX='-14c' + + # 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-') + + # 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 files which + # do not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # 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."`" + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + done + + # Define motif's palette location. + local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Colors + + # Define the Netpbm color palettes used when reducing colors. + # These palettes should be 14 colors based. For more information + # on this see the GRUB's documentation. + local PALETTE_PPM=$PALETTES/grub.ppm + + # Print which palette of colors centos-art.sh script is using to + # produce grub content. This is relevant in order to know if we + # are using whether trunk or branches palette of colors. + cli_printMessage "$PALETTE_PPM" 'AsPaletteLine' + + # Check GRUB's palettes existence: If there is no palette assume + # that this is the first time you are rendition GRUB images. If + # that is the case the script will provide you with the PNG format + # which should be used as base to produce (using GIMP) the .gpl + # palette. The .gpl palette information is used to produced + # (using GIMP) the colormap (.ppm) which is used to automate the + # GRUB's 14 colors image (splash.png) rendition. If there is no + # palette available, do not apply color reduction, show a message, + # and continue. + cli_checkFiles $PALETTE_PPM + + # Create Netpbm superformat (PNM). PNM file is created from the + # PNG image rendered previously. PNM is a common point for image + # manipulation using Netpbm tools. + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Reduce colors as specified in ppm palette of colors. + cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Create the 14 colors xpm.gz file. + cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine" + ppmtoxpm \ + < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ + && gzip --force ${FILE}.xpm \ + && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doKsplash.sh b/Scripts/Bash/Cli/Functions/Identity/render_doKsplash.sh new file mode 100755 index 0000000..e8c08a4 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doKsplash.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# render_doKsplash.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-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doKsplash { + + local -a SRC + local -a DST + local FONT='' + local COUNT=0 + + # Define font used to print bottom splash message. + FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf + + # Check existence of font file. + cli_checkFiles "$FONT" 'f' + + # 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 "${SRC[@]}" 'f' + + # 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" 'AsCreatingLine' + + # 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_replaceTMarkers "${DST[4]}" + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/render_doLastActions.sh new file mode 100755 index 0000000..9b35d4f --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doLastActions.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# render_doLastActions.sh -- This function performs +# last-rendition actions for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doLastActions { + + local ACTION='' + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then + + # 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 last-rendition actions for the current directory + # structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "${ACTION}" in + + groupSimilarFiles:* ) + render_groupSimilarFiles + ;; + esac + + done + + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/render_doPostActions.sh new file mode 100755 index 0000000..8fa8fb5 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doPostActions.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# render_doPostActions.sh -- This function performs +# post-rendition actions for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doPostActions { + + local ACTION='' + + for ACTION in "${POSTACTIONS[@]}"; do + + case "${ACTION}" in + + groupSimilarFiles:* ) + render_groupSimilarFiles + ;; + + esac + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doSvg.sh b/Scripts/Bash/Cli/Functions/Identity/render_doSvg.sh new file mode 100644 index 0000000..54a678a --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doSvg.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# render_doSvg.sh -- This function performs base-rendition +# action for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvg { + + # Define export id used inside design templates. This value + # defines the design area we want to export. + local EXPORTID='CENTOSARTWORK' + + # Check export id inside design templates. + grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null + if [[ $? -gt 0 ]];then + cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" + cli_printMessage '-' 'AsSeparatorLine' + continue + fi + + # Check existence of external files. Inside design templates and + # their instances, external files are used to refere 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. + render_checkSvgAbsref "$INSTANCE" + + # Render template instance using inkscape. Modify the inkscape + # output to reduce the amount of characters used in description + # column at final output. + cli_printMessage "$(inkscape $INSTANCE \ + --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ + -e "s!Area !`gettext "Area"`: !" \ + -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ + -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" 'AsRegularLine' + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doSvgLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/render_doSvgLastActions.sh new file mode 100644 index 0000000..0235f68 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doSvgLastActions.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# +# render_doSvgLastActions.sh -- This function performs +# last-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvgLastActions { + + local ACTION='' + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then + return + fi + + # Define SVG-directory-specific last-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # last-rendition actions. + local -a LASTACTIONS + + # Add directory-specific last-rendition actions to the list of + # post actions and last 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 option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Gdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Kdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderKsplash' + fi + + # 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 + # last-rendition actions for the current directory structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "${ACTION}" in + + renderKsplash ) + render_doKsplash + ;; + + renderDm:* ) + render_doDm + ;; + + esac + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doSvgPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/render_doSvgPostActions.sh new file mode 100644 index 0000000..1291c1c --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doSvgPostActions.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# render_doSvgPostActions.sh -- This function performs +# post-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvgPostActions { + + local ACTION='' + + # Define SVG-directory-specific post-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # post-rendition actions. + local -a POSTACTIONS + + # Execute SVG directory-specific post-rendition actions to the + # list of post actions and last 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 option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Distro/Backgrounds/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo: jpg' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupSimilarFiles: png jpg' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Syslinux/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux:-floyd' + elif [[ $TEMPLATE =~ "Grub" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub:-floyd' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderKsplash' + fi + + # Execute SVG command-line-specific post-rendition actions passed + # from command-line and add them, if any, to post-rendition list + # of actions. + if [[ $FLAG_CONVERT_TO != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngTo:${FLAG_CONVERT_TO}" + fi + + for ACTION in "${POSTACTIONS[@]}"; do + + case "${ACTION}" in + + convertPngTo:* ) + render_convertPngTo + ;; + + renderSyslinux* ) + render_doSyslinux + ;; + + renderGrub* ) + render_doGrub + ;; + + renderBrands ) + render_doBrands + ;; + + esac + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_doSyslinux.sh b/Scripts/Bash/Cli/Functions/Identity/render_doSyslinux.sh new file mode 100755 index 0000000..0963f4a --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_doSyslinux.sh @@ -0,0 +1,130 @@ +#!/bin/bash +# +# render_doSyslinux.sh -- This function provides post-rendition +# action used to produce syslinux images. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSyslinux { + + # Define 16 colors images default file name prefix. + local PREFIX='-16c' + + # 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 $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + done + + # 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 motif's palette location. + local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Colors + + # Define the Netpbm color palette used when reducing colors. This + # palette should be 16 colors based. For more information on this + # see the isolinux documentation. + local PALETTE_PPM=$PALETTES/syslinux.ppm + + # Define hexadecimal color information used by ppmtolss16. Color + # information and order used on PALETTE_HEX and PALETTE_PPM should + # match exactly. + local PALETTE_HEX=$PALETTES/syslinux.hex + + # Print which palette of colors centos-art.sh script is using to + # produce grub content. This is relevant in order to know if we + # are using whether trunk or branches palette of colors. + cli_printMessage "$PALETTE_PPM" 'AsPaletteLine' + cli_printMessage "$PALETTE_HEX" 'AsPaletteLine' + + # Check syslinux's palettes existence: If there is no palette + # assume that this is the first time you are rendition syslinux + # images. If that is the case the script will provide you with the + # PNG format which should be used as base to produce (using GIMP) + # the .gpl palette. The .gpl palette information is used to + # produced (using GIMP) the colormap (.ppm) which is used to + # automate the syslinux's 16 colors image (syslinux-splash.png) + # rendition. If there is no palette available, do not apply color + # reduction, show a message, and continue. + cli_checkFiles $PALETTE_PPM + cli_checkFiles $PALETTE_HEX + + # Create Netpbm superformat (PNM). PNM file is created from the + # PNG image rendered previously. PNM is a common point for image + # manipulation using Netpbm tools. + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Reduce colors. Here we use the Netpbm color $PALETTE_PPM 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" "AsSavedAsLine" + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm + + # Create LSS16 image. As specified in isolinux documentation the + # background color should be indexed on position 0 and forground + # in position 7 (see /usr/share/doc/syslinux-X.XX/isolinux.doc). + # This order of colors is specified in $PALETTE_PPM and redefined + # here again for the LSS16 image format. Both $PALETTE_PPM and + # LSS16 color map redefinition ($PALETTE_HEX) should have the same + # colors and index order. PALETTE_HEX should return just one line + # with the color information as described in isolinux + # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the + # same line]). + cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine" + PALETTE_HEX=$(cat $PALETTE_HEX | tr "\n" ' ' | tr -s ' ') + ppmtolss16 $PALETTE_HEX \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss + + # Create the 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" "AsSavedAsLine" + lss16toppm -map \ + < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Create the 16 colors PNG image. + cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine" + pnmtopng -verbose -palette=$PALETTE_PPM \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_getActions.sh b/Scripts/Bash/Cli/Functions/Identity/render_getActions.sh new file mode 100644 index 0000000..6afe0ec --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_getActions.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# render_getActions.sh -- This function interprets arguments passed to +# render functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="render:,releasever:,basearch:,copy:,to:,convert-to:,group-by:,theme-model:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --releasever ) + FLAG_RELEASE="$2" + if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then + cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + shift 2 + ;; + + --basearch ) + FLAG_ARCHITECTURE="$2" + if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then + cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + shift 2 + ;; + + --to ) + FLAG_TO="$2" + shift 2 + ;; + + --convert-to ) + FLAG_CONVERT_TO="$2" + shift 2 + ;; + + --group-by ) + FLAG_GROUPED_BY="$2" + shift 2 + ;; + + --theme-model ) + FLAG_THEME_MODEL=$(cli_getRepoName "$2" 'd') + shift 2 + ;; + + * ) + # Break options loop. + break + esac + done + + # Read remaining arguments and build the action value from them. + # At this point all options should be processed. + for ACTIONVAL in "$@";do + + if [[ $ACTIONVAL == '--' ]];then + continue + fi + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_syncroRepoChanges + + # Execute action name. + eval ${FUNCNAM}_render + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_getConfigOption.sh b/Scripts/Bash/Cli/Functions/Identity/render_getConfigOption.sh new file mode 100755 index 0000000..f5cdcd3 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_getConfigOption.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# render_getConfigOption.sh -- This function standardizes the way +# action values are retrived from pre-rendition configuration files. +# Use this function whenever you need to retrive action values from +# pre-rendition configuration script. +# +# Usage: VAR=$(render_getConfigOption "ACTION" "FIELD") +# +# VAR is the name of the variable where we store the option named +# returned by render_getConfigOption. +# +# ACTION is the string definition set in the pre-rendition +# configuration script that holds the action name and its options +# fields. +# +# FIELD is the field number in the action string we want to retrive +# option from. By default options start from third field on. The first +# field is reserved for the action type (i.e., POST or LAST), and the +# second field is reserved for the action itself (e.g., convertPngTo, +# renderSyslinux, renderKsplash, etc.). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getConfigOption { + + local ACTION="$1" + local FIELD="$2" + local VALUE='' + + # Check action value. The action's value must be present in order + # for this function to work. It provides the string needed to + # retrive options from. + if [[ "$ACTION" == '' ]];then + cli_printMessage "`gettext "There is no action to work with."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check field value. The field's value must match the cut's + # command specification of its -f option. + if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then + cli_printMessage "`gettext "The field specified is not valid."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Get option from pre-rendition configuration action definition. + VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate action value passed from pre-rendition configuration + # action definition. + VALUE=$(echo -n "${VALUE}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Output action value without trailing newline. + echo -n "$VALUE" + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_getDirOutput.sh b/Scripts/Bash/Cli/Functions/Identity/render_getDirOutput.sh new file mode 100644 index 0000000..bc664a3 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_getDirOutput.sh @@ -0,0 +1,62 @@ +#!/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-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirOutput { + + # Define base output directory using design model path as + # reference. By default rendered identity content is stored + # immediatly under identity entry structure, but if `Img/' + # directory exists use it instead. + OUTPUT=$(dirname $FILE | sed -r \ + -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ + -e "s!/Tpl!/Img!") + + # Redefine base output directory to introduce specific information + # like release number, architecture, etc. + OUTPUT=${OUTPUT}/${FLAG_RELEASE}/${FLAG_ARCHITECTURE} + + # Define whether to use or not locale-specific directory to store + # content, using current locale information as reference. As + # convenction, when we produce content in English language, we do + # not add a laguage-specific directory to organize content. + # However, when we produce language-specific content in a language + # different from English we do use language-specific directory to + # organize content. + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) + fi + + # Remove two or more consecutive slashes as well as the last + # remaining slash in the path. + OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') + + # Create final output directory, if it doesn't exist yet. + if [[ ! -d ${OUTPUT} ]];then + mkdir -p ${OUTPUT} + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_getDirTemplate.sh b/Scripts/Bash/Cli/Functions/Identity/render_getDirTemplate.sh new file mode 100644 index 0000000..08e598d --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_getDirTemplate.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# render_getDirTemplate.sh -- This function re-defines absolute +# path to artwork's related design templates directory. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirTemplate { + + # Initialize design models location using action value as + # reference. + TEMPLATE=$ACTIONVAL + + # Sanitate design models location. Be sure design models do + # always point to trunk directory structure. This is useful to let + # `centos-art.sh' script do rendition under branches directory + # structure, reusing design models under trunk directory + # structure. + TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") + + # Sanitate design models location using or not Tpl/ directory. + if [[ -d $TEMPLATE/Tpl ]];then + # Using Tpl/ directory is an obsolete practice that should be + # avoided. The concept of Tpl/ directory per artwork directory + # has been replaced by a common design model directory + # structure where we centralize design models for all + # different artistic motifs. However, there are some cases + # that we may need to use Tpl/ directory still, so we verify + # its existence and use it if present. + TEMPLATE=$TEMPLATE/Tpl + else + # Redefine design model location based on theme model + # (FLAG_THEME_MODEL) variable value. The theme model variable is + # defined in the associated pre-rendition configuration script + # and can be used to set which design model to use among a + # list of different design models that we can choose from. + TEMPLATE=$(echo "$TEMPLATE" \ + | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$FLAG_THEME_MODEL!") + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/render_groupSimilarFiles.sh b/Scripts/Bash/Cli/Functions/Identity/render_groupSimilarFiles.sh new file mode 100755 index 0000000..da066d5 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/render_groupSimilarFiles.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# render_groupSimilarFiles.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-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_groupSimilarFiles { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + 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 $SOURCE 'f' + + # 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" 'AsMovedToLine' + mv ${SOURCE} ${TARGET} + + done + +}