从特定组件安装 Deb 包

从特定组件安装 Deb 包

sources.list包中存储库的指定格式为

deb url distribution component(s)

我如何明确说明apt-get从哪个组件安装包?

答案1

你不能这么做。包不会在不同的组件中重复。

因此,如果您想安装一个软件,而您的 apt 配置(source.list 文件中的 repos)没有找到它,您应该尝试检查该软件属于哪个组件并添加它,然后更新并尝试再次安装。

祝你好运。

来源:https://wiki.debian.org/SourcesList

答案2

您可以从特定组件安装软件,但更轻松、更准确地安装不同版本的软件。

最简单的开始方式是搜索软件包。例如,您可能决定将官方 NGINX 存储库添加到/etc/apt/sources.list.d/nginx.list。这也可以是个人或私有存储库,其中包含使用安全或自定义更新修补的版本。

用于apt搜索相关包:

$ apt search nginx
...


nginx/stable 1.14.2-1~bionic all [upgradable from: 1.10.3-1+deb9u2]
  small, powerful, scalable web/proxy server

nginx-common/stable,stable,now 1.10.3-1+deb9u2 all [installed,automatic]
  small, powerful, scalable web/proxy server - common files

...

示例可以显示nginx/stablenginx/testing是否nginx/testing有较新的版本,或者如果您有自定义存储库。

可以通过 查看每个包的附加详细信息apt show

$ apt show nginx -a
Package: nginx
Version: 1.14.2-1~bionic
Priority: optional
Section: httpd
Maintainer: Sergey Budnevitch <[email protected]>
Installed-Size: 2,953 kB
Provides: httpd
Depends: init-system-helpers (>= 1.18~), libc6 (>= 2.17), libpcre3, libssl1.1 (>= 1.1.0), zlib1g (>= 1:1.1.4), lsb-base (>= 3.0-6), adduser
Conflicts: nginx-common
Homepage: http://nginx.org
Download-Size: 828 kB
APT-Sources: http://nginx.org/packages/debian bionic/nginx amd64 Packages
Description: high performance web server
 nginx [engine x] is an HTTP and reverse proxy server, as well as
 a mail proxy server.

...

Package: nginx
Version: 1.10.3-1+deb9u2
Priority: optional
Section: httpd
Maintainer: Debian Nginx Maintainers <[email protected]>
Installed-Size: 93.2 kB
Depends: nginx-full (<< 1.10.3-1+deb9u2.1~) | nginx-light (<< 1.10.3-1+deb9u2.1~) | nginx-extras (<< 1.10.3-1+deb9u2.1~), nginx-full (>= 1.10.3-1+deb9u2) | nginx-light (>= 1.10.3-1+deb9u2) | nginx-extras (>= 1.10.3-1+deb9u2)
Homepage: http://nginx.net
Tag: implemented-in::c, interface::daemon, network::server, network::service,
 protocol::http, role::program, use::proxying
Download-Size: 81.8 kB
APT-Manual-Installed: yes
APT-Sources: http://mirrors.linode.com/debian bionic/main amd64 Packages
Description: small, powerful, scalable web/proxy server
 Nginx ("engine X") is a high-performance web and reverse proxy server
 created by Igor Sysoev. It can be used both as a standalone web server
 and as a proxy to reduce the load on back-end HTTP or mail servers.
 .
 This is a dependency package to install either nginx-full (by default),
 nginx-light or nginx-extras.

如果您有一个独特的组件,只需将其传递给apt

$ sudo apt install nginx/stable

-t=target_release否则,您可以选择该组件独有的特定版本( )和发行版:

$ sudo apt install nginx -t='1.15.10-1~bionic'

您可以看到 Debian 维护者发布的版本是这样的1.10.3-1+deb9u2,而 NGINX 发布的版本是这样的1.15.10-1~stretch。您可以使用这些差异来检测这一点,以实现自动化。

相关内容