如何获取和修改通过apt-get安装的软件包的源代码?

Modified on: Sat, 09 Jun 2018 17:48:53 +0800

我假设通过apt-get安装的所有应用程序都是开源的;但对于那些以这种方式可用的那些,我在哪里可以获得这些应用程序的源代码并更新它们?

我有一些我经常使用的应用程序,这些应用程序不再被开发,我想添加功能。我将在哪里获得更新这些应用程序的权利?

具体来说,在这种情况下,我指的是hellanzb

最佳答案

使用命令apt-get source <package>(不要使用sudo)下载软件包的源代码。

来自man apt-get

   source
       source causes apt-get to fetch source packages. APT will examine the
       available packages to decide which source package to fetch. It will then
       find and download into the current directory the newest available version of
       that source package while respect the default release, set with the option
       APT::Default-Release, the -t option or per package with the pkg/release
       syntax, if possible.

       Source packages are tracked separately from binary packages via deb-src type
       lines in the sources.list(5) file. This means that you will need to add such
       a line for each repository you want to get sources from. If you don't do
       this you will properly get another (newer, older or none) source version
       than the one you have installed or could install.

       If the --compile option is specified then the package will be compiled to a
       binary .deb using dpkg-buildpackage, if --download-only is specified then
       the source package will not be unpacked.

       A specific source version can be retrieved by postfixing the source name
       with an equals and then the version to fetch, similar to the mechanism used
       for the package files. This enables exact matching of the source package
       name and version, implicitly enabling the APT::Get::Only-Source option.

       Note that source packages are not tracked like binary packages, they exist
       only in the current directory and are similar to downloading source tar
       balls.

要从源构建包,首先安装构建依赖项:

sudo apt-get build-dep <package>  

然后使用dpkg-buildpackage创建.deb文件。来自APT和Dpkg快速参考表

  

dpkg-buildpackage从Debian源代码树构建Debian软件包。您必须位于源树的主目录中才能使其正常工作。样品用法:

 dpkg-buildpackage -rfakeroot -uc -b

  
  

-rfakeroot指示它使用fakeroot程序模拟root权限(出于所有权目的),-uc代表“不加密签名更改日志” ,-b代表“仅构建二进制包”

在终端中,cd进入包含源包的目录(例如~/code/hellanzb-0.13)并运行以下命令:

dpkg-buildpackage -rfakeroot -uc -b

如果构建成功,则会在父代中存在.deb文件
 目录(例如~/code/hellanzb_0.13-6.1_all.deb)。

作者:,Isaiah

相关问答

添加新评论