– General Linux 2 –

Use Red Hat Package Management [5]

(Linux Professional Institute Certification)

a

   .~.      by: Andrew Eager
   /V\
  // \\         geoffrey robertson
  @._.@         geoffrey@zip.com.au
$Id: gl1.102.6.slides.tex,v 1.4 2003/05/30 05:09:04 waratah Exp $

aCopyright \begin{matrix}c \\ ◯ \end{matrix} 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies 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.

List of Slides

2

(2.2) 102 Installation & Package Mgt. [24]

2.102.1 Design hard disk layout [2] 2.102.2 Install a boot manager [3] 2.102.3 Make and install programs from source [5] 2.102.4 Manage shared libraries [3] 2.102.5 Use Debian package management [5] 2.102.6 Use Red Hat Package Manager (RPM) [6]

Use Red Hat Package Management

Objective

Candidates should be able to perform package management under Linux distributions that use RPMs for package distribution. This objective includes being able to install, re-install, upgrade, and remove packages, as well as obtain status and version information on packages. This objective also includes obtaining package information such as version, status, dependencies, integrity, and signatures. Candidates should be able to determine what files a package provides, as well as find which package a specific file comes from.

Use Red Hat Package Management

Key files, terms, and utilities

/etc/rpmrc
/usr/lib/rpm/*

Use Red Hat Package Management

Resources of interest

:

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-a

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-b

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-c

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-d

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-e

RPM - RedHat Package Manager

• RPM works with RedHat, SuSE & Mandrake (among others) and can do the following:

– Build an RPM package

– Install an RPM package

– Update an already installed RPM package

– Query an RPM package

– Erase an RPM package

– Verify an RPM package.

7-f

RPM Packages

• RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from:

– Local media (hard disk, cdrom etc)

– An ftp site

– An http site

• Packages sourced from local media are specified using just their filename. For example:

– acroread-4.05-1.i686.rpm

• Packages sourced from ftp or http sites are specified using the following syntax:

– ftp://USER:PASSWORD@HOST:PORT/path/to/package.rpm

RPM Packages

• RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from:

– Local media (hard disk, cdrom etc)

– An ftp site

– An http site

• Packages sourced from local media are specified using just their filename. For example:

– acroread-4.05-1.i686.rpm

• Packages sourced from ftp or http sites are specified using the following syntax:

– ftp://USER:PASSWORD@HOST:PORT/path/to/package.rpm

8-a

RPM Packages

• RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from:

– Local media (hard disk, cdrom etc)

– An ftp site

– An http site

• Packages sourced from local media are specified using just their filename. For example:

– acroread-4.05-1.i686.rpm

• Packages sourced from ftp or http sites are specified using the following syntax:

– ftp://USER:PASSWORD@HOST:PORT/path/to/package.rpm

8-b

RPM Filenames

RPM Filenames use a standard naming scheme:

 package  -version-patch.arch.rpm

package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example:

  kernel  -2.4.9-21.i686.rpm

RPM Filenames

RPM Filenames use a standard naming scheme:

package- version  -patch.arch.rpm

package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example:

 kernel- 2.4.9 -21.i686.rpm

RPM Filenames

RPM Filenames use a standard naming scheme:

package-version- patch .arch.rpm

package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example:

 kernel-2.4.9- 21 .i686.rpm

RPM Filenames

RPM Filenames use a standard naming scheme:

package-version-patch. arch .rpm

package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example:

 kernel-2.4.9-21. i686 .rpm

RPM Operating Modes

RPM operations are split up into 4 major modes: • Querying & Verifying

• Installing, Upgrading or Removing

• Building Packages

• RPM database administration functions

RPM Operating Modes

RPM operations are split up into 4 major modes: • Querying & Verifying

• Installing, Upgrading or Removing

• Building Packages

• RPM database administration functions

13-a

RPM Operating Modes

RPM operations are split up into 4 major modes: • Querying & Verifying

• Installing, Upgrading or Removing

• Building Packages

• RPM database administration functions

13-b

RPM Operating Modes

RPM operations are split up into 4 major modes: • Querying & Verifying

• Installing, Upgrading or Removing

• Building Packages

• RPM database administration functions

13-c

RPM Operating Modes

RPM operations are split up into 4 major modes: • Querying & Verifying

• Installing, Upgrading or Removing

• Building Packages

• RPM database administration functions

13-d

Verifying package Integrity

Having downloaded an rpm from the Internet, the \underline{very first}thing you want to do is verify its integrity.

You do this with the -K or --checksig option to rpm:

# rpm -K kernel-2.4.9-31.i586.rpm
kernel-2.4.9-31.i586.rpm: md5 gpg OK

NOTE: Some packages use PGP to check integrity while others use GnuPG.

Installing, Upgrading & Removing

Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential:

• Install - Install a package. Good for Kernels

• Upgrade - Upgrade a package if it’s installed, otherwise install the package

• Freshen - Upgrade a package only if it’s already installed.

• Erase - Remove a package.

Installing, Upgrading & Removing

Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential:

• Install - Install a package. Good for Kernels

• Upgrade - Upgrade a package if it’s installed, otherwise install the package

• Freshen - Upgrade a package only if it’s already installed.

• Erase - Remove a package.

15-a

Installing, Upgrading & Removing

Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential:

• Install - Install a package. Good for Kernels

• Upgrade - Upgrade a package if it’s installed, otherwise install the package

• Freshen - Upgrade a package only if it’s already installed.

• Erase - Remove a package.

15-b

Installing, Upgrading & Removing

Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential:

• Install - Install a package. Good for Kernels

• Upgrade - Upgrade a package if it’s installed, otherwise install the package

• Freshen - Upgrade a package only if it’s already installed.

• Erase - Remove a package.

15-c

Installing, Upgrading & Removing

Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential:

• Install - Install a package. Good for Kernels

• Upgrade - Upgrade a package if it’s installed, otherwise install the package

• Freshen - Upgrade a package only if it’s already installed.

• Erase - Remove a package.

15-d

Installing, Upgrading & Removing - Options

The table below summarises the various options used for package installation, freshening and removal.

Mode Short option Long option

  Install  -i  --install
 Upgrade  -U  --upgrade
 Freshen  -F  --freshen
  Erase  -e  --erase

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-a

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-b

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-c

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-d

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-e

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-f

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-g

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-h

Using RPM on the command line

Generally you use rpm in one of the following modes:

• rpm -i [install options] package file ...
• rpm -U [install-options] package file ...
• rpm -F [install-options] package file ...
• rpm -e [erase-options] package name ...

Commonly used options are:

-v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages

17-i

Example - install option

Install kernel-2.4.18-4 without removing the existing kernel:

# rpm -q kernel
kernel-2.4.9-21
# rpm -ivh kernel-2.4.18-4*.rpm
Preparing...           #################### [100%]
   1:kernel-2.4.18-4  #################### [100%]
# rpm -q kernel
kernel-2.4.18-4
kernel-2.4.9-21
#

Example - Freshen option

Upgrade the existing kernel to kernel-2.4.18-4.

# rpm -q kernel
kernel-2.4.9-21
# rpm -Uvh kernel-2.4.18-4*.rpm
Preparing...             #################### [100%]
   1:kernel-2.4.18-4   #################### [100%]
# rpm -q kernel
kernel-2.4.18-4
#

Example - Upgrade option:

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

20-a

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

20-b

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

20-c

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

20-d

What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install:

# rpm -q gocr
package gocr is not installed
# rpm -Uvh gocr-0.3.4-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.4-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.4-1
# rpm -Uvh gocr-0.3.6-1.i386.rpm
Preparing...             ###################### [100%]
   1:gocr-0.3.6-1.rpm  ###################### [100%]
# rpm -q gocr
gocr-0.3.6-1

20-e

Example - Erase option

Remove the package gocr from the system

# rpm -q gocr
gocr-0.3.6-1
# rpm -e gocr
# rpm -q gocr
#

Querying Packages

RPM can be used to query a package (either installed or not).

rpm -q|--query [select-options] [query-options]

Select options : Choose what it is you want to query -a Query all installed packages. -f Query package owning FILE. -p Query an (uninstalled) package file

Query options : Choose what it is you want to see from the query: -i Show all information about the package -l Show what files are contained in the package -R List packages on which this package depends

Querying Packages

RPM can be used to query a package (either installed or not).

rpm -q|--query [select-options] [query-options]

Select options : Choose what it is you want to query -a Query all installed packages. -f Query package owning FILE. -p Query an (uninstalled) package file

Query options : Choose what it is you want to see from the query: -i Show all information about the package -l Show what files are contained in the package -R List packages on which this package depends

22-a

Querying Packages

RPM can be used to query a package (either installed or not).

rpm -q|--query [select-options] [query-options]

Select options : Choose what it is you want to query -a Query all installed packages. -f Query package owning FILE. -p Query an (uninstalled) package file

Query options : Choose what it is you want to see from the query: -i Show all information about the package -l Show what files are contained in the package -R List packages on which this package depends

22-b

Query - Example

Give a list of all packages with kern in their name:

$  rpm -qa | grep kern ↩
kernelcfg-0.5-5
glibc-kernheaders-2.4-7.14
kernel-2.4.9-21
kernel-source-2.4.18-4

Query - Example

Show a list of all files in kernel-2.4.9-21

$ rpm -ql kernel-2.4.9-21 ↩
/boot/System.map-2.4.9-21
/boot/module-info-2.4.9-21
/boot/vmlinuz-2.4.9-21
....

Query - Example

Show package which owns /bin/ls:

$ rpm -qf /bin/ls ↩
$ fileutils-4.1-10 ↩

Show complete information about the fileutils package:

$ rpm -qi fileutils ↩
Name         : fileutils                       Relocations: (not relocateable)
Version      : 4.1                                   Vendor: Red Hat, Inc.
Release      : 10                                Build Date: Mon 25 Mar 2002 12:23:22 PM EST
Install date: Fri 24 May 2002 02:18:08 PM EST       Build Host: daffy.perf.redhat.com
Group        : Applications/File               Source RPM: fileutils-4.1-10.src.rpm
Size         : 1679468                              License: GPL
Packager     : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary      : The GNU versions of common file management utilities.
Description :
The fileutils package includes a number of GNU versions of common and
popular file management utilities. Fileutils includes the following
tools: chgrp (changes a file's group ownership), chown (changes a
file's ownership), chmod (changes a file's permissions), cp (copies
files), dd (copies and converts files), df (shows a filesystem's disk
usage), dir (gives a brief directory listing), dircolors (the setup
program for the color version of the ls command), du (shows disk
usage), install (copies files and sets permissions), ln (creates file
links), ls (lists directory contents), mkdir (creates directories),
mkfifo (creates FIFOs or named pipes), mknod (creates special files),
mv (renames files), rm (removes/deletes files), rmdir (removes empty

Verifying package files

This option to rpm is used to verify the \underline{files installed}on the system with those from the rpm package file. This is not to be confused with the integrity of the package file. The following table lists the characteristics verified:

5 - The MD5 checksum S - The file size L - Symbolic link T - Modification time D - Device major & minor number U - User owner G - Group owner M - Permission and/or file type

Example - Verify package

Verify the setup package against the originally installed version.

$ rpm -V setup ↩
S.5....T c /etc/bashrc
S.5....T c /etc/csh.cshrc
S.5....T c /etc/csh.login
S.5....T c /etc/host.conf
S.5....T c /etc/printcap
S.5....T c /etc/profile
..?..... c /etc/securetty
.M...... c /etc/shadow

The End

29