Fah*_*tha 13 debian package-management alternatives
Debian 发行版有Debian Alternatives System。来自维基:
Debian 替代系统为实现相同或相似功能的多个程序创建了一种方法,这些程序将被列为同时安装的替代实现,但其中一个特定实现被指定为默认实现。例如,许多系统同时安装了多个文本编辑器。vi 程序是一个经典的编辑器示例,它有许多实现,例如 nvi、elvis、vim 等,但是应该指定哪一个作为默认?
通常,Debian 中有多个软件包提供了特定的替代方案。如何获得 Debian 存储库中存在的所有此类软件包的完整列表?让我们以 vi 替代品为例。
注意:对已安装的软件包列表进行这样的查询很容易,但这不是这个问题所要问的。
小智 9
我知道这有点晚了,但这篇文章目前是与在 Debian 中寻找替代品相关的热门搜索之一。
在update-alternatives
这里使用的问题是,它只会向您显示已安装的选项,据我所知(它的手册页非常稀疏)。
要回答标题中提出的问题,即查找提供替代方案(无论是否安装)的所有可用软件包,您可以使用:
aptitude search '?provides(pattern)'
Run Code Online (Sandbox Code Playgroud)
也可以缩写为:
aptitude search '~Ppattern'
Run Code Online (Sandbox Code Playgroud)
pattern
您正在寻找的替代方案的全部或部分在哪里。在 的特定情况下vi
,这实际上不起作用。如果您检查软件包nvi
并vim
使用aptitude show
或apt-cache show
,您将看到没有一个在其“提供:”部分中列出“vi”。实际上,nvi 的描述完全缺少该部分。
但是,它对于其他替代方案的效果相当好,例如editor
:
$ aptitude search '~Peditor'
p deutex - composition tool for doom-style WAD files
p edbrowse - /bin/ed-alike webbrowser written in C
p emacs24 - GNU Emacs editor (with GTK+ GUI support)
p emacs24-lucid - GNU Emacs editor (with Lucid GUI support)
p emacs24-nox - GNU Emacs editor (without GUI support)
p fte-console - Text editor for programmers - console edi
p fte-terminal - Text editor for programmers - version for
p fte-xwindow - Text editor for programmers - X Window Sy
p jed - editor for programmers (textmode version)
p jove - Jonathan's Own Version of Emacs - a compa
p jupp - user friendly full screen text editor
p le - Text editor with block and binary operati
p ledit - line editor for interactive programs
p levee - very small vi clone
p mg - microscopic GNU Emacs-style editor
p nano - small, friendly text editor inspired by P
p nano-tiny - small, friendly text editor inspired by P
p ne - easy-to-use and powerful text editor
p pluma - official text editor of the MATE desktop
p rlfe - Front-end using readline to "cook" input
p rlwrap - readline feature command line wrapper
p scite - Lightweight GTK-based Programming Editor
p vigor - nvi with the evil paperclip
p vile - VI Like Emacs - vi work-alike
p vim - Vi IMproved - enhanced vi editor
p vim-athena - Vi IMproved - enhanced vi editor - with A
p vim-gnome - Vi IMproved - enhanced vi editor - with G
i vim-gtk - Vi IMproved - enhanced vi editor - with G
p vim-nox - Vi IMproved - enhanced vi editor - with s
i vim-tiny - Vi IMproved - enhanced vi editor - compac
p xjed - editor for programmers (x11 version)
p xul-ext-password-editor - edit password manager entries in Mozilla
p xvile - VI Like Emacs - vi work-alike (X11)
Run Code Online (Sandbox Code Playgroud)
尽管这并不完美,但aptitude
具有非常灵活的搜索功能,通常可以让您解决软件包未正确列出它们提供的替代方案的问题 - 例如,"~seditors ~dvi\s"
用作搜索模式将列出“编辑器”部分中的所有软件包描述包含字符串“vi”。
另一种选择是使用Debian 的软件包网站,右侧的部分中列出了类似的软件包。
这取决于。有一些替代方案,例如 x-www-browser,不使用包,而是通过维护者脚本添加到更新替代方案中:
/var/lib/dpkg/info/iceweasel.postinst: update-alternatives --install /usr/bin/x-www-browser \
/var/lib/dpkg/info/iceweasel.postinst: update-alternatives --remove mozilla /usr/bin/iceweasel
/var/lib/dpkg/info/iceweasel.postinst: update-alternatives --install /usr/bin/gnome-www-browser \
/var/lib/dpkg/info/iceweasel.prerm: update-alternatives --remove x-www-browser /usr/bin/iceweasel
/var/lib/dpkg/info/iceweasel.prerm: update-alternatives --remove gnome-www-browser /usr/bin/iceweasel
/var/lib/dpkg/info/chromium.postinst: update-alternatives --install /usr/bin/x-www-browser \
/var/lib/dpkg/info/chromium.postinst: update-alternatives --install /usr/bin/gnome-www-browser \
/var/lib/dpkg/info/chromium.prerm: update-alternatives --remove x-www-browser /usr/bin/chromium
/var/lib/dpkg/info/chromium.prerm: update-alternatives --remove gnome-www-browser /usr/bin/chromium
Run Code Online (Sandbox Code Playgroud)
还有其他人使用单个元包来安装相同二进制文件的任何版本(Java/OpenJRE 包也出现在脑海中init
)。其他人使用虚拟包,通过填写“提供”(这通常伴随着对替代 DPKG 数据库的更新),在这种情况下,这些包中的任何一个都应该提供相同的二进制文件。
那么,如何找到提供特定文件的所有包呢?如果你知道一个包,我会使用提供,以及apt-file search file
其他一切。
虚拟软件包和Debian 替代系统(这是二进制文件发挥作用的地方)相关但不相同。对于虚拟包,您可以使用apt-cache
来查找哪些(真实)包“提供”它:
$ apt-cache showpkg awk
Package: awk
Versions:
Reverse Depends:
base-files,awk
base-files,awk
Dependencies:
Provides:
Reverse Provides:
mawk:i386 1.3.3-17ubuntu2
gawk:i386 1:4.0.1+dfsg-2.1ubuntu2
original-awk 2012-12-20-1
mawk 1.3.3-17ubuntu2
gawk 1:4.0.1+dfsg-2.1ubuntu2
Run Code Online (Sandbox Code Playgroud)
对于显示管理器,虚拟包是x-display-manager
:
$ apt-cache showpkg x-display-manager
Package: x-display-manager
Versions:
Reverse Depends:
utf8-migration-tool,x-display-manager
razorqt,x-display-manager
lxde,x-display-manager
numlockx,x-display-manager
ltsp-client-core,x-display-manager
Dependencies:
Provides:
Reverse Provides:
gdm 3.10.0.1-0ubuntu3.1
lightdm 1.10.6-0ubuntu1
kdm 4:4.11.11-0ubuntu0.2
xdm 1:1.1.11-1ubuntu1
wdm 1.28-16
slim 1.3.4-2.1
lxdm 0.4.1-0ubuntu6
kdm 4:4.11.8-0ubuntu6
gdm 3.10.0.1-0ubuntu3
lightdm 1.10.0-0ubuntu3
Run Code Online (Sandbox Code Playgroud)
update-alternatives
正如 Braiam 的回答所示,替代系统由维护者脚本中的调用处理,而打包系统的其余部分完全不知道这些。该Provides
领域也比替代品更通用,因为一个包可能会在提供的服务或库方面提供另一个,而不仅仅是通过二进制文件。
如果没有包维护者添加有关该Provides
领域的替代方案的信息(并为替代方案的所有端点创建虚拟包 - 如vi
)并且没有检查包本身,目前没有通用的方法来确定哪个包可能提供替代方案。
小智 3
与问题严格相关,找到vi替代方案:
update-alternatives --list editor
Run Code Online (Sandbox Code Playgroud)
输出:
/bin/ed
/bin/nano
/usr/bin/mcedit
/usr/bin/vim.basic
/usr/bin/vim.tiny
Run Code Online (Sandbox Code Playgroud)
或者:
update-alternatives --config vi
Run Code Online (Sandbox Code Playgroud)
输出:
There are 2 choices for the alternative vi (providing /usr/bin/vi).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/vim.basic 30 auto mode
1 /usr/bin/vim.basic 30 manual mode
2 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number:
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1200 次 |
最近记录: |