如何获得Ubuntu源代码?

时间:2022-06-07 20:44:39

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

我在哪里可以找到最新Ubuntu版本的源代码?

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

另外,我如何查看代码?我可以在Visual Studio中查看很多。cpp和。h文件吗?

2 个解决方案

#1


17  

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:

ubuntu的源代码是按包划分的——从运行的ubuntu系统中,你可以通过以下操作轻松地获取任何包的源代码:

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

否则,到launchpad中,搜索相关的软件包。例如,这里有一个特定版本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.

也就是说,如果您已经在Linux系统上了,那么这就容易得多了——包源代码被分为原始的源tarball和ubuntu补丁,所以如果您不使用apt-get源代码,您将需要手动地将补丁应用到源代码中。而且新样式的包甚至被分为多个包。

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.

更重要的是,这些包通常不是设计来从非linux系统中交叉编译的。即使你下载并在VS中打开它们,你也无法从Windows系统中构建它们。

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 :)

最后,请注意,并不是所有东西都在C和c++中——您可以想象任何语言都有包。但我想大多数都可以在VS中打开作为文本文件:)

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工具,在ubuntu中可用,来做这个:

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.

这绝对是一个巨大的下载。有几十gb的可用空间。注意,这下载的只是核心包-用-s主包替换-s主包,宇宙,多重宇宙,限制获得一切。

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

一旦有了包文件,就可以通过在感兴趣的.dsc文件上运行dpkg-source -x来提取源代码。

#2


7  

  1. archive.ubuntu.com
  2. archive.ubuntu.com
  3. 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.
  4. 它们中的大多数都是. C和.h文件(不确定c++),但肯定不是全部(一些perl,一些Python等等)。还有许多文档文件没有使用.txt保存,就像README和LICENSE一样。

#1


17  

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:

ubuntu的源代码是按包划分的——从运行的ubuntu系统中,你可以通过以下操作轻松地获取任何包的源代码:

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

否则,到launchpad中,搜索相关的软件包。例如,这里有一个特定版本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.

也就是说,如果您已经在Linux系统上了,那么这就容易得多了——包源代码被分为原始的源tarball和ubuntu补丁,所以如果您不使用apt-get源代码,您将需要手动地将补丁应用到源代码中。而且新样式的包甚至被分为多个包。

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.

更重要的是,这些包通常不是设计来从非linux系统中交叉编译的。即使你下载并在VS中打开它们,你也无法从Windows系统中构建它们。

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 :)

最后,请注意,并不是所有东西都在C和c++中——您可以想象任何语言都有包。但我想大多数都可以在VS中打开作为文本文件:)

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工具,在ubuntu中可用,来做这个:

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.

这绝对是一个巨大的下载。有几十gb的可用空间。注意,这下载的只是核心包-用-s主包替换-s主包,宇宙,多重宇宙,限制获得一切。

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

一旦有了包文件,就可以通过在感兴趣的.dsc文件上运行dpkg-source -x来提取源代码。

#2


7  

  1. archive.ubuntu.com
  2. archive.ubuntu.com
  3. 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.
  4. 它们中的大多数都是. C和.h文件(不确定c++),但肯定不是全部(一些perl,一些Python等等)。还有许多文档文件没有使用.txt保存,就像README和LICENSE一样。