0

So far I did the following:

  1. I've commented out deb-src lines in /etc/apt/sources.list (related post).
  2. Run sudo apt-get update.

Now I'm trying to obtain the current kernel sources as Ubuntu's wiki page:

$ 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

But it doesn't download anything.

Running apt-get clean package_name command before source, doesn't help either.

What I'm missing?

  • You are not at all following the instructions of the link you posted... – fkraiem Jan 6 at 20:45
  • @fkraiem I'm trying to obtain the sources, not build, so I don't need to follow all the instructions. – kenorb Jan 6 at 21:08
1
$ 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

Notice the last entry /usr/src/linux-source-4.13.0.tar.bz2 is a bzip-compressed tar archive that contains the source.

Your version numbers may vary.

1

apt-get source downloads the source package to the current directory, not to /usr/src.

Moreover, since the current directory is typically writable by you, apt-get source need not, and therefore should not, be run with sudo.

  • Ok, I missed that, I was expecting in /usr/src, on the other hand the files are just config files (in linux-signed-4.18.0/), I was expecting Linux sources which I can edit and compile, so I didn't expect that. Will review the steps again, as they're confusing. Not as they normally should be in a standard Linux. Thanks. – kenorb Jan 6 at 22:08
0

Based on the feedback, this is the right command to download the current kernel sources into /usr/src:

sudo apt-get install linux-source

Here are the commands to extract the source files:

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.