From 05d9ae042b75547cd89593a95ce270222a509e95 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Mar 07 2011 23:21:23 +0000 Subject: Update `identity' functionality: - Rename command-line interface options: from to --------------- -------------- --release --releasever --architecture --basearch - Add the following options to command-line interface to be process as post-rendition actions: option description --------------- -------------- --convert-to to convert final PNG output to different image formats. --grouped-by to group similar image files into directories. These options were used in pre-rendition configuration scripts, but now pre-rendition configuration script are no longer used. - Do not use pre-rendition configuration scripts anymore. Instead, use command-line options and directory-specific processing to execute post-rendition and last-rendition actions. - Merge identity_getConfig.sh into identity_render functionality. Specifically, inside identity_renderSvgPostActions and identity_renderSvgLastActions to implement directory-specific processing of post-rendition and last-rendition actions. - Remove identity_getConfig.sh. --- diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh index 9aff109..2b9cf4b 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_getActions.sh @@ -26,16 +26,14 @@ function identity_getActions { - # Initialize actions array variable, the place used to - # to store post-rendition and last-rendition action definitions - # retrived from command-line interface. - local -a ACTIONS + # Initialize post-rendition actions passed from command-line. + local -a POSTACTIONS # Define short options we want to support. local ARGSS="" # Define long options we want to support. - local ARGSL="render:,release:,architecture:,copy:,to:,syslinux,grub,gdm,kdm,ksplash,format:,group-by-type:" + local ARGSL="render:,releasever:,basearch:,copy:,to:,convert-to:,grouped-by:" # Parse arguments using getopt(1) command parser. cli_doParseArguments @@ -61,16 +59,16 @@ function identity_getActions { shift 2 ;; - --release ) + --releasever ) FLAG_RELEASE="$2" if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then - cli_printMessage "`gettext "The release number provided is not supported."`" 'AsErrorLine' + cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine' cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi shift 2 ;; - --architecture ) + --basearch ) FLAG_ARCHITECTURE="$2" if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' @@ -84,40 +82,13 @@ function identity_getActions { shift 2 ;; - --syslinux ) - ACTIONS[$((${#ACTIONS[*]} + 1))]='POST:renderSyslinux:' - ACTIONS[$((${#ACTIONS[*]} + 1))]='POST:renderSyslinux:-floyd' - shift 1 - ;; - - --grub ) - ACTIONS[$((${#ACTIONS[*]} + 1))]='POST:renderGrub:' - ACTIONS[$((${#ACTIONS[*]} + 1))]='POST:renderGrub:-floyd' - shift 1 - ;; - - --ksplash ) - ACTIONS[$((${#ACTIONS[*]} + 1))]='LAST:renderKsplash' - shift 1 - ;; - - --gdm ) - ACTIONS[$((${#ACTIONS[*]} + 1))]='LAST:renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 1680x1050 2048x1536 2560x960 2560x1240 3271x1227' - shift 1 - ;; - - --kdm ) - ACTIONS[$((${#ACTIONS[*]} + 1))]='LAST:renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 1680x1050 2048x1536 2560x960 2560x1240 3271x1227' - shift 1 - ;; - - --group-by-type ) - ACTIONS[$((${#ACTIONS[*]} + 1))]="POST:groupByType:$2" + --convert-to ) + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]="renderFormats:$2" shift 2 ;; - --format ) - ACTIONS[$((${#ACTIONS[*]} + 1))]="POST:renderFormats:$2" + --grouped-by ) + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]="groupByType:$2" shift 2 ;; diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh deleted file mode 100755 index 9b88029..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# identity_getConfig.sh -- This function retrives values set in -# 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 identity_getConfig { - - local COUNT=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 - - if [[ $ACTION =~ '^POST:' ]];then - # Define post-rendition action. - POSTACTIONS[$COUNT]=$(identity_getConfigOption "$ACTION" '2-') - elif [[ $ACTION =~ '^LAST:' ]];then - # Define last-rendition action. - LASTACTIONS[$COUNT]=$(identity_getConfigOption "$ACTION" '2-') - else - cli_printMessage "`gettext "The base-rendition action you specified is not supported yet."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Sanitate theme model value using repository directory name - # convenction. - FLAG_THEME_MODEL=$(cli_getRepoName "$FLAG_THEME_MODEL" 'd') - - # Check theme model directory. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh b/Scripts/Bash/Cli/Functions/Identity/identity_render.sh index 086a55c..ae17275 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_render.sh @@ -39,11 +39,12 @@ function identity_render { local NEXT_FILE_DIR='' local COUNT=0 - # Define post-rendition and last-rendition array variables from - # actions array variable. - local -a POSTACTIONS - local -a LASTACTIONS - identity_getConfig + # Sanitate theme model value using repository directory name + # convenction. + FLAG_THEME_MODEL=$(cli_getRepoName "$FLAG_THEME_MODEL" 'd') + + # Check theme model directory. + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' # Define the extension pattern for template files. This is the # file extensions that centos-art will look for in order to build @@ -65,16 +66,12 @@ function identity_render { # required in order for centos-art.sh to know when to apply # last-rendition actions. for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do - FILES[$COUNT]=$FILE - COUNT=$(($COUNT + 1)) + FILES[$((${#FILES[*]} - 1 + 1))]=$FILE done # Set action preamble. cli_printActionPreamble "${FILES[*]}" '' '' - # Reset common directory counter. - COUNT=0 - # Start processing the base rendition list of FILES. Fun part # approching :-). while [[ $COUNT -lt ${#FILES[*]} ]];do diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh index 62e912a..9fcf788 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh @@ -32,6 +32,10 @@ function identity_renderPostActions { case "${ACTION}" in + renderFormats:* ) + identity_renderFormats + ;; + groupByType:* ) identity_renderGroupByType ;; diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh index caf9281..88a7ed5 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh @@ -30,30 +30,47 @@ function identity_renderSvgLastActions { # Verify position of file being produced in the list of files been # currently processed. - if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then + if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then + return + fi - # At this point centos-art.sh should be producing the last - # file from the same unique directory structure, so, before - # producing images for the next directory structure lets - # execute last-rendition actions for the current directory - # structure. - for ACTION in "${LASTACTIONS[@]}"; do + # Define SVG-directory-specific last-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # last-rendition actions. + local -a LASTACTIONS - case "${ACTION}" in + # Add directory-specific last-rendition actions to the list of + # post actions and last actions. This is required in order to + # provide a predictable way of producing content inside the + # repository and save you the time of writing long option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Gdm/.+\.svg$" ]];then + LASTACTIONS[$((${#LASTACTIONS[*]} - 1 + 1))]='renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Kdm/.+\.svg$" ]];then + LASTACTIONS[$((${#LASTACTIONS[*]} - 1 + 1))]='renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + LASTACTIONS[$((${#LASTACTIONS[*]} - 1 + 1))]='renderKsplash' + fi - renderKSplash ) - identity_renderKsplash - ;; + # At this point centos-art.sh should be producing the last file + # from the same unique directory structure, so, before producing + # images for the next directory structure lets execute + # last-rendition actions for the current directory structure. + for ACTION in "${LASTACTIONS[@]}"; do - renderDm:* ) - identity_renderDm - ;; + case "${ACTION}" in - esac + renderKsplash ) + identity_renderKsplash + ;; - done + renderDm:* ) + identity_renderDm + ;; - fi + esac -} + done +} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh index 95a3eab..286cfbc 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh @@ -28,6 +28,30 @@ function identity_renderSvgPostActions { local ACTION='' + # Define SVG-directory-specific post-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # post-rendition actions. + local -a POSTACTIONS + + # Execute SVG-directory-specific post-rendition actions to the + # list of post actions and last actions. This is required in order + # to provide a predictable way of producing content inside the + # repository and save you the time of writing long option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Distro/Backgrounds/.+\.svg$" ]];then + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderFormats: jpg' + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='groupByFormat: png jpg' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Syslinux/.+\.svg$" ]];then + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderSyslinux' + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderSyslinux:-floyd' + elif [[ $TEMPLATE =~ "Grub" ]];then + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderGrub' + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderGrub:-floyd' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + POSTACTIONS[$((${#POSTACTIONS[*]} - 1 + 1))]='renderKsplash' + fi + for ACTION in "${POSTACTIONS[@]}"; do case "${ACTION}" in @@ -40,10 +64,6 @@ function identity_renderSvgPostActions { identity_renderGrub ;; - renderFormats:* ) - identity_renderFormats - ;; - renderBrands ) identity_renderBrands ;;