diff --git a/Scripts/Modules/Locale/Modules/Directories/directories.sh b/Scripts/Modules/Locale/Modules/Directories/directories.sh index bccee93..0575773 100755 --- a/Scripts/Modules/Locale/Modules/Directories/directories.sh +++ b/Scripts/Modules/Locale/Modules/Directories/directories.sh @@ -33,7 +33,7 @@ function directories { # Sanitate non-option arguments to be sure they match the # directory conventions established by centos-art.sh script # against source directory locations in the working copy. - local DIRECTORY=$(tcar_printAbsolutePath ${1}) + local DIRECTORY=$(tcar_printPath "${1}") # Define regular expression used by locale module to determine the # file extension that it can retrieve translatable strings from, diff --git a/Scripts/Modules/Locale/Modules/Files/Modules/Update/Modules/Conf/conf.sh b/Scripts/Modules/Locale/Modules/Files/Modules/Update/Modules/Conf/conf.sh index 3f41866..6240933 100755 --- a/Scripts/Modules/Locale/Modules/Files/Modules/Update/Modules/Conf/conf.sh +++ b/Scripts/Modules/Locale/Modules/Files/Modules/Update/Modules/Conf/conf.sh @@ -74,9 +74,7 @@ function conf { if [[ -z ${LOCALE_FROM} ]];then tcar_printMessage "${CONFIGURATION} `gettext "hasn't locale-from set in."`" --as-error-line fi - if [[ ! ${LOCALE_FROM} =~ "^/" ]];then - LOCALE_FROM=$(dirname ${CONFIGURATION})/${LOCALE_FROM} - fi + LOCALE_FROM=$(tcar_printPath -b "$(dirname ${CONFIGURATION})" "${LOCALE_FROM}") # Re-define package name written in POT and PO files. This is # the name of the initialization file you provided as argument diff --git a/Scripts/Modules/Locale/Modules/Files/files.sh b/Scripts/Modules/Locale/Modules/Files/files.sh index f409476..02d2581 100755 --- a/Scripts/Modules/Locale/Modules/Files/files.sh +++ b/Scripts/Modules/Locale/Modules/Files/files.sh @@ -28,7 +28,7 @@ function files { # Define absolute path of argument passed in the command-line. - local RENDER_FROM=$(tcar_printAbsolutePath "${1}") + local RENDER_FROM=$(tcar_printPath "${1}") # Verify the argument passed in the command-line is a regular # file. diff --git a/Scripts/Modules/Locale/locale.sh b/Scripts/Modules/Locale/locale.sh index 00aa962..fa1457c 100755 --- a/Scripts/Modules/Locale/locale.sh +++ b/Scripts/Modules/Locale/locale.sh @@ -61,7 +61,7 @@ function locale { # are files or directories. for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do - local ARGUMENT=$(tcar_printAbsolutePath "${ARGUMENT}") + local ARGUMENT=$(tcar_printPath "${ARGUMENT}") if [[ -f ${ARGUMENT} ]];then tcar_setModuleEnvironment -m "files" -t "child" -g "${ARGUMENT}" diff --git a/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh b/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh index d8f37d5..1026bdb 100755 --- a/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh +++ b/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh @@ -91,7 +91,7 @@ function prepare_setRenderEnvironment { # Clean-up the search path. This location must point to a # directory inside the workplace. - DIRECTORY=$(tcar_printAbsolutePath ${DIRECTORY}) + DIRECTORY=$(tcar_printPath "${DIRECTORY}") # Verify the search path. It must exist and being a directory. tcar_checkFiles -ed ${DIRECTORY} diff --git a/Scripts/Modules/Render/Modules/Directories/directories.sh b/Scripts/Modules/Render/Modules/Directories/directories.sh index 9db4469..cace3dd 100755 --- a/Scripts/Modules/Render/Modules/Directories/directories.sh +++ b/Scripts/Modules/Render/Modules/Directories/directories.sh @@ -27,7 +27,7 @@ # provided in the command-line points to a directory. function directories { - local DIRECTORY=$(tcar_printAbsolutePath "${1}") + local DIRECTORY=$(tcar_printPath "${1}") local CONFIGURATION_FILES=$(tcar_getFilesList -p '.+/.+\.conf$' -t 'f' ${DIRECTORY}) diff --git a/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh b/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh index f5ccaba..972c35a 100755 --- a/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh +++ b/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh @@ -26,7 +26,7 @@ # Standardize the way docbook files are transformed in XHTML format. function asciidoc_setXhtmlRendition { - local LOCATION=$(tcar_printAbsolutePath "${1}") + local LOCATION=$(tcar_printPath "${1}") RENDER_PAGES=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-page") if [[ -z ${RENDER_PAGES} ]];then @@ -38,11 +38,13 @@ function asciidoc_setXhtmlRendition { if [[ -z ${IMAGES_FROM} ]];then IMAGES_FROM="${TCAR_WORKDIR}/Webenv/Final" fi + IMAGES_FROM=$(tcar_printPath "${IMAGES_FROM}") STYLES_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "styles-from") if [[ -z ${STYLES_FROM} ]];then STYLES_FROM="${TCAR_BASEDIR}/Models/Documentation/Css" fi + STYLES_FROM=$(tcar_printPath "${STYLES_FROM}") # When producing chunks, take into consideration that both single # and chunks share images produced in the root location. If we diff --git a/Scripts/Modules/Render/Modules/Files/files.sh b/Scripts/Modules/Render/Modules/Files/files.sh index 20764a8..8fc8023 100755 --- a/Scripts/Modules/Render/Modules/Files/files.sh +++ b/Scripts/Modules/Render/Modules/Files/files.sh @@ -28,7 +28,7 @@ # link. function files { - local CONFIGURATION=$(tcar_printAbsolutePath "${1}") + local CONFIGURATION=$(tcar_printPath "${1}") local -a SECTIONS local SECTION='' diff --git a/Scripts/Modules/Render/render.sh b/Scripts/Modules/Render/render.sh index 472df94..bfd40dd 100755 --- a/Scripts/Modules/Render/render.sh +++ b/Scripts/Modules/Render/render.sh @@ -40,7 +40,7 @@ function render { # Sanitate non-option arguments to be sure they match the # directory conventions established by tcar.sh script # against source directory locations in the working copy. - local ARGUMENT=$(tcar_printAbsolutePath ${ARGUMENT}) + local ARGUMENT=$(tcar_printPath "${ARGUMENT}") if [[ -d ${ARGUMENT} ]];then tcar_setModuleEnvironment -m 'directories' -t 'child' -g ${ARGUMENT} diff --git a/Scripts/Modules/Tuneup/tuneup.sh b/Scripts/Modules/Tuneup/tuneup.sh index c0ae63d..df9cee7 100755 --- a/Scripts/Modules/Tuneup/tuneup.sh +++ b/Scripts/Modules/Tuneup/tuneup.sh @@ -36,7 +36,7 @@ function tuneup { # Sanitate non-option arguments to be sure they match the # directory conventions established by tcar.sh script # against source directory locations in the working copy. - local ARGUMENT=$(tcar_printAbsolutePath ${ARGUMENT}) + local ARGUMENT=$(tcar_printPath "${ARGUMENT}") # Build list of files to process. if [[ -f ${ARGUMENT} ]];then diff --git a/Scripts/tcar_printAbsolutePath.sh b/Scripts/tcar_printAbsolutePath.sh deleted file mode 100755 index 5a3f3c3..0000000 --- a/Scripts/tcar_printAbsolutePath.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar - The CentOS Artwork Repository automation tool. -# Copyright © 2014 The CentOS Artwork SIG -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Alain Reguera Delgado -# 39 Street No. 4426 Cienfuegos, Cuba. -# -###################################################################### - -# Print non-option arguments passed through the command-line for -# further processing. -function tcar_printAbsolutePath { - - local LOCATION=${1} - - if [[ ! ${LOCATION} =~ '^/' ]];then - LOCATION=${PWD}/${LOCATION} - fi - - tcar_printPath "${LOCATION}" - -} diff --git a/Scripts/tcar_printPath.sh b/Scripts/tcar_printPath.sh index f4679cf..a592708 100755 --- a/Scripts/tcar_printPath.sh +++ b/Scripts/tcar_printPath.sh @@ -23,14 +23,49 @@ # ###################################################################### +# Print non-option arguments passed through the command-line for +# further processing. function tcar_printPath { - local LOCATION=${1} + # Define base directory's default value. + local BASEDIR="${PWD}" - # Remove consecutive slashes, trailing slashes and any dot-slash - # or double-dot slash construction from final location. - if [[ ${LOCATION} ]];then - echo "${LOCATION}" | sed -r -e 's,/+,/,g' -e 's,/+$,,g' -e 's,\.+/,,g' - fi + # Define the function's options. + OPTIND=1 + while getopts "b:" OPTION "${@}"; do + + case "${OPTION}" in + + b ) + BASEDIR=${OPTARG} + ;; + + esac + + done + + # Clean up positional parameters to reflect the fact that options + # have been processed already. + shift $(( ${OPTIND} - 1 )) + + # Retrieve all locations passed as non-option arguments to this + # function. + local LOCATIONS="${@}" + + for LOCATION in ${LOCATIONS};do + + # Concatenate both base directory and provided location to + # build the final path. + if [[ ${BASEDIR} =~ '^/' && ! ${LOCATION} =~ '^/' ]];then + LOCATION=${BASEDIR}/${LOCATION} + fi + + # Remove consecutive slashes, trailing slashes and any + # dot-slash or double-dot slash constructions from final + # location. + echo "${LOCATION}" \ + | sed -r -e 's,/+,/,g' -e 's,/+$,,g' -e 's,\.+/,,g' + + done }