|
Alain Reguera Delgado |
66223d |
#!/bin/bash
|
|
Alain Reguera Delgado |
66223d |
######################################################################
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
b33753 |
# tcar - The CentOS Artwork Repository automation tool.
|
|
Alain Reguera Delgado |
b33753 |
# Copyright © 2014 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
b33753 |
# This program is free software; you can redistribute it and/or
|
|
Alain Reguera Delgado |
b33753 |
# modify it under the terms of the GNU General Public License as
|
|
Alain Reguera Delgado |
b33753 |
# published by the Free Software Foundation; either version 2 of the
|
|
Alain Reguera Delgado |
b33753 |
# License, or (at your option) any later version.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
b33753 |
# This program is distributed in the hope that it will be useful,
|
|
Alain Reguera Delgado |
b33753 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
b33753 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
b33753 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
b33753 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
b33753 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
b33753 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
b33753 |
# Alain Reguera Delgado <al@centos.org.cu>
|
|
Alain Reguera Delgado |
b33753 |
# 39 Street No. 4426 Cienfuegos, Cuba.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
######################################################################
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
b33753 |
# Standardizes the path construction of directories inside the working
|
|
Alain Reguera Delgado |
b33753 |
# copy, using absolute paths. This function transforms relative paths
|
|
Alain Reguera Delgado |
b33753 |
# passed as non-option arguments to tcar.sh script command-line into
|
|
Alain Reguera Delgado |
b33753 |
# absolute paths inside the working copy, based on whether you are
|
|
Alain Reguera Delgado |
b33753 |
# using Subversion or Git as version control system. Further
|
|
Alain Reguera Delgado |
b33753 |
# verifications, (e.g., whether they really exist as directories
|
|
Alain Reguera Delgado |
b33753 |
# inside the working copy or not) should be realized outside this
|
|
Alain Reguera Delgado |
b33753 |
# function.
|
|
Alain Reguera Delgado |
b33753 |
#
|
|
Alain Reguera Delgado |
b33753 |
# Use this function whenever you want to be sure non-option arguments
|
|
Alain Reguera Delgado |
b33753 |
# passed to tcar.sh script command-line do always point to directories
|
|
Alain Reguera Delgado |
b33753 |
# inside the working copy. Transforming relative paths into absolute
|
|
Alain Reguera Delgado |
b33753 |
# paths, before processing them, is very useful when you need to
|
|
Alain Reguera Delgado |
b33753 |
# execute the tcar.sh script as command (e.g., `tcar') anywhere on
|
|
Alain Reguera Delgado |
b33753 |
# your workstation.
|
|
Alain Reguera Delgado |
66223d |
function tcar_checkRepoDirSource {
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
local LOCATION=${1}
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Remove any dot from arguments passed to tcar.sh script.
|
|
Alain Reguera Delgado |
66223d |
# This way it is possible to use a single dot to reflect the
|
|
Alain Reguera Delgado |
66223d |
# current location from which tcar.sh was executed. Notice
|
|
Alain Reguera Delgado |
66223d |
# that using a dot as argument is optional (e.g.: when you pass no
|
|
Alain Reguera Delgado |
66223d |
# argument to tcar command-line, the current location is
|
|
Alain Reguera Delgado |
66223d |
# used as default location). However, it might be useful to use a
|
|
Alain Reguera Delgado |
66223d |
# dot as argument when you want to include the current location in
|
|
Alain Reguera Delgado |
66223d |
# a list of arguments to process. Don't forget that dot slash can
|
|
Alain Reguera Delgado |
66223d |
# be used to refer locations relatively.
|
|
Alain Reguera Delgado |
66223d |
LOCATION=$(echo "${LOCATION}" | sed -r "s,^\.(/([[:alnum:]_/.-]+)?)?$,$(pwd)\1,g")
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Remove the path to repository's base directory from location in
|
|
Alain Reguera Delgado |
66223d |
# order to avoid path duplications here.
|
|
Alain Reguera Delgado |
66223d |
LOCATION=$(echo "${LOCATION}" | sed "s,${TCAR_BASEDIR}/,,g")
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# When we use Git as version control system, there isn't a need of
|
|
Alain Reguera Delgado |
66223d |
# using the `trunk', `branches', `tags' convention we were using
|
|
Alain Reguera Delgado |
66223d |
# for Subversion. The working copy begins directly with the
|
|
Alain Reguera Delgado |
66223d |
# content of our repository (e.g., Documentation, Scripts,
|
|
Alain Reguera Delgado |
66223d |
# Identity and Locales).
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# When we use Subversion as version control system, we follow the
|
|
Alain Reguera Delgado |
66223d |
# `trunk', `branches', `tags' convention to organize files inside
|
|
Alain Reguera Delgado |
66223d |
# the repository and need to redefine the source path in order to
|
|
Alain Reguera Delgado |
66223d |
# build the repository absolute path from the repository top level
|
|
Alain Reguera Delgado |
66223d |
# on. As convention, when you prepare your working copy through
|
|
Alain Reguera Delgado |
66223d |
# tcar.sh script, the absolute path to the `trunk/'
|
|
Alain Reguera Delgado |
66223d |
# directory is used as working copy. This is, path arguments
|
|
Alain Reguera Delgado |
66223d |
# provided to tcar.sh script will be interpreted from trunk/
|
|
Alain Reguera Delgado |
66223d |
# directory level on. For example, the following command should
|
|
Alain Reguera Delgado |
66223d |
# work correctly in both Subversion and Git repositories:
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# tcar render Documentation/Manuals/Docbook/Tcar-ug
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# There isn't a need of verifying the paths built here. This is
|
|
Alain Reguera Delgado |
66223d |
# something we do later, using the tcar_checkFiles function. We
|
|
Alain Reguera Delgado |
66223d |
# don't do the file verification here to avoid malformed error
|
|
Alain Reguera Delgado |
66223d |
# messages when we reassign variable values using this function as
|
|
Alain Reguera Delgado |
66223d |
# reference (e.g., in order to prevent error messages from being
|
|
Alain Reguera Delgado |
66223d |
# stored inside variables.).
|
|
Alain Reguera Delgado |
66223d |
LOCATION=${TCAR_BASEDIR}/${LOCATION}
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Remove trailing slashes passed as argument. The single slash
|
|
Alain Reguera Delgado |
66223d |
# form is used to refer the repository's root directory. The
|
|
Alain Reguera Delgado |
66223d |
# single slash form passed as argument of tcar.sh script is
|
|
Alain Reguera Delgado |
66223d |
# useful to execute commands over the
|
|
Alain Reguera Delgado |
66223d |
# entire repository tree.
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | sed -r -e 's,/+,/,g' -e 's,/+$,,g'
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
}
|