diff --git a/Automation/centos-art.sh-prepare/Config/bash_profile.conf b/Automation/centos-art.sh-prepare/Config/bash_profile.conf deleted file mode 100755 index b7fbb7a..0000000 --- a/Automation/centos-art.sh-prepare/Config/bash_profile.conf +++ /dev/null @@ -1,20 +0,0 @@ -# .bash_profile - -# Get the aliases and functions -if [ -f ~/.bashrc ]; then - . ~/.bashrc -fi - -# User specific environment and startup programs - -PATH=$PATH:$HOME/bin -export PATH - -EDITOR=/usr/bin/vim -export EDITOR - -TCAR_WORKDIR= -export TCAR_WORKDIR - -TCAR_BRAND= -export TCAR_BRAND diff --git a/Automation/centos-art.sh-prepare/Config/vim.conf b/Automation/centos-art.sh-prepare/Config/vim.conf deleted file mode 100755 index e54c201..0000000 --- a/Automation/centos-art.sh-prepare/Config/vim.conf +++ /dev/null @@ -1,9 +0,0 @@ -set nu -set textwidth=70 -set autoindent -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set expandtab -set tags=./tags,tags -set spell diff --git a/Automation/centos-art.sh-prepare/Configs/bash_profile.conf b/Automation/centos-art.sh-prepare/Configs/bash_profile.conf new file mode 100755 index 0000000..b7fbb7a --- /dev/null +++ b/Automation/centos-art.sh-prepare/Configs/bash_profile.conf @@ -0,0 +1,20 @@ +# .bash_profile + +# Get the aliases and functions +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# User specific environment and startup programs + +PATH=$PATH:$HOME/bin +export PATH + +EDITOR=/usr/bin/vim +export EDITOR + +TCAR_WORKDIR= +export TCAR_WORKDIR + +TCAR_BRAND= +export TCAR_BRAND diff --git a/Automation/centos-art.sh-prepare/Configs/vim.conf b/Automation/centos-art.sh-prepare/Configs/vim.conf new file mode 100755 index 0000000..e54c201 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Configs/vim.conf @@ -0,0 +1,9 @@ +set nu +set textwidth=70 +set autoindent +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set expandtab +set tags=./tags,tags +set spell diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_getEnvars.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_getEnvars.sh new file mode 100755 index 0000000..345bd34 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_getEnvars.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# prepare_getEnvars.sh -- This function outputs a brief description of +# relevant environment variables used by `centos-art.sh' script. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_getEnvars { + + local -a VARS + local -a INFO + local COUNT=0 + + # Define name of environment variables used by centos-art.sh + # script. + VARS[0]='EDITOR' + VARS[1]='TZ' + VARS[2]='TEXTDOMAIN' + VARS[3]='TEXTDOMAINDIR' + VARS[4]='LANG' + + # Define description of environment variables. + INFO[0]="`gettext "Default text editor"`" + INFO[1]="`gettext "Default time zone representation"`" + INFO[2]="`gettext "Default domain used to retrieve translated messages"`" + INFO[3]="`gettext "Default directory used to retrive translated messages"`" + INFO[4]="`gettext "Default locale information"`" + + until [[ $COUNT -eq ${#VARS[*]} ]];do + + # Let user to reduce output using regular expression as + # reference. + if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then + + # Output list of environment variables using indirect + # expansion (what a beautiful feature!) to output variable + # value. + cli_printMessage "${INFO[$COUNT]}:" + cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" --as-response-line + + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_getLinkName.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_getLinkName.sh new file mode 100755 index 0000000..e14dbbf --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_getLinkName.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# prepare_getLinkName.sh -- This function standardizes link name +# construction. For the construction sake, two arguments are required, +# one to now the file's base directory, and another holding the file's +# absolute path. With this information, the base directory is removed +# from file's absolute path and the remaining path is transformed into +# a file name where each slash is converted into minus sign. +# +# For example, if the following information is provided: +# +# ARG1: /home/centos/artwork/Identity/Brushes +# ARG2: /home/centos/artwork/Identity/Brushes/Corporate/symbol.gbr +# +# the result will be: `corporate-symbol.gbr'. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_getLinkName { + + local LINK_BASEDIR='' + local LINK_ABSPATH='' + local LINK_CHARSEP='' + + # Define absolute path to link's base directory. + LINK_BASEDIR="$1" + + # Define absolute path to link's file. + LINK_ABSPATH="$2" + + # Define character used as word separator on file name. + LINK_CHARSEP='-' + + # Output link name. + echo "$LINK_ABSPATH" | sed -r "s!^${LINK_BASEDIR}/!!" \ + | tr '[:upper:]' '[:lower:]' | sed -r "s!/!${LINK_CHARSEP}!g" + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_getOptions.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_getOptions.sh new file mode 100755 index 0000000..484f8ac --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_getOptions.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# +# prepare_getOptions.sh -- This function parses command options +# provided to `centos-art.sh' script when the first argument in the +# command-line is the `prepare' word. To parse options, this function +# makes use of getopt program. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_getOptions { + + # Define short options we want to support. + local ARGSS="h,q" + + # Define long options we want to support. + local ARGSL="help,quiet,answer-yes,packages,locales,links,images,manuals,directories,set-environment,see-environment,synchronize" + + # Redefine CLI_FUNCTION_ARGUMENTS using getopt(1) command parser. + cli_parseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$CLI_FUNCTION_ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + -h | --help ) + cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-prepare" + shift 1 + exit + ;; + + -q | --quiet ) + FLAG_QUIET="true" + shift 1 + ;; + + --answer-yes ) + FLAG_ANSWER="true" + shift 1 + ;; + + --set-environment ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateEnvironment" + shift 1 + ;; + + --see-environment ) + ACTIONNAMS="${ACTIONNAMS} prepare_seeEnvironment" + shift 1 + ;; + + --packages ) + ACTIONNAMS="${ACTIONNAMS} prepare_updatePackages" + shift 1 + ;; + + --locales ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateLocales" + shift 1 + ;; + + --links ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateLinks" + shift 1 + ;; + + --images ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateImages" + shift 1 + ;; + + --manuals ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateManuals" + shift 1 + ;; + + --directories ) + ACTIONNAMS="${ACTIONNAMS} prepare_updateDirectoryStructure" + shift 1 + ;; + + --synchronize ) + FLAG_SYNCHRONIZE="true" + shift 1 + ;; + + -- ) + # Remove the `--' argument from the list of arguments + # in order for processing non-option arguments + # correctly. At this point all option arguments have + # been processed already but the `--' argument still + # remains to mark ending of option arguments and + # beginning of non-option arguments. The `--' argument + # needs to be removed here in order to avoid + # centos-art.sh script to process it as a path inside + # the repository, which obviously is not. + shift 1 + break + ;; + + esac + done + + # Redefine CLI_FUNCTION_ARGUMENTS variable using current + # positional parameters. + cli_parseArgumentsReDef "$@" + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_seeEnvironment.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_seeEnvironment.sh new file mode 100755 index 0000000..b0d98cf --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_seeEnvironment.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# prepare_seeEnvironment.sh -- This function outputs a brief description of +# relevant environment variables used by `centos-art.sh' script. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_seeEnvironment { + + local -a VARS + local -a INFO + local COUNT=0 + + # Define name of environment variables used by centos-art.sh + # script. + VARS[0]='EDITOR' + VARS[1]='TZ' + VARS[2]='TEXTDOMAIN' + VARS[3]='TEXTDOMAINDIR' + VARS[4]='LANG' + VARS[5]='TCAR_WORKDIR' + + # Define description of environment variables. + INFO[0]="`gettext "Default text editor"`" + INFO[1]="`gettext "Default time zone representation"`" + INFO[2]="`gettext "Default domain used to retrieve translated messages"`" + INFO[3]="`gettext "Default directory used to retrive translated messages"`" + INFO[4]="`gettext "Default locale information"`" + INFO[5]="`gettext "Default path to your working copy"`" + + until [[ $COUNT -eq ${#VARS[*]} ]];do + + # Let user to reduce output using regular expression as + # reference. + if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then + + # Output list of environment variables using indirect + # expansion (what a beautiful feature!) to output variable + # value. + cli_printMessage "${INFO[$COUNT]}:" + cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" --as-response-line + + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateDirectoryStructure.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateDirectoryStructure.sh new file mode 100755 index 0000000..b7c8f7f --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateDirectoryStructure.sh @@ -0,0 +1,111 @@ +#!/bin/bash +# +# prepare_updateDirectoryStructure.sh -- This function standardizes +# the relation between source directory structures and target +# directory structures inside the repository. This function takes +# source and target paths as arguments, analyses them and builds the +# target directory structure based on source directory structure. This +# function must be executed before executing production functions like +# render. +# +# In order for this verification to work, all source directory +# structures provided must be organized using one directory level more +# than its related target directory. The purpose of this directory is +# content categorization. For example, consider the following path: +# +# ---------------++++++++++++++++++++++++ +# ${SOURCE_PATH}/${CATEGORY}/${COMPONENT} +# ---------------++++++++++++++++++++++++ +# ++++++++++++++++++++++++++++++++++------------ +# ${TARGET_PATH}/${NAME}/${VERSION}/${COMPONENT} +# ++++++++++++++++++++++++++++++++++------------ +# +# So we end with the following path: +# +# ${TARGET_PATH}/${CATEGORY}/${COMPONENT} +# +# In this path, ${CATEGORY} makes reference to a categorization +# directory used to describe source components related to target +# components. However, in the target side, such ${CATEGORY} directory +# is not needed and should be removed from it in order to get the +# final target path, which is: +# +# ${TARGET_PATH}/${COMPONENT} +# +# ${CATEGORY} is always a one-level directory, but ${COMPONENT} might +# have several levels deep. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateDirectoryStructure { + + # Define absolute path to design models' directory structure. This + # directory contains the directory structure you want to verify + # inside target path. + local SOURCE_PATH=$(cli_checkRepoDirSource "${1}") + + # Verify existence source path, just to be sure it was passed and + # it is a valid directory. + cli_checkFiles ${SOURCE_PATH} -d + + # Define absolute path to directory inside the repository where + # you want to replicate the source path directory structure. + local TARGET_PATH=$(cli_checkRepoDirSource "${2}") + + # NOTE: It is possible that target path doesn't exist. So verify + # the relation between target and source path. If there is a + # source path for the target, create an empty directory as target, + # using the related source directory as reference. + + # Define list of directories inside source path. + local SOURCE_DIRS=$(cli_getFilesList ${SOURCE_PATH} \ + --pattern='.+/[[:alpha:]]+$' --type=d) + + # Iterate through directories inside source path and verify + # whether or not they exist in the target path. If they don't + # exist create them. + for SOURCE_DIR in ${SOURCE_DIRS};do + + local SOURCE_DIR_BASENAME=$(echo ${SOURCE_DIR} \ + | sed -r "s,${SOURCE_PATH}/,,") + + local TARGET_DIR=${TARGET_PATH}/${SOURCE_DIR_BASENAME} + + if [[ ${SOURCE_DIR} == ${SOURCE_DIR_BASENAME} ]];then + continue + fi + + # Keep this for debugging ;) + #echo '---' + #echo $SOURCE_DIR_BASENAME; + #echo $SOURCE_DIR; + #echo $TARGET_DIR; + #echo $TARGET_PATH; + #echo '---' + #continue + + if [[ ! -d ${TARGET_DIR} ]];then + mkdir -p ${TARGET_DIR} + fi + + done + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateEnvironment.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateEnvironment.sh new file mode 100755 index 0000000..9128015 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateEnvironment.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# prepare_updateEnvironment.sh -- This function updates the +# `~/.bash_profile' file to provide default configuration values to +# centos-art.sh script. Those values which aren't set by this function +# are already set in the `bash_profile.conf' template file we use as +# reference to create the `~/.bash_profile' file. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateEnvironment { + + # Verify that centos-art.sh script is run using an absolute path. + # We use this information to determine the exact working copy + # location to use, later when `bash_profile' file is created. + if [[ ! $0 =~ "^${HOME}/.+/${CLI_NAME}.sh$" ]];then + cli_printMessage "`gettext "To set environment variables you should run centos-art.sh using its abosolute path."`" --as-error-line + fi + + local PROFILE=bash_profile + local SOURCE=${PREPARE_CONFIG_DIR}/${PROFILE}.conf + local TARGET=${HOME}/.${PROFILE} + + # Determine the repository absolute path using the script absolute + # path the script has been executed from. Be careful when you use + # the centos-art command. It points to ~/bin directory which is + # not (and must not be) the repository working copy absolute path. + if [[ $TCAR_WORKDIR =~ "^${HOME}/bin" ]];then + cli_printMessage "`eval_gettext "The repository working directory cannot be $HOME/bin"`" --as-error-line + else + local TCAR_WORKDIR=$(dirname "$0" | sed "s,/${TCAR_BASHSCRIPTS},,") + fi + + # Determine which is the brand information that will be used as + # repository brand information. By default we are using `centos' + # and shouldn't be change to anything else, at least if you + # pretend to produce content for The CentOS Project. + local TCAR_BRAND='centos' + + # Print action message. + cli_printMessage "${TARGET}" --as-updating-line + + # Copy default configuration file to its final destination. Note + # that we are not making a link here in order for different users + # to be able of using different values in their own environments. + cp -f $SOURCE $TARGET + + # Update bash_profile file with default values. + sed -i -r \ + -e "s,^(TCAR_WORKDIR=).*,\1${TCAR_WORKDIR}," \ + -e "s,^(TCAR_BRAND=).*,\1${TCAR_BRAND}," \ + ${TARGET} + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateImages.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateImages.sh new file mode 100755 index 0000000..6b5b030 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateImages.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# prepare_updateImages.sh -- This option initializes image files inside +# the working copy. When you provide this option, the centos-art.sh +# scripts renders image files from all design models available in the +# working copy. This step is required in order to satisfy dependencies +# from different components inside the working copy. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateImages { + + # Define list of directories that need to be rendered. + local DIRS=$(cli_getFilesList \ + ${TCAR_WORKDIR}/Identity/Images --maxdepth="1" \ + --mindepth="1" --type="d" --pattern=".+/[[:alnum:]]+") + + # CAUTION: The order in which the image components are rendered is + # very important. For example, in order for theme images to hold + # the branding information the `Identity/Images/Brands' directory + # must be rendered before the `Identity/Images/Themes' directory. + # The reason of this is that brand images are not draw inside + # theme design models themselves, but combined with theme images + # using the ImageMagick tool suite once both have been rendered. + + # Update list of directories to be sure that brands will always be + # rendered as first image component. Here we remove the brand + # component from the list and add it explicitly on top of all + # other directories in the list. + DIRS="${TCAR_WORKDIR}/Identity/Images/Brands + $(echo "$DIRS" | grep -v 'Identity/Images/Brands')" + + # Render image components using the list of directories. + cli_runFnEnvironment render ${DIRS} --with-brands + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateLinks.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateLinks.sh new file mode 100755 index 0000000..70a18fb --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateLinks.sh @@ -0,0 +1,183 @@ +#!/bin/bash +# +# prepare_updateLinks.sh -- This option creates/updates the symbolic links +# information required in your workstation to connect it with the +# files inside the working copy of The CentOS Artwork Repository. When +# you provide this option, the centos-art.sh put itself into your +# system's execution path and make common brushes, patterns, palettes +# and fonts available inside applications like GIMP, so you can make +# use of them without loosing version control over them. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateLinks { + + local -a LINKS_SRC + local -a LINKS_DST + local USERFILES='' + local PALETTE='' + local BRUSH='' + local PATTERN='' + local FONT='' + local FILE='' + local COUNT=0 + + # Define user's directories. Here is where configuration links are + # created in the local workstation. + local GIMP_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2) + local GIMP_DIR_BRUSHES=${GIMP_DIR}/brushes + local GIMP_DIR_PALETTES=${GIMP_DIR}/palettes + local GIMP_DIR_PATTERNS=${GIMP_DIR}/patterns + local INKS_DIR=${HOME}/.inkscape + local INKS_DIR_PALETTES=${INKS_DIR}/palettes + local FONT_DIR=${HOME}/.fonts + local APPS_DIR=${HOME}/bin + + # Define the working copy directory structure. Here is where user + # specific configuration links in the workstation will point to. + local WCDIR=${TCAR_WORKDIR}/Identity + local WCDIR_BRUSHES=${WCDIR}/Brushes + local WCDIR_PALETTES=${WCDIR}/Palettes + local WCDIR_PATTERNS=${WCDIR}/Patterns + local WCDIR_FONTS=${WCDIR}/Fonts + local WCDIR_EDITOR=${PREPARE_CONFIG_DIR} + + # Verify required working copy directory structure. If these + # directories don't exist, there isn't a target location where + # configuration links can point to. To prevent such an issue + # output an error message and stop the script execution after it. + for DIR in $(echo "Brushes Palettes Patterns Fonts");do + cli_checkFiles ${WCDIR}/${DIR} + done + + # Define link relation for cli. + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${APPS_DIR}/${CLI_NAME} + LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_NAME}.sh + USERFILES="${APPS_DIR}/${CLI_NAME}" + + # Define link relation for fonts. + for FONT in $(cli_getFilesList "${WCDIR_FONTS}" --pattern='^.+\.ttf$');do + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${FONT_DIR}/$(basename $FONT) + LINKS_DST[((++${#LINKS_DST[*]}))]=${FONT} + done + + # Define link relation for common palettes. + for PALETTE in $(cli_getFilesList "${WCDIR_PALETTES}" --pattern="^.+\.gpl$");do + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE}) + LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE} + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE}) + LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE} + done + + # Define link relation for common brushes. + for BRUSH in $(cli_getFilesList "${WCDIR_BRUSHES}" --pattern="^.+\.(gbr|gih)$");do + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_BRUSHES}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH}) + LINKS_DST[((++${#LINKS_DST[*]}))]=${BRUSH} + done + + # Define link relation for common patterns. + for PATTERN in $(cli_getFilesList "${WCDIR_PATTERNS}" --pattern="^.+\.png$");do + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PATTERNS}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH}) + LINKS_DST[((++${#LINKS_DST[*]}))]=${PATTERN} + done + + # Define link relation for Vim text editor's configuration. + if [[ $EDITOR == '/usr/bin/vim' ]];then + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc + LINKS_DST[((++${#LINKS_DST[*]}))]=${WCDIR_EDITOR}/vim.conf + USERFILES="${USERFILES} ${HOME}/.vimrc" + fi + + # Define link relation for the `reset.css' file. The `reset.css' + # file is resets the web browser default style and use ours + # instead. The reset.css file is common for all web environments + # so there is no need to have duplicated files inside the working + # copy. Instead, create a symbolic link to it from different + # places using absolute paths and the default style guide as + # reference. + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css/reset.css + LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Css/reset.css + + # Define link relation for `images' directory used inside the + # default web environment style guide. The `images' directory + # contains common images used by all web environments. By default + # no image is under version control so we point out the output + # directory where this images produced, once rendered. + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Images + LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv + + # Define link relation for `Manuals' images. These images exists + # to help people describe ideas inside documentation. + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/Manuals + LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Manuals + + # Define link for `centos-logo.png', the branding information that + # should be used in all web applications on the left-top corner. + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/logo-centos.png + LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Brands/Logos/White/78/centos.png + + # Define which files inside the user's configuration directories + # need to be removed in order for centos-art.sh script to make a + # fresh installation of common patterns, common palettes and + # common brushes using symbolic links from the working copy to the + # user's configuration directories inside the workstation. + USERFILES=$(echo "$USERFILES"; + cli_getFilesList ${APPS_DIR} --pattern='^.+\.sh$'; + cli_getFilesList ${FONT_DIR} --pattern='^.+\.ttf$'; + cli_getFilesList ${GIMP_DIR_BRUSHES} --pattern='^.+\.(gbr|gih)$'; + cli_getFilesList ${GIMP_DIR_PATTERNS} --pattern='^.+\.(pat|png|jpg|bmp)$'; + cli_getFilesList ${GIMP_DIR_PALETTES} --pattern='^.+\.gpl$'; + cli_getFilesList ${INKS_DIR_PALETTES} --pattern='^.+\.gpl$';) + + # Remove user-specific configuration files from user's home + # directory before creating symbolic links from the working copy. + # Otherwise, we might end up having links inside the user's home + # directory that don't exist inside the working copy. + if [[ "$USERFILES" != '' ]];then + rm -r $USERFILES + fi + + while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do + + # Print action message. + cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line + + # Create symbolic link's parent directory if it doesn't exist. + if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then + mkdir -p $(dirname ${LINKS_SRC[$COUNT]}) + fi + + # Remove symbolic link before creating it to prevent recursive + # creation once the first symbolic link be created and it be a + # directory. + if [[ -a ${LINKS_SRC[$COUNT]} ]];then + rm ${LINKS_SRC[$COUNT]} + fi + + # Create symbolic link. + ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateLocales.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateLocales.sh new file mode 100755 index 0000000..bb66e22 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateLocales.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# prepare_updateLocales.sh -- This function creates/updates the +# machine object (.mo) file gettext uses to output translated messages +# when centos-art.sh script is running. Certainly, what this function +# really does is a call to the locale functionality of centos-art.sh +# script to realize and update action against itself. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateLocales { + + # Realize localization tasks only when the current locale + # information is different to English language. Otherwise + # centos-art.sh would complain with an `English language cannot be + # localized to itself' message. Avoid this noise in the + # preparation stuff. + if [[ ! ${CLI_LANG_LL} =~ '^en' ]];then + cli_runFnEnvironment locale Scripts/Bash --update + fi + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updateManuals.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updateManuals.sh new file mode 100755 index 0000000..a5f5a40 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updateManuals.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# prepare_updateManuals.sh -- This option initializes documentation files +# inside the working copy. When you provide this option, the +# centos-art.sh script renders all documentation manuals from their +# related source files so you can read them nicely. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updateManuals { + + # Render key documentation manuals. + cli_runFnEnvironment render Documentation/Models/Docbook/Tcar-ug + cli_runFnEnvironment help --update --format="texinfo" tcar-fs::: + +} diff --git a/Automation/centos-art.sh-prepare/Scripts/prepare_updatePackages.sh b/Automation/centos-art.sh-prepare/Scripts/prepare_updatePackages.sh new file mode 100755 index 0000000..fdf2fc0 --- /dev/null +++ b/Automation/centos-art.sh-prepare/Scripts/prepare_updatePackages.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# prepare_updatePackages.sh -- This function verifies the required +# packages your workstation needs to have installed in order for +# `centos-art.sh' script to run correctly. If there is one or more +# missing packages, the `centos-art.sh' script asks you to confirm +# their installation through `sudo yum'. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_updatePackages { + + local PACKAGE='' + local PACKAGES='' + local PACKAGES_THIRDS='' + local -a PACKAGES_MISSING + local -a PACKAGES_INSTALL + local RPM='/bin/rpm' + local YUM='/usr/bin/yum' + local YUM_OPTIONS='' + + # Check execution rights of package managers. + cli_checkFiles -x $RPM + cli_checkFiles -x $YUM + + # Define required packages needed by centos-art.sh script. + PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp + coreutils texinfo texinfo-tex info tetex-latex tetex-fonts + tetex-xdvi tetex-dvips gettext texi2html gnome-doc-utils + elinks docbook-style-xsl docbook-utils docbook-dtds + docbook-style-dsssl docbook-simple docbook-utils-pdf + docbook-slides firefox sudo yum rpm ctags vim-enhanced" + + # Define packages from third party repositories (i.e., packages + # not included in CentOS [base] repository.) required by + # centos-art to work as expected. + PACKAGES_THIRDS="(inkscape|blender)" + + # Build list of installed and missing packages. + for PACKAGE in $PACKAGES;do + $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet + if [[ $? -ne 0 ]];then + PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE + else + PACKAGES_INSTALL[((++${#PACKAGES_INSTALL[*]}))]=$PACKAGE + fi + done + + # Define relation between centos-art.sh options and yum options. + [[ $FLAG_ANSWER == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -y" + [[ $FLAG_QUIET == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -q" + + # Use `sudo yum' to install missing packages in your workstation. + if [[ ${#PACKAGES_MISSING[*]} -gt 0 ]];then + sudo ${YUM} ${YUM_OPTIONS} install ${PACKAGES_MISSING[*]} + fi + + # Use `sudo yum' to update installed packages in your workstation. + if [[ ${#PACKAGES_INSTALL[*]} -gt 0 ]];then + sudo ${YUM} ${YUM_OPTIONS} update ${PACKAGES_INSTALL[*]} + fi + +} diff --git a/Automation/centos-art.sh-prepare/prepare_getEnvars.sh b/Automation/centos-art.sh-prepare/prepare_getEnvars.sh deleted file mode 100755 index 345bd34..0000000 --- a/Automation/centos-art.sh-prepare/prepare_getEnvars.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# -# prepare_getEnvars.sh -- This function outputs a brief description of -# relevant environment variables used by `centos-art.sh' script. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_getEnvars { - - local -a VARS - local -a INFO - local COUNT=0 - - # Define name of environment variables used by centos-art.sh - # script. - VARS[0]='EDITOR' - VARS[1]='TZ' - VARS[2]='TEXTDOMAIN' - VARS[3]='TEXTDOMAINDIR' - VARS[4]='LANG' - - # Define description of environment variables. - INFO[0]="`gettext "Default text editor"`" - INFO[1]="`gettext "Default time zone representation"`" - INFO[2]="`gettext "Default domain used to retrieve translated messages"`" - INFO[3]="`gettext "Default directory used to retrive translated messages"`" - INFO[4]="`gettext "Default locale information"`" - - until [[ $COUNT -eq ${#VARS[*]} ]];do - - # Let user to reduce output using regular expression as - # reference. - if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then - - # Output list of environment variables using indirect - # expansion (what a beautiful feature!) to output variable - # value. - cli_printMessage "${INFO[$COUNT]}:" - cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" --as-response-line - - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Automation/centos-art.sh-prepare/prepare_getLinkName.sh b/Automation/centos-art.sh-prepare/prepare_getLinkName.sh deleted file mode 100755 index e14dbbf..0000000 --- a/Automation/centos-art.sh-prepare/prepare_getLinkName.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# prepare_getLinkName.sh -- This function standardizes link name -# construction. For the construction sake, two arguments are required, -# one to now the file's base directory, and another holding the file's -# absolute path. With this information, the base directory is removed -# from file's absolute path and the remaining path is transformed into -# a file name where each slash is converted into minus sign. -# -# For example, if the following information is provided: -# -# ARG1: /home/centos/artwork/Identity/Brushes -# ARG2: /home/centos/artwork/Identity/Brushes/Corporate/symbol.gbr -# -# the result will be: `corporate-symbol.gbr'. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_getLinkName { - - local LINK_BASEDIR='' - local LINK_ABSPATH='' - local LINK_CHARSEP='' - - # Define absolute path to link's base directory. - LINK_BASEDIR="$1" - - # Define absolute path to link's file. - LINK_ABSPATH="$2" - - # Define character used as word separator on file name. - LINK_CHARSEP='-' - - # Output link name. - echo "$LINK_ABSPATH" | sed -r "s!^${LINK_BASEDIR}/!!" \ - | tr '[:upper:]' '[:lower:]' | sed -r "s!/!${LINK_CHARSEP}!g" - -} diff --git a/Automation/centos-art.sh-prepare/prepare_getOptions.sh b/Automation/centos-art.sh-prepare/prepare_getOptions.sh deleted file mode 100755 index 484f8ac..0000000 --- a/Automation/centos-art.sh-prepare/prepare_getOptions.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -# -# prepare_getOptions.sh -- This function parses command options -# provided to `centos-art.sh' script when the first argument in the -# command-line is the `prepare' word. To parse options, this function -# makes use of getopt program. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_getOptions { - - # Define short options we want to support. - local ARGSS="h,q" - - # Define long options we want to support. - local ARGSL="help,quiet,answer-yes,packages,locales,links,images,manuals,directories,set-environment,see-environment,synchronize" - - # Redefine CLI_FUNCTION_ARGUMENTS using getopt(1) command parser. - cli_parseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$CLI_FUNCTION_ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - -h | --help ) - cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-prepare" - shift 1 - exit - ;; - - -q | --quiet ) - FLAG_QUIET="true" - shift 1 - ;; - - --answer-yes ) - FLAG_ANSWER="true" - shift 1 - ;; - - --set-environment ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateEnvironment" - shift 1 - ;; - - --see-environment ) - ACTIONNAMS="${ACTIONNAMS} prepare_seeEnvironment" - shift 1 - ;; - - --packages ) - ACTIONNAMS="${ACTIONNAMS} prepare_updatePackages" - shift 1 - ;; - - --locales ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateLocales" - shift 1 - ;; - - --links ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateLinks" - shift 1 - ;; - - --images ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateImages" - shift 1 - ;; - - --manuals ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateManuals" - shift 1 - ;; - - --directories ) - ACTIONNAMS="${ACTIONNAMS} prepare_updateDirectoryStructure" - shift 1 - ;; - - --synchronize ) - FLAG_SYNCHRONIZE="true" - shift 1 - ;; - - -- ) - # Remove the `--' argument from the list of arguments - # in order for processing non-option arguments - # correctly. At this point all option arguments have - # been processed already but the `--' argument still - # remains to mark ending of option arguments and - # beginning of non-option arguments. The `--' argument - # needs to be removed here in order to avoid - # centos-art.sh script to process it as a path inside - # the repository, which obviously is not. - shift 1 - break - ;; - - esac - done - - # Redefine CLI_FUNCTION_ARGUMENTS variable using current - # positional parameters. - cli_parseArgumentsReDef "$@" - -} diff --git a/Automation/centos-art.sh-prepare/prepare_seeEnvironment.sh b/Automation/centos-art.sh-prepare/prepare_seeEnvironment.sh deleted file mode 100755 index b0d98cf..0000000 --- a/Automation/centos-art.sh-prepare/prepare_seeEnvironment.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# -# prepare_seeEnvironment.sh -- This function outputs a brief description of -# relevant environment variables used by `centos-art.sh' script. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_seeEnvironment { - - local -a VARS - local -a INFO - local COUNT=0 - - # Define name of environment variables used by centos-art.sh - # script. - VARS[0]='EDITOR' - VARS[1]='TZ' - VARS[2]='TEXTDOMAIN' - VARS[3]='TEXTDOMAINDIR' - VARS[4]='LANG' - VARS[5]='TCAR_WORKDIR' - - # Define description of environment variables. - INFO[0]="`gettext "Default text editor"`" - INFO[1]="`gettext "Default time zone representation"`" - INFO[2]="`gettext "Default domain used to retrieve translated messages"`" - INFO[3]="`gettext "Default directory used to retrive translated messages"`" - INFO[4]="`gettext "Default locale information"`" - INFO[5]="`gettext "Default path to your working copy"`" - - until [[ $COUNT -eq ${#VARS[*]} ]];do - - # Let user to reduce output using regular expression as - # reference. - if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then - - # Output list of environment variables using indirect - # expansion (what a beautiful feature!) to output variable - # value. - cli_printMessage "${INFO[$COUNT]}:" - cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" --as-response-line - - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateDirectoryStructure.sh b/Automation/centos-art.sh-prepare/prepare_updateDirectoryStructure.sh deleted file mode 100755 index b7c8f7f..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateDirectoryStructure.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# -# prepare_updateDirectoryStructure.sh -- This function standardizes -# the relation between source directory structures and target -# directory structures inside the repository. This function takes -# source and target paths as arguments, analyses them and builds the -# target directory structure based on source directory structure. This -# function must be executed before executing production functions like -# render. -# -# In order for this verification to work, all source directory -# structures provided must be organized using one directory level more -# than its related target directory. The purpose of this directory is -# content categorization. For example, consider the following path: -# -# ---------------++++++++++++++++++++++++ -# ${SOURCE_PATH}/${CATEGORY}/${COMPONENT} -# ---------------++++++++++++++++++++++++ -# ++++++++++++++++++++++++++++++++++------------ -# ${TARGET_PATH}/${NAME}/${VERSION}/${COMPONENT} -# ++++++++++++++++++++++++++++++++++------------ -# -# So we end with the following path: -# -# ${TARGET_PATH}/${CATEGORY}/${COMPONENT} -# -# In this path, ${CATEGORY} makes reference to a categorization -# directory used to describe source components related to target -# components. However, in the target side, such ${CATEGORY} directory -# is not needed and should be removed from it in order to get the -# final target path, which is: -# -# ${TARGET_PATH}/${COMPONENT} -# -# ${CATEGORY} is always a one-level directory, but ${COMPONENT} might -# have several levels deep. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateDirectoryStructure { - - # Define absolute path to design models' directory structure. This - # directory contains the directory structure you want to verify - # inside target path. - local SOURCE_PATH=$(cli_checkRepoDirSource "${1}") - - # Verify existence source path, just to be sure it was passed and - # it is a valid directory. - cli_checkFiles ${SOURCE_PATH} -d - - # Define absolute path to directory inside the repository where - # you want to replicate the source path directory structure. - local TARGET_PATH=$(cli_checkRepoDirSource "${2}") - - # NOTE: It is possible that target path doesn't exist. So verify - # the relation between target and source path. If there is a - # source path for the target, create an empty directory as target, - # using the related source directory as reference. - - # Define list of directories inside source path. - local SOURCE_DIRS=$(cli_getFilesList ${SOURCE_PATH} \ - --pattern='.+/[[:alpha:]]+$' --type=d) - - # Iterate through directories inside source path and verify - # whether or not they exist in the target path. If they don't - # exist create them. - for SOURCE_DIR in ${SOURCE_DIRS};do - - local SOURCE_DIR_BASENAME=$(echo ${SOURCE_DIR} \ - | sed -r "s,${SOURCE_PATH}/,,") - - local TARGET_DIR=${TARGET_PATH}/${SOURCE_DIR_BASENAME} - - if [[ ${SOURCE_DIR} == ${SOURCE_DIR_BASENAME} ]];then - continue - fi - - # Keep this for debugging ;) - #echo '---' - #echo $SOURCE_DIR_BASENAME; - #echo $SOURCE_DIR; - #echo $TARGET_DIR; - #echo $TARGET_PATH; - #echo '---' - #continue - - if [[ ! -d ${TARGET_DIR} ]];then - mkdir -p ${TARGET_DIR} - fi - - done - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateEnvironment.sh b/Automation/centos-art.sh-prepare/prepare_updateEnvironment.sh deleted file mode 100755 index 9128015..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateEnvironment.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# prepare_updateEnvironment.sh -- This function updates the -# `~/.bash_profile' file to provide default configuration values to -# centos-art.sh script. Those values which aren't set by this function -# are already set in the `bash_profile.conf' template file we use as -# reference to create the `~/.bash_profile' file. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateEnvironment { - - # Verify that centos-art.sh script is run using an absolute path. - # We use this information to determine the exact working copy - # location to use, later when `bash_profile' file is created. - if [[ ! $0 =~ "^${HOME}/.+/${CLI_NAME}.sh$" ]];then - cli_printMessage "`gettext "To set environment variables you should run centos-art.sh using its abosolute path."`" --as-error-line - fi - - local PROFILE=bash_profile - local SOURCE=${PREPARE_CONFIG_DIR}/${PROFILE}.conf - local TARGET=${HOME}/.${PROFILE} - - # Determine the repository absolute path using the script absolute - # path the script has been executed from. Be careful when you use - # the centos-art command. It points to ~/bin directory which is - # not (and must not be) the repository working copy absolute path. - if [[ $TCAR_WORKDIR =~ "^${HOME}/bin" ]];then - cli_printMessage "`eval_gettext "The repository working directory cannot be $HOME/bin"`" --as-error-line - else - local TCAR_WORKDIR=$(dirname "$0" | sed "s,/${TCAR_BASHSCRIPTS},,") - fi - - # Determine which is the brand information that will be used as - # repository brand information. By default we are using `centos' - # and shouldn't be change to anything else, at least if you - # pretend to produce content for The CentOS Project. - local TCAR_BRAND='centos' - - # Print action message. - cli_printMessage "${TARGET}" --as-updating-line - - # Copy default configuration file to its final destination. Note - # that we are not making a link here in order for different users - # to be able of using different values in their own environments. - cp -f $SOURCE $TARGET - - # Update bash_profile file with default values. - sed -i -r \ - -e "s,^(TCAR_WORKDIR=).*,\1${TCAR_WORKDIR}," \ - -e "s,^(TCAR_BRAND=).*,\1${TCAR_BRAND}," \ - ${TARGET} - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateImages.sh b/Automation/centos-art.sh-prepare/prepare_updateImages.sh deleted file mode 100755 index 6b5b030..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateImages.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# prepare_updateImages.sh -- This option initializes image files inside -# the working copy. When you provide this option, the centos-art.sh -# scripts renders image files from all design models available in the -# working copy. This step is required in order to satisfy dependencies -# from different components inside the working copy. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateImages { - - # Define list of directories that need to be rendered. - local DIRS=$(cli_getFilesList \ - ${TCAR_WORKDIR}/Identity/Images --maxdepth="1" \ - --mindepth="1" --type="d" --pattern=".+/[[:alnum:]]+") - - # CAUTION: The order in which the image components are rendered is - # very important. For example, in order for theme images to hold - # the branding information the `Identity/Images/Brands' directory - # must be rendered before the `Identity/Images/Themes' directory. - # The reason of this is that brand images are not draw inside - # theme design models themselves, but combined with theme images - # using the ImageMagick tool suite once both have been rendered. - - # Update list of directories to be sure that brands will always be - # rendered as first image component. Here we remove the brand - # component from the list and add it explicitly on top of all - # other directories in the list. - DIRS="${TCAR_WORKDIR}/Identity/Images/Brands - $(echo "$DIRS" | grep -v 'Identity/Images/Brands')" - - # Render image components using the list of directories. - cli_runFnEnvironment render ${DIRS} --with-brands - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateLinks.sh b/Automation/centos-art.sh-prepare/prepare_updateLinks.sh deleted file mode 100755 index 70a18fb..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateLinks.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash -# -# prepare_updateLinks.sh -- This option creates/updates the symbolic links -# information required in your workstation to connect it with the -# files inside the working copy of The CentOS Artwork Repository. When -# you provide this option, the centos-art.sh put itself into your -# system's execution path and make common brushes, patterns, palettes -# and fonts available inside applications like GIMP, so you can make -# use of them without loosing version control over them. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateLinks { - - local -a LINKS_SRC - local -a LINKS_DST - local USERFILES='' - local PALETTE='' - local BRUSH='' - local PATTERN='' - local FONT='' - local FILE='' - local COUNT=0 - - # Define user's directories. Here is where configuration links are - # created in the local workstation. - local GIMP_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2) - local GIMP_DIR_BRUSHES=${GIMP_DIR}/brushes - local GIMP_DIR_PALETTES=${GIMP_DIR}/palettes - local GIMP_DIR_PATTERNS=${GIMP_DIR}/patterns - local INKS_DIR=${HOME}/.inkscape - local INKS_DIR_PALETTES=${INKS_DIR}/palettes - local FONT_DIR=${HOME}/.fonts - local APPS_DIR=${HOME}/bin - - # Define the working copy directory structure. Here is where user - # specific configuration links in the workstation will point to. - local WCDIR=${TCAR_WORKDIR}/Identity - local WCDIR_BRUSHES=${WCDIR}/Brushes - local WCDIR_PALETTES=${WCDIR}/Palettes - local WCDIR_PATTERNS=${WCDIR}/Patterns - local WCDIR_FONTS=${WCDIR}/Fonts - local WCDIR_EDITOR=${PREPARE_CONFIG_DIR} - - # Verify required working copy directory structure. If these - # directories don't exist, there isn't a target location where - # configuration links can point to. To prevent such an issue - # output an error message and stop the script execution after it. - for DIR in $(echo "Brushes Palettes Patterns Fonts");do - cli_checkFiles ${WCDIR}/${DIR} - done - - # Define link relation for cli. - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${APPS_DIR}/${CLI_NAME} - LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_NAME}.sh - USERFILES="${APPS_DIR}/${CLI_NAME}" - - # Define link relation for fonts. - for FONT in $(cli_getFilesList "${WCDIR_FONTS}" --pattern='^.+\.ttf$');do - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${FONT_DIR}/$(basename $FONT) - LINKS_DST[((++${#LINKS_DST[*]}))]=${FONT} - done - - # Define link relation for common palettes. - for PALETTE in $(cli_getFilesList "${WCDIR_PALETTES}" --pattern="^.+\.gpl$");do - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE}) - LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE} - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE}) - LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE} - done - - # Define link relation for common brushes. - for BRUSH in $(cli_getFilesList "${WCDIR_BRUSHES}" --pattern="^.+\.(gbr|gih)$");do - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_BRUSHES}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH}) - LINKS_DST[((++${#LINKS_DST[*]}))]=${BRUSH} - done - - # Define link relation for common patterns. - for PATTERN in $(cli_getFilesList "${WCDIR_PATTERNS}" --pattern="^.+\.png$");do - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PATTERNS}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH}) - LINKS_DST[((++${#LINKS_DST[*]}))]=${PATTERN} - done - - # Define link relation for Vim text editor's configuration. - if [[ $EDITOR == '/usr/bin/vim' ]];then - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc - LINKS_DST[((++${#LINKS_DST[*]}))]=${WCDIR_EDITOR}/vim.conf - USERFILES="${USERFILES} ${HOME}/.vimrc" - fi - - # Define link relation for the `reset.css' file. The `reset.css' - # file is resets the web browser default style and use ours - # instead. The reset.css file is common for all web environments - # so there is no need to have duplicated files inside the working - # copy. Instead, create a symbolic link to it from different - # places using absolute paths and the default style guide as - # reference. - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css/reset.css - LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Css/reset.css - - # Define link relation for `images' directory used inside the - # default web environment style guide. The `images' directory - # contains common images used by all web environments. By default - # no image is under version control so we point out the output - # directory where this images produced, once rendered. - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Images - LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv - - # Define link relation for `Manuals' images. These images exists - # to help people describe ideas inside documentation. - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/Manuals - LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Manuals - - # Define link for `centos-logo.png', the branding information that - # should be used in all web applications on the left-top corner. - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/logo-centos.png - LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Brands/Logos/White/78/centos.png - - # Define which files inside the user's configuration directories - # need to be removed in order for centos-art.sh script to make a - # fresh installation of common patterns, common palettes and - # common brushes using symbolic links from the working copy to the - # user's configuration directories inside the workstation. - USERFILES=$(echo "$USERFILES"; - cli_getFilesList ${APPS_DIR} --pattern='^.+\.sh$'; - cli_getFilesList ${FONT_DIR} --pattern='^.+\.ttf$'; - cli_getFilesList ${GIMP_DIR_BRUSHES} --pattern='^.+\.(gbr|gih)$'; - cli_getFilesList ${GIMP_DIR_PATTERNS} --pattern='^.+\.(pat|png|jpg|bmp)$'; - cli_getFilesList ${GIMP_DIR_PALETTES} --pattern='^.+\.gpl$'; - cli_getFilesList ${INKS_DIR_PALETTES} --pattern='^.+\.gpl$';) - - # Remove user-specific configuration files from user's home - # directory before creating symbolic links from the working copy. - # Otherwise, we might end up having links inside the user's home - # directory that don't exist inside the working copy. - if [[ "$USERFILES" != '' ]];then - rm -r $USERFILES - fi - - while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do - - # Print action message. - cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line - - # Create symbolic link's parent directory if it doesn't exist. - if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then - mkdir -p $(dirname ${LINKS_SRC[$COUNT]}) - fi - - # Remove symbolic link before creating it to prevent recursive - # creation once the first symbolic link be created and it be a - # directory. - if [[ -a ${LINKS_SRC[$COUNT]} ]];then - rm ${LINKS_SRC[$COUNT]} - fi - - # Create symbolic link. - ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateLocales.sh b/Automation/centos-art.sh-prepare/prepare_updateLocales.sh deleted file mode 100755 index bb66e22..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateLocales.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# prepare_updateLocales.sh -- This function creates/updates the -# machine object (.mo) file gettext uses to output translated messages -# when centos-art.sh script is running. Certainly, what this function -# really does is a call to the locale functionality of centos-art.sh -# script to realize and update action against itself. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateLocales { - - # Realize localization tasks only when the current locale - # information is different to English language. Otherwise - # centos-art.sh would complain with an `English language cannot be - # localized to itself' message. Avoid this noise in the - # preparation stuff. - if [[ ! ${CLI_LANG_LL} =~ '^en' ]];then - cli_runFnEnvironment locale Scripts/Bash --update - fi - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updateManuals.sh b/Automation/centos-art.sh-prepare/prepare_updateManuals.sh deleted file mode 100755 index a5f5a40..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updateManuals.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# prepare_updateManuals.sh -- This option initializes documentation files -# inside the working copy. When you provide this option, the -# centos-art.sh script renders all documentation manuals from their -# related source files so you can read them nicely. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updateManuals { - - # Render key documentation manuals. - cli_runFnEnvironment render Documentation/Models/Docbook/Tcar-ug - cli_runFnEnvironment help --update --format="texinfo" tcar-fs::: - -} diff --git a/Automation/centos-art.sh-prepare/prepare_updatePackages.sh b/Automation/centos-art.sh-prepare/prepare_updatePackages.sh deleted file mode 100755 index fdf2fc0..0000000 --- a/Automation/centos-art.sh-prepare/prepare_updatePackages.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# prepare_updatePackages.sh -- This function verifies the required -# packages your workstation needs to have installed in order for -# `centos-art.sh' script to run correctly. If there is one or more -# missing packages, the `centos-art.sh' script asks you to confirm -# their installation through `sudo yum'. -# -# Copyright (C) 2009-2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_updatePackages { - - local PACKAGE='' - local PACKAGES='' - local PACKAGES_THIRDS='' - local -a PACKAGES_MISSING - local -a PACKAGES_INSTALL - local RPM='/bin/rpm' - local YUM='/usr/bin/yum' - local YUM_OPTIONS='' - - # Check execution rights of package managers. - cli_checkFiles -x $RPM - cli_checkFiles -x $YUM - - # Define required packages needed by centos-art.sh script. - PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp - coreutils texinfo texinfo-tex info tetex-latex tetex-fonts - tetex-xdvi tetex-dvips gettext texi2html gnome-doc-utils - elinks docbook-style-xsl docbook-utils docbook-dtds - docbook-style-dsssl docbook-simple docbook-utils-pdf - docbook-slides firefox sudo yum rpm ctags vim-enhanced" - - # Define packages from third party repositories (i.e., packages - # not included in CentOS [base] repository.) required by - # centos-art to work as expected. - PACKAGES_THIRDS="(inkscape|blender)" - - # Build list of installed and missing packages. - for PACKAGE in $PACKAGES;do - $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet - if [[ $? -ne 0 ]];then - PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE - else - PACKAGES_INSTALL[((++${#PACKAGES_INSTALL[*]}))]=$PACKAGE - fi - done - - # Define relation between centos-art.sh options and yum options. - [[ $FLAG_ANSWER == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -y" - [[ $FLAG_QUIET == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -q" - - # Use `sudo yum' to install missing packages in your workstation. - if [[ ${#PACKAGES_MISSING[*]} -gt 0 ]];then - sudo ${YUM} ${YUM_OPTIONS} install ${PACKAGES_MISSING[*]} - fi - - # Use `sudo yum' to update installed packages in your workstation. - if [[ ${#PACKAGES_INSTALL[*]} -gt 0 ]];then - sudo ${YUM} ${YUM_OPTIONS} update ${PACKAGES_INSTALL[*]} - fi - -}