Blame Scripts/Bash/Functions/Path/path_doCopy.sh

407d66
#!/bin/bash
407d66
#
6ecc07
# path_doCopy.sh -- This function duplicates files inside the working
6ecc07
# copy using subversion commands.
407d66
#
407d66
# Copyright (C) 2009, 2010 Alain Reguera Delgado
407d66
# 
407d66
# This program is free software; you can redistribute it and/or modify
407d66
# it under the terms of the GNU General Public License as published by
407d66
# the Free Software Foundation; either version 2 of the License, or
407d66
# (at your option) any later version.
407d66
# 
407d66
# This program is distributed in the hope that it will be useful, but
407d66
# WITHOUT ANY WARRANTY; without even the implied warranty of
407d66
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
407d66
# General Public License for more details.
407d66
#
407d66
# You should have received a copy of the GNU General Public License
407d66
# along with this program; if not, write to the Free Software
407d66
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
407d66
# USA.
407d66
# 
407d66
# ----------------------------------------------------------------------
407d66
# $Id$
407d66
# ----------------------------------------------------------------------
407d66
407d66
function path_doCopy {
407d66
6ecc07
    local -a SRC
6ecc07
    local -a DST
8ba5a0
    local -a DOC
6ecc07
    local COUNT=0
8ba5a0
8ba5a0
    # Verify target variable. We can't continue if target is empty.
8ba5a0
    if [[ $TARGET == '' ]];then
8ba5a0
        cli_printMessage "`gettext "There is no target to work with."`" 'AsErrorLine'
8ba5a0
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
8ba5a0
    fi
8ba5a0
8ba5a0
    # Define source locations. Start with parent directory at position
8ba5a0
    # zero and continue with parent directory related parallel
8ba5a0
    # directories.
8ba5a0
    SRC[0]=$ACTIONVAL
8ba5a0
    SRC[1]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${SRC[0]}" "--relative")").texi
8ba5a0
    SRC[2]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Scripts/Bash/Functions/Render/Config")
8ba5a0
    SRC[3]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Translations")
8ba5a0
8ba5a0
    # Define target locations. Start with parent directory at position
8ba5a0
    # zero and continue with parent directory related parallel
8ba5a0
    # directories.
6ecc07
    DST[0]=$TARGET
8ba5a0
    DST[1]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" "--relative")").texi
8ba5a0
    DST[2]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Scripts/Bash/Functions/Render/Config")
8ba5a0
    DST[3]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Translations")
8ba5a0
8ba5a0
    # Define documentation files that need to be counted inside
8ba5a0
    # changes commited up to central repository.
8ba5a0
    DOC[0]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-menu.texi
8ba5a0
    DOC[1]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-nodes.texi
6ecc07
6ecc07
    # Syncronize changes between working copy and central repository.
8ba5a0
    cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}"
6ecc07
8ba5a0
    # Print preamble with affected entries.
8ba5a0
    cli_printMessage "`ngettext "The following entry will be created" \
8ba5a0
        "The following entries will be created" "${#DST[*]}"`"
8ba5a0
    while [[ $COUNT -lt ${#DST[*]} ]];do
8ba5a0
        # Print affected entry.
6ecc07
        cli_printMessage "${DST[$COUNT]}" 'AsResponseLine'
8ba5a0
        # Increment counter.
6ecc07
        COUNT=$(($COUNT + 1))
407d66
    done
407d66
8ba5a0
    # Request confirmation question to continue with action.
8ba5a0
    cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine'
6ecc07
6ecc07
    # Reset counter.
6ecc07
    COUNT=0
6ecc07
8ba5a0
    while [[ $COUNT -lt ${#DST[*]} ]];do
6ecc07
8ba5a0
        # Verify relation between source and target locations. We
8ba5a0
        # cannot duplicate an entry if its parent directory doesn't
8ba5a0
        # exist as entry inside the working copy.
6ecc07
        if [[ -f ${SRC[$COUNT]} ]];then
8ba5a0
            if [[ ! -d $(dirname ${DST[$COUNT]}) ]];then
8ba5a0
                mkdir -p $(dirname ${DST[$COUNT]})
8ba5a0
                svn add $(dirname ${DST[$COUNT]}) --quiet
6ecc07
            fi
6ecc07
        fi
6ecc07
8ba5a0
        # Print action message.
8ba5a0
        cli_printMessage "${DST[$COUNT]}" 'AsCreatingLine'
8ba5a0
8ba5a0
        # Perform action.
6ecc07
        svn copy ${SRC[$COUNT]} ${DST[$COUNT]} --quiet
6ecc07
6ecc07
        # Increase counter.
6ecc07
        COUNT=$(($COUNT + 1))
6ecc07
8ba5a0
    done 
407d66
8ba5a0
    # Update texinfo documentation structure.
8ba5a0
    . /home/centos/bin/centos-art manual --update-structure="${DST[0]}"
407d66
6ecc07
    # Syncronize changes between working copy and central repository.
8ba5a0
    cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}"
407d66
407d66
}