diff --git a/Scripts/Bash/Functions/Path/path.sh b/Scripts/Bash/Functions/Path/path.sh index 4ca8fff..41a72c4 100755 --- a/Scripts/Bash/Functions/Path/path.sh +++ b/Scripts/Bash/Functions/Path/path.sh @@ -1,9 +1,9 @@ #!/bin/bash # # path.sh -- This function provides file manipulations to aliviate -# maintain of paths inside the repository. +# path maintainance inside the repository. # -# Copyright (C) 2009-2011 Alain Reguera Delgado +# 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 @@ -26,6 +26,16 @@ function path { + # Define deafult value to target flag. The target flag (--to) + # controls final destination used by copy related actions. + local FLAG_TO='' + + # Define default value to syncronization flag. The syncronization + # flag (--sync) controls wether centos-art.sh script calls itself + # to create/delete parallel directories at the moment of + # create/delte action itself. + local FLAG_SYNC='false' + # Define command-line interface. path_getActions diff --git a/Scripts/Bash/Functions/Path/path_doCopy.sh b/Scripts/Bash/Functions/Path/path_doCopy.sh index d3831ab..0e2574d 100755 --- a/Scripts/Bash/Functions/Path/path_doCopy.sh +++ b/Scripts/Bash/Functions/Path/path_doCopy.sh @@ -3,7 +3,7 @@ # path_doCopy.sh -- This function duplicates files inside the working # copy using subversion commands. # -# Copyright (C) 2009-2011 Alain Reguera Delgado +# 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 @@ -26,82 +26,47 @@ function path_doCopy { - local -a SRC - local -a DST - local -a DOC - local COUNT=0 - # Verify target variable. We can't continue if target is empty. - if [[ $TARGET == '' ]];then + if [[ $FLAG_TO == '' ]];then cli_printMessage "`gettext "There is no target to work with."`" 'AsErrorLine' cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi - # Define source locations. Start with parent directory at position - # zero and continue with related parallel directories. - SRC[0]=$ACTIONVAL - SRC[1]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${SRC[0]}" "--relative")").texi - SRC[2]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Scripts/Bash/Functions/Render/Config") - SRC[3]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Translations") - - # Define target locations. Start with parent directory at position - # zero and continue with related parallel directories. - DST[0]=$TARGET - DST[1]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" "--relative")").texi - DST[2]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Scripts/Bash/Functions/Render/Config") - DST[3]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Translations") - - # Define documentation files that need to be counted inside - # changes commited up to central repository. - DOC[0]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-menu.texi - DOC[1]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-nodes.texi - - # Syncronize changes between working copy and central repository. - cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}" - - # Print preamble with affected entries. - cli_printMessage "`ngettext "The following entry will be created" \ - "The following entries will be created" "${#DST[*]}"`:" - while [[ $COUNT -lt ${#DST[*]} ]];do - # Print affected entry. - cli_printMessage "${DST[$COUNT]}" 'AsResponseLine' - # Increment counter. - COUNT=$(($COUNT + 1)) - done - - # Request confirmation before continue with action. - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + # Print action preamble. + cli_printActionPreamble "${FLAG_TO}" 'doCreate' 'AsResponseLine' + + # Verify relation between source and target locations. We cannot + # duplicate an entry if its parent directory doesn't exist as + # entry inside the working copy. + if [[ -f ${ACTIONVAL} ]];then + if [[ ! -d $(dirname ${FLAG_TO}) ]];then + mkdir -p $(dirname ${FLAG_TO}) + fi + svn add $(dirname ${FLAG_TO}) --quiet + fi - # Reset counter. - COUNT=0 + # Print action message. + cli_printMessage "${FLAG_TO}" 'AsCreatingLine' - while [[ $COUNT -lt ${#DST[*]} ]];do + # Copy parent directory. + svn copy ${ACTIONVAL} ${FLAG_TO} --quiet - # Verify relation between source and target locations. We - # cannot duplicate an entry if its parent directory doesn't - # exist as entry inside the working copy. - if [[ -f ${SRC[$COUNT]} ]];then - if [[ ! -d $(dirname ${DST[$COUNT]}) ]];then - mkdir -p $(dirname ${DST[$COUNT]}) - fi - svn add $(dirname ${DST[$COUNT]}) --quiet - fi + # Verify syncronization flag. + if [[ $FLAG_SYNC == 'true' ]];then - # Print action message. - cli_printMessage "${DST[$COUNT]}" 'AsCreatingLine' + # Copy parallel directories. + . /home/centos/bin/centos-art manual --copy="$ACTIONVAL" --to="$FLAG_TO" + . /home/centos/bin/centos-art render --copy="$ACTIONVAL" --to="$FLAG_TO" + . /home/centos/bin/centos-art locale --copy="$ACTIONVAL" --to="$FLAG_TO" - # Perform action. - svn copy ${SRC[$COUNT]} ${DST[$COUNT]} --quiet + # Syncronize changes from working copy to central repository. + cli_commitRepoChanges "$ACTIONVAL $FLAG_TO $(cli_getRepoParallelDirs "$FLAG_TO")" - # Increase counter. - COUNT=$(($COUNT + 1)) + else - done + # Syncronize changes from working copy to central repository. + cli_commitRepoChanges "$ACTIONVAL $FLAG_TO" - # Update texinfo documentation structure. - . /home/centos/bin/centos-art manual --update-structure="${DST[0]}" - - # Syncronize changes between working copy and central repository. - cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}" + fi } diff --git a/Scripts/Bash/Functions/Path/path_doDelete.sh b/Scripts/Bash/Functions/Path/path_doDelete.sh index d04879e..8b62533 100755 --- a/Scripts/Bash/Functions/Path/path_doDelete.sh +++ b/Scripts/Bash/Functions/Path/path_doDelete.sh @@ -3,7 +3,7 @@ # path_doDelete.sh -- This function deletes files inside the working # copy using subversion commands. # -# Copyright (C) 2009-2011 Alain Reguera Delgado +# 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 @@ -26,9 +26,7 @@ function path_doDelete { - local -a SRC - local -a DOC - local COUNT=0 + local PDIR # Verify target variable. We can't continue if target is empty. if [[ $ACTIONVAL == '' ]];then @@ -36,45 +34,21 @@ function path_doDelete { cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi - # Update texinfo related entry documentation. - . /home/centos/bin/centos-art manual --delete="$ACTIONVAL" - - # Define source locations. Start with parent directory at position - # zero and continue with related parallel directories. - SRC[0]=$ACTIONVAL - SRC[1]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Scripts/Bash/Functions/Render/Config") - SRC[2]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Translations") - - # Print preamble with affected entries. - cli_printMessage "`ngettext "The following entry will be deleted" \ - "The following entries will be deleted" "${#SRC[*]}"`:" - while [[ $COUNT -lt ${#SRC[*]} ]];do - # Print affected entry. - cli_printMessage "${SRC[$COUNT]}" 'AsResponseLine' - # Increment counter. - COUNT=$(($COUNT + 1)) - done - - # Request confirmation before continue with action. - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + # Print action preamble. + cli_printActionPreamble "$ACTIONVAL" 'doDelete' 'AsResponseLine' - # Reset counter. - COUNT=0 - - while [[ $COUNT -lt ${#SRC[*]} ]];do - - # Print action message. - cli_printMessage "${SRC[$COUNT]}" 'AsDeletingLine' - - # Perform action. - svn del ${SRC[$COUNT]} --quiet + # Syncronize parallel directories related to action value. + . /home/centos/bin/centos-art manual --delete="$ACTIONVAL" + . /home/centos/bin/centos-art render --delete="$ACTIONVAL" + . /home/centos/bin/centos-art locale --delete="$ACTIONVAL" - # Increase counter. - COUNT=$(($COUNT + 1)) + # Print action message. + cli_printMessage "${ACTIONVAL}" 'AsDeletingLine' - done + # Perform action. + svn del ${ACTIONVAL} --quiet # Syncronize changes between working copy and central repository. - cli_commitRepoChanges "${SRC[@]}" + cli_commitRepoChanges "$ACTIONVAL $(cli_getRepoParallelDirs "$ACTIONVAL")" } diff --git a/Scripts/Bash/Functions/Path/path_getActions.sh b/Scripts/Bash/Functions/Path/path_getActions.sh index 7fdcaa8..634f002 100755 --- a/Scripts/Bash/Functions/Path/path_getActions.sh +++ b/Scripts/Bash/Functions/Path/path_getActions.sh @@ -3,7 +3,7 @@ # path_getActions.sh -- This function interpretes arguments passed to # `path' functionality and calls actions accordingly. # -# Copyright (C) 2009-2011 Alain Reguera Delgado +# 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 @@ -30,7 +30,7 @@ function path_getActions { local ARGSS="" # Define long options we want to support. - local ARGSL="copy:,move:,delete:,to:" + local ARGSL="copy:,move:,delete:,to:,quiet,sync,yes" # Parse arguments using getopt(1) command parser. cli_doParseArguments @@ -48,93 +48,62 @@ function path_getActions { # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - # Define action name using action value as reference. ACTIONNAM="${FUNCNAM}_doCopy" - # Look for related sub-options. - while true; do - case "$3" in - - --to ) - - # Redefine target directory. - TARGET="$4" - - # Verify target directory. - cli_checkRepoDirTarget - - # Rotate positional parameters. - shift 4 - ;; - - * ) - # Break sub-options loop. - break - ;; - esac - done - - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; - --move ) + --delete ) # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_doMove" + ACTIONNAM="${FUNCNAM}_doDelete" - # Look for related sub-options. - while true; do - case "$3" in + # Rotate positional parameters. + shift 2 + ;; - --to ) + --to ) - # Redefine target directory. - TARGET="$4" + # Redefine target flag. + FLAG_TO="$2" - # Verify target directory. - cli_checkRepoDirTarget + # Verify target directory. + cli_checkRepoDirTarget - # Rotate positional parameters. - shift 4 - ;; + # Rotate positional parameters. + shift 2 + ;; - * ) - # Break sub-options loop. - break - ;; - esac - done + --sync ) - # Break options loop. - break + # Redefine syncronization flag. + FLAG_SYNC='true' + + # Rotate positional parameters. + shift 1 ;; - --delete ) + --quiet ) - # Define action value passed through the command-line. - ACTIONVAL="$2" + # Redefine verbosity flag. + FLAG_QUIET='true' - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource + # Rotate positional parameters. + shift 1 + ;; - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_doDelete" + --yes ) - # Break options loop. - break + # Redefine answer flag. + FLAG_YES='true' + + # Rotate positional parameters. + shift 1 ;; * ) @@ -148,6 +117,10 @@ function path_getActions { cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi + # Check action value (ACTIONVAL) passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + # Execute action name. if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then eval $ACTIONNAM