我在 Raspbian 上把我的 apt 砖砌了

我在 Raspbian 上把我的 apt 砖砌了

我试图在 Raspbian Buster 安装上更新我的 npm。包管理器提供的版本不够。

首先我遵循了一些建议这个线程然后尝试使用升级到 Bullseye这些说明

我不完全确定这是在尝试升级到 Bullseye 之前还是之后开始的,但现在每当我运行时sudo apt install <anything>它都会告诉我它无法安装任何依赖项。当我尝试重新安装已安装的软件包时,出现无法下载该软件包的错误。下面是两个例子:

% sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nodejs : Depends: libnode72 (= 12.22.12~dfsg-1~deb11u4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
% sudo apt reinstall vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reinstallation of vim is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

系统已全面更新和升级(据我所知):

% sudo apt update && sudo apt full-upgrade && sudo apt dist-upgrade
Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

似乎没有包裹被搁置:

% sudo apt-mark showhold
%

我尝试了互联网上建议的各种修复方法:

% sudo apt --fix-broken install
%

% sudo dpkg --configure -a
%

没有结果。我还在 /etc/apt/sources.list.d 中将一些 *.list 文件重命名为 *.list.bak,但我相信我只是在问题开始后才这样做并试图解决它。

如何恢复我的包管理器以使其再次可用?

编辑:

输出apt policy nodejs

% sudo apt policy nodejs
nodejs:
  Installed: (none)
  Candidate: 12.22.12~dfsg-1~deb11u4
  Version table:
     12.22.12~dfsg-1~deb11u4 50
         50 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages

/etc/apt/sources.list 的内容

% cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

输出uname -m

% uname -m                                                                                                                                                                                                              
armv7l

输出lsb_release -a

% lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

值得注意的是:它仍然被列为破坏者,而不是靶心。

进度编辑: 所以,我上面提到我遵循这些说明尝试升级我的 npm。我相信这在sources.list.d 中添加了一个条目,我已再次禁用它。再次启用此条目允许我运行apt install nodejs。我尝试安装其他一些软件包,例如sudo apt install cowsay成功了。然后我继续尝试重新安装那些sudo apt reinstall cowsay也成功的新软件包。尝试重新安装之前安装的软件包仍然失败,并显示无法下载软件包的消息。然而,当我手动卸载并重新安装该包时,它成功了:sudo apt remove nano && sudo apt install nano。手动卸载并安装后重新安装现在成功:sudo apt reinstall nano

但是,尝试安装其他软件包仍然失败。例如,安装 npm 失败,并出现一长串node-*依赖项(包括我刚刚手动安装的 Nodejs)。另外,尝试安装例如 aptitude (在某些来源中推荐它可能能够恢复损坏的 apt 系统)失败:

% sudo apt install aptitude
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 aptitude : Depends: libapt-pkg6.0 (>= 1.9.0) but it is not going to be installed
            Depends: libstdc++6 (>= 9) but 8.3.0-6+rpi1 is to be installed
            Depends: libxapian30 (>= 1.4.17~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

因此,虽然取得了一些进展(能够安装 Nodejs),但我仍然没有摆脱困境。

答案1

不同的存储库和 URL 有何不同?

大概您已经在较新的 Pi 上安装了 Raspberry Pi OS 64 位。它使用标准 Debian ARM64 存储库而不是 Raspbian。固件仍然由 Raspberry Pi Ltd. 提供,32/64 位源相同

尝试这个:

deb http://archive.raspberrypi.org/debian/ bullseye main

检查此:

将您的 Raspberry Pi 升级到 Bullseye

Raspbian 32 位与 64 位 - 非常不同的 apt 来源.list

Raspberry PI OS/Debian 11 Bullseye APT 存储库

或者试试这个:

/etc/apt/sources.list

deb http://mirrordirector.raspbian.org/raspbian/ bullseye main contrib non-free rpi

/etc/apt/sources.list.d/raspi.list

deb http://archive.raspberrypi.org/debian/ bullseye main

更新:

apt-get update

apt-get dist-upgrade

清洁和去除:

apt-get autoremove

apt-get autoclean

编辑/更新:

  1. 备份/etc/apt//var/lib/apt/lists/

  2. 删除或移动您的修改列表条目

mv /etc/apt/sources.list.d/MY_FILES.list /BACKUP/

  1. 删除现有的包列表并清理包缓存

rm -rf /var/lib/apt/lists/*

apt clean

  1. sources.list从备份恢复原始版本或使用默认值创建一个sources.list

cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list

  1. 更新

apt update

  1. 重新安装基础包

apt --reinstall install raspberrypi-sys-mods raspberrypi-kernel raspberrypi-bootloader

如果您对系统进行了大量更改,则可能需要重新安装操作系统。

相关内容