Ubuntu 22.04 LTS构建内核时修复损坏依赖包问题
问题背景
系统版本:Ubuntu 22.04 LTSuname -a 输出:
Linux _ 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
执行内核构建依赖安装命令:
sudo apt-get build-dep linux linux-image-$(uname -r)
触发以下错误:
Reading package lists... Done
Picking 'linux-signed' as source package instead of 'linux-image-5.15.0-67-generic'
Reading package lists... Done
Building dependency tree... Done
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:
builddeps:linux-signed : Depends: linux-image-unsigned-5.15.0-67-generic (= 5.15.0-67.74) but it is not going to be installed
Depends: linux-generate (= 5.15.0-67.74) but it is not installable
E: Unable to correct problems, you have held broken packages.
已取消所有deb-src行注释并执行sudo apt update,当前/etc/apt/sources.list内容:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://ports.ubuntu.com/ubuntu-ports jammy main restricted deb-src http://ports.ubuntu.com/ubuntu-ports jammy main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted deb-src http://ports.ubuntu.com/ubuntu-ports jammy-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://ports.ubuntu.com/ubuntu-ports jammy universe deb-src http://ports.ubuntu.com/ubuntu-ports jammy universe deb http://ports.ubuntu.com/ubuntu-ports jammy-updates universe deb-src http://ports.ubuntu.com/ubuntu-ports jammy-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://ports.ubuntu.com/ubuntu-ports jammy multiverse deb-src http://ports.ubuntu.com/ubuntu-ports jammy multiverse deb http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse deb-src http://ports.ubuntu.com/ubuntu-ports jammy-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://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse deb-src http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse deb http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted deb http://ports.ubuntu.com/ubuntu-ports jammy-security universe deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security universe deb http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
解决步骤
修正依赖包名称并安装指定版本
错误提示中的linux-generate是拼写错误,实际应为linux-generic。执行以下命令安装缺失的指定版本依赖:sudo apt install linux-image-unsigned-5.15.0-67-generic=5.15.0-67.74 linux-generic=5.15.0-67.74重新安装内核构建依赖
依赖问题解决后,重新运行构建依赖安装命令:sudo apt-get build-dep linux linux-image-$(uname -r)修复系统损坏包(可选)
如果仍存在问题,执行以下命令修复系统中损坏的包并更新:sudo apt --fix-broken install sudo apt update && sudo apt upgrade -y确认源码仓库配置
你的sources.list配置已包含所有必要的deb-src仓库,无需额外修改。
内容的提问来源于stack exchange,提问作者realzhujunhao

