Linux 我如何获得 Ubuntu 源代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4767821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get the Ubuntu source code?
提问by Tom
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 文件吗?
回答by orlp
- archive.ubuntu.com
- 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
andLICENSE
.
- 存档.ubuntu.com
- 它们中的大多数是 .c 和 .h 文件(不确定 C++),但肯定不是全部(一些 perl,一些 Python 等)。还会有很多文档文件不是用 .txt 保存的,就像
README
和一样LICENSE
。
回答by bdonlan
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 source
,则需要手动将补丁应用到源代码。甚至新式包被分成多个包。
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, reallywant all of it, and I can't stress enough how silly it would be to download everythingjust 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 main
为-s main,universe,multiverse,restricted
以获取所有内容。
Once you have the package files, you can extract the source by running dpkg-source -x
on a .dsc file of interest.
获得包文件后,您可以通过运行dpkg-source -x
感兴趣的 .dsc 文件来提取源代码。