apt build-dep 失败,无法找到源包,尽管 /etc/apt/sources.list.d 文件夹中存在 deb-src 行

apt build-dep 失败,无法找到源包,尽管 /etc/apt/sources.list.d 文件夹中存在 deb-src 行

我运行了它sudo apt-get build-dep emacs24并返回了错误:

Reading package lists... Done
E: Unable to find a source package for emacs24

现在我知道了这种情况下通常的建议,那就是取消文件夹中文件deb-src中的注释行(每.list/etc/apt/sources.list.dhttps://unix.stackexchange.com/questions/158395/apt-get-build-dep-is-unable-to-find-a-source-package)。不过我已经试过了!我的/etc/apt/sources.list.d文件夹中的每个文件都有未注释的 deb-src 行。我甚至sudo apt-get update在取消注释这些行后运行了!所以请帮助我。这是我的文件夹的内容/etc/apt/sources.list.d,如果您需要这些文件中的任何内容,只需说出来,我很乐意提供它们。

$ ls /etc/apt/sources.list.d
alexlarsson-ubuntu-flatpak-xenial.list
alexlarsson-ubuntu-flatpak-xenial.list.save
cpick-ubuntu-hub-xenial.list
cpick-ubuntu-hub-xenial.list.save
damien-moore-ubuntu-codeblocks-stable-xenial.list
damien-moore-ubuntu-codeblocks-stable-xenial.list.save
danielrichter2007-ubuntu-grub-customizer-xenial.list
danielrichter2007-ubuntu-grub-customizer-xenial.list.save
docker.list
docker.list.save
dolik-rce-ubuntu-upp-xenial.list
dolik-rce-ubuntu-upp-xenial.list.save
dotnetdev.list
dotnetdev.list.save
gnome3-team-ubuntu-gnome3-staging-xenial.list
gnome3-team-ubuntu-gnome3-staging-xenial.list.save
gnome3-team-ubuntu-gnome3-xenial.list
gnome3-team-ubuntu-gnome3-xenial.list.save
google-chrome.list
google-chrome.list.save
google-earth.list
google-earth.list.save
icons.list
icons.list.save
jonathonf-ubuntu-golang-xenial.list
jonathonf-ubuntu-golang-xenial.list.save
kubuntu-ppa-ubuntu-backports-xenial.list
kubuntu-ppa-ubuntu-backports-xenial.list.save
mmk2410-ubuntu-eclipse-ide-java-xenial.list
mmk2410-ubuntu-eclipse-ide-java-xenial.list.save
mono-jenkins.list
mono-jenkins.list.save
mono-xamarin.list
mono-xamarin.list.save
nodesource.list
nodesource.list.save
noobslab-ubuntu-macbuntu-xenial.list
noobslab-ubuntu-macbuntu-xenial.list.save
notepadqq-team-ubuntu-notepadqq-xenial.list
notepadqq-team-ubuntu-notepadqq-xenial.list.save
runescape.list
runescape.list.save
saiarcot895-ubuntu-myppa-xenial.list
saiarcot895-ubuntu-myppa-xenial.list.save
spotify.list
spotify.list.save
trinity.list
trinity.list.save
ubuntu-elisp-ubuntu-ppa-xenial.list
ubuntu-elisp-ubuntu-ppa-xenial.list.save
unity8-desktop-session-team-ubuntu-unity8-preview-lxc-xenial.list
wine-ubuntu-wine-builds-xenial.list
wine-ubuntu-wine-builds-xenial.list.save

如果相关的话,并且您无法通过我提供的先前信息判断,我在 Ubuntu 16.04.1 上操作。

答案1

您需要取消deb-src注释主要的源文件/etc/apt/sources.list,而不是额外的文件/etc/apt/sources.list.d

例如,更改:

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

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

然后更新本地数据库:

sudo apt update

然后继续:)

答案2

software-properties-gtk选项“源代码”

从 GUI,您可以运行:

software-properties-gtk

然后在“Ubuntu 软件”选项卡下单击“源代码”:

在此处输入图片描述

这已添加了一些deb-src/etc/apt/sources.list,现在我可以这样做了sudo apt-get build-dep <package>

在 Ubuntu 16.04 至 18.04 上测试。

CLI 方法

sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update

在 Ubuntu 18.04 Docker 镜像上进行了测试。经过此更改后,我可以成功执行以下操作:

sudo apt-get build-dep hello

并且在更改之前它失败并出现错误:

E: You must put some 'source' URIs in your sources.list

相关内容