Blame Scripts/Bash/Functions/Help/Texinfo/texinfo_checkEntrySrcDst.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# texinfo_checkEntrySrcDst.sh -- This function standardizes
878a2b
# verification actions of source and target locations for tasks like
878a2b
# copying and renaming.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function texinfo_checkEntrySrcDst {
878a2b
878a2b
    # Initialize entry source absolute path.
878a2b
    local MANUAL_ENTRY_SRC="$1"
878a2b
878a2b
    # Initialize entry target absolute path.
878a2b
    local MANUAL_ENTRY_DST="$2"
878a2b
878a2b
    # Verify existence of source location.
878a2b
    if [[ ! -a ${MANUAL_ENTRY_SRC} ]];then
878a2b
        cli_printMessage "`gettext "The source location doesn't exist."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Verify source and target locations to be sure they are different
878a2b
    # one another. We cannot copy a source location to itself.
878a2b
    if [[ $MANUAL_ENTRY_SRC == $MANUAL_ENTRY_DST ]];then
878a2b
        cli_printMessage "`gettext "The source and target locations cannot be the same."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Verify source location to be sure it is under version control
878a2b
    # and there isn't pending change to be committed first.
878a2b
    if [[ $(cli_isVersioned ${MANUAL_ENTRY_SRC}) == 'true' ]];then
878a2b
        if [[ $(cli_getRepoStatus ${MANUAL_ENTRY_SRC}) != '' ]];then
878a2b
            cli_printMessage "`gettext "The source location has pending changes."`" --as-error-line
878a2b
        fi
878a2b
    else
878a2b
        cli_printMessage "`gettext "The source location isn't under version control."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Verify target directory where the source will be duplicated in.
878a2b
    # The target directory must exist before copying the source
878a2b
    # location into it. If it doesn't exist, use subversion to create
878a2b
    # it it.
878a2b
    if [[ ! -d $(dirname ${MANUAL_ENTRY_DST}) ]];then
878a2b
        svn mkdir $(dirname ${MANUAL_ENTRY_DST}) --quiet
878a2b
    fi
878a2b
878a2b
    # Verify existence of target location.
878a2b
    if [[ -a ${MANUAL_ENTRY_DST} ]];then
878a2b
        cli_printMessage "`gettext "The target location already exists."`" --as-error-line
878a2b
    fi
878a2b
878a2b
}