Difference between revisions of "Package managers"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (Added "pacman -Qi" command)
(typo fix)
 
(8 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
! RPM<br/><small>RHEL, Fedora, CentOS, Mandriva, SUSE, ...</small>
 
! RPM<br/><small>RHEL, Fedora, CentOS, Mandriva, SUSE, ...</small>
 
! DEB<br/><small>Debian, Knoppix, Ubuntu, ...</small>
 
! DEB<br/><small>Debian, Knoppix, Ubuntu, ...</small>
! Slackpkg<br/><small>Slackware, SLAX, ...</small>
 
 
! Ebuild<br/><small>Gentoo and derivatives (Sabayon, Ututo, ...)</small>
 
! Ebuild<br/><small>Gentoo and derivatives (Sabayon, Ututo, ...)</small>
 
! Pacman<br/><small>Arch Linux</small>
 
! Pacman<br/><small>Arch Linux</small>
Line 15: Line 14:
 
|| <code>rpm -qa</code>
 
|| <code>rpm -qa</code>
 
|| <code>dpkg -l</code>
 
|| <code>dpkg -l</code>
||
 
 
|| <code>equery list '*'</code>
 
|| <code>equery list '*'</code>
|| <code>pacman -Qi</code>
+
|| <code>pacman -Q</code>
 
|-
 
|-
 
! List of installed packages matching ''substr''
 
! List of installed packages matching ''substr''
 
|| <code>rpm -qa ''\*substr\*''</code>
 
|| <code>rpm -qa ''\*substr\*''</code>
 
|| <code>dpkg -l ''\*substr\*''</code>
 
|| <code>dpkg -l ''\*substr\*''</code>
||
 
 
|| <code>equery list ''substr''</code>
 
|| <code>equery list ''substr''</code>
 
|| <code>pacman -Q | grep ''substr''</code>
 
|| <code>pacman -Q | grep ''substr''</code>
Line 28: Line 25:
 
! Basic information about an installed ''package''
 
! Basic information about an installed ''package''
 
|| <code>rpm -qi ''package''</code>
 
|| <code>rpm -qi ''package''</code>
|| <code>dpkg -p ''package''</code>
+
|| <code>dpkg -s ''package''</code>
||
 
 
|| <code>eix ''package''</code>
 
|| <code>eix ''package''</code>
 
|| <code>pacman -Qi ''package''</code>
 
|| <code>pacman -Qi ''package''</code>
Line 36: Line 32:
 
|| <code>rpm -ql ''package''</code>
 
|| <code>rpm -ql ''package''</code>
 
|| <code>dpkg -L ''package''</code>
 
|| <code>dpkg -L ''package''</code>
||
 
 
|| <code>equery files ''package''</code>
 
|| <code>equery files ''package''</code>
 
|| <code>pacman -Ql ''package''</code>
 
|| <code>pacman -Ql ''package''</code>
Line 45: Line 40:
 
|| <code>rpm -qf ''file''</code>
 
|| <code>rpm -qf ''file''</code>
 
|| <code>dpkg -S ''file''</code>
 
|| <code>dpkg -S ''file''</code>
||
 
 
|| <code>equery belongs ''file''</code>
 
|| <code>equery belongs ''file''</code>
 
|| <code>pacman -Qo ''file''</code>
 
|| <code>pacman -Qo ''file''</code>
Line 52: Line 46:
 
|| <code>rpm -V ''package''</code>
 
|| <code>rpm -V ''package''</code>
 
|| <code>debsums -ca ''package''</code>
 
|| <code>debsums -ca ''package''</code>
||
 
 
|| <code>equery check ''package''</code>
 
|| <code>equery check ''package''</code>
 
||
 
||
Line 59: Line 52:
 
|| <code>rpm -q --scripts ''package''</code>
 
|| <code>rpm -q --scripts ''package''</code>
 
|| <code>less /var/lib/dpkg/info/''package''.{pre,post,config}*</code>
 
|| <code>less /var/lib/dpkg/info/''package''.{pre,post,config}*</code>
||
 
 
|| <code>cat `equery which ''package''`</code>
 
|| <code>cat `equery which ''package''`</code>
 
||
 
||
Line 65: Line 57:
 
! Show change log for a ''package''
 
! Show change log for a ''package''
 
|| <code>rpm -q --changelog ''package''</code>
 
|| <code>rpm -q --changelog ''package''</code>
|| <code>zcat /usr/share/doc/package/changelog.Debian.gz</code><br/><code>aptitude [-t release] changelog package</code>
+
|| <code>zcat /usr/share/doc/''package''/changelog.Debian.gz</code><br/><code>aptitude [-t release] changelog ''package''</code>
||
 
 
|| <code>view /usr/portage/''category''/''package''/ChangeLog</code>
 
|| <code>view /usr/portage/''category''/''package''/ChangeLog</code>
|| <code>pacman -Qc ''package''
+
|| <code>pacman -Qc ''package''</code>
 
|-
 
|-
 
! colspan="5" align="center" | <big>'''Local package installation/upgrade/removal'''</big>
 
! colspan="5" align="center" | <big>'''Local package installation/upgrade/removal'''</big>
Line 74: Line 65:
 
! Install a package from local ''package_file''
 
! Install a package from local ''package_file''
 
|| <code>rpm -ihv ''package_file*.rpm''<br/>yum localinstall ''package_file*.rpm''<ref name="localinstall">In case there are unsatisfied dependencies for ''package_file'', yum will try to get and install it from known repositores.</ref></code>
 
|| <code>rpm -ihv ''package_file*.rpm''<br/>yum localinstall ''package_file*.rpm''<ref name="localinstall">In case there are unsatisfied dependencies for ''package_file'', yum will try to get and install it from known repositores.</ref></code>
|| <code>dpkg -i ''package_file*.deb'' <ref name="apt">Usually it is not necessary to download packages manually and install them. Use apt-cache search ''name'' to search for package in configured repositories and apt-get install ''package'' to install package and all it's dependencies</ref></code>
+
|| <code>dpkg -i ''package_file*.deb'' <ref name="apt">Usually it is not necessary to download packages manually and install them. Use apt-cache search ''name'' to search for package in configured repositories and apt-get install ''package'' to install package and all its dependencies</ref></code>
||
 
 
|| <code>emerge --usepkg|-k ''package''<ref name="emerge-usepkg">Use a binary package if it is available from $PKGDIR, otherwise emerge from source as usual.</ref></code><br/><code>emerge --usepkgonly|-K ''package''<ref name="emerge-usepkgonly">Use a binary package if it is available from $PKGDIR, otherwise abort.</ref></code>
 
|| <code>emerge --usepkg|-k ''package''<ref name="emerge-usepkg">Use a binary package if it is available from $PKGDIR, otherwise emerge from source as usual.</ref></code><br/><code>emerge --usepkgonly|-K ''package''<ref name="emerge-usepkgonly">Use a binary package if it is available from $PKGDIR, otherwise abort.</ref></code>
 
|| <code>pacman -U ''package''</code>
 
|| <code>pacman -U ''package''</code>
Line 82: Line 72:
 
|| <code>rpm -Uhv ''package_file*.rpm''</code>
 
|| <code>rpm -Uhv ''package_file*.rpm''</code>
 
|| <code>dpkg -i ''package_file*.deb'' <ref name="apt"/></code>
 
|| <code>dpkg -i ''package_file*.deb'' <ref name="apt"/></code>
||
 
 
|| <code>emerge --update --usepkg|-k ''package''<ref name="emerge-usepkg"/></code><br/>
 
|| <code>emerge --update --usepkg|-k ''package''<ref name="emerge-usepkg"/></code><br/>
 
<code>emerge --update --usepkgonly|-K ''package''<ref name="emerge-usepkgonly"/></code>
 
<code>emerge --update --usepkgonly|-K ''package''<ref name="emerge-usepkgonly"/></code>
Line 92: Line 81:
 
|| <code>dpkg -r ''package''</code><br/>
 
|| <code>dpkg -r ''package''</code><br/>
 
<code>dpkg -P ''package''</code>
 
<code>dpkg -P ''package''</code>
||
 
 
|| <code>emerge --unmerge ''package''</code><br/>
 
|| <code>emerge --unmerge ''package''</code><br/>
 
<code>emerge --prune ''package''</code>
 
<code>emerge --prune ''package''</code>
Line 104: Line 92:
 
|| <code>apt-get update && apt-get install ''package''</code><br/>
 
|| <code>apt-get update && apt-get install ''package''</code><br/>
 
<code>aptitude update && aptitude install ''package''</code>
 
<code>aptitude update && aptitude install ''package''</code>
||
 
 
|| <code>emerge -av ''package''</code>
 
|| <code>emerge -av ''package''</code>
 
|| <code>pacman -S ''package''</code>
 
|| <code>pacman -S ''package''</code>
Line 110: Line 97:
 
! Install a debug information files for a ''package''
 
! Install a debug information files for a ''package''
 
|| <code>debuginfo-install ''package''</code>
 
|| <code>debuginfo-install ''package''</code>
||
 
 
||  
 
||  
 
|| <code>FEATURES="splitdebug installsources" emerge -av ''package''</code>
 
|| <code>FEATURES="splitdebug installsources" emerge -av ''package''</code>
Line 118: Line 104:
 
|| First install the yum-downloadonly plugin by running: <br/><code>yum install yum-downloadonly</code><br/> And then: <br/> <code>yum install|update ''package'' -y --downloadonly --downloaddir=/opt</code>
 
|| First install the yum-downloadonly plugin by running: <br/><code>yum install yum-downloadonly</code><br/> And then: <br/> <code>yum install|update ''package'' -y --downloadonly --downloaddir=/opt</code>
 
|| <code>apt-get install --download-only --reinstall ''package''</code><ref name="dpkgdir">Package will reside in /var/cache/apt/archives.</ref><br/><code>aptitude download ''package''</code>
 
|| <code>apt-get install --download-only --reinstall ''package''</code><ref name="dpkgdir">Package will reside in /var/cache/apt/archives.</ref><br/><code>aptitude download ''package''</code>
||
 
 
|| <code>emerge -avf ''package''</code><ref name="distfiles">Package sources will reside in /usr/portage/distfiles.</ref>
 
|| <code>emerge -avf ''package''</code><ref name="distfiles">Package sources will reside in /usr/portage/distfiles.</ref>
 
|| <code>pacman -Sw ''package''</code>
 
|| <code>pacman -Sw ''package''</code>
Line 127: Line 112:
 
|| <code>rpm -q --provides ''package''</code>
 
|| <code>rpm -q --provides ''package''</code>
 
|| <code>dpkg-query -W -f='${Provides}\n' ''package''</code>
 
|| <code>dpkg-query -W -f='${Provides}\n' ''package''</code>
||
 
 
|| <code>equery files ''package'' (package must be installed first)</code>
 
|| <code>equery files ''package'' (package must be installed first)</code>
 
|| <code>pacman -Ql ''package'' (package must be installed first)</code>
 
|| <code>pacman -Ql ''package'' (package must be installed first)</code>
Line 134: Line 118:
 
|| <code>rpm -q --requires ''package''</code>
 
|| <code>rpm -q --requires ''package''</code>
 
|| <code>dpkg-query -W -f='${Depends}\n' ''package''</code>
 
|| <code>dpkg-query -W -f='${Depends}\n' ''package''</code>
||
 
 
|| <code>equery depgraph --depth=1 ''package''</code>
 
|| <code>equery depgraph --depth=1 ''package''</code>
 
|| <code>pacman -Si ''package''</code>
 
|| <code>pacman -Si ''package''</code>
Line 140: Line 123:
 
! Which installed package(s) provide a given ''dependency''<ref name="dep">In rpm world, a ''dependency'' can be a package name, a file, or a special atom like <code>perl(IO::Zlib)</code> for a perl module. In deb world, this can be either real or virtual package name.</ref>?
 
! Which installed package(s) provide a given ''dependency''<ref name="dep">In rpm world, a ''dependency'' can be a package name, a file, or a special atom like <code>perl(IO::Zlib)</code> for a perl module. In deb world, this can be either real or virtual package name.</ref>?
 
|| <code>rpm -q --whatprovides ''dependency''</code>
 
|| <code>rpm -q --whatprovides ''dependency''</code>
|| <code>dpkg-query -W -f='${Package}: ${Provides}\n' '*' | grep ': .*package'</code>
+
|| <code>dpkg-query -W -f='${Package}: ${Provides}\n' '*' | grep ': .*''dependency''<nowiki>'</nowiki></code>
||
 
 
|| <code>equery belongs ''dependency''</code>
 
|| <code>equery belongs ''dependency''</code>
 
||
 
||
Line 147: Line 129:
 
! Which installed package(s) require a given ''dependency''<ref name="dep"/>?
 
! Which installed package(s) require a given ''dependency''<ref name="dep"/>?
 
|| <code>rpm -q --whatrequires ''dependency''</code>
 
|| <code>rpm -q --whatrequires ''dependency''</code>
|| <code>dpkg-query -W -f='${Package}: ${Depends}\n' '*' | grep ': .*package'</code><br><code>aptitude why package</code><ref name="why">Actualy shows the whole dpendency situation that leads to install this package</ref>
+
|| <code>dpkg-query -W -f='${Package}: ${Depends}\n' '*' | grep ': .*''package''<nowiki>'</nowiki></code><br><code>aptitude why ''package''</code><ref name="why">Actualy shows the whole dpendency situation that leads to install this package</ref>
||
 
 
|| <code>equery depends ''package''</code>
 
|| <code>equery depends ''package''</code>
|| <code>pacman -Qi package | grep Required</code>
+
|| <code>pacman -Qi ''package'' | grep Required</code>
 
||
 
||
 
|-
 
|-
 
! Show what prevents installation of a package
 
! Show what prevents installation of a package
 
|| <code>(yum/rpm tells with --verbose option -v)</code>
 
|| <code>(yum/rpm tells with --verbose option -v)</code>
|| <code>aptitude why-not package</code>
+
|| <code>aptitude why-not ''package''</code>
||
 
 
|| <code>emerge -pv ''package''</code>
 
|| <code>emerge -pv ''package''</code>
 
||
 
||
Line 163: Line 143:
 
|| <code>yumdownloader --source ''package''</code>
 
|| <code>yumdownloader --source ''package''</code>
 
|| <code>apt-get source ''package''</code>
 
|| <code>apt-get source ''package''</code>
||
 
 
|| <code>emerge -f ''package''</code>
 
|| <code>emerge -f ''package''</code>
 
|| <code>abs ''repository''/''package''</code>
 
|| <code>abs ''repository''/''package''</code>
Line 171: Line 150:
 
! Unpack a package ''file'' to local directory
 
! Unpack a package ''file'' to local directory
 
|| <code>rpm2cpio ''file.rpm'' | cpio -id</code>
 
|| <code>rpm2cpio ''file.rpm'' | cpio -id</code>
|| <code>dpkg -x ''file.deb'' .</code>
+
|| <code>dpkg -x / --extract ''file.deb'' .</code>
||
 
 
|| N/A
 
|| N/A
 
|| <code>tar -xzf ''package''</code> if ''package''.pkg.tar.gz or<br/><code>tar -xJf ''package''</code> if ''package''.pkg.tar.xz
 
|| <code>tar -xzf ''package''</code> if ''package''.pkg.tar.gz or<br/><code>tar -xJf ''package''</code> if ''package''.pkg.tar.xz
Line 179: Line 157:
 
|| <code>rpm -K ''file.rpm''</code><br/>(yum/rpm also checks GPG-signature and checksums automatically every time the package is installed or upgraded)
 
|| <code>rpm -K ''file.rpm''</code><br/>(yum/rpm also checks GPG-signature and checksums automatically every time the package is installed or upgraded)
 
|| <code>debsums ''package''</code>
 
|| <code>debsums ''package''</code>
||
 
 
|| <code>emerge -f ''package''</code>
 
|| <code>emerge -f ''package''</code>
 
||
 
||
 +
|-
 +
! Show package metadata
 +
|| <code>rpm -qip ''file.rpm''</code>
 +
|| <code>dpkg -I / --info ''file.deb''</code>
 +
|| N/A
 +
|| ??
 +
|-
 +
! Show package file list
 +
|| <code>rpm -qlvp ''file.rpm''</code>
 +
|| <code>dpkg -c / --contents ''file.deb''</code>
 +
|| N/A
 +
|| ??
 
|-
 
|-
 
! colspan="5" align="center" | <big>'''Repository queries'''</big>
 
! colspan="5" align="center" | <big>'''Repository queries'''</big>
Line 188: Line 177:
 
|| <code>yum provides ''/some/file''</code>
 
|| <code>yum provides ''/some/file''</code>
 
|| First run: <br/><code>apt-file update</code><br/>and then:<br/><code>apt-file search ''/some/file''</code>
 
|| First run: <br/><code>apt-file update</code><br/>and then:<br/><code>apt-file search ''/some/file''</code>
||
 
 
|| N/A
 
|| N/A
 
||
 
||
 
|-
 
|-
! Find a package based on some string or part of the string descriping it
+
! Find a package based on some string or part of the string describing it
 
|| <code>yum search ''\*substr\*''</code>
 
|| <code>yum search ''\*substr\*''</code>
 
|| <code>apt-cache search ''\*substr\*''</code>
 
|| <code>apt-cache search ''\*substr\*''</code>
||
 
 
|| <code>eix -S ''substr''</code>
 
|| <code>eix -S ''substr''</code>
 
|| <code>pacman -Ss ''substr''</code>
 
|| <code>pacman -Ss ''substr''</code>
Line 202: Line 189:
 
|| <code>yum info ''package''</code>
 
|| <code>yum info ''package''</code>
 
|| <code>apt-cache show ''package''</code>
 
|| <code>apt-cache show ''package''</code>
||
 
 
|| <code>eix ''package''</code>
 
|| <code>eix ''package''</code>
 
|| <code>pacman -Si ''package''</code>
 
|| <code>pacman -Si ''package''</code>

Latest revision as of 21:18, 16 January 2023

With OpenVZ, you can run many different Linux distributions on a single box. One particular thing in which distributions differ is package management. This article summarizes how to perform various common package management tasks on a different distributions.

Commands[edit]

Action RPM
RHEL, Fedora, CentOS, Mandriva, SUSE, ...
DEB
Debian, Knoppix, Ubuntu, ...
Ebuild
Gentoo and derivatives (Sabayon, Ututo, ...)
Pacman
Arch Linux
Basic queries
List of all installed packages rpm -qa dpkg -l equery list '*' pacman -Q
List of installed packages matching substr rpm -qa \*substr\* dpkg -l \*substr\* equery list substr pacman -Q | grep substr
Basic information about an installed package rpm -qi package dpkg -s package eix package pacman -Qi package
List of files in a given package rpm -ql package dpkg -L package equery files package pacman -Ql package
Advanced queries
Which package a file belongs to? rpm -qf file dpkg -S file equery belongs file pacman -Qo file
Check the hash (i.e. MD5 etc.) sums of an installed package rpm -V package debsums -ca package equery check package
Show pre/post install/uninstall scripts from a package rpm -q --scripts package less /var/lib/dpkg/info/package.{pre,post,config}* cat `equery which package`
Show change log for a package rpm -q --changelog package zcat /usr/share/doc/package/changelog.Debian.gz
aptitude [-t release] changelog package
view /usr/portage/category/package/ChangeLog pacman -Qc package
Local package installation/upgrade/removal
Install a package from local package_file rpm -ihv package_file*.rpm
yum localinstall package_file*.rpm[1]
dpkg -i package_file*.deb [2] emerge --usepkg|-k package[3]
emerge --usepkgonly|-K package[4]
pacman -U package
Upgrade a package from local package_file rpm -Uhv package_file*.rpm dpkg -i package_file*.deb [2] emerge --update --usepkg|-k package[3]

emerge --update --usepkgonly|-K package[4]

pacman -U package
Remove an installed package rpm -e package

yum remove|erase package[5]

dpkg -r package

dpkg -P package

emerge --unmerge package

emerge --prune package

pacman -R package
Package installation from repositories
Install a package yum install package

urpmi package

apt-get update && apt-get install package

aptitude update && aptitude install package

emerge -av package pacman -S package
Install a debug information files for a package debuginfo-install package FEATURES="splitdebug installsources" emerge -av package
Only download a package from repository, do not install First install the yum-downloadonly plugin by running:
yum install yum-downloadonly
And then:
yum install|update package -y --downloadonly --downloaddir=/opt
apt-get install --download-only --reinstall package[6]
aptitude download package
emerge -avf package[7] pacman -Sw package
Get information about package interdependencies
What a given package provides? rpm -q --provides package dpkg-query -W -f='${Provides}\n' package equery files package (package must be installed first) pacman -Ql package (package must be installed first)
What a given package requires? rpm -q --requires package dpkg-query -W -f='${Depends}\n' package equery depgraph --depth=1 package pacman -Si package
Which installed package(s) provide a given dependency[8]? rpm -q --whatprovides dependency dpkg-query -W -f='${Package}: ${Provides}\n' '*' | grep ': .*dependency' equery belongs dependency
Which installed package(s) require a given dependency[8]? rpm -q --whatrequires dependency dpkg-query -W -f='${Package}: ${Depends}\n' '*' | grep ': .*package'
aptitude why package[9]
equery depends package pacman -Qi package | grep Required
Show what prevents installation of a package (yum/rpm tells with --verbose option -v) aptitude why-not package emerge -pv package
Get package source files yumdownloader --source package apt-get source package emerge -f package abs repository/package
Working with package files
Unpack a package file to local directory rpm2cpio file.rpm | cpio -id dpkg -x / --extract file.deb . N/A tar -xzf package if package.pkg.tar.gz or
tar -xJf package if package.pkg.tar.xz
Check package file integrity (checksums, signatures...) rpm -K file.rpm
(yum/rpm also checks GPG-signature and checksums automatically every time the package is installed or upgraded)
debsums package emerge -f package
Show package metadata rpm -qip file.rpm dpkg -I / --info file.deb N/A ??
Show package file list rpm -qlvp file.rpm dpkg -c / --contents file.deb N/A ??
Repository queries
Find a package in a repository which /some/file belongs to yum provides /some/file First run:
apt-file update
and then:
apt-file search /some/file
N/A
Find a package based on some string or part of the string describing it yum search \*substr\* apt-cache search \*substr\* eix -S substr pacman -Ss substr
Shows the full description of package yum info package apt-cache show package eix package pacman -Si package

Relevant directories and files[edit]

Red Hat, Fedora, CentOS[edit]

  • yum config: /etc/yum.conf.
  • yum repos: /etc/yum.repos.d/.
  • rpm configs and macros: /etc/rpm/, /usr/lib/rpm/,
  • rpm DB: /var/lib/rpm/

Debian/Ubuntu[edit]

  • List of repositories and mirror sites: /etc/apt/sources.list, /etc/apt/sources.list.d/.

Gentoo[edit]

  • emerge configs: /etc/make.conf, /etc/portage/.
  • Portage tree: /usr/portage.
  • Binary packages (FEATURES="buildpkg" enabled in make.conf): /usr/portage/packages.
  • Default directory to download sources to: /usr/portage/distfiles.
  • Default Portage working directory: /var/lib/portage/.

Notes[edit]

  1. In case there are unsatisfied dependencies for package_file, yum will try to get and install it from known repositores.
  2. 2.0 2.1 Usually it is not necessary to download packages manually and install them. Use apt-cache search name to search for package in configured repositories and apt-get install package to install package and all its dependencies
  3. 3.0 3.1 Use a binary package if it is available from $PKGDIR, otherwise emerge from source as usual.
  4. 4.0 4.1 Use a binary package if it is available from $PKGDIR, otherwise abort.
  5. This will also remove any packages which depend on the package
  6. Package will reside in /var/cache/apt/archives.
  7. Package sources will reside in /usr/portage/distfiles.
  8. 8.0 8.1 In rpm world, a dependency can be a package name, a file, or a special atom like perl(IO::Zlib) for a perl module. In deb world, this can be either real or virtual package name.
  9. Actualy shows the whole dpendency situation that leads to install this package

See also[edit]

Debian[edit]