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