mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
368 lines
17 KiB
Markdown
368 lines
17 KiB
Markdown
我们如何得知安装的包来自哪个仓库?
|
||
==========
|
||
|
||
有时候你可能想知道安装的软件包来自于哪个仓库。这将帮助你在遇到包冲突问题时进行故障排除。
|
||
|
||
因为[第三方仓库][1]拥有最新版本的软件包,所以有时候当你试图安装一些包的时候会出现兼容性的问题。
|
||
|
||
在 Linux 上一切都是可能的,因为你可以安装一个即使在你的发行版系统上不能使用的包。
|
||
|
||
你也可以安装一个最新版本的包,即使你的发行版系统仓库还没有这个版本,怎么做到的呢?
|
||
|
||
这就是为什么出现了第三方仓库。它们允许用户从库中安装所有可用的包。
|
||
|
||
几乎所有的发行版系统都允许第三方软件库。一些发行版还会官方推荐一些不会取代基础仓库的第三方仓库,例如 CentOS 官方推荐安装 [EPEL 库][2]。
|
||
|
||
下面是常用的仓库列表和它们的详细信息。
|
||
|
||
* CentOS: [EPEL][2]、[ELRepo][3] 等是 [Centos 社区认证仓库](4)。
|
||
* Fedora: [RPMfusion 仓库][5] 是经常被很多 [Fedora][6] 用户使用的仓库。
|
||
* ArchLinux: ArchLinux 社区仓库包含了来自于 Arch 用户仓库的可信用户审核通过的软件包。
|
||
* openSUSE: [Packman 仓库][7] 为 openSUSE 提供了各种附加的软件包,特别是但不限于那些在 openSUSE Build Service 应用黑名单上的与多媒体相关的应用和库。它是 openSUSE 软件包的最大外部软件库。
|
||
* Ubuntu:个人软件包归档(PPA)是一种软件仓库。开发者们可以创建这种仓库来分发他们的软件。你可以在 PPA 导航页面找到相关信息。同时,你也可以启用 Cananical 合作伙伴软件仓库。
|
||
|
||
### 仓库是什么?
|
||
|
||
软件仓库是存储特定的应用程序的软件包的集中场所。
|
||
|
||
所有的 Linux 发行版都在维护他们自己的仓库,并允许用户在他们的机器上获取和安装包。
|
||
|
||
每个厂商都提供了各自的包管理工具来管理它们的仓库,例如搜索、安装、更新、升级、删除等等。
|
||
|
||
除了 RHEL 和 SUSE 以外大部分 Linux 发行版都是自由软件。要访问付费的仓库,你需要购买其订阅服务。
|
||
|
||
### 为什么我们需要启用第三方仓库?
|
||
|
||
在 Linux 里,并不建议从源代码安装包,因为这样做可能会在升级软件和系统的时候产生很多问题,这也是为什么我们建议从库中安装包而不是从源代码安装。
|
||
|
||
### 在 RHEL/CentOS 系统上我们如何得知安装的软件包来自哪个仓库?
|
||
|
||
这可以通过很多方法实现。我们会给你所有可能的选择,你可以选择一个对你来说最合适的。
|
||
|
||
#### 方法-1:使用 yum 命令
|
||
|
||
RHEL 和 CentOS 系统使用 RPM 包,因此我们能够使用 [Yum 包管理器][8] 来获得信息。
|
||
|
||
YUM 即 “Yellodog Updater, Modified” 是适用于基于 RPM 的系统例如 RHEL 和 CentOS 的一个开源命令行前端包管理工具。
|
||
|
||
`yum` 是从发行版仓库和其他第三方库中获取、安装、删除、查询和管理 RPM 包的一个主要工具。
|
||
|
||
```
|
||
# yum info apachetop
|
||
Loaded plugins: fastestmirror
|
||
Loading mirror speeds from cached hostfile
|
||
* epel: epel.mirror.constant.com
|
||
Installed Packages
|
||
Name : apachetop
|
||
Arch : x86_64
|
||
Version : 0.15.6
|
||
Release : 1.el7
|
||
Size : 65 k
|
||
Repo : installed
|
||
From repo : epel
|
||
Summary : A top-like display of Apache logs
|
||
URL : https://github.com/tessus/apachetop
|
||
License : BSD
|
||
Description : ApacheTop watches a logfile generated by Apache (in standard common or
|
||
: combined logformat, although it doesn't (yet) make use of any of the extra
|
||
: fields in combined) and generates human-parsable output in realtime.
|
||
```
|
||
|
||
`apachetop` 包来自 EPEL 仓库。
|
||
|
||
#### 方法-2:使用 yumdb 命令
|
||
|
||
`yumdb info` 提供了类似于 `yum info` 的信息但是它又提供了包校验和数据、类型、用户信息(谁安装的软件包)。从 yum 3.2.26 开始,yum 已经开始在 rpmdatabase 之外存储额外的信息(user 表示软件是用户安装的,dep 表示它是作为依赖项引入的)。
|
||
|
||
```
|
||
# yumdb info lighttpd
|
||
Loaded plugins: fastestmirror
|
||
lighttpd-1.4.50-1.el7.x86_64
|
||
checksum_data = a24d18102ed40148cfcc965310a516050ed437d728eeeefb23709486783a4d37
|
||
checksum_type = sha256
|
||
command_line = --enablerepo=epel install lighttpd apachetop aria2 atop axel
|
||
from_repo = epel
|
||
from_repo_revision = 1540756729
|
||
from_repo_timestamp = 1540757483
|
||
installed_by = 0
|
||
origin_url = https://epel.mirror.constant.com/7/x86_64/Packages/l/lighttpd-1.4.50-1.el7.x86_64.rpm
|
||
reason = user
|
||
releasever = 7
|
||
var_contentdir = centos
|
||
var_infra = stock
|
||
var_uuid = ce328b07-9c0a-4765-b2ad-59d96a257dc8
|
||
```
|
||
|
||
`lighttpd` 包来自 EPEL 仓库。
|
||
|
||
#### 方法-3:使用 rpm 命令
|
||
|
||
[RPM 命令][9] 即 “Red Hat Package Manager” 是一个适用于基于 Red Hat 的系统(例如 RHEL、CentOS、Fedora、openSUSE & Mageia)的强大的命令行包管理工具。
|
||
|
||
这个工具允许你在你的 Linux 系统/服务器上安装、更新、移除、查询和验证软件。RPM 文件具有 .rpm 后缀名。RPM 包是用必需的库和依赖关系构建的,不会与系统上安装的其他包冲突。
|
||
|
||
```
|
||
# rpm -qi apachetop
|
||
Name : apachetop
|
||
Version : 0.15.6
|
||
Release : 1.el7
|
||
Architecture: x86_64
|
||
Install Date: Mon 29 Oct 2018 06:47:49 AM EDT
|
||
Group : Applications/Internet
|
||
Size : 67020
|
||
License : BSD
|
||
Signature : RSA/SHA256, Mon 22 Jun 2015 09:30:26 AM EDT, Key ID 6a2faea2352c64e5
|
||
Source RPM : apachetop-0.15.6-1.el7.src.rpm
|
||
Build Date : Sat 20 Jun 2015 09:02:37 PM EDT
|
||
Build Host : buildvm-22.phx2.fedoraproject.org
|
||
Relocations : (not relocatable)
|
||
Packager : Fedora Project
|
||
Vendor : Fedora Project
|
||
URL : https://github.com/tessus/apachetop
|
||
Summary : A top-like display of Apache logs
|
||
Description :
|
||
ApacheTop watches a logfile generated by Apache (in standard common or
|
||
combined logformat, although it doesn't (yet) make use of any of the extra
|
||
fields in combined) and generates human-parsable output in realtime.
|
||
```
|
||
|
||
`apachetop` 包来自 EPEL 仓库。
|
||
|
||
#### 方法-4:使用 repoquery 命令
|
||
|
||
`repoquery` 是一个从 YUM 库查询信息的程序,类似于 rpm 查询。
|
||
|
||
```
|
||
# repoquery -i httpd
|
||
|
||
Name : httpd
|
||
Version : 2.4.6
|
||
Release : 80.el7.centos.1
|
||
Architecture: x86_64
|
||
Size : 9817285
|
||
Packager : CentOS BuildSystem
|
||
Group : System Environment/Daemons
|
||
URL : http://httpd.apache.org/
|
||
Repository : updates
|
||
Summary : Apache HTTP Server
|
||
Source : httpd-2.4.6-80.el7.centos.1.src.rpm
|
||
Description :
|
||
The Apache HTTP Server is a powerful, efficient, and extensible
|
||
web server.
|
||
```
|
||
|
||
`httpd` 包来自 CentOS updates 仓库。
|
||
|
||
### 在 Fedora 系统上我们如何得知安装的包来自哪个仓库?
|
||
|
||
DNF 是 “Dandified yum” 的缩写。DNF 是使用 hawkey/libsolv 库作为后端的下一代 yum 包管理器(yum 的分支)。从 Fedora 18 开始 Aleš Kozumplík 开始开发 DNF,并最终在 Fedora 22 上得以应用/启用。
|
||
|
||
[dnf 命令][10] 用于在 Fedora 22 以及之后的系统上安装、更新、搜索和删除包。它会自动解决依赖并使安装包的过程变得顺畅,不会出现任何问题。
|
||
|
||
```
|
||
$ dnf info tilix
|
||
Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST.
|
||
Installed Packages
|
||
Name : tilix
|
||
Version : 1.6.4
|
||
Release : 1.fc26
|
||
Arch : x86_64
|
||
Size : 3.6 M
|
||
Source : tilix-1.6.4-1.fc26.src.rpm
|
||
Repo : @System
|
||
From repo : updates
|
||
Summary : Tiling terminal emulator
|
||
URL : https://github.com/gnunn1/tilix
|
||
License : MPLv2.0 and GPLv3+ and CC-BY-SA
|
||
Description : Tilix is a tiling terminal emulator with the following features:
|
||
:
|
||
: - Layout terminals in any fashion by splitting them horizontally or vertically
|
||
: - Terminals can be re-arranged using drag and drop both within and between
|
||
: windows
|
||
: - Terminals can be detached into a new window via drag and drop
|
||
: - Input can be synchronized between terminals so commands typed in one
|
||
: terminal are replicated to the others
|
||
: - The grouping of terminals can be saved and loaded from disk
|
||
: - Terminals support custom titles
|
||
: - Color schemes are stored in files and custom color schemes can be created by
|
||
: simply creating a new file
|
||
: - Transparent background
|
||
: - Supports notifications when processes are completed out of view
|
||
:
|
||
: The application was written using GTK 3 and an effort was made to conform to
|
||
: GNOME Human Interface Guidelines (HIG).
|
||
```
|
||
|
||
`tilix` 包来自 Fedora updates 仓库。
|
||
|
||
### 在 openSUSE 系统上我们如何得知安装的包来自哪个仓库?
|
||
|
||
Zypper 是一个使用 libzypp 的命令行包管理器。[Zypper 命令][11] 提供了存储库访问、依赖处理、包安装等功能。
|
||
|
||
```
|
||
$ zypper info nano
|
||
|
||
Loading repository data...
|
||
Reading installed packages...
|
||
|
||
|
||
Information for package nano:
|
||
-----------------------------
|
||
Repository : Main Repository (OSS)
|
||
Name : nano
|
||
Version : 2.4.2-5.3
|
||
Arch : x86_64
|
||
Vendor : openSUSE
|
||
Installed Size : 1017.8 KiB
|
||
Installed : No
|
||
Status : not installed
|
||
Source package : nano-2.4.2-5.3.src
|
||
Summary : Pico editor clone with enhancements
|
||
Description :
|
||
GNU nano is a small and friendly text editor. It aims to emulate
|
||
the Pico text editor while also offering a few enhancements.
|
||
```
|
||
|
||
`nano` 包来自于 openSUSE Main 仓库(OSS)。
|
||
|
||
### 在 ArchLinux 系统上我们如何得知安装的包来自哪个仓库?
|
||
|
||
[Pacman 命令][12] 即包管理器工具(package manager utility ),是一个简单的用来安装、构建、删除和管理 Arch Linux 软件包的命令行工具。Pacman 使用 libalpm 作为后端来执行所有的操作。
|
||
|
||
```
|
||
# pacman -Ss chromium
|
||
extra/chromium 48.0.2564.116-1
|
||
The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser
|
||
extra/qt5-webengine 5.5.1-9 (qt qt5)
|
||
Provides support for web applications using the Chromium browser project
|
||
community/chromium-bsu 0.9.15.1-2
|
||
A fast paced top scrolling shooter
|
||
community/chromium-chromevox latest-1
|
||
Causes the Chromium web browser to automatically install and update the ChromeVox screen reader extention. Note: This
|
||
package does not contain the extension code.
|
||
community/fcitx-mozc 2.17.2313.102-1
|
||
Fcitx Module of A Japanese Input Method for Chromium OS, Windows, Mac and Linux (the Open Source Edition of Google Japanese
|
||
Input)
|
||
```
|
||
|
||
`chromium` 包来自 ArchLinux extra 仓库。
|
||
|
||
或者,我们可以使用以下选项获得关于包的详细信息。
|
||
|
||
```
|
||
# pacman -Si chromium
|
||
Repository : extra
|
||
Name : chromium
|
||
Version : 48.0.2564.116-1
|
||
Description : The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser
|
||
Architecture : x86_64
|
||
URL : http://www.chromium.org/
|
||
Licenses : BSD
|
||
Groups : None
|
||
Provides : None
|
||
Depends On : gtk2 nss alsa-lib xdg-utils bzip2 libevent libxss icu libexif libgcrypt ttf-font systemd dbus
|
||
flac snappy speech-dispatcher pciutils libpulse harfbuzz libsecret libvpx perl perl-file-basedir
|
||
desktop-file-utils hicolor-icon-theme
|
||
Optional Deps : kdebase-kdialog: needed for file dialogs in KDE
|
||
gnome-keyring: for storing passwords in GNOME keyring
|
||
kwallet: for storing passwords in KWallet
|
||
Conflicts With : None
|
||
Replaces : None
|
||
Download Size : 44.42 MiB
|
||
Installed Size : 172.44 MiB
|
||
Packager : Evangelos Foutras
|
||
Build Date : Fri 19 Feb 2016 04:17:12 AM IST
|
||
Validated By : MD5 Sum SHA-256 Sum Signature
|
||
```
|
||
|
||
`chromium` 包来自 ArchLinux extra 仓库。
|
||
|
||
### 在基于 Debian 的系统上我们如何得知安装的包来自哪个仓库?
|
||
|
||
在基于 Debian 的系统例如 Ubuntu、LinuxMint 上可以使用两种方法实现。
|
||
|
||
#### 方法-1:使用 apt-cache 命令
|
||
|
||
[apt-cache 命令][13] 可以显示存储在 APT 内部数据库的很多信息。这些信息是一种缓存,因为它们是从列在 `source.list` 文件里的不同的源中获得的。这个过程发生在 apt 更新操作期间。
|
||
|
||
```
|
||
$ apt-cache policy python3
|
||
python3:
|
||
Installed: 3.6.3-0ubuntu2
|
||
Candidate: 3.6.3-0ubuntu3
|
||
Version table:
|
||
3.6.3-0ubuntu3 500
|
||
500 http://in.archive.ubuntu.com/ubuntu artful-updates/main amd64 Packages
|
||
*** 3.6.3-0ubuntu2 500
|
||
500 http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages
|
||
100 /var/lib/dpkg/status
|
||
```
|
||
|
||
`python3` 包来自 Ubuntu updates 仓库。
|
||
|
||
#### 方法-2:使用 apt 命令
|
||
|
||
[APT 命令][14] 即 “Advanced Packaging Tool”,是 `apt-get` 命令的替代品,就像 DNF 是如何取代 YUM 一样。它是具有丰富功能的命令行工具并将所有的功能例如 `apt-cache`、`apt-search`、`dpkg`、`apt-cdrom`、`apt-config`、`apt-ket` 等包含在一个命令(APT)中,并且还有几个独特的功能。例如我们可以通过 APT 轻松安装 .dpkg 包,但我们不能使用 `apt-get` 命令安装,更多类似的功能都被包含进了 APT 命令。`apt-get` 因缺失了很多未被解决的特性而被 `apt` 取代。
|
||
|
||
```
|
||
$ apt -a show notepadqq
|
||
Package: notepadqq
|
||
Version: 1.3.2-1~artful1
|
||
Priority: optional
|
||
Section: editors
|
||
Maintainer: Daniele Di Sarli
|
||
Installed-Size: 1,352 kB
|
||
Depends: notepadqq-common (= 1.3.2-1~artful1), coreutils (>= 8.20), libqt5svg5 (>= 5.2.1), libc6 (>= 2.14), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.9.0~beta), libqt5gui5 (>= 5.7.0), libqt5network5 (>= 5.2.1), libqt5printsupport5 (>= 5.2.1), libqt5webkit5 (>= 5.6.0~rc), libqt5widgets5 (>= 5.2.1), libstdc++6 (>= 5.2)
|
||
Download-Size: 356 kB
|
||
APT-Sources: http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful/main amd64 Packages
|
||
Description: Notepad++-like editor for Linux
|
||
Text editor with support for multiple programming
|
||
languages, multiple encodings and plugin support.
|
||
|
||
Package: notepadqq
|
||
Version: 1.2.0-1~artful1
|
||
Status: install ok installed
|
||
Priority: optional
|
||
Section: editors
|
||
Maintainer: Daniele Di Sarli
|
||
Installed-Size: 1,352 kB
|
||
Depends: notepadqq-common (= 1.2.0-1~artful1), coreutils (>= 8.20), libqt5svg5 (>= 5.2.1), libc6 (>= 2.14), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.9.0~beta), libqt5gui5 (>= 5.7.0), libqt5network5 (>= 5.2.1), libqt5printsupport5 (>= 5.2.1), libqt5webkit5 (>= 5.6.0~rc), libqt5widgets5 (>= 5.2.1), libstdc++6 (>= 5.2)
|
||
Homepage: http://notepadqq.altervista.org
|
||
Download-Size: unknown
|
||
APT-Manual-Installed: yes
|
||
APT-Sources: /var/lib/dpkg/status
|
||
Description: Notepad++-like editor for Linux
|
||
Text editor with support for multiple programming
|
||
languages, multiple encodings and plugin support.
|
||
```
|
||
|
||
`notepadqq` 包来自 Launchpad PPA。
|
||
|
||
--------------------------------------------------------------------------------
|
||
|
||
via: https://www.2daygeek.com/how-do-we-find-out-the-installed-packages-came-from-which-repository/
|
||
|
||
作者:[Prakash Subramanian][a]
|
||
选题:[lujun9972][b]
|
||
译者:[zianglei](https://github.com/zianglei)
|
||
校对:[wxy](https://github.com/wxy)
|
||
|
||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||
|
||
[a]: https://www.2daygeek.com/author/prakash/
|
||
[b]: https://github.com/lujun9972
|
||
[1]: https://www.2daygeek.com/category/repository/
|
||
[2]: https://www.2daygeek.com/install-enable-epel-repository-on-rhel-centos-scientific-linux-oracle-linux/
|
||
[3]: https://www.2daygeek.com/install-enable-elrepo-on-rhel-centos-scientific-linux/
|
||
[4]: https://www.2daygeek.com/additional-yum-repositories-for-centos-rhel-fedora-systems/
|
||
[5]: https://www.2daygeek.com/install-enable-rpm-fusion-repository-on-centos-fedora-rhel/
|
||
[6]: https://fedoraproject.org/wiki/Third_party_repositories
|
||
[7]: https://www.2daygeek.com/install-enable-packman-repository-on-opensuse-leap/
|
||
[8]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
|
||
[9]: https://www.2daygeek.com/rpm-command-examples/
|
||
[10]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
|
||
[11]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
|
||
[12]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/
|
||
[13]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
|
||
[14]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
|