APT 是否正在尝试降级软件包?

APT 是否正在尝试降级软件包?

从上个月(或两个月)开始,我在运行时观察到这种错误apt-get upgrade

Preparing to unpack .../nginx-common_1.9.3-1ubuntu1.2_all.deb ...
Unpacking nginx-common (1.9.3-1ubuntu1.2) over (1.9.3-1ubuntu1.1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-common_1.9.3-1ubuntu1.2_all.deb (--unpack):
 trying to overwrite '/etc/logrotate.d/nginx', which is also in package nginx 1.10.1-1~wily
Preparing to unpack .../nginx-core_1.9.3-1ubuntu1.2_amd64.deb ...
Unpacking nginx-core (1.9.3-1ubuntu1.2) over (1.9.3-1ubuntu1.1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-core_1.9.3-1ubuntu1.2_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package nginx 1.10.1-1~wily
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)

虽然整个升级过程没有失败,但是在升级过程结束时我仍然遇到此错误:

Errors were encountered while processing:
 /var/cache/apt/archives/nginx-common_1.9.3-1ubuntu1.2_all.deb
 /var/cache/apt/archives/nginx-core_1.9.3-1ubuntu1.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

如果我理解正确的话,我有版本1.10.1目前已安装易于正在尝试安装版本1.9.3 超过它... 也就是说,它正在尝试降级。我说得对吗?是否有可能较新的版本来自某些 PPA,而较旧其中一个是来自某个官方名单吗?

我已经安装了 Ubuntu 15.10。

我该如何预防降级即将发生?

编辑:以下是来自apt-cache policy nginx

nginx:
  Installed: 1.10.1-1~wily
  Candidate: 1.10.1-1~wily
  Version table:
 *** 1.10.1-1~wily 0
        500 http://nginx.org/packages/ubuntu/ wily/nginx amd64 Packages
        100 /var/lib/dpkg/status
     1.10.0-1~wily 0
        500 http://nginx.org/packages/ubuntu/ wily/nginx amd64 Packages
     1.9.3-1ubuntu1.2 0
        500 http://de.archive.ubuntu.com/ubuntu/ wily-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ wily-security/main amd64 Packages
     1.9.3-1ubuntu1 0
        500 http://de.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
     1.8.1-1~wily 0
        500 http://nginx.org/packages/ubuntu/ wily/nginx amd64 Packages
     1.8.0-1~wily 0
        500 http://nginx.org/packages/ubuntu/ wily/nginx amd64 Packages

答案1

首先,我将检查 APT 配置为安装哪个包(在可用选项中),您可以使用以下方法执行此操作:

apt-cache policy nginx

例如

% apt-cache policy nginx
nginx:
  Installed: 1.10.0-0ubuntu0.16.04.2
  Candidate: 1.10.0-0ubuntu0.16.04.2
  Version table:
 *** 1.10.0-0ubuntu0.16.04.2 500
        500 http://nz.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://nz.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
        100 /var/lib/dpkg/status
     1.9.15-0ubuntu1 500
        500 http://nz.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://nz.archive.ubuntu.com/ubuntu xenial/main i386 Packages

这告诉我,如果我还没有安装 nginx,apt 会尝试安装

1.10.0-0ubuntu0.16.04.2

nginx 的版本。
然后,要安装特定的(非候选)包,您可以将其指定为选项,例如apt-getfrom man apt(我截断了输出以使其更易于理解)

摘要
apt-get ... pkg [{=pkg_version_number ] ...

例如

apt-get install nginx=1.9.15-0ubuntu1

nginx如果有必要,将安装软件包的非候选版本。请注意,在这种情况下,您可能需要进行一些自己的依赖项管理,但并非总是如此。

相关内容