如何识别 apt-cache show 输出中显示的软件包的 Debian 分支`?

如何识别 apt-cache show 输出中显示的软件包的 Debian 分支`?

我想从 Debiantesting分支安装软件包,例如tmuxgit

因此,我已将 APT 配置为testing,但将其用作main默认值:

nlykkei@debian-parallels ~ $ cat /etc/apt/sources.list.d/testing.list
deb http://deb.debian.org/debian/ testing main
deb-src http://deb.debian.org/debian/ testing main
nlykkei@debian-parallels ~ $ cat /etc/apt/preferences.d/testing.pref
Package: *
Pin: release a=testing
Pin-Priority: 100

现在,当我检查tmux可用版本时,3.1-c12.8-3版本都会显示。在本例中,很明显 是3.1c-1from testing,但是我如何在更复杂的输出中识别它?

我需要 的分支名称apt-get install -t <branch> <pkg>...,它设置Pin-Priority: 990<branch>

apt-cache show:

nlykkei@debian-parallels ~ $ apt-cache show tmux
Package: tmux
Version: 3.1c-1
Installed-Size: 830
Maintainer: Romain Francoise <[email protected]>
Architecture: amd64
Depends: libc6 (>= 2.27), libevent-2.1-7 (>= 2.1.8-stable), libtinfo6 (>= 6), libutempter0 (>= 1.1.5)
Description-en: terminal multiplexer
 tmux enables a number of terminals (or windows) to be accessed and
 controlled from a single terminal like screen. tmux runs as a
 server-client system. A server is created automatically when necessary
 and holds a number of sessions, each of which may have a number of
 windows linked to it. Any number of clients may connect to a session,
 or the server may be controlled by issuing commands with tmux.
 Communication takes place through a socket, by default placed in /tmp.
 Moreover tmux provides a consistent and well-documented command
 interface, with the same syntax whether used interactively, as a key
 binding, or from the shell. It offers a choice of vim or Emacs key
 layouts.
Description-md5: dc6ff920cb9183a42694d0ea54835078
Homepage: https://tmux.github.io/
Tag: hardware::input:keyboard, implemented-in::c, interface::text-mode,
 role::program, scope::application, works-with::software:running
Section: admin
Priority: optional
Filename: pool/main/t/tmux/tmux_3.1c-1_amd64.deb
Size: 362376
MD5sum: e0be6f85c58a244108eab29c9ee629cf
SHA256: 037f2f1f55c72e75e155cb54cdd9c41f4ac7575cef50a1427383b043cc8316e0

Package: tmux
Version: 2.8-3
Installed-Size: 681
Maintainer: Romain Francoise <[email protected]>
Architecture: amd64
Depends: libc6 (>= 2.27), libevent-2.1-6 (>= 2.1.8-stable), libtinfo6 (>= 6), libutempter0 (>= 1.1.5)
Description-en: terminal multiplexer
 tmux enables a number of terminals (or windows) to be accessed and
 controlled from a single terminal like screen. tmux runs as a
 server-client system. A server is created automatically when necessary
 and holds a number of sessions, each of which may have a number of
 windows linked to it. Any number of clients may connect to a session,
 or the server may be controlled by issuing commands with tmux.
 Communication takes place through a socket, by default placed in /tmp.
 Moreover tmux provides a consistent and well-documented command
 interface, with the same syntax whether used interactively, as a key
 binding, or from the shell. It offers a choice of vim or Emacs key
 layouts.
Description-md5: dc6ff920cb9183a42694d0ea54835078
Homepage: https://tmux.github.io/
Tag: hardware::input:keyboard, implemented-in::c, interface::text-mode,
 role::program, scope::application, works-with::software:running
Section: admin
Priority: optional
Filename: pool/main/t/tmux/tmux_2.8-3_amd64.deb
Size: 302084
MD5sum: 17d694a86ec7b0f46ac6ff60e0d843ff
SHA256: 9c247aef3c3c09d982d49a14091209d76bd06a3d2e699fc9d60ddcee203b456a

apt-cache policy:

nlykkei@debian-parallels ~ $ apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 100 http://deb.debian.org/debian testing/main amd64 Packages
     release o=Debian,a=testing,n=bullseye,l=Debian,c=main,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian buster-updates/main amd64 Packages
     release o=Debian,a=stable-updates,n=buster-updates,l=Debian,c=main,b=amd64
     origin deb.debian.org
 500 http://security.debian.org/debian-security buster/updates/main amd64 Packages
     release v=10,o=Debian,a=stable,n=buster,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian buster/main amd64 Packages
     release v=10.9,o=Debian,a=stable,n=buster,l=Debian,c=main,b=amd64
     origin deb.debian.org
Pinned packages:

更新:

tmux:
  Installed: 3.1c-1~bpo10+1
  Candidate: 3.1c-1~bpo10+1
  Version table:
 *** 3.1c-1~bpo10+1 100
        100 http://deb.debian.org/debian buster-backports/main amd64 Packages
        100 /var/lib/dpkg/status
     2.8-3 990
        990 http://deb.debian.org/debian buster/main amd64 Packages

答案1

apt-cache show不会告诉您它描述的是哪个“分支”,但apt show会:

$ apt show -a tmux
Package: tmux
Version: 3.1c-1
Priority: optional
Section: admin
Maintainer: Romain Francoise <[email protected]>
Installed-Size: 850 kB
Depends: libc6 (>= 2.27), libevent-2.1-7 (>= 2.1.8-stable), libtinfo6 (>= 6), libutempter0 (>= 1.1.5)
Homepage: https://tmux.github.io/
Tag: hardware::input:keyboard, implemented-in::c, interface::text-mode,
 role::program, scope::application, works-with::software:running
Download-Size: 362 kB
APT-Sources: http://deb.debian.org/debian testing/main amd64 Packages
Description: terminal multiplexer
 tmux enables a number of terminals (or windows) to be accessed and
 controlled from a single terminal like screen. tmux runs as a
 server-client system. A server is created automatically when necessary
 and holds a number of sessions, each of which may have a number of
 windows linked to it. Any number of clients may connect to a session,
 or the server may be controlled by issuing commands with tmux.
 Communication takes place through a socket, by default placed in /tmp.
 Moreover tmux provides a consistent and well-documented command
 interface, with the same syntax whether used interactively, as a key
 binding, or from the shell. It offers a choice of vim or Emacs key
 layouts.

Package: tmux
Version: 2.8-3
Priority: optional
Section: admin
Maintainer: Romain Francoise <[email protected]>
Installed-Size: 697 kB
Depends: libc6 (>= 2.27), libevent-2.1-6 (>= 2.1.8-stable), libtinfo6 (>= 6), libutempter0 (>= 1.1.5)
Homepage: https://tmux.github.io/
Tag: hardware::input:keyboard, implemented-in::c, interface::text-mode,
 role::program, scope::application, works-with::software:running
Download-Size: 302 kB
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian buster/main amd64 Packages
Description: terminal multiplexer
 tmux enables a number of terminals (or windows) to be accessed and
 controlled from a single terminal like screen. tmux runs as a
 server-client system. A server is created automatically when necessary
 and holds a number of sessions, each of which may have a number of
 windows linked to it. Any number of clients may connect to a session,
 or the server may be controlled by issuing commands with tmux.
 Communication takes place through a socket, by default placed in /tmp.
 Moreover tmux provides a consistent and well-documented command
 interface, with the same syntax whether used interactively, as a key
 binding, or from the shell. It offers a choice of vim or Emacs key
 layouts.

查找这些APT-Sources行:它们指示信息对应于哪个存储库。

答案2

你几乎已经受够了apt-cache policy。您只需将包名称附加到该命令行即可。

您可以用来apt-cache policy [package...]显示安装的版本、默认安装候选版本以及可安装的所有版本(根据您的sources.list文件和固定配置或APT::Default-Release设置)。

例如,在我的一个系统上,默认配置为使用sidaka unstable(由于APT::Default-Release "unstable";my 中的行/etc/apt/apt.conf),并且还允许从 中挑选软件包experimental

$ apt-cache policy tmux
tmux:
  Installed: 3.1c-1
  Candidate: 3.1c-1
  Version table:
     3.2~rc4-1 1
          1 http://ftp.au.debian.org/debian experimental/main amd64 Packages
 *** 3.1c-1 990
        990 http://ftp.au.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status

“已安装”是当前安装的版本。 “候选”是根据您的 apt 配置可以安装的版本(在这种情况下,候选版本已经安装)。 “版本表”显示所有可用版本。

可以通过指定确切的版本号或在您的sources.list文件之一中定义的目标版本来安装任何其他版本。例如,stable、testing、sid、experimental 或特定 debian 版本的名称,如“stretch”或“buster”。

例如,以下之一:

apt install tmux=3.2~rc4-1

apt -t experimental install tmux

apt install tmux/experimental

apt-cache policy顺便说一句,您还可以使用该选项覆盖显示的安装候选版本-t target_release。这在脚本中可能比从命令行运行的东西更有用,可以轻松使用grep -oP '^ +Candidate: \K.*'或提取候选版本awk -F': ' '/^ +Candidate:/ {print $2}'

相关内容