diff --git a/Scripts/Bash/Functions/Verify/verify.sh b/Scripts/Bash/Functions/Verify/verify.sh index 7efee0e..4c2cd35 100755 --- a/Scripts/Bash/Functions/Verify/verify.sh +++ b/Scripts/Bash/Functions/Verify/verify.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# prepare.sh -- This function prepares your workstation for using +# verify.sh -- This function verifies your workstation for using # centos-art.sh script. # # Copyright (C) 2009-2010 Alain Reguera Delgado @@ -26,9 +26,9 @@ function verify { - # Define prepare variables. + # Define global varibales. - # Define prepare actions. + # Define command-line interface. verify_getActions } diff --git a/Scripts/Bash/Functions/Verify/verify_doPackageCheck.sh b/Scripts/Bash/Functions/Verify/verify_doPackageCheck.sh new file mode 100755 index 0000000..efabbb0 --- /dev/null +++ b/Scripts/Bash/Functions/Verify/verify_doPackageCheck.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# verify_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-2010 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 verify_doPackageCheck { + + local PACKAGE='' + + # Check package manager command existance. + cli_checkFiles '/bin/rpm' 'f' '' '--quiet' + if [[ $? -ne 0 ]];then + cli_printMessage "`gettext "The RPM package manager is not installed."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + 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 "There are not missing packages."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Functions/Verify/verify_doPackageInstall.sh b/Scripts/Bash/Functions/Verify/verify_doPackageInstall.sh new file mode 100755 index 0000000..2bd7339 --- /dev/null +++ b/Scripts/Bash/Functions/Verify/verify_doPackageInstall.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# verify_doPackages.sh -- This function receives a list of missing +# list of packages to install and achieve the package installation +# using `yum' command. +# +# Copyright (C) 2009-2010 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 verify_doPackageInstall { + + # Verify `yum' command existence. + cli_checkFiles '/usr/bin/yum' 'f' '' '--quiet' + if [[ $? -ne 0 ]];then + cli_printMessage "`gettext "The yum package manager is not installed."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Use sudo to install packages in your system through yum. + sudo yum install ${PACKAGES_MISSING[*]} + +} diff --git a/Scripts/Bash/Functions/Verify/verify_doPackageReport.sh b/Scripts/Bash/Functions/Verify/verify_doPackageReport.sh new file mode 100755 index 0000000..a6b15b0 --- /dev/null +++ b/Scripts/Bash/Functions/Verify/verify_doPackageReport.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# verify_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-2010 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 verify_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_REGEX ]];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/Functions/Verify/verify_doPackages.sh b/Scripts/Bash/Functions/Verify/verify_doPackages.sh index 322d940..2aa2f26 100644 --- a/Scripts/Bash/Functions/Verify/verify_doPackages.sh +++ b/Scripts/Bash/Functions/Verify/verify_doPackages.sh @@ -32,14 +32,13 @@ function verify_doPackages { local PACKAGES='' local PACKAGES_THIRD_REGEX='' - local PACKAGES_MISSING='' - local PACKAGES_THIRD='' - local COUNT=0 + local -a PACKAGES_MISSING + local PACKAGES_COUNT=0 # 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 a b c gettext texi2html" + tetex-doc tetex-xdvi tetex-dvips gettext texi2html" # Define, from required packages, packages being from third # parties (i.e., packages not included in CentOS [base] @@ -48,6 +47,13 @@ function verify_doPackages { verify_doPackageCheck verify_doPackageReport - # --- verify_doPackageInstall + verify_doPackageInstall + + # 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. + verify_doPackages } diff --git a/Scripts/Bash/Functions/Verify/verify_getActions.sh b/Scripts/Bash/Functions/Verify/verify_getActions.sh index 7170d98..41a87cc 100755 --- a/Scripts/Bash/Functions/Verify/verify_getActions.sh +++ b/Scripts/Bash/Functions/Verify/verify_getActions.sh @@ -28,21 +28,23 @@ function verify_getActions { case $OPTIONNAM in --packages ) - verify_requiredPackages + verify_doPackages ;; - --paths ) + --links ) verify_pathToCli verify_pathToFonts verify_pathToInkscape ;; + --environment ) + ;; + * ) cli_printMessage "`gettext "The option provided is not valid."`" + cli_printMessage "$(caller)" "AsToKnowMoreLine" esac - cli_printMessage "$(caller)" "AsToKnowMoreLine" - }