From 9cdada76ea418cfc450552e1135435fb60792ede Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 14 2012 14:08:09 +0000 Subject: Update directory structure to support Commons functionalities. - Create `Functions/Commons' directory. - Rename `cli.sh' to `init.sh'. - Move all `Functions/cli_*.sh' files into Functions/Commons/ directory. This will let us to work the same functionalities from different scripts (i.e. It is possible to work in one unique function file from different working copies.). This is very useful because it eliminates code duplications. - Update `centos-art.sh' file to reflect location changes. --- diff --git a/Scripts/Bash/Functions/Commons/cli_checkFiles.sh b/Scripts/Bash/Functions/Commons/cli_checkFiles.sh new file mode 100755 index 0000000..56df0bb --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_checkFiles.sh @@ -0,0 +1,157 @@ +#!/bin/bash +# +# cli_checkFiles.sh -- This function standardizes the way file +# conditional expressions are applied inside centos-art.sh script. +# Here is where we answer 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 ends its +# execution. +# +# More than one file can be passed to this function, so we want to +# process them all as specified by the options. Since we are using +# getopt output it is possible to determine where options and +# non-option arguments are in the list of arguments (e.g., options +# are on the left side of ` -- ' and non-options on the rigth side of +# ` -- '). Non-options are the files we want to verify and options how +# we want to verify them. +# +# Another issue to consider, when more than one file is passed to this +# function, is that we cannot shift positional parameters as we +# frequently do whe just one argument is passsed, doing so would +# annulate the validation for the second and later files passed to the +# function. So, in order to provide verification to all files passed +# to the function, the verification loop must be set individual for +# each option in this function. +# +# Assuming no option be passed to the function, a general verification +# is performed to determine whether or not the file exists without +# considering the file type just its existence. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkFiles { + + # Define short options. + local ARGSS='d,r,h,n,x,w' + + # Define long options. + local ARGSL='directory,regular-file,symbolic-link,execution,versioned,working-copy' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize file variable as local to avoid conflicts outside + # this function scope. In the file variable will set the file path + # we'r going to verify. + local FILE='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Define list of files we want to apply verifications to. + local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') + + # Verify files in the list. It is required at least one. + if [[ $FILES =~ '--$' ]];then + cli_printMessage "You need to provide one file at least." --as-error-line + fi + + # Look for options passed through positional parameters. + while true; do + + case "$1" in + + -d|--directory ) + for FILE in $(echo $FILES);do + if [[ ! -d $FILE ]];then + cli_printMessage "`eval_gettext "The directory \\\"\\\$FILE\\\" does not exist."`" --as-error-line + fi + done + shift 1 + ;; + + -f|--regular-file ) + for FILE in $(echo $FILES);do + if [[ ! -f $FILE ]];then + cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" --as-error-line + fi + done + shift 1 + ;; + + -h|--symbolic-link ) + for FILE in $(echo $FILES);do + if [[ ! -h $FILE ]];then + cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" --as-error-line + fi + done + shift 1 + ;; + + -n|--versioned ) + for FILE in $(echo $FILES);do + if [[ $(cli_isVersioned $FILE) == 'false' ]];then + cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" is not versioned."`" --as-error-line + fi + done + shift 1 + ;; + + -x|--execution ) + for FILE in $(echo $FILES);do + if [[ ! -x $FILE ]];then + cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" --as-error-line + fi + done + shift 1 + ;; + + -w|--working-copy ) + for FILE in $(echo $FILES);do + if [[ ! $FILE =~ "^${CLI_WRKCOPY}/.+$" ]];then + cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist inside the working copy."`" --as-error-line + fi + done + shift 1 + ;; + + -- ) + for FILE in $(echo $FILES);do + if [[ ! -a $FILE ]];then + cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist."`" --as-error-line + fi + done + shift 1 + break + ;; + + esac + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_checkPathComponent.sh b/Scripts/Bash/Functions/Commons/cli_checkPathComponent.sh new file mode 100755 index 0000000..182850a --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_checkPathComponent.sh @@ -0,0 +1,111 @@ +#!/bin/bash +# +# cli_checkPathComponent.sh -- This function checks parts/components +# from repository paths. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkPathComponent { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='release,architecture,motif' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize file variable as local to avoid conflicts outside + # this function scope. In the file variable will set the file path + # we are going to verify. + local FILE='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Define list of locations we want to apply verifications to. + local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') + + # Verify list of locations, it is required that one location be + # present in the list and also be a valid file. + if [[ $FILES == '--' ]];then + cli_printMessage "You need to provide one file at least." --as-error-line + fi + + # Look for options passed through positional parameters. + while true; do + + case "$1" in + + --release ) + for FILE in $(echo $FILES);do + if [[ ! $FILE =~ "^.+/$(cli_getPathComponent --release-pattern)/.*$" ]];then + cli_printMessage "`eval_gettext "The release \\\"\\\$FILE\\\" is not valid."`" --as-error-line + fi + done + shift 2 + break + ;; + + --architecture ) + for FILE in $(echo $FILES);do + if [[ ! $FILE =~ $(cli_getPathComponent --architecture-pattern) ]];then + cli_printMessage "`eval_gettext "The architecture \\\"\\\$FILE\\\" is not valid."`" --as-error-line + fi + done + shift 2 + break + ;; + + --motif ) + for FILE in $(echo $FILES);do + if [[ ! $FILE =~ $(cli_getPathComponent --motif-pattern) ]];then + cli_printMessage "`eval_gettext "The theme \\\"\\\$FILE\\\" is not valid."`" --as-error-line + fi + done + shift 2 + break + ;; + + -- ) + for FILE in $(echo $FILES);do + if [[ $FILE == '' ]] \ + || [[ $FILE =~ '(\.\.(/)?)' ]] \ + || [[ ! $FILE =~ '^[A-Za-z0-9\.:/_-]+$' ]]; then + cli_printMessage "`eval_gettext "The value \\\"\\\$FILE\\\" is not valid."`" --as-error-line + fi + done + shift 2 + break + ;; + + esac + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh new file mode 100755 index 0000000..7090848 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# +# cli_checkRepoDirSource.sh -- This function provides input validation +# to repository entries considered as source locations. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkRepoDirSource { + + + # Define location in order to make this function reusable not just + # for action value variable but whatever value passed as first + # positional argument. + local LOCATION=$1 + + # Verify location. Assuming no location is passed as first + # positional parameter to this function, print an error message + # and stop script execution. + if [[ "$LOCATION" == '' ]];then + cli_printMessage "`gettext "The first positional parameter is required."`" --as-error-line + fi + + # Check action value to be sure strange characters are kept far + # away from path provided. + cli_checkPathComponent $LOCATION + + # Redefine source value to build repository absolute path from + # repository top level on. As we are removing + # /home/centos/artwork/ from all centos-art.sh output (in order to + # save horizontal output space), we need to be sure that all + # strings begining with trunk/..., branches/..., and tags/... use + # the correct absolute path. That is, you can refer trunk's + # entries using both /home/centos/artwork/trunk/... or just + # trunk/..., the /home/centos/artwork/ part is automatically added + # here. + if [[ $LOCATION =~ '^(trunk|branches|tags)' ]];then + LOCATION=${CLI_WRKCOPY}/$LOCATION + fi + + # Re-define source value to build repository absolute path from + # repository relative paths. This let us to pass repository + # relative paths as source value. Passing relative paths as + # source value may save us some typing; specially if we are stood + # a few levels up from the location we want to refer to as source + # value. There is no need to pass the absolute path to it, just + # refere it relatively. + if [[ -d ${LOCATION} ]];then + + # Add directory to the top of the directory stack. + pushd "$LOCATION" > /dev/null + + # Check directory existence inside the repository. + if [[ $(pwd) =~ "^${CLI_WRKCOPY}" ]];then + # Re-define source value using absolute path. + LOCATION=$(pwd) + else + cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line + fi + + # Remove directory from the directory stack. + popd > /dev/null + + elif [[ -f ${LOCATION} ]];then + + # Add directory to the top of the directory stack. + pushd "$(dirname "$LOCATION")" > /dev/null + + # Check directory existence inside the repository. + if [[ $(pwd) =~ "^${CLI_WRKCOPY}" ]];then + # Re-define source value using absolute path. + LOCATION=$(pwd)/$(basename "$LOCATION") + else + cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line + fi + + # Remove directory from the directory stack. + popd > /dev/null + + fi + + # Output sanitated location. + echo $LOCATION + +} diff --git a/Scripts/Bash/Functions/Commons/cli_checkRepoDirTarget.sh b/Scripts/Bash/Functions/Commons/cli_checkRepoDirTarget.sh new file mode 100755 index 0000000..b688c12 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_checkRepoDirTarget.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# cli_checkRepoDirTarget.sh -- This function provides input validation +# to repository entries considered as target location. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkRepoDirTarget { + + local LOCATION="$1" + + # Redefine target value to build repository absolute path from + # repository top level on. As we are removing + # /home/centos/artwork/ from all centos-art.sh output (in order to + # save horizontal output space), we need to be sure that all + # strings begining with trunk/..., branches/..., and tags/... use + # the correct absolute path. That is, you can refer trunk's + # entries using both /home/centos/artwork/trunk/... or just + # trunk/..., the /home/centos/artwork/ part is automatically added + # here. + if [[ $LOCATION =~ '^(trunk|branches|tags)/.+$' ]];then + LOCATION=${CLI_WRKCOPY}/$LOCATION + fi + + # Print target location. + echo $LOCATION + +} diff --git a/Scripts/Bash/Functions/Commons/cli_commitRepoChanges.sh b/Scripts/Bash/Functions/Commons/cli_commitRepoChanges.sh new file mode 100755 index 0000000..e3a7dc9 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_commitRepoChanges.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# +# cli_commitRepoChanges.sh -- This function realizes a subversion +# commit command agains the workgin copy in order to send local +# changes up to central repository. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_commitRepoChanges { + + # Verify `--dont-commit-changes' option. + if [[ $FLAG_DONT_COMMIT_CHANGES == 'true' ]];then + return + fi + + local -a FILES + local -a INFO + local -a FILESNUM + local COUNT=0 + local STATUSOUT='' + local PREDICATE='' + local CHNGTOTAL=0 + local LOCATIONS='' + local LOCATION='' + + # Define source location the subversion status action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Print action message. + cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line + + # Build list of files that have received changes in its versioned + # status. Be sure to keep output files off from this list. + # Remember, output files are not versioned inside the working + # copy, so they are not considered for evaluation here. But take + # care, sometimes output files are in the same format of source + # files, so we need to differentiate them using their locations. + for LOCATION in $LOCATIONS;do + + # Don't process location outside of version control. + if [[ $(cli_isVersioned $LOCATION) == 'false' ]];then + continue + fi + + # Process location based on its path information. + if [[ $LOCATION =~ '(trunk/Manuals/Tcar-fs|branches/Manuals/Texinfo)' ]];then + STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|txt|xhtml|xml|docbook|bz2)$')\n$STATUSOUT" + elif [[ $LOCATION =~ 'trunk/Manuals' ]];then + STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|txt|xhtml)$')\n$STATUSOUT" + elif [[ $LOCATION =~ 'trunk/Identity' ]];then + STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|png|jpg|rc|xpm|xbm|tif|ppm|pnm|gz|lss|log)$')\n$STATUSOUT" + else + STATUSOUT="$(svn status ${LOCATION})\n$STATUSOUT" + fi + + done + + # Sanitate status output. Expand new lines, remove leading spaces + # and empty lines. + STATUSOUT=$(echo -e "$STATUSOUT" | sed -r 's!^[[:space:]]*!!' | egrep -v '^[[:space:]]*$') + + # Define path fo files considered recent modifications from + # working copy up to central repository. + FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + + # Define description of files considered recent modifications from + # working copy up to central repository. + INFO[0]="`gettext "Modified"`" + INFO[1]="`gettext "Unversioned"`" + INFO[2]="`gettext "Deleted"`" + INFO[3]="`gettext "Added"`" + + while [[ $COUNT -ne ${#FILES[*]} ]];do + + # Define total number of files. Avoid counting empty line. + if [[ "${FILES[$COUNT]}" == '' ]];then + FILESNUM[$COUNT]=0 + else + FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) + fi + + # Calculate total amount of changes. + CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) + + # Build report predicate. Use report predicate to show any + # information specific to the number of files found. For + # example, you can use this section to show warning messages, + # notes, and so on. By default we use the word `file' or + # `files' at ngettext's consideration followed by change + # direction. + PREDICATE[$COUNT]=`ngettext "file in the working copy" \ + "files in the working copy" $((${FILESNUM[$COUNT]} + 1))` + + # Output report line. + cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # Check total amount of changes and, if any, check differences and + # commit them up to central repository. + if [[ $CHNGTOTAL -gt 0 ]];then + + # Outout separator line. + cli_printMessage '-' --as-separator-line + + # In the very specific case unversioned files, we need to add + # them to the repository first, in order to make them + # available for subversion commands (e.g., `copy') Otherwise, + # if no unversioned file is found, go ahead with change + # differences and committing. Notice that if there is mix of + # changes (e.g., aditions and modifications), addition take + # preference and no other change is considered. In order + # for other changes to be considered, be sure no adition is + # present, or that they have already happened. + if [[ ${FILESNUM[1]} -gt 0 ]];then + + cli_printMessage "`ngettext "The following file is unversioned" \ + "The following files are unversioned" ${FILESNUM[1]}`:" + for FILE in ${FILES[1]};do + cli_printMessage "$FILE" --as-response-line + done + cli_printMessage "`ngettext "Do you want to add it now?" \ + "Do you want to add them now?" ${FILESNUM[1]}`" --as-yesornorequest-line + svn add ${FILES[1]} --quiet + + else + + # Verify changes on locations. + cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line + svn diff $LOCATIONS | less + + # Commit changes on locations. + cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line + svn commit $LOCATIONS + + fi + + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_expandTMarkers.sh b/Scripts/Bash/Functions/Commons/cli_expandTMarkers.sh new file mode 100755 index 0000000..1bf6c1d --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_expandTMarkers.sh @@ -0,0 +1,175 @@ +#!/bin/bash +# +# cli_expandTMarkers.sh -- This function standardizes +# replacements for common translation markers. Raplacements are +# applied to temporal instances used to produce the final file. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_expandTMarkers { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 + local LOCATION='' + + # Define source location on which sed replacements take place. + LOCATION="$1" + + # Verify file source location. + cli_checkFiles $LOCATION + + # Define copyright translation markers. + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LAST=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LIST=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year-list)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-holder)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-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_IRC=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--irc') + + # Define emails translation markers. + SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' + DST[((++${#DST[*]}))]="centos-docs@centos.org" + SRC[((++${#SRC[*]}))]='=MAIL_L10N=' + DST[((++${#DST[*]}))]="centos-l10n@centos.org" + + # Define locale translation markers. + SRC[((++${#SRC[*]}))]='=LOCALE_LL=' + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')" + SRC[((++${#SRC[*]}))]='=LOCALE=' + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale)" + + # Define domain translation markers for domains. + SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')." + else + DST[((++${#DST[*]}))]="" + fi + + # Define repository translation markers. + SRC[((++${#SRC[*]}))]='=REPO_TLDIR=' + DST[((++${#DST[*]}))]="$(cli_getRepoTLDir)" + SRC[((++${#SRC[*]}))]='=REPO_HOME=' + DST[((++${#DST[*]}))]="${CLI_WRKCOPY}" + + # 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 + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may ramain from one file to another. + unset SRC + unset DST + +} diff --git a/Scripts/Bash/Functions/Commons/cli_exportFunctions.sh b/Scripts/Bash/Functions/Commons/cli_exportFunctions.sh new file mode 100755 index 0000000..2a85602 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_exportFunctions.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# cli_exportFunctions.sh -- This function exports funtionalities to +# `centos-art.sh' script execution evironment. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_exportFunctions { + + # Define source location where function files are placed in. + local LOCATION=$1 + + # Define suffix used to retrive function files. + local SUFFIX=$2 + + # Verify suffix value used to retrive function files. Assuming no + # suffix value is passed as second argument to this function, use + # the function name value (CLI_FUNCNAME) as default value. + if [[ $SUFFIX == '' ]];then + SUFFIX=$CLI_FUNCNAME + fi + + # Define pattern used to retrive function names from function + # files. + local PATTERN="^function[[:space:]]+${SUFFIX}[[:alnum:]_]*[[:space:]]+{$" + + # Define list of files. + local FUNCFILE='' + local FUNCFILES=$(cli_getFilesList ${LOCATION} --pattern="${SUFFIX}.*\.sh" --maxdepth="1") + + # Verify 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 [[ $FUNCFILES == '' ]];then + cli_printMessage "`gettext "No function file was found for this action."`" --as-error-line + fi + + # Process list of files. + for FUNCFILE in $FUNCFILES;do + + # Verify file execution rights. + cli_checkFiles $FUNCFILE --execution + + # Initialize file. + . $FUNCFILE + + # Export function names inside the file to current shell + # script environment. + export -f $(egrep "${PATTERN}" ${FUNCFILE} | gawk '{ print $2 }') + + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh b/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh new file mode 100755 index 0000000..248d4cf --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# cli_getConfigLines.sh -- This function retrives configuration lines +# form configuration files. As arguments, the configuration file +# absolute path, the configuration section name, and the configuration +# variable name must be provided. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getConfigLines { + + # Initialize absolute path to configuration file. + local CONFIG_ABSPATH="$1" + + # Verify absolute path to configuration file. + cli_checkFiles ${CONFIG_ABSPATH} + + # Initialize configuration section name where the variable value + # we want to to retrive is set in. + local CONFIG_SECTION="$2" + + # Initialize variable name we want to retrive value from. + local CONFIG_VARNAME="$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 begining of the line. + if [[ ! $CONFIG_VARNAME =~ '^[[:alnum:]_./-]+$' ]];then + CONFIG_VARNAME='[[:alnum:]_./-]+=' + fi + + # Retrive configuration lines from configuration file. + local CONFIG_LINES=$(cat ${CONFIG_ABSPATH} \ + | egrep -v '^#' \ + | egrep -v '^[[:space:]]*$' \ + | sed -r 's![[:space:]]*!!g' \ + | sed -r -n "/^\[${CONFIG_SECTION}\]$/,/^\[/p" \ + | egrep -v '^\[' | sort | uniq \ + | egrep "^${CONFIG_VARNAME}") + + # Output value related to variable name. + echo "$CONFIG_LINES" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getConfigValue.sh b/Scripts/Bash/Functions/Commons/cli_getConfigValue.sh new file mode 100755 index 0000000..4b54ec6 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getConfigValue.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# cli_getConfigValue.sh -- This function retrives configuration values +# from configuration files. As arguments, the configuration file +# absolute path, the configuration section name, and the configuration +# variable name must be provided. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getConfigValue { + + # Initialize absolute path to configuration file. + local CONFIG_ABSPATH="$1" + + # Initialize configuration section name where the variable value + # we want to to retrive is set in. + local CONFIG_SECTION="$2" + + # Initialize variable name we want to retrive value from. + local CONFIG_VARNAME="$3" + + # Retrive configuration lines from configuration file. + local CONFIG_LINES=$(cli_getConfigLines \ + "$CONFIG_ABSPATH" "$CONFIG_SECTION" "$CONFIG_VARNAME") + + # Parse configuration lines to retrive the values of variable + # names. + local CONFIG_VARVALUE=$(echo $CONFIG_LINES \ + | gawk 'BEGIN { FS="=" } { print $2 }' \ + | sed -r 's/^"(.*)"$/\1/') + + # Output values related to variable name. + echo "$CONFIG_VARVALUE" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getCountryCodes.sh b/Scripts/Bash/Functions/Commons/cli_getCountryCodes.sh new file mode 100755 index 0000000..a521486 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getCountryCodes.sh @@ -0,0 +1,276 @@ +#!/bin/bash +# +# cli_getCountryCodes.sh -- This function outputs a list with country +# codes as defined in ISO3166 standard. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCountryCodes { + + local FILTER="$(echo $1 | cut -d_ -f2)" + + COUNTRYCODES='AD + AE + AF + AG + AI + AL + AM + AN + AO + AQ + AR + AS + AT + AU + AW + AZ + BA + BB + BD + BE + BF + BG + BH + BI + BJ + BM + BN + BO + BR + BS + BT + BV + BW + BY + BZ + CA + CC + CD + CF + CG + CH + CI + CK + CL + CM + CN + CO + CR + CS + CU + CV + CX + CY + CZ + DE + DJ + DK + DM + DO + DZ + EC + EE + EG + EH + ER + ES + ET + FI + FJ + FK + FM + FO + FR + GA + GB + GD + GE + GF + GH + GI + GL + GM + GN + GP + GQ + GR + GS + GT + GU + GW + GY + HK + HM + HN + HR + HT + HU + ID + IE + IL + IN + IO + IQ + IR + IS + IT + JM + JO + JP + KE + KG + KH + KI + KM + KN + KP + KR + KW + KY + KZ + LA + LB + LC + LI + LK + LR + LS + LT + LU + LV + LY + MA + MC + MD + MG + MH + MK + ML + MM + MN + MO + MP + MQ + MR + MS + MT + MU + MV + MW + MX + MY + MZ + NA + NC + NE + NF + NG + NI + NL + NO + NP + NR + NU + NZ + OM + PA + PE + PF + PG + PH + PK + PL + PM + PN + PR + PS + PT + PW + PY + QA + RE + RO + RU + RW + SA + SB + SC + SD + SE + SG + SH + SI + SJ + SK + SL + SM + SN + SO + SR + ST + SV + SY + SZ + TC + TD + TF + TG + TH + TJ + TK + TL + TM + TN + TO + TR + TT + TV + TW + TZ + UA + UG + UM + US + UY + UZ + VA + VC + VE + VG + VI + VN + VU + WF + WS + YE + YT + ZA + ZM + ZW' + + if [[ $FILTER != '' ]];then + echo $COUNTRYCODES | egrep "$FILTER" + else + echo "$COUNTRYCODES" + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getCountryName.sh b/Scripts/Bash/Functions/Commons/cli_getCountryName.sh new file mode 100755 index 0000000..0db8776 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getCountryName.sh @@ -0,0 +1,758 @@ +#!/bin/bash +# +# cli_getCountryName.sh -- This function reads one language locale +# code in the format LL_CC and outputs the name of its related +# country. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCountryName { + + local LOCALECODE="$(echo $1 | cut -d_ -f2)" + local COUNTRYNAME="" + + case $LOCALECODE in + + 'AD' ) + COUNTRYNAME="`gettext "Andorra"`" + ;; + 'AE' ) + COUNTRYNAME="`gettext "United Arab Emirates"`" + ;; + 'AF' ) + COUNTRYNAME="`gettext "Afghanistan"`" + ;; + 'AG' ) + COUNTRYNAME="`gettext "Antigua and Barbuda"`" + ;; + 'AI' ) + COUNTRYNAME="`gettext "Anguilla"`" + ;; + 'AL' ) + COUNTRYNAME="`gettext "Albania"`" + ;; + 'AM' ) + COUNTRYNAME="`gettext "Armenia"`" + ;; + 'AN' ) + COUNTRYNAME="`gettext "Netherlands Antilles"`" + ;; + 'AO' ) + COUNTRYNAME="`gettext "Angola"`" + ;; + 'AQ' ) + COUNTRYNAME="`gettext "Antarctica"`" + ;; + 'AR' ) + COUNTRYNAME="`gettext "Argentina"`" + ;; + 'AS' ) + COUNTRYNAME="`gettext "Samoa (American)"`" + ;; + 'AT' ) + COUNTRYNAME="`gettext "Austria"`" + ;; + 'AU' ) + COUNTRYNAME="`gettext "Australia"`" + ;; + 'AW' ) + COUNTRYNAME="`gettext "Aruba"`" + ;; + 'AZ' ) + COUNTRYNAME="`gettext "Azerbaijan"`" + ;; + 'BA' ) + COUNTRYNAME="`gettext "Bosnia and Herzegovina"`" + ;; + 'BB' ) + COUNTRYNAME="`gettext "Barbados"`" + ;; + 'BD' ) + COUNTRYNAME="`gettext "Bangladesh"`" + ;; + 'BE' ) + COUNTRYNAME="`gettext "Belgium"`" + ;; + 'BF' ) + COUNTRYNAME="`gettext "Burkina Faso"`" + ;; + 'BG' ) + COUNTRYNAME="`gettext "Bulgaria"`" + ;; + 'BH' ) + COUNTRYNAME="`gettext "Bahrain"`" + ;; + 'BI' ) + COUNTRYNAME="`gettext "Burundi"`" + ;; + 'BJ' ) + COUNTRYNAME="`gettext "Benin"`" + ;; + 'BM' ) + COUNTRYNAME="`gettext "Bermuda"`" + ;; + 'BN' ) + COUNTRYNAME="`gettext "Brunei"`" + ;; + 'BO' ) + COUNTRYNAME="`gettext "Bolivia"`" + ;; + 'BR' ) + COUNTRYNAME="`gettext "Brazil"`" + ;; + 'BS' ) + COUNTRYNAME="`gettext "Bahamas"`" + ;; + 'BT' ) + COUNTRYNAME="`gettext "Bhutan"`" + ;; + 'BV' ) + COUNTRYNAME="`gettext "Bouvet Island"`" + ;; + 'BW' ) + COUNTRYNAME="`gettext "Botswana"`" + ;; + 'BY' ) + COUNTRYNAME="`gettext "Belarus"`" + ;; + 'BZ' ) + COUNTRYNAME="`gettext "Belize"`" + ;; + 'CA' ) + COUNTRYNAME="`gettext "Canada"`" + ;; + 'CC' ) + COUNTRYNAME="`gettext "Cocos (Keeling) Islands"`" + ;; + 'CD' ) + COUNTRYNAME="`gettext "Congo (Dem. Rep.)"`" + ;; + 'CF' ) + COUNTRYNAME="`gettext "Central African Rep."`" + ;; + 'CG' ) + COUNTRYNAME="`gettext "Congo (Rep.)"`" + ;; + 'CH' ) + COUNTRYNAME="`gettext "Switzerland"`" + ;; + 'CI' ) + COUNTRYNAME="`gettext "Co^te d'Ivoire"`" + ;; + 'CK' ) + COUNTRYNAME="`gettext "Cook Islands"`" + ;; + 'CL' ) + COUNTRYNAME="`gettext "Chile"`" + ;; + 'CM' ) + COUNTRYNAME="`gettext "Cameroon"`" + ;; + 'CN' ) + COUNTRYNAME="`gettext "China"`" + ;; + 'CO' ) + COUNTRYNAME="`gettext "Colombia"`" + ;; + 'CR' ) + COUNTRYNAME="`gettext "Costa Rica"`" + ;; + 'CS' ) + COUNTRYNAME="`gettext "Serbia and Montenegro"`" + ;; + 'CU' ) + COUNTRYNAME="`gettext "Cuba"`" + ;; + 'CV' ) + COUNTRYNAME="`gettext "Cape Verde"`" + ;; + 'CX' ) + COUNTRYNAME="`gettext "Christmas Island"`" + ;; + 'CY' ) + COUNTRYNAME="`gettext "Cyprus"`" + ;; + 'CZ' ) + COUNTRYNAME="`gettext "Czech Republic"`" + ;; + 'DE' ) + COUNTRYNAME="`gettext "Germany"`" + ;; + 'DJ' ) + COUNTRYNAME="`gettext "Djibouti"`" + ;; + 'DK' ) + COUNTRYNAME="`gettext "Denmark"`" + ;; + 'DM' ) + COUNTRYNAME="`gettext "Dominica"`" + ;; + 'DO' ) + COUNTRYNAME="`gettext "Dominican Republic"`" + ;; + 'DZ' ) + COUNTRYNAME="`gettext "Algeria"`" + ;; + 'EC' ) + COUNTRYNAME="`gettext "Ecuador"`" + ;; + 'EE' ) + COUNTRYNAME="`gettext "Estonia"`" + ;; + 'EG' ) + COUNTRYNAME="`gettext "Egypt"`" + ;; + 'EH' ) + COUNTRYNAME="`gettext "Western Sahara"`" + ;; + 'ER' ) + COUNTRYNAME="`gettext "Eritrea"`" + ;; + 'ES' ) + COUNTRYNAME="`gettext "Spain"`" + ;; + 'ET' ) + COUNTRYNAME="`gettext "Ethiopia"`" + ;; + 'FI' ) + COUNTRYNAME="`gettext "Finland"`" + ;; + 'FJ' ) + COUNTRYNAME="`gettext "Fiji"`" + ;; + 'FK' ) + COUNTRYNAME="`gettext "Falkland Islands"`" + ;; + 'FM' ) + COUNTRYNAME="`gettext "Micronesia"`" + ;; + 'FO' ) + COUNTRYNAME="`gettext "Faeroe Islands"`" + ;; + 'FR' ) + COUNTRYNAME="`gettext "France"`" + ;; + 'GA' ) + COUNTRYNAME="`gettext "Gabon"`" + ;; + 'GB' ) + COUNTRYNAME="`gettext "Britain (UK)"`" + ;; + 'GD' ) + COUNTRYNAME="`gettext "Grenada"`" + ;; + 'GE' ) + COUNTRYNAME="`gettext "Georgia"`" + ;; + 'GF' ) + COUNTRYNAME="`gettext "French Guiana"`" + ;; + 'GH' ) + COUNTRYNAME="`gettext "Ghana"`" + ;; + 'GI' ) + COUNTRYNAME="`gettext "Gibraltar"`" + ;; + 'GL' ) + COUNTRYNAME="`gettext "Greenland"`" + ;; + 'GM' ) + COUNTRYNAME="`gettext "Gambia"`" + ;; + 'GN' ) + COUNTRYNAME="`gettext "Guinea"`" + ;; + 'GP' ) + COUNTRYNAME="`gettext "Guadeloupe"`" + ;; + 'GQ' ) + COUNTRYNAME="`gettext "Equatorial Guinea"`" + ;; + 'GR' ) + COUNTRYNAME="`gettext "Greece"`" + ;; + 'GS' ) + COUNTRYNAME="`gettext "South Georgia and the South Sandwich Islands"`" + ;; + 'GT' ) + COUNTRYNAME="`gettext "Guatemala"`" + ;; + 'GU' ) + COUNTRYNAME="`gettext "Guam"`" + ;; + 'GW' ) + COUNTRYNAME="`gettext "Guinea-Bissau"`" + ;; + 'GY' ) + COUNTRYNAME="`gettext "Guyana"`" + ;; + 'HK' ) + COUNTRYNAME="`gettext "Hong Kong"`" + ;; + 'HM' ) + COUNTRYNAME="`gettext "Heard Island and McDonald Islands"`" + ;; + 'HN' ) + COUNTRYNAME="`gettext "Honduras"`" + ;; + 'HR' ) + COUNTRYNAME="`gettext "Croatia"`" + ;; + 'HT' ) + COUNTRYNAME="`gettext "Haiti"`" + ;; + 'HU' ) + COUNTRYNAME="`gettext "Hungary"`" + ;; + 'ID' ) + COUNTRYNAME="`gettext "Indonesia"`" + ;; + 'IE' ) + COUNTRYNAME="`gettext "Ireland"`" + ;; + 'IL' ) + COUNTRYNAME="`gettext "Israel"`" + ;; + 'IN' ) + COUNTRYNAME="`gettext "India"`" + ;; + 'IO' ) + COUNTRYNAME="`gettext "British Indian Ocean Territory"`" + ;; + 'IQ' ) + COUNTRYNAME="`gettext "Iraq"`" + ;; + 'IR' ) + COUNTRYNAME="`gettext "Iran"`" + ;; + 'IS' ) + COUNTRYNAME="`gettext "Iceland"`" + ;; + 'IT' ) + COUNTRYNAME="`gettext "Italy"`" + ;; + 'JM' ) + COUNTRYNAME="`gettext "Jamaica"`" + ;; + 'JO' ) + COUNTRYNAME="`gettext "Jordan"`" + ;; + 'JP' ) + COUNTRYNAME="`gettext "Japan"`" + ;; + 'KE' ) + COUNTRYNAME="`gettext "Kenya"`" + ;; + 'KG' ) + COUNTRYNAME="`gettext "Kyrgyzstan"`" + ;; + 'KH' ) + COUNTRYNAME="`gettext "Cambodia"`" + ;; + 'KI' ) + COUNTRYNAME="`gettext "Kiribati"`" + ;; + 'KM' ) + COUNTRYNAME="`gettext "Comoros"`" + ;; + 'KN' ) + COUNTRYNAME="`gettext "St Kitts and Nevis"`" + ;; + 'KP' ) + COUNTRYNAME="`gettext "Korea (North)"`" + ;; + 'KR' ) + COUNTRYNAME="`gettext "Korea (South)"`" + ;; + 'KW' ) + COUNTRYNAME="`gettext "Kuwait"`" + ;; + 'KY' ) + COUNTRYNAME="`gettext "Cayman Islands"`" + ;; + 'KZ' ) + COUNTRYNAME="`gettext "Kazakhstan"`" + ;; + 'LA' ) + COUNTRYNAME="`gettext "Laos"`" + ;; + 'LB' ) + COUNTRYNAME="`gettext "Lebanon"`" + ;; + 'LC' ) + COUNTRYNAME="`gettext "St Lucia"`" + ;; + 'LI' ) + COUNTRYNAME="`gettext "Liechtenstein"`" + ;; + 'LK' ) + COUNTRYNAME="`gettext "Sri Lanka"`" + ;; + 'LR' ) + COUNTRYNAME="`gettext "Liberia"`" + ;; + 'LS' ) + COUNTRYNAME="`gettext "Lesotho"`" + ;; + 'LT' ) + COUNTRYNAME="`gettext "Lithuania"`" + ;; + 'LU' ) + COUNTRYNAME="`gettext "Luxembourg"`" + ;; + 'LV' ) + COUNTRYNAME="`gettext "Latvia"`" + ;; + 'LY' ) + COUNTRYNAME="`gettext "Libya"`" + ;; + 'MA' ) + COUNTRYNAME="`gettext "Morocco"`" + ;; + 'MC' ) + COUNTRYNAME="`gettext "Monaco"`" + ;; + 'MD' ) + COUNTRYNAME="`gettext "Moldova"`" + ;; + 'MG' ) + COUNTRYNAME="`gettext "Madagascar"`" + ;; + 'MH' ) + COUNTRYNAME="`gettext "Marshall Islands"`" + ;; + 'MK' ) + COUNTRYNAME="`gettext "Macedonia"`" + ;; + 'ML' ) + COUNTRYNAME="`gettext "Mali"`" + ;; + 'MM' ) + COUNTRYNAME="`gettext "Myanmar (Burma)"`" + ;; + 'MN' ) + COUNTRYNAME="`gettext "Mongolia"`" + ;; + 'MO' ) + COUNTRYNAME="`gettext "Macao"`" + ;; + 'MP' ) + COUNTRYNAME="`gettext "Northern Mariana Islands"`" + ;; + 'MQ' ) + COUNTRYNAME="`gettext "Martinique"`" + ;; + 'MR' ) + COUNTRYNAME="`gettext "Mauritania"`" + ;; + 'MS' ) + COUNTRYNAME="`gettext "Montserrat"`" + ;; + 'MT' ) + COUNTRYNAME="`gettext "Malta"`" + ;; + 'MU' ) + COUNTRYNAME="`gettext "Mauritius"`" + ;; + 'MV' ) + COUNTRYNAME="`gettext "Maldives"`" + ;; + 'MW' ) + COUNTRYNAME="`gettext "Malawi"`" + ;; + 'MX' ) + COUNTRYNAME="`gettext "Mexico"`" + ;; + 'MY' ) + COUNTRYNAME="`gettext "Malaysia"`" + ;; + 'MZ' ) + COUNTRYNAME="`gettext "Mozambique"`" + ;; + 'NA' ) + COUNTRYNAME="`gettext "Namibia"`" + ;; + 'NC' ) + COUNTRYNAME="`gettext "New Caledonia"`" + ;; + 'NE' ) + COUNTRYNAME="`gettext "Niger"`" + ;; + 'NF' ) + COUNTRYNAME="`gettext "Norfolk Island"`" + ;; + 'NG' ) + COUNTRYNAME="`gettext "Nigeria"`" + ;; + 'NI' ) + COUNTRYNAME="`gettext "Nicaragua"`" + ;; + 'NL' ) + COUNTRYNAME="`gettext "Netherlands"`" + ;; + 'NO' ) + COUNTRYNAME="`gettext "Norway"`" + ;; + 'NP' ) + COUNTRYNAME="`gettext "Nepal"`" + ;; + 'NR' ) + COUNTRYNAME="`gettext "Nauru"`" + ;; + 'NU' ) + COUNTRYNAME="`gettext "Niue"`" + ;; + 'NZ' ) + COUNTRYNAME="`gettext "New Zealand"`" + ;; + 'OM' ) + COUNTRYNAME="`gettext "Oman"`" + ;; + 'PA' ) + COUNTRYNAME="`gettext "Panama"`" + ;; + 'PE' ) + COUNTRYNAME="`gettext "Peru"`" + ;; + 'PF' ) + COUNTRYNAME="`gettext "French Polynesia"`" + ;; + 'PG' ) + COUNTRYNAME="`gettext "Papua New Guinea"`" + ;; + 'PH' ) + COUNTRYNAME="`gettext "Philippines"`" + ;; + 'PK' ) + COUNTRYNAME="`gettext "Pakistan"`" + ;; + 'PL' ) + COUNTRYNAME="`gettext "Poland"`" + ;; + 'PM' ) + COUNTRYNAME="`gettext "St Pierre and Miquelon"`" + ;; + 'PN' ) + COUNTRYNAME="`gettext "Pitcairn"`" + ;; + 'PR' ) + COUNTRYNAME="`gettext "Puerto Rico"`" + ;; + 'PS' ) + COUNTRYNAME="`gettext "Palestine"`" + ;; + 'PT' ) + COUNTRYNAME="`gettext "Portugal"`" + ;; + 'PW' ) + COUNTRYNAME="`gettext "Palau"`" + ;; + 'PY' ) + COUNTRYNAME="`gettext "Paraguay"`" + ;; + 'QA' ) + COUNTRYNAME="`gettext "Qatar"`" + ;; + 'RE' ) + COUNTRYNAME="`gettext "Reunion"`" + ;; + 'RO' ) + COUNTRYNAME="`gettext "Romania"`" + ;; + 'RU' ) + COUNTRYNAME="`gettext "Russia"`" + ;; + 'RW' ) + COUNTRYNAME="`gettext "Rwanda"`" + ;; + 'SA' ) + COUNTRYNAME="`gettext "Saudi Arabia"`" + ;; + 'SB' ) + COUNTRYNAME="`gettext "Solomon Islands"`" + ;; + 'SC' ) + COUNTRYNAME="`gettext "Seychelles"`" + ;; + 'SD' ) + COUNTRYNAME="`gettext "Sudan"`" + ;; + 'SE' ) + COUNTRYNAME="`gettext "Sweden"`" + ;; + 'SG' ) + COUNTRYNAME="`gettext "Singapore"`" + ;; + 'SH' ) + COUNTRYNAME="`gettext "St Helena"`" + ;; + 'SI' ) + COUNTRYNAME="`gettext "Slovenia"`" + ;; + 'SJ' ) + COUNTRYNAME="`gettext "Svalbard and Jan Mayen"`" + ;; + 'SK' ) + COUNTRYNAME="`gettext "Slovakia"`" + ;; + 'SL' ) + COUNTRYNAME="`gettext "Sierra Leone"`" + ;; + 'SM' ) + COUNTRYNAME="`gettext "San Marino"`" + ;; + 'SN' ) + COUNTRYNAME="`gettext "Senegal"`" + ;; + 'SO' ) + COUNTRYNAME="`gettext "Somalia"`" + ;; + 'SR' ) + COUNTRYNAME="`gettext "Suriname"`" + ;; + 'ST' ) + COUNTRYNAME="`gettext "Sao Tome and Principe"`" + ;; + 'SV' ) + COUNTRYNAME="`gettext "El Salvador"`" + ;; + 'SY' ) + COUNTRYNAME="`gettext "Syria"`" + ;; + 'SZ' ) + COUNTRYNAME="`gettext "Swaziland"`" + ;; + 'TC' ) + COUNTRYNAME="`gettext "Turks and Caicos Islands"`" + ;; + 'TD' ) + COUNTRYNAME="`gettext "Chad"`" + ;; + 'TF' ) + COUNTRYNAME="`gettext "French Southern and Antarctic Lands"`" + ;; + 'TG' ) + COUNTRYNAME="`gettext "Togo"`" + ;; + 'TH' ) + COUNTRYNAME="`gettext "Thailand"`" + ;; + 'TJ' ) + COUNTRYNAME="`gettext "Tajikistan"`" + ;; + 'TK' ) + COUNTRYNAME="`gettext "Tokelau"`" + ;; + 'TL' ) + COUNTRYNAME="`gettext "Timor-Leste"`" + ;; + 'TM' ) + COUNTRYNAME="`gettext "Turkmenistan"`" + ;; + 'TN' ) + COUNTRYNAME="`gettext "Tunisia"`" + ;; + 'TO' ) + COUNTRYNAME="`gettext "Tonga"`" + ;; + 'TR' ) + COUNTRYNAME="`gettext "Turkey"`" + ;; + 'TT' ) + COUNTRYNAME="`gettext "Trinidad and Tobago"`" + ;; + 'TV' ) + COUNTRYNAME="`gettext "Tuvalu"`" + ;; + 'TW' ) + COUNTRYNAME="`gettext "Taiwan"`" + ;; + 'TZ' ) + COUNTRYNAME="`gettext "Tanzania"`" + ;; + 'UA' ) + COUNTRYNAME="`gettext "Ukraine"`" + ;; + 'UG' ) + COUNTRYNAME="`gettext "Uganda"`" + ;; + 'UM' ) + COUNTRYNAME="`gettext "US minor outlying islands"`" + ;; + 'US' ) + COUNTRYNAME="`gettext "United States"`" + ;; + 'UY' ) + COUNTRYNAME="`gettext "Uruguay"`" + ;; + 'UZ' ) + COUNTRYNAME="`gettext "Uzbekistan"`" + ;; + 'VA' ) + COUNTRYNAME="`gettext "Vatican City"`" + ;; + 'VC' ) + COUNTRYNAME="`gettext "St Vincent"`" + ;; + 'VE' ) + COUNTRYNAME="`gettext "Venezuela"`" + ;; + 'VG' ) + COUNTRYNAME="`gettext "Virgin Islands (UK)"`" + ;; + 'VI' ) + COUNTRYNAME="`gettext "Virgin Islands (US)"`" + ;; + 'VN' ) + COUNTRYNAME="`gettext "Vietnam"`" + ;; + 'VU' ) + COUNTRYNAME="`gettext "Vanuatu"`" + ;; + 'WF' ) + COUNTRYNAME="`gettext "Wallis and Futuna"`" + ;; + 'WS' ) + COUNTRYNAME="`gettext "Samoa (Western)"`" + ;; + 'YE' ) + COUNTRYNAME="`gettext "Yemen"`" + ;; + 'YT' ) + COUNTRYNAME="`gettext "Mayotte"`" + ;; + 'ZA' ) + COUNTRYNAME="`gettext "South Africa"`" + ;; + 'ZM' ) + COUNTRYNAME="`gettext "Zambia"`" + ;; + 'ZW' ) + COUNTRYNAME="`gettext "Zimbabwe"`" + ;; + * ) + COUNTRYNAME="`gettext "Unknown"`" + + esac + + echo $COUNTRYNAME + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getCurrentLocale.sh b/Scripts/Bash/Functions/Commons/cli_getCurrentLocale.sh new file mode 100755 index 0000000..9181c59 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getCurrentLocale.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# cli_getCurrentLocale.sh -- This function checks LANG environment +# variable and returns the current locale information in the LL_CC +# format. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCurrentLocale { + + local CURRENTLOCALE='' + local OPTION="$1" + + # Redefine current locale using LL_CC format. + CURRENTLOCALE=$(echo $LANG | sed -r 's!(^[a-z]{2,3}_[A-Z]{2}).+$!\1!') + + # Define centos-art.sh script default current locale. If + # centos-art.sh script doesn't support current system locale, use + # English language from United States as default current locale. + if [[ $CURRENTLOCALE == '' ]];then + CURRENTLOCALE='en_US' + fi + + # Output current locale. + case $OPTION in + + '--langcode-only' ) + echo "${CURRENTLOCALE}" | cut -d_ -f1 + ;; + + '--langcode-and-countrycode'| * ) + echo "${CURRENTLOCALE}" + ;; + esac +} diff --git a/Scripts/Bash/Functions/Commons/cli_getFilesList.sh b/Scripts/Bash/Functions/Commons/cli_getFilesList.sh new file mode 100755 index 0000000..5b9ff22 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getFilesList.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# cli_getFilesList.sh -- This function outputs the list of files to +# process. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getFilesList { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize pattern used to reduce the find output. + local PATTERN="$FLAG_FILTER" + + # Initialize options used with find command. + local OPTIONS='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$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. + local LOCATIONS="$@" + + # Verify locations. + cli_checkFiles ${LOCATIONS} + + # 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. Doing so, everytime 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 LOCATION variable as part of + # regular expresion 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. + 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 coul be introduced to it. The best we can do is + # verifying exit status and go on. + find ${LOCATIONS} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getLangCodes.sh b/Scripts/Bash/Functions/Commons/cli_getLangCodes.sh new file mode 100755 index 0000000..59f7444 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getLangCodes.sh @@ -0,0 +1,222 @@ +#!/bin/bash +# +# cli_getLangCodes.sh -- This function outputs a list with language +# codes as defined in ISO639 standard. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLangCodes { + + local FILTER="$(echo $1 | cut -d_ -f1)" + + LANGCODES="aa + ab + ae + af + ak + am + an + ar + as + av + ay + az + ba + be + bg + bh + bi + bm + bn + bo + br + bs + ca + ce + ch + co + cr + cs + cu + cv + cy + da + de + dv + dz + ee + el + en + eo + es + et + eu + fa + ff + fi + fj + fo + fr + fy + ga + gd + gl + gn + gu + gv + ha + he + hi + ho + hr + ht + hu + hy + hz + ia + id + ie + ig + ii + ik + io + is + it + iu + ja + jv + ka + kg + ki + kj + kk + kl + km + kn + ko + kr + ks + ku + kv + kw + ky + la + lb + lg + li + ln + lo + lt + lu + lv + mg + mh + mi + mk + ml + mn + mo + mr + ms + mt + my + na + nb + nd + ne + ng + nl + nn + no + nr + nv + ny + oc + oj + om + or + os + pa + pi + pl + ps + pt + qu + rm + rn + ro + ru + rw + sa + sc + sd + se + sg + si + sk + sl + sm + sn + so + sq + sr + ss + st + su + sv + sw + ta + te + tg + th + ti + tk + tl + tn + to + tr + ts + tt + tw + ty + ug + uk + ur + uz + ve + vi + vo + wa + wo + xh + yi + yo + za + zh + zu" + + if [[ $FILTER != '' ]];then + echo "$LANGCODES" | egrep "$FILTER" | sed -r 's![[:space:]]+!!g' + else + echo "$LANGCODES" + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getLangName.sh b/Scripts/Bash/Functions/Commons/cli_getLangName.sh new file mode 100755 index 0000000..6d734b2 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getLangName.sh @@ -0,0 +1,780 @@ +#!/bin/bash +# +# cli_getLangName.sh -- This function reads one language locale code +# in the format LL_CC and outputs its language name. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLangName { + + local LANGCODE="$(echo "$1" | cut -d_ -f1 | tr '[:upper:]' '[:lower:]')" + local LANGNAME='' + + case $LANGCODE in + + 'aa' ) + LANGNAME="`gettext "Afar"`" + ;; + + 'ab' ) + LANGNAME="`gettext "Abkhazian"`" + ;; + + 'ae' ) + LANGNAME="`gettext "Avestan"`" + ;; + + 'af' ) + LANGNAME="`gettext "Afrikaans"`" + ;; + + 'ak' ) + LANGNAME="`gettext "Akan"`" + ;; + + 'am' ) + LANGNAME="`gettext "Amharic"`" + ;; + + 'an' ) + LANGNAME="`gettext "Aragonese"`" + ;; + + 'ar' ) + LANGNAME="`gettext "Arabic"`" + ;; + + 'as' ) + LANGNAME="`gettext "Assamese"`" + ;; + + 'av' ) + LANGNAME="`gettext "Avaric"`" + ;; + + 'ay' ) + LANGNAME="`gettext "Aymara"`" + ;; + + 'az' ) + LANGNAME="`gettext "Azerbaijani"`" + ;; + + 'ba' ) + LANGNAME="`gettext "Bashkir"`" + ;; + + 'be' ) + LANGNAME="`gettext "Byelorussian"`" + ;; + + 'bg' ) + LANGNAME="`gettext "Bulgarian"`" + ;; + + 'bh' ) + LANGNAME="`gettext "Bihari"`" + ;; + + 'bi' ) + LANGNAME="`gettext "Bislama"`" + ;; + + 'bm' ) + LANGNAME="`gettext "Bambara"`" + ;; + + 'bn' ) + LANGNAME="`gettext "Bengali"`" + ;; + + 'bo' ) + LANGNAME="`gettext "Tibetan"`" + ;; + + 'br' ) + LANGNAME="`gettext "Breton"`" + ;; + + 'bs' ) + LANGNAME="`gettext "Bosnian"`" + ;; + + 'ca' ) + LANGNAME="`gettext "Catalan"`" + ;; + + 'ce' ) + LANGNAME="`gettext "Chechen"`" + ;; + + 'ch' ) + LANGNAME="`gettext "Chamorro"`" + ;; + + 'co' ) + LANGNAME="`gettext "Corsican"`" + ;; + + 'cr' ) + LANGNAME="`gettext "Cree"`" + ;; + + 'cs' ) + LANGNAME="`gettext "Czech"`" + ;; + + 'cu' ) + LANGNAME="`gettext "Church Slavic"`" + ;; + + 'cv' ) + LANGNAME="`gettext "Chuvash"`" + ;; + + 'cy' ) + LANGNAME="`gettext "Welsh"`" + ;; + + 'da' ) + LANGNAME="`gettext "Danish"`" + ;; + + 'de' ) + LANGNAME="`gettext "German"`" + ;; + + 'dv' ) + LANGNAME="`gettext "Divehi"`" + ;; + + 'dz' ) + LANGNAME="`gettext "Dzongkha"`" + ;; + + 'ee' ) + LANGNAME="`gettext "E'we"`" + ;; + + 'el' ) + LANGNAME="`gettext "Greek"`" + ;; + + 'en' ) + LANGNAME="`gettext "English"`" + ;; + + 'eo' ) + LANGNAME="`gettext "Esperanto"`" + ;; + + 'es' ) + LANGNAME="`gettext "Spanish"`" + ;; + + 'et' ) + LANGNAME="`gettext "Estonian"`" + ;; + + 'eu' ) + LANGNAME="`gettext "Basque"`" + ;; + 'fa' ) + LANGNAME="`gettext "Persian"`" + ;; + + 'ff' ) + LANGNAME="`gettext "Fulah"`" + ;; + + 'fi' ) + LANGNAME="`gettext "Finnish"`" + ;; + + 'fj' ) + LANGNAME="`gettext "Fijian"`" + ;; + + 'fo' ) + LANGNAME="`gettext "Faroese"`" + ;; + + 'fr' ) + LANGNAME="`gettext "French"`" + ;; + + 'fy' ) + LANGNAME="`gettext "Frisian"`" + ;; + + 'ga' ) + LANGNAME="`gettext "Irish"`" + ;; + + 'gd' ) + LANGNAME="`gettext "Scots"`" + ;; + + 'gl' ) + LANGNAME="`gettext "Gallegan"`" + ;; + + 'gn' ) + LANGNAME="`gettext "Guarani"`" + ;; + + 'gu' ) + LANGNAME="`gettext "Gujarati"`" + ;; + + 'gv' ) + LANGNAME="`gettext "Manx"`" + ;; + + 'ha' ) + LANGNAME="`gettext "Hausa"`" + ;; + + 'he' ) + LANGNAME="`gettext "Hebrew"`" + ;; + + 'hi' ) + LANGNAME="`gettext "Hindi"`" + ;; + + 'ho' ) + LANGNAME="`gettext "Hiri Motu"`" + ;; + + 'hr' ) + LANGNAME="`gettext "Croatian"`" + ;; + + 'ht' ) + LANGNAME="`gettext "Haitian"`" + ;; + + 'hu' ) + LANGNAME="`gettext "Hungarian"`" + ;; + + 'hy' ) + LANGNAME="`gettext "Armenian"`" + ;; + + 'hz' ) + LANGNAME="`gettext "Herero"`" + ;; + + 'ia' ) + LANGNAME="`gettext "Interlingua"`" + ;; + + 'id' ) + LANGNAME="`gettext "Indonesian"`" + ;; + + 'ie' ) + LANGNAME="`gettext "Interlingue"`" + ;; + + 'ig' ) + LANGNAME="`gettext "Igbo"`" + ;; + + 'ii' ) + LANGNAME="`gettext "Sichuan Yi"`" + ;; + + 'ik' ) + LANGNAME="`gettext "Inupiak"`" + ;; + + 'io' ) + LANGNAME="`gettext "Ido"`" + ;; + + 'is' ) + LANGNAME="`gettext "Icelandic"`" + ;; + + 'it' ) + LANGNAME="`gettext "Italian"`" + ;; + + 'iu' ) + LANGNAME="`gettext "Inuktitut"`" + ;; + + 'ja' ) + LANGNAME="`gettext "Japanese"`" + ;; + + 'jv' ) + LANGNAME="`gettext "Javanese"`" + ;; + + 'ka' ) + LANGNAME="`gettext "Georgian"`" + ;; + + 'kg' ) + LANGNAME="`gettext "Kongo"`" + ;; + + 'ki' ) + LANGNAME="`gettext "Kikuyu"`" + ;; + + 'kj' ) + LANGNAME="`gettext "Kuanyama"`" + ;; + + 'kk' ) + LANGNAME="`gettext "Kazakh"`" + ;; + + 'kl' ) + LANGNAME="`gettext "Kalaallisut"`" + ;; + + 'km' ) + LANGNAME="`gettext "Khmer"`" + ;; + + 'kn' ) + LANGNAME="`gettext "Kannada"`" + ;; + + 'ko' ) + LANGNAME="`gettext "Korean"`" + ;; + + 'kr' ) + LANGNAME="`gettext "Kanuri"`" + ;; + + 'ks' ) + LANGNAME="`gettext "Kashmiri"`" + ;; + + 'ku' ) + LANGNAME="`gettext "Kurdish"`" + ;; + + 'kv' ) + LANGNAME="`gettext "Komi"`" + ;; + + 'kw' ) + LANGNAME="`gettext "Cornish"`" + ;; + + 'ky' ) + LANGNAME="`gettext "Kirghiz"`" + ;; + + 'la' ) + LANGNAME="`gettext "Latin"`" + ;; + + 'lb' ) + LANGNAME="`gettext "Letzeburgesch"`" + ;; + + 'lg' ) + LANGNAME="`gettext "Ganda"`" + ;; + + 'li' ) + LANGNAME="`gettext "Limburgish"`" + ;; + + 'ln' ) + LANGNAME="`gettext "Lingala"`" + ;; + + 'lo' ) + LANGNAME="`gettext "Lao"`" + ;; + + 'lt' ) + LANGNAME="`gettext "Lithuanian"`" + ;; + + 'lu' ) + LANGNAME="`gettext "Luba-Katanga"`" + ;; + + 'lv' ) + LANGNAME="`gettext "Latvian"`" + ;; + + 'mg' ) + LANGNAME="`gettext "Malagasy"`" + ;; + + 'mh' ) + LANGNAME="`gettext "Marshall"`" + ;; + + 'mi' ) + LANGNAME="`gettext "Maori"`" + ;; + + 'mk' ) + LANGNAME="`gettext "Macedonian"`" + ;; + + 'ml' ) + LANGNAME="`gettext "Malayalam"`" + ;; + + 'mn' ) + LANGNAME="`gettext "Mongolian"`" + ;; + + 'mo' ) + LANGNAME="`gettext "Moldavian"`" + ;; + + 'mr' ) + LANGNAME="`gettext "Marathi"`" + ;; + + 'ms' ) + LANGNAME="`gettext "Malay"`" + ;; + + 'mt' ) + LANGNAME="`gettext "Maltese"`" + ;; + + 'my' ) + LANGNAME="`gettext "Burmese"`" + ;; + + 'na' ) + LANGNAME="`gettext "Nauru"`" + ;; + + 'nb' ) + LANGNAME="`gettext "Norwegian Bokmaal"`" + ;; + + 'nd' ) + LANGNAME="`gettext "Ndebele, North"`" + ;; + + 'ne' ) + LANGNAME="`gettext "Nepali"`" + ;; + + 'ng' ) + LANGNAME="`gettext "Ndonga"`" + ;; + + 'nl' ) + LANGNAME="`gettext "Dutch"`" + ;; + + 'nn' ) + LANGNAME="`gettext "Norwegian Nynorsk"`" + ;; + + 'no' ) + LANGNAME="`gettext "Norwegian"`" + ;; + + 'nr' ) + LANGNAME="`gettext "Ndebele, South"`" + ;; + + 'nv' ) + LANGNAME="`gettext "Navajo"`" + ;; + + 'ny' ) + LANGNAME="`gettext "Chichewa"`" + ;; + + 'oc' ) + LANGNAME="`gettext "Occitan"`" + ;; + + 'oj' ) + LANGNAME="`gettext "Ojibwa"`" + ;; + + 'om' ) + LANGNAME="`gettext "(Afan) Oromo"`" + ;; + + 'or' ) + LANGNAME="`gettext "Oriya"`" + ;; + + 'os' ) + LANGNAME="`gettext "Ossetian; Ossetic"`" + ;; + + 'pa' ) + LANGNAME="`gettext "Panjabi; Punjabi"`" + ;; + + 'pi' ) + LANGNAME="`gettext "Pali"`" + ;; + + 'pl' ) + LANGNAME="`gettext "Polish"`" + ;; + + 'ps' ) + LANGNAME="`gettext "Pashto, Pushto"`" + ;; + + 'pt' ) + LANGNAME="`gettext "Portuguese"`" + ;; + + 'qu' ) + LANGNAME="`gettext "Quechua"`" + ;; + + 'rm' ) + LANGNAME="`gettext "Rhaeto-Romance"`" + ;; + + 'rn' ) + LANGNAME="`gettext "Rundi"`" + ;; + + 'ro' ) + LANGNAME="`gettext "Romanian"`" + ;; + + 'ru' ) + LANGNAME="`gettext "Russian"`" + ;; + + 'rw' ) + LANGNAME="`gettext "Kinyarwanda"`" + ;; + + 'sa' ) + LANGNAME="`gettext "Sanskrit"`" + ;; + + 'sc' ) + LANGNAME="`gettext "Sardinian"`" + ;; + + 'sd' ) + LANGNAME="`gettext "Sindhi"`" + ;; + + 'se' ) + LANGNAME="`gettext "Northern Sami"`" + ;; + + 'sg' ) + LANGNAME="`gettext "Sango; Sangro"`" + ;; + + 'si' ) + LANGNAME="`gettext "Sinhalese"`" + ;; + + 'sk' ) + LANGNAME="`gettext "Slovak"`" + ;; + + 'sl' ) + LANGNAME="`gettext "Slovenian"`" + ;; + + 'sm' ) + LANGNAME="`gettext "Samoan"`" + ;; + + 'sn' ) + LANGNAME="`gettext "Shona"`" + ;; + + 'so' ) + LANGNAME="`gettext "Somali"`" + ;; + + 'sq' ) + LANGNAME="`gettext "Albanian"`" + ;; + + 'sr' ) + LANGNAME="`gettext "Serbian"`" + ;; + + 'ss' ) + LANGNAME="`gettext "Swati; Siswati"`" + ;; + + 'st' ) + LANGNAME="`gettext "Sesotho; Sotho, Southern"`" + ;; + + 'su' ) + LANGNAME="`gettext "Sundanese"`" + ;; + + 'sv' ) + LANGNAME="`gettext "Swedish"`" + ;; + + 'sw' ) + LANGNAME="`gettext "Swahili"`" + ;; + + 'ta' ) + LANGNAME="`gettext "Tamil"`" + ;; + + 'te' ) + LANGNAME="`gettext "Telugu"`" + ;; + + 'tg' ) + LANGNAME="`gettext "Tajik"`" + ;; + + 'th' ) + LANGNAME="`gettext "Thai"`" + ;; + + 'ti' ) + LANGNAME="`gettext "Tigrinya"`" + ;; + + 'tk' ) + LANGNAME="`gettext "Turkmen"`" + ;; + + 'tl' ) + LANGNAME="`gettext "Tagalog"`" + ;; + + 'tn' ) + LANGNAME="`gettext "Tswana; Setswana"`" + ;; + + 'to' ) + LANGNAME="`gettext "Tonga (?)"`" + ;; + + 'tr' ) + LANGNAME="`gettext "Turkish"`" + ;; + + 'ts' ) + LANGNAME="`gettext "Tsonga"`" + ;; + + + 'tt' ) + LANGNAME="`gettext "Tatar"`" + ;; + + 'tw' ) + LANGNAME="`gettext "Twi"`" + ;; + + 'ty' ) + LANGNAME="`gettext "Tahitian"`" + ;; + + 'ug' ) + LANGNAME="`gettext "Uighur"`" + ;; + + 'uk' ) + LANGNAME="`gettext "Ukrainian"`" + ;; + + 'ur' ) + LANGNAME="`gettext "Urdu"`" + ;; + + 'uz' ) + LANGNAME="`gettext "Uzbek"`" + ;; + + 've' ) + LANGNAME="`gettext "Venda"`" + ;; + + 'vi' ) + LANGNAME="`gettext "Vietnamese"`" + ;; + + 'vo' ) + LANGNAME="`gettext "Volapuk; Volapuk"`" + ;; + + 'wa' ) + LANGNAME="`gettext "Walloon"`" + ;; + + 'wo' ) + LANGNAME="`gettext "Wolof"`" + ;; + + 'xh' ) + LANGNAME="`gettext "Xhosa"`" + ;; + + 'yi' ) + LANGNAME="`gettext "Yiddish (formerly ji)"`" + ;; + + 'yo' ) + LANGNAME="`gettext "Yoruba"`" + ;; + + 'za' ) + LANGNAME="`gettext "Zhuang"`" + ;; + + 'zh' ) + LANGNAME="`gettext "Chinese"`" + ;; + + 'zu' ) + LANGNAME="`gettext "Zulu"`" + ;; + + * ) + LANGNAME="`gettext "Unknown"`" + + esac + + echo $LANGNAME; +} + diff --git a/Scripts/Bash/Functions/Commons/cli_getLocales.sh b/Scripts/Bash/Functions/Commons/cli_getLocales.sh new file mode 100755 index 0000000..853efc7 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getLocales.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# cli_getLocales.sh -- This function outputs/verifies locale codes in LL +# and LL_CC format. Combine both ISO639 and ISO3166 specification in +# order to build the final locale list. This function defines which +# translation locales are supported inside CentOS Artwork Repository. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLocales { + + # Print locales supported by centos-art.sh script. + locale -a | egrep '^[a-z]{2,3}_[A-Z]{2}$' | sort | uniq + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getPathComponent.sh b/Scripts/Bash/Functions/Commons/cli_getPathComponent.sh new file mode 100755 index 0000000..e838cf7 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getPathComponent.sh @@ -0,0 +1,131 @@ +#!/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 retrive information +# from paths (e.g., releases, architectures and theme artistic motifs) +# or the patterns used to build the paths. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +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' + + # Initialize ARGUMENTS with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Define release pattern. + local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+)){0,1})" + + # Define architecture pattern. Make it match the architectures the + # CentOS distribution is able to be installed on. + local ARCHITECTURE="(i386|x86_64)" + + # Define pattern for themes' artistic motifs. + local THEME_MOTIF="Identity/Images/Themes/(([[:alnum:]]+)/(${RELEASE}))" + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$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 + ;; + + esac + + done +} diff --git a/Scripts/Bash/Functions/Commons/cli_getRepoName.sh b/Scripts/Bash/Functions/Commons/cli_getRepoName.sh new file mode 100755 index 0000000..4a43eb3 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getRepoName.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# +# cli_getRepoName.sh -- This function standardize file and directories +# name convenction inside the working copy of CentOS Artowrk +# Repository. As convenction, regular files are written in lower case +# and directories are written in lower case but with the first letter +# in upper case. Use this function to sanitate the name of regular +# files and directory components of paths you work with. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +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 sanitated (e.g., /home, + # /home/centos, /home/centos/artwork, + # /home/centos/artwork/turnk, trunk, etc.) So, we keep + # them unchaged for later use. + PREFIXDIR=$(echo $NAME \ + | sed -r "s,^(($(cli_getRepoTLDir)/)?(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 sanitated values. + CLEANDIRS="${CLEANDIRS}/$DIR" + + done + + # Redefine path using sanitated values. + NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") + + # Add prefix directory information to sanitated path + # information. + if [[ "$PREFIXDIR" != '' ]];then + NAME=${PREFIXDIR}${NAME} + fi + ;; + + esac + + # Print out the clean path string. + echo $NAME + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getRepoParallelDirs.sh b/Scripts/Bash/Functions/Commons/cli_getRepoParallelDirs.sh new file mode 100755 index 0000000..f2d0bc8 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getRepoParallelDirs.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# cli_getRepoParallelDirs.sh -- This function returns the parallel +# directories related to the first positional paramenter passed as +# parent directory. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoParallelDirs { + + local BOND='' + local TDIR='' + local -a PDIRS + + # Define bond string using first positional parameter as + # reference. + if [[ "$1" != '' ]];then + BOND="$1" + elif [[ "$ACTIONVAL" != '' ]];then + BOND="$ACTIONVAL" + else + cli_printMessage "`gettext "The bond string is required."`" --as-error-line + fi + + # Define repository top level directory. + TDIR=$(cli_getRepoTLDir ${BOND}) + + # Define parallel directory base structures. + PDIRS[0]=Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir ${BOND} --relative) + PDIRS[1]=Scripts/Bash/Functions/Render/Config + PDIRS[2]=L10n + + # Redefine bond string without its top level directory structure. + BOND=$(echo $BOND | sed -r "s,^${TDIR}/(.+)$,\1,") + + # Concatenate repository top level directory, parallel directory + # base structure, and bond information; in order to produce the + # final parallel directory path. + for PDIR in "${PDIRS[@]}";do + echo ${TDIR}/${PDIR}/${BOND} + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getRepoStatus.sh b/Scripts/Bash/Functions/Commons/cli_getRepoStatus.sh new file mode 100755 index 0000000..dca042f --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getRepoStatus.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# cli_getRepoStatus.sh -- This function requests the working copy +# using the svn status command and returns the first character in the +# output line, as described in svn help status, for the LOCATION +# specified. Use this function to perform verifications based a +# repository LOCATION status. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoStatus { + + local LOCATION="$1" + + # Define regular expression pattern to retrive first column, + # returned by subversion status command. This column is one + # character column as describes `svn help status' command. + local PATTERN='^( |A|C|D|I|M|R|X|!|~).+$' + + # Output specific state of location using subversion `status' + # command. + svn status "$LOCATION" --quiet | sed -r "s/${PATTERN}/\1/" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getRepoTLDir.sh b/Scripts/Bash/Functions/Commons/cli_getRepoTLDir.sh new file mode 100755 index 0000000..bc30f2c --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getRepoTLDir.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# +# cli_getRepoTLDir.sh -- This function returns the repository top +# level absolute path. The repository top level absolute path can be +# either ${CLI_WRKCOPY}/trunk, ${CLI_WRKCOPY}/branches, or +# ${CLI_WRKCOPY}/tags. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoTLDir { + + # Define short options. + local ARGSS='r' + + # Define long options. + local ARGSL='relative' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize path pattern and replacement. + local PATTERN='' + local REPLACE='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Define the location we want to apply verifications to. + local LOCATION=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') + + # Verify location passed as non-option argument. If no location is + # passed as non-option argument to this function, then set the + # trunk directory structure as default location. + if [[ $LOCATION =~ '--$' ]];then + LOCATION=${CLI_WRKCOPY}/trunk + fi + + # Verify location where the working copy should be stored in the + # workstations. Whatever the location provided be, it should refer + # to one of the top level directories inside the working copy of + # CentOS Artwork Repository which, in turn, should be sotred in + # the `artwork' directory immediatly under your home directory. + if [[ ! $LOCATION =~ "^${CLI_WRKCOPY}/(trunk|branches|tags)" ]];then + cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line + fi + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + -r|--relative ) + PATTERN="^${CLI_WRKCOPY}/(trunk|branches|tags)/.+$" + REPLACE='\1' + shift 2 + break + ;; + + -- ) + PATTERN="^(${CLI_WRKCOPY}/(trunk|branches|tags))/.+$" + REPLACE='\1' + shift 1 + break + ;; + esac + + done + + # Print out top level directory. + echo $LOCATION | sed -r "s!${PATTERN}!${REPLACE}!g" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getTTFont.sh b/Scripts/Bash/Functions/Commons/cli_getTTFont.sh new file mode 100755 index 0000000..d6b0cd8 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getTTFont.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# cli_getFont.sh -- This function creates a list of all True Type +# Fonts (TTF) installed in your workstation and returns the absolute +# path of the file matching the pattern passed as first argument. +# Assuming more than one value matches, the first one in the list is +# used. In case no match is found, the function verifies if there is +# any file in the list that can be used (giving preference to sans +# files). If no file is found at this point, an error will be printed +# out. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getTTFont { + + local -a FONT_PATTERNS + local FONT_PATTERN='' + local FONT_FILE='' + + # Define list of patterns used to build the list of TTF files. + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="/${1}\.ttf$" + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="sans\.ttf$" + FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="\.ttf$" + + # Define directory location where fonts are installed in your + # workstation. + local FONT_DIR='/usr/share/fonts' + + # Define list of all TTF files installed in your workstation. + local FONT_FILES=$(cli_getFilesList ${FONT_DIR} --pattern="\.ttf") + + # Define TTF absolute path based on pattern. Notice that if the + # pattern matches more than one value, only the first one of a + # sorted list will be used. + for FONT_PATTERN in ${FONT_PATTERNS[@]};do + + FONT_FILE=$(echo "$FONT_FILES" | egrep ${FONT_PATTERN} \ + | head -n 1) + + if [[ -f $FONT_FILE ]];then + break + fi + + done + + # Output TTF absolute path. + if [[ -f $FONT_FILE ]];then + echo $FONT_FILE + else + cli_printMessage "`gettext "The font provided doesn't exist."`" --as-error-line + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_getTemporalFile.sh b/Scripts/Bash/Functions/Commons/cli_getTemporalFile.sh new file mode 100755 index 0000000..89c9ae2 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_getTemporalFile.sh @@ -0,0 +1,59 @@ +#!/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. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +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 exention is + # required in order to avoid complains from inkscape. + local NAME="$(cli_getRepoName $1 -f)" + + # Check default base name for temporal file, it can't be an empty + # value. + if [[ "$NAME" == '' ]];then + cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line + fi + + # Redefine file name for the temporal file. Make it a combination + # of the program name, the program process id, a random string and + # the design model name. Using the program name and process id in + # the file name let us to relate both the shell script execution + # and the temporal files it creates, so they can be removed in + # case an interruption signal be detected. The random string let + # us to produce the same artwork in different terminals at the + # same time. the The design model name provides file + # identification. + NAME=${CLI_NAME}-${CLI_PPID}-${RANDOM}-${NAME} + + # Define absolute path for temporal file using the program name, + # the current locale, the unique identifier and the file name. + local TEMPFILE="${CLI_TEMPDIR}/${NAME}" + + # Output absolute path to final temporal file. + echo $TEMPFILE + +} diff --git a/Scripts/Bash/Functions/Commons/cli_isLocalized.sh b/Scripts/Bash/Functions/Commons/cli_isLocalized.sh new file mode 100755 index 0000000..efce7f8 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_isLocalized.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# cli_isLocalized.sh -- This function determines whether a file or +# directory can have translation messages or not. This is the way we +# standardize what locations can be localized and what cannot inside +# the repository. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_isLocalized { + + local DIR='' + local -a DIRS + + # Initialize default value returned by this function. + local LOCALIZED='false' + + # Initialize location will use as reference to determine whether + # it can have translation messages or not. + local LOCATION="$1" + + # Redefine location to be sure we'll always evaluate a directory, + # as reference location. + if [[ -f $LOCATION ]];then + LOCATION=$(dirname $LOCATION) + fi + + # Verify location existence. If it doesn't exist we cannot go on. + cli_checkFiles $LOCATION -d + + # Define regular expresion list of all directories inside the + # repository that can have translation. These are the + # locale-specific directories will be created for. + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Distro/$(\ + cli_getPathComponent --release-pattern)/Anaconda|Concept|Posters|Media)" + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+$" + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Scripts$" + + # Verify location passed as first argument agains the list of + # directories that can have translation messages. By default, the + # location passed as first argument is considered as a location + # that cannot have translation messages until a positive answer + # says otherwise. + for DIR in ${DIRS[@]};do + if [[ $LOCATION =~ $DIR ]];then + LOCALIZED='true' + break + fi + done + + # Output final answer to all verifications. + echo "$LOCALIZED" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_isVersioned.sh b/Scripts/Bash/Functions/Commons/cli_isVersioned.sh new file mode 100755 index 0000000..a1f7f97 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_isVersioned.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# cli_isVersioned.sh -- This function determines whether a location is +# under version control or not. When the location is under version +# control, this function returns `true'. when the location isn't under +# version control, this function returns `false'. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_isVersioned { + + # Initialize absolute path using first positional parameter as + # reference. + local LOCATION="$1" + + # Verify location to be sure it really exists. + cli_checkFiles $LOCATION + + # Use subversion to determine whether the location is under + # version control or not. + svn info $LOCATION &> /dev/null + + # Verify subversion exit status and print output. + if [[ $? -eq 0 ]];then + echo 'true' + else + echo 'false' + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_parseArguments.sh b/Scripts/Bash/Functions/Commons/cli_parseArguments.sh new file mode 100755 index 0000000..3585d7a --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_parseArguments.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# cli_parseArguments.sh -- This function redefines arguments +# (ARGUMENTS) global variable using getopt(1) output. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_parseArguments { + + # Reset positional parameters using optional arguments. + eval set -- "$ARGUMENTS" + + # Parse optional arguments using getopt. + ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n "$CLI_NAME (${FUNCNAME[1]})" -- "$@") + + # Be sure getout parsed arguments successfully. + if [[ $? != 0 ]]; then + cli_printMessage "${CLI_FUNCDIRNAM}" --as-toknowmore-line + fi + +} diff --git a/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh b/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh new file mode 100755 index 0000000..6a6c4c0 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# cli_parseArgumentsReDef.sh -- This function initiates/reset and +# sanitates positional parameters passed to this function and creates +# the the list of arguments that getopt will process. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_parseArgumentsReDef { + + local ARG + + # Clean up arguments global variable. + ARGUMENTS='' + + # Fill up arguments global variable with current positional + # parameter information. To avoid interpretation problems, use + # single quotes to enclose each argument (ARG) from command-line + # idividually. + for ARG in "$@"; do + + # Sanitate option arguments before process them. Be sure that + # no option argument does contain any single quote (U+0027) + # inside; that would break option parsing. Remember that we + # are using single quotes to enclose option arguments in order + # to let getopt to interpret option arguments with spaces + # inside. To solve this issue, we replace all single quotes + # in the arguments list with their respective codification and + # reverse the process back when doPrint them out. + ARG=$(echo $ARG | sed "s/'/\\\0x27/g") + + # Concatenate arguments and encolose them to let getopt to + # process them when they have spaces inside. + ARGUMENTS="$ARGUMENTS '$ARG'" + + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_printActionPreamble.sh b/Scripts/Bash/Functions/Commons/cli_printActionPreamble.sh new file mode 100755 index 0000000..c8270bc --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_printActionPreamble.sh @@ -0,0 +1,146 @@ +#!/bin/bash +# +# cli_printActionPreamble -- This function standardizes the way +# preamble messages are printed out. Preamble messages are used before +# actions (e.g., file elimination, edition, creation, actualization, +# etc.) and provide a way for the user to control whether the action +# is performed or not. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printActionPreamble { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='to-create,to-delete,to-locale,to-edit' + + # Initialize arguments with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize message. + local MESSAGE='' + + # Initialize message options. + local OPTION='' + + # Initialize file variable as local to avoid conflicts outside. + # We'll use the file variable later, to show the list of files + # that will be affected by the action. + local FILE='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Define the location we want to apply verifications to. + local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') + + # Initialize counter with total number of files. + local COUNT=$(echo $FILES | wc -l) + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + --to-create ) + if [[ $FILES == '--' ]];then + MESSAGE="`gettext "There is no entry to create."`" + OPTION='--as-error-line' + else + MESSAGE="`ngettext "The following entry will be created" \ + "The following entries will be created" $COUNT`:" + OPTION='' + fi + shift 2 + break + ;; + + --to-delete ) + if [[ $FILES == '--' ]];then + MESSAGE="`gettext "There is no file to delete."`" + OPTION='--as-error-line' + else + MESSAGE="`ngettext "The following entry will be deleted" \ + "The following entries will be deleted" $COUNT`:" + OPTION='' + fi + shift 2 + break + ;; + + --to-locale ) + if [[ $FILES == '--' ]];then + MESSAGE="`gettext "There is no file to locale."`" + OPTION='--as-error-line' + else + MESSAGE="`ngettext "Translatable strings will be retrived from the following entry" \ + "Translatable strings will be retrived from the following entries" $COUNT`:" + OPTION='' + fi + shift 2 + break + ;; + + --to-edit ) + if [[ $FILES == '--' ]];then + MESSAGE="`gettext "There is no file to edit."`" + OPTION='--as-error-line' + else + MESSAGE="`ngettext "The following file will be edited" \ + "The following files will be edited" $COUNT`:" + OPTION='' + fi + shift 2 + break + ;; + + -- ) + if [[ $FILES == '--' ]];then + MESSAGE="`gettext "There is no file to process."`" + OPTION='--as-error-line' + else + MESSAGE="`ngettext "The following file will be processed" \ + "The following files will be processed" $COUNT`:" + OPTION='' + fi + shift 1 + break + ;; + esac + done + + # Print out the preamble message. + cli_printMessage "${MESSAGE}" "${OPTION}" + for FILE in $FILES;do + cli_printMessage "$FILE" --as-response-line + done + cli_printMessage "`gettext "Do you want to continue"`" --as-yesornorequest-line + +} diff --git a/Scripts/Bash/Functions/Commons/cli_printCopyrightInfo.sh b/Scripts/Bash/Functions/Commons/cli_printCopyrightInfo.sh new file mode 100755 index 0000000..6f4e6e2 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_printCopyrightInfo.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# +# cli_printCopyrightInfo.sh -- This function standardizes the +# copyright information used 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. So, in that sake, I'll assume +# the same copyright information used by The CentOS Wiki +# (http://wiki.centos.org/) as reference. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printCopyrightInfo { + + case "$1" in + + --license ) + + # Print out the name of the license used by to release the + # content produced by centos-art.sh script, inside CentOS + # Artwork Repository. + echo "`gettext "Creative Common Attribution-ShareAlike 3.0 License"`" + ;; + + --license-url ) + + # Print out the url of the license used by to release the + # content produced by centos-art.sh script, inside CentOS + # Artwork Repository. + cli_printUrl --cc-sharealike + ;; + + --copyright-year-first ) + + # The former year when I (as part of The CentOS Project) + # started to consolidate The CentOS Project Corporate + # Visual Identity through the CentOS Artwork Repository. + echo '2009' + ;; + + --copyright-year|--copyright-year-last ) + + # 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 does never + # happen, so assume the current year as last working year. + date +%Y + ;; + + --copyright-year-range ) + + local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first') + local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last') + echo "${FIRST_YEAR}-${LAST_YEAR}" + ;; + + --copyright-year-list ) + + local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first') + local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last') + + # 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!, *$!!' + ;; + + --copyright-holder ) + + # Output default copyright holder. + echo "`gettext "The CentOS Project"`" + ;; + + --copyright-holder-predicate ) + + local HOLDER=$(cli_printCopyrightInfo '--copyright-holder') + echo "${HOLDER}. `gettext "All rights reserved."`" + ;; + + --copyright ) + + local YEAR=$(cli_printCopyrightInfo '--copyright-year-last') + local HOLDER=$(cli_printCopyrightInfo '--copyright-holder') + echo "Copyright © ${YEAR} ${HOLDER}" + ;; + + esac + +} diff --git a/Scripts/Bash/Functions/Commons/cli_printMessage.sh b/Scripts/Bash/Functions/Commons/cli_printMessage.sh new file mode 100755 index 0000000..93d7fcc --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_printMessage.sh @@ -0,0 +1,242 @@ +#!/bin/bash +# +# cli_printMessage.sh -- This function standardizes the way messages +# are printed out from centos-art.sh script. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printMessage { + + # Verify `--quiet' option. + if [[ "$FLAG_QUIET" == 'true' ]];then + return + fi + + local MESSAGE="$1" + local FORMAT="$2" + + # Verify message variable, it cannot have an empty value. + if [[ $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 + + # Reverse the codification performed on characters that may affect + # parsing options and non-option arguments. This codification is + # realized before building the ARGUMENTS variable, at + # cli_parseArgumentsReDef, and we need to reverse it back here + # in order to show the correct character when the message be + # printed out on the screen. + MESSAGE=$(echo $MESSAGE | sed -e "s/\\\0x27/'/g") + + # Remove empty spaces from message. + MESSAGE=$(echo $MESSAGE | sed -e 's!^[[:space:]]+!!') + + # Print out messages based on format. + case "$FORMAT" in + + --as-separator-line ) + + # Build the separator line. + MESSAGE=$(\ + until [[ $MESSAGE_WIDTH -eq 0 ]];do + echo -n "$MESSAGE" + MESSAGE_WIDTH=$(($MESSAGE_WIDTH - 1)) + done) + + # Draw the separator line. + echo "$MESSAGE" > /dev/stderr + ;; + + --as-banner-line ) + cli_printMessage '-' --as-separator-line + cli_printMessage "$MESSAGE" + cli_printMessage '-' --as-separator-line + ;; + + --as-cropping-line ) + cli_printMessage "`gettext "Cropping from"`: $MESSAGE" + ;; + + --as-tuningup-line ) + cli_printMessage "`gettext "Tuning-up"`: $MESSAGE" + ;; + + --as-checking-line ) + cli_printMessage "`gettext "Checking"`: $MESSAGE" + ;; + + --as-creating-line | --as-updating-line ) + if [[ -a "$MESSAGE" ]];then + cli_printMessage "`gettext "Updating"`: $MESSAGE" + else + cli_printMessage "`gettext "Creating"`: $MESSAGE" + fi + ;; + + --as-deleting-line ) + cli_printMessage "`gettext "Deleting"`: $MESSAGE" + ;; + + --as-reading-line ) + cli_printMessage "`gettext "Reading"`: $MESSAGE" + ;; + + --as-savedas-line ) + cli_printMessage "`gettext "Saved as"`: $MESSAGE" + ;; + + --as-linkto-line ) + cli_printMessage "`gettext "Linked to"`: $MESSAGE" + ;; + + --as-movedto-line ) + cli_printMessage "`gettext "Moved to"`: $MESSAGE" + ;; + + --as-translation-line ) + cli_printMessage "`gettext "Translation"`: $MESSAGE" + ;; + + --as-validating-line ) + cli_printMessage "`gettext "Validating"`: $MESSAGE" + ;; + + --as-template-line ) + cli_printMessage "`gettext "Template"`: $MESSAGE" + ;; + + --as-configuration-line ) + cli_printMessage "`gettext "Configuration"`: $MESSAGE" + ;; + + --as-palette-line ) + cli_printMessage "`gettext "Palette"`: $MESSAGE" + ;; + + --as-response-line ) + cli_printMessage "--> $MESSAGE" + ;; + + --as-request-line ) + cli_printMessage "${MESSAGE}:\040" --as-notrailingnew-line + ;; + + --as-selection-line ) + local NAME='' + select NAME in ${MESSAGE};do + echo $NAME + break + done + ;; + + --as-error-line ) + # Define where the error was originated inside the + # centos-art.sh script. Print out the function name and + # line from the caller. + local ORIGIN="$(caller 1 | gawk '{ print $2 " " $1 }')" + + # Build the error message. + cli_printMessage "${CLI_NAME} (${ORIGIN}): $MESSAGE" --as-stderr-line + cli_printMessage "${CLI_FUNCDIRNAM}" --as-toknowmore-line + ;; + + --as-toknowmore-line ) + cli_printMessage '-' --as-separator-line + cli_printMessage "`gettext "To know more, run the following command"`:" + cli_printMessage "centos-art help --read trunk/Scripts/Functions/$MESSAGE" + cli_printMessage '-' --as-separator-line + exit # <-- ATTENTION: Do not remove this line. We use this + # option as convenction to end script + # execution. + ;; + + --as-yesornorequest-line ) + # Define positive answer. + local Y="`gettext "yes"`" + + # Define negative answer. + local N="`gettext "no"`" + + # Define default answer. + local ANSWER=${N} + + if [[ $FLAG_ANSWER == 'true' ]];then + + ANSWER=${Y} + + else + + # Print the question. + cli_printMessage "$MESSAGE [${Y}/${N}]:\040" --as-notrailingnew-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 possitive answer is passed, the script + # terminates its execution immediatly. + if [[ ! ${ANSWER} =~ "^${Y}" ]];then + exit + fi + ;; + + --as-notrailingnew-line ) + echo -e -n "$MESSAGE" > /dev/stderr + ;; + + --as-stdout-line ) + echo "$MESSAGE" + ;; + + --as-stderr-line ) + echo "$MESSAGE" + ;; + + * ) + + # 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!${CLI_WRKCOPY}/(trunk|branches|tags)/!\1/!g" \ + | awk 'BEGIN { FS=": " } + { + if ( $0 ~ /^-+$/ ) + print $0 + else + printf "%-15s\t%s\n", $1, $2 + } + END {}' > /dev/stderr + ;; + + esac + +} diff --git a/Scripts/Bash/Functions/Commons/cli_printUrl.sh b/Scripts/Bash/Functions/Commons/cli_printUrl.sh new file mode 100755 index 0000000..5994d8d --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_printUrl.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# +# cli_printUrl.sh -- This function standardize the way URLs are +# printed inside 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. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printUrl { + + local URL='' + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='home,lists,wiki,forums,bugs,planet,docs,mirrors,irc,projects,projects-artwork,cc-sharealike,with-locale,as-html-link' + + # Define ARGUMENTS as local variable in order to parse options + # internlally. + local ARGUMENTS='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + --home ) + URL='http://www.centos.org/' + shift 1 + ;; + + --lists ) + URL='http://lists.centos.org/' + shift 1 + ;; + + --wiki ) + URL='http://wiki.centos.org/' + shift 1 + ;; + + --forums ) + URL='http://forums.centos.org/' + shift 1 + ;; + + --bugs ) + URL='http://bugs.centos.org/' + shift 1 + ;; + + --projects ) + URL='https://projects.centos.org/' + shift 1 + ;; + + --projects-artwork ) + URL=$(cli_printUrl '--projects')svn/artwork/ + shift 1 + ;; + + --planet ) + URL='http://planet.centos.org/' + shift 1 + ;; + + --docs ) + URL='http://docs.centos.org/' + shift 1 + ;; + + --mirrors ) + URL='http://mirrors.centos.org/' + shift 1 + ;; + + --irc ) + URL='http://www.centos.org/modules/tinycontent/index.php?id=8' + shift 1 + ;; + + --cc-sharealike ) + URL="http://creativecommons.org/licenses/by-sa/3.0/" + shift 1 + ;; + + --with-locale ) + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + URL="${URL}$(cli_getCurrentLocale '--langcode-only')/" + fi + shift 1 + ;; + + --as-html-link ) + URL="${URL}" + shift 1 + ;; + + -- ) + + shift 1 + break + ;; + esac + done + + # Print Url. + echo "$URL" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_syncroRepoChanges.sh b/Scripts/Bash/Functions/Commons/cli_syncroRepoChanges.sh new file mode 100755 index 0000000..168ee6b --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_syncroRepoChanges.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# cli_syncroRepoChanges.sh -- This function syncronizes both central +# repository and working copy performing a subversion update command +# first and a subversion commit command later. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_syncroRepoChanges { + + # Verify don't commit changes flag. + if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then + return + fi + + # Define source location the subversion update action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Bring changes from the repository into the working copy. + cli_updateRepoChanges "$LOCATIONS" + + # Check changes in the working copy. + cli_commitRepoChanges "$LOCATIONS" + +} diff --git a/Scripts/Bash/Functions/Commons/cli_terminateScriptExecution.sh b/Scripts/Bash/Functions/Commons/cli_terminateScriptExecution.sh new file mode 100755 index 0000000..f342034 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_terminateScriptExecution.sh @@ -0,0 +1,51 @@ +#!/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. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_terminateScriptExecution { + + # Build list of temporal files related to this script execution. + # Remember that inside `/tmp' directory there are files and + # directories you might have no access to (due permission + # restrictions), so command cli_getFilesList to look for files in + # the first level of files that you are owner of. Otherwise, + # undesired `permission denied' messages might be output. + local FILES=$(cli_getFilesList ${CLI_TEMPDIR} \ + --pattern="${CLI_NAME}-${CLI_PPID}-.+" \ + --maxdepth="1" --uid="$(id -u)") + + # Remove list of temporal files related to this script execution, + # if any of course. Remember that some of the temporal files can + # be directories, too. + if [[ $FILES != '' ]];then + rm -rf $FILES + fi + + # Terminate script correctly. + exit 0 + +} diff --git a/Scripts/Bash/Functions/Commons/cli_unsetFunctions.sh b/Scripts/Bash/Functions/Commons/cli_unsetFunctions.sh new file mode 100755 index 0000000..9bf4e4b --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_unsetFunctions.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# cli_unsetFunctions.sh -- This function unsets funtionalities from +# `centos-art.sh' script execution evironment. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_unsetFunctions { + + # Define source location where function files are placed in. + local LOCATION=$1 + + # Define suffix used to retrive function files. + local SUFFIX=$2 + + # Verify suffix value used to retrive function files. Assuming no + # suffix value is passed as second argument to this function, use + # the function name value (CLI_FUNCNAME) as default value. + if [[ $SUFFIX == '' ]];then + SUFFIX=$CLI_FUNCNAME + 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 FUNCDEF='' + local FUNCDEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${SUFFIX}") + + # Unset function names from current execution environment. + for FUNCDEF in $FUNCDEFS;do + unset -f $FUNCDEF + done + +} diff --git a/Scripts/Bash/Functions/Commons/cli_updateRepoChanges.sh b/Scripts/Bash/Functions/Commons/cli_updateRepoChanges.sh new file mode 100755 index 0000000..78a6ad4 --- /dev/null +++ b/Scripts/Bash/Functions/Commons/cli_updateRepoChanges.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# cli_updateRepoChanges.sh -- This function realizes a subversion +# update command against the working copy in order to bring changes +# from the central repository into the working copy. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_updateRepoChanges { + + # Verify don't commit changes flag. + if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then + return + fi + + local -a FILES + local -a INFO + local -a FILESNUM + local COUNT=0 + local UPDATEOUT='' + local PREDICATE='' + local CHNGTOTAL=0 + local LOCATIONS='' + + # Define source location the subversion update action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Update working copy and retrive update output. + cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" --as-banner-line + UPDATEOUT=$(svn update ${LOCATIONS}) + + # Define path of files considered recent modifications from + # central repository to working copy. + FILES[0]=$(echo "$UPDATEOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[1]=$(echo "$UPDATEOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[2]=$(echo "$UPDATEOUT" | egrep "^U.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[3]=$(echo "$UPDATEOUT" | egrep "^C.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[4]=$(echo "$UPDATEOUT" | egrep "^G.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + + # Define description of files considered recent modifications from + # central repository to working copy. + INFO[0]="`gettext "Added"`" + INFO[1]="`gettext "Deleted"`" + INFO[2]="`gettext "Updated"`" + INFO[3]="`gettext "Conflicted"`" + INFO[4]="`gettext "Merged"`" + + while [[ $COUNT -ne ${#FILES[*]} ]];do + + # Define total number of files. Avoid counting empty line. + if [[ "${FILES[$COUNT]}" == '' ]];then + FILESNUM[$COUNT]=0 + else + FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) + fi + + # Calculate total amount of changes. + CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) + + # Build report predicate. Use report predicate to show any + # information specific to the number of files found. For + # example, you can use this section to show warning messages, + # notes, and so on. By default we use the word `file' or + # `files' at ngettext's consideration followed by change + # direction. + PREDICATE[$COUNT]=`ngettext "file from the repository" \ + "files from the repository" $((${FILESNUM[$COUNT]} + 1))` + + # Output report line. + cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Scripts/Bash/Functions/cli.sh b/Scripts/Bash/Functions/cli.sh deleted file mode 100755 index e9f1acb..0000000 --- a/Scripts/Bash/Functions/cli.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# -# cli.sh -- This function initiates centos-art command-line interface. -# Variables defined in this function are accesible by all other -# functions. The cli function is the first script executed by -# centos-art command-line onces invoked. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli { - - # Initialize global variables. - local CLI_FUNCNAME='' - local CLI_FUNCDIR='' - local CLI_FUNCDIRNAM='' - local CLI_FUNCSCRIPT='' - local ARGUMENTS='' - - # Initialize default value to filter flag. The filter flag - # (--filter) is used mainly to reduce the number of files to - # process. The value of this variable is interpreted as - # egrep-posix regular expression. By default, everything matches. - local FLAG_FILTER='.+' - - # Initialize default value to verbosity flag. The verbosity flag - # (--quiet) controls whether centos-art.sh script prints messages - # or not. By default, all messages are printed out. - local FLAG_QUIET='false' - - # Initialize default value to answer flag. The answer flag - # (--answer-yes) controls whether centos-art.sh script does or - # does not pass confirmation request points. By default, it - # doesn't. - local FLAG_ANSWER='false' - - # Initialize default value to don't commit changes flag. The don't - # commit changes flag (--dont-commit-changes) controls whether - # centos-art.sh script syncronizes changes between the central - # repository and the working copy. By default, it does. - local FLAG_DONT_COMMIT_CHANGES='false' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Define function directory (CLI_FUNCDIR). The directory path where - # functionalities are stored inside the repository. - CLI_FUNCDIR=${CLI_BASEDIR}/Functions - - # Check function name. The function name is critical for - # centos-art.sh script to do something coherent. If it is not - # provided, execute the help functionality and end script - # execution. - if [[ "$1" == '' ]];then - exec ${CLI_BASEDIR}/centos-art.sh help - exit - fi - - # Define function name (CLI_FUNCNAME) variable from first command-line - # argument. As convenction we use the first argument to determine - # the exact name of functionality to call. - CLI_FUNCNAME=$(cli_getRepoName $1 -f) - - # Define function directory. - CLI_FUNCDIRNAM=$(cli_getRepoName $CLI_FUNCNAME -d) - - # Define function file name. - CLI_FUNCSCRIPT=${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}/${CLI_FUNCNAME}.sh - - # Check function script execution rights. - cli_checkFiles "${CLI_FUNCSCRIPT}" --execution - - # 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 - - # Redefine ARGUMENTS using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Define default text editors used by centos-art.sh script. - if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then - EDITOR='/usr/bin/vim' - fi - - # Check text editor execution rights. - cli_checkFiles $EDITOR --execution - - # Go for function initialization. Keep the cli_exportFunctions - # function calling after all variables and arguments definitions. - cli_exportFunctions "${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}" - - # Execute function. - eval $CLI_FUNCNAME - -} diff --git a/Scripts/Bash/Functions/cli_checkFiles.sh b/Scripts/Bash/Functions/cli_checkFiles.sh deleted file mode 100755 index 56df0bb..0000000 --- a/Scripts/Bash/Functions/cli_checkFiles.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/bash -# -# cli_checkFiles.sh -- This function standardizes the way file -# conditional expressions are applied inside centos-art.sh script. -# Here is where we answer 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 ends its -# execution. -# -# More than one file can be passed to this function, so we want to -# process them all as specified by the options. Since we are using -# getopt output it is possible to determine where options and -# non-option arguments are in the list of arguments (e.g., options -# are on the left side of ` -- ' and non-options on the rigth side of -# ` -- '). Non-options are the files we want to verify and options how -# we want to verify them. -# -# Another issue to consider, when more than one file is passed to this -# function, is that we cannot shift positional parameters as we -# frequently do whe just one argument is passsed, doing so would -# annulate the validation for the second and later files passed to the -# function. So, in order to provide verification to all files passed -# to the function, the verification loop must be set individual for -# each option in this function. -# -# Assuming no option be passed to the function, a general verification -# is performed to determine whether or not the file exists without -# considering the file type just its existence. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkFiles { - - # Define short options. - local ARGSS='d,r,h,n,x,w' - - # Define long options. - local ARGSL='directory,regular-file,symbolic-link,execution,versioned,working-copy' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize file variable as local to avoid conflicts outside - # this function scope. In the file variable will set the file path - # we'r going to verify. - local FILE='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Define list of files we want to apply verifications to. - local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') - - # Verify files in the list. It is required at least one. - if [[ $FILES =~ '--$' ]];then - cli_printMessage "You need to provide one file at least." --as-error-line - fi - - # Look for options passed through positional parameters. - while true; do - - case "$1" in - - -d|--directory ) - for FILE in $(echo $FILES);do - if [[ ! -d $FILE ]];then - cli_printMessage "`eval_gettext "The directory \\\"\\\$FILE\\\" does not exist."`" --as-error-line - fi - done - shift 1 - ;; - - -f|--regular-file ) - for FILE in $(echo $FILES);do - if [[ ! -f $FILE ]];then - cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" --as-error-line - fi - done - shift 1 - ;; - - -h|--symbolic-link ) - for FILE in $(echo $FILES);do - if [[ ! -h $FILE ]];then - cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" --as-error-line - fi - done - shift 1 - ;; - - -n|--versioned ) - for FILE in $(echo $FILES);do - if [[ $(cli_isVersioned $FILE) == 'false' ]];then - cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" is not versioned."`" --as-error-line - fi - done - shift 1 - ;; - - -x|--execution ) - for FILE in $(echo $FILES);do - if [[ ! -x $FILE ]];then - cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" --as-error-line - fi - done - shift 1 - ;; - - -w|--working-copy ) - for FILE in $(echo $FILES);do - if [[ ! $FILE =~ "^${CLI_WRKCOPY}/.+$" ]];then - cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist inside the working copy."`" --as-error-line - fi - done - shift 1 - ;; - - -- ) - for FILE in $(echo $FILES);do - if [[ ! -a $FILE ]];then - cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist."`" --as-error-line - fi - done - shift 1 - break - ;; - - esac - done - -} diff --git a/Scripts/Bash/Functions/cli_checkPathComponent.sh b/Scripts/Bash/Functions/cli_checkPathComponent.sh deleted file mode 100755 index 182850a..0000000 --- a/Scripts/Bash/Functions/cli_checkPathComponent.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# -# cli_checkPathComponent.sh -- This function checks parts/components -# from repository paths. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkPathComponent { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='release,architecture,motif' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize file variable as local to avoid conflicts outside - # this function scope. In the file variable will set the file path - # we are going to verify. - local FILE='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Define list of locations we want to apply verifications to. - local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') - - # Verify list of locations, it is required that one location be - # present in the list and also be a valid file. - if [[ $FILES == '--' ]];then - cli_printMessage "You need to provide one file at least." --as-error-line - fi - - # Look for options passed through positional parameters. - while true; do - - case "$1" in - - --release ) - for FILE in $(echo $FILES);do - if [[ ! $FILE =~ "^.+/$(cli_getPathComponent --release-pattern)/.*$" ]];then - cli_printMessage "`eval_gettext "The release \\\"\\\$FILE\\\" is not valid."`" --as-error-line - fi - done - shift 2 - break - ;; - - --architecture ) - for FILE in $(echo $FILES);do - if [[ ! $FILE =~ $(cli_getPathComponent --architecture-pattern) ]];then - cli_printMessage "`eval_gettext "The architecture \\\"\\\$FILE\\\" is not valid."`" --as-error-line - fi - done - shift 2 - break - ;; - - --motif ) - for FILE in $(echo $FILES);do - if [[ ! $FILE =~ $(cli_getPathComponent --motif-pattern) ]];then - cli_printMessage "`eval_gettext "The theme \\\"\\\$FILE\\\" is not valid."`" --as-error-line - fi - done - shift 2 - break - ;; - - -- ) - for FILE in $(echo $FILES);do - if [[ $FILE == '' ]] \ - || [[ $FILE =~ '(\.\.(/)?)' ]] \ - || [[ ! $FILE =~ '^[A-Za-z0-9\.:/_-]+$' ]]; then - cli_printMessage "`eval_gettext "The value \\\"\\\$FILE\\\" is not valid."`" --as-error-line - fi - done - shift 2 - break - ;; - - esac - done - -} diff --git a/Scripts/Bash/Functions/cli_checkRepoDirSource.sh b/Scripts/Bash/Functions/cli_checkRepoDirSource.sh deleted file mode 100755 index 7090848..0000000 --- a/Scripts/Bash/Functions/cli_checkRepoDirSource.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -# -# cli_checkRepoDirSource.sh -- This function provides input validation -# to repository entries considered as source locations. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkRepoDirSource { - - - # Define location in order to make this function reusable not just - # for action value variable but whatever value passed as first - # positional argument. - local LOCATION=$1 - - # Verify location. Assuming no location is passed as first - # positional parameter to this function, print an error message - # and stop script execution. - if [[ "$LOCATION" == '' ]];then - cli_printMessage "`gettext "The first positional parameter is required."`" --as-error-line - fi - - # Check action value to be sure strange characters are kept far - # away from path provided. - cli_checkPathComponent $LOCATION - - # Redefine source value to build repository absolute path from - # repository top level on. As we are removing - # /home/centos/artwork/ from all centos-art.sh output (in order to - # save horizontal output space), we need to be sure that all - # strings begining with trunk/..., branches/..., and tags/... use - # the correct absolute path. That is, you can refer trunk's - # entries using both /home/centos/artwork/trunk/... or just - # trunk/..., the /home/centos/artwork/ part is automatically added - # here. - if [[ $LOCATION =~ '^(trunk|branches|tags)' ]];then - LOCATION=${CLI_WRKCOPY}/$LOCATION - fi - - # Re-define source value to build repository absolute path from - # repository relative paths. This let us to pass repository - # relative paths as source value. Passing relative paths as - # source value may save us some typing; specially if we are stood - # a few levels up from the location we want to refer to as source - # value. There is no need to pass the absolute path to it, just - # refere it relatively. - if [[ -d ${LOCATION} ]];then - - # Add directory to the top of the directory stack. - pushd "$LOCATION" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${CLI_WRKCOPY}" ]];then - # Re-define source value using absolute path. - LOCATION=$(pwd) - else - cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line - fi - - # Remove directory from the directory stack. - popd > /dev/null - - elif [[ -f ${LOCATION} ]];then - - # Add directory to the top of the directory stack. - pushd "$(dirname "$LOCATION")" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${CLI_WRKCOPY}" ]];then - # Re-define source value using absolute path. - LOCATION=$(pwd)/$(basename "$LOCATION") - else - cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line - fi - - # Remove directory from the directory stack. - popd > /dev/null - - fi - - # Output sanitated location. - echo $LOCATION - -} diff --git a/Scripts/Bash/Functions/cli_checkRepoDirTarget.sh b/Scripts/Bash/Functions/cli_checkRepoDirTarget.sh deleted file mode 100755 index b688c12..0000000 --- a/Scripts/Bash/Functions/cli_checkRepoDirTarget.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# cli_checkRepoDirTarget.sh -- This function provides input validation -# to repository entries considered as target location. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkRepoDirTarget { - - local LOCATION="$1" - - # Redefine target value to build repository absolute path from - # repository top level on. As we are removing - # /home/centos/artwork/ from all centos-art.sh output (in order to - # save horizontal output space), we need to be sure that all - # strings begining with trunk/..., branches/..., and tags/... use - # the correct absolute path. That is, you can refer trunk's - # entries using both /home/centos/artwork/trunk/... or just - # trunk/..., the /home/centos/artwork/ part is automatically added - # here. - if [[ $LOCATION =~ '^(trunk|branches|tags)/.+$' ]];then - LOCATION=${CLI_WRKCOPY}/$LOCATION - fi - - # Print target location. - echo $LOCATION - -} diff --git a/Scripts/Bash/Functions/cli_commitRepoChanges.sh b/Scripts/Bash/Functions/cli_commitRepoChanges.sh deleted file mode 100755 index e3a7dc9..0000000 --- a/Scripts/Bash/Functions/cli_commitRepoChanges.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash -# -# cli_commitRepoChanges.sh -- This function realizes a subversion -# commit command agains the workgin copy in order to send local -# changes up to central repository. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_commitRepoChanges { - - # Verify `--dont-commit-changes' option. - if [[ $FLAG_DONT_COMMIT_CHANGES == 'true' ]];then - return - fi - - local -a FILES - local -a INFO - local -a FILESNUM - local COUNT=0 - local STATUSOUT='' - local PREDICATE='' - local CHNGTOTAL=0 - local LOCATIONS='' - local LOCATION='' - - # Define source location the subversion status action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Print action message. - cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line - - # Build list of files that have received changes in its versioned - # status. Be sure to keep output files off from this list. - # Remember, output files are not versioned inside the working - # copy, so they are not considered for evaluation here. But take - # care, sometimes output files are in the same format of source - # files, so we need to differentiate them using their locations. - for LOCATION in $LOCATIONS;do - - # Don't process location outside of version control. - if [[ $(cli_isVersioned $LOCATION) == 'false' ]];then - continue - fi - - # Process location based on its path information. - if [[ $LOCATION =~ '(trunk/Manuals/Tcar-fs|branches/Manuals/Texinfo)' ]];then - STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|txt|xhtml|xml|docbook|bz2)$')\n$STATUSOUT" - elif [[ $LOCATION =~ 'trunk/Manuals' ]];then - STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|txt|xhtml)$')\n$STATUSOUT" - elif [[ $LOCATION =~ 'trunk/Identity' ]];then - STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|png|jpg|rc|xpm|xbm|tif|ppm|pnm|gz|lss|log)$')\n$STATUSOUT" - else - STATUSOUT="$(svn status ${LOCATION})\n$STATUSOUT" - fi - - done - - # Sanitate status output. Expand new lines, remove leading spaces - # and empty lines. - STATUSOUT=$(echo -e "$STATUSOUT" | sed -r 's!^[[:space:]]*!!' | egrep -v '^[[:space:]]*$') - - # Define path fo files considered recent modifications from - # working copy up to central repository. - FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - - # Define description of files considered recent modifications from - # working copy up to central repository. - INFO[0]="`gettext "Modified"`" - INFO[1]="`gettext "Unversioned"`" - INFO[2]="`gettext "Deleted"`" - INFO[3]="`gettext "Added"`" - - while [[ $COUNT -ne ${#FILES[*]} ]];do - - # Define total number of files. Avoid counting empty line. - if [[ "${FILES[$COUNT]}" == '' ]];then - FILESNUM[$COUNT]=0 - else - FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) - fi - - # Calculate total amount of changes. - CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) - - # Build report predicate. Use report predicate to show any - # information specific to the number of files found. For - # example, you can use this section to show warning messages, - # notes, and so on. By default we use the word `file' or - # `files' at ngettext's consideration followed by change - # direction. - PREDICATE[$COUNT]=`ngettext "file in the working copy" \ - "files in the working copy" $((${FILESNUM[$COUNT]} + 1))` - - # Output report line. - cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # Check total amount of changes and, if any, check differences and - # commit them up to central repository. - if [[ $CHNGTOTAL -gt 0 ]];then - - # Outout separator line. - cli_printMessage '-' --as-separator-line - - # In the very specific case unversioned files, we need to add - # them to the repository first, in order to make them - # available for subversion commands (e.g., `copy') Otherwise, - # if no unversioned file is found, go ahead with change - # differences and committing. Notice that if there is mix of - # changes (e.g., aditions and modifications), addition take - # preference and no other change is considered. In order - # for other changes to be considered, be sure no adition is - # present, or that they have already happened. - if [[ ${FILESNUM[1]} -gt 0 ]];then - - cli_printMessage "`ngettext "The following file is unversioned" \ - "The following files are unversioned" ${FILESNUM[1]}`:" - for FILE in ${FILES[1]};do - cli_printMessage "$FILE" --as-response-line - done - cli_printMessage "`ngettext "Do you want to add it now?" \ - "Do you want to add them now?" ${FILESNUM[1]}`" --as-yesornorequest-line - svn add ${FILES[1]} --quiet - - else - - # Verify changes on locations. - cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line - svn diff $LOCATIONS | less - - # Commit changes on locations. - cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line - svn commit $LOCATIONS - - fi - - fi - -} diff --git a/Scripts/Bash/Functions/cli_expandTMarkers.sh b/Scripts/Bash/Functions/cli_expandTMarkers.sh deleted file mode 100755 index 1bf6c1d..0000000 --- a/Scripts/Bash/Functions/cli_expandTMarkers.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/bash -# -# cli_expandTMarkers.sh -- This function standardizes -# replacements for common translation markers. Raplacements are -# applied to temporal instances used to produce the final file. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_expandTMarkers { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - local COUNTSRC=0 - local COUNTDST=0 - local LOCATION='' - - # Define source location on which sed replacements take place. - LOCATION="$1" - - # Verify file source location. - cli_checkFiles $LOCATION - - # Define copyright translation markers. - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LAST=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LIST=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year-list)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-holder)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER_PREDICATE=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-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_IRC=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--irc') - - # Define emails translation markers. - SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' - DST[((++${#DST[*]}))]="centos-docs@centos.org" - SRC[((++${#SRC[*]}))]='=MAIL_L10N=' - DST[((++${#DST[*]}))]="centos-l10n@centos.org" - - # Define locale translation markers. - SRC[((++${#SRC[*]}))]='=LOCALE_LL=' - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')" - SRC[((++${#SRC[*]}))]='=LOCALE=' - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale)" - - # Define domain translation markers for domains. - SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')." - else - DST[((++${#DST[*]}))]="" - fi - - # Define repository translation markers. - SRC[((++${#SRC[*]}))]='=REPO_TLDIR=' - DST[((++${#DST[*]}))]="$(cli_getRepoTLDir)" - SRC[((++${#SRC[*]}))]='=REPO_HOME=' - DST[((++${#DST[*]}))]="${CLI_WRKCOPY}" - - # 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 - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may ramain from one file to another. - unset SRC - unset DST - -} diff --git a/Scripts/Bash/Functions/cli_exportFunctions.sh b/Scripts/Bash/Functions/cli_exportFunctions.sh deleted file mode 100755 index 2a85602..0000000 --- a/Scripts/Bash/Functions/cli_exportFunctions.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# cli_exportFunctions.sh -- This function exports funtionalities to -# `centos-art.sh' script execution evironment. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_exportFunctions { - - # Define source location where function files are placed in. - local LOCATION=$1 - - # Define suffix used to retrive function files. - local SUFFIX=$2 - - # Verify suffix value used to retrive function files. Assuming no - # suffix value is passed as second argument to this function, use - # the function name value (CLI_FUNCNAME) as default value. - if [[ $SUFFIX == '' ]];then - SUFFIX=$CLI_FUNCNAME - fi - - # Define pattern used to retrive function names from function - # files. - local PATTERN="^function[[:space:]]+${SUFFIX}[[:alnum:]_]*[[:space:]]+{$" - - # Define list of files. - local FUNCFILE='' - local FUNCFILES=$(cli_getFilesList ${LOCATION} --pattern="${SUFFIX}.*\.sh" --maxdepth="1") - - # Verify 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 [[ $FUNCFILES == '' ]];then - cli_printMessage "`gettext "No function file was found for this action."`" --as-error-line - fi - - # Process list of files. - for FUNCFILE in $FUNCFILES;do - - # Verify file execution rights. - cli_checkFiles $FUNCFILE --execution - - # Initialize file. - . $FUNCFILE - - # Export function names inside the file to current shell - # script environment. - export -f $(egrep "${PATTERN}" ${FUNCFILE} | gawk '{ print $2 }') - - done - -} diff --git a/Scripts/Bash/Functions/cli_getConfigLines.sh b/Scripts/Bash/Functions/cli_getConfigLines.sh deleted file mode 100755 index 248d4cf..0000000 --- a/Scripts/Bash/Functions/cli_getConfigLines.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# cli_getConfigLines.sh -- This function retrives configuration lines -# form configuration files. As arguments, the configuration file -# absolute path, the configuration section name, and the configuration -# variable name must be provided. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getConfigLines { - - # Initialize absolute path to configuration file. - local CONFIG_ABSPATH="$1" - - # Verify absolute path to configuration file. - cli_checkFiles ${CONFIG_ABSPATH} - - # Initialize configuration section name where the variable value - # we want to to retrive is set in. - local CONFIG_SECTION="$2" - - # Initialize variable name we want to retrive value from. - local CONFIG_VARNAME="$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 begining of the line. - if [[ ! $CONFIG_VARNAME =~ '^[[:alnum:]_./-]+$' ]];then - CONFIG_VARNAME='[[:alnum:]_./-]+=' - fi - - # Retrive configuration lines from configuration file. - local CONFIG_LINES=$(cat ${CONFIG_ABSPATH} \ - | egrep -v '^#' \ - | egrep -v '^[[:space:]]*$' \ - | sed -r 's![[:space:]]*!!g' \ - | sed -r -n "/^\[${CONFIG_SECTION}\]$/,/^\[/p" \ - | egrep -v '^\[' | sort | uniq \ - | egrep "^${CONFIG_VARNAME}") - - # Output value related to variable name. - echo "$CONFIG_LINES" - -} diff --git a/Scripts/Bash/Functions/cli_getConfigValue.sh b/Scripts/Bash/Functions/cli_getConfigValue.sh deleted file mode 100755 index 4b54ec6..0000000 --- a/Scripts/Bash/Functions/cli_getConfigValue.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# cli_getConfigValue.sh -- This function retrives configuration values -# from configuration files. As arguments, the configuration file -# absolute path, the configuration section name, and the configuration -# variable name must be provided. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getConfigValue { - - # Initialize absolute path to configuration file. - local CONFIG_ABSPATH="$1" - - # Initialize configuration section name where the variable value - # we want to to retrive is set in. - local CONFIG_SECTION="$2" - - # Initialize variable name we want to retrive value from. - local CONFIG_VARNAME="$3" - - # Retrive configuration lines from configuration file. - local CONFIG_LINES=$(cli_getConfigLines \ - "$CONFIG_ABSPATH" "$CONFIG_SECTION" "$CONFIG_VARNAME") - - # Parse configuration lines to retrive the values of variable - # names. - local CONFIG_VARVALUE=$(echo $CONFIG_LINES \ - | gawk 'BEGIN { FS="=" } { print $2 }' \ - | sed -r 's/^"(.*)"$/\1/') - - # Output values related to variable name. - echo "$CONFIG_VARVALUE" - -} diff --git a/Scripts/Bash/Functions/cli_getCountryCodes.sh b/Scripts/Bash/Functions/cli_getCountryCodes.sh deleted file mode 100755 index a521486..0000000 --- a/Scripts/Bash/Functions/cli_getCountryCodes.sh +++ /dev/null @@ -1,276 +0,0 @@ -#!/bin/bash -# -# cli_getCountryCodes.sh -- This function outputs a list with country -# codes as defined in ISO3166 standard. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCountryCodes { - - local FILTER="$(echo $1 | cut -d_ -f2)" - - COUNTRYCODES='AD - AE - AF - AG - AI - AL - AM - AN - AO - AQ - AR - AS - AT - AU - AW - AZ - BA - BB - BD - BE - BF - BG - BH - BI - BJ - BM - BN - BO - BR - BS - BT - BV - BW - BY - BZ - CA - CC - CD - CF - CG - CH - CI - CK - CL - CM - CN - CO - CR - CS - CU - CV - CX - CY - CZ - DE - DJ - DK - DM - DO - DZ - EC - EE - EG - EH - ER - ES - ET - FI - FJ - FK - FM - FO - FR - GA - GB - GD - GE - GF - GH - GI - GL - GM - GN - GP - GQ - GR - GS - GT - GU - GW - GY - HK - HM - HN - HR - HT - HU - ID - IE - IL - IN - IO - IQ - IR - IS - IT - JM - JO - JP - KE - KG - KH - KI - KM - KN - KP - KR - KW - KY - KZ - LA - LB - LC - LI - LK - LR - LS - LT - LU - LV - LY - MA - MC - MD - MG - MH - MK - ML - MM - MN - MO - MP - MQ - MR - MS - MT - MU - MV - MW - MX - MY - MZ - NA - NC - NE - NF - NG - NI - NL - NO - NP - NR - NU - NZ - OM - PA - PE - PF - PG - PH - PK - PL - PM - PN - PR - PS - PT - PW - PY - QA - RE - RO - RU - RW - SA - SB - SC - SD - SE - SG - SH - SI - SJ - SK - SL - SM - SN - SO - SR - ST - SV - SY - SZ - TC - TD - TF - TG - TH - TJ - TK - TL - TM - TN - TO - TR - TT - TV - TW - TZ - UA - UG - UM - US - UY - UZ - VA - VC - VE - VG - VI - VN - VU - WF - WS - YE - YT - ZA - ZM - ZW' - - if [[ $FILTER != '' ]];then - echo $COUNTRYCODES | egrep "$FILTER" - else - echo "$COUNTRYCODES" - fi - -} diff --git a/Scripts/Bash/Functions/cli_getCountryName.sh b/Scripts/Bash/Functions/cli_getCountryName.sh deleted file mode 100755 index 0db8776..0000000 --- a/Scripts/Bash/Functions/cli_getCountryName.sh +++ /dev/null @@ -1,758 +0,0 @@ -#!/bin/bash -# -# cli_getCountryName.sh -- This function reads one language locale -# code in the format LL_CC and outputs the name of its related -# country. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCountryName { - - local LOCALECODE="$(echo $1 | cut -d_ -f2)" - local COUNTRYNAME="" - - case $LOCALECODE in - - 'AD' ) - COUNTRYNAME="`gettext "Andorra"`" - ;; - 'AE' ) - COUNTRYNAME="`gettext "United Arab Emirates"`" - ;; - 'AF' ) - COUNTRYNAME="`gettext "Afghanistan"`" - ;; - 'AG' ) - COUNTRYNAME="`gettext "Antigua and Barbuda"`" - ;; - 'AI' ) - COUNTRYNAME="`gettext "Anguilla"`" - ;; - 'AL' ) - COUNTRYNAME="`gettext "Albania"`" - ;; - 'AM' ) - COUNTRYNAME="`gettext "Armenia"`" - ;; - 'AN' ) - COUNTRYNAME="`gettext "Netherlands Antilles"`" - ;; - 'AO' ) - COUNTRYNAME="`gettext "Angola"`" - ;; - 'AQ' ) - COUNTRYNAME="`gettext "Antarctica"`" - ;; - 'AR' ) - COUNTRYNAME="`gettext "Argentina"`" - ;; - 'AS' ) - COUNTRYNAME="`gettext "Samoa (American)"`" - ;; - 'AT' ) - COUNTRYNAME="`gettext "Austria"`" - ;; - 'AU' ) - COUNTRYNAME="`gettext "Australia"`" - ;; - 'AW' ) - COUNTRYNAME="`gettext "Aruba"`" - ;; - 'AZ' ) - COUNTRYNAME="`gettext "Azerbaijan"`" - ;; - 'BA' ) - COUNTRYNAME="`gettext "Bosnia and Herzegovina"`" - ;; - 'BB' ) - COUNTRYNAME="`gettext "Barbados"`" - ;; - 'BD' ) - COUNTRYNAME="`gettext "Bangladesh"`" - ;; - 'BE' ) - COUNTRYNAME="`gettext "Belgium"`" - ;; - 'BF' ) - COUNTRYNAME="`gettext "Burkina Faso"`" - ;; - 'BG' ) - COUNTRYNAME="`gettext "Bulgaria"`" - ;; - 'BH' ) - COUNTRYNAME="`gettext "Bahrain"`" - ;; - 'BI' ) - COUNTRYNAME="`gettext "Burundi"`" - ;; - 'BJ' ) - COUNTRYNAME="`gettext "Benin"`" - ;; - 'BM' ) - COUNTRYNAME="`gettext "Bermuda"`" - ;; - 'BN' ) - COUNTRYNAME="`gettext "Brunei"`" - ;; - 'BO' ) - COUNTRYNAME="`gettext "Bolivia"`" - ;; - 'BR' ) - COUNTRYNAME="`gettext "Brazil"`" - ;; - 'BS' ) - COUNTRYNAME="`gettext "Bahamas"`" - ;; - 'BT' ) - COUNTRYNAME="`gettext "Bhutan"`" - ;; - 'BV' ) - COUNTRYNAME="`gettext "Bouvet Island"`" - ;; - 'BW' ) - COUNTRYNAME="`gettext "Botswana"`" - ;; - 'BY' ) - COUNTRYNAME="`gettext "Belarus"`" - ;; - 'BZ' ) - COUNTRYNAME="`gettext "Belize"`" - ;; - 'CA' ) - COUNTRYNAME="`gettext "Canada"`" - ;; - 'CC' ) - COUNTRYNAME="`gettext "Cocos (Keeling) Islands"`" - ;; - 'CD' ) - COUNTRYNAME="`gettext "Congo (Dem. Rep.)"`" - ;; - 'CF' ) - COUNTRYNAME="`gettext "Central African Rep."`" - ;; - 'CG' ) - COUNTRYNAME="`gettext "Congo (Rep.)"`" - ;; - 'CH' ) - COUNTRYNAME="`gettext "Switzerland"`" - ;; - 'CI' ) - COUNTRYNAME="`gettext "Co^te d'Ivoire"`" - ;; - 'CK' ) - COUNTRYNAME="`gettext "Cook Islands"`" - ;; - 'CL' ) - COUNTRYNAME="`gettext "Chile"`" - ;; - 'CM' ) - COUNTRYNAME="`gettext "Cameroon"`" - ;; - 'CN' ) - COUNTRYNAME="`gettext "China"`" - ;; - 'CO' ) - COUNTRYNAME="`gettext "Colombia"`" - ;; - 'CR' ) - COUNTRYNAME="`gettext "Costa Rica"`" - ;; - 'CS' ) - COUNTRYNAME="`gettext "Serbia and Montenegro"`" - ;; - 'CU' ) - COUNTRYNAME="`gettext "Cuba"`" - ;; - 'CV' ) - COUNTRYNAME="`gettext "Cape Verde"`" - ;; - 'CX' ) - COUNTRYNAME="`gettext "Christmas Island"`" - ;; - 'CY' ) - COUNTRYNAME="`gettext "Cyprus"`" - ;; - 'CZ' ) - COUNTRYNAME="`gettext "Czech Republic"`" - ;; - 'DE' ) - COUNTRYNAME="`gettext "Germany"`" - ;; - 'DJ' ) - COUNTRYNAME="`gettext "Djibouti"`" - ;; - 'DK' ) - COUNTRYNAME="`gettext "Denmark"`" - ;; - 'DM' ) - COUNTRYNAME="`gettext "Dominica"`" - ;; - 'DO' ) - COUNTRYNAME="`gettext "Dominican Republic"`" - ;; - 'DZ' ) - COUNTRYNAME="`gettext "Algeria"`" - ;; - 'EC' ) - COUNTRYNAME="`gettext "Ecuador"`" - ;; - 'EE' ) - COUNTRYNAME="`gettext "Estonia"`" - ;; - 'EG' ) - COUNTRYNAME="`gettext "Egypt"`" - ;; - 'EH' ) - COUNTRYNAME="`gettext "Western Sahara"`" - ;; - 'ER' ) - COUNTRYNAME="`gettext "Eritrea"`" - ;; - 'ES' ) - COUNTRYNAME="`gettext "Spain"`" - ;; - 'ET' ) - COUNTRYNAME="`gettext "Ethiopia"`" - ;; - 'FI' ) - COUNTRYNAME="`gettext "Finland"`" - ;; - 'FJ' ) - COUNTRYNAME="`gettext "Fiji"`" - ;; - 'FK' ) - COUNTRYNAME="`gettext "Falkland Islands"`" - ;; - 'FM' ) - COUNTRYNAME="`gettext "Micronesia"`" - ;; - 'FO' ) - COUNTRYNAME="`gettext "Faeroe Islands"`" - ;; - 'FR' ) - COUNTRYNAME="`gettext "France"`" - ;; - 'GA' ) - COUNTRYNAME="`gettext "Gabon"`" - ;; - 'GB' ) - COUNTRYNAME="`gettext "Britain (UK)"`" - ;; - 'GD' ) - COUNTRYNAME="`gettext "Grenada"`" - ;; - 'GE' ) - COUNTRYNAME="`gettext "Georgia"`" - ;; - 'GF' ) - COUNTRYNAME="`gettext "French Guiana"`" - ;; - 'GH' ) - COUNTRYNAME="`gettext "Ghana"`" - ;; - 'GI' ) - COUNTRYNAME="`gettext "Gibraltar"`" - ;; - 'GL' ) - COUNTRYNAME="`gettext "Greenland"`" - ;; - 'GM' ) - COUNTRYNAME="`gettext "Gambia"`" - ;; - 'GN' ) - COUNTRYNAME="`gettext "Guinea"`" - ;; - 'GP' ) - COUNTRYNAME="`gettext "Guadeloupe"`" - ;; - 'GQ' ) - COUNTRYNAME="`gettext "Equatorial Guinea"`" - ;; - 'GR' ) - COUNTRYNAME="`gettext "Greece"`" - ;; - 'GS' ) - COUNTRYNAME="`gettext "South Georgia and the South Sandwich Islands"`" - ;; - 'GT' ) - COUNTRYNAME="`gettext "Guatemala"`" - ;; - 'GU' ) - COUNTRYNAME="`gettext "Guam"`" - ;; - 'GW' ) - COUNTRYNAME="`gettext "Guinea-Bissau"`" - ;; - 'GY' ) - COUNTRYNAME="`gettext "Guyana"`" - ;; - 'HK' ) - COUNTRYNAME="`gettext "Hong Kong"`" - ;; - 'HM' ) - COUNTRYNAME="`gettext "Heard Island and McDonald Islands"`" - ;; - 'HN' ) - COUNTRYNAME="`gettext "Honduras"`" - ;; - 'HR' ) - COUNTRYNAME="`gettext "Croatia"`" - ;; - 'HT' ) - COUNTRYNAME="`gettext "Haiti"`" - ;; - 'HU' ) - COUNTRYNAME="`gettext "Hungary"`" - ;; - 'ID' ) - COUNTRYNAME="`gettext "Indonesia"`" - ;; - 'IE' ) - COUNTRYNAME="`gettext "Ireland"`" - ;; - 'IL' ) - COUNTRYNAME="`gettext "Israel"`" - ;; - 'IN' ) - COUNTRYNAME="`gettext "India"`" - ;; - 'IO' ) - COUNTRYNAME="`gettext "British Indian Ocean Territory"`" - ;; - 'IQ' ) - COUNTRYNAME="`gettext "Iraq"`" - ;; - 'IR' ) - COUNTRYNAME="`gettext "Iran"`" - ;; - 'IS' ) - COUNTRYNAME="`gettext "Iceland"`" - ;; - 'IT' ) - COUNTRYNAME="`gettext "Italy"`" - ;; - 'JM' ) - COUNTRYNAME="`gettext "Jamaica"`" - ;; - 'JO' ) - COUNTRYNAME="`gettext "Jordan"`" - ;; - 'JP' ) - COUNTRYNAME="`gettext "Japan"`" - ;; - 'KE' ) - COUNTRYNAME="`gettext "Kenya"`" - ;; - 'KG' ) - COUNTRYNAME="`gettext "Kyrgyzstan"`" - ;; - 'KH' ) - COUNTRYNAME="`gettext "Cambodia"`" - ;; - 'KI' ) - COUNTRYNAME="`gettext "Kiribati"`" - ;; - 'KM' ) - COUNTRYNAME="`gettext "Comoros"`" - ;; - 'KN' ) - COUNTRYNAME="`gettext "St Kitts and Nevis"`" - ;; - 'KP' ) - COUNTRYNAME="`gettext "Korea (North)"`" - ;; - 'KR' ) - COUNTRYNAME="`gettext "Korea (South)"`" - ;; - 'KW' ) - COUNTRYNAME="`gettext "Kuwait"`" - ;; - 'KY' ) - COUNTRYNAME="`gettext "Cayman Islands"`" - ;; - 'KZ' ) - COUNTRYNAME="`gettext "Kazakhstan"`" - ;; - 'LA' ) - COUNTRYNAME="`gettext "Laos"`" - ;; - 'LB' ) - COUNTRYNAME="`gettext "Lebanon"`" - ;; - 'LC' ) - COUNTRYNAME="`gettext "St Lucia"`" - ;; - 'LI' ) - COUNTRYNAME="`gettext "Liechtenstein"`" - ;; - 'LK' ) - COUNTRYNAME="`gettext "Sri Lanka"`" - ;; - 'LR' ) - COUNTRYNAME="`gettext "Liberia"`" - ;; - 'LS' ) - COUNTRYNAME="`gettext "Lesotho"`" - ;; - 'LT' ) - COUNTRYNAME="`gettext "Lithuania"`" - ;; - 'LU' ) - COUNTRYNAME="`gettext "Luxembourg"`" - ;; - 'LV' ) - COUNTRYNAME="`gettext "Latvia"`" - ;; - 'LY' ) - COUNTRYNAME="`gettext "Libya"`" - ;; - 'MA' ) - COUNTRYNAME="`gettext "Morocco"`" - ;; - 'MC' ) - COUNTRYNAME="`gettext "Monaco"`" - ;; - 'MD' ) - COUNTRYNAME="`gettext "Moldova"`" - ;; - 'MG' ) - COUNTRYNAME="`gettext "Madagascar"`" - ;; - 'MH' ) - COUNTRYNAME="`gettext "Marshall Islands"`" - ;; - 'MK' ) - COUNTRYNAME="`gettext "Macedonia"`" - ;; - 'ML' ) - COUNTRYNAME="`gettext "Mali"`" - ;; - 'MM' ) - COUNTRYNAME="`gettext "Myanmar (Burma)"`" - ;; - 'MN' ) - COUNTRYNAME="`gettext "Mongolia"`" - ;; - 'MO' ) - COUNTRYNAME="`gettext "Macao"`" - ;; - 'MP' ) - COUNTRYNAME="`gettext "Northern Mariana Islands"`" - ;; - 'MQ' ) - COUNTRYNAME="`gettext "Martinique"`" - ;; - 'MR' ) - COUNTRYNAME="`gettext "Mauritania"`" - ;; - 'MS' ) - COUNTRYNAME="`gettext "Montserrat"`" - ;; - 'MT' ) - COUNTRYNAME="`gettext "Malta"`" - ;; - 'MU' ) - COUNTRYNAME="`gettext "Mauritius"`" - ;; - 'MV' ) - COUNTRYNAME="`gettext "Maldives"`" - ;; - 'MW' ) - COUNTRYNAME="`gettext "Malawi"`" - ;; - 'MX' ) - COUNTRYNAME="`gettext "Mexico"`" - ;; - 'MY' ) - COUNTRYNAME="`gettext "Malaysia"`" - ;; - 'MZ' ) - COUNTRYNAME="`gettext "Mozambique"`" - ;; - 'NA' ) - COUNTRYNAME="`gettext "Namibia"`" - ;; - 'NC' ) - COUNTRYNAME="`gettext "New Caledonia"`" - ;; - 'NE' ) - COUNTRYNAME="`gettext "Niger"`" - ;; - 'NF' ) - COUNTRYNAME="`gettext "Norfolk Island"`" - ;; - 'NG' ) - COUNTRYNAME="`gettext "Nigeria"`" - ;; - 'NI' ) - COUNTRYNAME="`gettext "Nicaragua"`" - ;; - 'NL' ) - COUNTRYNAME="`gettext "Netherlands"`" - ;; - 'NO' ) - COUNTRYNAME="`gettext "Norway"`" - ;; - 'NP' ) - COUNTRYNAME="`gettext "Nepal"`" - ;; - 'NR' ) - COUNTRYNAME="`gettext "Nauru"`" - ;; - 'NU' ) - COUNTRYNAME="`gettext "Niue"`" - ;; - 'NZ' ) - COUNTRYNAME="`gettext "New Zealand"`" - ;; - 'OM' ) - COUNTRYNAME="`gettext "Oman"`" - ;; - 'PA' ) - COUNTRYNAME="`gettext "Panama"`" - ;; - 'PE' ) - COUNTRYNAME="`gettext "Peru"`" - ;; - 'PF' ) - COUNTRYNAME="`gettext "French Polynesia"`" - ;; - 'PG' ) - COUNTRYNAME="`gettext "Papua New Guinea"`" - ;; - 'PH' ) - COUNTRYNAME="`gettext "Philippines"`" - ;; - 'PK' ) - COUNTRYNAME="`gettext "Pakistan"`" - ;; - 'PL' ) - COUNTRYNAME="`gettext "Poland"`" - ;; - 'PM' ) - COUNTRYNAME="`gettext "St Pierre and Miquelon"`" - ;; - 'PN' ) - COUNTRYNAME="`gettext "Pitcairn"`" - ;; - 'PR' ) - COUNTRYNAME="`gettext "Puerto Rico"`" - ;; - 'PS' ) - COUNTRYNAME="`gettext "Palestine"`" - ;; - 'PT' ) - COUNTRYNAME="`gettext "Portugal"`" - ;; - 'PW' ) - COUNTRYNAME="`gettext "Palau"`" - ;; - 'PY' ) - COUNTRYNAME="`gettext "Paraguay"`" - ;; - 'QA' ) - COUNTRYNAME="`gettext "Qatar"`" - ;; - 'RE' ) - COUNTRYNAME="`gettext "Reunion"`" - ;; - 'RO' ) - COUNTRYNAME="`gettext "Romania"`" - ;; - 'RU' ) - COUNTRYNAME="`gettext "Russia"`" - ;; - 'RW' ) - COUNTRYNAME="`gettext "Rwanda"`" - ;; - 'SA' ) - COUNTRYNAME="`gettext "Saudi Arabia"`" - ;; - 'SB' ) - COUNTRYNAME="`gettext "Solomon Islands"`" - ;; - 'SC' ) - COUNTRYNAME="`gettext "Seychelles"`" - ;; - 'SD' ) - COUNTRYNAME="`gettext "Sudan"`" - ;; - 'SE' ) - COUNTRYNAME="`gettext "Sweden"`" - ;; - 'SG' ) - COUNTRYNAME="`gettext "Singapore"`" - ;; - 'SH' ) - COUNTRYNAME="`gettext "St Helena"`" - ;; - 'SI' ) - COUNTRYNAME="`gettext "Slovenia"`" - ;; - 'SJ' ) - COUNTRYNAME="`gettext "Svalbard and Jan Mayen"`" - ;; - 'SK' ) - COUNTRYNAME="`gettext "Slovakia"`" - ;; - 'SL' ) - COUNTRYNAME="`gettext "Sierra Leone"`" - ;; - 'SM' ) - COUNTRYNAME="`gettext "San Marino"`" - ;; - 'SN' ) - COUNTRYNAME="`gettext "Senegal"`" - ;; - 'SO' ) - COUNTRYNAME="`gettext "Somalia"`" - ;; - 'SR' ) - COUNTRYNAME="`gettext "Suriname"`" - ;; - 'ST' ) - COUNTRYNAME="`gettext "Sao Tome and Principe"`" - ;; - 'SV' ) - COUNTRYNAME="`gettext "El Salvador"`" - ;; - 'SY' ) - COUNTRYNAME="`gettext "Syria"`" - ;; - 'SZ' ) - COUNTRYNAME="`gettext "Swaziland"`" - ;; - 'TC' ) - COUNTRYNAME="`gettext "Turks and Caicos Islands"`" - ;; - 'TD' ) - COUNTRYNAME="`gettext "Chad"`" - ;; - 'TF' ) - COUNTRYNAME="`gettext "French Southern and Antarctic Lands"`" - ;; - 'TG' ) - COUNTRYNAME="`gettext "Togo"`" - ;; - 'TH' ) - COUNTRYNAME="`gettext "Thailand"`" - ;; - 'TJ' ) - COUNTRYNAME="`gettext "Tajikistan"`" - ;; - 'TK' ) - COUNTRYNAME="`gettext "Tokelau"`" - ;; - 'TL' ) - COUNTRYNAME="`gettext "Timor-Leste"`" - ;; - 'TM' ) - COUNTRYNAME="`gettext "Turkmenistan"`" - ;; - 'TN' ) - COUNTRYNAME="`gettext "Tunisia"`" - ;; - 'TO' ) - COUNTRYNAME="`gettext "Tonga"`" - ;; - 'TR' ) - COUNTRYNAME="`gettext "Turkey"`" - ;; - 'TT' ) - COUNTRYNAME="`gettext "Trinidad and Tobago"`" - ;; - 'TV' ) - COUNTRYNAME="`gettext "Tuvalu"`" - ;; - 'TW' ) - COUNTRYNAME="`gettext "Taiwan"`" - ;; - 'TZ' ) - COUNTRYNAME="`gettext "Tanzania"`" - ;; - 'UA' ) - COUNTRYNAME="`gettext "Ukraine"`" - ;; - 'UG' ) - COUNTRYNAME="`gettext "Uganda"`" - ;; - 'UM' ) - COUNTRYNAME="`gettext "US minor outlying islands"`" - ;; - 'US' ) - COUNTRYNAME="`gettext "United States"`" - ;; - 'UY' ) - COUNTRYNAME="`gettext "Uruguay"`" - ;; - 'UZ' ) - COUNTRYNAME="`gettext "Uzbekistan"`" - ;; - 'VA' ) - COUNTRYNAME="`gettext "Vatican City"`" - ;; - 'VC' ) - COUNTRYNAME="`gettext "St Vincent"`" - ;; - 'VE' ) - COUNTRYNAME="`gettext "Venezuela"`" - ;; - 'VG' ) - COUNTRYNAME="`gettext "Virgin Islands (UK)"`" - ;; - 'VI' ) - COUNTRYNAME="`gettext "Virgin Islands (US)"`" - ;; - 'VN' ) - COUNTRYNAME="`gettext "Vietnam"`" - ;; - 'VU' ) - COUNTRYNAME="`gettext "Vanuatu"`" - ;; - 'WF' ) - COUNTRYNAME="`gettext "Wallis and Futuna"`" - ;; - 'WS' ) - COUNTRYNAME="`gettext "Samoa (Western)"`" - ;; - 'YE' ) - COUNTRYNAME="`gettext "Yemen"`" - ;; - 'YT' ) - COUNTRYNAME="`gettext "Mayotte"`" - ;; - 'ZA' ) - COUNTRYNAME="`gettext "South Africa"`" - ;; - 'ZM' ) - COUNTRYNAME="`gettext "Zambia"`" - ;; - 'ZW' ) - COUNTRYNAME="`gettext "Zimbabwe"`" - ;; - * ) - COUNTRYNAME="`gettext "Unknown"`" - - esac - - echo $COUNTRYNAME - -} diff --git a/Scripts/Bash/Functions/cli_getCurrentLocale.sh b/Scripts/Bash/Functions/cli_getCurrentLocale.sh deleted file mode 100755 index 9181c59..0000000 --- a/Scripts/Bash/Functions/cli_getCurrentLocale.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# cli_getCurrentLocale.sh -- This function checks LANG environment -# variable and returns the current locale information in the LL_CC -# format. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCurrentLocale { - - local CURRENTLOCALE='' - local OPTION="$1" - - # Redefine current locale using LL_CC format. - CURRENTLOCALE=$(echo $LANG | sed -r 's!(^[a-z]{2,3}_[A-Z]{2}).+$!\1!') - - # Define centos-art.sh script default current locale. If - # centos-art.sh script doesn't support current system locale, use - # English language from United States as default current locale. - if [[ $CURRENTLOCALE == '' ]];then - CURRENTLOCALE='en_US' - fi - - # Output current locale. - case $OPTION in - - '--langcode-only' ) - echo "${CURRENTLOCALE}" | cut -d_ -f1 - ;; - - '--langcode-and-countrycode'| * ) - echo "${CURRENTLOCALE}" - ;; - esac -} diff --git a/Scripts/Bash/Functions/cli_getFilesList.sh b/Scripts/Bash/Functions/cli_getFilesList.sh deleted file mode 100755 index 5b9ff22..0000000 --- a/Scripts/Bash/Functions/cli_getFilesList.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# -# cli_getFilesList.sh -- This function outputs the list of files to -# process. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getFilesList { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize pattern used to reduce the find output. - local PATTERN="$FLAG_FILTER" - - # Initialize options used with find command. - local OPTIONS='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$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. - local LOCATIONS="$@" - - # Verify locations. - cli_checkFiles ${LOCATIONS} - - # 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. Doing so, everytime 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 LOCATION variable as part of - # regular expresion 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. - 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 coul be introduced to it. The best we can do is - # verifying exit status and go on. - find ${LOCATIONS} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq - -} diff --git a/Scripts/Bash/Functions/cli_getLangCodes.sh b/Scripts/Bash/Functions/cli_getLangCodes.sh deleted file mode 100755 index 59f7444..0000000 --- a/Scripts/Bash/Functions/cli_getLangCodes.sh +++ /dev/null @@ -1,222 +0,0 @@ -#!/bin/bash -# -# cli_getLangCodes.sh -- This function outputs a list with language -# codes as defined in ISO639 standard. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLangCodes { - - local FILTER="$(echo $1 | cut -d_ -f1)" - - LANGCODES="aa - ab - ae - af - ak - am - an - ar - as - av - ay - az - ba - be - bg - bh - bi - bm - bn - bo - br - bs - ca - ce - ch - co - cr - cs - cu - cv - cy - da - de - dv - dz - ee - el - en - eo - es - et - eu - fa - ff - fi - fj - fo - fr - fy - ga - gd - gl - gn - gu - gv - ha - he - hi - ho - hr - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - io - is - it - iu - ja - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ku - kv - kw - ky - la - lb - lg - li - ln - lo - lt - lu - lv - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - my - na - nb - nd - ne - ng - nl - nn - no - nr - nv - ny - oc - oj - om - or - os - pa - pi - pl - ps - pt - qu - rm - rn - ro - ru - rw - sa - sc - sd - se - sg - si - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - tg - th - ti - tk - tl - tn - to - tr - ts - tt - tw - ty - ug - uk - ur - uz - ve - vi - vo - wa - wo - xh - yi - yo - za - zh - zu" - - if [[ $FILTER != '' ]];then - echo "$LANGCODES" | egrep "$FILTER" | sed -r 's![[:space:]]+!!g' - else - echo "$LANGCODES" - fi - -} diff --git a/Scripts/Bash/Functions/cli_getLangName.sh b/Scripts/Bash/Functions/cli_getLangName.sh deleted file mode 100755 index 6d734b2..0000000 --- a/Scripts/Bash/Functions/cli_getLangName.sh +++ /dev/null @@ -1,780 +0,0 @@ -#!/bin/bash -# -# cli_getLangName.sh -- This function reads one language locale code -# in the format LL_CC and outputs its language name. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLangName { - - local LANGCODE="$(echo "$1" | cut -d_ -f1 | tr '[:upper:]' '[:lower:]')" - local LANGNAME='' - - case $LANGCODE in - - 'aa' ) - LANGNAME="`gettext "Afar"`" - ;; - - 'ab' ) - LANGNAME="`gettext "Abkhazian"`" - ;; - - 'ae' ) - LANGNAME="`gettext "Avestan"`" - ;; - - 'af' ) - LANGNAME="`gettext "Afrikaans"`" - ;; - - 'ak' ) - LANGNAME="`gettext "Akan"`" - ;; - - 'am' ) - LANGNAME="`gettext "Amharic"`" - ;; - - 'an' ) - LANGNAME="`gettext "Aragonese"`" - ;; - - 'ar' ) - LANGNAME="`gettext "Arabic"`" - ;; - - 'as' ) - LANGNAME="`gettext "Assamese"`" - ;; - - 'av' ) - LANGNAME="`gettext "Avaric"`" - ;; - - 'ay' ) - LANGNAME="`gettext "Aymara"`" - ;; - - 'az' ) - LANGNAME="`gettext "Azerbaijani"`" - ;; - - 'ba' ) - LANGNAME="`gettext "Bashkir"`" - ;; - - 'be' ) - LANGNAME="`gettext "Byelorussian"`" - ;; - - 'bg' ) - LANGNAME="`gettext "Bulgarian"`" - ;; - - 'bh' ) - LANGNAME="`gettext "Bihari"`" - ;; - - 'bi' ) - LANGNAME="`gettext "Bislama"`" - ;; - - 'bm' ) - LANGNAME="`gettext "Bambara"`" - ;; - - 'bn' ) - LANGNAME="`gettext "Bengali"`" - ;; - - 'bo' ) - LANGNAME="`gettext "Tibetan"`" - ;; - - 'br' ) - LANGNAME="`gettext "Breton"`" - ;; - - 'bs' ) - LANGNAME="`gettext "Bosnian"`" - ;; - - 'ca' ) - LANGNAME="`gettext "Catalan"`" - ;; - - 'ce' ) - LANGNAME="`gettext "Chechen"`" - ;; - - 'ch' ) - LANGNAME="`gettext "Chamorro"`" - ;; - - 'co' ) - LANGNAME="`gettext "Corsican"`" - ;; - - 'cr' ) - LANGNAME="`gettext "Cree"`" - ;; - - 'cs' ) - LANGNAME="`gettext "Czech"`" - ;; - - 'cu' ) - LANGNAME="`gettext "Church Slavic"`" - ;; - - 'cv' ) - LANGNAME="`gettext "Chuvash"`" - ;; - - 'cy' ) - LANGNAME="`gettext "Welsh"`" - ;; - - 'da' ) - LANGNAME="`gettext "Danish"`" - ;; - - 'de' ) - LANGNAME="`gettext "German"`" - ;; - - 'dv' ) - LANGNAME="`gettext "Divehi"`" - ;; - - 'dz' ) - LANGNAME="`gettext "Dzongkha"`" - ;; - - 'ee' ) - LANGNAME="`gettext "E'we"`" - ;; - - 'el' ) - LANGNAME="`gettext "Greek"`" - ;; - - 'en' ) - LANGNAME="`gettext "English"`" - ;; - - 'eo' ) - LANGNAME="`gettext "Esperanto"`" - ;; - - 'es' ) - LANGNAME="`gettext "Spanish"`" - ;; - - 'et' ) - LANGNAME="`gettext "Estonian"`" - ;; - - 'eu' ) - LANGNAME="`gettext "Basque"`" - ;; - 'fa' ) - LANGNAME="`gettext "Persian"`" - ;; - - 'ff' ) - LANGNAME="`gettext "Fulah"`" - ;; - - 'fi' ) - LANGNAME="`gettext "Finnish"`" - ;; - - 'fj' ) - LANGNAME="`gettext "Fijian"`" - ;; - - 'fo' ) - LANGNAME="`gettext "Faroese"`" - ;; - - 'fr' ) - LANGNAME="`gettext "French"`" - ;; - - 'fy' ) - LANGNAME="`gettext "Frisian"`" - ;; - - 'ga' ) - LANGNAME="`gettext "Irish"`" - ;; - - 'gd' ) - LANGNAME="`gettext "Scots"`" - ;; - - 'gl' ) - LANGNAME="`gettext "Gallegan"`" - ;; - - 'gn' ) - LANGNAME="`gettext "Guarani"`" - ;; - - 'gu' ) - LANGNAME="`gettext "Gujarati"`" - ;; - - 'gv' ) - LANGNAME="`gettext "Manx"`" - ;; - - 'ha' ) - LANGNAME="`gettext "Hausa"`" - ;; - - 'he' ) - LANGNAME="`gettext "Hebrew"`" - ;; - - 'hi' ) - LANGNAME="`gettext "Hindi"`" - ;; - - 'ho' ) - LANGNAME="`gettext "Hiri Motu"`" - ;; - - 'hr' ) - LANGNAME="`gettext "Croatian"`" - ;; - - 'ht' ) - LANGNAME="`gettext "Haitian"`" - ;; - - 'hu' ) - LANGNAME="`gettext "Hungarian"`" - ;; - - 'hy' ) - LANGNAME="`gettext "Armenian"`" - ;; - - 'hz' ) - LANGNAME="`gettext "Herero"`" - ;; - - 'ia' ) - LANGNAME="`gettext "Interlingua"`" - ;; - - 'id' ) - LANGNAME="`gettext "Indonesian"`" - ;; - - 'ie' ) - LANGNAME="`gettext "Interlingue"`" - ;; - - 'ig' ) - LANGNAME="`gettext "Igbo"`" - ;; - - 'ii' ) - LANGNAME="`gettext "Sichuan Yi"`" - ;; - - 'ik' ) - LANGNAME="`gettext "Inupiak"`" - ;; - - 'io' ) - LANGNAME="`gettext "Ido"`" - ;; - - 'is' ) - LANGNAME="`gettext "Icelandic"`" - ;; - - 'it' ) - LANGNAME="`gettext "Italian"`" - ;; - - 'iu' ) - LANGNAME="`gettext "Inuktitut"`" - ;; - - 'ja' ) - LANGNAME="`gettext "Japanese"`" - ;; - - 'jv' ) - LANGNAME="`gettext "Javanese"`" - ;; - - 'ka' ) - LANGNAME="`gettext "Georgian"`" - ;; - - 'kg' ) - LANGNAME="`gettext "Kongo"`" - ;; - - 'ki' ) - LANGNAME="`gettext "Kikuyu"`" - ;; - - 'kj' ) - LANGNAME="`gettext "Kuanyama"`" - ;; - - 'kk' ) - LANGNAME="`gettext "Kazakh"`" - ;; - - 'kl' ) - LANGNAME="`gettext "Kalaallisut"`" - ;; - - 'km' ) - LANGNAME="`gettext "Khmer"`" - ;; - - 'kn' ) - LANGNAME="`gettext "Kannada"`" - ;; - - 'ko' ) - LANGNAME="`gettext "Korean"`" - ;; - - 'kr' ) - LANGNAME="`gettext "Kanuri"`" - ;; - - 'ks' ) - LANGNAME="`gettext "Kashmiri"`" - ;; - - 'ku' ) - LANGNAME="`gettext "Kurdish"`" - ;; - - 'kv' ) - LANGNAME="`gettext "Komi"`" - ;; - - 'kw' ) - LANGNAME="`gettext "Cornish"`" - ;; - - 'ky' ) - LANGNAME="`gettext "Kirghiz"`" - ;; - - 'la' ) - LANGNAME="`gettext "Latin"`" - ;; - - 'lb' ) - LANGNAME="`gettext "Letzeburgesch"`" - ;; - - 'lg' ) - LANGNAME="`gettext "Ganda"`" - ;; - - 'li' ) - LANGNAME="`gettext "Limburgish"`" - ;; - - 'ln' ) - LANGNAME="`gettext "Lingala"`" - ;; - - 'lo' ) - LANGNAME="`gettext "Lao"`" - ;; - - 'lt' ) - LANGNAME="`gettext "Lithuanian"`" - ;; - - 'lu' ) - LANGNAME="`gettext "Luba-Katanga"`" - ;; - - 'lv' ) - LANGNAME="`gettext "Latvian"`" - ;; - - 'mg' ) - LANGNAME="`gettext "Malagasy"`" - ;; - - 'mh' ) - LANGNAME="`gettext "Marshall"`" - ;; - - 'mi' ) - LANGNAME="`gettext "Maori"`" - ;; - - 'mk' ) - LANGNAME="`gettext "Macedonian"`" - ;; - - 'ml' ) - LANGNAME="`gettext "Malayalam"`" - ;; - - 'mn' ) - LANGNAME="`gettext "Mongolian"`" - ;; - - 'mo' ) - LANGNAME="`gettext "Moldavian"`" - ;; - - 'mr' ) - LANGNAME="`gettext "Marathi"`" - ;; - - 'ms' ) - LANGNAME="`gettext "Malay"`" - ;; - - 'mt' ) - LANGNAME="`gettext "Maltese"`" - ;; - - 'my' ) - LANGNAME="`gettext "Burmese"`" - ;; - - 'na' ) - LANGNAME="`gettext "Nauru"`" - ;; - - 'nb' ) - LANGNAME="`gettext "Norwegian Bokmaal"`" - ;; - - 'nd' ) - LANGNAME="`gettext "Ndebele, North"`" - ;; - - 'ne' ) - LANGNAME="`gettext "Nepali"`" - ;; - - 'ng' ) - LANGNAME="`gettext "Ndonga"`" - ;; - - 'nl' ) - LANGNAME="`gettext "Dutch"`" - ;; - - 'nn' ) - LANGNAME="`gettext "Norwegian Nynorsk"`" - ;; - - 'no' ) - LANGNAME="`gettext "Norwegian"`" - ;; - - 'nr' ) - LANGNAME="`gettext "Ndebele, South"`" - ;; - - 'nv' ) - LANGNAME="`gettext "Navajo"`" - ;; - - 'ny' ) - LANGNAME="`gettext "Chichewa"`" - ;; - - 'oc' ) - LANGNAME="`gettext "Occitan"`" - ;; - - 'oj' ) - LANGNAME="`gettext "Ojibwa"`" - ;; - - 'om' ) - LANGNAME="`gettext "(Afan) Oromo"`" - ;; - - 'or' ) - LANGNAME="`gettext "Oriya"`" - ;; - - 'os' ) - LANGNAME="`gettext "Ossetian; Ossetic"`" - ;; - - 'pa' ) - LANGNAME="`gettext "Panjabi; Punjabi"`" - ;; - - 'pi' ) - LANGNAME="`gettext "Pali"`" - ;; - - 'pl' ) - LANGNAME="`gettext "Polish"`" - ;; - - 'ps' ) - LANGNAME="`gettext "Pashto, Pushto"`" - ;; - - 'pt' ) - LANGNAME="`gettext "Portuguese"`" - ;; - - 'qu' ) - LANGNAME="`gettext "Quechua"`" - ;; - - 'rm' ) - LANGNAME="`gettext "Rhaeto-Romance"`" - ;; - - 'rn' ) - LANGNAME="`gettext "Rundi"`" - ;; - - 'ro' ) - LANGNAME="`gettext "Romanian"`" - ;; - - 'ru' ) - LANGNAME="`gettext "Russian"`" - ;; - - 'rw' ) - LANGNAME="`gettext "Kinyarwanda"`" - ;; - - 'sa' ) - LANGNAME="`gettext "Sanskrit"`" - ;; - - 'sc' ) - LANGNAME="`gettext "Sardinian"`" - ;; - - 'sd' ) - LANGNAME="`gettext "Sindhi"`" - ;; - - 'se' ) - LANGNAME="`gettext "Northern Sami"`" - ;; - - 'sg' ) - LANGNAME="`gettext "Sango; Sangro"`" - ;; - - 'si' ) - LANGNAME="`gettext "Sinhalese"`" - ;; - - 'sk' ) - LANGNAME="`gettext "Slovak"`" - ;; - - 'sl' ) - LANGNAME="`gettext "Slovenian"`" - ;; - - 'sm' ) - LANGNAME="`gettext "Samoan"`" - ;; - - 'sn' ) - LANGNAME="`gettext "Shona"`" - ;; - - 'so' ) - LANGNAME="`gettext "Somali"`" - ;; - - 'sq' ) - LANGNAME="`gettext "Albanian"`" - ;; - - 'sr' ) - LANGNAME="`gettext "Serbian"`" - ;; - - 'ss' ) - LANGNAME="`gettext "Swati; Siswati"`" - ;; - - 'st' ) - LANGNAME="`gettext "Sesotho; Sotho, Southern"`" - ;; - - 'su' ) - LANGNAME="`gettext "Sundanese"`" - ;; - - 'sv' ) - LANGNAME="`gettext "Swedish"`" - ;; - - 'sw' ) - LANGNAME="`gettext "Swahili"`" - ;; - - 'ta' ) - LANGNAME="`gettext "Tamil"`" - ;; - - 'te' ) - LANGNAME="`gettext "Telugu"`" - ;; - - 'tg' ) - LANGNAME="`gettext "Tajik"`" - ;; - - 'th' ) - LANGNAME="`gettext "Thai"`" - ;; - - 'ti' ) - LANGNAME="`gettext "Tigrinya"`" - ;; - - 'tk' ) - LANGNAME="`gettext "Turkmen"`" - ;; - - 'tl' ) - LANGNAME="`gettext "Tagalog"`" - ;; - - 'tn' ) - LANGNAME="`gettext "Tswana; Setswana"`" - ;; - - 'to' ) - LANGNAME="`gettext "Tonga (?)"`" - ;; - - 'tr' ) - LANGNAME="`gettext "Turkish"`" - ;; - - 'ts' ) - LANGNAME="`gettext "Tsonga"`" - ;; - - - 'tt' ) - LANGNAME="`gettext "Tatar"`" - ;; - - 'tw' ) - LANGNAME="`gettext "Twi"`" - ;; - - 'ty' ) - LANGNAME="`gettext "Tahitian"`" - ;; - - 'ug' ) - LANGNAME="`gettext "Uighur"`" - ;; - - 'uk' ) - LANGNAME="`gettext "Ukrainian"`" - ;; - - 'ur' ) - LANGNAME="`gettext "Urdu"`" - ;; - - 'uz' ) - LANGNAME="`gettext "Uzbek"`" - ;; - - 've' ) - LANGNAME="`gettext "Venda"`" - ;; - - 'vi' ) - LANGNAME="`gettext "Vietnamese"`" - ;; - - 'vo' ) - LANGNAME="`gettext "Volapuk; Volapuk"`" - ;; - - 'wa' ) - LANGNAME="`gettext "Walloon"`" - ;; - - 'wo' ) - LANGNAME="`gettext "Wolof"`" - ;; - - 'xh' ) - LANGNAME="`gettext "Xhosa"`" - ;; - - 'yi' ) - LANGNAME="`gettext "Yiddish (formerly ji)"`" - ;; - - 'yo' ) - LANGNAME="`gettext "Yoruba"`" - ;; - - 'za' ) - LANGNAME="`gettext "Zhuang"`" - ;; - - 'zh' ) - LANGNAME="`gettext "Chinese"`" - ;; - - 'zu' ) - LANGNAME="`gettext "Zulu"`" - ;; - - * ) - LANGNAME="`gettext "Unknown"`" - - esac - - echo $LANGNAME; -} - diff --git a/Scripts/Bash/Functions/cli_getLocales.sh b/Scripts/Bash/Functions/cli_getLocales.sh deleted file mode 100755 index 853efc7..0000000 --- a/Scripts/Bash/Functions/cli_getLocales.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# cli_getLocales.sh -- This function outputs/verifies locale codes in LL -# and LL_CC format. Combine both ISO639 and ISO3166 specification in -# order to build the final locale list. This function defines which -# translation locales are supported inside CentOS Artwork Repository. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLocales { - - # Print locales supported by centos-art.sh script. - locale -a | egrep '^[a-z]{2,3}_[A-Z]{2}$' | sort | uniq - -} diff --git a/Scripts/Bash/Functions/cli_getPathComponent.sh b/Scripts/Bash/Functions/cli_getPathComponent.sh deleted file mode 100755 index e838cf7..0000000 --- a/Scripts/Bash/Functions/cli_getPathComponent.sh +++ /dev/null @@ -1,131 +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 retrive information -# from paths (e.g., releases, architectures and theme artistic motifs) -# or the patterns used to build the paths. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -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' - - # Initialize ARGUMENTS with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Define release pattern. - local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+)){0,1})" - - # Define architecture pattern. Make it match the architectures the - # CentOS distribution is able to be installed on. - local ARCHITECTURE="(i386|x86_64)" - - # Define pattern for themes' artistic motifs. - local THEME_MOTIF="Identity/Images/Themes/(([[:alnum:]]+)/(${RELEASE}))" - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$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 - ;; - - esac - - done -} diff --git a/Scripts/Bash/Functions/cli_getRepoName.sh b/Scripts/Bash/Functions/cli_getRepoName.sh deleted file mode 100755 index 4a43eb3..0000000 --- a/Scripts/Bash/Functions/cli_getRepoName.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash -# -# cli_getRepoName.sh -- This function standardize file and directories -# name convenction inside the working copy of CentOS Artowrk -# Repository. As convenction, regular files are written in lower case -# and directories are written in lower case but with the first letter -# in upper case. Use this function to sanitate the name of regular -# files and directory components of paths you work with. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -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 sanitated (e.g., /home, - # /home/centos, /home/centos/artwork, - # /home/centos/artwork/turnk, trunk, etc.) So, we keep - # them unchaged for later use. - PREFIXDIR=$(echo $NAME \ - | sed -r "s,^(($(cli_getRepoTLDir)/)?(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 sanitated values. - CLEANDIRS="${CLEANDIRS}/$DIR" - - done - - # Redefine path using sanitated values. - NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") - - # Add prefix directory information to sanitated path - # information. - if [[ "$PREFIXDIR" != '' ]];then - NAME=${PREFIXDIR}${NAME} - fi - ;; - - esac - - # Print out the clean path string. - echo $NAME - -} diff --git a/Scripts/Bash/Functions/cli_getRepoParallelDirs.sh b/Scripts/Bash/Functions/cli_getRepoParallelDirs.sh deleted file mode 100755 index f2d0bc8..0000000 --- a/Scripts/Bash/Functions/cli_getRepoParallelDirs.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# cli_getRepoParallelDirs.sh -- This function returns the parallel -# directories related to the first positional paramenter passed as -# parent directory. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoParallelDirs { - - local BOND='' - local TDIR='' - local -a PDIRS - - # Define bond string using first positional parameter as - # reference. - if [[ "$1" != '' ]];then - BOND="$1" - elif [[ "$ACTIONVAL" != '' ]];then - BOND="$ACTIONVAL" - else - cli_printMessage "`gettext "The bond string is required."`" --as-error-line - fi - - # Define repository top level directory. - TDIR=$(cli_getRepoTLDir ${BOND}) - - # Define parallel directory base structures. - PDIRS[0]=Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir ${BOND} --relative) - PDIRS[1]=Scripts/Bash/Functions/Render/Config - PDIRS[2]=L10n - - # Redefine bond string without its top level directory structure. - BOND=$(echo $BOND | sed -r "s,^${TDIR}/(.+)$,\1,") - - # Concatenate repository top level directory, parallel directory - # base structure, and bond information; in order to produce the - # final parallel directory path. - for PDIR in "${PDIRS[@]}";do - echo ${TDIR}/${PDIR}/${BOND} - done - -} diff --git a/Scripts/Bash/Functions/cli_getRepoStatus.sh b/Scripts/Bash/Functions/cli_getRepoStatus.sh deleted file mode 100755 index dca042f..0000000 --- a/Scripts/Bash/Functions/cli_getRepoStatus.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# cli_getRepoStatus.sh -- This function requests the working copy -# using the svn status command and returns the first character in the -# output line, as described in svn help status, for the LOCATION -# specified. Use this function to perform verifications based a -# repository LOCATION status. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoStatus { - - local LOCATION="$1" - - # Define regular expression pattern to retrive first column, - # returned by subversion status command. This column is one - # character column as describes `svn help status' command. - local PATTERN='^( |A|C|D|I|M|R|X|!|~).+$' - - # Output specific state of location using subversion `status' - # command. - svn status "$LOCATION" --quiet | sed -r "s/${PATTERN}/\1/" - -} diff --git a/Scripts/Bash/Functions/cli_getRepoTLDir.sh b/Scripts/Bash/Functions/cli_getRepoTLDir.sh deleted file mode 100755 index bc30f2c..0000000 --- a/Scripts/Bash/Functions/cli_getRepoTLDir.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# -# cli_getRepoTLDir.sh -- This function returns the repository top -# level absolute path. The repository top level absolute path can be -# either ${CLI_WRKCOPY}/trunk, ${CLI_WRKCOPY}/branches, or -# ${CLI_WRKCOPY}/tags. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoTLDir { - - # Define short options. - local ARGSS='r' - - # Define long options. - local ARGSL='relative' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize path pattern and replacement. - local PATTERN='' - local REPLACE='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Define the location we want to apply verifications to. - local LOCATION=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') - - # Verify location passed as non-option argument. If no location is - # passed as non-option argument to this function, then set the - # trunk directory structure as default location. - if [[ $LOCATION =~ '--$' ]];then - LOCATION=${CLI_WRKCOPY}/trunk - fi - - # Verify location where the working copy should be stored in the - # workstations. Whatever the location provided be, it should refer - # to one of the top level directories inside the working copy of - # CentOS Artwork Repository which, in turn, should be sotred in - # the `artwork' directory immediatly under your home directory. - if [[ ! $LOCATION =~ "^${CLI_WRKCOPY}/(trunk|branches|tags)" ]];then - cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line - fi - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - -r|--relative ) - PATTERN="^${CLI_WRKCOPY}/(trunk|branches|tags)/.+$" - REPLACE='\1' - shift 2 - break - ;; - - -- ) - PATTERN="^(${CLI_WRKCOPY}/(trunk|branches|tags))/.+$" - REPLACE='\1' - shift 1 - break - ;; - esac - - done - - # Print out top level directory. - echo $LOCATION | sed -r "s!${PATTERN}!${REPLACE}!g" - -} diff --git a/Scripts/Bash/Functions/cli_getTTFont.sh b/Scripts/Bash/Functions/cli_getTTFont.sh deleted file mode 100755 index d6b0cd8..0000000 --- a/Scripts/Bash/Functions/cli_getTTFont.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# cli_getFont.sh -- This function creates a list of all True Type -# Fonts (TTF) installed in your workstation and returns the absolute -# path of the file matching the pattern passed as first argument. -# Assuming more than one value matches, the first one in the list is -# used. In case no match is found, the function verifies if there is -# any file in the list that can be used (giving preference to sans -# files). If no file is found at this point, an error will be printed -# out. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getTTFont { - - local -a FONT_PATTERNS - local FONT_PATTERN='' - local FONT_FILE='' - - # Define list of patterns used to build the list of TTF files. - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="/${1}\.ttf$" - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="sans\.ttf$" - FONT_PATTERNS[((++${#FONT_PATTERNS[*]}))]="\.ttf$" - - # Define directory location where fonts are installed in your - # workstation. - local FONT_DIR='/usr/share/fonts' - - # Define list of all TTF files installed in your workstation. - local FONT_FILES=$(cli_getFilesList ${FONT_DIR} --pattern="\.ttf") - - # Define TTF absolute path based on pattern. Notice that if the - # pattern matches more than one value, only the first one of a - # sorted list will be used. - for FONT_PATTERN in ${FONT_PATTERNS[@]};do - - FONT_FILE=$(echo "$FONT_FILES" | egrep ${FONT_PATTERN} \ - | head -n 1) - - if [[ -f $FONT_FILE ]];then - break - fi - - done - - # Output TTF absolute path. - if [[ -f $FONT_FILE ]];then - echo $FONT_FILE - else - cli_printMessage "`gettext "The font provided doesn't exist."`" --as-error-line - fi - -} diff --git a/Scripts/Bash/Functions/cli_getTemporalFile.sh b/Scripts/Bash/Functions/cli_getTemporalFile.sh deleted file mode 100755 index 89c9ae2..0000000 --- a/Scripts/Bash/Functions/cli_getTemporalFile.sh +++ /dev/null @@ -1,59 +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. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -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 exention is - # required in order to avoid complains from inkscape. - local NAME="$(cli_getRepoName $1 -f)" - - # Check default base name for temporal file, it can't be an empty - # value. - if [[ "$NAME" == '' ]];then - cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line - fi - - # Redefine file name for the temporal file. Make it a combination - # of the program name, the program process id, a random string and - # the design model name. Using the program name and process id in - # the file name let us to relate both the shell script execution - # and the temporal files it creates, so they can be removed in - # case an interruption signal be detected. The random string let - # us to produce the same artwork in different terminals at the - # same time. the The design model name provides file - # identification. - NAME=${CLI_NAME}-${CLI_PPID}-${RANDOM}-${NAME} - - # Define absolute path for temporal file using the program name, - # the current locale, the unique identifier and the file name. - local TEMPFILE="${CLI_TEMPDIR}/${NAME}" - - # Output absolute path to final temporal file. - echo $TEMPFILE - -} diff --git a/Scripts/Bash/Functions/cli_isLocalized.sh b/Scripts/Bash/Functions/cli_isLocalized.sh deleted file mode 100755 index efce7f8..0000000 --- a/Scripts/Bash/Functions/cli_isLocalized.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# cli_isLocalized.sh -- This function determines whether a file or -# directory can have translation messages or not. This is the way we -# standardize what locations can be localized and what cannot inside -# the repository. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_isLocalized { - - local DIR='' - local -a DIRS - - # Initialize default value returned by this function. - local LOCALIZED='false' - - # Initialize location will use as reference to determine whether - # it can have translation messages or not. - local LOCATION="$1" - - # Redefine location to be sure we'll always evaluate a directory, - # as reference location. - if [[ -f $LOCATION ]];then - LOCATION=$(dirname $LOCATION) - fi - - # Verify location existence. If it doesn't exist we cannot go on. - cli_checkFiles $LOCATION -d - - # Define regular expresion list of all directories inside the - # repository that can have translation. These are the - # locale-specific directories will be created for. - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Distro/$(\ - cli_getPathComponent --release-pattern)/Anaconda|Concept|Posters|Media)" - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+$" - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Scripts$" - - # Verify location passed as first argument agains the list of - # directories that can have translation messages. By default, the - # location passed as first argument is considered as a location - # that cannot have translation messages until a positive answer - # says otherwise. - for DIR in ${DIRS[@]};do - if [[ $LOCATION =~ $DIR ]];then - LOCALIZED='true' - break - fi - done - - # Output final answer to all verifications. - echo "$LOCALIZED" - -} diff --git a/Scripts/Bash/Functions/cli_isVersioned.sh b/Scripts/Bash/Functions/cli_isVersioned.sh deleted file mode 100755 index a1f7f97..0000000 --- a/Scripts/Bash/Functions/cli_isVersioned.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# cli_isVersioned.sh -- This function determines whether a location is -# under version control or not. When the location is under version -# control, this function returns `true'. when the location isn't under -# version control, this function returns `false'. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_isVersioned { - - # Initialize absolute path using first positional parameter as - # reference. - local LOCATION="$1" - - # Verify location to be sure it really exists. - cli_checkFiles $LOCATION - - # Use subversion to determine whether the location is under - # version control or not. - svn info $LOCATION &> /dev/null - - # Verify subversion exit status and print output. - if [[ $? -eq 0 ]];then - echo 'true' - else - echo 'false' - fi - -} diff --git a/Scripts/Bash/Functions/cli_parseArguments.sh b/Scripts/Bash/Functions/cli_parseArguments.sh deleted file mode 100755 index 3585d7a..0000000 --- a/Scripts/Bash/Functions/cli_parseArguments.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# cli_parseArguments.sh -- This function redefines arguments -# (ARGUMENTS) global variable using getopt(1) output. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_parseArguments { - - # Reset positional parameters using optional arguments. - eval set -- "$ARGUMENTS" - - # Parse optional arguments using getopt. - ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n "$CLI_NAME (${FUNCNAME[1]})" -- "$@") - - # Be sure getout parsed arguments successfully. - if [[ $? != 0 ]]; then - cli_printMessage "${CLI_FUNCDIRNAM}" --as-toknowmore-line - fi - -} diff --git a/Scripts/Bash/Functions/cli_parseArgumentsReDef.sh b/Scripts/Bash/Functions/cli_parseArgumentsReDef.sh deleted file mode 100755 index 6a6c4c0..0000000 --- a/Scripts/Bash/Functions/cli_parseArgumentsReDef.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# cli_parseArgumentsReDef.sh -- This function initiates/reset and -# sanitates positional parameters passed to this function and creates -# the the list of arguments that getopt will process. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_parseArgumentsReDef { - - local ARG - - # Clean up arguments global variable. - ARGUMENTS='' - - # Fill up arguments global variable with current positional - # parameter information. To avoid interpretation problems, use - # single quotes to enclose each argument (ARG) from command-line - # idividually. - for ARG in "$@"; do - - # Sanitate option arguments before process them. Be sure that - # no option argument does contain any single quote (U+0027) - # inside; that would break option parsing. Remember that we - # are using single quotes to enclose option arguments in order - # to let getopt to interpret option arguments with spaces - # inside. To solve this issue, we replace all single quotes - # in the arguments list with their respective codification and - # reverse the process back when doPrint them out. - ARG=$(echo $ARG | sed "s/'/\\\0x27/g") - - # Concatenate arguments and encolose them to let getopt to - # process them when they have spaces inside. - ARGUMENTS="$ARGUMENTS '$ARG'" - - done - -} diff --git a/Scripts/Bash/Functions/cli_printActionPreamble.sh b/Scripts/Bash/Functions/cli_printActionPreamble.sh deleted file mode 100755 index c8270bc..0000000 --- a/Scripts/Bash/Functions/cli_printActionPreamble.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -# -# cli_printActionPreamble -- This function standardizes the way -# preamble messages are printed out. Preamble messages are used before -# actions (e.g., file elimination, edition, creation, actualization, -# etc.) and provide a way for the user to control whether the action -# is performed or not. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printActionPreamble { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='to-create,to-delete,to-locale,to-edit' - - # Initialize arguments with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize message. - local MESSAGE='' - - # Initialize message options. - local OPTION='' - - # Initialize file variable as local to avoid conflicts outside. - # We'll use the file variable later, to show the list of files - # that will be affected by the action. - local FILE='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Define the location we want to apply verifications to. - local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') - - # Initialize counter with total number of files. - local COUNT=$(echo $FILES | wc -l) - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - --to-create ) - if [[ $FILES == '--' ]];then - MESSAGE="`gettext "There is no entry to create."`" - OPTION='--as-error-line' - else - MESSAGE="`ngettext "The following entry will be created" \ - "The following entries will be created" $COUNT`:" - OPTION='' - fi - shift 2 - break - ;; - - --to-delete ) - if [[ $FILES == '--' ]];then - MESSAGE="`gettext "There is no file to delete."`" - OPTION='--as-error-line' - else - MESSAGE="`ngettext "The following entry will be deleted" \ - "The following entries will be deleted" $COUNT`:" - OPTION='' - fi - shift 2 - break - ;; - - --to-locale ) - if [[ $FILES == '--' ]];then - MESSAGE="`gettext "There is no file to locale."`" - OPTION='--as-error-line' - else - MESSAGE="`ngettext "Translatable strings will be retrived from the following entry" \ - "Translatable strings will be retrived from the following entries" $COUNT`:" - OPTION='' - fi - shift 2 - break - ;; - - --to-edit ) - if [[ $FILES == '--' ]];then - MESSAGE="`gettext "There is no file to edit."`" - OPTION='--as-error-line' - else - MESSAGE="`ngettext "The following file will be edited" \ - "The following files will be edited" $COUNT`:" - OPTION='' - fi - shift 2 - break - ;; - - -- ) - if [[ $FILES == '--' ]];then - MESSAGE="`gettext "There is no file to process."`" - OPTION='--as-error-line' - else - MESSAGE="`ngettext "The following file will be processed" \ - "The following files will be processed" $COUNT`:" - OPTION='' - fi - shift 1 - break - ;; - esac - done - - # Print out the preamble message. - cli_printMessage "${MESSAGE}" "${OPTION}" - for FILE in $FILES;do - cli_printMessage "$FILE" --as-response-line - done - cli_printMessage "`gettext "Do you want to continue"`" --as-yesornorequest-line - -} diff --git a/Scripts/Bash/Functions/cli_printCopyrightInfo.sh b/Scripts/Bash/Functions/cli_printCopyrightInfo.sh deleted file mode 100755 index 6f4e6e2..0000000 --- a/Scripts/Bash/Functions/cli_printCopyrightInfo.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -# -# cli_printCopyrightInfo.sh -- This function standardizes the -# copyright information used 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. So, in that sake, I'll assume -# the same copyright information used by The CentOS Wiki -# (http://wiki.centos.org/) as reference. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printCopyrightInfo { - - case "$1" in - - --license ) - - # Print out the name of the license used by to release the - # content produced by centos-art.sh script, inside CentOS - # Artwork Repository. - echo "`gettext "Creative Common Attribution-ShareAlike 3.0 License"`" - ;; - - --license-url ) - - # Print out the url of the license used by to release the - # content produced by centos-art.sh script, inside CentOS - # Artwork Repository. - cli_printUrl --cc-sharealike - ;; - - --copyright-year-first ) - - # The former year when I (as part of The CentOS Project) - # started to consolidate The CentOS Project Corporate - # Visual Identity through the CentOS Artwork Repository. - echo '2009' - ;; - - --copyright-year|--copyright-year-last ) - - # 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 does never - # happen, so assume the current year as last working year. - date +%Y - ;; - - --copyright-year-range ) - - local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first') - local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last') - echo "${FIRST_YEAR}-${LAST_YEAR}" - ;; - - --copyright-year-list ) - - local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first') - local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last') - - # 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!, *$!!' - ;; - - --copyright-holder ) - - # Output default copyright holder. - echo "`gettext "The CentOS Project"`" - ;; - - --copyright-holder-predicate ) - - local HOLDER=$(cli_printCopyrightInfo '--copyright-holder') - echo "${HOLDER}. `gettext "All rights reserved."`" - ;; - - --copyright ) - - local YEAR=$(cli_printCopyrightInfo '--copyright-year-last') - local HOLDER=$(cli_printCopyrightInfo '--copyright-holder') - echo "Copyright © ${YEAR} ${HOLDER}" - ;; - - esac - -} diff --git a/Scripts/Bash/Functions/cli_printMessage.sh b/Scripts/Bash/Functions/cli_printMessage.sh deleted file mode 100755 index 93d7fcc..0000000 --- a/Scripts/Bash/Functions/cli_printMessage.sh +++ /dev/null @@ -1,242 +0,0 @@ -#!/bin/bash -# -# cli_printMessage.sh -- This function standardizes the way messages -# are printed out from centos-art.sh script. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printMessage { - - # Verify `--quiet' option. - if [[ "$FLAG_QUIET" == 'true' ]];then - return - fi - - local MESSAGE="$1" - local FORMAT="$2" - - # Verify message variable, it cannot have an empty value. - if [[ $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 - - # Reverse the codification performed on characters that may affect - # parsing options and non-option arguments. This codification is - # realized before building the ARGUMENTS variable, at - # cli_parseArgumentsReDef, and we need to reverse it back here - # in order to show the correct character when the message be - # printed out on the screen. - MESSAGE=$(echo $MESSAGE | sed -e "s/\\\0x27/'/g") - - # Remove empty spaces from message. - MESSAGE=$(echo $MESSAGE | sed -e 's!^[[:space:]]+!!') - - # Print out messages based on format. - case "$FORMAT" in - - --as-separator-line ) - - # Build the separator line. - MESSAGE=$(\ - until [[ $MESSAGE_WIDTH -eq 0 ]];do - echo -n "$MESSAGE" - MESSAGE_WIDTH=$(($MESSAGE_WIDTH - 1)) - done) - - # Draw the separator line. - echo "$MESSAGE" > /dev/stderr - ;; - - --as-banner-line ) - cli_printMessage '-' --as-separator-line - cli_printMessage "$MESSAGE" - cli_printMessage '-' --as-separator-line - ;; - - --as-cropping-line ) - cli_printMessage "`gettext "Cropping from"`: $MESSAGE" - ;; - - --as-tuningup-line ) - cli_printMessage "`gettext "Tuning-up"`: $MESSAGE" - ;; - - --as-checking-line ) - cli_printMessage "`gettext "Checking"`: $MESSAGE" - ;; - - --as-creating-line | --as-updating-line ) - if [[ -a "$MESSAGE" ]];then - cli_printMessage "`gettext "Updating"`: $MESSAGE" - else - cli_printMessage "`gettext "Creating"`: $MESSAGE" - fi - ;; - - --as-deleting-line ) - cli_printMessage "`gettext "Deleting"`: $MESSAGE" - ;; - - --as-reading-line ) - cli_printMessage "`gettext "Reading"`: $MESSAGE" - ;; - - --as-savedas-line ) - cli_printMessage "`gettext "Saved as"`: $MESSAGE" - ;; - - --as-linkto-line ) - cli_printMessage "`gettext "Linked to"`: $MESSAGE" - ;; - - --as-movedto-line ) - cli_printMessage "`gettext "Moved to"`: $MESSAGE" - ;; - - --as-translation-line ) - cli_printMessage "`gettext "Translation"`: $MESSAGE" - ;; - - --as-validating-line ) - cli_printMessage "`gettext "Validating"`: $MESSAGE" - ;; - - --as-template-line ) - cli_printMessage "`gettext "Template"`: $MESSAGE" - ;; - - --as-configuration-line ) - cli_printMessage "`gettext "Configuration"`: $MESSAGE" - ;; - - --as-palette-line ) - cli_printMessage "`gettext "Palette"`: $MESSAGE" - ;; - - --as-response-line ) - cli_printMessage "--> $MESSAGE" - ;; - - --as-request-line ) - cli_printMessage "${MESSAGE}:\040" --as-notrailingnew-line - ;; - - --as-selection-line ) - local NAME='' - select NAME in ${MESSAGE};do - echo $NAME - break - done - ;; - - --as-error-line ) - # Define where the error was originated inside the - # centos-art.sh script. Print out the function name and - # line from the caller. - local ORIGIN="$(caller 1 | gawk '{ print $2 " " $1 }')" - - # Build the error message. - cli_printMessage "${CLI_NAME} (${ORIGIN}): $MESSAGE" --as-stderr-line - cli_printMessage "${CLI_FUNCDIRNAM}" --as-toknowmore-line - ;; - - --as-toknowmore-line ) - cli_printMessage '-' --as-separator-line - cli_printMessage "`gettext "To know more, run the following command"`:" - cli_printMessage "centos-art help --read trunk/Scripts/Functions/$MESSAGE" - cli_printMessage '-' --as-separator-line - exit # <-- ATTENTION: Do not remove this line. We use this - # option as convenction to end script - # execution. - ;; - - --as-yesornorequest-line ) - # Define positive answer. - local Y="`gettext "yes"`" - - # Define negative answer. - local N="`gettext "no"`" - - # Define default answer. - local ANSWER=${N} - - if [[ $FLAG_ANSWER == 'true' ]];then - - ANSWER=${Y} - - else - - # Print the question. - cli_printMessage "$MESSAGE [${Y}/${N}]:\040" --as-notrailingnew-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 possitive answer is passed, the script - # terminates its execution immediatly. - if [[ ! ${ANSWER} =~ "^${Y}" ]];then - exit - fi - ;; - - --as-notrailingnew-line ) - echo -e -n "$MESSAGE" > /dev/stderr - ;; - - --as-stdout-line ) - echo "$MESSAGE" - ;; - - --as-stderr-line ) - echo "$MESSAGE" - ;; - - * ) - - # 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!${CLI_WRKCOPY}/(trunk|branches|tags)/!\1/!g" \ - | awk 'BEGIN { FS=": " } - { - if ( $0 ~ /^-+$/ ) - print $0 - else - printf "%-15s\t%s\n", $1, $2 - } - END {}' > /dev/stderr - ;; - - esac - -} diff --git a/Scripts/Bash/Functions/cli_printUrl.sh b/Scripts/Bash/Functions/cli_printUrl.sh deleted file mode 100755 index 5994d8d..0000000 --- a/Scripts/Bash/Functions/cli_printUrl.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# -# cli_printUrl.sh -- This function standardize the way URLs are -# printed inside 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. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printUrl { - - local URL='' - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='home,lists,wiki,forums,bugs,planet,docs,mirrors,irc,projects,projects-artwork,cc-sharealike,with-locale,as-html-link' - - # Define ARGUMENTS as local variable in order to parse options - # internlally. - local ARGUMENTS='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - --home ) - URL='http://www.centos.org/' - shift 1 - ;; - - --lists ) - URL='http://lists.centos.org/' - shift 1 - ;; - - --wiki ) - URL='http://wiki.centos.org/' - shift 1 - ;; - - --forums ) - URL='http://forums.centos.org/' - shift 1 - ;; - - --bugs ) - URL='http://bugs.centos.org/' - shift 1 - ;; - - --projects ) - URL='https://projects.centos.org/' - shift 1 - ;; - - --projects-artwork ) - URL=$(cli_printUrl '--projects')svn/artwork/ - shift 1 - ;; - - --planet ) - URL='http://planet.centos.org/' - shift 1 - ;; - - --docs ) - URL='http://docs.centos.org/' - shift 1 - ;; - - --mirrors ) - URL='http://mirrors.centos.org/' - shift 1 - ;; - - --irc ) - URL='http://www.centos.org/modules/tinycontent/index.php?id=8' - shift 1 - ;; - - --cc-sharealike ) - URL="http://creativecommons.org/licenses/by-sa/3.0/" - shift 1 - ;; - - --with-locale ) - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - URL="${URL}$(cli_getCurrentLocale '--langcode-only')/" - fi - shift 1 - ;; - - --as-html-link ) - URL="${URL}" - shift 1 - ;; - - -- ) - - shift 1 - break - ;; - esac - done - - # Print Url. - echo "$URL" - -} diff --git a/Scripts/Bash/Functions/cli_syncroRepoChanges.sh b/Scripts/Bash/Functions/cli_syncroRepoChanges.sh deleted file mode 100755 index 168ee6b..0000000 --- a/Scripts/Bash/Functions/cli_syncroRepoChanges.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# -# cli_syncroRepoChanges.sh -- This function syncronizes both central -# repository and working copy performing a subversion update command -# first and a subversion commit command later. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_syncroRepoChanges { - - # Verify don't commit changes flag. - if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then - return - fi - - # Define source location the subversion update action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Bring changes from the repository into the working copy. - cli_updateRepoChanges "$LOCATIONS" - - # Check changes in the working copy. - cli_commitRepoChanges "$LOCATIONS" - -} diff --git a/Scripts/Bash/Functions/cli_terminateScriptExecution.sh b/Scripts/Bash/Functions/cli_terminateScriptExecution.sh deleted file mode 100755 index f342034..0000000 --- a/Scripts/Bash/Functions/cli_terminateScriptExecution.sh +++ /dev/null @@ -1,51 +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. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_terminateScriptExecution { - - # Build list of temporal files related to this script execution. - # Remember that inside `/tmp' directory there are files and - # directories you might have no access to (due permission - # restrictions), so command cli_getFilesList to look for files in - # the first level of files that you are owner of. Otherwise, - # undesired `permission denied' messages might be output. - local FILES=$(cli_getFilesList ${CLI_TEMPDIR} \ - --pattern="${CLI_NAME}-${CLI_PPID}-.+" \ - --maxdepth="1" --uid="$(id -u)") - - # Remove list of temporal files related to this script execution, - # if any of course. Remember that some of the temporal files can - # be directories, too. - if [[ $FILES != '' ]];then - rm -rf $FILES - fi - - # Terminate script correctly. - exit 0 - -} diff --git a/Scripts/Bash/Functions/cli_unsetFunctions.sh b/Scripts/Bash/Functions/cli_unsetFunctions.sh deleted file mode 100755 index 9bf4e4b..0000000 --- a/Scripts/Bash/Functions/cli_unsetFunctions.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# cli_unsetFunctions.sh -- This function unsets funtionalities from -# `centos-art.sh' script execution evironment. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_unsetFunctions { - - # Define source location where function files are placed in. - local LOCATION=$1 - - # Define suffix used to retrive function files. - local SUFFIX=$2 - - # Verify suffix value used to retrive function files. Assuming no - # suffix value is passed as second argument to this function, use - # the function name value (CLI_FUNCNAME) as default value. - if [[ $SUFFIX == '' ]];then - SUFFIX=$CLI_FUNCNAME - 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 FUNCDEF='' - local FUNCDEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${SUFFIX}") - - # Unset function names from current execution environment. - for FUNCDEF in $FUNCDEFS;do - unset -f $FUNCDEF - done - -} diff --git a/Scripts/Bash/Functions/cli_updateRepoChanges.sh b/Scripts/Bash/Functions/cli_updateRepoChanges.sh deleted file mode 100755 index 78a6ad4..0000000 --- a/Scripts/Bash/Functions/cli_updateRepoChanges.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# cli_updateRepoChanges.sh -- This function realizes a subversion -# update command against the working copy in order to bring changes -# from the central repository into the working copy. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_updateRepoChanges { - - # Verify don't commit changes flag. - if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then - return - fi - - local -a FILES - local -a INFO - local -a FILESNUM - local COUNT=0 - local UPDATEOUT='' - local PREDICATE='' - local CHNGTOTAL=0 - local LOCATIONS='' - - # Define source location the subversion update action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Update working copy and retrive update output. - cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" --as-banner-line - UPDATEOUT=$(svn update ${LOCATIONS}) - - # Define path of files considered recent modifications from - # central repository to working copy. - FILES[0]=$(echo "$UPDATEOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[1]=$(echo "$UPDATEOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[2]=$(echo "$UPDATEOUT" | egrep "^U.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[3]=$(echo "$UPDATEOUT" | egrep "^C.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[4]=$(echo "$UPDATEOUT" | egrep "^G.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - - # Define description of files considered recent modifications from - # central repository to working copy. - INFO[0]="`gettext "Added"`" - INFO[1]="`gettext "Deleted"`" - INFO[2]="`gettext "Updated"`" - INFO[3]="`gettext "Conflicted"`" - INFO[4]="`gettext "Merged"`" - - while [[ $COUNT -ne ${#FILES[*]} ]];do - - # Define total number of files. Avoid counting empty line. - if [[ "${FILES[$COUNT]}" == '' ]];then - FILESNUM[$COUNT]=0 - else - FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) - fi - - # Calculate total amount of changes. - CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) - - # Build report predicate. Use report predicate to show any - # information specific to the number of files found. For - # example, you can use this section to show warning messages, - # notes, and so on. By default we use the word `file' or - # `files' at ngettext's consideration followed by change - # direction. - PREDICATE[$COUNT]=`ngettext "file from the repository" \ - "files from the repository" $((${FILESNUM[$COUNT]} + 1))` - - # Output report line. - cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Functions/init.sh b/Scripts/Bash/Functions/init.sh new file mode 100755 index 0000000..e9f1acb --- /dev/null +++ b/Scripts/Bash/Functions/init.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# cli.sh -- This function initiates centos-art command-line interface. +# Variables defined in this function are accesible by all other +# functions. The cli function is the first script executed by +# centos-art command-line onces invoked. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli { + + # Initialize global variables. + local CLI_FUNCNAME='' + local CLI_FUNCDIR='' + local CLI_FUNCDIRNAM='' + local CLI_FUNCSCRIPT='' + local ARGUMENTS='' + + # Initialize default value to filter flag. The filter flag + # (--filter) is used mainly to reduce the number of files to + # process. The value of this variable is interpreted as + # egrep-posix regular expression. By default, everything matches. + local FLAG_FILTER='.+' + + # Initialize default value to verbosity flag. The verbosity flag + # (--quiet) controls whether centos-art.sh script prints messages + # or not. By default, all messages are printed out. + local FLAG_QUIET='false' + + # Initialize default value to answer flag. The answer flag + # (--answer-yes) controls whether centos-art.sh script does or + # does not pass confirmation request points. By default, it + # doesn't. + local FLAG_ANSWER='false' + + # Initialize default value to don't commit changes flag. The don't + # commit changes flag (--dont-commit-changes) controls whether + # centos-art.sh script syncronizes changes between the central + # repository and the working copy. By default, it does. + local FLAG_DONT_COMMIT_CHANGES='false' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Define function directory (CLI_FUNCDIR). The directory path where + # functionalities are stored inside the repository. + CLI_FUNCDIR=${CLI_BASEDIR}/Functions + + # Check function name. The function name is critical for + # centos-art.sh script to do something coherent. If it is not + # provided, execute the help functionality and end script + # execution. + if [[ "$1" == '' ]];then + exec ${CLI_BASEDIR}/centos-art.sh help + exit + fi + + # Define function name (CLI_FUNCNAME) variable from first command-line + # argument. As convenction we use the first argument to determine + # the exact name of functionality to call. + CLI_FUNCNAME=$(cli_getRepoName $1 -f) + + # Define function directory. + CLI_FUNCDIRNAM=$(cli_getRepoName $CLI_FUNCNAME -d) + + # Define function file name. + CLI_FUNCSCRIPT=${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}/${CLI_FUNCNAME}.sh + + # Check function script execution rights. + cli_checkFiles "${CLI_FUNCSCRIPT}" --execution + + # 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 + + # Redefine ARGUMENTS using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Define default text editors used by centos-art.sh script. + if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then + EDITOR='/usr/bin/vim' + fi + + # Check text editor execution rights. + cli_checkFiles $EDITOR --execution + + # Go for function initialization. Keep the cli_exportFunctions + # function calling after all variables and arguments definitions. + cli_exportFunctions "${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}" + + # Execute function. + eval $CLI_FUNCNAME + +} diff --git a/Scripts/Bash/centos-art.sh b/Scripts/Bash/centos-art.sh index 6772f1e..571b71c 100755 --- a/Scripts/Bash/centos-art.sh +++ b/Scripts/Bash/centos-art.sh @@ -49,7 +49,7 @@ if [[ ! -d ${CLI_WRKCOPY} ]];then fi # Initialize common functions. -FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh) +FILES=$(ls ${CLI_BASEDIR}/Functions/{init,Commons/cli_*}.sh) for FILE in ${FILES};do if [[ -x ${FILE} ]];then . ${FILE}