分享

我们如何得知安装的包来自哪个仓库? | Linux 中国

 昵称60727945 2018-11-29
有时候你可能想知道安装的软件包来自于哪个仓库。这将帮助你在遇到包冲突问题时进行故障排除。
-- Prakash Subramanian



致谢
编译自 | 
https://www./how-do-we-find-out-the-installed-packages-came-from-which-repository/
 
 作者 | Prakash Subramanian
 译者 | zianglei 🌟🌟共计翻译:3.0 篇 贡献时间:20 天

有时候你可能想知道安装的软件包来自于哪个仓库。这将帮助你在遇到包冲突问题时进行故障排除。因为第三方仓库[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 包的一个主要工具。

  1. # yum info apachetop

  2. Loaded plugins: fastestmirror

  3. Loading mirror speeds from cached hostfile

  4. * epel: epel.mirror.constant.com

  5. Installed Packages

  6. Name        : apachetop

  7. Arch        : x86_64

  8. Version     : 0.15.6

  9. Release     : 1.el7

  10. Size        : 65 k

  11. Repo        : installed

  12. From repo   : epel

  13. Summary     : A top-like display of Apache logs

  14. URL         : https://github.com/tessus/apachetop

  15. License     : BSD

  16. Description : ApacheTop watches a logfile generated by Apache (in standard common or

  17.            : combined logformat, although it doesn't (yet) make use of any of the extra

  18.            : 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 表示它是作为依赖项引入的)。

  1. # yumdb info lighttpd

  2. Loaded plugins: fastestmirror

  3. lighttpd-1.4.50-1.el7.x86_64

  4.     checksum_data = a24d18102ed40148cfcc965310a516050ed437d728eeeefb23709486783a4d37

  5.     checksum_type = sha256

  6.     command_line = --enablerepo=epel install lighttpd apachetop aria2 atop axel

  7.     from_repo = epel

  8.     from_repo_revision = 1540756729

  9.     from_repo_timestamp = 1540757483

  10.     installed_by = 0

  11.     origin_url = https://epel.mirror.constant.com/7/x86_64/Packages/l/lighttpd-1.4.50-1.el7.x86_64.rpm

  12.     reason = user

  13.     releasever = 7

  14.     var_contentdir = centos

  15.     var_infra = stock

  16.     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 包是用必需的库和依赖关系构建的,不会与系统上安装的其他包冲突。

  1. # rpm -qi apachetop

  2. Name        : apachetop

  3. Version     : 0.15.6

  4. Release     : 1.el7

  5. Architecture: x86_64

  6. Install Date: Mon 29 Oct 2018 06:47:49 AM EDT

  7. Group       : Applications/Internet

  8. Size        : 67020

  9. License     : BSD

  10. Signature   : RSA/SHA256, Mon 22 Jun 2015 09:30:26 AM EDT, Key ID 6a2faea2352c64e5

  11. Source RPM  : apachetop-0.15.6-1.el7.src.rpm

  12. Build Date  : Sat 20 Jun 2015 09:02:37 PM EDT

  13. Build Host  : buildvm-22.phx2.fedoraproject.org

  14. Relocations : (not relocatable)

  15. Packager    : Fedora Project

  16. Vendor      : Fedora Project

  17. URL         : https://github.com/tessus/apachetop

  18. Summary     : A top-like display of Apache logs

  19. Description :

  20. ApacheTop watches a logfile generated by Apache (in standard common or

  21. combined logformat, although it doesn't (yet) make use of any of the extra

  22. fields in combined) and generates human-parsable output in realtime.

apachetop 包来自 EPEL 仓库。

方法-4:使用 repoquery 命令

repoquery 是一个从 YUM 库查询信息的程序,类似于 rpm 查询。

  1. # repoquery -i httpd

  2. Name        : httpd

  3. Version     : 2.4.6

  4. Release     : 80.el7.centos.1

  5. Architecture: x86_64

  6. Size        : 9817285

  7. Packager    : CentOS BuildSystem

  8. Group       : System Environment/Daemons

  9. URL         : http://httpd.apache.org/

  10. Repository  : updates

  11. Summary     : Apache HTTP Server

  12. Source      : httpd-2.4.6-80.el7.centos.1.src.rpm

  13. Description :

  14. The Apache HTTP Server is a powerful, efficient, and extensible

  15. 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 以及之后的系统上安装、更新、搜索和删除包。它会自动解决依赖并使安装包的过程变得顺畅,不会出现任何问题。

  1. $ dnf info tilix

  2. Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST.

  3. Installed Packages

  4. Name         : tilix

  5. Version      : 1.6.4

  6. Release      : 1.fc26

  7. Arch         : x86_64

  8. Size         : 3.6 M

  9. Source       : tilix-1.6.4-1.fc26.src.rpm

  10. Repo         : @System

  11. From repo    : updates

  12. Summary      : Tiling terminal emulator

  13. URL          : https://github.com/gnunn1/tilix

  14. License      : MPLv2.0 and GPLv3+ and CC-BY-SA

  15. Description  : Tilix is a tiling terminal emulator with the following features:

  16.             :

  17.             :  - Layout terminals in any fashion by splitting them horizontally or vertically

  18.             :  - Terminals can be re-arranged using drag and drop both within and between

  19.             :    windows

  20.             :  - Terminals can be detached into a new window via drag and drop

  21.             :  - Input can be synchronized between terminals so commands typed in one

  22.             :    terminal are replicated to the others

  23.             :  - The grouping of terminals can be saved and loaded from disk

  24.             :  - Terminals support custom titles

  25.             :  - Color schemes are stored in files and custom color schemes can be created by

  26.             :    simply creating a new file

  27.             :  - Transparent background

  28.             :  - Supports notifications when processes are completed out of view

  29.             :

  30.             : The application was written using GTK 3 and an effort was made to conform to

  31.             : GNOME Human Interface Guidelines (HIG).

tilix 包来自 Fedora updates 仓库。

在 openSUSE 系统上我们如何得知安装的包来自哪个仓库?

Zypper 是一个使用 libzypp 的命令行包管理器。Zypper 命令[11] 提供了存储库访问、依赖处理、包安装等功能。

  1. $ zypper info nano

  2. Loading repository data...

  3. Reading installed packages...

  4. Information for package nano:

  5. -----------------------------

  6. Repository     : Main Repository (OSS)            

  7. Name           : nano                              

  8. Version        : 2.4.2-5.3                          

  9. Arch           : x86_64                            

  10. Vendor         : openSUSE                          

  11. Installed Size : 1017.8 KiB                        

  12. Installed      : No                                

  13. Status         : not installed                      

  14. Source package : nano-2.4.2-5.3.src                

  15. Summary        : Pico editor clone with enhancements

  16. Description    :                                    

  17.    GNU nano is a small and friendly text editor. It aims to emulate

  18.    the Pico text editor while also offering a few enhancements.

nano 包来自于 openSUSE Main 仓库(OSS)。

在 ArchLinux 系统上我们如何得知安装的包来自哪个仓库?

Pacman 命令[12] 即包管理器工具(package manager utility ),是一个简单的用来安装、构建、删除和管理 Arch Linux 软件包的命令行工具。Pacman 使用 libalpm 作为后端来执行所有的操作。

  1. # pacman -Ss chromium

  2. extra/chromium 48.0.2564.116-1

  3.    The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser

  4. extra/qt5-webengine 5.5.1-9 (qt qt5)

  5.    Provides support for web applications using the Chromium browser project

  6. community/chromium-bsu 0.9.15.1-2

  7.    A fast paced top scrolling shooter

  8. community/chromium-chromevox latest-1

  9.    Causes the Chromium web browser to automatically install and update the ChromeVox screen reader extention. Note: This

  10.    package does not contain the extension code.

  11. community/fcitx-mozc 2.17.2313.102-1

  12.    Fcitx Module of A Japanese Input Method for Chromium OS, Windows, Mac and Linux (the Open Source Edition of Google Japanese

  13.    Input)

chromium 包来自 ArchLinux extra 仓库。

或者,我们可以使用以下选项获得关于包的详细信息。

  1. # pacman -Si chromium

  2. Repository      : extra

  3. Name            : chromium

  4. Version         : 48.0.2564.116-1

  5. Description     : The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser

  6. Architecture    : x86_64

  7. URL             : http://www.chromium.org/

  8. Licenses        : BSD

  9. Groups          : None

  10. Provides        : None

  11. Depends On      : gtk2  nss  alsa-lib  xdg-utils  bzip2  libevent  libxss  icu  libexif  libgcrypt  ttf-font  systemd  dbus

  12.                  flac  snappy  speech-dispatcher  pciutils  libpulse  harfbuzz  libsecret  libvpx  perl  perl-file-basedir

  13.                  desktop-file-utils  hicolor-icon-theme

  14. Optional Deps   : kdebase-kdialog: needed for file dialogs in KDE

  15.                  gnome-keyring: for storing passwords in GNOME keyring

  16.                  kwallet: for storing passwords in KWallet

  17. Conflicts With  : None

  18. Replaces        : None

  19. Download Size   : 44.42 MiB

  20. Installed Size  : 172.44 MiB

  21. Packager        : Evangelos Foutras

  22. Build Date      : Fri 19 Feb 2016 04:17:12 AM IST

  23. 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 更新操作期间。

  1. $ apt-cache policy python3

  2. python3:

  3.  Installed: 3.6.3-0ubuntu2

  4.  Candidate: 3.6.3-0ubuntu3

  5.  Version table:

  6.     3.6.3-0ubuntu3 500

  7.        500 http://in.archive.ubuntu.com/ubuntu artful-updates/main amd64 Packages

  8. *** 3.6.3-0ubuntu2 500

  9.        500 http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages

  10.        100 /var/lib/dpkg/status

python3 包来自 Ubuntu updates 仓库。

方法-2:使用 apt 命令

APT 命令[14] 即 “Advanced Packaging Tool”,是 apt-get 命令的替代品,就像 DNF 是如何取代 YUM 一样。它是具有丰富功能的命令行工具并将所有的功能例如 apt-cacheapt-searchdpkgapt-cdromapt-configapt-ket 等包含在一个命令(APT)中,并且还有几个独特的功能。例如我们可以通过 APT 轻松安装 .dpkg 包,但我们不能使用 apt-get 命令安装,更多类似的功能都被包含进了 APT 命令。apt-get 因缺失了很多未被解决的特性而被 apt 取代。

  1. $ apt -a show notepadqq

  2. Package: notepadqq

  3. Version: 1.3.2-1~artful1

  4. Priority: optional

  5. Section: editors

  6. Maintainer: Daniele Di Sarli

  7. Installed-Size: 1,352 kB

  8. 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)

  9. Download-Size: 356 kB

  10. APT-Sources: http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful/main amd64 Packages

  11. Description: Notepad++-like editor for Linux

  12. Text editor with support for multiple programming

  13. languages, multiple encodings and plugin support.

  14. Package: notepadqq

  15. Version: 1.2.0-1~artful1

  16. Status: install ok installed

  17. Priority: optional

  18. Section: editors

  19. Maintainer: Daniele Di Sarli

  20. Installed-Size: 1,352 kB

  21. 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)

  22. Homepage: http://notepadqq.altervista.org

  23. Download-Size: unknown

  24. APT-Manual-Installed: yes

  25. APT-Sources: /var/lib/dpkg/status

  26. Description: Notepad++-like editor for Linux

  27. Text editor with support for multiple programming

  28. languages, multiple encodings and plugin support.

notepadqq 包来自 Launchpad PPA。


via: https://www./how-do-we-find-out-the-installed-packages-came-from-which-repository/

作者:Prakash Subramanian[16] 选题:lujun9972 译者:zianglei 校对:wxy

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多