diff --git a/Scripts/Bash/Functions/Identity/identity.sh b/Scripts/Bash/Functions/Identity/identity.sh new file mode 100644 index 0000000..b8440e0 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# render.sh -- This function provides rendition features to +# centos-art.sh script. Here we initialize rendition variables and +# call render_getActions functions. +# +# 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 rendition actions. + render_getActions + +} diff --git a/Scripts/Bash/Functions/Identity/identity_checkAbsolutePaths.sh b/Scripts/Bash/Functions/Identity/identity_checkAbsolutePaths.sh new file mode 100755 index 0000000..d1024d5 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_checkAbsolutePaths.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# render_checkAbsolutePaths.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_checkAbsolutePaths { + + 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/Functions/Identity/identity_doCopy.sh b/Scripts/Bash/Functions/Identity/identity_doCopy.sh new file mode 100755 index 0000000..957e92e --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doCopy.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# render_doCopy.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_doCopy { + + # Verify target directory. + cli_checkRepoDirTarget + + # Determine what directory structure we are duplicating. + +} diff --git a/Scripts/Bash/Functions/Identity/identity_doIdentity.sh b/Scripts/Bash/Functions/Identity/identity_doIdentity.sh new file mode 100755 index 0000000..f87cefc --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentity.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# render_doIdentity.sh -- This function initiates rendition +# configuration functions and executes them to perform the rendition +# action specified in the `ACTIONS' array variable. Function +# initialization and execution is based on the absolute path +# convenction defined by ARTCONF variable. +# +# 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: render_doIdentity.sh 824 2011-01-06 20:54:52Z al $ +# ---------------------------------------------------------------------- + +function render_doIdentity { + + local FILE='' + + # Initialize artwork identification. + local ARTCOMP='' + + # Define default theme model. + local THEMEMODEL='Default' + + # Build list of files to process. + local FILES=$(cli_getFilesList "$ARTCONF" ".*/?render\.conf\.sh") + + # Set action preamble. + # Do not print action preamble here, it prevents massive rendition. + + # Process list of files. + for FILE in $FILES;do + + # Output action message. + cli_printMessage $FILE 'AsConfigurationLine' + + # Define artwork-specific action arrays. We need to do this + # here because ACTIONS variable is unset after + # render_doIdentityImages execution. Otherwise, undesired + # concatenations may occur. + local -a ACTIONS + local -a POSTACTIONS + local -a LASTACTIONS + + # Initialize artwork-specific pre-rendition configuration + # (function) scripts. + . $FILE + + # Execute artwork-specific pre-rendition configuration + # (function) scripts to re-define artwork-specific ACTIONS. + render_loadConfig + + # Check variables passed from artwork-specific pre-rendition + # configuration scripts and make required transformations. + render_getIdentityConfig + + # Redefine action value (ACTIONVAL) based on pre-rendition + # configuration script path value. Otherwise, massive + # rendition may fail. Functions like renderImage need to know + # the exact artwork path (that is, where images will be + # stored). + ACTIONVAL=$(dirname $(echo $FILE | sed -r \ + -e 's!Scripts/Bash/Functions/Render/Config/(Identity)/!\1/!' \ + -e "s!Themes/!Themes/Motifs/$(cli_getPathComponent '--theme')/!")) + + # Redefine artwork identification using redefined action + # value. + ARTCOMP=$(echo $ACTIONVAL | cut -d/ -f6-) + + # Remove motif name from artwork identification in order to + # reuse motif artwork identification. There is not need to + # create one artwork identification for each motif directory + # structure if we can reuse just one. + ARTCOMP=$(echo $ARTCOMP \ + | sed -r "s!Themes/Motifs/$(cli_getPathComponent '--theme')/!Themes/!") + + # Start rendition as defined in artwork-specific pre-rendition + # configuration file. + render_getIdentityBase + + # Unset artwork-specific actions so they can be redefined by + # artwork-specific pre-rendition configuration scripts. This + # is required in massive rendition. For example, if you say + # centos-art.sh to render the whole Distro directory it first + # renders Prompt entry, which defines the renderSyslinux + # post-rendition action, and later Progress entry which does + # not defines post-rendition actions. If we do not unset the + # ACTIONS variable, post-rendition actions defined in Prompt + # entry remain for Progress entry and that is not desired. We + # want ACTIONS to do what we exactly tell it to do inside each + # artwork-specific pre-rendition configuration script. + unset ACTIONS + unset POSTACTIONS + unset LASTACTIONS + + done + +} diff --git a/Scripts/Bash/Functions/Identity/identity_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityGroupByType.sh new file mode 100755 index 0000000..2af7c88 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityGroupByType.sh @@ -0,0 +1,163 @@ +#!/bin/bash +# +# render_doIdentityGroupByTypes.sh -- This function provides +# post-rendition and last-rendition action to group file inside +# directories named as their file type. +# +# Usage: +# ------ +# Post-rendition --> render_doIdentityGroupByTypes "$FILE" "$ACTION" +# Last-rendition --> render_doIdentityGroupByTypes "$ACTION" +# +# Note that post-rendition uses 2 arguments ($FILE and $ACTION) and +# last-rendition just one ($ACTION). This function uses the amount +# of arguments to determine when it is acting as post-rendition and +# when as last-rendition. +# +# This function create one directory for each different file type. +# Later files are moved inside directories respectively. 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. +# +# For example, the following three lines will create one jpg, ppm, +# xpm, and tif file for each png file available and groups them all by +# its file type, inside directories named as their file type (i.e. +# Png, Jpg, Ppm, Xpm, Tif). Note that in the example, groupByType is +# ivoked as post-rendition action. If you want to invoke it as +# last-rendition action use LAST definition instead of POST. +# +# ACTIONS[0]='BASE:renderImage' +# ACTIONS[1]='POST:renderFormats: jpg, ppm, xpm, tif' +# ACTIONS[2]='POST:groupByType: png, jpg, ppm, xpm, tif' +# +# groupByType function is generally used with renderFormats function. +# Both definitions must match the file type you want to have rendered +# and grouped. You don't need to specify the png file type in +# renderFormats' definition, but in groupByType's definition it must +# be specified. Otherwise png files will not be grouped inside a png +# 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_doIdentityGroupByType { + + local FILE='' + local -a FILES + local -a PATTERNS + local FORMATS='' + local SOURCE='' + local TARGET='' + local COUNT=0 + + if [[ $# -eq 1 ]];then + # Define file types for post-rendition action. + FORMATS=$1 + elif [[ $# -eq 2 ]];then + # Define file types for last-rendition action. + FORMATS=$2 + else + cli_printMessage "`gettext "groupByType: Wrong invokation."`" 'AsErrorLine' + cli_printMessage $(caller) "AsToKnowMoreLine" + fi + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + FORMATS=$(render_getIdentityConfigOption "$FORMATS" '2-') + + # Check file types passed from render.conf.sh pre-rendition + # configuration script. + if [[ "$FORMATS" == "" ]];then + cli_printMessage "`gettext "There is no file type information to process."`" 'AsErrorLine' + cli_printMessage $(caller) "AsToKnowMoreLine" + fi + + if [[ $# -eq 1 ]];then + + # Define pattern for file extensions. + PATTERNS[0]=$(echo "$FORMATS" | sed 's! !|!g') + + # Define pattern for directories. + PATTERNS[1]=$(echo $(for i in $FORMATS; do cli_getRepoName "$i" 'd'; done) | sed 's! !|!g') + + # Define pattern for path. The path pattern combines both file + # extension and directories patterns. This pattern is what we + # use to match rendered file. + PATTERNS[2]="^.*[^(${PATTERNS[1]})]/[[:alpha:]_-]+\.(${PATTERNS[0]})$" + + # Define list of files to process when acting as + # last-rendition action. There may be many different files to + # process here, so we need to build a list with them all + # (without duplications). + for FILE in $(find $ACTIONVAL -regextype posix-egrep -type f -regex ${PATTERNS[2]} \ + | sed -r 's!\.[[:alpha:]]{1,4}$!!' | sort | uniq \ + | egrep $FLAG_FILTER);do + FILES[$COUNT]="$FILE" + COUNT=$(($COUNT + 1)) + done + + elif [[ $# -eq 2 ]];then + + # Define list of files to process when action as + # post-rendition action. There is just one value to process + # here, the one being currently rendered. + FILES[0]="$1" + + fi + + # Start processing list of files. + for FILE in "${FILES[@]}";do + + 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 + + done + +} diff --git a/Scripts/Bash/Functions/Identity/identity_doIdentityImageBrands.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageBrands.sh new file mode 100644 index 0000000..767e48f --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageBrands.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# render_doIdentityImageBrands.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_doIdentityImageBrands { + + 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/Functions/Identity/identity_doIdentityImageDm.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageDm.sh new file mode 100755 index 0000000..ef0cd7e --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageDm.sh @@ -0,0 +1,192 @@ +#!/bin/bash +# +# render_doIdentityImageDm.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[0]='BASE:renderImage' +# 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_doIdentityImageDm { + + local -a SRC + local -a DST + local DM='' + local TGZ='' + local COUNT=0 + local RESOLUTION='' + local RESOLUTIONS='' + + # Get display manager passed from render.conf.sh pre-rendition + # configuration script. + DM=$(render_getIdentityConfigOption "$1" '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_getIdentityConfigOption "$1" '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]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/GdmGreeterTheme.xml + SRC[4]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/GdmGreeterTheme.desktop + SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png + SRC[6]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-language.png + SRC[7]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-reboot.png + SRC[8]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-session.png + SRC[9]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/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 + + # Output division rule. + cli_printMessage '-' 'AsSeparatorLine' + +} diff --git a/Scripts/Bash/Functions/Identity/identity_doIdentityImageFormats.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageFormats.sh new file mode 100644 index 0000000..77ccffc --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageFormats.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# render_doIdentityImageFormats.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_doIdentityImageFormats { + + # Get absolute path of PNG image file. + local FILE="$1" + + # Get image formats. + local FORMATS=$(render_getIdentityConfigOption "$2" '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/Functions/Identity/identity_doIdentityImageGrub.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageGrub.sh new file mode 100644 index 0000000..c3bc356 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageGrub.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# render_doIdentityImageGrub.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_doIdentityImageGrub { + + local FILE="$1" + local ACTION="$2" + local OPTIONS='' + + # 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. + OPTIONS=$(render_getIdentityConfigOption "$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/Functions/Identity/identity_doIdentityImageKsplash.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageKsplash.sh new file mode 100755 index 0000000..ba2c6d4 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageKsplash.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# +# render_doIdentityImageKsplash.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_doIdentityImageKsplash { + + 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]="$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/Ksplash/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]}" + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + +} diff --git a/Scripts/Bash/Functions/Identity/identity_doIdentityImageSyslinux.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImageSyslinux.sh new file mode 100755 index 0000000..fdd0830 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImageSyslinux.sh @@ -0,0 +1,134 @@ +#!/bin/bash +# +# render_doIdentityImageSyslinux.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_doIdentityImageSyslinux { + + local FILE="$1" + local ACTION="$2" + local OPTIONS='' + + # 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. + OPTIONS=$(render_getIdentityConfigOption "$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/Functions/Identity/identity_doIdentityImages.sh b/Scripts/Bash/Functions/Identity/identity_doIdentityImages.sh new file mode 100644 index 0000000..8926cd0 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_doIdentityImages.sh @@ -0,0 +1,240 @@ +#!/bin/bash +# +# render_doIdentityImages.sh -- This function renders image-based +# identity contents. +# +# 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_doIdentityImages { + + local FILE='' + local OUTPUT='' + local EXPORTID='' + local TEMPLATE='' + local TRANSLATION='' + local EXTERNALFILE='' + local EXTERNALFILES='' + local COMMONDIRCOUNT=0 + + # Export id used inside design templates. This value defines the + # design area we want to export. + EXPORTID='CENTOSARTWORK' + + # Start processing the base rendition list of FILES. Fun part + # approching :-). + for FILE in $FILES; do + + # 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_getIdentityDirOutput + + # 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/\.(svgz|svg)$//") + + # Define absolute path to final file (without extension). + FILE=${OUTPUT}/$(basename "${FILE}") + + # Define instance name from design model. + INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) + + 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/cat ${TEMPLATE} > ${INSTANCE} + + fi + + # Apply replacement of translation markers to design model + # translated instance. + cli_replaceTMarkers ${INSTANCE} + + # 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. 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. + render_checkAbsolutePaths "$INSTANCE" + + # Render template instance and 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' + + # Remove template instance. + if [[ -a $INSTANCE ]];then + rm $INSTANCE + fi + + # Execute post-rendition actions. + for ACTION in "${POSTACTIONS[@]}"; do + + case "$ACTION" in + + renderSyslinux* ) + render_doIdentityImageSyslinux "${FILE}" "$ACTION" + ;; + + renderGrub* ) + render_doIdentityImageGrub "${FILE}" "$ACTION" + ;; + + renderFormats:* ) + render_doIdentityImageFormats "${FILE}" "$ACTION" + ;; + + groupByType:* ) + render_doIdentityGroupByType "${FILE}" "$ACTION" + ;; + + esac + + done + + # Output separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Apply last-rendition actions. As convenction, last-rendition + # actions are applied after all images inside the same + # directory structure have been produced. Notice that, in + # order to apply last-rendition actions correctly, + # centos-art.sh needs to "predict" what the last file in the + # same directory structure would be. There is no magic here, + # so we need to previously define which are the common + # directory structures centos-art.sh could produce content + # for inside an array variable. Later, using the index of that + # array variable we could check the next item in the array + # against the file being currently produced. If they match, we + # haven't reached the end of the same directory structure, but + # if they don't match, we do have reach the end of the same + # directory structure and it is time for last-rendition + # actions to be evaluated before go producing the next + # directory structure in the list of files to process. + if [[ $(dirname "$TEMPLATE") != ${COMMONDIRS[$(($COMMONDIRCOUNT + 1))]} ]];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 evaluate last-rendition actions for the current + # directory structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "$ACTION" in + + renderKSplash ) + render_doIdentityImageKsplash + ;; + + renderDm:* ) + render_doIdentityImageDm "$ACTION" + ;; + + groupByType:* ) + render_doIdentityGroupByType "$ACTION" + ;; + + renderBrands ) + render_doIdentityImageBrands "${FILE}" "$ACTION" + ;; + + esac + done + fi + + # Increment common directory counter. + COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) + + done + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getActions.sh b/Scripts/Bash/Functions/Identity/identity_getActions.sh new file mode 100644 index 0000000..05d0436 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getActions.sh @@ -0,0 +1,148 @@ +#!/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:,release:,architecture:,copy:,to:" + + # 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 + + --render ) + + # Redefine action name. + ACTIONNAM="${FUNCNAM}_doIdentity" + + # Redefine action value. + ACTIONVAL="$2" + + # Rotate positional parameters + shift 2 + ;; + + --copy ) + + # Redefine action value variable. + ACTIONVAL="$2" + + # Redefine action name variable. + ACTIONNAM="${FUNCNAME}_doCopy" + + # Rotate positional parameters + shift 2 + ;; + + --release ) + + # Redefine release number flag. + FLAG_RELEASE="$2" + + # Verify release number flag. + if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then + cli_printMessage "`gettext "The release number provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Rotate positional parameters + shift 2 + ;; + + --architecture ) + + # Redefine architecture flag. + FLAG_ARCHITECTURE="$2" + + # Verify architecture flag. + if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then + cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Rotate positional parameters + shift 2 + ;; + + --to ) + + # Redefine target value flag. + FLAG_TO="$2" + + # Rotate positional parameters + shift 2 + ;; + + * ) + # Break options loop. + break + esac + done + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Define pre-rendition configuration directory. Pre-rendition + # configuration directory is where we store render.conf.sh + # scripts. The render.conf.sh script defines how each identity + # content is rendered. + local ARTCONF=$(echo "$ACTIONVAL" \ + | sed -r -e 's!/(Identity)!/Scripts/Bash/Functions/Render/Config/\1!' \ + -e "s!Motifs/$(cli_getPathComponent '--theme')/?!!") + + # Check directory of pre-rendition configuration script. + cli_checkFiles "$ARTCONF" 'd' + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_commitRepoChanges + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getIdentityBase.sh b/Scripts/Bash/Functions/Identity/identity_getIdentityBase.sh new file mode 100755 index 0000000..02e8e3d --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getIdentityBase.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# render_getIdentityBase.sh -- This function initiates rendition features +# taking BASEACTIONS 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_getIdentityBase { + + local FILES='' + local PARENTDIR='' + local TEMPLATE='' + local COMMONDIR='' + local COMMONDIRCOUNT=0 + local -a COMMONDIRS + + # Redefine parent directory for current workplace. + PARENTDIR=$(basename "$ACTIONVAL") + + # Define base location of template files. + render_getIdentityDirTemplate + + # Define list of files to process. + FILES=$(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*\.(svgz|svg)") + + # Set action preamble. + # Do not print action preamble here, it prevents massive rendition. + + # Define common absolute paths in order 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 COMMONDIR in $(dirname "$FILES" | sort | uniq);do + COMMONDIRS[$COMMONDIRCOUNT]=$(dirname "$COMMONDIR") + COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) + done + + # Execute base-rendition action. + render_doIdentityImages + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getIdentityConfig.sh b/Scripts/Bash/Functions/Identity/identity_getIdentityConfig.sh new file mode 100755 index 0000000..2363995 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getIdentityConfig.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# render_getIdentityConfig.sh -- This function checks/validates variables +# passed from artwork-specific pre-rendition configuration 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_getIdentityConfig { + + local POSTCOUNT=0 + local LASTCOUNT=0 + + # Re-define action variables in separated array variables. Once + # verification is done, we remove the BASE, POST, LAST parts from + # action definition in order to have the plain name of function to + # call. + for ACTION in "${ACTIONS[@]}"; do + + # Define post-rendition actions. + if [[ $ACTION =~ '^POST:' ]];then + ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') + POSTACTIONS[$POSTCOUNT]="$ACTION" + POSTCOUNT=$(($POSTCOUNT + 1)) + + # Define last-rendition actions. + elif [[ $ACTION =~ '^LAST:' ]];then + ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') + LASTACTIONS[$LASTCOUNT]="$ACTION" + LASTCOUNT=$(($LASTCOUNT + 1)) + fi + + done + + # Check post-rendition actions. Validation of post-rendition + # actions is action-specific. So, validation of post-rendition + # actions is not here, but inside action-specific functions. See + # render_doIdentityImages and render_doIdentityTexts to see + # validation of renderImage and renderText post-rendition actions, + # respectively. + + # Sanitate theme model value using repository directory name + # convenction. + THEMEMODEL=$(cli_getRepoName "$THEMEMODEL" 'd') + + # Check theme model directory. + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}" 'd' + +} diff --git a/Scripts/Bash/Functions/Identity/identity_getIdentityConfigOption.sh b/Scripts/Bash/Functions/Identity/identity_getIdentityConfigOption.sh new file mode 100755 index 0000000..3e46d83 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getIdentityConfigOption.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# render_getIdentityConfigOption.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_getIdentityConfigOption "ACTION" "FIELD") +# +# VAR is the name of the variable where we store the option named +# returned by render_getIdentityConfigOption. +# +# 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., BASE, POST or LAST), and +# the second field is reserved for the action itself (e.g., +# renderImage, renderFormats, etc.). Note that this convenction can be +# altered if the action string has been modified (e.g., you stript the +# BASE field from action string) and passed the modified action string +# to another function for processing. +# +# 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_getIdentityConfigOption { + + 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/Functions/Identity/identity_getIdentityDirOutput.sh b/Scripts/Bash/Functions/Identity/identity_getIdentityDirOutput.sh new file mode 100644 index 0000000..ecf8d12 --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getIdentityDirOutput.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# render_getIdentityDirOutput.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_getIdentityDirOutput { + + # Define base output directory using design model path as reference. + OUTPUT=$(dirname $FILE | sed -r \ + -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!") + + # By default rendered identity content is stored immediatly under + # identity entry structure, but if `Img/' directory exists use it + # instead. + if [[ -d ${OUTPUT}/Img ]]; then + OUTPUT=${OUTPUT}/Img + fi + + # 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/Functions/Identity/identity_getIdentityDirTemplate.sh b/Scripts/Bash/Functions/Identity/identity_getIdentityDirTemplate.sh new file mode 100644 index 0000000..04e0e6e --- /dev/null +++ b/Scripts/Bash/Functions/Identity/identity_getIdentityDirTemplate.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# render_getIdentityDirTemplate.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_getIdentityDirTemplate { + + # 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 + # (THEMEMODEL) 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/$THEMEMODEL!") + fi + +} diff --git a/Scripts/Bash/Functions/Identity/render.sh b/Scripts/Bash/Functions/Identity/render.sh deleted file mode 100644 index b8440e0..0000000 --- a/Scripts/Bash/Functions/Identity/render.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# render.sh -- This function provides rendition features to -# centos-art.sh script. Here we initialize rendition variables and -# call render_getActions functions. -# -# 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 rendition actions. - render_getActions - -} diff --git a/Scripts/Bash/Functions/Identity/render_checkAbsolutePaths.sh b/Scripts/Bash/Functions/Identity/render_checkAbsolutePaths.sh deleted file mode 100755 index d1024d5..0000000 --- a/Scripts/Bash/Functions/Identity/render_checkAbsolutePaths.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# render_checkAbsolutePaths.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_checkAbsolutePaths { - - 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/Functions/Identity/render_doCopy.sh b/Scripts/Bash/Functions/Identity/render_doCopy.sh deleted file mode 100755 index 957e92e..0000000 --- a/Scripts/Bash/Functions/Identity/render_doCopy.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# render_doCopy.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_doCopy { - - # Verify target directory. - cli_checkRepoDirTarget - - # Determine what directory structure we are duplicating. - -} diff --git a/Scripts/Bash/Functions/Identity/render_doIdentity.sh b/Scripts/Bash/Functions/Identity/render_doIdentity.sh deleted file mode 100755 index f87cefc..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentity.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# -# render_doIdentity.sh -- This function initiates rendition -# configuration functions and executes them to perform the rendition -# action specified in the `ACTIONS' array variable. Function -# initialization and execution is based on the absolute path -# convenction defined by ARTCONF variable. -# -# 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: render_doIdentity.sh 824 2011-01-06 20:54:52Z al $ -# ---------------------------------------------------------------------- - -function render_doIdentity { - - local FILE='' - - # Initialize artwork identification. - local ARTCOMP='' - - # Define default theme model. - local THEMEMODEL='Default' - - # Build list of files to process. - local FILES=$(cli_getFilesList "$ARTCONF" ".*/?render\.conf\.sh") - - # Set action preamble. - # Do not print action preamble here, it prevents massive rendition. - - # Process list of files. - for FILE in $FILES;do - - # Output action message. - cli_printMessage $FILE 'AsConfigurationLine' - - # Define artwork-specific action arrays. We need to do this - # here because ACTIONS variable is unset after - # render_doIdentityImages execution. Otherwise, undesired - # concatenations may occur. - local -a ACTIONS - local -a POSTACTIONS - local -a LASTACTIONS - - # Initialize artwork-specific pre-rendition configuration - # (function) scripts. - . $FILE - - # Execute artwork-specific pre-rendition configuration - # (function) scripts to re-define artwork-specific ACTIONS. - render_loadConfig - - # Check variables passed from artwork-specific pre-rendition - # configuration scripts and make required transformations. - render_getIdentityConfig - - # Redefine action value (ACTIONVAL) based on pre-rendition - # configuration script path value. Otherwise, massive - # rendition may fail. Functions like renderImage need to know - # the exact artwork path (that is, where images will be - # stored). - ACTIONVAL=$(dirname $(echo $FILE | sed -r \ - -e 's!Scripts/Bash/Functions/Render/Config/(Identity)/!\1/!' \ - -e "s!Themes/!Themes/Motifs/$(cli_getPathComponent '--theme')/!")) - - # Redefine artwork identification using redefined action - # value. - ARTCOMP=$(echo $ACTIONVAL | cut -d/ -f6-) - - # Remove motif name from artwork identification in order to - # reuse motif artwork identification. There is not need to - # create one artwork identification for each motif directory - # structure if we can reuse just one. - ARTCOMP=$(echo $ARTCOMP \ - | sed -r "s!Themes/Motifs/$(cli_getPathComponent '--theme')/!Themes/!") - - # Start rendition as defined in artwork-specific pre-rendition - # configuration file. - render_getIdentityBase - - # Unset artwork-specific actions so they can be redefined by - # artwork-specific pre-rendition configuration scripts. This - # is required in massive rendition. For example, if you say - # centos-art.sh to render the whole Distro directory it first - # renders Prompt entry, which defines the renderSyslinux - # post-rendition action, and later Progress entry which does - # not defines post-rendition actions. If we do not unset the - # ACTIONS variable, post-rendition actions defined in Prompt - # entry remain for Progress entry and that is not desired. We - # want ACTIONS to do what we exactly tell it to do inside each - # artwork-specific pre-rendition configuration script. - unset ACTIONS - unset POSTACTIONS - unset LASTACTIONS - - done - -} diff --git a/Scripts/Bash/Functions/Identity/render_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Identity/render_doIdentityGroupByType.sh deleted file mode 100755 index 2af7c88..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityGroupByType.sh +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# -# render_doIdentityGroupByTypes.sh -- This function provides -# post-rendition and last-rendition action to group file inside -# directories named as their file type. -# -# Usage: -# ------ -# Post-rendition --> render_doIdentityGroupByTypes "$FILE" "$ACTION" -# Last-rendition --> render_doIdentityGroupByTypes "$ACTION" -# -# Note that post-rendition uses 2 arguments ($FILE and $ACTION) and -# last-rendition just one ($ACTION). This function uses the amount -# of arguments to determine when it is acting as post-rendition and -# when as last-rendition. -# -# This function create one directory for each different file type. -# Later files are moved inside directories respectively. 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. -# -# For example, the following three lines will create one jpg, ppm, -# xpm, and tif file for each png file available and groups them all by -# its file type, inside directories named as their file type (i.e. -# Png, Jpg, Ppm, Xpm, Tif). Note that in the example, groupByType is -# ivoked as post-rendition action. If you want to invoke it as -# last-rendition action use LAST definition instead of POST. -# -# ACTIONS[0]='BASE:renderImage' -# ACTIONS[1]='POST:renderFormats: jpg, ppm, xpm, tif' -# ACTIONS[2]='POST:groupByType: png, jpg, ppm, xpm, tif' -# -# groupByType function is generally used with renderFormats function. -# Both definitions must match the file type you want to have rendered -# and grouped. You don't need to specify the png file type in -# renderFormats' definition, but in groupByType's definition it must -# be specified. Otherwise png files will not be grouped inside a png -# 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_doIdentityGroupByType { - - local FILE='' - local -a FILES - local -a PATTERNS - local FORMATS='' - local SOURCE='' - local TARGET='' - local COUNT=0 - - if [[ $# -eq 1 ]];then - # Define file types for post-rendition action. - FORMATS=$1 - elif [[ $# -eq 2 ]];then - # Define file types for last-rendition action. - FORMATS=$2 - else - cli_printMessage "`gettext "groupByType: Wrong invokation."`" 'AsErrorLine' - cli_printMessage $(caller) "AsToKnowMoreLine" - fi - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - FORMATS=$(render_getIdentityConfigOption "$FORMATS" '2-') - - # Check file types passed from render.conf.sh pre-rendition - # configuration script. - if [[ "$FORMATS" == "" ]];then - cli_printMessage "`gettext "There is no file type information to process."`" 'AsErrorLine' - cli_printMessage $(caller) "AsToKnowMoreLine" - fi - - if [[ $# -eq 1 ]];then - - # Define pattern for file extensions. - PATTERNS[0]=$(echo "$FORMATS" | sed 's! !|!g') - - # Define pattern for directories. - PATTERNS[1]=$(echo $(for i in $FORMATS; do cli_getRepoName "$i" 'd'; done) | sed 's! !|!g') - - # Define pattern for path. The path pattern combines both file - # extension and directories patterns. This pattern is what we - # use to match rendered file. - PATTERNS[2]="^.*[^(${PATTERNS[1]})]/[[:alpha:]_-]+\.(${PATTERNS[0]})$" - - # Define list of files to process when acting as - # last-rendition action. There may be many different files to - # process here, so we need to build a list with them all - # (without duplications). - for FILE in $(find $ACTIONVAL -regextype posix-egrep -type f -regex ${PATTERNS[2]} \ - | sed -r 's!\.[[:alpha:]]{1,4}$!!' | sort | uniq \ - | egrep $FLAG_FILTER);do - FILES[$COUNT]="$FILE" - COUNT=$(($COUNT + 1)) - done - - elif [[ $# -eq 2 ]];then - - # Define list of files to process when action as - # post-rendition action. There is just one value to process - # here, the one being currently rendered. - FILES[0]="$1" - - fi - - # Start processing list of files. - for FILE in "${FILES[@]}";do - - 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 - - done - -} diff --git a/Scripts/Bash/Functions/Identity/render_doIdentityImageBrands.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageBrands.sh deleted file mode 100644 index 767e48f..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageBrands.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageBrands.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_doIdentityImageBrands { - - 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/Functions/Identity/render_doIdentityImageDm.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageDm.sh deleted file mode 100755 index ef0cd7e..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageDm.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageDm.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[0]='BASE:renderImage' -# 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_doIdentityImageDm { - - local -a SRC - local -a DST - local DM='' - local TGZ='' - local COUNT=0 - local RESOLUTION='' - local RESOLUTIONS='' - - # Get display manager passed from render.conf.sh pre-rendition - # configuration script. - DM=$(render_getIdentityConfigOption "$1" '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_getIdentityConfigOption "$1" '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]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/GdmGreeterTheme.xml - SRC[4]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/GdmGreeterTheme.desktop - SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png - SRC[6]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-language.png - SRC[7]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-reboot.png - SRC[8]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/icon-session.png - SRC[9]=$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/${DM}/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 - - # Output division rule. - cli_printMessage '-' 'AsSeparatorLine' - -} diff --git a/Scripts/Bash/Functions/Identity/render_doIdentityImageFormats.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageFormats.sh deleted file mode 100644 index 77ccffc..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageFormats.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageFormats.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_doIdentityImageFormats { - - # Get absolute path of PNG image file. - local FILE="$1" - - # Get image formats. - local FORMATS=$(render_getIdentityConfigOption "$2" '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/Functions/Identity/render_doIdentityImageGrub.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageGrub.sh deleted file mode 100644 index c3bc356..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageGrub.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageGrub.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_doIdentityImageGrub { - - local FILE="$1" - local ACTION="$2" - local OPTIONS='' - - # 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. - OPTIONS=$(render_getIdentityConfigOption "$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/Functions/Identity/render_doIdentityImageKsplash.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageKsplash.sh deleted file mode 100755 index ba2c6d4..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageKsplash.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageKsplash.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_doIdentityImageKsplash { - - 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]="$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}/Distro/Ksplash/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]}" - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - -} diff --git a/Scripts/Bash/Functions/Identity/render_doIdentityImageSyslinux.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImageSyslinux.sh deleted file mode 100755 index fdd0830..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImageSyslinux.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImageSyslinux.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_doIdentityImageSyslinux { - - local FILE="$1" - local ACTION="$2" - local OPTIONS='' - - # 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. - OPTIONS=$(render_getIdentityConfigOption "$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/Functions/Identity/render_doIdentityImages.sh b/Scripts/Bash/Functions/Identity/render_doIdentityImages.sh deleted file mode 100644 index 8926cd0..0000000 --- a/Scripts/Bash/Functions/Identity/render_doIdentityImages.sh +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/bash -# -# render_doIdentityImages.sh -- This function renders image-based -# identity contents. -# -# 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_doIdentityImages { - - local FILE='' - local OUTPUT='' - local EXPORTID='' - local TEMPLATE='' - local TRANSLATION='' - local EXTERNALFILE='' - local EXTERNALFILES='' - local COMMONDIRCOUNT=0 - - # Export id used inside design templates. This value defines the - # design area we want to export. - EXPORTID='CENTOSARTWORK' - - # Start processing the base rendition list of FILES. Fun part - # approching :-). - for FILE in $FILES; do - - # 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_getIdentityDirOutput - - # 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/\.(svgz|svg)$//") - - # Define absolute path to final file (without extension). - FILE=${OUTPUT}/$(basename "${FILE}") - - # Define instance name from design model. - INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) - - 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/cat ${TEMPLATE} > ${INSTANCE} - - fi - - # Apply replacement of translation markers to design model - # translated instance. - cli_replaceTMarkers ${INSTANCE} - - # 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. 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. - render_checkAbsolutePaths "$INSTANCE" - - # Render template instance and 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' - - # Remove template instance. - if [[ -a $INSTANCE ]];then - rm $INSTANCE - fi - - # Execute post-rendition actions. - for ACTION in "${POSTACTIONS[@]}"; do - - case "$ACTION" in - - renderSyslinux* ) - render_doIdentityImageSyslinux "${FILE}" "$ACTION" - ;; - - renderGrub* ) - render_doIdentityImageGrub "${FILE}" "$ACTION" - ;; - - renderFormats:* ) - render_doIdentityImageFormats "${FILE}" "$ACTION" - ;; - - groupByType:* ) - render_doIdentityGroupByType "${FILE}" "$ACTION" - ;; - - esac - - done - - # Output separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Apply last-rendition actions. As convenction, last-rendition - # actions are applied after all images inside the same - # directory structure have been produced. Notice that, in - # order to apply last-rendition actions correctly, - # centos-art.sh needs to "predict" what the last file in the - # same directory structure would be. There is no magic here, - # so we need to previously define which are the common - # directory structures centos-art.sh could produce content - # for inside an array variable. Later, using the index of that - # array variable we could check the next item in the array - # against the file being currently produced. If they match, we - # haven't reached the end of the same directory structure, but - # if they don't match, we do have reach the end of the same - # directory structure and it is time for last-rendition - # actions to be evaluated before go producing the next - # directory structure in the list of files to process. - if [[ $(dirname "$TEMPLATE") != ${COMMONDIRS[$(($COMMONDIRCOUNT + 1))]} ]];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 evaluate last-rendition actions for the current - # directory structure. - for ACTION in "${LASTACTIONS[@]}"; do - - case "$ACTION" in - - renderKSplash ) - render_doIdentityImageKsplash - ;; - - renderDm:* ) - render_doIdentityImageDm "$ACTION" - ;; - - groupByType:* ) - render_doIdentityGroupByType "$ACTION" - ;; - - renderBrands ) - render_doIdentityImageBrands "${FILE}" "$ACTION" - ;; - - esac - done - fi - - # Increment common directory counter. - COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Functions/Identity/render_getActions.sh b/Scripts/Bash/Functions/Identity/render_getActions.sh deleted file mode 100644 index 05d0436..0000000 --- a/Scripts/Bash/Functions/Identity/render_getActions.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/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:,release:,architecture:,copy:,to:" - - # 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 - - --render ) - - # Redefine action name. - ACTIONNAM="${FUNCNAM}_doIdentity" - - # Redefine action value. - ACTIONVAL="$2" - - # Rotate positional parameters - shift 2 - ;; - - --copy ) - - # Redefine action value variable. - ACTIONVAL="$2" - - # Redefine action name variable. - ACTIONNAM="${FUNCNAME}_doCopy" - - # Rotate positional parameters - shift 2 - ;; - - --release ) - - # Redefine release number flag. - FLAG_RELEASE="$2" - - # Verify release number flag. - if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then - cli_printMessage "`gettext "The release number provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Rotate positional parameters - shift 2 - ;; - - --architecture ) - - # Redefine architecture flag. - FLAG_ARCHITECTURE="$2" - - # Verify architecture flag. - if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then - cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Rotate positional parameters - shift 2 - ;; - - --to ) - - # Redefine target value flag. - FLAG_TO="$2" - - # Rotate positional parameters - shift 2 - ;; - - * ) - # Break options loop. - break - esac - done - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Define pre-rendition configuration directory. Pre-rendition - # configuration directory is where we store render.conf.sh - # scripts. The render.conf.sh script defines how each identity - # content is rendered. - local ARTCONF=$(echo "$ACTIONVAL" \ - | sed -r -e 's!/(Identity)!/Scripts/Bash/Functions/Render/Config/\1!' \ - -e "s!Motifs/$(cli_getPathComponent '--theme')/?!!") - - # Check directory of pre-rendition configuration script. - cli_checkFiles "$ARTCONF" 'd' - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_commitRepoChanges - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges - -} diff --git a/Scripts/Bash/Functions/Identity/render_getIdentityBase.sh b/Scripts/Bash/Functions/Identity/render_getIdentityBase.sh deleted file mode 100755 index 02e8e3d..0000000 --- a/Scripts/Bash/Functions/Identity/render_getIdentityBase.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# render_getIdentityBase.sh -- This function initiates rendition features -# taking BASEACTIONS 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_getIdentityBase { - - local FILES='' - local PARENTDIR='' - local TEMPLATE='' - local COMMONDIR='' - local COMMONDIRCOUNT=0 - local -a COMMONDIRS - - # Redefine parent directory for current workplace. - PARENTDIR=$(basename "$ACTIONVAL") - - # Define base location of template files. - render_getIdentityDirTemplate - - # Define list of files to process. - FILES=$(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*\.(svgz|svg)") - - # Set action preamble. - # Do not print action preamble here, it prevents massive rendition. - - # Define common absolute paths in order 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 COMMONDIR in $(dirname "$FILES" | sort | uniq);do - COMMONDIRS[$COMMONDIRCOUNT]=$(dirname "$COMMONDIR") - COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) - done - - # Execute base-rendition action. - render_doIdentityImages - -} diff --git a/Scripts/Bash/Functions/Identity/render_getIdentityConfig.sh b/Scripts/Bash/Functions/Identity/render_getIdentityConfig.sh deleted file mode 100755 index 2363995..0000000 --- a/Scripts/Bash/Functions/Identity/render_getIdentityConfig.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# render_getIdentityConfig.sh -- This function checks/validates variables -# passed from artwork-specific pre-rendition configuration 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_getIdentityConfig { - - local POSTCOUNT=0 - local LASTCOUNT=0 - - # Re-define action variables in separated array variables. Once - # verification is done, we remove the BASE, POST, LAST parts from - # action definition in order to have the plain name of function to - # call. - for ACTION in "${ACTIONS[@]}"; do - - # Define post-rendition actions. - if [[ $ACTION =~ '^POST:' ]];then - ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') - POSTACTIONS[$POSTCOUNT]="$ACTION" - POSTCOUNT=$(($POSTCOUNT + 1)) - - # Define last-rendition actions. - elif [[ $ACTION =~ '^LAST:' ]];then - ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') - LASTACTIONS[$LASTCOUNT]="$ACTION" - LASTCOUNT=$(($LASTCOUNT + 1)) - fi - - done - - # Check post-rendition actions. Validation of post-rendition - # actions is action-specific. So, validation of post-rendition - # actions is not here, but inside action-specific functions. See - # render_doIdentityImages and render_doIdentityTexts to see - # validation of renderImage and renderText post-rendition actions, - # respectively. - - # Sanitate theme model value using repository directory name - # convenction. - THEMEMODEL=$(cli_getRepoName "$THEMEMODEL" 'd') - - # Check theme model directory. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}" 'd' - -} diff --git a/Scripts/Bash/Functions/Identity/render_getIdentityConfigOption.sh b/Scripts/Bash/Functions/Identity/render_getIdentityConfigOption.sh deleted file mode 100755 index 3e46d83..0000000 --- a/Scripts/Bash/Functions/Identity/render_getIdentityConfigOption.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# render_getIdentityConfigOption.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_getIdentityConfigOption "ACTION" "FIELD") -# -# VAR is the name of the variable where we store the option named -# returned by render_getIdentityConfigOption. -# -# 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., BASE, POST or LAST), and -# the second field is reserved for the action itself (e.g., -# renderImage, renderFormats, etc.). Note that this convenction can be -# altered if the action string has been modified (e.g., you stript the -# BASE field from action string) and passed the modified action string -# to another function for processing. -# -# 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_getIdentityConfigOption { - - 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/Functions/Identity/render_getIdentityDirOutput.sh b/Scripts/Bash/Functions/Identity/render_getIdentityDirOutput.sh deleted file mode 100644 index ecf8d12..0000000 --- a/Scripts/Bash/Functions/Identity/render_getIdentityDirOutput.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# render_getIdentityDirOutput.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_getIdentityDirOutput { - - # Define base output directory using design model path as reference. - OUTPUT=$(dirname $FILE | sed -r \ - -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!") - - # By default rendered identity content is stored immediatly under - # identity entry structure, but if `Img/' directory exists use it - # instead. - if [[ -d ${OUTPUT}/Img ]]; then - OUTPUT=${OUTPUT}/Img - fi - - # 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/Functions/Identity/render_getIdentityDirTemplate.sh b/Scripts/Bash/Functions/Identity/render_getIdentityDirTemplate.sh deleted file mode 100644 index 04e0e6e..0000000 --- a/Scripts/Bash/Functions/Identity/render_getIdentityDirTemplate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# render_getIdentityDirTemplate.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_getIdentityDirTemplate { - - # 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 - # (THEMEMODEL) 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/$THEMEMODEL!") - fi - -}