Blame Scripts/Functions/Prepare/prepare_updatePackages.sh

4c79b5
#!/bin/bash
4c79b5
#
8cbdc0
# prepare_updatePackages.sh -- This function verifies the required
8e457b
# packages your workstation needs to have installed in order for
500ea2
# `centos-art.sh' script to run correctly. If there is one or more
500ea2
# missing packages, the `centos-art.sh' script asks you to confirm
500ea2
# their installation through `sudo yum'.
4c79b5
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
4c79b5
# ----------------------------------------------------------------------
3b853a
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
8cbdc0
function prepare_updatePackages {
4c79b5
8e457b
    local PACKAGE=''
4c79b5
    local PACKAGES=''
8e457b
    local PACKAGES_THIRDS=''
8d73a3
    local -a PACKAGES_MISSING
a03fb8
    local -a PACKAGES_INSTALL
8e457b
    local RPM='/bin/rpm'
8e457b
    local YUM='/usr/bin/yum'
297437
    local YUM_OPTIONS=''
8e457b
8e457b
    # Check execution rights of package managers.
e90089
    cli_checkFiles $RPM --execution
e90089
    cli_checkFiles $YUM --execution
4c79b5
4c79b5
    # Define required packages needed by centos-art.sh script.
8e457b
    PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp
8e457b
        coreutils texinfo info tetex-latex tetex-fonts tetex-xdvi
8e457b
        tetex-dvips gettext texi2html gnome-doc-utils elinks
8e457b
        docbook-style-xsl docbook-utils docbook-dtds
8e457b
        docbook-style-dsssl docbook-simple docbook-utils-pdf
42dcbf
        docbook-slides firefox sudo yum rpm ctags"
8e457b
8e457b
    # Define packages from third party repositories (i.e., packages
8e457b
    # not included in CentOS [base] repository.) required by
8e457b
    # centos-art to work as expected.
8e457b
    PACKAGES_THIRDS="(inkscape|blender)"
8e457b
a03fb8
    # Build list of installed and missing packages.
8e457b
    for PACKAGE in $PACKAGES;do
8e457b
        $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet
8e457b
        if [[ $? -ne 0 ]];then
8e457b
            PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE
a03fb8
        else
a03fb8
            PACKAGES_INSTALL[((++${#PACKAGES_INSTALL[*]}))]=$PACKAGE
8e457b
        fi
8e457b
    done
8e457b
297437
    # Define relation between centos-art.sh options and yum options.
297437
    [[ $FLAG_ANSWER == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -y"
297437
    [[ $FLAG_QUIET  == 'true' ]] && YUM_OPTIONS="${YUM_OPTIONS} -q"
297437
a03fb8
    # Use `sudo yum' to install missing packages in your workstation.
a03fb8
    if [[ ${#PACKAGES_MISSING[*]} -gt 0 ]];then
297437
        sudo ${YUM} ${YUM_OPTIONS} install ${PACKAGES_MISSING[*]}
a03fb8
    fi
a03fb8
        
a03fb8
    # Use `sudo yum' to update installed packages in your workstation.
a03fb8
    if [[ ${#PACKAGES_INSTALL[*]} -gt 0 ]];then
297437
        sudo ${YUM} ${YUM_OPTIONS} update ${PACKAGES_INSTALL[*]}
8e457b
    fi
297437
    
4c79b5
}