LPI Linux Certification/Using Red Hat Package Management
From Wikibooks, the open-content textbooks collection
Red Hat Package Manager is a powerful package manager, which can be used to build, install, query, verify, update, and erase individual software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.
Contents |
[edit] Detailed Objective
Weight: 8
Description:
Candidates should be able to perform package management using RPM based tools.
- Key knowledge area(s):
- Install, re-install, upgrade and remove RPM packages.
- Obtain information on RPM packages such as version, status, dependencies, integrity and signatures.
- Determine what files a package provides, as well as find which package a specific file comes from.
- The following is a partial list of the used files, terms and utilities:
- /etc/rpmrc
- /usr/lib/rpm/*
- rpm
- grep
[edit] Red Hat Package Manager
Some Linux distribution uses rpm the “Red Hat Package Manager” for all its distribution software. RPM maintains a detailed database of all software installed in the system.
To install a RPM package, do:
rpm -i [package].rpm
The package will be installed only if the dependency are met and there is no conflict with another package. To upgrade a package, do:
rpm -U [package].rpm
The files of the old package version will be removed and replaced by the new files. To remove a RPM package, do:
rpm -e [package]
The package will be removed only if there are unresolved dependencies.
[edit] RPM Queries
With the -q option you can query the RPM database.
rpm -q -i apache
The -i is to get package information.\
There are several switches that you can use:
- -l: To get a file list of a package.
$ rpm -q -l pciutils /sbin/lspci /sbin/setpci /usr/share/doc/package/pciutils ... /usr/share/pci.ids
- -f file: Query which package a file belongs to.
$ rpm -q -f /sbin/lspci pciutils-2.1.9-58
- -s: File list with status information.
- -d: list only documentation files.
- -a: List all the installed packages.
[edit] RPM Commands
To get general information on a package or program, use rpmlocate.
rpmlocate ipcs -q -i apache
Searching for ipcs in rpm db:
util-linux-2.11n-75: /usr/bin/ipcs /usr/share/man/man8/ipcs.8.gz
To list all the installed packages, use rpmqpack.
rpmqpack
[edit] Source Installation
The RPM source files have generally the format package.src.rpm and can be installed the same way as binaries. The directories where they will be installed from /usr/src/packages are:
- SOURCES: For the original sources.
- SPECS: For the .spec file that controls the build process.
- BUILD: All the sources are built in this directory.
- RPMS: Where the complete binary packages are stored.
- SRPMS: The sources.
To install the source of a package, do:
$ rpm -i mypack.src.rpm
The source files will be stored in the /usr/src/packages in directories SPEC and SOURCES. To compile the sources, do:
$ rpm -ba /usr/src/packages/SPECS/mypack.spec
The result of the compilation will be stored in the BUILD directory
[edit] Exercises
- Is the apache package installed?
- In which package are the files /bin/ls, /usr/sbin/tcpdump, and /sbin/ifconfig?
- From the floppy disk install the pci utilities and grub packages. Build the binaries and try to execute them. The sources should be in the /usr/src/packages/BINARY directory.