diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare.sh index 6feffa9..0618ea1 100755 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare.sh +++ b/Scripts/Bash/Cli/Functions/Prepare/prepare.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# prepare.sh -- This function verifies your workstation for using -# centos-art.sh script. +# prepare.sh -- This function prepares your workstation for using the +# centos-art command-line. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -26,7 +26,46 @@ function prepare { - # Define command-line interface. + # Define packages flag. The package flag (--packages) controls + # whether package verification is performed or not. By default no + # package verification is done. + local FLAG_PACKAGES='false' + + # Define links flag. The link flag (--links) controls whether + # links verifications are performed or not. By default no link + # verification is done. + local FLAG_LINKS='false' + + # Define environment flag. The environment flag (--environment) + # controles whether verification of environment variables are + # performed or not. By default no verification of environment + # variables is done. + local FLAG_ENVIRONMENT='false' + + # Interpret arguments and options passed through command-line. prepare_getArguments + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Define action name. It does matter what option be passed to + # centos-art, there are many different actions to perform based on + # the option passed (e.g., `--packages', `--links', + # `--environment', etc.). In that sake, we defined action name + # inside prepare_getArguments, at the moment of interpreting + # options. + + # Define action value. There is no action value in this function, + # but action name values only. There is no need for non-option + # arguments here since we are doing fixed verifications only in + # predifined paths. + + # Verify flags and execute actions accordingly. Start with + # packages, links and then environment. + prepare_doPackages + prepare_doLinks + prepare_doEnvironment + } diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkCheck.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkCheck.sh deleted file mode 100755 index 7c63273..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkCheck.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# prepare_doLinkCheck.sh -- This function receives a list of required -# symbolic links and verifies them. This function enforces relation -# between link names and their targets (previously defined in -# prepare_doLinks.sh function). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doLinkCheck { - - local -a LINKS_TARGET - local LINKS_COUNT=0 - - until [[ $LINKS_COUNT -eq ${#LINKS[*]} ]];do - - if [[ -h ${LINKS[$LINKS_COUNT]} ]]; then - - # At this point the required link does exist but we don't - # know if its target is the one it should be. Get target - # from required link in order to check it later. - LINKS_TARGET[$LINKS_COUNT]=$(stat --format='%N' ${LINKS[$LINKS_COUNT]} \ - | tr '`' ' ' | tr "'" ' ' | tr -s ' ' | cut -d' ' -f4) - - # Check required target from required link in order to - # know if it is indeed the one it should be. Otherwise add - # required link to list of missing links. - if [[ ${LINKS_TARGET[$LINKS_COUNT]} != ${TARGETS[$LINKS_COUNT]} ]] ;then - LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} - LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" - fi - - else - - # At this point the required link doesn't exist at all. - # Add required link to list of missing links. - LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} - LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" - - fi - - # Increase link counter. - LINKS_COUNT=$(($LINKS_COUNT + 1)) - - done - - # Stript out leading spaces from missing links ids. - LINKS_MISSING_ID=$(echo $LINKS_MISSING_ID | sed 's!^ +!!') - - # If there is no missing link, end script execution with a - # descriptive output. - if [[ ${#LINKS_MISSING[*]} -eq 0 ]];then - cli_printMessage "`gettext "The required links are already installed."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkInstall.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkInstall.sh deleted file mode 100755 index 4d24934..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkInstall.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# prepare_doLinkInstall.sh -- This function receives a list of missing -# links and installs them using `ln'. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doLinkInstall { - - local ID=0 - local LINKS_PARENT='' - local WARNING='' - - for ID in $LINKS_MISSING_ID;do - - # Verify parent directory of missing link names that have a - # file as target. If the parent directory doesn't exist, - # create it first before creating links inside it. Because - # links are not created yet, we use their related targets as - # reference to determine what type of link we are creating. - if [[ -f ${TARGETS[$ID]} ]];then - LINKS_PARENT=$(dirname "${LINKS[$ID]}") - cli_checkFiles $LINKS_PARENT 'd' - fi - - # Verify missing link that already exists as regular file. If - # a regular file exists with the same name of a required link, - # warn the user about it and continue with the next file in - # the list of missing links that need to be installed. - if [[ -f ${LINKS[$ID]} ]];then - WARNING=" (`gettext "Already exists as regular file."`)" - cli_printMessage "${LINKS[$ID]}${WARNING}" 'AsResponseLine' - continue - fi - - # Create symbolic link. - ln -s ${TARGETS[$ID]} ${LINKS[$ID]} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkReport.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkReport.sh deleted file mode 100755 index ffdc7c4..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinkReport.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# prepare_doLinkReport.sh -- This function outputs information about -# missing links that need to be installed and a confirmation question -# for users to accept the installation action. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doLinkReport { - - local LINK='' - local LINKS_MISSING_MAX=0 - - # Define max number of missing links. - LINKS_MISSING_MAX=${#LINKS_MISSING[*]} - - # Output list header. - cli_printMessage "`ngettext "The following link will be installed" \ - "The following links will be installed" "$LINKS_MISSING_MAX"`:" - - # Output list body. - for LINK in ${LINKS_MISSING[@]};do - cli_printMessage "${LINK}" 'AsResponseLine' - done - - # Request confirmation for further link installation. - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh index 5c09c67..5b52382 100755 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh +++ b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh @@ -1,10 +1,8 @@ #!/bin/bash # -# prepare_doLinks.sh -- This function verifies required links your -# workstation needs in order to run the centos-art command correctly. -# If any required link is missing, the `centos-art.sh' script asks you -# to confirm their installation. When installing links, the -# `centos-art.sh' script uses the `ln' command to achieve the task. +# prepare_doLinks.sh -- This function verifies the required symbolic +# links your workstation needs to have installed in order for +# centos-art command to run correctly. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -29,30 +27,118 @@ function prepare_doLinks { - local -a LINKS - local -a TARGETS - local -a LINKS_MISSING + # Verify `--links' option. + if [[ $FLAG_LINKS == 'false' ]];then + return + fi + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + local -a LINKS_SRC + local -a LINKS_SRC_MISSING + local -a LINKS_DST + local -a LINKS_DST_UNKNOWN + local ID='' + local COUNT=0 + local WARNING='' local LINKS_MISSING_ID='' - # Define link names. - LINKS[0]=${HOME}/bin/centos-art - LINKS[1]=${HOME}/.fonts/denmark.ttf - LINKS[2]=${HOME}/.inkscape/palettes/CentOS.gpl - LINKS[3]=${HOME}/.$(rpm -q gimp | cut -d. -f-2)/palettes/CentOS.gpl - LINKS[4]=${HOME}/artwork/branches/Scripts - - # Define link targets. Use array index as reference to know - # relation between link names and targets. Be sure both link names - # and link targets use the same array index value. - TARGETS[0]=${CLI_BASEDIR}/init.sh - TARGETS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf/denmark.ttf - TARGETS[2]=$(cli_getRepoTLDir)/Identity/Colors/CentOS.gpl - TARGETS[3]=${TARGETS[2]} - TARGETS[4]=$(cli_getRepoTLDir)/Scripts/ - - prepare_doLinkCheck - prepare_doLinkReport - prepare_doLinkInstall + # Define link sources. + LINKS_SRC[0]=${HOME}/bin/$CLI_PROGRAM + LINKS_SRC[1]=${HOME}/.fonts/denmark.ttf + LINKS_SRC[2]=${HOME}/.inkscape/palettes/CentOS.gpl + LINKS_SRC[3]=${HOME}/.$(rpm -q gimp | cut -d. -f-2)/palettes/CentOS.gpl + + # Define link targets. + LINKS_DST[0]=${CLI_BASEDIR}/init.sh + LINKS_DST[1]=${HOME}/artwork/trunk/Identity/Fonts/denmark.ttf + LINKS_DST[2]=${HOME}/artwork/trunk/Identity/Colors/CentOS.gpl + LINKS_DST[3]=${LINKS_DST[2]} + + # Print action message. + cli_printMessage "`gettext "Symbolic links"`" 'AsCheckingLine' + + # Define which links are missing from the list of source links. + until [[ $COUNT -eq ${#LINKS_SRC[*]} ]];do + + if [[ -h ${LINKS_SRC[$COUNT]} ]]; then + + # At this point the required link does exist but we don't + # know if its target is the one it should be. Get target + # from required link in order to check it later. + LINKS_DST_UNKNOWN[$COUNT]=$(stat --format='%N' ${LINKS_SRC[$COUNT]} \ + | tr '`' ' ' | tr "'" ' ' | tr -s ' ' | cut -d' ' -f4) + + # Check required target from required link in order to + # know if it is indeed the one it should be. Otherwise add + # required link to list of missing links. + if [[ ${LINKS_DST_UNKNOWN[$COUNT]} != ${LINKS_DST[$COUNT]} ]] ;then + LINKS_MISSING_ID="$COUNT $LINKS_MISSING_ID" + fi + + else + + # Add required link to list of missing links. At this + # point the required link doesn't exist at all. + LINKS_MISSING_ID="$COUNT $LINKS_MISSING_ID" + + fi + + # Increase link counter. + COUNT=$(($COUNT + 1)) + + done + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Is there any link missing? + if [[ $LINKS_MISSING_ID == '' ]];then + cli_printMessage "`gettext "The required links has been already created."`" + return + fi + + # Sort the list of missing links identifications. + LINKS_MISSING_ID=$(echo $LINKS_MISSING_ID | tr ' ' "\n" | sort ) + + # Define number of missing links. This is required for gettext to + # set the plural form of messages. + LINKS_MISSING_ID_COUNT=$(echo $LINKS_MISSING_ID | wc -l) + + # At this point there is one or more missing links that need to be + # created in the workstation. Report this issue and specify which + # these links are. + cli_printMessage "`ngettext "The following link needs to be created" \ + "The following links need to be created" \ + "$LINKS_MISSING_ID_COUNT"`:" + + # Build report of missing packages and remark those comming from + # third party repository. + for ID in $LINKS_MISSING_ID;do + # Consider missing link that already exists as regular file. If + # a regular file exists with the same name of a required link, + # warn the user about it and continue with the next file in + # the list of missing links that need to be created. + if [[ -f ${LINKS_SRC[$ID]} ]];then + WARNING=" (`gettext "Caution! It already exists as regular file."`)" + fi + cli_printMessage "${LINKS_SRC[$ID]}${WARNING}" 'AsResponseLine' + done + + # Print confirmation request. + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + + # Create symbolic links using their identifications. + for ID in $LINKS_MISSING_ID;do + + # Print action message. + cli_printMessage "${LINKS_SRC[$ID]}" 'AsCreatingLine' + + # Create the symbolic link. + ln ${LINKS_DST[$ID]} ${LINKS_SRC[$ID]} --force --symbolic + + done # At this point all required links must be installed. To confirm # required links installation let's verify them once more. diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageCheck.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageCheck.sh deleted file mode 100755 index ed9204c..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageCheck.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# -# prepare_doPackageCheck.sh -- This function receives a list of -# packages and verifies if they are currently installed in your -# system. Third party package verification is also done here. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doPackageCheck { - - local PACKAGE='' - - # Check package manager command existance. - cli_checkFiles '/bin/rpm' 'x' - - for PACKAGE in $PACKAGES;do - - # Query your system's RPM database. - rpm -q --queryformat "%{NAME}\n" $PACKAGE --quiet - - # Define missing packages. - if [[ $? -ne 0 ]];then - PACKAGES_MISSING[$PACKAGES_COUNT]=$PACKAGE - fi - - # Increase package counter. - PACKAGES_COUNT=$(($PACKAGES_COUNT + 1)) - - done - - # In there is no missing package, end script execution with a - # descriptive output. - if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then - cli_printMessage "`gettext "The required packages are already installed."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageInstall.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageInstall.sh deleted file mode 100755 index da3e422..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageInstall.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# prepare_doPackageInstall.sh -- This function receives a list of -# missing packages and installs them using sudo yum. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doPackageInstall { - - # Verify `yum' command existence. - cli_checkFiles '/usr/bin/yum' 'x' - - # Use sudo to install packages in your system through yum. - sudo yum install ${PACKAGES_MISSING[*]} - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageReport.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageReport.sh deleted file mode 100755 index 05e0a48..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackageReport.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# prepare_doPackageReport.sh -- This function receives one list of -# missing packages and another list of packages from third party -# repository that were marked as missing packages. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doPackageReport { - - local PACKAGE='' - local WARNING='' - - cli_printMessage "`ngettext "The following package needs to be installed" \ - "The following packages need to be installed" \ - "$PACKAGES_COUNT"`:" - - for PACKAGE in ${PACKAGES_MISSING[@]};do - - # Is this package from third party? - if [[ $PACKAGE =~ $PACKAGES_THIRD_FLAG_FILTER ]];then - WARNING=" (`gettext "requires third party repository!"`)" - fi - - cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' - - done - - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh index 99343e0..e504453 100644 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh +++ b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh @@ -1,11 +1,10 @@ #!/bin/bash # -# prepare_doPackages.sh -- This function verifies required packages -# your workstation needs in order to run the centos-art command -# correctly. If there are missing packages, the `centos-art.sh' script -# asks you to confirm their installation. When installing packages, -# the `centos-art.sh' script uses the yum application in order to -# achieve the task. +# prepare_doPackages.sh -- This function verifies the required +# packages your workstation needs to have installed in order for +# centos-art command to run correctly. If there is one or more missing +# packages, the `centos-art.sh' script asks you to confirm their +# installation through yum. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -30,30 +29,88 @@ function prepare_doPackages { + # Verify `--packages' option. + if [[ $FLAG_PACKAGES == 'false' ]];then + return + fi + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + local PACKAGE='' + local WARNING='' local PACKAGES='' - local PACKAGES_THIRD_FLAG_FILTER='' + local PACKAGES_THIRDS='' local -a PACKAGES_MISSING - local PACKAGES_COUNT=0 + local RPM='/bin/rpm' + local YUM='/usr/bin/yum' + + # Check execution rights of package managers. + cli_checkFiles $RPM 'x' + cli_checkFiles $YUM 'x' # Define required packages needed by centos-art.sh script. - PACKAGES="bash inkscape ImageMagick netpbm netpbm-progs - syslinux gimp coreutils texinfo info tetex-latex tetex-fonts - tetex-doc tetex-xdvi tetex-dvips gettext texi2html" + PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp + coreutils texinfo 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" + + # 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)" + + # Print action message. + cli_printMessage "`gettext "RPM packages"`" 'AsCheckingLine' + + # Build list of missing packages. + for PACKAGE in $PACKAGES;do + $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet + if [[ $? -ne 0 ]];then + PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE + fi + done + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + # Is there any package missing? + if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then + cli_printMessage "`gettext "The required packages has been already installed."`" + return + fi + + # At this point there is one or more missing packages that need to + # be installed in the workstation. Report this issue and specify + # which these packages are. + cli_printMessage "`ngettext "The following package needs to be installed" \ + "The following packages need to be installed" \ + "${#PACKAGES_MISSING[*]}"`:" + + # Build report of missing packages and remark those comming from + # third party repository. + for PACKAGE in ${PACKAGES_MISSING[@]};do + if [[ $PACKAGE =~ $PACKAGES_THIRDS ]];then + WARNING=" (`gettext "requires third party repository!"`)" + fi + cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' + done - # Define, from required packages, packages being from third - # parties (i.e., packages not included in CentOS [base] - # repository.). - PACKAGES_THIRD_FLAG_FILTER="(inkscape|blender)" + # Print confirmation request. + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - prepare_doPackageCheck - prepare_doPackageReport - prepare_doPackageInstall + # Use sudo to install the missing packages in your system through + # yum. + sudo ${YUM} install ${PACKAGES_MISSING[*]} # At this point we need to recheck installed packages in order to # be sure the user decided not to continue when there are still # missing packages to be install. For example this may happen - # when we try to install third party packages and there is no - # third party repository availabe to get those packages from. + # when we try to install third party packages but there is no + # third party repository configured in the workstation for yum to + # retrive those packages from. prepare_doPackages } diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh index 183e1d6..a94be13 100755 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh +++ b/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh @@ -1,7 +1,7 @@ #!/bin/bash # # prepare_getArguments.sh -- This function interpretes arguments passed -# to `verify' functionality and calls actions accordingly. +# to `prepare' functionality and calls actions accordingly. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -44,18 +44,18 @@ function prepare_getArguments { case "$1" in --packages ) - ACTIONNAM="${FUNCNAM}_doPackages" - break + FLAG_PACKAGES="true" + shift 1 ;; --links ) - ACTIONNAM="${FUNCNAM}_doLinks" - break + FLAG_LINKS="true" + shift 1 ;; --environment ) - ACTIONNAM="${FUNCNAM}_doEnvironment" - break + FLAG_ENVIRONMENT="true" + shift 1 ;; * ) @@ -63,12 +63,4 @@ function prepare_getArguments { esac done - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - } diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToCli.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToCli.sh deleted file mode 100755 index ce621a8..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToCli.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# prepare_pathToCli.sh -- This function -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_pathToCli { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define directories required by the centos-art.sh script command - # line interface. - REPODIRS[0]=/home/centos - REPODIRS[1]=/home/centos/bin - REPODIRS[2]=${CLI_BASEDIR} - - # Define files required by the centos-art.sh script command line - # interface. - REPOFILES[0]=${REPODIRS[2]}/init.sh - - # Define symbolic links required by the centos-art.sh script - # command line interface. - REPOLINKS[0]=${REPODIRS[1]}/centos-art - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToFonts.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToFonts.sh deleted file mode 100644 index d973c18..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToFonts.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# prepare_pathToFonts.sh -- This function checks user's fonts -# directory. In order for some artworks to be rendered correctly, -# denmark font needs to be available. By default, denmark font doesn't -# come with CentOS distribution so create a symbolic link (from the -# one we have inside repository) to make it available if it isn't yet. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_pathToFonts { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define font related directories. - REPODIRS[0]=${HOME}/.fonts - REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf - - # Define font related files. - REPOFILES[0]=${REPODIRS[1]}/denmark.ttf - - # Define font related symbolic links. - REPOLINKS[0]=${REPODIRS[0]}/denmark.ttf - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToInkscape.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToInkscape.sh deleted file mode 100755 index 0986b6d..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_pathToInkscape.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# prepare_pathToInkscape.sh -- This function prepares user's -# ~/.inkscape configurations directory to use CentOS defaults (e.g., -# palettes, patterns, etc). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_pathToInkscape { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define directories required by the centos-art.sh script command - # line interface. - REPODIRS[0]=${HOME}/.inkscape/palettes - REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Colors - - # Define files required by the centos-art.sh script command line - # interface. - REPOFILES[0]=${REPODIRS[1]}/CentOS.gpl - - # Define symbolic links required by the centos-art.sh script - # command line interface. - REPOLINKS[0]=${REPODIRS[0]}/CentOS.gpl - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -}