apt-get -f install 无法更正依赖关系

apt-get -f install 无法更正依赖关系

我最近尝试将 dist-upgrade 从 16.04 升级到 18.04。在升级过程中,它报告了依赖关系中断的问题。我记下了这些软件包,希望以后能修复这个问题。

现在我似乎陷入了无法安装、修复或卸载软件包的境地。

首先,我的存储库:

ralmond@Limu:~$ cat /etc/apt/sources.list
# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 
(20120425)]/ dists/precise/main/binary-i386/

# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 (20120425)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 (20120425)]/ precise main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner

# deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu trusty/ # disabled on upgrade to trusty disabled on upgrade to xenial
# deb https://mirrors.nics.utk.edu/cran/linux/ubuntu xenial main
# deb-src https://mirrors.nics.utk.edu/cran/linux/ubuntu xenial main
# deb http://cran.rstudio.com/bin/linux/ubuntu xenial/ # disabled on upgrade to bionic

我手动注释掉了精确的合作伙伴存储库,因为这可能是一个问题。sources.list 和 sources.list.d 中的所有其他较旧的存储库都被注释掉了。

我尝试运行 apt-get -f install 来修复损坏的依赖项,但我得到了

ralmond@Limu:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
    debhelper : Depends: dh-autoreconf (>= 17~) but it is not installed
         Depends: dh-strip-nondeterminism (>= 0.028~) but 0.015-1 is installed
     libglib2.0-bin : Depends: libglib2.0-0 (= 2.56.1-2ubuntu1) but 2.48.2-0ubuntu1 is installed
     libhtml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is installed
                   Depends: perlapi-5.26.0
     libnet-ssleay-perl : Depends: perl (>= 5.26.1-4build1) but 5.22.1-9ubuntu0.5 is installed
                  Depends: perlapi-5.26.1
     libxml-libxml-perl : Depends: perl (>= 5.26.1-2ubuntu1) but 5.22.1-9ubuntu0.5 is installed
                  Depends: perlapi-5.26.1
     libxml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is installed
                  Depends: perlapi-5.26.0
     systemd : Depends: libsystemd0 (= 229-4ubuntu21.2) but 237-3ubuntu10 is installed
     texlive-binaries : Depends: libharfbuzz0b (>= 1.4.1) but 1.0.1-1ubuntu0.1 is installed
                Depends: libmpfr6 (>= 3.1.3) but it is not installed
                Depends: libpoppler73 (>= 0.62.0) but it is not installed
     texlive-extra-utils : Depends: libunicode-linebreak-perl but it is not installed
     texlive-generic-extra : Depends: texlive-plain-generic (>= 2017.20170628) but it is not installed
     texlive-generic-recommended : Depends: texlive-plain-generic (>= 2017.20170628) but it is not installed
     texlive-lang-chinese : Depends: fonts-arphic-bkai00mp but it is not installed
                    Depends: fonts-arphic-bsmi00lp but it is not installed
                    Depends: fonts-arphic-gbsn00lp but it is not installed
                    Depends: fonts-arphic-gkai00mp but it is not installed
   texlive-lang-korean : Depends: fonts-baekmuk but it is not installed
                   Depends: fonts-unfonts-extra but it is not installed
   texlive-lang-other : Depends: fonts-sil-padauk (>= 3.003-1) but 2.80-2 is installed
   texlive-plain-extra : Depends: texlive-plain-generic (>= 2017.20170628) but it is not installed
   texlive-pstricks : Depends: texlive-plain-generic (>= 2017.20170628) but it is not installed
   texlive-science : Depends: texlive-lang-greek (>= 2017.20170628) but it is not installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

没有保留的包裹:

ralmond@Limu:~$ sudo apt-mark showhold
ralmond@Limu:~$ 

如果我再次尝试 dist-upgrade,我会收到非常相似的错误消息:

ralmond@Limu:~$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
     debhelper : Depends: dh-autoreconf (>= 17~) but it is not installed
         Depends: dh-strip-nondeterminism (>= 0.028~) but 0.015-1 is installed
     libglib2.0-bin : Depends: libglib2.0-0 (= 2.56.1-2ubuntu1) but 2.48.2-0ubuntu1 is installed
... [Removing nearly identical list of broken packages.]
E: Unmet dependencies. Try using -f.

-f 选项似乎没有帮助。

ralmond@Limu:~$ sudo apt-get -f dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
      debhelper : Depends: dh-autoreconf (>= 17~) but it is not installed
         Depends: dh-strip-nondeterminism (>= 0.028~) but 0.015-1 is installed
...
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

删除包也有类似的问题:

ralmond@Limu:~$ sudo apt-get -f remove debhelper
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
  alien : Depends: debhelper (>= 7) but it is not going to be installed
  dh-strip-nondeterminism : Depends: debhelper but it is not going to be installed
  dh-translations : Depends: debhelper but it is not going to be installed
  libglib2.0-bin : Depends: libglib2.0-0 (= 2.56.1-2ubuntu1) but 2.48.2-0ubuntu1 is to be installed
  libhtml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is to be installed
                   Depends: perlapi-5.26.0
  libnet-ssleay-perl : Depends: perl (>= 5.26.1-4build1) but 5.22.1-9ubuntu0.5 is to be installed
                  Depends: perlapi-5.26.1
  libxml-libxml-perl : Depends: perl (>= 5.26.1-2ubuntu1) but 5.22.1-9ubuntu0.5 is to be installed
                  Depends: perlapi-5.26.1
  libxml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is to be installed
                  Depends: perlapi-5.26.0
  systemd : Depends: libsystemd0 (= 229-4ubuntu21.2) but 237-3ubuntu10 is to be installed
  texlive-binaries : Depends: libharfbuzz0b (>= 1.4.1) but 1.0.1-1ubuntu0.1 is to be installed
                Depends: libmpfr6 (>= 3.1.3) but it is not going to be installed
                Depends: libpoppler73 (>= 0.62.0) but it is not going to be installed
  texlive-extra-utils : Depends: libunicode-linebreak-perl but it is not going to be installed
  texlive-generic-extra : Depends: texlive-plain-generic (>= 2017.20170628) but it is not going to be installed
  texlive-generic-recommended : Depends: texlive-plain-generic (>= 2017.20170628) but it is not going to be installed
  texlive-lang-chinese : Depends: fonts-arphic-bkai00mp but it is not going to be installed
                    Depends: fonts-arphic-bsmi00lp but it is not going to be installed
                    Depends: fonts-arphic-gbsn00lp but it is not going to be installed
                    Depends: fonts-arphic-gkai00mp but it is not going to be installed
  texlive-lang-korean : Depends: fonts-baekmuk but it is not going to be installed
                   Depends: fonts-unfonts-extra but it is not going to be installed
  texlive-lang-other : Depends: fonts-sil-padauk (>= 3.003-1) but 2.80-2 is to be installed
  texlive-plain-extra : Depends: texlive-plain-generic (>= 2017.20170628) but it is not going to be installed
  texlive-pstricks : Depends: texlive-plain-generic (>= 2017.20170628) but it is not going to be installed
  texlive-science : Depends: texlive-lang-greek (>= 2017.20170628) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

看起来 debhelper 确实有点坏了。我担心移除它太过激进,因为担心会破坏整个 debian 系统,导致无法前进或后退。

在此先感谢您对下一步尝试的任何帮助或建议。

更新 1: 点击此链接(未满足的依赖关系错误)。它建议尝试dpkg --purge --pending。这并没有解决我的问题,但我认为它提供了一个线索。以下是输出:

ralmond@Limu:~$ sudo dpkg --purge --pending
[sudo] password for ralmond: 
dpkg: dependency problems prevent removal of texlive:
  mathtex depends on texlive.

dpkg: error processing package texlive (--purge):
  dependency problems - not removing
(Reading database ... 545797 files and directories currently installed.)
Removing systemd-shim (9-1bzr4ubuntu1) ...
Removing 'diversion of /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service to /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.systemd by systemd-shim'
  dpkg-divert: error: rename involves overwriting '/usr/share/dbus-1/system-services/org.freedesktop.systemd1.service' with
  different file '/usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.systemd', not allowed
dpkg: error processing package systemd-shim (--purge):
  installed systemd-shim package post-removal script subprocess 
returned error exit status 2
Errors were encountered while processing:
  texlive
  systemd-shim

答案1

我想我找到了答案。虽然过程缓慢而痛苦,但我希望它能帮助我找到答案。(我已经完成了一部分)。

1)首先,我删除了尽可能多的软件包dpkg -r(例如,所有的 texlive 软件包都不是系统关键的,我可以稍后重新安装它们,所以我清理了尽可能多的软件包。

2)对于实际属于系统的软件包,我使用了以下步骤:

a) 用于sudo apt-get -f install检查什么地方仍然损坏。

ralmond@Limu:~/packageDepot$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 libglib2.0-bin : Depends: libglib2.0-0 (= 2.56.1-2ubuntu1) but 2.48.2-0ubuntu1 is installed
 libhtml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is installed
                   Depends: perlapi-5.26.0
 libnet-ssleay-perl : Depends: perl (>= 5.26.1-4build1) but 5.22.1-9ubuntu0.5 is installed
                  Depends: perlapi-5.26.1
 libxml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is installed
                  Depends: perlapi-5.26.0
 systemd : Depends: libsystemd0 (= 229-4ubuntu21.2) but 237-3ubuntu10 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

2) 每次处理一个包,apt-get install检查缺少的依赖项。列表中的下一个是 glib2,因此:

ralmond@Limu:~/packageDepot$ sudo apt-get install libglib2.0-0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
   libglib2.0-0 : Breaks: libglib2.0-0:i386 (!= 2.56.1-2ubuntu1) but 2.48.2-0ubuntu1 is to be installed
   libglib2.0-0:i386 : Breaks: libglib2.0-0 (!= 2.48.2-0ubuntu1) but 2.56.1-2ubuntu1 is to be installed
   libhtml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is to be installed
   ... 
   E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

啊!i386 版本有依赖关系。再次运行检查 i386 版本是否没有任何依赖关系。

ralmond@Limu:~/packageDepot$ sudo apt-get install libglib2.0-0 libglib2.0-0:i386
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
   libhtml-parser-perl : Depends: perl (>= 5.26.0-4) but 5.22.1-9ubuntu0.5 is to be installed
   ... [Same list of packages]
   E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

接下来,我使用 手动下载文件apt-get download。注意,不要以 root 身份运行,否则没有 则无法删除文件sudo

ralmond@Limu:~/packageDepot$ apt-get download libglib2.0-0 libglib2.0- 0:i386
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libglib2.0-0 amd64 2.56.1-2ubuntu1 [1,167 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic/main i386 libglib2.0-0 i386 2.56.1-2ubuntu1 [1,232 kB]
Fetched 2,399 kB in 7s (323 kB/s)                                              

现在使用 手动安装dpkg -i

ralmond@Limu:~/packageDepot$ sudo dpkg -i ./libglib*
(Reading database ... 421587 files and directories currently installed.)
 Preparing to unpack .../libglib2.0-0_2.56.1-2ubuntu1_amd64.deb ...
 De-configuring libglib2.0-0:i386 (2.48.2-0ubuntu1) ...
 Unpacking libglib2.0-0:amd64 (2.56.1-2ubuntu1) over (2.48.2-0ubuntu1) ...
 Preparing to unpack .../libglib2.0-0_2.56.1-2ubuntu1_i386.deb ...
 Unpacking libglib2.0-0:i386 (2.56.1-2ubuntu1) over (2.48.2-0ubuntu1) ...
 Setting up libglib2.0-0:amd64 (2.56.1-2ubuntu1) ...
 Setting up libglib2.0-0:i386 (2.56.1-2ubuntu1) ...
 Processing triggers for libc-bin (2.27-3ubuntu1) ...

现在回过头来apt-get -f install解决下一个问题。

如果我发现需要更多步骤,我会更新。

相关内容