Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Ubuntu source code?

Where can I find the source code for the latest Ubuntu release?

Also, how would I view the code? Would it just be lots of .cpp and .h files I could view in Visual Studio?

like image 467
Tom Avatar asked Jan 22 '11 12:01

Tom


People also ask

Where can I get Linux source code?

The current Linux source code is always available in both a complete tarball (an archive created with the tar command) and an incremental patch from the official home of the Linux kernel, http://www.kernel.org.

How do I find my kernel source code?

If the kernel source code is present in your system, you can find it under the /usr/src/linux-<Version> directory, where <Version> must be replaced with the source code kernel version you are dealing with. You also can find the last kernel source code at https://github.com/torvalds/linux.

Is Ubuntu source free?

In the spirit of open source, Ubuntu is absolutely free to download, use, share and improve however and whenever you like.

What is Ubuntu source?

The kernel source for the Ubuntu kernel is based very closely on the upstream mainline kernel tree maintained by Linus. The Ubuntu-ness of this kernel is maintained as a git branch against the Linus tree.


2 Answers

The source code for ubuntu is divided up by package - from a running ubuntu system you can easily retreive the source for any package by doing:

apt-get source (package name)

Otherwise, go to launchpad, and search up the package in question. For example, here's the download page for the source code for a specific version of curl: https://launchpad.net/ubuntu/+source/curl/7.21.2-4ubuntu1

That said, it's a lot easier if you're on a Linux system already - the package sources are divided into an original source tarball plus ubuntu patches, so if you don't use apt-get source, you'll need to manually apply the patch to the source code. And new-style packages are even divided into multiple packages.

What's more, the packages are generally not designed to be cross-compiled from a non-Linux system. Even if you download them and open them in VS, you won't be able to build them from a Windows system.

Finally, note that not everything is in C and C++ - there are packages in just about any language you can imagine. But I suppose most of them could be opened in VS as text files :)

Note: If you really, really want all of it, and I can't stress enough how silly it would be to download everything just to start learning about the system, you can use the debmirror tool, available in ubuntu, to do this:

debmirror -a none \
          --source \
          -s main \
          -d lucid,lucid-security,lucid-updates \
          -r /ubuntu \ 
          --progress \
          -e http \
          -h archive.ubuntu.com \ ## or other ubuntu archive mirror
          destpath

This will be an absolutely huge download. Have several tens of GBs of space available. Note that this downloads only core packages - replace -s main with -s main,universe,multiverse,restricted to get everything.

Once you have the package files, you can extract the source by running dpkg-source -x on a .dsc file of interest.

like image 93
bdonlan Avatar answered Oct 18 '22 22:10

bdonlan


  1. archive.ubuntu.com
  2. Most of them are .c and .h files (not sure about C++), but certainly not all (some perl, some Python, etc). There will also be a lot of documentation files that aren't saved with .txt, just like README and LICENSE.
like image 29
orlp Avatar answered Oct 18 '22 22:10

orlp