diff --git a/Scripts/Functions/Copy/copy.sh b/Scripts/Functions/Copy/copy.sh new file mode 100755 index 0000000..644e336 --- /dev/null +++ b/Scripts/Functions/Copy/copy.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# +# copy.sh -- This function copies files inside the repository and +# updates menu, nodes and cross references inside repository +# documentation manual for each file copied. +# +# When a copying action is performed inside the repository, +# centos-art.sh script verifies whether the file being copied (the +# source file) is a regular file or a directory. +# +# When a regular file is the source of copying actions, the target +# location can be anything accepted by subversion copy command. +# However, when the source location is a directory, centos-art.sh +# verifies whether that directory is empty or not. If the directory is +# empty, then it is copied to target. However, when there is one or +# more files inside, centos-art.sh loops recursively through all files +# inside that directory, builds a list of files to process and copy +# file by file to target location creating parents directories for +# target files when it be needed. +# +# 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 published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function copy { + + local ACTIONNAM='' + local ACTIONVAL='' + local -a ACTIONVALS + local -a SRC + local DST='' + local COUNT=0 + + # Interpret arguments and options passed through command-line. + copy_getArguments + + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Store remaining arguments into an array. This way it is possible + # to find out which is the last argument in the list. The last + # argument in the list is considered the target location while all + # other arguments are considered source locations. + for ACTIONVAL in "$@";do + ACTIONVALS[((++${#ACTIONVALS[*]}))]="$ACTIONVAL" + done + + # Define list of source locations using remaining arguments. + while [[ ${COUNT} -lt $((${#ACTIONVALS[*]} - 1)) ]];do + SRC[((++${#SRC[*]}))]=${ACTIONVALS[$COUNT]} + COUNT=$(($COUNT + 1)) + done + + # Define target location. + DST=$(cli_checkRepoDirTarget "${ACTIONVALS[((${#ACTIONVALS[*]} - 1))]}") + + # Loop through source locations and copy them to target location. + for ACTIONVAL in "${SRC[@]}";do + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. + cli_syncroRepoChanges "$ACTIONVAL $DST" + + # Copy source location to target location. + echo "svn copy $ACTIONVAL $DST" + + # Commit changes from working copy to central repository only. + # At this point, changes in the repository are not merged in + # the working copy, but chages in the working copy do are + # committed up to repository. + cli_commitRepoChanges "$ACTIONVAL $DST" + + # Update repository documentation manual structure. + centos-art help "$ACTIONVAL" "$DST" --copy + + done + +} diff --git a/Scripts/Functions/Copy/copy_getArguments.sh b/Scripts/Functions/Copy/copy_getArguments.sh new file mode 100755 index 0000000..dc4618c --- /dev/null +++ b/Scripts/Functions/Copy/copy_getArguments.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# copy_getArguments.sh -- This function interprets arguments passed to +# copy functionality and calls actions accordingly. +# +# 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 published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# ---------------------------------------------------------------------- +# $Id: copy_getArguments.sh 2184 2011-03-30 03:19:31Z al $ +# ---------------------------------------------------------------------- + +function copy_getArguments { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="quiet,answer:,dont-commit-changes" + + # Redefine ARGUMENTS variable using getopt output. + cli_doParseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --quiet ) + FLAG_QUIET="true" + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --answer ) + FLAG_ANSWER="$2" + shift 2 + ;; + + --dont-commit-changes ) + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + -- ) + # Remove the `--' argument from the list of arguments + # in order for processing non-option arguments + # correctly. At this point all option arguments have + # been processed already but the `--' argument still + # remains to mark ending of option arguments and + # begining of non-option arguments. The `--' argument + # needs to be removed here in order to avoid + # centos-art.sh script to process it as a path inside + # the repository, which obviously is not. + shift 1 + break + ;; + esac + done + + # Redefine ARGUMENTS variable using current positional parameters. + cli_doParseArgumentsReDef "$@" + +}