From 8219f02b4928c0a7fc471e92a5a72a97449f4406 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Nov 25 2010 15:32:39 +0000 Subject: Update render functionality: - Rename OPTIONNAM and OPTIONVAL varialbe names to ACTIONNAM and ACTIONVAL respectively. - Use the AsErrorLine output message style on error messages. - Rename render_getIdentityFileslist to render_getFilesFist function calls. - Add positional parameters interpretation using getopt(1) inside render_getFilesList function. - Change `--entry' to `--directory' option definition and `--filter' to reduce the amount of files processed inside the directory specified by `--directory'. --- diff --git a/Scripts/Bash/Functions/Render/Config/Translations/Identity/Brands/render.conf.sh b/Scripts/Bash/Functions/Render/Config/Translations/Identity/Brands/render.conf.sh index b5abe97..524036d 100755 --- a/Scripts/Bash/Functions/Render/Config/Translations/Identity/Brands/render.conf.sh +++ b/Scripts/Bash/Functions/Render/Config/Translations/Identity/Brands/render.conf.sh @@ -128,7 +128,7 @@ function render_loadConfig { FILE=$(echo $FILE | sed -r 's!^.+/Tpl/!!') # Check output directory existence. - DIRNAME=$(dirname $OPTIONVAL/$BOND/$FILE) + DIRNAME=$(dirname $ACTIONVAL/$BOND/$FILE) if [ ! -d $DIRNAME ]; then mkdir -p $DIRNAME fi @@ -139,8 +139,8 @@ function render_loadConfig { # This let us reuse translation files using symbolic links # and pointing them to translation template (`Tpl') files. cli_printMessage $TRANSLATION "AsTranslationLine" - cli_printMessage $OPTIONVAL/$BOND/$FILE "AsLinkToLine" - ln -sf $TRANSLATION $OPTIONVAL/$BOND/$FILE + cli_printMessage $ACTIONVAL/$BOND/$FILE "AsLinkToLine" + ln -sf $TRANSLATION $ACTIONVAL/$BOND/$FILE echo '----------------------------------------------------------------------' diff --git a/Scripts/Bash/Functions/Render/render.sh b/Scripts/Bash/Functions/Render/render.sh index 196a75d..3e5b767 100644 --- a/Scripts/Bash/Functions/Render/render.sh +++ b/Scripts/Bash/Functions/Render/render.sh @@ -32,7 +32,7 @@ function render { # Re-define root directory used to load pre-rendering # configuration scripts based on option value. - local ARTCONF=$(echo "$OPTIONVAL" \ + local ARTCONF=$(echo "$ACTIONVAL" \ | sed -r -e 's!/(Identity|Translations)!/Scripts/Bash/Functions/Render/Config/\1!' \ -e "s!Motifs/$(cli_getThemeName)/?!!") diff --git a/Scripts/Bash/Functions/Render/render_doIdentity.sh b/Scripts/Bash/Functions/Render/render_doIdentity.sh index 9e77661..3ee0ffe 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentity.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentity.sh @@ -49,11 +49,11 @@ function render_doIdentity { render_getIdentityOutputDir # Re-define parent directory for current workplace. - PARENTDIR=$(basename $OPTIONVAL) + PARENTDIR=$(basename $ACTIONVAL) # Re-define directory path used as reference to build the list of # files that will be rendered. - render_getIdentityFileslist + render_getFilesList # Define which type of features does centos-art.sh script is able # to performs. diff --git a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh index 110a207..d7b921f 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh @@ -113,7 +113,7 @@ function render_doIdentityGroupByType { # last-rendering 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 $OPTIONVAL -regextype posix-egrep -type f -regex ${PATTERNS[2]} \ + for FILE in $(find $ACTIONVAL -regextype posix-egrep -type f -regex ${PATTERNS[2]} \ | sed -r 's!\.[[:alpha:]]{1,4}$!!' | sort | uniq \ | egrep $REGEX);do FILES[$COUNT]="$FILE" diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh index b392ece..a7860e8 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh @@ -91,7 +91,7 @@ function render_doIdentityImageDm { # directories under # trunk/Translations/Identity/Themes/Distro/BootUp/ structure, # using the centos-art.sh script. - VERSIONS=$(find $OPTIONVAL -regextype posix-egrep \ + VERSIONS=$(find $ACTIONVAL -regextype posix-egrep \ -maxdepth 1 -type d -regex "^.*/${RELEASE_FORMAT}$" \ | egrep $REGEX) @@ -120,13 +120,13 @@ function render_doIdentityImageDm { VERSION=$(basename $VERSION) # Define directory to store release-specific images. - IMG=$OPTIONVAL/$VERSION/Img + IMG=$ACTIONVAL/$VERSION/Img # Check existence of release-specific image directory. cli_checkFiles "$IMG" 'd' # Define directory to store release-specific tar.gz files. - TGZ=$OPTIONVAL/$VERSION/Tgz + TGZ=$ACTIONVAL/$VERSION/Tgz # Check existence of release-specific tar.gz directory. cli_checkFiles "$TGZ" 'd' diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageKsplash.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageKsplash.sh index 3da4795..af01728 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageKsplash.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageKsplash.sh @@ -31,7 +31,7 @@ function render_doIdentityImageKsplash { local RELDIR='' local KSPLASH_TOP='' local KSPLASH_PREVIEW='' - local RELDIRS=$(find $OPTIONVAL -regextype posix-egrep -maxdepth 1 \ + local RELDIRS=$(find $ACTIONVAL -regextype posix-egrep -maxdepth 1 \ -type d -regex "^.*/$RELEASE_FORMAT$" | egrep $REGEX) # Define font file used to render Preview.png bottom text. @@ -41,8 +41,8 @@ function render_doIdentityImageKsplash { # images. Since we are building Preview with active and bottom # splash only, there is no need to include inactive bar on # checking. - local KSPLASH_ACTIVE_BAR="$OPTIONVAL/splash_active_bar.png" - local KSPLASH_BOTTOM="$OPTIONVAL/splash_bottom.png" + local KSPLASH_ACTIVE_BAR="$ACTIONVAL/splash_active_bar.png" + local KSPLASH_BOTTOM="$ACTIONVAL/splash_bottom.png" # Check existence of non-release-specific required image files. cli_checkFiles $KSPLASH_ACTIVE_BAR diff --git a/Scripts/Bash/Functions/Render/render_getActions.sh b/Scripts/Bash/Functions/Render/render_getActions.sh index fb4a441..f3d036a 100644 --- a/Scripts/Bash/Functions/Render/render_getActions.sh +++ b/Scripts/Bash/Functions/Render/render_getActions.sh @@ -28,44 +28,38 @@ function render_getActions { # Evaluate option name and define which actions does centos-art.sh # script supports. - case $OPTIONNAM in + case $ACTIONNAM in - --entry ) + --directory ) - if [[ $OPTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Identity/.+$' ]];then + if [[ $ACTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Identity/.+$' ]];then # Define identity rendering support. render_getActionsIdentity - elif [[ $OPTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Translations/.+$' ]];then + elif [[ $ACTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Translations/.+$' ]];then # Define translation rendering support. render_getActionsTranslations else - cli_printMessage "`gettext "The path provided can't be processed."`" - cli_printMessage "trunk/Scripts/Bash" "AsToKnowMoreLine" + cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi ;; * ) - cli_printMessage "`eval_gettext "The option provided is not valid."`" - - if [[ $OPTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Identity/.+$' ]];then - - cli_printMessage "$OPTIONVAL" "AsToKnowMoreLine" - - elif [[ $OPTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Translations/.+$' ]];then - - cli_printMessage "$OPTIONVAL" "AsToKnowMoreLine" + cli_printMessage "`eval_gettext "The option provided is not valid."`" 'AsErrorLine' + if [[ $ACTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Identity/.+$' ]];then + cli_printMessage "$ACTIONVAL" 'AsToKnowMoreLine' + elif [[ $ACTIONVAL =~ '^/home/centos/artwork/(trunk|branches|tags)/Translations/.+$' ]];then + cli_printMessage "$ACTIONVAL" 'AsToKnowMoreLine' else - - cli_printMessage "$(caller)" "AsToKnowMoreLine" - + cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi ;; diff --git a/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh b/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh index 016b296..897da25 100755 --- a/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh +++ b/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh @@ -50,8 +50,8 @@ function render_getActionsIdentity { # directory which currently doesn't exist there is nothing to do # here, so leave a message quit script execution. if [[ ! -d $ARTCONF ]];then - cli_printMessage "`gettext "The path provided can't be processed."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" + cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi for FILE in $(find $ARTCONF -name 'render.conf.sh');do @@ -81,16 +81,16 @@ function render_getActionsIdentity { # configuration scripts and make required transformations. render_checkConfig - # Re-define option value (OPTIONVAL) based on pre-rendering + # Re-define option value (ACTIONVAL) based on pre-rendering # configuration script path value. Otherwise massive rendering # may fail. Functions like renderImage need to know the exact # artwork path (that is, where images will be stored). - OPTIONVAL=$(dirname $(echo $FILE | sed -r \ + ACTIONVAL=$(dirname $(echo $FILE | sed -r \ -e 's!Scripts/Bash/Functions/Render/Config/Identity/!Identity/!' \ -e "s!Themes/!Themes/Motifs/$(cli_getThemeName)/!")) # Re-define artwork identification. - ARTCOMP=$(echo $OPTIONVAL | cut -d/ -f6-) + 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 diff --git a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh index 1aa76f5..5e5af2e 100755 --- a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh +++ b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh @@ -32,7 +32,7 @@ function render_getActionsTranslations { # directory. Translation rendering is based on translation # templates inside 'Tpl/' directory. If that directory doesn't # exist leave a message and quit execution. - if [[ ! -d $OPTIONVAL/Tpl ]];then + if [[ ! -d $ACTIONVAL/Tpl ]];then cli_printMessage "`gettext "Can't find translation templates in the directory provided."`" cli_printMessage "$(caller)" "AsToKnowMoreLine" fi @@ -98,7 +98,7 @@ function render_getActionsTranslations { # translations directories available in the current location will # be affected. if [[ $REGEX =~ "^$RELEASE_FORMAT$" ]];then - RELEASES=$OPTIONVAL/$REGEX + RELEASES=$ACTIONVAL/$REGEX # Re-define releases using regular expression value. If you need # to create/update two or more release-specific directories (e.g., @@ -113,8 +113,8 @@ function render_getActionsTranslations { # By default look for available release-specific directories and # use them all. else - RELEASES=$(find $OPTIONVAL -regextype posix-egrep \ - -regex "^$OPTIONVAL/$RELEASE_FORMAT$" | sort) + RELEASES=$(find $ACTIONVAL -regextype posix-egrep \ + -regex "^$ACTIONVAL/$RELEASE_FORMAT$" | sort) fi # At this point, if there isn't release-specific directories @@ -157,7 +157,7 @@ function render_getActionsTranslations { # Get translation templates and process them using release # information previously defined. - for FILE in $(find $OPTIONVAL/Tpl -name '*.sed');do + for FILE in $(find $ACTIONVAL/Tpl -name '*.sed');do # Define translation file locale. LOCALE=$(echo $FILE | sed -r 's!^/.+/Tpl/([a-z]{2}|[a-z]{2}_[A-Z]{2})/.+$!\1!' ) diff --git a/Scripts/Bash/Functions/Render/render_getFilesList.sh b/Scripts/Bash/Functions/Render/render_getFilesList.sh index ef1b0bc..81213a4 100644 --- a/Scripts/Bash/Functions/Render/render_getFilesList.sh +++ b/Scripts/Bash/Functions/Render/render_getFilesList.sh @@ -27,6 +27,31 @@ function render_getFilesList { + # Define short options we want to support. + ARGSS="" + + # Define long options we want to support. + ARGSL="filter:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + --filter ) + REGEX="$2" + shift 2 + ;; + * ) + break + esac + done + # Define source location to look files for. In order to define # source location we evaluate both matching list and translation # path information, and based on them, we set which is the source diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh index ce070b8..270ccac 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh @@ -55,7 +55,7 @@ function render_getIdentityDefs { # Define the design template absolute path. This definition is # done by interpreting the matching list and translation path # information. This defintion needs to be coherent with those - # defined in render_getIdentityFileslist function. + # defined in render_getFilesList function. if [[ "${MATCHINGLIST}" != "" ]] \ && [[ "${TRANSLATIONPATH}" == "" ]];then @@ -345,7 +345,7 @@ function render_getIdentityDefs { # Create the design template instance. When building the instance, # take into account the matching list and translation path. It # should be coherent with previous definitions above and in - # render_getIdentityFileslist. + # render_getFilesList. if [[ "${MATCHINGLIST}" == "" ]] \ && [[ "${TRANSLATIONPATH}" != "" ]];then diff --git a/Scripts/Bash/Functions/Render/render_getIdentityOutputDir.sh b/Scripts/Bash/Functions/Render/render_getIdentityOutputDir.sh index d11ee35..d337c53 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityOutputDir.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityOutputDir.sh @@ -28,16 +28,16 @@ function render_getIdentityOutputDir { # By default rendered identity artworks are stored immediatly # under identity entry structure. - IMG=$OPTIONVAL + IMG=$ACTIONVAL # But if Img/ directory exists, use it instead. - if [[ -d $OPTIONVAL/Img ]]; then - IMG=$OPTIONVAL/Img + if [[ -d $ACTIONVAL/Img ]]; then + IMG=$ACTIONVAL/Img fi # But if Txt/ directory exists, use it instead. - if [[ -d $OPTIONVAL/Txt ]]; then - IMG=$OPTIONVAL/Txt + if [[ -d $ACTIONVAL/Txt ]]; then + IMG=$ACTIONVAL/Txt fi } diff --git a/Scripts/Bash/Functions/Render/render_getIdentityTemplateDir.sh b/Scripts/Bash/Functions/Render/render_getIdentityTemplateDir.sh index 71e269c..7c0f939 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityTemplateDir.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityTemplateDir.sh @@ -28,7 +28,7 @@ function render_getIdentityTemplateDir { # By default design templates are stored in the artworks identity # entry, under Tpl/ directory. - SVG=$OPTIONVAL/Tpl + SVG=$ACTIONVAL/Tpl # If you are rendering theme motifs, design templates are not # stored inside Tpl directory. Instead, we use one common theme @@ -37,7 +37,7 @@ function render_getIdentityTemplateDir { # to use before rendering artistic motifs. if [[ ! -d $SVG ]] \ && [[ $SVG =~ "trunk/Identity/Themes/Motifs/$(cli_getThemeName)/" ]]; then - SVG=$(echo "$OPTIONVAL" | sed "s!Motifs/$(cli_getThemeName)!Models/$THEMEMODEL!") + SVG=$(echo "$ACTIONVAL" | sed "s!Motifs/$(cli_getThemeName)!Models/$THEMEMODEL!") fi }