Posts Tagged ‘rpm’

Yum Revisited (Part 2)

September 20th, 2009 No comments

YUM - Yellowdog Updater Modified Here is the second article dedicated to the “yum” command. We will demonstrate some useful option of the command and how-to recover in some problematic situation. Keeping your system up to date is important, knowing how to do it and how to correct some issue related to rpm are also important. So let’s see if everyone can find something new about the “yum” command and see if we can apply it in our daily system admin job. You can also consult the “yum” website or the “yum” wiki to obtain more information. As always, I will try to make this article as useful as it can be, so we  can all come back to it and use it as a reference to the “yum” command.

Checking if update are available

Let’s say you want to be advise when new update are available and want to be emailed with the list of packages included in the update.  When we run the “yum” command with the “check-update” parameter, it actually go and check if any update are available at the repository you have defined in your “/etc/yum.repos.d” directory. If any update are available, they will be listed and the program exit code returned will be 100. If no update are available then the exit code will be 0.

# yum check-update ; echo $?
Loaded plugins: changelog, fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base:
* updates:
* addons:
* extras:
cman.i386                                2.0.98-1.el5_3.7       updates
ksh.i386                                 20080202-2.el5_3.1     updates
openais.i386                             0.80.3-22.el5_3.9      updates
rgmanager.i386                           2.0.46-1.el5.centos.4  updates
tzdata.noarch                            2009k-1.el5            updates

We can easily make a little script that we can put in our system crontab file, that will check if any update are available. If there are any, then a list of the updated package will be send to you by email

/usr/bin/yum check-update > /tmp/cu$$ 2>&1
if [ $RET -eq 100 ]; then
   cat /tmp/cu$$ | mail -s "System Update Available"
rm /tmp/cu$$ > /dev/null 2>&1

Read more…

Categories: Admin

Yum Revisited (Part 1)

September 4th, 2009 3 comments

YumThis is a first of a series of two articles dedicated to the “yum” program. In this first article, we will mainly look at the configuration files. In the next article, we will look at some advance usage, that will help us in administrating our servers.  As always, will build our article, in a way that we can come back to it and use it as a reference if we need some information about “yum”. We will concentrate on the command line version of “yum”, but I would like mention that there is a graphical version called “yumex” that I would recommend. It is not the fastest one, but it is simple to use and it work.  Visit the  “yumex” home page, you can aloso download the RedHat/Centos 5 rpm from here.

Main configuration file (/etc/yum.conf)

We can say that “yum” configuration break in two parts, the main configuration file yum.conf  located in the /etc directory and the /etc/yum.repos.d directory that contains separated files for each repository that “yum” can connect to, for updating/installing our system. Below is a modified version of the yum.conf file that include comment for every option line, so we could use it as a reference. I think all options, along  with the comments included are self explanatory .

# The Main section must exist for yum to do anything

# Directory where packages are downloaded

# 0=Remove packages & headers after they are install/update
# 1=Keep downloaded packages after update

# Debug Level. Valid numbers are 0-10, default is 2

# Where yum log file is located

# Distribution Package Name (Fedora=fedora-release, RedHat/Centos=redhat-release)

# 1=Complaint when package aleady install is installed, 0=not tolerant
# For example, if you request to install foo, bar and baz and baz is installed;
# yum won't error out complaining that baz is already installedt

# 1=Only update the architectures of packages that is installed, 0=Override Check

# Let yum determine if package is obsolete during update (1=Activate 0=Deactivate)

# Confirms that all packages are cryptographically verified

# 1=Enabling yum plugins, 0=Disable yum plugins
# Once plugins are enabled in yum.conf, you may install yum plugins and use them.

# Determine when repositories metedata expire after it is received.
# Note: yum-RHN-plugin doesn't honor this.

# Some package (like kernel) can only be install and not updated
# So here we would keep 5 versions of the kernel.
# When the sixth one is installed, the oldest one will get deleted.
installonly_limit = 5

# List of packages to exclude from updates or installs.
# Uncomment below if you want to autoupdate also the kernel rpms
# Reboot is necessary to use the new kernel, once installed.
# exclude=kernel*

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

Read more…

Categories: Admin

What script is run when a package is install ?

Today, we will look at what script is run when you install a rpm. In our example we will look at the script that is run when we perform a kernel installation.  First, let’s look what kernel version is installed on our system, with the this command :

# rpm -qa | grep -i kernel

Let’s view the script that is run when the kernel 2.6.18-128.1.6 is install ;

# rpm -q --scripts kernel-2.6.18-128.1.6.el5
postinstall scriptlet (using /bin/sh):
if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ]; then
   if [ -f /etc/sysconfig/kernel ]; then
      /bin/sed -i -e 's/^DEFAULTKERNEL=kernel-smp$/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel || exit $?
/sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install 2.6.18-128.1.6.el5 || exit $?
if [ -x /sbin/weak-modules ]
   /sbin/weak-modules --add-kernel 2.6.18-128.1.6.el5 || exit $?
preuninstall scriptlet (using /bin/sh):
/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove 2.6.18-128.1.6.el5 || exit $?
if [ -x /sbin/weak-modules ]
   /sbin/weak-modules --remove-kernel 2.6.18-128.1.6.el5 || exit $?
Categories: Admin