Blame Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh

878a2b
#!/bin/bash
878a2b
#
92f633
# cli_checkRepoDirSource.sh -- This function standardizes the path
92f633
# construction to directories inside the working copy, using absolute
92f633
# paths. This function transforms relative paths passed as non-option
92f633
# arguments to centos-art.sh script command-line into absolute paths
819c26
# inside the working copy based on whether you are using Subversion or
819c26
# Git as version control system. Further verifications, (e.g., whether
819c26
# they really exist as directories inside the working copy or not)
819c26
# should be realized outside this function.
a9ece5
#
819c26
# NOTE: Transforming relative paths into absolute paths before
819c26
# processing them is very useful when you need to execute the
819c26
# centos-art.sh script as command (e.g., `centos-art') anywhere
819c26
# inside the workstation.
a9ece5
#
a9ece5
# Use this function whenever you need to be sure that non-option
a9ece5
# arguments passed to centos-art.sh script command-line will always
a9ece5
# point to directories inside the working copy.
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 cli_checkRepoDirSource {
878a2b
893a6f
    local LOCATION=${1}
893a6f
123ee8
    # Remove any dot from arguments passed to centos-art.sh script.
123ee8
    # This way it is possible to use a single dot to reflect the
123ee8
    # current location from which centos-art.sh was executed. Notice
123ee8
    # that using a dot as argument is optional (e.g.: when you pass no
123ee8
    # argument to centos-art command-line, the current location is
123ee8
    # used as default location). However, it might be useful to use a
123ee8
    # dot as argument when you want to include the current location in
123ee8
    # a list of arguments to process.
123ee8
    LOCATION=$(echo "$LOCATION" | sed -r "s,^\.$,$(pwd),g")
123ee8
3b9515
    # Remove the working directory absolute path from location to
3b9515
    # avoid path duplications here.
3b9515
    LOCATION=$(echo "$LOCATION" | sed "s,${TCAR_WORKDIR}/,,g")
3b9515
819c26
    # When we use Subversion as version control system, we follow the
819c26
    # `trunk', `branches', `tags' convention to organize files inside
819c26
    # the repository and need to redefine the source path in order to
819c26
    # build repository absolute path from repository's top level on.
819c26
    #
819c26
    # As we are removing the absolute path prefix (e.g.,
819c26
    # `/home/centos/artwork/') from all centos-art.sh output (in order
819c26
    # to save horizontal output space), we need to be sure that all
819c26
    # strings beginning with `trunk/...', `branches/...', and
819c26
    # `tags/...' use the correct absolute path. That is, you can refer
819c26
    # trunk's entries using both `/home/centos/artwork/trunk/...' or
819c26
    # just `trunk/...', the `/home/centos/artwork/' part is
819c26
    # automatically added here.
819c26
    #
819c26
    # When we use Git as version control system, there isn't a need of
819c26
    # using the `trunk', `branches', `tags' convention we were using
819c26
    # for Subversion.  Instead, we use a Git remote branch named
819c26
    # `develop' to do most of the work. Then, when we have something
819c26
    # functional in `develop' branch, we merge `develop' branch into
819c26
    # the `master' branch (probably doing a rebase on master branch).
819c26
    #
819c26
    # There isn't a need of verifying the paths built here.  This is
819c26
    # something we do later, using the cli_checkFiles function. We
819c26
    # don't do the file verification here to avoid malformed error
819c26
    # messages when we reassign variable values using this function as
819c26
    # reference (e.g., in order to prevent error messages to be also
819c26
    # stored inside variables.).
819c26
    LOCATION=${TCAR_WORKDIR}/${LOCATION}
878a2b
819c26
    # Output the absolute path to location.
5a1b27
    echo "${LOCATION}"
819c26
878a2b
}