3. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Red Hat introduced RPM in 1995.
RPM is the package management system used for packaging in the Linux Standard Base (LSB).
RPM (Red Hat Package Manager), is made up of several parts:
Package files (*.rpm); RPM database; rpm tool
RPM Overview
3
rpm tool: [Querying, verifying] [Installing, upgrading, removing] [miscellaneous functions]
RPM packages naming scheme: package-version-patch.architecture.rpm (Ex: ethereal-0.8.9-1.i386.rpm)
RPM database: Info about every package installed. Kept in /var/lib/rpm directory.
every time that rpm cmd is used the database is consulted (On error or inconsistencies run: rpm –rebuilddb)
4. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Validating package integrity - rpm -K package_file.rpm or rpm --checksig
RPM includes functions to check integrity of a package, using the MD5 algorithm and the GnuPG tool.
RPM use
4
Red Hat’s public key package maintainer is available on its FTP site and is named RPM-GPG-KEY
[root@redhat /root]# gpg --import RPM-GPG-KEY
gpg: key DB42A60E: public key imported
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: Total number processed: 1
gpg: imported: 1
Ex:
If the package validates correctly:
[root@redhat /root]# rpm -K wget-1.5.3-6.src.rpm
wget-1.5.3-6.src.rpm: md5 gpg OK
If the package isn’t valid:
[root@redhat /root]# rpm -K wget-1.5.3-10.i386.rpm
wget-1.5.3-10.i386.rpm: rpmReadSignature failed
GnuPG tool: Public key encryption package to check authenticity source of a file or doc and to encrypt communications. www.gnupg.org
PGP tool: Some packages use PGP to check integrity while others use GnuPG. www.pgpi.com
5. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Installing packages - rpm -i package_file.rpm or rpm --install package_file.rpm
1.Many options contain a long and short version:
-i and --install
2.Installs multiple packages:
rpm -i first_package_file.rpm second_package_file.rpm or rpm -i *.rpm
3.can use wildcards when installing or upgrading packages, but not when removing packages.
4.can also get packages from Internet:
rpm -i ftp://rpmfind.net/linux/redhat/redhat-7.0/i386/en/RedHat/RPMS//libpcap-0.4-29.i386.rpm
rpm -i http://rpmfind.net/linux/redhat/redhat-7.0/i386/en/RedHat/RPMS//libpcap-0.4-29.i386.rpm
5.Option -v shows the name of the package installed.
Option -h shows hash marks as the package is installed to show status.
6.By default, rpm will not let you overwrite a file from another package.
Overwrite options:
--force Forces rpm to overwrite existing packages or files.
--nodeps Bypasses dependency checking. Useful if you have installed a dependency by other means.
--replacefiles Overwrite files owned by other packages.
RPM use
5
7. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Removing packages - rpm -e package_name or rpm --uninstall package_name
1.When removing a package, use package name not the filename.
2.Wildcards do not work when removing packages.
3.By default dependency check will not let to remove a package if another depends on it
RPM use
7
Option --nodeps can be used to override default dependency check.
[root@redhat]# rpm -e libpcap
error: removing these packages would break dependencies:
libpcap >= 0.4 is needed by ethereal-0.8.9-1
Ex:
When a package is removed, rpm saves any configuration files that were changed from the default.
(.rpmsave) This way you can reinstall the package later without needing to reconfigure it.
[root@redhat]# ls /etc/pine*
/etc/pine.conf
[root@redhat]# rpm -e pine
[root@redhat]# ls /etc/pine*
/etc/pine.conf.rpmsave
[root@redhat]#
Ex:
8. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Query RPM db: Listing install packages - rpm -q package_name or rpm --query package_name
RPM database stored in /var/lib/rpm holds information about every package installed on the system.
2.Wildcards do not work when removing packages.
3.By default dependency check will not let to remove a package if another depends on it
RPM use
8
Use Option -a To list every package installed on the system.
[root@redhat /root]# rpm -q kernel
kernel-2.2.14-5.0
Ex:
[root@redhat /root]# rpm -qaEx:
Combine with grep to see which groups of packages are installed.
[root@redhat /root]# rpm -qa | grep kernel
kernel-headers-2.2.14-5.0
kernel-2.2.14-5.0
kernel-pcmcia-cs-2.2.14-5.0
kernel-utils-2.2.14-5.0
Ex:
10. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Query RPM db: list files that will install with package use -Add Option –i to –q rpm -qi package_name
RPM use
10
information about the installed Linux kernel
[root@redhat /etc]# rpm -qi kernel
Name : kernel Relocations: (not relocateable)
Version : 2.2.14 Vendor: Red Hat, Inc.
Release : 5.0 Build Date: Tue 07 Mar 2000 09:13:08 PM EST
Install date: Wed 01 Nov 2000 06:58:30 PM EST Build Host: porky.devel.redhat.com
Group : System Environment/Kernel Source RPM: kernel-2.2.14-5.0.src.rpm
Size : 11973135 License: GPL
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary : The Linux kernel (the core of the Linux operating system).
Description :
The kernel package contains the Linux kernel (vmlinuz), the core of your
Red Hat Linux operating system. The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.
Ex:
Query RPM db: Printing package scripts - Add Option –p to –q rpm -qp --scripts package_file.rpm
11. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Verifying package files change - rpm -V package_name
Verify a package using package filename - option -p rpm -Vp package_file.rpm
Verify every package installed on system - option - a rpm -Va package_file.rpm
RPM use
11
Package Verification Characteristics
Item Meaning
. No change for this characteristic
5 The MD5 checksum has changed
S File size has changed
L Symbolic link has changed
T Modification time has changed
D The device major and/or minor number has changed
U User owner has changed
G group owner has changed
M Permission and/or file type has changed
[root@redhat /etc]# rpm -V setup
S.5....T c /etc/hosts.allow
......G. c /etc/profile
S.5....T c /etc/services
Ex:
the hosts.allow file and services file, the file size, MD5 checksum, and modification time have changed.
For the profile file, the group owner has changed, but nothing else.
12. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
Creating binary packages from source RPM packages - rpm -i command.
places files into /usr/src/redhat
RPM use
12
Subdirectories in /usr/src/redhat
Directory Purpose
/usr/src/redhat/ SOURCES Contains the application source code
/usr/src/redhat/ SPECS Contains the RPM spec file
/usr/src/redhat/ BUILD Where source code is built
/usr/src/redhat/ RPMS Contains the final binary RPM
/usr/src/redhat/ SRPMS Contains the source RPM built by the process
The spec file for a package controls how the package is compiled and the scripts that run
when it is installed or removed. named /usr/src/redhat/SPECS/package_name.spec.
13. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
RPM use
13
The spec file has 8 sections:
spec File Section Description
1.Header General information such as summary, name, version, and so on
2.Prep Shell scripts that do any work needed before the compile process
3.Build Commands to build the spec file and compile the source code
4.Install Commands needed to install the software on a system
5.Clean Optional cmds to clean up the build environment, in case this package is rebuilt again
6.File List List of files in the package
7.Changelog Log of any changes you make to the package
8.Optional Install Scripts that may be run during install or uninstall of the package
and Uninstall Scripts
%build
#./configure --prefix=/usr --sysconfdir=/etc
%configure --sysconfdir=/etc
make
Ex: sample build section from the spec file for the wget application:
changes to the compile process are made here. After all of the appropriate modifications have been made, the binary
package needs to be built. (The binary package will be put in the /usr/src/redhat/RPMS directory)
This is done with the -ba option for rpm. rpm -ba package.spec
14. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
YUM use
14
Yellowdog Updater Modified (YUM)
Originally developed to manage Red Hat Linux systems at Duke University's Physics department.
$ gcl --help
bash: gcl: command not found
$ which gcl
/usr/bin/which: no gcl in (/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerber
os/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/
sbin:/home/user/bin)
$ type gcl
bash: type: gcl: not found
Ex:
YUM adds automatic updates, package management, dependency management, to RPM.
YUM, like APT, works with repositories - collections of packages, accessible over a network.
Ex. YUM vs RPM: <For Missing gcl command>
16. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
YUM use
16
# yum install gcl
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcl.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be updated
--> Processing Dependency: gcl-selinux for package: gcl-2.6.8-0.7.20100201cvs.fc12.x86_64
--> Running transaction check
---> Package gcl-selinux.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================
Package Arch Version Repository Size
=====================================================================================
Installing:
gcl x86_64 2.6.8-0.7.20100201cvs.fc12 updates 6.3 M
Installing for dependencies:
gcl-selinux x86_64 2.6.8-0.7.20100201cvs.fc12 updates 17 k
Transaction Summary
=====================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 6.4 M
Installed size: 40 M
Is this ok [y/N]: y
.. // ..
Ex:
Ex. YUM vs RPM: Installing gcl with yum
19. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
YUM use
19
Removing a dependent package with yum
# yum remove gcl-selinux
Loaded plugins: presto, refresh-packagekit
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package gcl-selinux.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be erased
Processing Dependency: gcl-selinux for package: gcl-2.6.8-0.7.20100201cvs.fc12.x86_64
--> Running transaction check
---> Package gcl.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================
Package Arch Version Repository Size
=====================================================================================
Removing:
gcl-selinux x86_64 2.6.8-0.7.20100201cvs.fc12 @updates 90 k
Removing for dependencies:
gcl x86_64 2.6.8-0.7.20100201cvs.fc12 @updates 40 M
Transaction Summary
=====================================================================================
Remove 2 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Is this ok [y/N]: n
Exiting on user Command
Complete!
Ex:
20. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
YUM use
20
Updating using yum update
# yum update 'gr*'
Loaded plugins: presto, refresh-packagekit
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package grep.x86_64 0:2.6.3-1.fc12 set to be updated
---> Package groff.x86_64 0:1.18.1.4-20.fc12 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================
Package Arch Version Repository Size
=====================================================================================
Updating:
grep x86_64 2.6.3-1.fc12 updates 228 k
groff x86_64 1.18.1.4-20.fc12 updates 1.5 M
Transaction Summary
=====================================================================================
Install 0 Package(s)
Upgrade 2 Package(s)
Total download size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
.. // ..
Ex:
22. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
RPM and YUM package management
YUM use
22
Displaying information
$ yum info gcl
Loaded plugins: presto, refresh-packagekit
Installed Packages
Name : gcl
Arch : x86_64
Version : 2.6.8
Release : 0.7.20100201cvs.fc12
Size : 40 M
Repo : installed
From repo : updates
Summary : GNU Common Lisp
URL : http://www.gnu.org/software/gcl/
License : GPL+ and LGPLv2+
Description: GCL is a Common Lisp currently compliant with the ANSI standard.
: Lisp compilation produces native code through the intermediary of
: the system's C compiler, from which GCL derives efficient
: performance and facile portability. Currently uses TCL/Tk as GUI.
Ex:
$ rpm -qi gcl
Name : gcl Relocations: (not relocatable)
Version : 2.6.8 Vendor: Fedora Project
.. // ..
GCL is a Common Lisp currently compliant with the ANSI standard. Lisp
compilation produces native code through the intermediary of the
system's C compiler, from which GCL derives efficient performance and
facile portability. Currently uses TCL/Tk as GUI.