|
|
328582 |
#!/bin/bash
|
|
|
328582 |
#
|
|
|
328582 |
# cli_checkRepoDirTarget.sh -- This function provides input validation
|
|
|
328582 |
# to repository entries considered as target location.
|
|
|
328582 |
#
|
|
|
69a93e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
328582 |
#
|
|
|
328582 |
# This program is free software; you can redistribute it and/or
|
|
|
328582 |
# modify it under the terms of the GNU General Public License as
|
|
|
328582 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
328582 |
# License, or (at your option) any later version.
|
|
|
328582 |
#
|
|
|
328582 |
# This program is distributed in the hope that it will be useful, but
|
|
|
328582 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
328582 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
328582 |
# General Public License for more details.
|
|
|
328582 |
#
|
|
|
328582 |
# You should have received a copy of the GNU General Public License
|
|
|
328582 |
# along with this program; if not, write to the Free Software
|
|
|
328582 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
328582 |
# USA.
|
|
|
328582 |
#
|
|
|
328582 |
# ----------------------------------------------------------------------
|
|
|
571f97 |
# $Id$
|
|
|
328582 |
# ----------------------------------------------------------------------
|
|
|
328582 |
|
|
|
328582 |
function cli_checkRepoDirTarget {
|
|
|
328582 |
|
|
|
328582 |
# Check target value before making an absolute path from it.
|
|
|
1e2d9e |
cli_checkPathComponent "$FLAG_TO" '--repo-directory'
|
|
|
328582 |
|
|
|
328582 |
# Redefine target value to build repository absolute path from
|
|
|
328582 |
# repository top level on. As we are removing
|
|
|
328582 |
# /home/centos/artwork/ from all centos-art.sh output (in order to
|
|
|
328582 |
# save horizontal output space), we need to be sure that all
|
|
|
328582 |
# strings begining with trunk/..., branches/..., and tags/... use
|
|
|
328582 |
# the correct absolute path. That is, you can refer trunk's
|
|
|
328582 |
# entries using both /home/centos/artwork/trunk/... or just
|
|
|
328582 |
# trunk/..., the /home/centos/artwork/ part is automatically added
|
|
|
328582 |
# here.
|
|
|
69a93e |
if [[ $FLAG_TO =~ '^(trunk|branches|tags)/.+$' ]];then
|
|
|
7b46a4 |
FLAG_TO=${HOME}/artwork/$FLAG_TO
|
|
|
328582 |
fi
|
|
|
328582 |
|
|
|
328582 |
# Check target value.
|
|
|
69a93e |
if [[ -a ${FLAG_TO} ]];then
|
|
|
328582 |
|
|
|
328582 |
# At this point target value does existent as working copy
|
|
|
328582 |
# entry. We don't use existent locations as target. So, print
|
|
|
328582 |
# a message and stop script execution.
|
|
|
69a93e |
cli_printMessage "`eval_gettext "The location \\\`\\\$FLAG_TO' already exists."`" 'AsErrorLine'
|
|
|
328582 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
328582 |
|
|
|
328582 |
else
|
|
|
328582 |
|
|
|
328582 |
# At this point existent locations inside working copy and
|
|
|
328582 |
# invalid urls have been discarded. Assume a new target
|
|
|
328582 |
# location has being specified. So, build the absolute path
|
|
|
328582 |
# for it.
|
|
|
328582 |
|
|
|
328582 |
# Add directory to the top of the directory stack.
|
|
|
a1c6f0 |
pushd "$(dirname "$FLAG_TO")" > /dev/null
|
|
|
328582 |
|
|
|
328582 |
# Check directory existence inside the repository.
|
|
|
7b46a4 |
if [[ $(pwd) =~ "^${HOME}/artwork" ]];then
|
|
|
328582 |
# Re-define target value using absolute path.
|
|
|
a1c6f0 |
FLAG_TO=$(pwd)/$(basename "$FLAG_TO")
|
|
|
328582 |
fi
|
|
|
328582 |
|
|
|
328582 |
# Remove directory from the directory stack.
|
|
|
328582 |
popd > /dev/null
|
|
|
328582 |
|
|
|
328582 |
# Verify target location. It is required that target location
|
|
|
328582 |
# points to an entry under (trunk|branches|tags)/Identity/...
|
|
|
328582 |
# directory structure *only*. Remember that Identity parent
|
|
|
328582 |
# directory structure is the reference used to create parallel
|
|
|
328582 |
# directories (i.e., documentation, configuration scripts,
|
|
|
328582 |
# translations, etc.). We don't manipulate parallel
|
|
|
328582 |
# directories with path ---or any other--- functionality
|
|
|
328582 |
# directly. Consider manipulation of parallel directories as
|
|
|
328582 |
# a consequence of a previous manipulation of Identity parent
|
|
|
328582 |
# directory structure.
|
|
|
69a93e |
if [[ ! ${FLAG_TO} =~ '^.+/(trunk|branches|tags)/Identity/.+$' ]];then
|
|
|
69a93e |
cli_printMessage "`eval_gettext "cannot create \\\`\\\$FLAG_TO': It isn't an identity directory structure."`" 'AsErrorLine'
|
|
|
328582 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
328582 |
fi
|
|
|
328582 |
fi
|
|
|
328582 |
|
|
|
328582 |
}
|