Difference between revisions of "RPM Package Manager"

From Christoph's Personal Wiki
Jump to: navigation, search
(Examples)
(RPM vs. APT)
(8 intermediate revisions by the same user not shown)
Line 31: Line 31:
 
   lib64python2.5-devel-2.5-4.1mdv2007.1
 
   lib64python2.5-devel-2.5-4.1mdv2007.1
 
   lib64python2.5-devel-2.5-4.1mdv2007.1
 
   lib64python2.5-devel-2.5-4.1mdv2007.1
 +
*Get a list of all packages currently installed:
 +
rpm -qa --queryformat='%{NAME} %{ARCH}\n' | sort | uniq > pkgs.txt
  
 
You can alter the output from a query using "querytags". To find out which querytags are available, execute the following command:
 
You can alter the output from a query using "querytags". To find out which querytags are available, execute the following command:
Line 59: Line 61:
 
  /usr/lib64/liblapack.a: relocation R_X86_64_32 against `a local symbol' can not  
 
  /usr/lib64/liblapack.a: relocation R_X86_64_32 against `a local symbol' can not  
 
  be used when making a shared object; recompile with -fPIC
 
  be used when making a shared object; recompile with -fPIC
 +
 +
==RPM vs. APT==
 +
Show the equivalent commands in RedHat-based vs. Debian-based distros.
 +
<pre>
 +
Feature                              rpm                                  deb
 +
-----------------------------------------------------------------------------------------------------------------
 +
View all installed packages          rpm -qa                              dpkg -l, dpkg-query -Wf '${Package}\n'
 +
                                                                          dpkg --get-selections
 +
View files in an installed package  rpm -ql ${PKG}                        dpkg -L ${PKG}
 +
View files in a package file        rpm -qlp ./${PKG}.rpm                dpkg -c ./${PKG}.deb
 +
View package info, installed package rpm -qi ${PKG} (1)                    apt-cache show ${PKG}
 +
                                                                          dpkg -s ${PKG}
 +
View package info, package file      rpm -qip ./${PKG}.rpm (1)            dpkg -I ./${PKG}.deb
 +
View pre/post install shell scripts  rpm -q --scripts ${PKG}              cat /var/lib/dpkg/info/${PKG}.{pre,post}{inst,rm}
 +
View changelog for a package file    rpm -qp --changelog ./${PKG}.rpm      dpkg-deb --fsys-tarfile ${PKG}.deb |\
 +
                                                                            tar -O -xvf - ./usr/share/doc/${PKG}/changelog.gz | gunzip
 +
Install a package file              rpm -ivh ./${PKG}.rpm                dpkg -i
 +
Uninstall a package                  rpm -e ${PKG}                        apt-get remove/purge ${PKG}
 +
                                                                          dpkg -r/dpkg -P
 +
Upgrade a package from a file        rpm -Uvh ./${PKG}.rpm                dpkg -i ${PKG}.deb
 +
Find which package owns a file      rpm -qif /path/to/file                dpkg -S /path/to/file
 +
Find which package provides a file  rpm -q --whatprovides /path/to/file  dpkg-query -S /path/to/file
 +
List dependencies of a package      rpm -q --requires ${PKG}              apt-cache depends package
 +
List dependencies of a package file  rpm -qp --requires ./${PKG}.rpm  (shown in package's info)
 +
List reverse dependencies of package                                      apt-cache rdepends ${PKG}
 +
Verify installed package files      rpm -qV                              debsums
 +
  against MD5 checksums
 +
Query database for data              rpm --queryformat                    dpkg-query -s ${PKG}
 +
List files in package                                                      dpkg-query -L ${PKG}
 +
Find which package provides a        rpm provides htpasswd
 +
  command
 +
</pre>
 +
 +
; Find what package a file belongs to in Debian/Ubuntu
 +
 +
<pre>
 +
$ apt-file search filename
 +
#~OR~
 +
$ apt-file search /path/to/file
 +
</pre>
 +
 +
* Install and update <code>apt-file</code>:
 +
<pre>
 +
$ sudo apt install -y apt-file
 +
$ sudo apt-file update
 +
</pre>
 +
 +
* Prevent package(s) from being upgraded:
 +
<pre>
 +
$ sudo apt-mark docker-ce docker-ce-cli
 +
$ sudo apt-mark showhold
 +
docker-ce
 +
docker-ce-cli
 +
</pre>
 +
 +
See also:
 +
*[http://www.jpsdomain.org/linux/apt.html APT and RPM Packager Lookup Tables]
 +
*[https://help.ubuntu.com/community/SwitchingToUbuntu/FromLinux/RedHatEnterpriseLinuxAndFedora SwitchingToUbuntu/FromLinux/RedHatEnterpriseLinuxAndFedora]
  
 
==See also==
 
==See also==
 +
*[[rpmbuild]]
 
*[[urpmi]]
 
*[[urpmi]]
 
*[[wikipedia:Yellow dog Updater, Modified|yum]]
 
*[[wikipedia:Yellow dog Updater, Modified|yum]]
Line 75: Line 136:
 
*[http://developer.novell.com/wiki/index.php?title=SUSE_Package_Conventions SUSE Package Conventions]
 
*[http://developer.novell.com/wiki/index.php?title=SUSE_Package_Conventions SUSE Package Conventions]
 
*[http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/swinstall.html Package File Format - Linux Standards Base]
 
*[http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/swinstall.html Package File Format - Linux Standards Base]
*[http://lwn.net/Articles/214255/ RPM -- plans, goals, etc. ] - Fedora announcement about RPM.
+
*[http://lwn.net/Articles/214255/ RPM -- plans, goals, etc. ] &mdash; Fedora announcement about RPM.
 
*[http://wiki.rpm.org RPM.org's wiki]
 
*[http://wiki.rpm.org RPM.org's wiki]
 
*[[wikipedia:RPM Package Manager]]
 
*[[wikipedia:RPM Package Manager]]
  
 
[[Category:Linux Command Line Tools]]
 
[[Category:Linux Command Line Tools]]

Revision as of 02:48, 20 May 2021

RPM Package Manager (originally Red Hat Package Manager, abbreviated RPM) is a package management system.

Usage

NOTE: RPM file names normally have the following format:

<name>-<version>-<release>.<arch>.rpm

Examples

  • Install/upgrade packages verbosely:
rpm -Uvh package_name(s)
  • Install/upgrade packages verbosely ignoring dependencies and/or conflicts. (Note: Only do this if you really know what you are doing; the warnings are there for a reason!)
rpm -Uvh --force package_name(s):
  • Return information about a package that is already installed:
rpm -qi package_name
  • Return information about a package that is not necessarily installed:
rpm -qpi package_name
  • Return the ChangeLog of the installed package:
rpm -q --changelog package_name
  • List the absolute paths of all files installed from a given package:
rpm -ql package_name
  • Return glibc-version (if installed):
rpm -qa |grep glibc
  • Returns glibc-version:
rpm -q --whatprovides /lib/libc.so.6
  • Example of what packages Python requires:
rpm -q --whatrequires python
  lib64xml2-python-2.6.27-3mdv2007.1
  tkinter-2.5-4mdv2007.1
  python-imaging-1.1.4-11mdv2007.1
  python-numpy-1.0.1-2mdv2007.1
  python-numeric-24.2-4mdv2007.1
  lib64python2.5-devel-2.5-4.1mdv2007.1
  lib64python2.5-devel-2.5-4.1mdv2007.1
  • Get a list of all packages currently installed:
rpm -qa --queryformat='%{NAME} %{ARCH}\n' | sort | uniq > pkgs.txt

You can alter the output from a query using "querytags". To find out which querytags are available, execute the following command:

rpm --querytags

You can then display selected information on that package(s) in question. For an example, if you only wish to display the names of all packages having "auto" in them (i.e., not version, release, arch, etc.), execute the following command

rpm -qa --qf '%{NAME}\n'|grep auto

This is useful if you want to compare installed packages on two machines with different versions (and/or architectures).

Source code may also be distributed in RPM packages. Such package labels do not have an architecture part and replace it with "src". E.g.:

libgnomeuimm2.0-2.0.0-3.src.rpm

An SRPM is an RPM package with source code. Unlike a tarball (or an RPM), an SRPM package can be automatically compiled and installed, following instructions in the .spec file included in the SRPM.

Recompile with -fPIC

see: HOWTO fix -fPIC errors for some background.

Some 64-bit packages require the source to be compiled with the -fPIC option. For this example, I will be using LAPACK (64-bit version).

  • Step #1: Download the source rpm (e.g., lapack.src.rpm)
  • Step #2: Install/unpack the package
rpm -i lapack.src.rpm
  • Step #3: Add the -fPIC flag to the .SPEC file
vi /usr/src/rpm/SPECS/lapack.spec
   %define optflags ... -fPIC -DPIC ...
  • Step #4: Check that the option was compiled into the libary:
nm /usr/lib64/liblapack.a|more

That should take care of errors that look something like this:

/usr/lib64/liblapack.a: relocation R_X86_64_32 against `a local symbol' can not 
be used when making a shared object; recompile with -fPIC

RPM vs. APT

Show the equivalent commands in RedHat-based vs. Debian-based distros.

Feature                              rpm                                   deb
-----------------------------------------------------------------------------------------------------------------
View all installed packages          rpm -qa                               dpkg -l, dpkg-query -Wf '${Package}\n'
                                                                           dpkg --get-selections
View files in an installed package   rpm -ql ${PKG}                        dpkg -L ${PKG}
View files in a package file         rpm -qlp ./${PKG}.rpm                 dpkg -c ./${PKG}.deb
View package info, installed package rpm -qi ${PKG} (1)                    apt-cache show ${PKG}
                                                                           dpkg -s ${PKG}
View package info, package file      rpm -qip ./${PKG}.rpm (1)             dpkg -I ./${PKG}.deb
View pre/post install shell scripts  rpm -q --scripts ${PKG}               cat /var/lib/dpkg/info/${PKG}.{pre,post}{inst,rm}
View changelog for a package file    rpm -qp --changelog ./${PKG}.rpm      dpkg-deb --fsys-tarfile ${PKG}.deb |\
                                                                             tar -O -xvf - ./usr/share/doc/${PKG}/changelog.gz | gunzip
Install a package file               rpm -ivh ./${PKG}.rpm                 dpkg -i
Uninstall a package                  rpm -e ${PKG}                         apt-get remove/purge ${PKG}
                                                                           dpkg -r/dpkg -P
Upgrade a package from a file        rpm -Uvh ./${PKG}.rpm                 dpkg -i ${PKG}.deb
Find which package owns a file       rpm -qif /path/to/file                dpkg -S /path/to/file
Find which package provides a file   rpm -q --whatprovides /path/to/file   dpkg-query -S /path/to/file
List dependencies of a package       rpm -q --requires ${PKG}              apt-cache depends package
List dependencies of a package file  rpm -qp --requires ./${PKG}.rpm  (shown in package's info)
List reverse dependencies of package                                       apt-cache rdepends ${PKG}
Verify installed package files       rpm -qV                               debsums
  against MD5 checksums
Query database for data              rpm --queryformat                     dpkg-query -s ${PKG}
List files in package                                                      dpkg-query -L ${PKG}
Find which package provides a        rpm provides htpasswd
  command
Find what package a file belongs to in Debian/Ubuntu
$ apt-file search filename
#~OR~
$ apt-file search /path/to/file
  • Install and update apt-file:
$ sudo apt install -y apt-file
$ sudo apt-file update
  • Prevent package(s) from being upgraded:
$ sudo apt-mark docker-ce docker-ce-cli
$ sudo apt-mark showhold
docker-ce
docker-ce-cli

See also:

See also

External links