使用 apt 安装或升级时出错

使用 apt 安装或升级时出错

我试图将 debian 9 升级到 10,但是当我尝试运行 sudo apt-get update、sudo apt-get Upgrade 和 sudo apt-get full-upgrade 时,它​​们都收到以下错误消息:

    optiplex@optiplex:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-image-generic-lts-xenial : Depends: linux-firmware but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我尝试跑步

apt --fix-broken install

但后来我收到了这个错误消息:

 optiplex@optiplex:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  linux-image-4.9.0-8-amd64
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  linux-firmware
The following NEW packages will be installed:
  linux-firmware
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
3 not fully installed or removed.
Need to get 0 B/33.9 MB of archives.
After this operation, 127 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  linux-firmware
Install these packages without verification? [y/N] y
(Reading database ... 514688 files and directories currently installed.)
Preparing to unpack .../linux-firmware_1.127.24_all.deb ...
Unpacking linux-firmware (1.127.24) ...
dpkg: error processing archive /var/cache/apt/archives/linux-firmware_1.127.24_all.deb (--unpack):
 trying to overwrite '/lib/firmware/cis/PE-200.cis', which is also in package firmware-linux-free 3.4
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/linux-firmware_1.127.24_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

有人可以帮我解决这个问题吗?


编辑:

我正在查看 GAD3R 给出的说明,但这次每当我尝试使用 apt 执行任何操作时,我都会收到略有不同的错误消息:

    dpkg: error processing package snapd (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑2:

我已经尽力了,apt-get upgrade 但我不断收到错误:

... Selecting previously unselected package x11proto-dev.
Preparing to unpack .../513-x11proto-dev_2018.4-4_all.deb ...
Unpacking x11proto-dev (2018.4-4) ...
Preparing to unpack .../514-xbrlapi_5.6-10_amd64.deb ...
Unpacking xbrlapi (5.6-10) over (5.4-7+deb9u1) ...
Preparing to unpack .../515-xscreensaver-data_5.42+dfsg1-1_amd64.deb ...
Unpacking xscreensaver-data (5.42+dfsg1-1) over (5.36-1) ...
Preparing to unpack .../516-xscreensaver-gl_5.42+dfsg1-1_amd64.deb ...
Unpacking xscreensaver-gl (5.42+dfsg1-1) over (5.36-1) ...
Preparing to unpack .../517-xserver-xephyr_2%3a1.20.4-1_amd64.deb ...
Unpacking xserver-xephyr (2:1.20.4-1) over (2:1.19.2-1+deb9u5) ...
Preparing to unpack .../518-xterm_344-1_amd64.deb ...
Unpacking xterm (344-1) over (327-2) ...
Errors were encountered while processing:
 /tmp/apt-dpkg-install-3w5XWy/270-libel-api-java_3.0.0-2_all.deb
 /tmp/apt-dpkg-install-3w5XWy/303-libjsp-api-java_2.3.4-2_all.deb
 /tmp/apt-dpkg-install-3w5XWy/361-libwebsocket-api-java_1.1-1_all.deb
 /tmp/apt-dpkg-install-3w5XWy/433-plymouth_0.9.4-1.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我在 Optiplex 755 PC 上运行 Debian 9

感谢您的时间!

尼古拉.

答案1

要将 Debian 9 升级到 10,您应该具有仅有的您的以下几行/etc/apt/sources.list

deb http://deb.debian.org/debian buster main
deb http://deb.debian.org/debian-security/ buster/updates main
deb http://deb.debian.org/debian buster-updates main

禁用目录下的第三方存储库/etc/apt/sources.list.d/

在您的情况下,您启用了 ubuntu-xenial 存储库(它提供了软件包linux-image-generic-lts-xenial),它将破坏您的系统。

然后运行:

sudo apt update
sudo apt install linux-image-amd64
sudo apt upgrade
sudo apt dist-upgrade

正如所说@斯蒂芬·基特linux-firmware_1.127.24_all.deb属于 Ubuntu Trusty 导致的error code (1),应该将其删除:apt purge linux-firmware

解决以下错误(post-removal脚本):

Errors were encountered while processing:
/var/cache/apt/archives/linux-firmware_1.127.24_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑该/var/lib/dpkg/info/linux-firmware.postrm文件并将其内容替换为:

#!/bin/bash
/bin/true

解决以下错误(post-installation脚本):

subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑/var/lib/dpkg/info/snapd.postinst如下:

#!/bin/bash
/bin/true

更新

备份文件/var/lib/dpkg/status/var/lib/dpkg/status-old然后将其替换statusstatus-old

sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.bak1
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status-old.bak1
sudo mv /var/lib/dpkg/status-old /var/lib/dpkg/status

然后运行:

sudo dpkg --configure -a
sudo apt clean
sudo apt autoclean
sudo apt update 
sudo apt upgrade

答案2

好的,

我已经编辑了 resources.list 文件,现在它看起来像这样:

    #deb http://security.debian.org/debian-security stretch/updates main non-free contrib
#deb-src http://security.debian.org/debian-security stretch/updates main non-free contrib

# stretch-updates, previously known as 'volatile'
#deb http://ftp.au.debian.org/debian/ stretch-updates main non-free contrib
#deb-src http://ftp.au.debian.org/debian/ stretch-updates main non-free contrib

#deb http://ftp.debian.org/debian stretch-backports main

#deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse 
#deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse 
#deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse 
#deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse 
#deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://deb.debian.org/debian buster main
deb http://deb.debian.org/debian-security/ buster/updates main
deb http://deb.debian.org/debian buster-updates main

我查看了sources.list.d

里面有许多存储库:

google-chrome.list
google-chrome.list.save
oibaf-ubuntu-graphics-drivers-eoan.list
oibaf-ubuntu-graphics-drivers-eoan.list.save
qucs-ubuntu-qucs-disco.list
qucs-ubuntu-qucs-disco.list.save
stretch-backports.list
stretch-backports.list.save
ubuntu-x-swat-ubuntu-updates-eoan.list
ubuntu-x-swat-ubuntu-updates-eoan.list.save
webupd8team-ubuntu-brackets-eoan.list
webupd8team-ubuntu-brackets-eoan.list.save

我打开并检查了所有这些,但没有一个有linux-image-generic-lts-xenial名字。我怀疑那些名字中带有 ubuntu 的人也可能是罪魁祸首。我也尝试运行,apt purge linux-firmware但出现了与以前相同的错误。

相关内容