Beruflich Dokumente
Kultur Dokumente
In this lab, we'll learn how to use Red Hat's packaging system. Both the format and the
primary command used to install and query packages are called rpm, deb. There are
several dozen RPM-based Linux distributions, including CentOS, Fedora Core, Red Hat
Enterprise Linux, and SUSE, Debian, Ubuntu.
First, we'll use the rpm (dpkg) command to install packages manually, then we'll look at
the higher level RPM commands. While Red Hat Enterprise Linux uses the up2date
command to access the commercial repositories on the Red Hat Network, CentOS uses
the yum (apt-get) command. These commands will install packages and all of their
dependencies from the network.
2. Install emacs, an alternative to vim, from the Fedora repository using the
same technique you applied above. This install will fail. What went
wrong?
2. Querying the RPM database
1. List information about the package installed above.
rpm -qa | wc -l
3. Since yum has complete databases of information about packages that are
in its repositories, it can also provide information about packages that have
not been installed, like emacs.
yum can also determine what files a package needs to work and what
packages provide those files.
1. Verify the zsh package. The rpm -V command should return nothing, as the
package should be intact. Delete a file. Verify the package again. Now you should
receive a message indicating that the file you removed is missing.
rpm -V zsh
rm -f /bin/zsh
rpm -V zsh
2. Fix the broken zsh package. We can't re-install the package directly with yum, as
it's already installed and forcing re-installing will cause the pre- and post-install
scripts to be run again. For some packages, that may not cause problems, but for
others, such as a running web server, it might. The simplest solution is to
download the RPM and extract the file we want from it; fortunately, we already
downloaded zsh. To extract the file we want, we construct a pipeline that
converts the RPM to a CPIO archive with rpm2cpio then extracts the man page
we need with cpio. Note that rpm might complain about the timestamps of the
restored file when you do the check to verify that the file has been restored.
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
cd /
rpm2cpio /home/your_username/zsh*rpm | cpio -vi ./bin/zsh
ls -l /bin/zsh
rpm -V zsh
• Building Software with RPM
1. Install the RPM build tools that you'll need to create an RPM.
2. Download the source RPM for nmap-4.20 from DAG RPMs and install it (use a
search engine to find the site if you don't know the URL.) Note that installing a
source RPM is not like installing a binary RPM. If you get some errors about
nonexistent file owners being replaced by root, that's not a problem. It just means
that a user on the system where the source RPM was created doesn't exist on your
system.
3. RPM always installs the source code and the SPEC file that describes how to
build the source code under /usr/src/redhat, where you can later build binary
RPMs from it using rpmbuild.
cd /usr/src/redhat
# You should find a SPEC file and a tarball containing the
source code.
ls -lR | less
# Read the SPEC file and find what packages nmap depends upon.
# List the dependencies in your lab.txt file.
less SPECS/nmap.spec
4. Build the nmap source RPM. If you encounter dependency problems, use yum to
resolve them. If you encounter a dependency you cannot resolve, remove it from
the SPEC file and try to build the RPM without it.
5. View the new packages. How many binary RPMs were built from the one source
RPM? How many source RPMs? Record the answers in your lab.txt file.
ls -l RPMS/* SRPMS/*
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
6. Using the build output saved above, answer the following questions. What
processor was the build optimized for (the options for the C compiler gcc should
be helpful in answering this question)? What dependencies to each of the binary
RPMs have? Include the answers to your questions in your lab.txt file.
less typescript
7. Install the new RPMs. You may need to resolve dependencies with yum. This need
may be surprising, as you already resolved dependencies while building nmap.
However, those dependencies were the ones required to compile the software and
did not include the libraries needed by the software at runtime.
rpm -q nmap
rpm -ql nmap