Ubuntu下面包依赖损坏的解决unmet dependencies

2023-05-16

2017-1-4 更新

在原来的文章中提到过使用gzip压缩changelog得到changelog.debian.gz,然后覆盖掉原来的,从而达到欺骗系统认为的软件包的版本问题, 但是这样的话需要自己手动定位找到并且压缩, 像pulseaudio这样的软件有很多个changelog,还需要一个个找, 找个一个最简单的方法:
1. 使用apt-get download下载对应版本的deb包
2. 使用gdebi-gtk图形化或者ark解压,直接提取里面的gz文件覆盖即可.
--------------------------------------------------------
以下为原内容
--------------------------------------------------------

出现dependencies的原因

在新版的Ubuntu下,例如Ubuntu 14.04或者16.04一般是不会出现broken dependencies,或者出现unmet dependencies, 但是如果我们使用dpkg强制安装了某些deb包,或者在build-dep的是否手动更改了某些Packages的文件和版本时, 那么在再次使用apt-get install或者build-dep来安装library和packages的时就很可能出现问题.


问题的定位

出现了dependencies的问题,那么一般会有提示, 而且在log中也会有呈现, 这个时候又分几种情况.

第一种是无法安装依赖问题

例如下面这个示例:

$ sudo apt-get build-dep pulseaudio
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have unmet dependencies:
 libjack-dev : Depends: libjack0 (= 1:0.121.3+20120418git75e3e20b-2.1ubuntu1) but it is not going to be installed
E: Build-dependencies for pulseaudio could not be satisfied.

这里面便是相互依赖无法满足的问题.

第二种是break dependencies的问题

例如对于前面的libjack问题, 我们手动来安装一下它看看究竟是什么导致的无法满足:

$ sudo apt-get install libjack0
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:
 libbluetooth-dev : Depends: libbluetooth3 (= 4.101-0ubuntu13.1) but 4.101.1-0indt2 is to be installed
 libjack-jackd2-0 : Conflicts: libjack-0.116
                    Conflicts: libjack0 but 1:0.121.3+20120418git75e3e20b-2.1ubuntu1 is to be installed
 libjack-jackd2-0:i386 : Conflicts: libjack-0.116
                         Conflicts: libjack0 but 1:0.121.3+20120418git75e3e20b-2.1ubuntu1 is to be installed
 libjack0 : Conflicts: libjack-0.116
            Conflicts: libjack-0.116:i386
 libpulse-dev : Depends: libpulse0 (= 1:4.0-0ubuntu11.1) but 1:4.0-0ubuntu11indt2 is to be installed
 libpulse0 : Breaks: libpulse0:i386 (!= 1:4.0-0ubuntu11indt2) but 1:4.0-0ubuntu11.1 is to be installed
 libpulse0:i386 : Breaks: libpulse0 (!= 1:4.0-0ubuntu11.1) but 1:4.0-0ubuntu11indt2 is to be installed
 pulseaudio : Depends: libpulse0 (= 1:4.0-0ubuntu11.1) but 1:4.0-0ubuntu11indt2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

可以看到这个是版本的问题, 因为版本的冲突,导致无法安装. 而且Ubuntu提示让我们使用apt-get -f install 去修复.


如何解决

自动修复

前面已经有提示让我们用apt-get -f install来修复,那么这个命令可以修复哪些情况的dependencies问题呢?  一般是没有更改packages的版本,但是依赖不正确,例如A依赖B,但是B没有安装, 此时强制安装A,那么是可以修复的. 还有一种情况, 例如安装B的过程中断电或者被Ctrl+C终止,那么也是可以通过这个命令来修复的. 

手动修复

但是前面示例的这种版本的问题是无法通过这个命令来修复的. 例如:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libkutils4 libswresample0 linux-image-4.4.0-45-generic
  linux-image-extra-4.4.0-45-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libpulse0
The following packages will be REMOVED:
  libbluetooth-dev
The following packages will be upgraded:
  libpulse0
1 upgraded, 0 newly installed, 1 to remove and 8 not upgraded.
4 not fully installed or removed.
Need to get 0 B/225 kB of archives.
After this operation, 409 kB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 737309 files and directories currently installed.)
Preparing to unpack .../libpulse0_1%3a4.0-0ubuntu11.1_amd64.deb ...
Unpacking libpulse0:amd64 (1:4.0-0ubuntu11.1) over (1:4.0-0ubuntu11indt2) ...
dpkg: error processing archive /var/cache/apt/archives/libpulse0_1%3a4.0-0ubuntu11.1_amd64.deb (--unpack):
 trying to overwrite shared '/usr/share/doc/libpulse0/changelog.Debian.gz', which is different from other instances of package libpulse0:amd64
Errors were encountered while processing:
 /var/cache/apt/archives/libpulse0_1%3a4.0-0ubuntu11.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

可以看到根据提示是我们的changelog不同,所以无法覆盖, 因此我们需要手动来解决. 根据提示, 我们来看看两者的版本, 究竟有什么不同:

$ zcat /usr/share/doc/libpulse0/changelog.Debian.gz | head
pulseaudio (1:4.0-0ubuntu11indt2) unstable; urgency=medium

然后看看想要安装的,或者说Ubuntu默认的是什么版本

第一步需要先下载package的source code, 因为这里面含有changelog:

$ apt-get source libpulse0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'pulseaudio' as source package instead of 'libpulse0'
NOTICE: 'pulseaudio' packaging is maintained in the 'Bzr' version control system at:
http://bazaar.launchpad.net/~ubuntu-audio-dev/pulseaudio/ubuntu
Please use:
bzr branch http://bazaar.launchpad.net/~ubuntu-audio-dev/pulseaudio/ubuntu
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 1,470 kB of source archives.
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty-updates/main pulseaudio 1:4.0-0ubuntu11.1 (dsc) [4,851 B]
Get:2 http://mirrors.aliyun.com/ubuntu/ trusty-updates/main pulseaudio 1:4.0-0ubuntu11.1 (tar) [1,392 kB]
Get:3 http://mirrors.aliyun.com/ubuntu/ trusty-updates/main pulseaudio 1:4.0-0ubuntu11.1 (diff) [72.6 kB]
Fetched 1,470 kB in 6s (232 kB/s)                                              
gpgv: Signature made Thu 29 Jan 2015 02:29:24 AM CST using RSA key ID B16223A3
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./pulseaudio_4.0-0ubuntu11.1.dsc
dpkg-source: info: extracting pulseaudio in pulseaudio-4.0
dpkg-source: info: unpacking pulseaudio_4.0.orig.tar.xz
dpkg-source: info: unpacking pulseaudio_4.0-0ubuntu11.1.debian.tar.xz
dpkg-source: info: applying 0003-esd-honour-system-pulseaudio.patch
dpkg-source: info: applying 0005-dont-load-cork-music-on-phone.patch
dpkg-source: info: applying 0006-load-module-x11-bell.patch
dpkg-source: info: applying 0016-nodisplay-autostart.patch
dpkg-source: info: applying 0020-stream-Return-error-in-case-a-client-peeks-to-early.patch
dpkg-source: info: applying 0022-inotify-wrapper-Quit-daemon-if-pid-file-is-removed.patch
dpkg-source: info: applying 0023-fixing_snd_mixer_poll_descriptors_count_when_zero.patch
dpkg-source: info: applying 0101-alsa-ucm-Make-combination-ports-have-lower-priority.patch
dpkg-source: info: applying 0102-combine-Fix-crash-in-output-freeing.patch
dpkg-source: info: applying 0103-resampler-Fix-peaks-resampler-s-channel-handling.patch
dpkg-source: info: applying 0104-default-system.pa-Do-not-load-module-dbus-protocol.patch
dpkg-source: info: applying 0105-sink-source-Initialize-port-before-fixate-hook-fixes.patch
dpkg-source: info: applying 0106-module-switch-on-port-available-Don-t-switch-profile.patch
dpkg-source: info: applying 0107-sink-source-Fix-restore-of-volume-on-devices-without.patch
dpkg-source: info: applying 0201-ALSA-Add-extcon-Android-switch-jack-detection.patch
dpkg-source: info: applying 0202-dont-probe-ucm.patch
dpkg-source: info: applying 0203-card-Add-hook-before-profile-changes.patch
dpkg-source: info: applying 0204-Add-module-to-talk-to-the-Android-audio-hal-to-set-u.patch
dpkg-source: info: applying 0205-suspend-on-idle-ensure-we-still-time-out-if-a-stream-remains-corked.patch

然后查看对比:

$ head debian/changelog
pulseaudio (1:4.0-0ubuntu11.1) trusty; urgency=medium

可见两者的版本确实不一样, 因此我们要解决这个问题,那么将现在安装了的改成original的即可.

$ gzip debian/changelog 
$ file debian/changelog.gz 
debian/changelog.gz: gzip compressed data, was "changelog", from Unix, last modified: Thu Jan 29 02:29:16 2015

然后在覆盖一下:

sudo cp debian/changelog.gz /usr/share/doc/libpulse0/changelog.Debian.gz

再次使用 -f install来修复:

Unpacking libpulse0:amd64 (1:4.0-0ubuntu11.1) over (1:4.0-0ubuntu11indt2) ...
dpkg: error processing archive /var/cache/apt/archives/libpulse0_1%3a4.0-0ubuntu11.1_amd64.deb (--unpack):
 trying to overwrite shared '/usr/share/doc/libpulse0/changelog.Debian.gz', which is different from other instances of package libpulse0:amd64
Errors were encountered while processing:
 /var/cache/apt/archives/libpulse0_1%3a4.0-0ubuntu11.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

为此可以知道,这个版本信息不仅仅存在于那个changelog文件中,在packages database中也存在, 因此我们只能手动强制安装并覆盖这个libpulse包到Ubuntu原来的版本了

先获取

apt-get download libpulse0
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty-updates/main libpulse0 amd64 1:4.0-0ubuntu11.1 [225 kB]
Fetched 225 kB in 2s (87.6 kB/s)    
然后强制安装

sudo dpkg -i libpulse*.deb   

最后再自动修复

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libkutils4 libswresample0 linux-image-4.4.0-45-generic
  linux-image-extra-4.4.0-45-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  libbluetooth-dev
0 upgraded, 0 newly installed, 1 to remove and 8 not upgraded.
3 not fully installed or removed.
After this operation, 409 kB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 737308 files and directories currently installed.)
Removing libbluetooth-dev (4.101-0ubuntu13.1) ...
Setting up libpulse0:i386 (1:4.0-0ubuntu11.1) ...
Setting up pulseaudio (1:4.0-0ubuntu11.1) ...
Setting up pulseaudio-module-nvs (1:4.0-0ubuntu11indt2) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...

这个时候我们就可以安装依赖了.

$ sudo apt-get build-dep pulseaudio
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have unmet dependencies:
 libbluetooth-dev : Depends: libbluetooth3 (= 4.101-0ubuntu13.1) but 4.101.1-0indt2 is to be installed
 libjack-dev : Depends: libjack0 (= 1:0.121.3+20120418git75e3e20b-2.1ubuntu1) but it is not going to be installed
E: Build-dependencies for pulseaudio could not be satisfied.


因此我们还是得解决这个问题:

$ sudo dpkg -i libbluetooth-dev_4.101-0ubuntu13.1_amd64.deb 
Selecting previously unselected package libbluetooth-dev.
(Reading database ... 737260 files and directories currently installed.)
Preparing to unpack libbluetooth-dev_4.101-0ubuntu13.1_amd64.deb ...
Unpacking libbluetooth-dev (4.101-0ubuntu13.1) ...
dpkg: dependency problems prevent configuration of libbluetooth-dev:
 libbluetooth-dev depends on libbluetooth3 (= 4.101-0ubuntu13.1); however:
  Version of libbluetooth3:amd64 on system is 4.101.1-0indt2.

dpkg: error processing package libbluetooth-dev (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libbluetooth-dev

那好我们重复前面的方法, 手动来安装正确的libbluetooth-dev, 再次之前可以先卸装掉版本不对的:

$ sudo apt-get build-dep bluez
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libbluetooth-dev
0 upgraded, 0 newly installed, 1 to remove and 8 not upgraded.
1 not fully installed or removed.
After this operation, 409 kB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 737284 files and directories currently installed.)
Removing libbluetooth-dev (4.101-0ubuntu13.1) ...

然后再次查看一下:

$ sudo apt-get build-dep pulseaudio
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have unmet dependencies:
 libbluetooth-dev : Depends: libbluetooth3 (= 4.101-0ubuntu13.1) but 4.101.1-0indt2 is to be installed
E: Build-dependencies for pulseaudio could not be satisfied.

这个变成了libbluetooth3, 因此我们还需要卸装这个, 安装会原来的下面这个版本:
4.101-0ubuntu13.1
直接remove:

$ sudo apt-get remove libbluetooth-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'libbluetooth-dev' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libkutils4 libsamplerate0:i386 libspeexdsp1:i386 libswresample0
  linux-image-4.4.0-45-generic linux-image-extra-4.4.0-45-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
再次安装pulseaudio的依赖即可成功了:

$ sudo apt-get build-dep pulseaudio
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libasyncns-dev libatomic-ops-dev libbluetooth-dev libfftw3-bin libfftw3-dev
  libfftw3-long3 libfftw3-quad3 libgconf2-dev libjack-dev liblircclient-dev
  liborc-0.4-dev libsbc-dev libspeex-dev libspeexdsp-dev libsystemd-daemon-dev
  libsystemd-login-dev libtdb-dev libwrap0-dev libxtst-dev x11proto-record-dev
0 upgraded, 20 newly installed, 0 to remove and 8 not upgraded.
Need to get 4,055 kB of archives.
After this operation, 26.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

总结

当我们遇到依赖问题的时候, 最好先尝试自动解决,然后根据提示,一层层的找到相关的依赖是哪个出现了问题,然后再根据下面顺序手动的解决问题:

1. 卸装最末尾被依赖的(apt-get remove)

2. 安装原版的Ubuntu自带的版本Package (apt-get source ..., dpkg -i XXX)

3. 重复执行上面的1与2步骤

4. 如果无法获取,或者只需要更改某部分,那么自己使用build-dep与dpkg-buildpackage -uc -us -rfakeroot -b去编译,并安装解决问题.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ubuntu下面包依赖损坏的解决unmet dependencies 的相关文章

随机推荐

  • 样条插值曲线类型及其优缺点说明

    Spline Types This page gives a breakdown of each spline type how to use each one and the advantages disadvantages of eac
  • caffe layer层详解

    1 基本的layer定义 xff0c 参数 1 基本的layer定义 xff0c 参数 如何利用caffe定义一个网络 xff0c 首先要了解caffe中的基本接口 xff0c 下面分别对五类layer进行介绍 Vision Layers
  • caffe编译中的python问题

    问题 usr include boost python detail wrap python hpp 50 23 fatal error pyconfig h No such file or directory 解决方案 make clea
  • latex图像注释位置

    latex图像注释的位置在左边 不知道谁把模板里的 usepackage caption 给注释掉了
  • pytorch pretrained model

    pytorch pretrained model two methods method 1 比较大小 self span class token punctuation span model span class token operato
  • nodejs之minimist中间件使用

    minimist是nodejs的命令行参数解析工具 xff0c 因其简单好用 xff0c 轻量等特性 xff0c 所以用户使用较多 特性 xff1a short options long options Boolean 和 Number类型
  • RNA-seq 保姆教程:差异表达分析(一)

    介绍 RNA seq 目前是测量细胞反应的最突出的方法之一 RNA seq 不仅能够分析样本之间基因表达的差异 xff0c 还可以发现新的亚型并分析 SNP 变异 本教程 1 将涵盖处理和分析差异基因表达数据的基本工作流程 xff0c 旨在
  • 腾讯、阿里云服务器安装java全流程(yum安装java超简单详细版)

    有些服务器中自带了java xff0c 但不是你想要的版本的话 xff0c 可以先卸载掉 xff0c 然后更换想要的ava版本 因为是有网环境 xff0c 可以使用yum安装 无网环境可以参考我写的另一篇文章 xff1a linux无网环境
  • 某个牛人做WINDOWS系统文件详解

    某个牛人做WINDOWS系统文件详解 超牛 很详细介绍WINDOWS系统文件用途 想各位保存一份以后说定会有用 A ACCESS CHM Windows帮助文件 ACCSTAT EXE 辅助状态指示器 ADVAPI32 DLL 高级Win3
  • Nginx 流量统计分析

    目录 程序简介输出结果环境程序要求例子代码 程序简介 通过分析nginx日志 xff0c 统计出nginx流量 xff08 统计nginx日志中 body bytes sent 字段 xff09 xff0c 能自定义时间间隔 xff0c 默
  • 融资租赁业务系统(财务中台)

    融资租赁业务系统 财务中台 产品白皮书 版本号 xff1a V1 1 李雷 微信号 xff1a yanan122914 平台概述 融资租赁财务中台产品是一套专门针对融资租赁行业设计的融资租赁财务统一解决方案 对租赁公司传统的大单回租 直租
  • Session详解,学习 Session对象一篇文章就够了

    目录 1 Session概述 2 Session原理 3 Session使用 3 1 获取Session 3 2 Session保存数据 3 3 Session获取数据 3 4 Session移除数据 4 Session与Request应用
  • spring框架--全面详解(学习笔记)

    目录 1 Spring是什么 2 Spring 框架特点 3 Spring体系结构 4 Spring开发环境搭建 5 spring中IOC和DI 6 Spring中bean的生命周期 7 Spring Bean作用域 8 spring注解开
  • Caused by: java.lang.NoClassDefFoundError: io/seata/spring/annotation/datasource/SeataDataSourceBean

    在使用Spring Boot整合Seata实现分布式事务的时候报了这个错 当时在pom xml引入的spring cloud alibaba dependencies依赖包是2 2 2 RELEASE lt dependency gt lt
  • setup maven plugin connection

    setup maven plugin connection discover and map eclipse plugins to maven plugin goal executions 今天在创建maven工程时遇到了一个问题 工程在创
  • qt生成的exe到指定路径加载DLL文件

    qt编译生成的exe程序在打包依赖文件后 xff0c 如果同时又有其他dll文件时 xff0c 目录会看起来非常杂乱 我们可以通过将依赖文件放到某个路径下 xff0c 让exe程序在指定路径下加载 xff0c 此时需要用到qt 的qt co
  • PowerShell格式化显示(Format-Table Format-List)

    格式化 Format Format Wide Format List 常用 xff0c 显示的更加详细 Format Table 常用 AutoSize xff08 让表格更加紧凑 xff09 Format Custom 例子 xff1a
  • 使用VBA调用jar传递参数,并获取返回值

    目录 VBA代码 Java代码 运行效果 Excel Log效果 xff08 通过VBA调用jar后 xff0c 运行 xff0c 生成的Log xff09 课题 课题原因 xff08 直接原因 xff09 log4j的配置 课题验证 课题
  • 生产者与消费者模型&信号量

    6 生产者与消费者模型 6 1 123规则 1个线程安全的队列 只要保证先进先出的特性的数据结构都可以称之为队列 该队列需要保证互斥 xff0c 即同一时刻只能有一个线程对该安全队列进行操作还需要保证同步 xff0c 即生产者往安全队列生产
  • Ubuntu下面包依赖损坏的解决unmet dependencies

    2017 1 4 更新 在原来的文章中提到过使用gzip压缩changelog得到changelog debian gz 然后覆盖掉原来的 从而达到欺骗系统认为的软件包的版本问题 但是这样的话需要自己手动定位找到并且压缩 像pulseaud