到目前为止我做了以下事情:
- 我已经注释掉了
deb-src
(/etc/apt/sources.list
相关邮政)。 - 跑步
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
。