From 3b3b3899fa77e70927a45cf3d40040e8821e58b1 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 16 2012 02:46:10 +0000 Subject: Update Functions directory structure. --- diff --git a/Scripts/Bash/Functions/Commons/cli_commitRepoChanges.sh b/Scripts/Bash/Functions/Commons/cli_commitRepoChanges.sh deleted file mode 100755 index 375f4f1..0000000 --- a/Scripts/Bash/Functions/Commons/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, 2012 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/Documentation/Manuals/Texinfo)' ]];then - STATUSOUT="$(svn status ${LOCATION} | egrep -v '(pdf|txt|xhtml|xml|docbook|bz2)$')\n$STATUSOUT" - elif [[ $LOCATION =~ 'trunk/Manuals/Documentation/Manuals/Docbook' ]];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_getTTFont.sh b/Scripts/Bash/Functions/Commons/cli_getTTFont.sh deleted file mode 100755 index b9bda9c..0000000 --- a/Scripts/Bash/Functions/Commons/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, 2012 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_isVersioned.sh b/Scripts/Bash/Functions/Commons/cli_isVersioned.sh deleted file mode 100755 index 897fa1a..0000000 --- a/Scripts/Bash/Functions/Commons/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, 2012 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_updateRepoChanges.sh b/Scripts/Bash/Functions/Commons/cli_updateRepoChanges.sh deleted file mode 100755 index 72cc826..0000000 --- a/Scripts/Bash/Functions/Commons/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, 2012 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/Render/Svg/svg_getTTFont.sh b/Scripts/Bash/Functions/Render/Svg/svg_getTTFont.sh new file mode 100755 index 0000000..8ec1fd7 --- /dev/null +++ b/Scripts/Bash/Functions/Render/Svg/svg_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, 2012 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 svg_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 + +}