From a6bab370943071ff501cc8a048ba6ace1f1c9264 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jun 11 2011 16:27:15 +0000 Subject: Update `tuneup' functionality: - Previous to this commmit, a regular expression was defined to set the file extensions supported as pattern. Then, one list of files was built using both the action value and the file extension regular expression pattern. Later, when processing the list of files, backend-specific functionalities were exported and unset for each file in the list based on the file extension. - In this commit, the supported file extensions are no longer defined as a regular expression pattern. Instead, we use a simple list of values (e.g., `TUNEUP_EXTENSIONS="svg xhtml sh"') and loop through it to create one list of files to process for each supported extension individually. Then, if the list of files is not empty, we export backend-specific functionalities and then loop through the list of files to process to apply backend-specific maintaince tasks to each file in the list, individually. Once all files in the list has been processed, backend-specific functionalities are unset and the next supported extension is evaluated in the same way described here. This commit is much more optimized than previous one. Specially for environmnets where many different files need to be processed in just one run of `centos-art.sh' script. In this commit, we've organized the list of files to process by extension, in order to export/unset only the backend-specific functionalities needed for extension-specific processing. Nice, doesn't it? :) --- diff --git a/Scripts/Functions/Tuneup/tuneup.sh b/Scripts/Functions/Tuneup/tuneup.sh index 2c08ba5..f87c4be 100755 --- a/Scripts/Functions/Tuneup/tuneup.sh +++ b/Scripts/Functions/Tuneup/tuneup.sh @@ -38,6 +38,10 @@ function tuneup { # where backend-specific directories are stored in. local TUNEUP_BACKEND_DIR="${FUNCDIR}/${FUNCDIRNAM}/Backends" + # Initialize list of supported file extensions. This is, the file + # extensions we want to perform maintainance tasks for. + local TUNEUP_EXTENSIONS='svg xhtml sh' + # Interpret arguments and options passed through command-line. tuneup_getOptions @@ -68,11 +72,7 @@ function tuneup { cli_syncroRepoChanges # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" --as-error-line - fi + $ACTIONNAM # Commit changes from working copy to central repository only. # At this point, changes in the repository are not merged in diff --git a/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh b/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh index 9eda77b..1638375 100755 --- a/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh +++ b/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# tuneup_doBaseActions.sh -- This function builds the list of files to -# process and performs maintainance tasks, file by file. +# tuneup_doBaseActions.sh -- This function builds one list of files to +# process for each file extension supported and applies maintainance +# tasks file by file for each one of them. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -25,40 +26,45 @@ function tuneup_doBaseActions { - # Define file extensions we'll look files for. This is, the - # extension of files we want to perform maintainance tasks for. - local EXTENSION='(svg|xhtml|sh)' - - # Build list of files to process using action value as reference. + local TUNEUP_EXTENSION='' local FILE='' - local FILES=$(cli_getFilesList ${ACTIONVAL} --pattern="${FLAG_FILTER}\.${EXTENSION}") + local FILES='' # Print separator line. cli_printMessage '-' --as-separator-line - # Process list of files and perform maintainance tasks - # accordingly. - for FILE in $FILES;do - - # Print action message. - cli_printMessage "$FILE" --as-tuningup-line + for TUNEUP_EXTENSION in ${TUNEUP_EXTENSIONS};do # Redefine name of tuneup backend based on the file extension # of file being processed. - if [[ $FILE =~ '\.svg$' ]];then + if [[ $TUNEUP_EXTENSION == 'svg' ]];then TUNEUP_BACKEND='svg' - elif [[ $FILE =~ '\.xhtml$' ]];then + elif [[ $TUNEUP_EXTENSION == 'xhtml' ]];then TUNEUP_BACKEND='xhtml' - elif [[ $FILE =~ '\.sh$' ]];then + elif [[ $TUNEUP_EXTENSION == 'sh' ]];then TUNEUP_BACKEND='shell' + else + cli_printMessage "`gettext "No file to tune up found."`" --as-error-line + fi + + # Build list of files to process using action value as reference. + FILES=$(cli_getFilesList ${ACTIONVAL} --pattern="${FLAG_FILTER}\.${TUNEUP_EXTENSION}") + + # Verify list of files to process. Assuming no file is found, + # evaluate the next supported file extension. + if [[ $FILES == '' ]];then + continue fi # Initialize backend-specific functionalities. cli_exportFunctions "${TUNEUP_BACKEND_DIR}/$(cli_getRepoName \ ${TUNEUP_BACKEND} -d)" "${TUNEUP_BACKEND}" - # Perform backend base-rendition. - ${TUNEUP_BACKEND} + # Apply backend-specific maintainance tasks. + for FILE in $FILES;do + cli_printMessage "$FILE" --as-tuningup-line + ${TUNEUP_BACKEND} + done # Unset backend-specific functionalities from environment. # This is required to prevent end up with more than one