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
6ecc07
    local COUNT=0
6ecc07
 
6ecc07
    # Define source locations.
6ecc07
    SRC[0]=$SOURCE
6ecc07
    SRC[1]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir '--basename')").texi
6ecc07
    SRC[2]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Scripts/Bash/Functions/Render/Config")
6ecc07
    SRC[3]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Translations")
6ecc07
6ecc07
    # Define target locations.
6ecc07
    DST[0]=$TARGET
6ecc07
    DST[1]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir '--basename')").texi
6ecc07
    DST[2]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Scripts/Bash/Functions/Render/Config")
6ecc07
    DST[3]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Translations")
6ecc07
6ecc07
    # Syncronize changes between working copy and central repository.
6ecc07
    cli_commitRepoChanges "${SRC[@]} ${DST[@]}"
6ecc07
6ecc07
    # Output entries affected by action.
6ecc07
    cli_printMessage "`ngettext "The following entry will be created:" \
6ecc07
        "The following entries will be created:" \
6ecc07
        "${#DST[*]}"`"
6ecc07
    while [[ $COUNT -lt ${#SRC[*]} ]];do
6ecc07
        cli_printMessage "${DST[$COUNT]}" 'AsResponseLine'
6ecc07
        COUNT=$(($COUNT + 1))
407d66
    done
407d66
6ecc07
    # Request confirmation to perform action.
6ecc07
    cli_printMessage "`gettext "Do you want to continue?"`" 'AsYesOrNoRequestLine'
6ecc07
6ecc07
    # Reset counter.
6ecc07
    COUNT=0
6ecc07
6ecc07
    # Perform action.
6ecc07
    while [[ $COUNT -lt ${#SRC[*]} ]];do
6ecc07
6ecc07
        cli_printMessage ${DST[$COUNT]} 'AsCreatingLine'
6ecc07
6ecc07
        # Verify repository entry. We cannot duplicate an entry if its
6ecc07
        # parent directory doesn't exist as entry inside the working
6ecc07
        # copy.
6ecc07
        if [[ -f ${SRC[$COUNT]} ]];then
6ecc07
            if [[ -d $(dirname ${SRC[$COUNT]}) ]];then
6ecc07
                if [[ ! -d $(dirname ${DST[$COUNT]}) ]];then
6ecc07
                    mkdir -p $(dirname ${DST[$COUNT]})
6ecc07
                    svn add $(dirname ${DST[$COUNT]}) --quiet
6ecc07
                fi
6ecc07
            fi
6ecc07
        elif [[ -d ${SRC[$COUNT]} ]];then
6ecc07
            if [[ -d ${DST[$COUNT]} ]];then
6ecc07
                cli_printMessage "`gettext "cannot create "` \`${DST[$COUNT]}': `gettext "Directory already exists."`" 'AsErrorLine'
6ecc07
                cli_printMessage "$(caller)" 'AsToKnowMoreLine'
6ecc07
            fi
6ecc07
        fi
6ecc07
6ecc07
        # Copy using subversion command.
6ecc07
        svn copy ${SRC[$COUNT]} ${DST[$COUNT]} --quiet
6ecc07
6ecc07
        # Increase counter.
6ecc07
        COUNT=$(($COUNT + 1))
6ecc07
6ecc07
    done
407d66
6ecc07
    # Update documentation chapter, menu and nodes inside Texinfo
6ecc07
    # documentation structure.
6ecc07
    . ~/bin/centos-art manual --update-structure=${DST[0]}
407d66
6ecc07
    # Syncronize changes between working copy and central repository.
6ecc07
    cli_commitRepoChanges "${DST[@]}"
407d66
407d66
}