diff --git a/Automation/Modules/Cli/Scripts/cli_checkFiles.sh b/Automation/Modules/Cli/Scripts/cli_checkFiles.sh deleted file mode 100755 index 0e4d50b..0000000 --- a/Automation/Modules/Cli/Scripts/cli_checkFiles.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_checkFiles.sh -- This function standardizes the way file -# conditional expressions are applied to files. Here is where -# centos-art.sh script answers questions like: is the file a regular -# file or a directory? Or, is it a symbolic link? Or even, does it -# have execution rights, etc. If the verification fails somehow at -# any point, an error message is output and centos-art.sh script -# finishes its execution. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_checkFiles { - - # Define short options. - local ARGSS='i:,r,m:,n,d,e,f,h,x' - - # Define long options. - local ARGSL='mime:,is-versioned,match:,is-installed' - - # Initialize local array variables. - local -a CONDITION_COMMAND - local -a CONDITION_PATTERN - local -a CONDITION_MESSAGE - - # Initialize local counter. - local COUNTER=0 - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. This - # variable is shared for different function environments. - local TCAR_ARGUMENTS='' - - # Redefine arguments using current positional parameters. - cli_setArguments "${@}" - - # Redefine positional parameters using arguments variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Look for options passed through positional parameters. - while true; do - - case "${1}" in - - -d ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-d' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a directory."`" - shift 1 - ;; - - -e ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-e' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "doesn't exist."`" - shift 1 - ;; - - -f ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-f' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a regular file."`" - shift 1 - ;; - - -h ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-h' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a symbolic link."`" - shift 1 - ;; - - -x ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-x' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't an executable file."`" - shift 1 - ;; - - -i | --mime ) - local MIME=${2} - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='file' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-bi' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "isn't a \\\"\\\${MIME}\\\" file."`" - shift 2 - ;; - - -m | --match ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='match' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="${2}" - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "doesn't match its pattern."`" - shift 2 - ;; - - -r | --is-versioned ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="centos-art" - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="vcs --is-versioned" - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="" - shift 1 - ;; - - -n | --is-installed ) - CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="rpm" - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="-q --quiet" - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't installed in the system."`" - shift 1 - ;; - - -- ) - shift 1 - break - ;; - - esac - done - - # Define list of files we want to apply verifications to, now that - # all option-like arguments have been removed from positional - # parameters list so we are free to go with the verifications. - local FILE='' - local FILES=${@} - - for FILE in ${FILES};do - - until [[ ${COUNTER} -eq ${#CONDITION_PATTERN[*]} ]];do - - case ${CONDITION_COMMAND[${COUNTER}]} in - - "test" | "rpm" ) - ${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE} \ - || cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line - ;; - - "centos-art" ) - # Don't create another level for error messages here - # (that would duplicate them unnecessarily). Instead, - # set error messages inside specific functionalities - # and use them directly from there. - cli_runFnEnvironment ${CONDITION_PATTERN[${COUNTER}]} ${FILE} - ;; - - "file" ) - if [[ ! $(${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE}) == "${MIME}" ]];then - cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line - fi - ;; - - "match" ) - if [[ ! ${FILE} =~ "${CONDITION_PATTERN[${COUNTER}]}" ]];then - cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line - fi - ;; - - * ) - cli_printMessage "`gettext "The condition command provided isn't supported."`" --as-error-line - ;; - - esac - - COUNTER=$((${COUNTER} + 1)) - - done - - done - -} diff --git a/Automation/Modules/Cli/Scripts/cli_checkRepoDirSource.sh b/Automation/Modules/Cli/Scripts/cli_checkRepoDirSource.sh deleted file mode 100755 index 19e434c..0000000 --- a/Automation/Modules/Cli/Scripts/cli_checkRepoDirSource.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_checkRepoDirSource.sh -- This function standardizes the path -# construction of directories inside the working copy, using -# absolute paths. This function transforms relative paths passed as -# non-option arguments to centos-art.sh script command-line into -# absolute paths inside the working copy based on whether you are -# using Subversion or Git as version control system. Further -# verifications, (e.g., whether they really exist as directories -# inside the working copy or not) should be realized outside this -# function. -# -# Use this function whenever you want to be sure non-option -# arguments passed to centos-art.sh script command-line do always -# point to directories inside the working copy. Transforming -# relative paths into absolute paths, before processing them, is -# very useful when you need to execute the centos-art.sh script as -# command (e.g., `centos-art') anywhere on your workstation. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_checkRepoDirSource { - - local LOCATION=${1} - - # Remove any dot from arguments passed to centos-art.sh script. - # This way it is possible to use a single dot to reflect the - # current location from which centos-art.sh was executed. Notice - # that using a dot as argument is optional (e.g.: when you pass no - # argument to centos-art command-line, the current location is - # used as default location). However, it might be useful to use a - # dot as argument when you want to include the current location in - # a list of arguments to process. - LOCATION=$(echo "${LOCATION}" | sed -r "s,^\.$,$(pwd),g") - - # Remove the working directory absolute path from location to - # avoid path duplications here. - LOCATION=$(echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,,g") - - # When we use Git as version control system, there isn't a need of - # using the `trunk', `branches', `tags' convention we were using - # for Subversion. The working copy begins directly with the - # content of our repository (e.g., Documentation, Scripts, - # Identity and Locales). - # - # When we use Subversion as version control system, we follow the - # `trunk', `branches', `tags' convention to organize files inside - # the repository and need to redefine the source path in order to - # build the repository absolute path from the repository top level - # on. As convention, when you prepare your working copy through - # centos-art.sh script, the absolute path to the `trunk/' - # directory is used as working copy. This is, path arguments - # provided to centos-art.sh script will be interpreted from trunk/ - # directory level on. For example, the following command should - # work correctly in both Subversion and Git repositories: - # - # centos-art render Documentation/Manuals/Docbook/Tcar-ug - # - # There isn't a need of verifying the paths built here. This is - # something we do later, using the cli_checkFiles function. We - # don't do the file verification here to avoid malformed error - # messages when we reassign variable values using this function as - # reference (e.g., in order to prevent error messages from being - # stored inside variables.). - LOCATION=${TCAR_USER_WRKDIR}/${LOCATION} - - # Output the absolute path to location. - echo "${LOCATION}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_expandTMarkers.sh b/Automation/Modules/Cli/Scripts/cli_expandTMarkers.sh deleted file mode 100755 index ebeaff7..0000000 --- a/Automation/Modules/Cli/Scripts/cli_expandTMarkers.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_expandTMarkers.sh -- This function standardizes construction -# of translation markers and their related expansion. As convention, -# translation markers must be set inside source files (e.g., -# Docbook, Svg, etc.) and expanded inside temporal instances used to -# produce final contents. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_expandTMarkers { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - local COUNTSRC=0 - local COUNTDST=0 - - # Define source location on which sed replacements take place. - local LOCATION="${1}" - - # Verify that source location does exist. - cli_checkFiles -e ${LOCATION} - - # Define copyright translation markers. - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(_LAST)?=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(S)?_LIST=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --years-list)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --holder)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --holder-predicate)" - - # Define license translation markers. - SRC[((++${#SRC[*]}))]='=LICENSE=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license)" - SRC[((++${#SRC[*]}))]='=LICENSE_URL=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license-url)" - - # Define theme translation markers. - SRC[((++${#SRC[*]}))]='=THEME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif)" - SRC[((++${#SRC[*]}))]='=THEMENAME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-name)" - SRC[((++${#SRC[*]}))]='=THEMERELEASE=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-release)" - - # Define release-specific translation markers. - SRC[((++${#SRC[*]}))]='=RELEASE=' - DST[((++${#DST[*]}))]="${FLAG_RELEASEVER}" - SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f1)" - SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f2)" - - # Define architectures translation markers. - SRC[((++${#SRC[*]}))]='=ARCH=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent ${FLAG_BASEARCH} --architecture)" - - # Define url translation markers. - SRC[((++${#SRC[*]}))]='=URL=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--home' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_WIKI=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--wiki' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_LISTS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--lists' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_FORUMS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--forums' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--mirrors' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_DOCS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--docs' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_PROJECTS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--projects' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_BUGS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--bugs' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_SVN=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--svn' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_TRAC=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--trac' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_PLANET=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--planet' '--with-locale') - - # Define emails translation markers. - SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' - DST[((++${#DST[*]}))]="$(cli_printMailingList --docs)" - - # Define locale translation markers. - SRC[((++${#SRC[*]}))]='=LOCALE=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LC}" - SRC[((++${#SRC[*]}))]='=LOCALE_LL=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" - SRC[((++${#SRC[*]}))]='=LOCALE_CC=' - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_CC}" - - # Define domain translation markers for domains. - SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' - if [[ ! ${TCAR_SCRIPT_LANG_LL} =~ '^en' ]];then - DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" - else - DST[((++${#DST[*]}))]="" - fi - - # Define repository translation markers. - SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_BASEDIR)=' - DST[((++${#DST[*]}))]="${TCAR_BASEDIR}" - - # Do replacement of nested translation markers. - while [[ ${COUNTDST} -lt ${#DST[@]} ]];do - - # Verify existence of translation markers. If there is no - # translation marker on replacement, continue with the next - # one in the list. - if [[ ! ${DST[${COUNTDST}]} =~ '=[A-Z_]+=' ]];then - # Increment destination counter. - COUNTDST=$((${COUNTDST} + 1)) - # The current replacement value doesn't have translation - # marker inside, so skip it and evaluate the next - # replacement value in the list. - continue - fi - - while [[ ${COUNTSRC} -lt ${#SRC[*]} ]];do - - # Update replacements. - DST[${COUNTDST}]=$(echo ${DST[${COUNTDST}]} \ - | sed -r "s!${SRC[${COUNTSRC}]}!${DST[${COUNTSRC}]}!g") - - # Increment source counter. - COUNTSRC=$((${COUNTSRC} + 1)) - - done - - # Reset source counter - COUNTSRC=0 - - # Increment destination counter. - COUNTDST=$((${COUNTDST} + 1)) - - done - - # Apply replacements for translation markers. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - - # Use sed to replace translation markers inside the design - # model instance. - sed -r -i "s!${SRC[${COUNT}]}!${DST[${COUNT}]}!g" ${LOCATION} - - # Increment counter. - COUNT=$((${COUNT} + 1)) - - done - - # Remove escaped character from translation markers. This is one - # of the reasons why translation marker should be expanded in - # source files instances not the source files themselves. - # Escaping translation markers provides a way of talking about - # them without expanding them. - sed -r -i 's/(=)\\([A-Z_]+=)/\1\2/g' ${LOCATION} - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may remain from one file to another. - unset SRC - unset DST - -} diff --git a/Automation/Modules/Cli/Scripts/cli_exportFunctions.sh b/Automation/Modules/Cli/Scripts/cli_exportFunctions.sh deleted file mode 100755 index 2b15a5a..0000000 --- a/Automation/Modules/Cli/Scripts/cli_exportFunctions.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_exportFunctions.sh -- This function standardizes the way -# specific functionalities are exported to centos-art.sh script -# environment. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_exportFunctions { - - # Retrieve export identifier for the function we want to export. - local MODULE_INIT_FILE="${1}" - - # Verify the export identification existence. - cli_checkFiles -x ${MODULE_INIT_FILE} - - # Define the source location where function files are placed in. - local MODULE_SCRIPTS_DIR=$(dirname ${MODULE_INIT_FILE})/Scripts - - # Define suffix used to retrieve function files. - local MODULE_INIT_FILENAME=$(basename "${MODULE_INIT_FILE}" | sed -r 's/\.sh$//') - - # Define the pattern used to retrieve function names from function - # files. - local FUNCTION_PATTERN="^function[[:space:]]+${MODULE_INIT_FILENAME}(_[[:alnum:]]+)?[[:space:]]+{[[:space:]]*$" - - # Define the list of files. - local MODULE_SCRIPTS="${MODULE_INIT_FILE} - $(cli_getFilesList ${MODULE_SCRIPTS_DIR} \ - --pattern="${MODULE_DIR}/.+\.sh$" --maxdepth='1' \ - --mindepth='1' --type='f')" - - # Verify the list of files. If no function file exists for the - # location specified stop the script execution. Otherwise the - # script will surely try to execute a function that haven't been - # exported yet and report an error about it. - if [[ -z ${MODULE_SCRIPTS} ]];then - cli_printMessage "${FUNCNAME}: `gettext "No function file was found."`" --as-error-line - fi - - # Process the list of files. - for MODULE_SCRIPT in ${MODULE_SCRIPTS};do - - # Verify the execution rights for function file. - cli_checkFiles -x ${MODULE_SCRIPT} - - # Verify that function files have not been already exported. - # If they have been already exported don't export them again. - # Instead, continue with the next function file in the list. - declare -F | gawk '{ print $3 }' | egrep "^${MODULE_SCRIPT}$" > /dev/null - if [[ $? -eq 0 ]];then - continue - fi - - # Initialize the function file. - . ${MODULE_SCRIPT} - - # Export the function names inside the file to current shell - # script environment. - export -f $(egrep "${FUNCTION_PATTERN}" ${MODULE_SCRIPT} | gawk '{ print $2 }') - - done - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getConfigLines.sh b/Automation/Modules/Cli/Scripts/cli_getConfigLines.sh deleted file mode 100755 index 46a1783..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getConfigLines.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getConfigLines.sh -- This function standardizes the way -# configuration lines are retrieved form configuration files. As -# arguments, the configuration file absolute path, the configuration -# section name, and the configuration option name must be provided. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getConfigLines { - - # Initialize absolute path to configuration file. - local CONFIGURATION_FILE="${1}" - - # Verify that configuration file does exist. - cli_checkFiles -e ${CONFIGURATION_FILE} - - # Initialize configuration section name where the variable value - # we want to to retrieve is set in. - local CONFIGURATION_SECTION="${2}" - - # Be sure the configuration section name has the correct format. - if [[ ! ${CONFIGURATION_SECTION} =~ '^[[:alnum:]._-]+$' ]];then - cli_printMessage "`gettext "The configuration section provided is incorrect."`" --as-error-line - fi - - # Initialize variable name we want to retrieve value from. - local CONFIGURATION_OPTION="${3}" - - # Verify configuration variable name. When no variable name is - # provided print all configuration lines that can be considered as - # well-formed paths. Be sure configuration variable name starts - # just at the beginning of the line. - if [[ ! ${CONFIGURATION_OPTION} =~ '^[[:alnum:]_./-]+$' ]];then - CONFIGURATION_OPTION='[[:alnum:]_./-]+[[:space:]]*=' - fi - - # Retrieve configuration lines from configuration file. - local CONFIGURATION_LINES=$(cat ${CONFIGURATION_FILE} \ - | egrep -v '^#' \ - | egrep -v '^[[:space:]]*$' \ - | sed -r -n "/^\[${CONFIGURATION_SECTION}\][[:space:]]*$/,/^\[/p" \ - | egrep -v '^\[' | sort | uniq \ - | egrep "^${CONFIGURATION_OPTION}") - - # Output value related to variable name. - echo "${CONFIGURATION_LINES}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getConfigSectionNames.sh b/Automation/Modules/Cli/Scripts/cli_getConfigSectionNames.sh deleted file mode 100755 index 387defc..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getConfigSectionNames.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getConfigSectionNames.sh -- This function standardizes the way -# section names are retrieved from configuration files. Once section -# names are retrieved they are printed to standard output for -# further processing. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getConfigSectionNames { - - # Define absolute path to configuration file we want to retrieve - # section names from. - local CONFIGURATION_FILE=${1} - - # Verify existence of configuration file. - cli_checkFiles ${CONFIGURATION_FILE} -f - - # Output all section names without brackets, one per line. - egrep '^\[[[:alnum:]._-]+\][[:space:]]*$' ${CONFIGURATION_FILE} \ - | sed -r 's/\[(.+)\]/\1/' - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getConfigValue.sh b/Automation/Modules/Cli/Scripts/cli_getConfigValue.sh deleted file mode 100755 index 82b3127..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getConfigValue.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getConfigValue.sh -- This function standardizes the way -# configuration values are retrieved from configuration files. As -# arguments, the configuration file absolute path, the configuration -# section name, and the configuration option name must be provided. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getConfigValue { - - # Initialize absolute path to configuration file. - local CONFIGURATION_FILE="${1}" - - # Initialize configuration section name where the variable value - # we want to to retrieve is set in. - local CONFIGURATION_SECTION="${2}" - - # Initialize variable name we want to retrieve value from. - local CONFIGURATION_OPTION="${3}" - - # Retrieve configuration lines from configuration file. - local CONFIGURATION_LINES=$(cli_getConfigLines \ - "${CONFIGURATION_FILE}" "${CONFIGURATION_SECTION}" "${CONFIGURATION_OPTION}") - - # Parse configuration lines to retrieve the values of variable - # names. - local CONFIGURATION_VALUE=$(echo ${CONFIGURATION_LINES} \ - | cut -d= -f2- \ - | sed -r -e 's/"//g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' ) - - # Output values related to variable name. - echo "${CONFIGURATION_VALUE}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getFilesList.sh b/Automation/Modules/Cli/Scripts/cli_getFilesList.sh deleted file mode 100755 index 8c4e2e2..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getFilesList.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getFilesList.sh -- This function standardizes the way list of -# files are built inside centos-art.sh script. This function outputs -# a sorted and unique list of files based on the options and -# locations passed as argument. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getFilesList { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' - - # Initialize pattern used to reduce the find output. - local PATTERN="${TCAR_FLAG_FILTER}" - - # Initialize options used with find command. - local OPTIONS='' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local TCAR_ARGUMENTS='' - - # Process all arguments currently available in this function - # environment. If either ARGSS or ARGSL local variables have been - # defined, argument processing goes through getopt for validation. - cli_setArguments "${@}" - - # Redefine positional parameters using TCAR_ARGUMENTS variable. - eval set -- "${TCAR_ARGUMENTS}" - - while true;do - case "${1}" in - - --pattern ) - PATTERN="${2}" - shift 2 - ;; - - --maxdepth ) - OPTIONS="${OPTIONS} -maxdepth ${2}" - shift 2 - ;; - - --mindepth ) - OPTIONS="${OPTIONS} -mindepth ${2}" - shift 2 - ;; - - --type ) - OPTIONS="${OPTIONS} -type ${2}" - shift 2 - ;; - - --uid ) - OPTIONS="${OPTIONS} -uid ${2}" - shift 2 - ;; - - -- ) - shift 1 - break - ;; - esac - done - - # At this point all options arguments have been processed and - # removed from positional parameters. Only non-option arguments - # remain so we use them as source location for find command to - # look files for. - - # Verify that locations does exist. - cli_checkFiles -e ${@} - - # Redefine pattern as regular expression. When we use regular - # expressions with find, regular expressions are evaluated against - # the whole file path. This way, when the regular expression is - # specified, we need to build it in a way that matches the whole - # path we are using. Doing so, every time we pass the `--filter' - # option in the command-line could be a tedious task. Instead, in - # the sake of reducing some typing, we prepare the regular - # expression here to match the whole path using the regular - # expression provided by the user as pattern. Do not use locations - # as part of regular expression so it could be possible to use - # path expansion. Using path expansion reduce the amount of - # places to find out things and so the time required to finish the - # task. - # - # Don't do such path expansion here. Instead, do it when you call - # this function. Otherwise you would be prohibiting the - # application of exact patterns. - #PATTERN="^/.*${PATTERN}$" - - # Define list of files to process. At this point we cannot verify - # whether the location is a directory or a file since path - # expansion could be introduced to it. The best we can do is - # verifying exit status and go on. - find ${@} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getLocalizationDir.sh b/Automation/Modules/Cli/Scripts/cli_getLocalizationDir.sh deleted file mode 100755 index 4377c5b..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getLocalizationDir.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getLocalizationDir.sh -- This function standardizes the way -# localization paths are created. The first argument of this -# function must be a path pointing a directory inside the -# repository. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getLocalizationDir { - - # 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. - LOCATION=$(cli_checkRepoDirSource "${1}") - - # In case the location specified would be a file, remove the file - # part from the path so only its parent directory remains. - if [[ -f ${LOCATION} ]];then - LOCATION=$(dirname ${LOCATION}) - fi - - # Make path transformation. - case "${2}" in - - '--no-lang' ) - LOCATION=$(echo "${LOCATION}" \ - | sed -r -e "s!(Identity|Scripts|Documentation)!Locales/\1!") - ;; - - * ) - LOCATION=$(echo "${LOCATION}" \ - | sed -r -e "s!(Identity|Scripts|Documentation)!Locales/\1!")/${TCAR_SCRIPT_LANG_LC} - ;; - - esac - - # Output transformed path. - echo "${LOCATION}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getOptions.sh b/Automation/Modules/Cli/Scripts/cli_getOptions.sh deleted file mode 100755 index d606855..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getOptions.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getOptions.sh -- This function parses common options passed to -# to `centos-art.sh' script. Because option parsing is different for -# each function environment inside centos-art.sh script, we cannot -# use getopt here. That would enter in conflict with options from -# deeper function environments making impossible to parse both -# common and specific options through getopt in a modular way (e.g., -# without duplicating common option definition inside each different -# module the centos-art.sh script is made of). -# -# To solve this issue centos-art.sh script restricts the order in -# which common options are passed through the command line. This -# way, common options must be passed first and specific options -# later. Common options are defined in this file and specific -# options are defined in module-specific files. -# -# This introduces the nature of common options: common options do -# not modify the centos-art.sh script behaviour in any way. Common -# options exist to show information about centos-art.sh script and -# its modules only (e.g., --help and --version) and once done, exit -# successfully without processing any other option or argument -# passed in the command-line. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getOptions { - - # Define valid short options. - local ARGSS="h,v" - - # Define valid long options. - local ARGSL="help,version" - - # Define module arguments local to this function. This is very - # important in order to provide option parsing for different - # function environment levels. - local TCAR_ARGUMENTS='' - - # Redefine arguments using getopt(1) command parser. - cli_setArguments "${@}" - - # Reset positional parameters on this function, using output - # produced from (getopt) arguments parser. - eval set -- "${TCAR_ARGUMENTS}" - - # Look for options passed through command-line. - while true; do - case ${1} in - - -h | --help ) - cli_printHelp - ;; - - -v | --version ) - cli_printVersion - ;; - - * ) - # At this point none of the valid options were - # provided so, finish the script execution. This is - # not absolutely needed because getopt will complain - # about non-valid options and probably never execution - # reaches this point. Consider this a backup - # verification. - exit 0 - ;; - - esac - - done - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getPathComponent.sh b/Automation/Modules/Cli/Scripts/cli_getPathComponent.sh deleted file mode 100755 index a563f5c..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getPathComponent.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getPathComponent.sh -- This function standardizes the way -# directory structures are organized inside the working copy of -# CentOS Artwork Repository. You can use this function to retrieve -# information from paths (e.g., releases, architectures and theme -# artistic motifs) or the patterns used to build the paths. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getPathComponent { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,motif,motif-name,motif-release,motif-pattern,repo-dir' - - # Define release pattern. - local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+))?)" - - # Define architecture pattern. Make it match the architectures the - # CentOS distribution is able to be installed on. - local ARCHITECTURE="(i386|x86_64)" - - # Define regular expression pattern that match the theme artistic - # motif component inside the path strings. - local THEME_MOTIF="Identity/Images/Themes/(([[:alnum:]]+)/(${RELEASE}))" - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local TCAR_ARGUMENTS='' - - # Process all arguments currently available in this function - # environment. If either ARGSS or ARGSL local variables have been - # defined, argument processing goes through getopt for validation. - cli_setArguments "${@}" - - # Redefine positional parameters using TCAR_ARGUMENTS variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Define location we want to apply verifications to. - local LOCATION=$(echo ${@} | sed -r 's!^.*--[[:space:]](.+)$!\1!') - - # Look for options passed through positional parameters. - while true;do - - case "${1}" in - - --release ) - echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!" - shift 1 - break - ;; - - --release-major ) - echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!" - shift 1 - break - ;; - - --release-minor ) - echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!" - shift 1 - break - ;; - - --release-pattern ) - echo "${RELEASE}" - shift 1 - break - ;; - - --architecture ) - echo "${LOCATION}" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!" - shift 1 - break - ;; - - --architecture-pattern ) - echo "${ARCHITECTURE}" - shift 1 - break - ;; - - --motif ) - echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!" - shift 1 - break - ;; - - --motif-name ) - echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!" - shift 1 - break - ;; - - --motif-release ) - echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!" - shift 1 - break - ;; - - --motif-pattern ) - echo "${THEME_MOTIF}" - shift 1 - break - ;; - - --repo-dir ) - echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,," - shift 1 - break - ;; - - esac - - done - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getRepoName.sh b/Automation/Modules/Cli/Scripts/cli_getRepoName.sh deleted file mode 100755 index ebbe5d2..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getRepoName.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getRepoName.sh -- This function standardizes files and -# directories name convection inside the working copy of CentOS -# Artowrk Repository. As convection, regular files are written in -# lower-case and directories are written capitalized. Use this -# function to sanitate the name of regular files and directories on -# paths you work with. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getRepoName { - - # Define the name we want to apply verifications to. - local NAME="${1}" - - # Avoid using options as it were names. When name value is empty - # but an option is provided, the option becomes the first - # positional argument and is evaluated as it were a name which is - # something we need to prevent from happening. - if [[ ${NAME} =~ '^-' ]];then - return - fi - - # Look for options passed through positional parameters. - case "${2}" in - - -f|--basename ) - - # Reduce the path passed to use just the non-directory - # part of it (i.e., the last component in the path; _not_ - # the last "real" directory in the path). - NAME=$(basename ${NAME}) - - # Clean value. - NAME=$(echo ${NAME} \ - | tr -s ' ' '_' \ - | tr '[:upper:]' '[:lower:]') - ;; - - -d|--dirname ) - - local DIR='' - local DIRS='' - local CLEANDIRS='' - local PREFIXDIR='' - - # In order to sanitate each directory in a path, it is - # required to break off the path string so each component - # can be worked out individually and later combine them - # back to create a clean path string. - - # Reduce path information passed to use the directory part - # of it only. Of course, this is applied if there is a - # directory part in the path. Assuming there is no - # directory part but a non-empty value in the path, use - # that value as directory part and clean it up. - if [[ ${NAME} =~ '.+/.+' ]];then - - # When path information is reduced, we need to - # consider that absolute paths contain some - # directories outside the working copy directory - # structure that shouldn't be sanitized (e.g., /home, - # /home/centos, /home/centos/artwork, - # /home/centos/artwork/turnk, trunk, etc.) So, we keep - # them unchanged for later use. - PREFIXDIR=$(echo ${NAME} \ - | sed -r "s,^((${TCAR_USER_WRKDIR}/)?(trunk|branches|tags)/)?.+$,\1,") - - # ... and remove them from the path information we do - # want to sanitate. - DIRS=$(dirname "${NAME}" \ - | sed -r "s!^${PREFIXDIR}!!" \ - | tr '/' ' ') - - else - - # At this point, there is not directory part in the - # information passed, so use the value passed as - # directory part as such. - DIRS=${NAME} - - fi - - for DIR in ${DIRS};do - - # Sanitate directory component. - if [[ ${DIR} =~ '^[a-z]' ]];then - DIR=$(echo ${DIR} \ - | tr -s ' ' '_' \ - | tr '[:upper:]' '[:lower:]' \ - | sed -r 's/^([[:alpha:]])/\u\1/') - fi - - # Rebuild path using sanitized values. - CLEANDIRS="${CLEANDIRS}/${DIR}" - - done - - # Redefine path using sanitized values. - NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") - - # Add prefix directory information to sanitate path - # information. - if [[ "${PREFIXDIR}" != '' ]];then - NAME=${PREFIXDIR}${NAME} - fi - ;; - - esac - - # Print out the clean path string. - echo ${NAME} - -} diff --git a/Automation/Modules/Cli/Scripts/cli_getTemporalFile.sh b/Automation/Modules/Cli/Scripts/cli_getTemporalFile.sh deleted file mode 100755 index 84f4e85..0000000 --- a/Automation/Modules/Cli/Scripts/cli_getTemporalFile.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_getTemporalFile.sh -- This function returns the absolute path -# you need to use to create temporal files. Use this function -# whenever you need to create temporal files inside centos-art.sh -# script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_getTemporalFile { - - # Define base name for temporal file. This is required when svg - # instances are created previous to be parsed by inkscape in order - # to be exported as png. In such cases .svg file extension is - # required in order to avoid complains from inkscape. - local FILENAME="$(cli_getRepoName ${1} -f)" - - # Check default base name for temporal file, it can't be an empty - # value. - if [[ -z "${FILENAME}" ]];then - cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line - fi - - # Define absolute path for temporal file and send it out to - # standard output. - echo "${TCAR_SCRIPT_TEMPDIR}/${FILENAME}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_initModule.sh b/Automation/Modules/Cli/Scripts/cli_initModule.sh deleted file mode 100755 index 4c1fe13..0000000 --- a/Automation/Modules/Cli/Scripts/cli_initModule.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_initModule.sh -- This function initiates module environments -# inside the centos-art.sh script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_initModule { - - # Define module's name (MODULE_NAME) using the first argument - # in the command-line. - local MODULE_NAME=$(cli_getRepoName "${1}" "-f" | cut -d '-' -f1) - - # Define regular expression to match available modules. - local MODULE_NAME_LIST=$(ls ${MODULE_BASEDIR}/ \ - | tr '\n' '|' | sed -r 's/\|$//' | tr '[[:upper:]]' '[[:lower:]]') - - # Check module's name possible values. - if [[ ! ${MODULE_NAME} =~ "^(${MODULE_NAME_LIST})$" ]];then - cli_printMessage "`gettext "The module provided isn't valid."`" --as-error-line - fi - - # Define function directory. - local MODULE_DIR=${MODULE_BASEDIR}/$(cli_getRepoName "${MODULE_NAME}" "-d") - - # Define function file name. - local MODULE_INIT_FILE=${MODULE_DIR}/${MODULE_NAME}.sh - - # Check function script execution rights. - cli_checkFiles -x ${MODULE_INIT_FILE} - - # Remove the first argument passed to centos-art.sh command-line - # in order to build optional arguments inside functionalities. We - # start counting from second argument (inclusive) on. - shift 1 - - # Verify number of arguments passed to centos-art.sh script. By - # default, to all modules, when no option is provided the version - # information is printed. - if [[ $# -lt 1 ]];then - cli_printVersion - fi - - # Go for function initialization. Keep the cli_exportFunctions - # function calling after all variables and arguments definitions. - cli_exportFunctions "${MODULE_INIT_FILE}" - - # Execute function. - ${MODULE_NAME} "${@}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printCaller.sh b/Automation/Modules/Cli/Scripts/cli_printCaller.sh deleted file mode 100755 index ef3bace..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printCaller.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printCaller.sh -- This function standardizes the way caller -# information is retrieved. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printCaller { - - local EXPR=${1} - local OPTS=${2} - - case ${OPTS} in - - --line ) - caller ${EXPR} | gawk '{ print $1 }' - ;; - - --name ) - caller ${EXPR} | gawk '{ print $2 }' - ;; - - --path ) - caller ${EXPR} | gawk '{ print $3 }' - ;; - - * ) - # Define where the error was originated inside the - # centos-art.sh script. Print out the function name and - # line from the caller. - caller ${EXPR} | gawk '{ print $2 " L." $1 }' - ;; - - esac - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printCopyrightInfo.sh b/Automation/Modules/Cli/Scripts/cli_printCopyrightInfo.sh deleted file mode 100755 index bdd11e7..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printCopyrightInfo.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printCopyrightInfo.sh -- This function standardizes the -# copyright information printed on content produced by centos-art.sh -# script. -# -# As far as I understand, the copyright exists to make people create -# more. The copyright gives creators the legal power over their -# creations and so the freedom to distribute them under the ethical -# terms the creator considers better. At this moment I don't feel -# very confident about this legal affairs and their legal -# implications, but I need to decide what copyright information the -# centos-art.sh script will print out when it be requested about it. -# So, in that sake, I'll assume the same copyright information used -# by The CentOS Wiki (http://wiki.centos.org/) as reference. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printCopyrightInfo { - - case "${1}" in - - --license ) - - # Print the license name. - echo "`gettext "Creative Common Attribution-ShareAlike 3.0 License"`" - ;; - - --license-url ) - - # Print the url related to license name. - cli_printUrl --cc-sharealike - ;; - - --first-year ) - - # The former year when I (as collaborator of The CentOS - # Project) started to consolidate The CentOS Project - # Corporate Visual Identity through the CentOS Artwork - # Repository. - echo '2009' - ;; - - --year|--last-year) - - # The last year when The CentOS Project stopped working in - # its Corporate Visual Identity through the CentOS Artwork - # Repository. That is something that I hope never happens, - # so assume the current year as last working year. - date +%Y - ;; - - --years-range ) - - local FIRST_YEAR=$(cli_printCopyrightInfo --first-year) - local LAST_YEAR=$(cli_printCopyrightInfo --last-year) - echo "${FIRST_YEAR}-${LAST_YEAR}" - ;; - - --years-list ) - - local FIRST_YEAR=$(cli_printCopyrightInfo --first-year) - local LAST_YEAR=$(cli_printCopyrightInfo --last-year) - - # Define full copyright year string based on first and - # last year. - local FULL_YEAR=$(\ - while [[ ${FIRST_YEAR} -le ${LAST_YEAR} ]];do - echo -n "${FIRST_YEAR}, " - FIRST_YEAR=$((${FIRST_YEAR} + 1)) - done) - - # Prepare full copyright year string and print it out. - echo "${FULL_YEAR}" | sed 's!, *$!!' - ;; - - --holder ) - - # Print centos-art.sh script default copyright holder. - echo "The CentOS Project" - ;; - - --holder-predicate ) - - local HOLDER=$(cli_printCopyrightInfo --holder) - echo "${HOLDER}. `gettext "All rights reserved."`" - ;; - - * ) - - local YEAR=$(cli_printCopyrightInfo --last-year) - local HOLDER=$(cli_printCopyrightInfo --holder) - echo "Copyright © ${YEAR} ${HOLDER}" - ;; - - esac - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printHelp.sh b/Automation/Modules/Cli/Scripts/cli_printHelp.sh deleted file mode 100755 index 86f1c0a..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printHelp.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printHelp.sh -- This function standardizes the way -# centos-art.sh script prints help about itself. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printHelp { - - ${TCAR_MANUAL_READER} "${MODULE_NAME}" - exit 0 - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printMailingList.sh b/Automation/Modules/Cli/Scripts/cli_printMailingList.sh deleted file mode 100755 index 94086da..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printMailingList.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printMailingList.sh -- This function standardizes the way -# mailing list addresses are printed on content produced by -# centos-art.sh script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printMailingList { - - local MAILADDRS='' - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='as-html-link:,docs' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local TCAR_ARGUMENTS='' - - # Process all arguments currently available in this function - # environment. If either ARGSS or ARGSL local variables have been - # defined, argument processing goes through getopt for validation. - cli_setArguments "${@}" - - # Redefine positional parameters using TCAR_ARGUMENTS variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Look for options passed through command-line. - while true; do - case "${1}" in - - --docs ) - MAILADDRS="${TCAR_BRAND}-docs@$(cli_printUrl --domain)" - shift 1 - ;; - - --as-html-link ) - MAILADDRS="${2}" - shift 2 - ;; - - -- ) - - shift 1 - break - ;; - esac - done - - # Print mail address. - echo "${MAILADDRS}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printMessage.sh b/Automation/Modules/Cli/Scripts/cli_printMessage.sh deleted file mode 100755 index 0113386..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printMessage.sh +++ /dev/null @@ -1,274 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printMessage.sh -- This function standardizes the way messages -# are printed by centos-art.sh script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printMessage { - - local MESSAGE="${1}" - local FORMAT="${2}" - - # Verify message variable, it cannot have an empty value. - if [[ -z ${MESSAGE} ]];then - cli_printMessage "`gettext "The message cannot be empty."`" --as-error-line - fi - - # Define message horizontal width. This is the max number of - # horizontal characters the message will use to be displayed on - # the screen. - local MESSAGE_WIDTH=66 - - # Remove empty spaces from message. - MESSAGE=$(echo ${MESSAGE} | sed -r -e 's!^[[:space:]]+!!') - - # Print messages that will always be printed no matter what value - # the TCAR_FLAG_QUIET variable has. - case "${FORMAT}" in - - --as-stdout-line ) - - # Default printing format. This is the format used when no - # other specification is passed to this function. As - # convenience, we transform absolute paths into relative - # paths in order to free horizontal space on final output - # messages. - echo "${MESSAGE}" | sed -r \ - -e "s!${TCAR_BASEDIR}/!!g" \ - -e "s!> /!> !g" \ - -e "s!/{2,}!/!g" \ - | gawk 'BEGIN { FS=": " } - { - if ( $0 ~ /^-+$/ ) - print $0 - else - printf "%-15s\t%s\n", $1, $2 - } - END {}' - ;; - - --as-error-line ) - - # Build the error message. - cli_printMessage "${TCAR_SCRIPT_COMMAND} ($(cli_printCaller 1)): ${MESSAGE}" --as-stderr-line - cli_printMessage "${MODULE_NAME}" --as-toknowmore-line - - # Finish script execution with exit status 1 (SIGHUP) to - # imply the script finished because an error. We are - # using this as convention to finish the script execution. - # So, don't remove the following line, please. - exit 1 - ;; - - --as-suggestion-line ) - - # Build the error message. - cli_printMessage "${TCAR_SCRIPT_COMMAND} ($(cli_printCaller 1)):" --as-stderr-line - cli_printMessage "`gettext "The path provided cannot be processed the way you entered it."`" --as-stderr-line - cli_printMessage "`gettext "Instead, try the following equivalence:"` ${MESSAGE}" --as-stderr-line - cli_printMessage "${MODULE_NAME}" --as-toknowmore-line - - # Finish script execution with exit status 1 (SIGHUP) to - # imply the script finished because an error. We are - # using this as convention to finish the script execution. - # So, don't remove the following line, please. - exit 1 - ;; - - --as-toknowmore-line ) - cli_printMessage "`gettext "To know more, run"` ${TCAR_SCRIPT_COMMAND} ${MESSAGE} --help" --as-stderr-line - ;; - - --as-yesornorequest-line ) - - # Define positive answer. - local Y="`gettext "yes"`" - - # Define negative answer. - local N="`gettext "no"`" - - # Define default answer. - local ANSWER=${N} - - if [[ ${TCAR_FLAG_YES} == 'true' ]];then - - ANSWER=${Y} - - else - - # Print the question to standard error. - cli_printMessage "${MESSAGE} [${Y}/${N}]" --as-request-line - - # Redefine default answer based on user's input. - read ANSWER - - fi - - # Verify user's answer. Only positive answer let the - # script flow to continue. Otherwise, if something - # different from positive answer is passed, the script - # terminates its execution immediately. - if [[ ! ${ANSWER} =~ "^${Y}" ]];then - exit - fi - ;; - - --as-selection-line ) - # Create selection based on message. - local NAME='' - select NAME in ${MESSAGE};do - echo ${NAME} - break - done - ;; - - --as-response-line ) - cli_printMessage "--> ${MESSAGE}" --as-stderr-line - ;; - - --as-request-line ) - cli_printMessage "${MESSAGE}:\040" --as-notrailingnew-line - ;; - - --as-notrailingnew-line ) - echo -e -n "${MESSAGE}" | sed -r \ - -e "s!${TCAR_BASEDIR}/!!g" 1>&2 - ;; - - --as-stderr-line ) - echo "${MESSAGE}" | sed -r \ - -e "s!${TCAR_BASEDIR}/!!g" 1>&2 - ;; - - esac - - # Verify verbose option. The verbose option controls whether - # messages are printed or not. - if [[ "${TCAR_FLAG_QUIET}" == 'true' ]];then - return - fi - - # Print messages that will be printed only when the TCAR_FLAG_QUIET - # variable is provided to centos-art.sh script. - case "${FORMAT}" in - - --as-separator-line ) - - # Build the separator line. - MESSAGE=$(\ - until [[ ${MESSAGE_WIDTH} -eq 0 ]];do - echo -n "$(echo ${MESSAGE} | sed -r 's!(.).*!\1!')" - MESSAGE_WIDTH=$((${MESSAGE_WIDTH} - 1)) - done) - - # Draw the separator line. - echo "${MESSAGE}" - ;; - - --as-banner-line ) - cli_printMessage '-' --as-separator-line - cli_printMessage "${MESSAGE}" --as-stdout-line - cli_printMessage '-' --as-separator-line - ;; - - --as-processing-line ) - cli_printMessage "`gettext "Processing"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-cropping-line ) - cli_printMessage "`gettext "Cropping from"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-tuningup-line ) - cli_printMessage "`gettext "Tuning-up"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-checking-line ) - cli_printMessage "`gettext "Checking"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-combining-line ) - cli_printMessage "`gettext "Combining"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-creating-line | --as-updating-line ) - if [[ -a "${MESSAGE}" ]];then - cli_printMessage "`gettext "Updating"`: ${MESSAGE}" --as-stdout-line - else - cli_printMessage "`gettext "Creating"`: ${MESSAGE}" --as-stdout-line - fi - ;; - - --as-deleting-line ) - cli_printMessage "`gettext "Deleting"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-reading-line ) - cli_printMessage "`gettext "Reading"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-savedas-line ) - cli_printMessage "`gettext "Saved as"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-linkto-line ) - cli_printMessage "`gettext "Linked to"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-movedto-line ) - cli_printMessage "`gettext "Moved to"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-translation-line ) - cli_printMessage "`gettext "Translation"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-translating-line ) - cli_printMessage "`gettext "Translating"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-validating-line ) - cli_printMessage "`gettext "Validating"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-template-line ) - cli_printMessage "`gettext "Template"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-configuration-line ) - cli_printMessage "`gettext "Configuration"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-palette-line ) - cli_printMessage "`gettext "Palette"`: ${MESSAGE}" --as-stdout-line - ;; - - --as-inkscape-line ) - cli_printMessage "${MESSAGE}" --as-stdout-line - ;; - - esac - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printUrl.sh b/Automation/Modules/Cli/Scripts/cli_printUrl.sh deleted file mode 100755 index 40c8d78..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printUrl.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printUrl.sh -- This function standardizes the way URLs are -# printed by centos-art.sh script. This function describes the -# domain organization of The CentOS Project through its URLs and -# provides a way to print them out when needed. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printUrl { - - local URL='' - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='domain,home,lists,wiki,forums,bugs,planet,docs,mirrors,projects,svn,trac,irc,cc-sharealike,with-locale,as-html-link' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local TCAR_ARGUMENTS='' - - # Process all arguments currently available in this function - # environment. If either ARGSS or ARGSL local variables have been - # defined, argument processing goes through getopt for validation. - cli_setArguments "${@}" - - # Redefine positional parameters using TCAR_ARGUMENTS variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Look for options passed through command-line. - while true; do - case "${1}" in - - --domain ) - URL="${TCAR_BRAND}.org" - shift 1 - ;; - - --home ) - URL="http://www.$(cli_printUrl --domain)/" - shift 1 - ;; - - --lists ) - URL="http://lists.$(cli_printUrl --domain)/" - shift 1 - ;; - - --wiki ) - URL="http://wiki.$(cli_printUrl --domain)/" - shift 1 - ;; - - --forums ) - URL="http://forums.$(cli_printUrl --domain)/" - shift 1 - ;; - - --bugs ) - URL="http://bugs.$(cli_printUrl --domain)/" - shift 1 - ;; - - --projects ) - URL="https://projects.$(cli_printUrl --domain)/" - shift 1 - ;; - - --svn ) - URL="$(cli_printUrl --projects)svn/" - shift 1 - ;; - - --trac ) - URL="$(cli_printUrl --projects)trac/" - shift 1 - ;; - - --planet ) - URL="http://planet.$(cli_printUrl --domain)/" - shift 1 - ;; - - --docs ) - URL="http://docs.$(cli_printUrl --domain)/" - shift 1 - ;; - - --mirrors ) - URL="http://mirrors.$(cli_printUrl --domain)/" - shift 1 - ;; - - --irc ) - URL="http://$(cli_printUrl --home)modules/tinycontent/index.php?id=8" - shift 1 - ;; - - --cc-sharealike ) - URL="http://creativecommons.org/licenses/by-sa/3.0/" - shift 1 - ;; - - --with-locale ) - if [[ ! ${LANG} =~ '^en' ]];then - URL="${URL}${TCAR_SCRIPT_LANG_LL}/" - fi - shift 1 - ;; - - --as-html-link ) - URL="${URL}" - shift 1 - ;; - - -- ) - - shift 1 - break - ;; - esac - done - - # Print Url. - echo "${URL}" - -} diff --git a/Automation/Modules/Cli/Scripts/cli_printVersion.sh b/Automation/Modules/Cli/Scripts/cli_printVersion.sh deleted file mode 100755 index 0bf3592..0000000 --- a/Automation/Modules/Cli/Scripts/cli_printVersion.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_printVersion.sh -- This function standardizes the way -# centos-art.sh script prints version about itself. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_printVersion { - - cli_printMessage "`eval_gettext "Running module $MODULE_NAME (v$MODULE_VERSION) through $TCAR_SCRIPT_NAME (v$TCAR_SCRIPT_VERSION)."`" --as-stdout-line - exit 0 - -} diff --git a/Automation/Modules/Cli/Scripts/cli_runFnEnvironment.sh b/Automation/Modules/Cli/Scripts/cli_runFnEnvironment.sh deleted file mode 100755 index 3fe5fe2..0000000 --- a/Automation/Modules/Cli/Scripts/cli_runFnEnvironment.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_runFnEnvironment.sh -- This function standardizes the way -# centos-art.sh script is called to itself. The main purpose of this -# somehow own interface is to control the parent script flow based -# on specific function environments exit status. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_runFnEnvironment { - - # Execute specific function environment. - ${MODULE_NAME} ${@} - - # Retrieve exit status. - local STATUS=$? - - # Finish script execution based on exit status. - if [[ ${STATUS} -ne 0 ]];then - exit ${STATUS} - fi - -} diff --git a/Automation/Modules/Cli/Scripts/cli_setArguments.sh b/Automation/Modules/Cli/Scripts/cli_setArguments.sh deleted file mode 100755 index 474da4b..0000000 --- a/Automation/Modules/Cli/Scripts/cli_setArguments.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_setArguments.sh -- This function uses getopt to process -# arguments passed to centos-art.sh script. -# -# This function works with the following three variables: -# -# ARGSS -# Stores getopt short arguments definition. -# -# ARGSL -# Stores getopt long arguments definition. -# -# TCAR_ARGUMENTS -# Stores arguments passed to functions or command-line -# interface depending the context it is defined. -# -# These three variables are not defined in this function but the -# function environment you want to provide option parsing for, -# through getopt command. Using local definition for these three -# variables let you to nest option parsing inside different -# function-environment levels. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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 -# -###################################################################### - -function cli_setArguments { - - # Verify existence of arguments that will be processed. If there - # is none, return to caller. - if [[ -z "${@}" ]];then - return - fi - - local ARGUMENT='' - - # Fill up arguments global variable with current positional - # parameter information. To avoid interpretation problems, use - # single quotes to enclose each argument (TCAR_ARGUMENTS) from - # command-line individually. - for ARGUMENT in "${@}"; do - - # Remove any single quote from arguments passed to - # centos-art.sh script. We will use single quotes for grouping - # option values so white space can be passed through them. - ARGUMENT=$(echo "${ARGUMENT}" | tr -d "'") - - # Concatenate arguments and enclose them to let getopt to - # process them when they have spaces inside. - TCAR_ARGUMENTS="${TCAR_ARGUMENTS} '${ARGUMENT}'" - - done - - # Verify non-option arguments passed to command-line. If there - # isn't any or dot is provided, redefine the TCAR_ARGUMENTS - # variable to use the current location the centos-art.sh script - # was called from. - if [[ -z "${TCAR_ARGUMENTS}" ]];then - TCAR_ARGUMENTS=${PWD} - fi - - # Verify presence of either short or long options in the - # environment. If they are present apply option validation through - # getopt. - if [[ ! -z ${ARGSS} ]] || [[ ! -z ${ARGSL} ]];then - - # Redefine positional parameters using TCAR_ARGUMENTS variable. - eval set -- "${TCAR_ARGUMENTS}" - - # Process positional parameters using getopt's option validation. - TCAR_ARGUMENTS=$(getopt -o "${ARGSS}" -l "${ARGSL}" \ - -n "${TCAR_SCRIPT_COMMAND} (${MODULE_NAME})" -- "${@}") - - # Verify getopt's exit status and finish the script execution - # with an error message, if it failed. - if [[ $? -ne 0 ]];then - cli_printMessage "`gettext "The argument verification failed."`" --as-error-line - fi - - fi - -} diff --git a/Automation/Modules/Cli/Scripts/cli_synchronizeRepoChanges.sh b/Automation/Modules/Cli/Scripts/cli_synchronizeRepoChanges.sh deleted file mode 100755 index 0f04ad3..0000000 --- a/Automation/Modules/Cli/Scripts/cli_synchronizeRepoChanges.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_synchronizeRepoChanges.sh -- This function standardizes the -# way changes are synchronized between the working copy and the -# central repository. This function is an interface to the Svn -# functionality of the centos-art.sh script. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_synchronizeRepoChanges { - - # Verify synchronization flag. - if [[ ${FLAG_SYNCHRONIZE} != 'true' ]];then - return - fi - - # Verify existence of locations passed to this function. - cli_checkFiles -e ${@} - - # Synchronize changes. - cli_runFnEnvironment vcs --synchronize ${@} - -} diff --git a/Automation/Modules/Cli/Scripts/cli_terminateScriptExecution.sh b/Automation/Modules/Cli/Scripts/cli_terminateScriptExecution.sh deleted file mode 100755 index 2e3daa5..0000000 --- a/Automation/Modules/Cli/Scripts/cli_terminateScriptExecution.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_terminateScriptExecution.sh -- This function standardizes the -# actions that must be realized just before leaving the script -# execution (e.g., cleaning temporal files). This function is the -# one called when interruption signals like EXIT, SIGHUP, SIGINT and -# SIGTERM are detected. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_terminateScriptExecution { - - # Remove temporal directory. - rm -r ${TCAR_SCRIPT_TEMPDIR} - - # NOTE: Don't specify an exit status here. As convenction we do - # this when error messages are triggerd. See `--as-error-line' - # option from `cli_printMessage' functionality. - -} diff --git a/Automation/Modules/Cli/Scripts/cli_unsetFunctions.sh b/Automation/Modules/Cli/Scripts/cli_unsetFunctions.sh deleted file mode 100755 index d1346d7..0000000 --- a/Automation/Modules/Cli/Scripts/cli_unsetFunctions.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli_unsetFunctions.sh -- This function unsets functionalities from -# centos-art.sh script execution environment. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli_unsetFunctions { - - # Define export id used to retrieve function files. This is the - # same export id used to export functions without the directory - # part. - local FUNCTION_EXPORTID=$(basename "${1}") - - # Verify suffix value used to retrieve function files. - if [[ ${FUNCTION_EXPORTID} == '' ]];then - cli_printMessage "`gettext "The export id was not provided."`" --as-error-line - fi - - # Define list of format-specific functionalities. This is the - # list of function definitions previously exported by - # `cli_exportFunctions'. Be sure to limit the list to function - # names that start with the suffix specified only. - local FUNCTION_DEF='' - local FUNCTION_DEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${FUNCTION_EXPORTID}") - - # Unset function names from current execution environment. - for FUNCTION_DEF in ${FUNCTION_DEFS};do - unset -f ${FUNCTION_DEF} - done - -} diff --git a/Automation/Modules/Cli/cli.conf b/Automation/Modules/Cli/cli.conf deleted file mode 100755 index c9a13d9..0000000 --- a/Automation/Modules/Cli/cli.conf +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli.conf -- This file provides default configuration values to -# centos-art.sh script's cli module. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -# -------------------------------------------------------------------- -# Command-line interface (read-only) configuration variables. -# -------------------------------------------------------------------- -declare -xr MODULE_VERSION='0.1' -declare -x MODULE_BASEDIR=${TCAR_SCRIPT_BASEDIR}/Modules - -# -------------------------------------------------------------------- -# Internationalization configuration variables. -# -------------------------------------------------------------------- -declare -x TEXTDOMAIN=${MODULE_NAME} -declare -x TEXTDOMAINDIR=${MODULE_DIR}/Locales - -# -------------------------------------------------------------------- -# Redefine manuals configuration values. -# -------------------------------------------------------------------- -declare -x TCAR_MANUAL_FILE=${MODULE_DIR}/${MODULE_NAME}.asciidoc -declare -x TCAR_MANUAL_SEARCHPATH=${MODULE_DIR}/Manuals -declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" diff --git a/Automation/Modules/Cli/cli.sh b/Automation/Modules/Cli/cli.sh deleted file mode 100755 index d10d7e8..0000000 --- a/Automation/Modules/Cli/cli.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -###################################################################### -# -# cli.sh -- This function initiates the centos-art.sh script -# command-line interface. This is the first script the centos-art.sh -# runs, onces it has been executed in a terminal. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function cli { - - # Initialize command-line interface common functions. - for MODULE_SCRIPT in $(ls ${TCAR_SCRIPT_INIT_DIR}/Scripts/*.sh);do - if [[ -x ${MODULE_SCRIPT} ]];then - . ${MODULE_SCRIPT} - export -f $(grep '^function ' ${MODULE_SCRIPT} | cut -d' ' -f2) - else - echo "${MODULE_SCRIPT} `gettext "has not execution rights."`" - fi - done - - # Trap signals in order to terminate the script execution - # correctly (e.g., removing all temporal files before leaving). - # Trapping the exit signal seems to be enough by now, since it is - # always present as part of the script execution flow. Each time - # the centos-art.sh script is executed it will inevitably end with - # an EXIT signal at some point of its execution, even if it is - # interrupted in the middle of its execution (e.g., through - # `Ctrl+C'). - trap cli_terminateScriptExecution 0 - - # Initialize command-line interface default configuration values. - if [[ -f ${TCAR_SCRIPT_INIT_DIR}/${TCAR_SCRIPT_INIT}.conf ]];then - . ${TCAR_SCRIPT_INIT_DIR}/${TCAR_SCRIPT_INIT}.conf - fi - - # Verify first argument passed to centos-art.sh script. - if [[ ${1} == "${TCAR_SCRIPT_INIT}" ]];then - cli_getOptions "${@}" - else - cli_initModule "${@}" - fi - -} diff --git a/Automation/Modules/Prepare/Scripts/prepare_getOptions.sh b/Automation/Modules/Prepare/Scripts/prepare_getOptions.sh index 621237e..b5e0985 100755 --- a/Automation/Modules/Prepare/Scripts/prepare_getOptions.sh +++ b/Automation/Modules/Prepare/Scripts/prepare_getOptions.sh @@ -1,10 +1,10 @@ #!/bin/bash ###################################################################### # -# prepare_getOptions.sh -- This function parses command options -# provided to `centos-art.sh' script when the first argument in the -# command-line is the `prepare' word. To parse options, this -# function makes use of getopt program. +# prepare_getOptions.sh -- This function parses options passed to +# `centos-art.sh' script command-line, when the first argument is +# the `prepare' word. To parse options, this function makes use of +# getopt program. # # Written by: # * Alain Reguera Delgado , 2009-2013 diff --git a/Automation/Modules/Prepare/prepare.asciidoc b/Automation/Modules/Prepare/prepare.asciidoc index 1f895a3..19dc075 100644 --- a/Automation/Modules/Prepare/prepare.asciidoc +++ b/Automation/Modules/Prepare/prepare.asciidoc @@ -29,10 +29,11 @@ The *prepare* module has the following options: *--quiet*:: This option suppresses all outputs except script's errors. *--packages*:: - This option verifies whether or not required packages are installed in the - workstation. When required packages are not installed in the workstation, - the *prepare* module executes the *yum install* command through *sudo* to - install the required packages. + This option verifies whether or not required packages are + installed in the workstation. When required packages are not + installed in the workstation, the *prepare* module executes the + *yum install* command through *sudo* to install the required + packages. *--images*:: This option calls the *render* module of *centos-art.sh* script and produces content related to all +images.conf+ files found diff --git a/Automation/Modules/Prepare/prepare.conf b/Automation/Modules/Prepare/prepare.conf index 8e747e3..ca57d2f 100755 --- a/Automation/Modules/Prepare/prepare.conf +++ b/Automation/Modules/Prepare/prepare.conf @@ -33,15 +33,3 @@ declare -xr MODULE_VERSION='0.1' declare -x MODULE_BASEDIR=${MODULE_DIR}/Modules declare -x MODULE_ACTIONS='' -# -------------------------------------------------------------------- -# Internationalization configuration variables. -# -------------------------------------------------------------------- -declare -x TEXTDOMAIN=${MODULE_NAME} -declare -x TEXTDOMAINDIR=${MODULE_DIR}/Locales - -# -------------------------------------------------------------------- -# Redefine manuals configuration values. -# -------------------------------------------------------------------- -declare -x TCAR_MANUAL_FILE=${MODULE_DIR}/${MODULE_NAME}.asciidoc -declare -x TCAR_MANUAL_SEARCHPATH=${MODULE_DIR}/Manuals -declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" diff --git a/Automation/Scripts/cli_checkFiles.sh b/Automation/Scripts/cli_checkFiles.sh new file mode 100755 index 0000000..0e4d50b --- /dev/null +++ b/Automation/Scripts/cli_checkFiles.sh @@ -0,0 +1,188 @@ +#!/bin/bash +###################################################################### +# +# cli_checkFiles.sh -- This function standardizes the way file +# conditional expressions are applied to files. Here is where +# centos-art.sh script answers questions like: is the file a regular +# file or a directory? Or, is it a symbolic link? Or even, does it +# have execution rights, etc. If the verification fails somehow at +# any point, an error message is output and centos-art.sh script +# finishes its execution. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_checkFiles { + + # Define short options. + local ARGSS='i:,r,m:,n,d,e,f,h,x' + + # Define long options. + local ARGSL='mime:,is-versioned,match:,is-installed' + + # Initialize local array variables. + local -a CONDITION_COMMAND + local -a CONDITION_PATTERN + local -a CONDITION_MESSAGE + + # Initialize local counter. + local COUNTER=0 + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. This + # variable is shared for different function environments. + local TCAR_ARGUMENTS='' + + # Redefine arguments using current positional parameters. + cli_setArguments "${@}" + + # Redefine positional parameters using arguments variable. + eval set -- "${TCAR_ARGUMENTS}" + + # Look for options passed through positional parameters. + while true; do + + case "${1}" in + + -d ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-d' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a directory."`" + shift 1 + ;; + + -e ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-e' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "doesn't exist."`" + shift 1 + ;; + + -f ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-f' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a regular file."`" + shift 1 + ;; + + -h ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-h' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't a symbolic link."`" + shift 1 + ;; + + -x ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-x' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't an executable file."`" + shift 1 + ;; + + -i | --mime ) + local MIME=${2} + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='file' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-bi' + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "isn't a \\\"\\\${MIME}\\\" file."`" + shift 2 + ;; + + -m | --match ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='match' + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="${2}" + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "doesn't match its pattern."`" + shift 2 + ;; + + -r | --is-versioned ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="centos-art" + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="vcs --is-versioned" + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="" + shift 1 + ;; + + -n | --is-installed ) + CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]="rpm" + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="-q --quiet" + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`gettext "isn't installed in the system."`" + shift 1 + ;; + + -- ) + shift 1 + break + ;; + + esac + done + + # Define list of files we want to apply verifications to, now that + # all option-like arguments have been removed from positional + # parameters list so we are free to go with the verifications. + local FILE='' + local FILES=${@} + + for FILE in ${FILES};do + + until [[ ${COUNTER} -eq ${#CONDITION_PATTERN[*]} ]];do + + case ${CONDITION_COMMAND[${COUNTER}]} in + + "test" | "rpm" ) + ${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE} \ + || cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line + ;; + + "centos-art" ) + # Don't create another level for error messages here + # (that would duplicate them unnecessarily). Instead, + # set error messages inside specific functionalities + # and use them directly from there. + cli_runFnEnvironment ${CONDITION_PATTERN[${COUNTER}]} ${FILE} + ;; + + "file" ) + if [[ ! $(${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE}) == "${MIME}" ]];then + cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line + fi + ;; + + "match" ) + if [[ ! ${FILE} =~ "${CONDITION_PATTERN[${COUNTER}]}" ]];then + cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line + fi + ;; + + * ) + cli_printMessage "`gettext "The condition command provided isn't supported."`" --as-error-line + ;; + + esac + + COUNTER=$((${COUNTER} + 1)) + + done + + done + +} diff --git a/Automation/Scripts/cli_checkRepoDirSource.sh b/Automation/Scripts/cli_checkRepoDirSource.sh new file mode 100755 index 0000000..19e434c --- /dev/null +++ b/Automation/Scripts/cli_checkRepoDirSource.sh @@ -0,0 +1,91 @@ +#!/bin/bash +###################################################################### +# +# cli_checkRepoDirSource.sh -- This function standardizes the path +# construction of directories inside the working copy, using +# absolute paths. This function transforms relative paths passed as +# non-option arguments to centos-art.sh script command-line into +# absolute paths inside the working copy based on whether you are +# using Subversion or Git as version control system. Further +# verifications, (e.g., whether they really exist as directories +# inside the working copy or not) should be realized outside this +# function. +# +# Use this function whenever you want to be sure non-option +# arguments passed to centos-art.sh script command-line do always +# point to directories inside the working copy. Transforming +# relative paths into absolute paths, before processing them, is +# very useful when you need to execute the centos-art.sh script as +# command (e.g., `centos-art') anywhere on your workstation. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_checkRepoDirSource { + + local LOCATION=${1} + + # Remove any dot from arguments passed to centos-art.sh script. + # This way it is possible to use a single dot to reflect the + # current location from which centos-art.sh was executed. Notice + # that using a dot as argument is optional (e.g.: when you pass no + # argument to centos-art command-line, the current location is + # used as default location). However, it might be useful to use a + # dot as argument when you want to include the current location in + # a list of arguments to process. + LOCATION=$(echo "${LOCATION}" | sed -r "s,^\.$,$(pwd),g") + + # Remove the working directory absolute path from location to + # avoid path duplications here. + LOCATION=$(echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,,g") + + # When we use Git as version control system, there isn't a need of + # using the `trunk', `branches', `tags' convention we were using + # for Subversion. The working copy begins directly with the + # content of our repository (e.g., Documentation, Scripts, + # Identity and Locales). + # + # When we use Subversion as version control system, we follow the + # `trunk', `branches', `tags' convention to organize files inside + # the repository and need to redefine the source path in order to + # build the repository absolute path from the repository top level + # on. As convention, when you prepare your working copy through + # centos-art.sh script, the absolute path to the `trunk/' + # directory is used as working copy. This is, path arguments + # provided to centos-art.sh script will be interpreted from trunk/ + # directory level on. For example, the following command should + # work correctly in both Subversion and Git repositories: + # + # centos-art render Documentation/Manuals/Docbook/Tcar-ug + # + # There isn't a need of verifying the paths built here. This is + # something we do later, using the cli_checkFiles function. We + # don't do the file verification here to avoid malformed error + # messages when we reassign variable values using this function as + # reference (e.g., in order to prevent error messages from being + # stored inside variables.). + LOCATION=${TCAR_USER_WRKDIR}/${LOCATION} + + # Output the absolute path to location. + echo "${LOCATION}" + +} diff --git a/Automation/Scripts/cli_expandTMarkers.sh b/Automation/Scripts/cli_expandTMarkers.sh new file mode 100755 index 0000000..ebeaff7 --- /dev/null +++ b/Automation/Scripts/cli_expandTMarkers.sh @@ -0,0 +1,190 @@ +#!/bin/bash +###################################################################### +# +# cli_expandTMarkers.sh -- This function standardizes construction +# of translation markers and their related expansion. As convention, +# translation markers must be set inside source files (e.g., +# Docbook, Svg, etc.) and expanded inside temporal instances used to +# produce final contents. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_expandTMarkers { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 + + # Define source location on which sed replacements take place. + local LOCATION="${1}" + + # Verify that source location does exist. + cli_checkFiles -e ${LOCATION} + + # Define copyright translation markers. + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(_LAST)?=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR(S)?_LIST=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --years-list)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --holder)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --holder-predicate)" + + # Define license translation markers. + SRC[((++${#SRC[*]}))]='=LICENSE=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license)" + SRC[((++${#SRC[*]}))]='=LICENSE_URL=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license-url)" + + # Define theme translation markers. + SRC[((++${#SRC[*]}))]='=THEME=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif)" + SRC[((++${#SRC[*]}))]='=THEMENAME=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-name)" + SRC[((++${#SRC[*]}))]='=THEMERELEASE=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-release)" + + # Define release-specific translation markers. + SRC[((++${#SRC[*]}))]='=RELEASE=' + DST[((++${#DST[*]}))]="${FLAG_RELEASEVER}" + SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f1)" + SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f2)" + + # Define architectures translation markers. + SRC[((++${#SRC[*]}))]='=ARCH=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${FLAG_BASEARCH} --architecture)" + + # Define url translation markers. + SRC[((++${#SRC[*]}))]='=URL=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--home' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_WIKI=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--wiki' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_LISTS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--lists' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_FORUMS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--forums' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--mirrors' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_DOCS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--docs' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_PROJECTS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--projects' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_BUGS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--bugs' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_SVN=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--svn' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_TRAC=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--trac' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_PLANET=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--planet' '--with-locale') + + # Define emails translation markers. + SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' + DST[((++${#DST[*]}))]="$(cli_printMailingList --docs)" + + # Define locale translation markers. + SRC[((++${#SRC[*]}))]='=LOCALE=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LC}" + SRC[((++${#SRC[*]}))]='=LOCALE_LL=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" + SRC[((++${#SRC[*]}))]='=LOCALE_CC=' + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_CC}" + + # Define domain translation markers for domains. + SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' + if [[ ! ${TCAR_SCRIPT_LANG_LL} =~ '^en' ]];then + DST[((++${#DST[*]}))]="${TCAR_SCRIPT_LANG_LL}" + else + DST[((++${#DST[*]}))]="" + fi + + # Define repository translation markers. + SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_BASEDIR)=' + DST[((++${#DST[*]}))]="${TCAR_BASEDIR}" + + # Do replacement of nested translation markers. + while [[ ${COUNTDST} -lt ${#DST[@]} ]];do + + # Verify existence of translation markers. If there is no + # translation marker on replacement, continue with the next + # one in the list. + if [[ ! ${DST[${COUNTDST}]} =~ '=[A-Z_]+=' ]];then + # Increment destination counter. + COUNTDST=$((${COUNTDST} + 1)) + # The current replacement value doesn't have translation + # marker inside, so skip it and evaluate the next + # replacement value in the list. + continue + fi + + while [[ ${COUNTSRC} -lt ${#SRC[*]} ]];do + + # Update replacements. + DST[${COUNTDST}]=$(echo ${DST[${COUNTDST}]} \ + | sed -r "s!${SRC[${COUNTSRC}]}!${DST[${COUNTSRC}]}!g") + + # Increment source counter. + COUNTSRC=$((${COUNTSRC} + 1)) + + done + + # Reset source counter + COUNTSRC=0 + + # Increment destination counter. + COUNTDST=$((${COUNTDST} + 1)) + + done + + # Apply replacements for translation markers. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + + # Use sed to replace translation markers inside the design + # model instance. + sed -r -i "s!${SRC[${COUNT}]}!${DST[${COUNT}]}!g" ${LOCATION} + + # Increment counter. + COUNT=$((${COUNT} + 1)) + + done + + # Remove escaped character from translation markers. This is one + # of the reasons why translation marker should be expanded in + # source files instances not the source files themselves. + # Escaping translation markers provides a way of talking about + # them without expanding them. + sed -r -i 's/(=)\\([A-Z_]+=)/\1\2/g' ${LOCATION} + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may remain from one file to another. + unset SRC + unset DST + +} diff --git a/Automation/Scripts/cli_exportFunctions.sh b/Automation/Scripts/cli_exportFunctions.sh new file mode 100755 index 0000000..2b15a5a --- /dev/null +++ b/Automation/Scripts/cli_exportFunctions.sh @@ -0,0 +1,85 @@ +#!/bin/bash +###################################################################### +# +# cli_exportFunctions.sh -- This function standardizes the way +# specific functionalities are exported to centos-art.sh script +# environment. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_exportFunctions { + + # Retrieve export identifier for the function we want to export. + local MODULE_INIT_FILE="${1}" + + # Verify the export identification existence. + cli_checkFiles -x ${MODULE_INIT_FILE} + + # Define the source location where function files are placed in. + local MODULE_SCRIPTS_DIR=$(dirname ${MODULE_INIT_FILE})/Scripts + + # Define suffix used to retrieve function files. + local MODULE_INIT_FILENAME=$(basename "${MODULE_INIT_FILE}" | sed -r 's/\.sh$//') + + # Define the pattern used to retrieve function names from function + # files. + local FUNCTION_PATTERN="^function[[:space:]]+${MODULE_INIT_FILENAME}(_[[:alnum:]]+)?[[:space:]]+{[[:space:]]*$" + + # Define the list of files. + local MODULE_SCRIPTS="${MODULE_INIT_FILE} + $(cli_getFilesList ${MODULE_SCRIPTS_DIR} \ + --pattern="${MODULE_DIR}/.+\.sh$" --maxdepth='1' \ + --mindepth='1' --type='f')" + + # Verify the list of files. If no function file exists for the + # location specified stop the script execution. Otherwise the + # script will surely try to execute a function that haven't been + # exported yet and report an error about it. + if [[ -z ${MODULE_SCRIPTS} ]];then + cli_printMessage "${FUNCNAME}: `gettext "No function file was found."`" --as-error-line + fi + + # Process the list of files. + for MODULE_SCRIPT in ${MODULE_SCRIPTS};do + + # Verify the execution rights for function file. + cli_checkFiles -x ${MODULE_SCRIPT} + + # Verify that function files have not been already exported. + # If they have been already exported don't export them again. + # Instead, continue with the next function file in the list. + declare -F | gawk '{ print $3 }' | egrep "^${MODULE_SCRIPT}$" > /dev/null + if [[ $? -eq 0 ]];then + continue + fi + + # Initialize the function file. + . ${MODULE_SCRIPT} + + # Export the function names inside the file to current shell + # script environment. + export -f $(egrep "${FUNCTION_PATTERN}" ${MODULE_SCRIPT} | gawk '{ print $2 }') + + done + +} diff --git a/Automation/Scripts/cli_getConfigLines.sh b/Automation/Scripts/cli_getConfigLines.sh new file mode 100755 index 0000000..46a1783 --- /dev/null +++ b/Automation/Scripts/cli_getConfigLines.sh @@ -0,0 +1,70 @@ +#!/bin/bash +###################################################################### +# +# cli_getConfigLines.sh -- This function standardizes the way +# configuration lines are retrieved form configuration files. As +# arguments, the configuration file absolute path, the configuration +# section name, and the configuration option name must be provided. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getConfigLines { + + # Initialize absolute path to configuration file. + local CONFIGURATION_FILE="${1}" + + # Verify that configuration file does exist. + cli_checkFiles -e ${CONFIGURATION_FILE} + + # Initialize configuration section name where the variable value + # we want to to retrieve is set in. + local CONFIGURATION_SECTION="${2}" + + # Be sure the configuration section name has the correct format. + if [[ ! ${CONFIGURATION_SECTION} =~ '^[[:alnum:]._-]+$' ]];then + cli_printMessage "`gettext "The configuration section provided is incorrect."`" --as-error-line + fi + + # Initialize variable name we want to retrieve value from. + local CONFIGURATION_OPTION="${3}" + + # Verify configuration variable name. When no variable name is + # provided print all configuration lines that can be considered as + # well-formed paths. Be sure configuration variable name starts + # just at the beginning of the line. + if [[ ! ${CONFIGURATION_OPTION} =~ '^[[:alnum:]_./-]+$' ]];then + CONFIGURATION_OPTION='[[:alnum:]_./-]+[[:space:]]*=' + fi + + # Retrieve configuration lines from configuration file. + local CONFIGURATION_LINES=$(cat ${CONFIGURATION_FILE} \ + | egrep -v '^#' \ + | egrep -v '^[[:space:]]*$' \ + | sed -r -n "/^\[${CONFIGURATION_SECTION}\][[:space:]]*$/,/^\[/p" \ + | egrep -v '^\[' | sort | uniq \ + | egrep "^${CONFIGURATION_OPTION}") + + # Output value related to variable name. + echo "${CONFIGURATION_LINES}" + +} diff --git a/Automation/Scripts/cli_getConfigSectionNames.sh b/Automation/Scripts/cli_getConfigSectionNames.sh new file mode 100755 index 0000000..387defc --- /dev/null +++ b/Automation/Scripts/cli_getConfigSectionNames.sh @@ -0,0 +1,44 @@ +#!/bin/bash +###################################################################### +# +# cli_getConfigSectionNames.sh -- This function standardizes the way +# section names are retrieved from configuration files. Once section +# names are retrieved they are printed to standard output for +# further processing. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getConfigSectionNames { + + # Define absolute path to configuration file we want to retrieve + # section names from. + local CONFIGURATION_FILE=${1} + + # Verify existence of configuration file. + cli_checkFiles ${CONFIGURATION_FILE} -f + + # Output all section names without brackets, one per line. + egrep '^\[[[:alnum:]._-]+\][[:space:]]*$' ${CONFIGURATION_FILE} \ + | sed -r 's/\[(.+)\]/\1/' + +} diff --git a/Automation/Scripts/cli_getConfigValue.sh b/Automation/Scripts/cli_getConfigValue.sh new file mode 100755 index 0000000..82b3127 --- /dev/null +++ b/Automation/Scripts/cli_getConfigValue.sh @@ -0,0 +1,56 @@ +#!/bin/bash +###################################################################### +# +# cli_getConfigValue.sh -- This function standardizes the way +# configuration values are retrieved from configuration files. As +# arguments, the configuration file absolute path, the configuration +# section name, and the configuration option name must be provided. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getConfigValue { + + # Initialize absolute path to configuration file. + local CONFIGURATION_FILE="${1}" + + # Initialize configuration section name where the variable value + # we want to to retrieve is set in. + local CONFIGURATION_SECTION="${2}" + + # Initialize variable name we want to retrieve value from. + local CONFIGURATION_OPTION="${3}" + + # Retrieve configuration lines from configuration file. + local CONFIGURATION_LINES=$(cli_getConfigLines \ + "${CONFIGURATION_FILE}" "${CONFIGURATION_SECTION}" "${CONFIGURATION_OPTION}") + + # Parse configuration lines to retrieve the values of variable + # names. + local CONFIGURATION_VALUE=$(echo ${CONFIGURATION_LINES} \ + | cut -d= -f2- \ + | sed -r -e 's/"//g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' ) + + # Output values related to variable name. + echo "${CONFIGURATION_VALUE}" + +} diff --git a/Automation/Scripts/cli_getFilesList.sh b/Automation/Scripts/cli_getFilesList.sh new file mode 100755 index 0000000..8c4e2e2 --- /dev/null +++ b/Automation/Scripts/cli_getFilesList.sh @@ -0,0 +1,126 @@ +#!/bin/bash +###################################################################### +# +# cli_getFilesList.sh -- This function standardizes the way list of +# files are built inside centos-art.sh script. This function outputs +# a sorted and unique list of files based on the options and +# locations passed as argument. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getFilesList { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' + + # Initialize pattern used to reduce the find output. + local PATTERN="${TCAR_FLAG_FILTER}" + + # Initialize options used with find command. + local OPTIONS='' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local TCAR_ARGUMENTS='' + + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" + + # Redefine positional parameters using TCAR_ARGUMENTS variable. + eval set -- "${TCAR_ARGUMENTS}" + + while true;do + case "${1}" in + + --pattern ) + PATTERN="${2}" + shift 2 + ;; + + --maxdepth ) + OPTIONS="${OPTIONS} -maxdepth ${2}" + shift 2 + ;; + + --mindepth ) + OPTIONS="${OPTIONS} -mindepth ${2}" + shift 2 + ;; + + --type ) + OPTIONS="${OPTIONS} -type ${2}" + shift 2 + ;; + + --uid ) + OPTIONS="${OPTIONS} -uid ${2}" + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # At this point all options arguments have been processed and + # removed from positional parameters. Only non-option arguments + # remain so we use them as source location for find command to + # look files for. + + # Verify that locations does exist. + cli_checkFiles -e ${@} + + # Redefine pattern as regular expression. When we use regular + # expressions with find, regular expressions are evaluated against + # the whole file path. This way, when the regular expression is + # specified, we need to build it in a way that matches the whole + # path we are using. Doing so, every time we pass the `--filter' + # option in the command-line could be a tedious task. Instead, in + # the sake of reducing some typing, we prepare the regular + # expression here to match the whole path using the regular + # expression provided by the user as pattern. Do not use locations + # as part of regular expression so it could be possible to use + # path expansion. Using path expansion reduce the amount of + # places to find out things and so the time required to finish the + # task. + # + # Don't do such path expansion here. Instead, do it when you call + # this function. Otherwise you would be prohibiting the + # application of exact patterns. + #PATTERN="^/.*${PATTERN}$" + + # Define list of files to process. At this point we cannot verify + # whether the location is a directory or a file since path + # expansion could be introduced to it. The best we can do is + # verifying exit status and go on. + find ${@} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq + +} diff --git a/Automation/Scripts/cli_getLocalizationDir.sh b/Automation/Scripts/cli_getLocalizationDir.sh new file mode 100755 index 0000000..4377c5b --- /dev/null +++ b/Automation/Scripts/cli_getLocalizationDir.sh @@ -0,0 +1,62 @@ +#!/bin/bash +###################################################################### +# +# cli_getLocalizationDir.sh -- This function standardizes the way +# localization paths are created. The first argument of this +# function must be a path pointing a directory inside the +# repository. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getLocalizationDir { + + # 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. + LOCATION=$(cli_checkRepoDirSource "${1}") + + # In case the location specified would be a file, remove the file + # part from the path so only its parent directory remains. + if [[ -f ${LOCATION} ]];then + LOCATION=$(dirname ${LOCATION}) + fi + + # Make path transformation. + case "${2}" in + + '--no-lang' ) + LOCATION=$(echo "${LOCATION}" \ + | sed -r -e "s!(Identity|Scripts|Documentation)!Locales/\1!") + ;; + + * ) + LOCATION=$(echo "${LOCATION}" \ + | sed -r -e "s!(Identity|Scripts|Documentation)!Locales/\1!")/${TCAR_SCRIPT_LANG_LC} + ;; + + esac + + # Output transformed path. + echo "${LOCATION}" + +} diff --git a/Automation/Scripts/cli_getOptions.sh b/Automation/Scripts/cli_getOptions.sh new file mode 100755 index 0000000..d606855 --- /dev/null +++ b/Automation/Scripts/cli_getOptions.sh @@ -0,0 +1,94 @@ +#!/bin/bash +###################################################################### +# +# cli_getOptions.sh -- This function parses common options passed to +# to `centos-art.sh' script. Because option parsing is different for +# each function environment inside centos-art.sh script, we cannot +# use getopt here. That would enter in conflict with options from +# deeper function environments making impossible to parse both +# common and specific options through getopt in a modular way (e.g., +# without duplicating common option definition inside each different +# module the centos-art.sh script is made of). +# +# To solve this issue centos-art.sh script restricts the order in +# which common options are passed through the command line. This +# way, common options must be passed first and specific options +# later. Common options are defined in this file and specific +# options are defined in module-specific files. +# +# This introduces the nature of common options: common options do +# not modify the centos-art.sh script behaviour in any way. Common +# options exist to show information about centos-art.sh script and +# its modules only (e.g., --help and --version) and once done, exit +# successfully without processing any other option or argument +# passed in the command-line. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getOptions { + + # Define valid short options. + local ARGSS="h,v" + + # Define valid long options. + local ARGSL="help,version" + + # Define module arguments local to this function. This is very + # important in order to provide option parsing for different + # function environment levels. + local TCAR_ARGUMENTS='' + + # Redefine arguments using getopt(1) command parser. + cli_setArguments "${@}" + + # Reset positional parameters on this function, using output + # produced from (getopt) arguments parser. + eval set -- "${TCAR_ARGUMENTS}" + + # Look for options passed through command-line. + while true; do + case ${1} in + + -h | --help ) + cli_printHelp + ;; + + -v | --version ) + cli_printVersion + ;; + + * ) + # At this point none of the valid options were + # provided so, finish the script execution. This is + # not absolutely needed because getopt will complain + # about non-valid options and probably never execution + # reaches this point. Consider this a backup + # verification. + exit 0 + ;; + + esac + + done + +} diff --git a/Automation/Scripts/cli_getPathComponent.sh b/Automation/Scripts/cli_getPathComponent.sh new file mode 100755 index 0000000..a563f5c --- /dev/null +++ b/Automation/Scripts/cli_getPathComponent.sh @@ -0,0 +1,142 @@ +#!/bin/bash +###################################################################### +# +# cli_getPathComponent.sh -- This function standardizes the way +# directory structures are organized inside the working copy of +# CentOS Artwork Repository. You can use this function to retrieve +# information from paths (e.g., releases, architectures and theme +# artistic motifs) or the patterns used to build the paths. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getPathComponent { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,motif,motif-name,motif-release,motif-pattern,repo-dir' + + # Define release pattern. + local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+))?)" + + # Define architecture pattern. Make it match the architectures the + # CentOS distribution is able to be installed on. + local ARCHITECTURE="(i386|x86_64)" + + # Define regular expression pattern that match the theme artistic + # motif component inside the path strings. + local THEME_MOTIF="Identity/Images/Themes/(([[:alnum:]]+)/(${RELEASE}))" + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local TCAR_ARGUMENTS='' + + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" + + # Redefine positional parameters using TCAR_ARGUMENTS variable. + eval set -- "${TCAR_ARGUMENTS}" + + # Define location we want to apply verifications to. + local LOCATION=$(echo ${@} | sed -r 's!^.*--[[:space:]](.+)$!\1!') + + # Look for options passed through positional parameters. + while true;do + + case "${1}" in + + --release ) + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!" + shift 1 + break + ;; + + --release-major ) + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!" + shift 1 + break + ;; + + --release-minor ) + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!" + shift 1 + break + ;; + + --release-pattern ) + echo "${RELEASE}" + shift 1 + break + ;; + + --architecture ) + echo "${LOCATION}" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!" + shift 1 + break + ;; + + --architecture-pattern ) + echo "${ARCHITECTURE}" + shift 1 + break + ;; + + --motif ) + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!" + shift 1 + break + ;; + + --motif-name ) + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!" + shift 1 + break + ;; + + --motif-release ) + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!" + shift 1 + break + ;; + + --motif-pattern ) + echo "${THEME_MOTIF}" + shift 1 + break + ;; + + --repo-dir ) + echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,," + shift 1 + break + ;; + + esac + + done + +} diff --git a/Automation/Scripts/cli_getRepoName.sh b/Automation/Scripts/cli_getRepoName.sh new file mode 100755 index 0000000..ebbe5d2 --- /dev/null +++ b/Automation/Scripts/cli_getRepoName.sh @@ -0,0 +1,136 @@ +#!/bin/bash +###################################################################### +# +# cli_getRepoName.sh -- This function standardizes files and +# directories name convection inside the working copy of CentOS +# Artowrk Repository. As convection, regular files are written in +# lower-case and directories are written capitalized. Use this +# function to sanitate the name of regular files and directories on +# paths you work with. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getRepoName { + + # Define the name we want to apply verifications to. + local NAME="${1}" + + # Avoid using options as it were names. When name value is empty + # but an option is provided, the option becomes the first + # positional argument and is evaluated as it were a name which is + # something we need to prevent from happening. + if [[ ${NAME} =~ '^-' ]];then + return + fi + + # Look for options passed through positional parameters. + case "${2}" in + + -f|--basename ) + + # Reduce the path passed to use just the non-directory + # part of it (i.e., the last component in the path; _not_ + # the last "real" directory in the path). + NAME=$(basename ${NAME}) + + # Clean value. + NAME=$(echo ${NAME} \ + | tr -s ' ' '_' \ + | tr '[:upper:]' '[:lower:]') + ;; + + -d|--dirname ) + + local DIR='' + local DIRS='' + local CLEANDIRS='' + local PREFIXDIR='' + + # In order to sanitate each directory in a path, it is + # required to break off the path string so each component + # can be worked out individually and later combine them + # back to create a clean path string. + + # Reduce path information passed to use the directory part + # of it only. Of course, this is applied if there is a + # directory part in the path. Assuming there is no + # directory part but a non-empty value in the path, use + # that value as directory part and clean it up. + if [[ ${NAME} =~ '.+/.+' ]];then + + # When path information is reduced, we need to + # consider that absolute paths contain some + # directories outside the working copy directory + # structure that shouldn't be sanitized (e.g., /home, + # /home/centos, /home/centos/artwork, + # /home/centos/artwork/turnk, trunk, etc.) So, we keep + # them unchanged for later use. + PREFIXDIR=$(echo ${NAME} \ + | sed -r "s,^((${TCAR_USER_WRKDIR}/)?(trunk|branches|tags)/)?.+$,\1,") + + # ... and remove them from the path information we do + # want to sanitate. + DIRS=$(dirname "${NAME}" \ + | sed -r "s!^${PREFIXDIR}!!" \ + | tr '/' ' ') + + else + + # At this point, there is not directory part in the + # information passed, so use the value passed as + # directory part as such. + DIRS=${NAME} + + fi + + for DIR in ${DIRS};do + + # Sanitate directory component. + if [[ ${DIR} =~ '^[a-z]' ]];then + DIR=$(echo ${DIR} \ + | tr -s ' ' '_' \ + | tr '[:upper:]' '[:lower:]' \ + | sed -r 's/^([[:alpha:]])/\u\1/') + fi + + # Rebuild path using sanitized values. + CLEANDIRS="${CLEANDIRS}/${DIR}" + + done + + # Redefine path using sanitized values. + NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") + + # Add prefix directory information to sanitate path + # information. + if [[ "${PREFIXDIR}" != '' ]];then + NAME=${PREFIXDIR}${NAME} + fi + ;; + + esac + + # Print out the clean path string. + echo ${NAME} + +} diff --git a/Automation/Scripts/cli_getTemporalFile.sh b/Automation/Scripts/cli_getTemporalFile.sh new file mode 100755 index 0000000..84f4e85 --- /dev/null +++ b/Automation/Scripts/cli_getTemporalFile.sh @@ -0,0 +1,49 @@ +#!/bin/bash +###################################################################### +# +# cli_getTemporalFile.sh -- This function returns the absolute path +# you need to use to create temporal files. Use this function +# whenever you need to create temporal files inside centos-art.sh +# script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_getTemporalFile { + + # Define base name for temporal file. This is required when svg + # instances are created previous to be parsed by inkscape in order + # to be exported as png. In such cases .svg file extension is + # required in order to avoid complains from inkscape. + local FILENAME="$(cli_getRepoName ${1} -f)" + + # Check default base name for temporal file, it can't be an empty + # value. + if [[ -z "${FILENAME}" ]];then + cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line + fi + + # Define absolute path for temporal file and send it out to + # standard output. + echo "${TCAR_SCRIPT_TEMPDIR}/${FILENAME}" + +} diff --git a/Automation/Scripts/cli_initModule.sh b/Automation/Scripts/cli_initModule.sh new file mode 100755 index 0000000..29d039c --- /dev/null +++ b/Automation/Scripts/cli_initModule.sh @@ -0,0 +1,81 @@ +#!/bin/bash +###################################################################### +# +# cli_initModule.sh -- This function initiates module environments +# inside the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_initModule { + + # Define module's name (MODULE_NAME) using the first argument + # in the command-line. + local MODULE_NAME=$(cli_getRepoName "${1}" "-f" | cut -d '-' -f1) + + # Define regular expression to match available modules. + local MODULE_NAME_LIST=$(ls ${TCAR_SCRIPT_MODULES_BASEDIR} \ + | tr '\n' '|' | sed -r 's/\|$//' | tr '[[:upper:]]' '[[:lower:]]') + + # Check module's name possible values. + if [[ ! ${MODULE_NAME} =~ "^(${MODULE_NAME_LIST})$" ]];then + cli_printMessage "`gettext "The module provided isn't valid."`" --as-error-line + fi + + # Define function directory. + local MODULE_DIR=${TCAR_SCRIPT_MODULES_BASEDIR}/$(cli_getRepoName "${MODULE_NAME}" "-d") + + # Define function file name. + local MODULE_INIT_FILE=${MODULE_DIR}/${MODULE_NAME}.sh + + # Check function script execution rights. + cli_checkFiles -x ${MODULE_INIT_FILE} + + # Remove the first argument passed to centos-art.sh command-line + # in order to build optional arguments inside functionalities. We + # start counting from second argument (inclusive) on. + shift 1 + + # Verify number of arguments passed to centos-art.sh script. By + # default, to all modules, when no option is provided the version + # information is printed. + if [[ $# -lt 1 ]];then + cli_printVersion + fi + + # Redefine internationalization configuration variables. + declare -x TEXTDOMAIN=${MODULE_NAME} + declare -x TEXTDOMAINDIR=${MODULE_DIR}/Locales + + # Redefine manuals configuration values. + declare -x TCAR_MANUAL_FILE=${MODULE_DIR}/${MODULE_NAME}.asciidoc + declare -x TCAR_MANUAL_SEARCHPATH=${MODULE_DIR}/Manuals + declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" + + # Go for function initialization. Keep the cli_exportFunctions + # function calling after all variables and arguments definitions. + cli_exportFunctions "${MODULE_INIT_FILE}" + + # Execute function. + ${MODULE_NAME} "${@}" + +} diff --git a/Automation/Scripts/cli_printCaller.sh b/Automation/Scripts/cli_printCaller.sh new file mode 100755 index 0000000..ef3bace --- /dev/null +++ b/Automation/Scripts/cli_printCaller.sh @@ -0,0 +1,57 @@ +#!/bin/bash +###################################################################### +# +# cli_printCaller.sh -- This function standardizes the way caller +# information is retrieved. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printCaller { + + local EXPR=${1} + local OPTS=${2} + + case ${OPTS} in + + --line ) + caller ${EXPR} | gawk '{ print $1 }' + ;; + + --name ) + caller ${EXPR} | gawk '{ print $2 }' + ;; + + --path ) + caller ${EXPR} | gawk '{ print $3 }' + ;; + + * ) + # Define where the error was originated inside the + # centos-art.sh script. Print out the function name and + # line from the caller. + caller ${EXPR} | gawk '{ print $2 " L." $1 }' + ;; + + esac + +} diff --git a/Automation/Scripts/cli_printCopyrightInfo.sh b/Automation/Scripts/cli_printCopyrightInfo.sh new file mode 100755 index 0000000..bdd11e7 --- /dev/null +++ b/Automation/Scripts/cli_printCopyrightInfo.sh @@ -0,0 +1,119 @@ +#!/bin/bash +###################################################################### +# +# cli_printCopyrightInfo.sh -- This function standardizes the +# copyright information printed on content produced by centos-art.sh +# script. +# +# As far as I understand, the copyright exists to make people create +# more. The copyright gives creators the legal power over their +# creations and so the freedom to distribute them under the ethical +# terms the creator considers better. At this moment I don't feel +# very confident about this legal affairs and their legal +# implications, but I need to decide what copyright information the +# centos-art.sh script will print out when it be requested about it. +# So, in that sake, I'll assume the same copyright information used +# by The CentOS Wiki (http://wiki.centos.org/) as reference. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printCopyrightInfo { + + case "${1}" in + + --license ) + + # Print the license name. + echo "`gettext "Creative Common Attribution-ShareAlike 3.0 License"`" + ;; + + --license-url ) + + # Print the url related to license name. + cli_printUrl --cc-sharealike + ;; + + --first-year ) + + # The former year when I (as collaborator of The CentOS + # Project) started to consolidate The CentOS Project + # Corporate Visual Identity through the CentOS Artwork + # Repository. + echo '2009' + ;; + + --year|--last-year) + + # The last year when The CentOS Project stopped working in + # its Corporate Visual Identity through the CentOS Artwork + # Repository. That is something that I hope never happens, + # so assume the current year as last working year. + date +%Y + ;; + + --years-range ) + + local FIRST_YEAR=$(cli_printCopyrightInfo --first-year) + local LAST_YEAR=$(cli_printCopyrightInfo --last-year) + echo "${FIRST_YEAR}-${LAST_YEAR}" + ;; + + --years-list ) + + local FIRST_YEAR=$(cli_printCopyrightInfo --first-year) + local LAST_YEAR=$(cli_printCopyrightInfo --last-year) + + # Define full copyright year string based on first and + # last year. + local FULL_YEAR=$(\ + while [[ ${FIRST_YEAR} -le ${LAST_YEAR} ]];do + echo -n "${FIRST_YEAR}, " + FIRST_YEAR=$((${FIRST_YEAR} + 1)) + done) + + # Prepare full copyright year string and print it out. + echo "${FULL_YEAR}" | sed 's!, *$!!' + ;; + + --holder ) + + # Print centos-art.sh script default copyright holder. + echo "The CentOS Project" + ;; + + --holder-predicate ) + + local HOLDER=$(cli_printCopyrightInfo --holder) + echo "${HOLDER}. `gettext "All rights reserved."`" + ;; + + * ) + + local YEAR=$(cli_printCopyrightInfo --last-year) + local HOLDER=$(cli_printCopyrightInfo --holder) + echo "Copyright © ${YEAR} ${HOLDER}" + ;; + + esac + +} diff --git a/Automation/Scripts/cli_printHelp.sh b/Automation/Scripts/cli_printHelp.sh new file mode 100755 index 0000000..86f1c0a --- /dev/null +++ b/Automation/Scripts/cli_printHelp.sh @@ -0,0 +1,34 @@ +#!/bin/bash +###################################################################### +# +# cli_printHelp.sh -- This function standardizes the way +# centos-art.sh script prints help about itself. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printHelp { + + ${TCAR_MANUAL_READER} "${MODULE_NAME}" + exit 0 + +} diff --git a/Automation/Scripts/cli_printMailingList.sh b/Automation/Scripts/cli_printMailingList.sh new file mode 100755 index 0000000..94086da --- /dev/null +++ b/Automation/Scripts/cli_printMailingList.sh @@ -0,0 +1,78 @@ +#!/bin/bash +###################################################################### +# +# cli_printMailingList.sh -- This function standardizes the way +# mailing list addresses are printed on content produced by +# centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printMailingList { + + local MAILADDRS='' + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='as-html-link:,docs' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local TCAR_ARGUMENTS='' + + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" + + # Redefine positional parameters using TCAR_ARGUMENTS variable. + eval set -- "${TCAR_ARGUMENTS}" + + # Look for options passed through command-line. + while true; do + case "${1}" in + + --docs ) + MAILADDRS="${TCAR_BRAND}-docs@$(cli_printUrl --domain)" + shift 1 + ;; + + --as-html-link ) + MAILADDRS="${2}" + shift 2 + ;; + + -- ) + + shift 1 + break + ;; + esac + done + + # Print mail address. + echo "${MAILADDRS}" + +} diff --git a/Automation/Scripts/cli_printMessage.sh b/Automation/Scripts/cli_printMessage.sh new file mode 100755 index 0000000..0113386 --- /dev/null +++ b/Automation/Scripts/cli_printMessage.sh @@ -0,0 +1,274 @@ +#!/bin/bash +###################################################################### +# +# cli_printMessage.sh -- This function standardizes the way messages +# are printed by centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printMessage { + + local MESSAGE="${1}" + local FORMAT="${2}" + + # Verify message variable, it cannot have an empty value. + if [[ -z ${MESSAGE} ]];then + cli_printMessage "`gettext "The message cannot be empty."`" --as-error-line + fi + + # Define message horizontal width. This is the max number of + # horizontal characters the message will use to be displayed on + # the screen. + local MESSAGE_WIDTH=66 + + # Remove empty spaces from message. + MESSAGE=$(echo ${MESSAGE} | sed -r -e 's!^[[:space:]]+!!') + + # Print messages that will always be printed no matter what value + # the TCAR_FLAG_QUIET variable has. + case "${FORMAT}" in + + --as-stdout-line ) + + # Default printing format. This is the format used when no + # other specification is passed to this function. As + # convenience, we transform absolute paths into relative + # paths in order to free horizontal space on final output + # messages. + echo "${MESSAGE}" | sed -r \ + -e "s!${TCAR_BASEDIR}/!!g" \ + -e "s!> /!> !g" \ + -e "s!/{2,}!/!g" \ + | gawk 'BEGIN { FS=": " } + { + if ( $0 ~ /^-+$/ ) + print $0 + else + printf "%-15s\t%s\n", $1, $2 + } + END {}' + ;; + + --as-error-line ) + + # Build the error message. + cli_printMessage "${TCAR_SCRIPT_COMMAND} ($(cli_printCaller 1)): ${MESSAGE}" --as-stderr-line + cli_printMessage "${MODULE_NAME}" --as-toknowmore-line + + # Finish script execution with exit status 1 (SIGHUP) to + # imply the script finished because an error. We are + # using this as convention to finish the script execution. + # So, don't remove the following line, please. + exit 1 + ;; + + --as-suggestion-line ) + + # Build the error message. + cli_printMessage "${TCAR_SCRIPT_COMMAND} ($(cli_printCaller 1)):" --as-stderr-line + cli_printMessage "`gettext "The path provided cannot be processed the way you entered it."`" --as-stderr-line + cli_printMessage "`gettext "Instead, try the following equivalence:"` ${MESSAGE}" --as-stderr-line + cli_printMessage "${MODULE_NAME}" --as-toknowmore-line + + # Finish script execution with exit status 1 (SIGHUP) to + # imply the script finished because an error. We are + # using this as convention to finish the script execution. + # So, don't remove the following line, please. + exit 1 + ;; + + --as-toknowmore-line ) + cli_printMessage "`gettext "To know more, run"` ${TCAR_SCRIPT_COMMAND} ${MESSAGE} --help" --as-stderr-line + ;; + + --as-yesornorequest-line ) + + # Define positive answer. + local Y="`gettext "yes"`" + + # Define negative answer. + local N="`gettext "no"`" + + # Define default answer. + local ANSWER=${N} + + if [[ ${TCAR_FLAG_YES} == 'true' ]];then + + ANSWER=${Y} + + else + + # Print the question to standard error. + cli_printMessage "${MESSAGE} [${Y}/${N}]" --as-request-line + + # Redefine default answer based on user's input. + read ANSWER + + fi + + # Verify user's answer. Only positive answer let the + # script flow to continue. Otherwise, if something + # different from positive answer is passed, the script + # terminates its execution immediately. + if [[ ! ${ANSWER} =~ "^${Y}" ]];then + exit + fi + ;; + + --as-selection-line ) + # Create selection based on message. + local NAME='' + select NAME in ${MESSAGE};do + echo ${NAME} + break + done + ;; + + --as-response-line ) + cli_printMessage "--> ${MESSAGE}" --as-stderr-line + ;; + + --as-request-line ) + cli_printMessage "${MESSAGE}:\040" --as-notrailingnew-line + ;; + + --as-notrailingnew-line ) + echo -e -n "${MESSAGE}" | sed -r \ + -e "s!${TCAR_BASEDIR}/!!g" 1>&2 + ;; + + --as-stderr-line ) + echo "${MESSAGE}" | sed -r \ + -e "s!${TCAR_BASEDIR}/!!g" 1>&2 + ;; + + esac + + # Verify verbose option. The verbose option controls whether + # messages are printed or not. + if [[ "${TCAR_FLAG_QUIET}" == 'true' ]];then + return + fi + + # Print messages that will be printed only when the TCAR_FLAG_QUIET + # variable is provided to centos-art.sh script. + case "${FORMAT}" in + + --as-separator-line ) + + # Build the separator line. + MESSAGE=$(\ + until [[ ${MESSAGE_WIDTH} -eq 0 ]];do + echo -n "$(echo ${MESSAGE} | sed -r 's!(.).*!\1!')" + MESSAGE_WIDTH=$((${MESSAGE_WIDTH} - 1)) + done) + + # Draw the separator line. + echo "${MESSAGE}" + ;; + + --as-banner-line ) + cli_printMessage '-' --as-separator-line + cli_printMessage "${MESSAGE}" --as-stdout-line + cli_printMessage '-' --as-separator-line + ;; + + --as-processing-line ) + cli_printMessage "`gettext "Processing"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-cropping-line ) + cli_printMessage "`gettext "Cropping from"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-tuningup-line ) + cli_printMessage "`gettext "Tuning-up"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-checking-line ) + cli_printMessage "`gettext "Checking"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-combining-line ) + cli_printMessage "`gettext "Combining"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-creating-line | --as-updating-line ) + if [[ -a "${MESSAGE}" ]];then + cli_printMessage "`gettext "Updating"`: ${MESSAGE}" --as-stdout-line + else + cli_printMessage "`gettext "Creating"`: ${MESSAGE}" --as-stdout-line + fi + ;; + + --as-deleting-line ) + cli_printMessage "`gettext "Deleting"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-reading-line ) + cli_printMessage "`gettext "Reading"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-savedas-line ) + cli_printMessage "`gettext "Saved as"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-linkto-line ) + cli_printMessage "`gettext "Linked to"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-movedto-line ) + cli_printMessage "`gettext "Moved to"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-translation-line ) + cli_printMessage "`gettext "Translation"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-translating-line ) + cli_printMessage "`gettext "Translating"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-validating-line ) + cli_printMessage "`gettext "Validating"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-template-line ) + cli_printMessage "`gettext "Template"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-configuration-line ) + cli_printMessage "`gettext "Configuration"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-palette-line ) + cli_printMessage "`gettext "Palette"`: ${MESSAGE}" --as-stdout-line + ;; + + --as-inkscape-line ) + cli_printMessage "${MESSAGE}" --as-stdout-line + ;; + + esac + +} diff --git a/Automation/Scripts/cli_printUrl.sh b/Automation/Scripts/cli_printUrl.sh new file mode 100755 index 0000000..40c8d78 --- /dev/null +++ b/Automation/Scripts/cli_printUrl.sh @@ -0,0 +1,151 @@ +#!/bin/bash +###################################################################### +# +# cli_printUrl.sh -- This function standardizes the way URLs are +# printed by centos-art.sh script. This function describes the +# domain organization of The CentOS Project through its URLs and +# provides a way to print them out when needed. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printUrl { + + local URL='' + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='domain,home,lists,wiki,forums,bugs,planet,docs,mirrors,projects,svn,trac,irc,cc-sharealike,with-locale,as-html-link' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. Doing this is very important to + # avoid any clash with higher execution environments. + local TCAR_ARGUMENTS='' + + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" + + # Redefine positional parameters using TCAR_ARGUMENTS variable. + eval set -- "${TCAR_ARGUMENTS}" + + # Look for options passed through command-line. + while true; do + case "${1}" in + + --domain ) + URL="${TCAR_BRAND}.org" + shift 1 + ;; + + --home ) + URL="http://www.$(cli_printUrl --domain)/" + shift 1 + ;; + + --lists ) + URL="http://lists.$(cli_printUrl --domain)/" + shift 1 + ;; + + --wiki ) + URL="http://wiki.$(cli_printUrl --domain)/" + shift 1 + ;; + + --forums ) + URL="http://forums.$(cli_printUrl --domain)/" + shift 1 + ;; + + --bugs ) + URL="http://bugs.$(cli_printUrl --domain)/" + shift 1 + ;; + + --projects ) + URL="https://projects.$(cli_printUrl --domain)/" + shift 1 + ;; + + --svn ) + URL="$(cli_printUrl --projects)svn/" + shift 1 + ;; + + --trac ) + URL="$(cli_printUrl --projects)trac/" + shift 1 + ;; + + --planet ) + URL="http://planet.$(cli_printUrl --domain)/" + shift 1 + ;; + + --docs ) + URL="http://docs.$(cli_printUrl --domain)/" + shift 1 + ;; + + --mirrors ) + URL="http://mirrors.$(cli_printUrl --domain)/" + shift 1 + ;; + + --irc ) + URL="http://$(cli_printUrl --home)modules/tinycontent/index.php?id=8" + shift 1 + ;; + + --cc-sharealike ) + URL="http://creativecommons.org/licenses/by-sa/3.0/" + shift 1 + ;; + + --with-locale ) + if [[ ! ${LANG} =~ '^en' ]];then + URL="${URL}${TCAR_SCRIPT_LANG_LL}/" + fi + shift 1 + ;; + + --as-html-link ) + URL="${URL}" + shift 1 + ;; + + -- ) + + shift 1 + break + ;; + esac + done + + # Print Url. + echo "${URL}" + +} diff --git a/Automation/Scripts/cli_printVersion.sh b/Automation/Scripts/cli_printVersion.sh new file mode 100755 index 0000000..0bf3592 --- /dev/null +++ b/Automation/Scripts/cli_printVersion.sh @@ -0,0 +1,34 @@ +#!/bin/bash +###################################################################### +# +# cli_printVersion.sh -- This function standardizes the way +# centos-art.sh script prints version about itself. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_printVersion { + + cli_printMessage "`eval_gettext "Running module $MODULE_NAME (v$MODULE_VERSION) through $TCAR_SCRIPT_NAME (v$TCAR_SCRIPT_VERSION)."`" --as-stdout-line + exit 0 + +} diff --git a/Automation/Scripts/cli_runFnEnvironment.sh b/Automation/Scripts/cli_runFnEnvironment.sh new file mode 100755 index 0000000..3fe5fe2 --- /dev/null +++ b/Automation/Scripts/cli_runFnEnvironment.sh @@ -0,0 +1,44 @@ +#!/bin/bash +###################################################################### +# +# cli_runFnEnvironment.sh -- This function standardizes the way +# centos-art.sh script is called to itself. The main purpose of this +# somehow own interface is to control the parent script flow based +# on specific function environments exit status. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_runFnEnvironment { + + # Execute specific function environment. + ${MODULE_NAME} ${@} + + # Retrieve exit status. + local STATUS=$? + + # Finish script execution based on exit status. + if [[ ${STATUS} -ne 0 ]];then + exit ${STATUS} + fi + +} diff --git a/Automation/Scripts/cli_setArguments.sh b/Automation/Scripts/cli_setArguments.sh new file mode 100755 index 0000000..474da4b --- /dev/null +++ b/Automation/Scripts/cli_setArguments.sh @@ -0,0 +1,101 @@ +#!/bin/bash +###################################################################### +# +# cli_setArguments.sh -- This function uses getopt to process +# arguments passed to centos-art.sh script. +# +# This function works with the following three variables: +# +# ARGSS +# Stores getopt short arguments definition. +# +# ARGSL +# Stores getopt long arguments definition. +# +# TCAR_ARGUMENTS +# Stores arguments passed to functions or command-line +# interface depending the context it is defined. +# +# These three variables are not defined in this function but the +# function environment you want to provide option parsing for, +# through getopt command. Using local definition for these three +# variables let you to nest option parsing inside different +# function-environment levels. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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 +# +###################################################################### + +function cli_setArguments { + + # Verify existence of arguments that will be processed. If there + # is none, return to caller. + if [[ -z "${@}" ]];then + return + fi + + local ARGUMENT='' + + # Fill up arguments global variable with current positional + # parameter information. To avoid interpretation problems, use + # single quotes to enclose each argument (TCAR_ARGUMENTS) from + # command-line individually. + for ARGUMENT in "${@}"; do + + # Remove any single quote from arguments passed to + # centos-art.sh script. We will use single quotes for grouping + # option values so white space can be passed through them. + ARGUMENT=$(echo "${ARGUMENT}" | tr -d "'") + + # Concatenate arguments and enclose them to let getopt to + # process them when they have spaces inside. + TCAR_ARGUMENTS="${TCAR_ARGUMENTS} '${ARGUMENT}'" + + done + + # Verify non-option arguments passed to command-line. If there + # isn't any or dot is provided, redefine the TCAR_ARGUMENTS + # variable to use the current location the centos-art.sh script + # was called from. + if [[ -z "${TCAR_ARGUMENTS}" ]];then + TCAR_ARGUMENTS=${PWD} + fi + + # Verify presence of either short or long options in the + # environment. If they are present apply option validation through + # getopt. + if [[ ! -z ${ARGSS} ]] || [[ ! -z ${ARGSL} ]];then + + # Redefine positional parameters using TCAR_ARGUMENTS variable. + eval set -- "${TCAR_ARGUMENTS}" + + # Process positional parameters using getopt's option validation. + TCAR_ARGUMENTS=$(getopt -o "${ARGSS}" -l "${ARGSL}" \ + -n "${TCAR_SCRIPT_COMMAND} (${MODULE_NAME})" -- "${@}") + + # Verify getopt's exit status and finish the script execution + # with an error message, if it failed. + if [[ $? -ne 0 ]];then + cli_printMessage "`gettext "The argument verification failed."`" --as-error-line + fi + + fi + +} diff --git a/Automation/Scripts/cli_synchronizeRepoChanges.sh b/Automation/Scripts/cli_synchronizeRepoChanges.sh new file mode 100755 index 0000000..0f04ad3 --- /dev/null +++ b/Automation/Scripts/cli_synchronizeRepoChanges.sh @@ -0,0 +1,44 @@ +#!/bin/bash +###################################################################### +# +# cli_synchronizeRepoChanges.sh -- This function standardizes the +# way changes are synchronized between the working copy and the +# central repository. This function is an interface to the Svn +# functionality of the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_synchronizeRepoChanges { + + # Verify synchronization flag. + if [[ ${FLAG_SYNCHRONIZE} != 'true' ]];then + return + fi + + # Verify existence of locations passed to this function. + cli_checkFiles -e ${@} + + # Synchronize changes. + cli_runFnEnvironment vcs --synchronize ${@} + +} diff --git a/Automation/Scripts/cli_terminateScriptExecution.sh b/Automation/Scripts/cli_terminateScriptExecution.sh new file mode 100755 index 0000000..2e3daa5 --- /dev/null +++ b/Automation/Scripts/cli_terminateScriptExecution.sh @@ -0,0 +1,41 @@ +#!/bin/bash +###################################################################### +# +# cli_terminateScriptExecution.sh -- This function standardizes the +# actions that must be realized just before leaving the script +# execution (e.g., cleaning temporal files). This function is the +# one called when interruption signals like EXIT, SIGHUP, SIGINT and +# SIGTERM are detected. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_terminateScriptExecution { + + # Remove temporal directory. + rm -r ${TCAR_SCRIPT_TEMPDIR} + + # NOTE: Don't specify an exit status here. As convenction we do + # this when error messages are triggerd. See `--as-error-line' + # option from `cli_printMessage' functionality. + +} diff --git a/Automation/Scripts/cli_unsetFunctions.sh b/Automation/Scripts/cli_unsetFunctions.sh new file mode 100755 index 0000000..d1346d7 --- /dev/null +++ b/Automation/Scripts/cli_unsetFunctions.sh @@ -0,0 +1,53 @@ +#!/bin/bash +###################################################################### +# +# cli_unsetFunctions.sh -- This function unsets functionalities from +# centos-art.sh script execution environment. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function cli_unsetFunctions { + + # Define export id used to retrieve function files. This is the + # same export id used to export functions without the directory + # part. + local FUNCTION_EXPORTID=$(basename "${1}") + + # Verify suffix value used to retrieve function files. + if [[ ${FUNCTION_EXPORTID} == '' ]];then + cli_printMessage "`gettext "The export id was not provided."`" --as-error-line + fi + + # Define list of format-specific functionalities. This is the + # list of function definitions previously exported by + # `cli_exportFunctions'. Be sure to limit the list to function + # names that start with the suffix specified only. + local FUNCTION_DEF='' + local FUNCTION_DEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${FUNCTION_EXPORTID}") + + # Unset function names from current execution environment. + for FUNCTION_DEF in ${FUNCTION_DEFS};do + unset -f ${FUNCTION_DEF} + done + +} diff --git a/Automation/centos-art.asciidoc b/Automation/centos-art.asciidoc index 6d0e2bf..202d5a5 100644 --- a/Automation/centos-art.asciidoc +++ b/Automation/centos-art.asciidoc @@ -28,19 +28,22 @@ repository. When you execute the *centos-art.sh* script in a terminal, it will request the absolute path where you stored your working copy of CentOS artwork repository. To avoid the absolute path request every time you -execute the script, you can edit the +~/.bash_profile+ file and set -the absolute path to your working copy there, as value to +execute the script, you can edit the +~/.bash_profile+ file and +declare the absolute path to your working copy there, as value to TCAR_BASEDIR variable. -Once *centos-art.sh* script knows what is the absolute path to your -working copy, it executes the file *centos-art.conf* to load default -values to configuration variables into its execution environment. -After configuration variables have been loaded in the execution -environment, the script looks whether or not any option was passed as -first argument to *centos-art.sh* script. If no option was passed, it -gives control to *cli* module. At this point, the *centos-art.sh* -script waits for modules to conclude their job and exit the script -execution as described in the xref:exit[] section. +Once *centos-art.sh* script knows what the absolute path to your +working copy is, it executes the file *centos-art.conf* to load +default values to configuration variables into its execution +environment. After configuration variables have been loaded in the +execution environment, the script looks for supported options in the +first argument. If the options passed are recognized the script +process them. If the options aren't recognized or no option is passed +at all, the *centos-art.sh* script exports common functions and +executes the module specified as first argument, assuming the first +argument is a valid module name of course. Finally, the +*centos-art.sh* script waits for the module script to conclude its job +and exits the as described in the xref:exit[] section. anchor:exit[Exit Status] @@ -56,21 +59,12 @@ Modules From version 0.5 on, *centos-art.sh* script introduces the idea of modules to its base design. Modules are individual execution environments that may nest themselves one inside another to achieve -high levels of code maintainability. Modules make it possible to -divide a big task into smaller tasks that can be easier to debug, -maintain and share with other modules. +high levels maintainability. Modules make it possible to divide a big +task into smaller tasks that can be easier to debug, maintain and +share with other modules. The following modules are available for *centos-art.sh* script: -*cli*:: - This modules initializes common and specific functions inside - *centos-art.sh* script execution environment. This module is - loaded internally when you execute the *centos-art.sh* script in a - terminal and you probably don't need to execute it in a terminal - unless you want to see help or version information about it. This - module interprets arguments passed to *centos-art.sh* command-line - to execute the associated module (a.k.a., specific functions). - *prepare*:: This module standardizes configuration tasks needed by your working copy (e.g., creation of links, images and documentations). @@ -124,40 +118,41 @@ stored in the directory +Automation/Modules+. This directory contains module's documentation produced by *help* module. The structure of this directory looks as follow: + -------------------------------------- +---------------------------------------------------------------------- Manuals/ |-- ${LANG}/ | |-- man${SECTION_NUMBER} | `-- ${MODULE_NAME}.${SECTION_NUMBER} `-- man${SECTION_NUMBER} `-- ${MODULE_NAME}.${SECTION_NUMBER} -------------------------------------- +---------------------------------------------------------------------- *Locales/*:: This directory contains module's translations produced by *locale* module. The structure of this directory looks as follow: + -------------------------------------- +---------------------------------------------------------------------- Locales/ `-- ${LANG}/ |-- LC_MESSAGES - | `-- ${MODULE_NAME}.sh.mo + | |-- ${MODULE_NAME}.sh.mo + | `-- ${MODULE_NAME}.docbook.mo |-- ${MODULE_NAME}.sh.po |-- ${MODULE_NAME}.sh.pot - |-- ${MODULE_NAME}.xml.po - `-- ${MODULE_NAME}.xml.pot -------------------------------------- + |-- ${MODULE_NAME}.docbook.po + `-- ${MODULE_NAME}.docbook.pot +---------------------------------------------------------------------- *Scripts/*:: This directory contains function scripts written by module's - writers. Here is where all the tasks the module is useful to are - written and organized. As convention the following structure is + writers. Here is where all the tasks the module is useful for are + written and stored in. As convention the following structure is used: + -------------------------------------- +---------------------------------------------------------------------- Scripts/ `-- ${MODULE_NAME}_${FUNCTION_NAME}.sh -------------------------------------- +---------------------------------------------------------------------- + {asccidoc-br} + @@ -167,9 +162,9 @@ does, as well as author and copying information. After the top comment and separated by one white line, you should define the function sentence using the long format. + -------------------------------------- +---------------------------------------------------------------------- #!/bin/bash -######################################################################## +###################################################################### # # ${MODULE_NAME}_${FUNCTION_NAME}.sh -- ${FUNCTION_DESCRIPTION} # @@ -180,8 +175,8 @@ sentence using the long format. # # 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. +# 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 @@ -192,12 +187,12 @@ sentence using the long format. # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -######################################################################## +###################################################################### function ${MODULE_NAME}_${FUNCTION_NAME} { ... } -------------------------------------- +---------------------------------------------------------------------- + [NOTE] If your are planning to contribute a new module to *centos-art.sh* @@ -229,12 +224,6 @@ variable. this file only but, frequently, it is convenient as the module complexity grows to divide it in smaller pieces (function scripts) to improve maintainability and error findings. -*$\{MODULE_NAME}.xml*:: - This file is produced from *$\{MODULE_NAME}.asciidoc* and is used as - source to retrieve translatable strings. Translatable strings - retrieved from this file are stored in the module's *Locales/* - directory and used to produce localized mapages inside module's - *Manuals/$\{LANG}/man$\{SECTION_NUMBER}/* directory. Options ------- @@ -245,10 +234,14 @@ Options *--version*:: Display program's name and version. +Bugs +---- +The module *pack* isn't implemented yet. + Reporting Bugs -------------- -Report bugs on the *automation* category of *centos-artwork* project -at the https://centos.org.cu/bugs/[The CentOS Bugs] website. +Report bugs inside the *automation* category of *centos-artwork* +project, at the https://centos.org.cu/bugs/[The CentOS Bugs] website. Author ------ diff --git a/Automation/centos-art.conf b/Automation/centos-art.conf index f035829..8bbe1b8 100755 --- a/Automation/centos-art.conf +++ b/Automation/centos-art.conf @@ -41,22 +41,10 @@ declare -x TCAR_SCRIPT_COMMAND="centos-art" # Set the script version. # declare -x TCAR_SCRIPT_VERSION='0.5' - -# -------------------------------------------------------------------- -# Command-line interface (read-only) configuration variables. -# -------------------------------------------------------------------- -# -# Set the script initialization module's name. -# -declare -xr TCAR_SCRIPT_INIT=cli -# -# Set the script initialization module's directory. -# -declare -xr TCAR_SCRIPT_INIT_DIR=${TCAR_SCRIPT_BASEDIR}/Modules/Cli # -# Set the script initialization module's file. +# Set the script modules directory. # -declare -xr TCAR_SCRIPT_INIT_FILE=${TCAR_SCRIPT_INIT_DIR}/${TCAR_SCRIPT_INIT}.sh +declare -x TCAR_SCRIPT_MODULES_BASEDIR=${TCAR_SCRIPT_BASEDIR}/Modules # # Set the script temporal directory. # diff --git a/Automation/centos-art.sh b/Automation/centos-art.sh index 44c0ee3..34d494b 100755 --- a/Automation/centos-art.sh +++ b/Automation/centos-art.sh @@ -58,25 +58,42 @@ fi case ${1} in --help ) - # Print script help. + # Print script's help. ${TCAR_MANUAL_READER} ${TCAR_SCRIPT_NAME} ;; --version ) - # Print script version. + # Print script's name and version. echo "`eval_gettext "Running $TCAR_SCRIPT_NAME (v$TCAR_SCRIPT_VERSION)."`" ;; * ) - # Initialize script command-line interface. - if [[ -x ${TCAR_SCRIPT_INIT_FILE} ]];then - . ${TCAR_SCRIPT_INIT_FILE} \ - && export -f ${TCAR_SCRIPT_INIT} \ - && ${TCAR_SCRIPT_INIT} "$@" - else - echo "${TCAR_SCRIPT_INIT_FILE} `gettext "has not execution rights."`" - fi + + # Export script's environment functions. + for SCRIPT_FILE in $(ls ${TCAR_SCRIPT_BASEDIR}/Scripts/*.sh);do + if [[ -x ${SCRIPT_FILE} ]];then + . ${SCRIPT_FILE} + export -f $(grep '^function ' ${SCRIPT_FILE} | cut -d' ' -f2) + else + echo "${SCRIPT_FILE} `gettext "has not execution rights."`" + fi + done + + # Trap signals in order to terminate the script execution + # correctly (e.g., removing all temporal files before + # leaving). Trapping the exit signal seems to be enough by + # now, since it is always present as part of the script + # execution flow. Each time the centos-art.sh script is + # executed it will inevitably end with an EXIT signal at some + # point of its execution, even if it is interrupted in the + # middle of its execution (e.g., through `Ctrl+C'). + trap cli_terminateScriptExecution 0 + + # Export script's module environment. + cli_initModule "${@}" + ;; + esac exit 0