如何通过 Apt 下载最新稳定的 Ubuntu 内核源?

如何通过 Apt 下载最新稳定的 Ubuntu 内核源?

到目前为止我做了以下事情:

  1. 我已经注释掉了deb-src/etc/apt/sources.list相关邮政)。
  2. 跑步sudo apt-get update

现在我试图获取当前的内核源代码Ubuntu 的维基页面

$ sudo apt-get source linux-image-$(uname -r)
Reading package lists... Done
Picking 'linux-signed' as source package instead of 'linux-image-4.18.0-13-generic'
Skipping already downloaded file 'linux-signed_4.18.0-13.14.dsc'
Skipping already downloaded file 'linux-signed_4.18.0-13.14.tar.xz'
Need to get 0 B of source archives.
Skipping unpack of already unpacked source in linux-signed-4.18.0

$ sudo apt-get source linux-source
Reading package lists... Done
Picking 'linux-meta' as source package instead of 'linux-source'
NOTICE: 'linux-meta' packaging is maintained in the 'Git' version control system at:
git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-meta/+git/cosmic
Please use:
git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-meta/+git/cosmic
to retrieve the latest (possibly unreleased) updates to the package.
Skipping already downloaded file 'linux-meta_4.18.0.13.14.dsc'
Skipping already downloaded file 'linux-meta_4.18.0.13.14.tar.xz'
Need to get 0 B of source archives.
Skipping unpack of already unpacked source in linux-meta-4.18.0.13.14

$ ls /usr/src
linux-headers-4.18.0-12  linux-headers-4.18.0-12-generic  linux-headers-4.18.0-13  linux-headers-4.18.0-13-generic

但它没有下载任何东西。

之前运行apt-get clean package_name命令source也无济于事。

我遗漏了什么?

答案1

根据反馈,这是将当前内核源下载到的正确命令/usr/src

sudo apt-get install linux-source

以下是提取源文件的命令:

cd /usr/src/linux-source-$(uname -r | cut -f1 -d-)
sudo tar jxvf linux-source-*.tar.bz2

答案2

$ apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-4.4.0 - Linux kernel source for version 4.4.0 with Ubuntu patches
linux-source-4.10.0 - Linux kernel source for version 4.10.0 with Ubuntu patches
linux-source-4.11.0 - Linux kernel source for version 4.11.0 with Ubuntu patches
linux-source-4.13.0 - Linux kernel source for version 4.13.0 with Ubuntu patches
linux-source-4.15.0 - Linux kernel source for version 4.15.0 with Ubuntu patches
linux-source-4.8.0 - Linux kernel source for version 4.8.0 with Ubuntu patches
walt@bat:~(0)$ dpkg -L linux-source-4.13.0 
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/linux-source-4.13.0
/usr/share/doc/linux-source-4.13.0/changelog.Debian.gz
/usr/share/doc/linux-source-4.13.0/copyright
/usr/src
/usr/src/linux-source-4.13.0
/usr/src/linux-source-4.13.0/linux-source-4.13.0.tar.bz2
/usr/src/linux-source-4.13.0/debian
/usr/src/linux-source-4.13.0/debian/debian.env
/usr/src/linux-source-4.13.0/debian/tests-build
/usr/src/linux-source-4.13.0/debian/tests-build/README

   <...snip...>  

/usr/src/linux-source-4.13.0/debian.hwe/control.stub.in
/usr/src/linux-source-4.13.0/debian.hwe/modprobe.d
/usr/src/linux-source-4.13.0/debian.hwe/modprobe.d/common.conf
/usr/src/linux-source-4.13.0/debian.hwe/copyright
/usr/src/linux-source-4.13.0.tar.bz2

请注意,最后一项/usr/src/linux-source-4.13.0.tar.bz2是包含源代码的bzip压缩档案。tar

您的版本号可能会有所不同。

答案3

apt-get source将源包下载到当前目录,而不是/usr/src

此外,由于当前目录通常可由您写入,apt-get source因此不需要,也不应该使用 运行sudo

相关内容