Equery

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Equery and the translation is 76% complete.
Outdated translations are marked like this.

equery是一个用于简化常用 Portage 操作的工具。此外,它可以显示包依赖项、元数据和已安装文件。

equery is part of gentoolkit.

安装

Emerge

Equery是使用app-portage/gentoolkit包安装的工具集的一部分:

root #emerge --ask app-portage/gentoolkit

有关安装equery或其他工具的更多信息,请访问Gentoolkit文章。

使用

介绍

equery是一个显示系统上已安装软件包有用信息的工具,equery基于模块系统。每个模块都有一个简写名称。例如,运行equery l gcc与运行equery list gcc相同。调用--help选项(equery --help)将输出全局选项并列出所有可用模块及其简写名称。将模块名称添加到末尾(equery --help module)将显示该特定模块的帮助信息。执行man equery还将提供所有可用模块和选项的详细说明以及一些有用的示例。

以下是适用于大多数模块的功能列表。

user $equery --quiet list gcc
sys-devel/gcc-4.3.2-r3
user $equery --quiet list sys-devel/gcc
sys-devel/gcc-4.3.2-r3
user $equery --quiet list '>=sys-devel/gcc-4'
sys-devel/gcc-4.3.2-r3

emerge一样,equery不理解部分的包名称:

user $equery check zilla
!!! No package found matching zilla

emerge不同,equery可以在类别或包名称中接受类似shell的通配:

user $equery check '*zilla*'
 * Checking www-client/mozilla-firefox-3.0.14 ...
    90 out of 90 files passed
user $equery check 'www-c*/*'
 * Checking www-client/links-2.2 ...
   30 out of 30 files passed
 * Checking www-client/mozilla-firefox-3.0.14 ...
   90 out of 90 files passed

大多数equery模块接受多个输入:

user $equery hasuse sse sse2
 * Searching for USE flag sse ...
[IP-] [  ] media-libs/flac-1.2.1-r3 (0)
[IP-] [  ] media-libs/speex-1.2_beta3_p2 (0)
  
 * Searching for USE flag sse2 ...
[IP-] [  ] dev-libs/openssl-0.9.8k (0)
[IP-] [  ] x11-libs/pixman-0.16.0 (0)

一些模块还允许完整的正则表达式:

user $equery -q list --portage-tree --full-regex '[kr]?flickr.*'
dev-dotnet/flickrnet-bin-2.2
dev-ruby/flickr-1.0.2-r1
dev-ruby/flickr-1.0.2-r2
dev-ruby/rflickr-20060201
media-gfx/kflickr-0.6
[...]
附注
通配符支持取代了equery中许多旧的选项。例如,要对某个集合中的所有包执行操作,请使用'*'(星号)。要对类别中的所有包执行操作,请使用'category-name/*'
警告
在使用shell特殊字符时,例如星号或大于号、小于号等,不要忘记使用引号将其括起来。

本文档的下几节将简要介绍不同的equery模块。

功能

要查看 equery 的全部功能,只要不加任何参数运行即可:

user $equery
Gentoo package query tool
Usage: equery [global-options] module-name [module-options]
 
modules (short name)
 (b)elongs               list what package FILES belong to
 (c)hanges               list changelog entries for ATOM
 chec(k)                 verify checksums and timestamps for PKG
 (d)epends               list all packages directly depending on ATOM
 dep(g)raph              display a tree of all dependencies for PKG
 (f)iles                 list all files installed by PKG
 h(a)s                   list all packages for matching ENVIRONMENT data stored in /var/db/pkg
 (h)asuse                list all packages that have USE flag
 ke(y)words              display keywords for specified PKG
 (l)ist                  list package matching PKG
 (m)eta                  display metadata about PKG
 (s)ize                  display total size of all files owned by PKG
 (u)ses                  display USE flags for PKG
 (w)hich                 print full path to ebuild for PKG
附注
As of 2023-01-27, the keywords module is not documented in the equery(1) man page - cf. bug #565408. However, a description is provided below. The keywords module is documented in its alias command eshowkw(1) man page.

命令别名(Aliases)

使用 equery 的一个常见方法是创建命令别名(aliases)。当使用 bash 的时候这些别名(aliases)可以放到 ~/.bashrc 文件中:

文件 ~/.bashrc
alias eqf='equery f'
alias equ='equery u'
alias eqh='equery h'
alias eqa='equery a'
alias eqb='equery b'
alias eql='equery l'
alias eqd='equery d'
alias eqg='equery g'
alias eqc='equery c'
alias eqk='equery k'
alias eqm='equery m'
alias eqy='equery y'
alias eqs='equery s'
alias eqw='equery w'

查找文件来自哪个包:belongs (b)

user $equery belongs -e /usr/bin/glxgears
 * Searching for /usr/bin/glxgears ...
 x11-apps/mesa-progs-7.5.1 (/usr/bin/glxgears)

belongs可以使用-f选项搜索与正则表达式匹配的文件。-e选项在找到匹配项后停止搜索,由于您的系统上的任何文件都不应归两个软件包所有,因此这是一个安全的操作。

也可以使用belongs (b)的简短版本。例如,列出equery所属的包:

user $equery b equery
 * Searching for equery ... 
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib/python-exec/python2.7/equery)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib64/python3.3/site-packages/gentoolkit/test/equery)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/bin/equery -> ../lib/python-exec/python-exec2)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib64/python2.7/site-packages/gentoolkit/equery)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib/python-exec/python3.3/equery)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib64/python2.7/site-packages/gentoolkit/test/equery)
app-portage/gentoolkit-0.3.0.8-r2 (/usr/lib64/python3.3/site-packages/gentoolkit/equery)

验证包的完整性:check (k)

有时检查包的完整性是有用的。equery可以通过验证MD5值以及时间戳来检验一个软件包是否被破坏,替换或删除。

user $equery check gentoolkit
 * Checking app-portage/gentoolkit-0.3.0_rc7 ...
   71 out of 71 files passed

列出依赖该包的所有包:depends (d)

Ever wonder why a certain package has been installed on the system? equery can tell which packages list it as a dependency with depends. Include indirect dependencies with the -D option.

有没有想过为什么系统上安装了某个软件包?equery使用depends可以列出哪些包依赖这个包。使用-D选项显示间接依赖项。

user $equery depends pygtk
 * Searching for pygtk ...
app-admin/pessulus-2.24.0 (>=dev-python/pygtk-2.6.0)
app-editors/gedit-2.24.3 (python ? >=dev-python/pygtk-2.12)
dev-libs/libgweather-2.24.3 (python ? >=dev-python/pygtk-2)
dev-python/gnome-python-base-2.22.3 (>=dev-python/pygtk-2.10.3)
dev-python/gnome-python-desktop-base-2.24.1 (>=dev-python/pygtk-2.10.3)
[...]

第二个例子列出了所有直接依赖于udev的包:

user $equery d udev
sys-auth/consolekit-0.4.5_p20120320 (acl ? >=sys-fs/udev-146-r1)
sys-fs/cryptsetup-1.4.1 (>=sys-fs/udev-124)
                        (>=sys-fs/udev-182[static-libs])
                        (<=sys-fs/udev-171-r6)
sys-fs/lvm2-2.02.88 (>=sys-fs/udev-151-r4)
virtual/dev-manager-0 (sys-fs/udev)
x11-libs/cairo-1.10.2-r2 (drm ? >=sys-fs/udev-136)
附注
此输出将包括由USE标志控制的可选依赖项,即上面(acl ? >=sys-fs/udev-146-r1)中的acl USE,即使该USE标志未激活。如果USE标志处于活动状态,则包只是依赖项。

获取依赖图:depgraph (g)

depgraphdepends相反,它将找到给定包依赖的所有ebuild(而不是依赖于该包的ebuild)。当它找到依赖项时,它将递归搜索该包的依赖项。使用--depth选项控制树的深度。

user $equery depgraph mozilla-firefox
 * Searching for mozilla-firefox ...
 * dependency graph for www-client/mozilla-firefox-2.0.0.19:
`-- www-client/mozilla-firefox-2.0.0.19
 `-- virtual/jre-1.6.0 (virtual/jre) [java]
  `-- virtual/jdk-1.6.0 (virtual/jdk-1.6.0*)
  `-- dev-java/icedtea6-bin (unable to resolve: package masked or removed)
   `-- dev-java/sun-jdk-1.6.0.15
    `-- dev-java/java-sdk-docs-1.6.0.10 [doc]
     `-- app-arch/unzip-6.0-r1
      `-- app-arch/bzip2-1.0.5-r1 [bzip2]
    `-- sys-libs/glibc-2.9_p20081201-r2
     `-- sys-devel/gettext-0.17 [nls]
      `-- virtual/libiconv-0 (virtual/libiconv)
[...]

注意如果设置了java USE,jre是一个直接依赖项,jdk是一个间接依赖项

列出包安装的文件:files (f)

equery使用files模块,可以列出ebuild安装的所有文件。尝试--tree以获得易于阅读的目录布局。使用--filter查找指定某种类型的文件。例如,要查找可执行文件的安装位置,请使用--filter=cmd,或者要快速查找配置文件位置,请尝试使用--filter=conf

user $equery files --tree gentoolkit
 * Searching for gentoolkit ...
 * Contents of app-portage/gentoolkit-0.3.0_rc7:
 /etc
   > /eclean
      + distfiles.exclude
      + packages.exclude
   > /env.d
      + 99gentoolkit-env
   > /revdep-rebuild
      + 99revdep-rebuild
 /usr
   > /bin
      + eclean
      + eclean-dist -> eclean
      + eclean-pkg -> eclean
      + epkginfo
      + equery
      + eread
      + euse
      + glsa-check
      + revdep-rebuild
   > /lib
      > /python2.6
         > /site-packages
            > /gentoolkit
            + gentoolkit-0.3.0_rc7-py2.6.egg-info
               + __init__.py
               > /equery
                  + __init__.py
                  + belongs.py
                  + changes.py
                  + check.py
                  + depends.py
                  + depgraph.py
                  + files.py
[...]

另一个例子,列出media-sound/ncmpcpp安装的所有文件:

user $equery f ncmpcpp
 * Searching for ncmpcpp ...
 * Contents of media-sound/ncmpcpp-0.5.10:
/usr
/usr/bin
/usr/bin/ncmpcpp
/usr/share
/usr/share/bash-completion
/usr/share/bash-completion/ncmpcpp
/usr/share/doc
/usr/share/doc/ncmpcpp-0.5.10
/usr/share/doc/ncmpcpp-0.5.10/AUTHORS.bz2
/usr/share/doc/ncmpcpp-0.5.10/NEWS.bz2
/usr/share/doc/ncmpcpp-0.5.10/config.bz2
/usr/share/doc/ncmpcpp-0.5.10/keys.bz2
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/ncmpcpp.1.bz2

其他模块和命令行参数的说明可以参看equery man page (man equery)。

寻找具有特定USE标志的包:hasuse (h)

hasuse可用于查找具有给定USE标志的包。hasuse不会指示标志是否已启用; 它只是输出一个具有查询标志作为选项的ebuild列表。有关获取此类信息的更多提示,请参阅equery手册页中的hasuse示例部分。

user $equery hasuse qt3 qt4
 * Searching for USE flag qt3 ...
[IP-] [  ] app-crypt/pinentry-0.7.5 (0)
[IP-] [  ] net-dns/avahi-0.6.24-r2 (0)
[IP-] [  ] net-wireless/wpa_supplicant-0.6.9 (0)
  
 * Searching for USE flag qt4 ...
[IP-] [  ] net-dns/avahi-0.6.24-r2 (0)
[IP-] [  ] net-wireless/wpa_supplicant-0.6.9 (0)

Display keywords for specified package (y)

keywords can be used to display the keyword status of a package on various architectures.

user $equery keywords coreutils
Keywords for sys-apps/coreutils:
          |                               |   u   |  
          | a   a     p s     l r   a     |   n   |  
          | m   r h   p p   i o i s l m m | e u s | r
          | d a m p p c a x a o s 3 p 6 i | a s l | e
          | 6 r 6 p p 6 r 8 6 n c 9 h 8 p | p e o | p
          | 4 m 4 a c 4 c 6 4 g v 0 a k s | i d t | o
----------+-------------------------------+-------+-------
  8.32-r1 | + + + + + + + + ~ o ~ ~ ~ ~ ~ | 7 # 0 | gentoo
   9.1-r1 | + + + + + + + + ~ ~ ~ ~ ~ ~ ~ | 7 #   | gentoo
[I]9.1-r2 | + + + + + + + + ~ ~ ~ ~ ~ ~ ~ | 7 o   | gentoo

+ indicates the package version is available on stable; ~ indicates its availability on testing; and o indicates the package version is unavailable. [I] indicates the package version currently installed; [M] indicates the package is masked.

列出包: list (l)

list是一个简单但功能强大的模块,用于列出Portage树或overlay中已安装的软件包。

Listing all installed packages

标准查询将通过给定包名称搜索已安装的包。传入'*'显示集合中的所有包。在最左边的字段中,可以看到所有上述包是I(nstalled)和P(ortage)树。它们未被屏蔽(第二个字段为空白),它们都安装在默认slot (0)中。

user $equery list '*'
 * Searching for * ...
[IP-] [  ] app-admin/eselect-1.2.3 (0)
[IP-] [  ] app-admin/eselect-ctags-1.10 (0)
[IP-] [  ] app-admin/eselect-esd-20060719 (0)
[IP-] [  ] app-admin/eselect-fontconfig-1.0 (0)
[IP-] [  ] app-admin/eselect-opengl-1.0.8-r1 (0)
[IP-] [  ] app-admin/eselect-python-20090824 (0)
[IP-] [  ] app-admin/eselect-ruby-20081227 (0)
[IP-] [  ] app-admin/eselect-vi-1.1.5 (0)
[IP-] [  ] app-admin/perl-cleaner-1.05 (0)
[IP-] [  ] app-admin/pessulus-2.24.0 (0)
[IP-] [  ] app-admin/python-updater-0.7 (0)
[IP-] [  ] app-admin/sudo-1.7.2_p1 (0)
[...]

In the leftmost field it is possible to see all the above packages are I(nstalled) and from the P(ortage) tree. They are not masked (the second field is blank), and they are all installed in the default slot (0).

Listing packages available in ebuild repositories

使用本地选项在Portage树和overlays中查找包。

user $equery list -po vim
 * Searching for vim ...
[-P-] [  ] app-editors/vim-7.0.235 (0)
[-P-] [ ~] app-editors/vim-7.0.243 (0)
[-P-] [  ] app-editors/vim-7.1.123 (0)
[-P-] [ ~] app-editors/vim-7.1.330 (0)
[-P-] [  ] app-editors/vim-7.2 (0)
[-P-] [ ~] app-editors/vim-7.2.108 (0)
[IP-] [  ] app-editors/vim-7.2.182 (0)
[-P-] [ ~] app-editors/vim-7.2.238 (0)
[-P-] [ ~] app-editors/vim-7.2.264 (0)

可以看到已安装版本7.2.182,并且overlay中没有可用的版本。用户可以通过第二字段中的关键字~查看哪些版本被屏蔽了。

提示
To only list available packages, excluding packages that are already installed, add the --exclude-installed (-I) option.

查看包元数据:meta (m)

Portage树中的每个包至少提供有关其维护者等的一些元数据(metadata)。有用信息的数量取决于软件包维护者决定如何提供。没有选项,meta返回一些基本的有用信息。

user $equery meta gnucash
 * app-office/gnucash [gentoo]
 Maintainer:  tove@gentoo.org (Torsten Veller)
 Upstream:    None specified
 Location:    /usr/portage/app-office/gnucash
 Keywords:    2.2.9-r1:0: alpha amd64 ppc sparc x86
 Keywords:    2.2.9-r2:0:
 Keywords:    2.3.8:0:
 Keywords:    2.3.10:0: ~alpha ~amd64 ~ppc ~sparc ~x86

一些维护者提供有关包的额外信息,这可能非常有用:

user $equery meta --description emacs
 * app-editors/emacs
  GNU Emacs is an extensible, customizable text editor - and more. At its core
  is an interpreter for Emacs Lisp, a dialect of the Lisp programming language
  with extensions to support text editing. The features of GNU Emacs include:
   * Content-sensitive editing modes, including syntax coloring, for a wide
     variety of file types including plain text, source code, and HTML.
   * Complete built-in documentation, including a tutorial for new users.
   * Support for many languages and their scripts, including all the European
     "Latin" scripts, Russian, Greek, Japanese, Chinese, Korean, Thai,
     Vietnamese, Lao, Ethiopian, and some Indian scripts.
   * Highly customizable, using Emacs Lisp code or a graphical customization
     interface.
   * A large number of extensions that add other functionality, including a
     project planner, mail and news reader, debugger interface, calendar, and
     more. Many of these extensions are distributed with GNU Emacs; others are
     available separately.

查看包大小:size (s)

曾经很想知道特定包装占用多少空间?由于包可以将文件放在多个目录中,因此通常的du -hc命令可能无法给出正确的数字。不要担心,equery可以实现!

user $equery size openoffice-bin
 * app-office/openoffice-bin-3.1.1
         Total files : 4624
         Total size  : 361.38 MiB

使用size选项以使用人类易读的单位来打印所使用的总空间,并列出程序包具有的文件总数。要以字节为单位获取总大小,请使用--bytes

列出每个包的USE标志:uses (u)

equeryuses模块可以提供有关特定包可用的USE标志以及当前启用了哪些标志的信息。

user $equery uses gst-plugins-meta
 * Searching for gst-plugins-meta ...
[ Legend : U - flag is set in make.conf       ]
[        : I - package is installed with flag ]
[ Colors : set, unset                         ]
 * Found these USE flags for media-plugins/gst-plugins-meta-0.10-r2:
 U I
 + + X      : Adds support for X11
 - - a52    : Enables support for decoding ATSC A/52 streams used in DVD
 + + alsa   : Adds support for media-libs/alsa-lib (Advanced Linux Sound
              Architecture)
 - - dvb    : Adds support for DVB (Digital Video Broadcasting)
 + + dvd    : Adds support for DVDs
 + + esd    : Adds support for media-sound/esound (Enlightened Sound Daemon)
 + + ffmpeg : Enable ffmpeg-based audio/video codec support
 + + flac   : Adds support for FLAC: Free Lossless Audio Codec
 - - mad    : Adds support for mad (high-quality mp3 decoder library and cli
              frontend)
 + + mpeg   : Adds libmpeg3 support to various packages
 - - mythtv : Support for retrieval from media-tv/mythtv backend
 + + ogg    : Adds support for the Ogg container format (commonly used by
              Vorbis, Theora and flac)
 - - oss    : Adds support for OSS (Open Sound System)
 + + theora : Adds support for the Theora Video Compression Codec
 + + vorbis : Adds support for the OggVorbis audio codec
 - - xv     : Adds in optional support for the Xvideo extension (an X API for
              video playback)

这里在gstreamer的插件meta-package中启用了许多USE标志,但可以看出还有其他可用的USE标志。有关USE标志的更多信息,请参阅Gentoo HandbookUSE Flags章节。

找到ebuild路径:which (w)

which是一个简单的脚本,可帮助用户快速找到ebuild的文件路径。如果使用which传递未版本化的包名称,它将返回最新的可安装ebuild版本的路径。换句话说,如果键入emerge example/package,它将返回Portage将使用的ebuild。which还接受版本化程序包以获取该ebuild的路径。

user $equery which gnome
/usr/portage/gnome-base/gnome/gnome-2.26.3.ebuild

最后,如果equery的上述功能都没有提供答案,请尝试使用which通过cat,less或grep等程序手动搜索ebuild:

user $grep HOMEPAGE $(equery which gentoolkit)
HOMEPAGE="http://www.gentoo.org/proj/en/portage/tools/index.xml"
警告
请注意,如果通过管道发送,equery当前会更改输出的格式。管道格式旨在通过工具更容易解析,但可以通过添加 --no-pipe选项来关闭它。编写使用equery的脚本时,请注意此行为。

Summary table

Parameter "equery -" Description
u show USE-flags of package
d dependencies
g dependency graph
b package origin of specific file
s size
w path

另请参阅

  • q applets - 用C编写的小而快的Portage辅助工具集。
  • eix - 一组通过二进制缓存搜索和区分,本地Portage树和overlays的实用程序。
  • Gentoolkit - 一套可以简化Gentoo系统管理的工具。