如何获取伪包的真实包名和版本?
如果运行apt-get install pseudo-package-name
如何apt-get install pseudo-package-name
将要安装的真实完整包名(包括版本)?
这与前一个问题有关: 从lts包获取内核版本?
例:
apt-get install linux-image-generic-lts-trusty
将安装(截至目前在我的32位Trusty服务器上):
linux-image-3.13.0-35-generic
我试过以下,但没有人给我答案。 我正在尝试编写脚本,所以我可以抓住linux-headers。
$ sudo apt-get install -qqs linux-image-generic-lts-trusty Inst linux-image-generic-lts-trusty (3.13.0.35.42 Ubuntu:14.04/trusty-updates [i386]) Conf linux-image-generic-lts-trusty (3.13.0.35.42 Ubuntu:14.04/trusty-updates [i386]) $ apt-cache depends linux-image-generic-lts-trusty linux-image-generic-lts-trusty Depends: linux-image-generic $ apt-cache depends linux-image-generic linux-image-generic Depends: linux-image-3.13.0-35-generic Depends: linux-image-extra-3.13.0-35-generic Depends: linux-firmware $ apt-cache policy linux-image-generic-lts-trusty linux-image-generic-lts-trusty: Installed: (none) Candidate: 3.13.0.35.42 Version table: 3.13.0.35.42 0 500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main i386 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main i386 Packages 3.13.0.24.28 0 500 http://us.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages
在对/ var / lib / {apt,dpkg}进行一些探索之后,我重新确定了这个问题没有通用的,可编写脚本的答案。 所以,类似于下面@mchid和@muru的答案,我这样做了:
#!/bin/bash metapackage=linux-image-generic-lts-trusty linux_package_version=$(apt-cache policy $metapackage |\ sed -nE '/Candidate:/ s,[^[:digit:]]*([[:digit:]\.]+)\.([[:digit:]]+)\.[[:digit:]]+,\1-\2,p') apt-get download linux-headers-${linux_package_version}-generic linux-headers-${linux_package_version})
首先,您必须准确显示元数据包提供的包:
例:
apt-cache show linux-image-generic-lts-trusty | grep Depends:
输出:
Depends: linux-image-generic Depends: linux-image-generic
现在,如果您键入元数据包的特定包,您将获得确切的结果:
apt-cache show linux-image-generic | grep Depends:
输出:
Depends: linux-image-3.13.0-35-generic, linux-image-extra-3.13.0-35-generic, linux-firmware Depends: linux-image-3.13.0-24-generic, linux-image-extra-3.13.0-24-generic, linux-firmware
除非另有说明,否则始终安装最新版本,如下例所示:
sudo apt-get install linux-image-3.13.0-24-generic
或者,如果您只是想要该版本,则可以键入以下命令或其中的变体:
apt-cache show linux-image-generic-lts-trusty | grep Version:
输出:
Version: 3.13.0.35.42 Version: 3.13.0.24.28
问题是依赖:
linux-image-generic-lts-trusty └── linux-image-generic └── linux-image-3.13.0-35-generic
因此,您可能无法直接获取有关将安装哪个软件包的信息。 你需要使用像apt-rdepends
这样的东西。
一般来说,你不能。 诸如“email-client”之类的包不提供可以遵循和解决的依赖链。