5.3. 源软件包的结构

5.3.1. 格式

A source package is usually comprised of three files, a .dsc, a .orig.tar.gz, and a .debian.tar.xz (or .diff.gz). They allow creation of binary packages (.deb files described above) from the source code files of the program, which are written in a programming language.

.dsc (Debian Source Control) 文件是包括 RFC 2822 标头 (如同 control 文件于 第 5.2.1 节 “描述:control 文件”) 的简短文本档,描述原始软件包及包括的其他文件。由维护者签署,保证其真实性。详情见 第 6.6 节 “检查软件包真伪”

例 5.1. 一个.dsc 文件

  1. -----BEGIN PGP SIGNED MESSAGE-----
  2. Hash: SHA512
  3.  
  4. Format: 3.0 (quilt)
  5. Source: zim
  6. Binary: zim
  7. Architecture: all
  8. Version: 0.68-1
  9. Maintainer: Zim Package Maintainers <zim@packages.debian.org>
  10. Uploaders: Raphaël Hertzog <hertzog@debian.org>
  11. Homepage: http://zim-wiki.org
  12. Standards-Version: 4.1.3
  13. Vcs-Browser: https://salsa.debian.org/debian/zim
  14. Vcs-Git: https://salsa.debian.org/debian/zim.git
  15. Build-Depends: debhelper (>= 11), xdg-utils, python (>= 2.6.6-3~), libgtk2.0-0 (>= 2.6), python-gtk2, python-xdg, dh-python
  16. Package-List:
  17. zim deb x11 optional arch=all
  18. Checksums-Sha1:
  19. a3b50aa8e44126cc7edd2c1912adf9820f50ad58 2044224 zim_0.68.orig.tar.gz
  20. 4e13b37625789334da2d95b93e51e41ffd3b6b01 9300 zim_0.68-1.debian.tar.xz
  21. Checksums-Sha256:
  22. d91518e010f6a6e951a75314138b5545a4c51151fc99f513aa7768a18858df15 2044224 zim_0.68.orig.tar.gz
  23. 23f4ddc69af74509932acc3b5f0d4cd2af943016e4fd5740b9d98ec4d49fd8c2 9300 zim_0.68-1.debian.tar.xz
  24. Files:
  25. 336041a16687abb66fd9f604b98407e8 2044224 zim_0.68.orig.tar.gz
  26. 1714f67b35ab69e709849ad707206ca8 9300 zim_0.68-1.debian.tar.xz
  27.  
  28. -----BEGIN PGP SIGNATURE-----
  29. Comment: Signed by Raphael Hertzog
  30.  
  31. iQEzBAEBCgAdFiEE1823g1EQnhJ1LsbSA4gdq+vCmrkFAlqyOxkACgkQA4gdq+vC
  32. mrnCqAf/Ww9wg97VragtVhSFvehoVoJ0ZhoqNaSuCP/W1Fuf+P0YklzL2BlkVRXW
  33. X23c8Qs1v6VE2iRY3mEkdWwgBs1QwF0MX7H1jjQfPHCynGHKlH5dfo5fqLizgCeu
  34. c9Pug3ZisjF90CgsseO7SVDqHVmO6QsfAaGWpHAw92HDz/xwjrS/4Ejntqjy0b+r
  35. Gmw2AZuBdhp+7C6p7In/Gg6DHPBLQGMLCKypoZKQdl+L0fWjjeykOzMIbjry2sRH
  36. H0J4FLVGAGumh3zIZlm/t3ehGfP9Dg8FvzMaCNsf8OtYCSAEutrQEDBaskcTSIpq
  37. L0GQhKlViDuu8gzsqm7efPEhPcsF1A==
  38. =6jGR
  39. -----END PGP SIGNATURE-----

需要注意的是源码包也有依赖性(编译-依赖),和那些二进制包依赖完全不同,因为它们需要设置编译软件所需工具的选项后,再来构建二进制包。

当心 不同的命名空间

需注意,原始软件包与其产生的可运行软件包间,不需使用对应的名称。每个原始软件包可能产生多个可运行软件包。所以 .dsc 文件有 SourceBinary 字段记录原始软件包的名称与其产生的可运行软件包清单。

文化 为什么要分成几个软件包

通常,一个源代码软件包 (对于一个指定软件来说) 可产生多个二进制软件包。分开多个二进制包,可以满足在不同的环境使用 (部分) 软件。对于一个共享库,安装它后,可以让一个于应用程序工作 (如,libc6);或者安装后,可以用来开发一个新的程序 (libc6-dev 就是这样的软件包)。在客户端-服务端服务里发现同样的逻辑,在一部机器安装服务端的内容同时在另部机器安装客户端的内容 (例如: openssh-server 与 openssh-client)。

一样频繁的是,在一个专用的软件包提供文档:用户可以不依赖软件包而独立安装文档包,并且可以在任何时候选择删除掉以节省磁盘空间。此外,这也节省了 Debian 镜像的磁盘空间,因为在所有的架构中(而不是在每个架构中都复制一个一样的文档软件包)将共享这个文档软件包。

洞察不同格式的源码包

本来只有一个原始的软件包格式,像1.0这样的格式,它关联了.orig.tar.gz.diff.gz“Debian化”的补丁(还有一个变种,由一个单一的.tar.gz归档,当.orig.tar.gz不可用时它会自动使用。).

Since Debian 6 Squeeze, Debian developers have the option to use new formats that correct many problems of the historical format. Format 3.0 (quilt) can combine multiple upstream archives in the same source package: in addition to the usual .orig.tar.gz, supplementary .orig-*component*.tar.gz archives can be included. This is useful with software that is distributed in several upstream components but for which a single source package is desired. These archives can also be compressed with xz rather than gzip, which saves disk space and network resources. Finally, the monolithic patch, .diff.gz is replaced by a .debian.tar.xz archive containing the compiling instructions and a set of upstream patches contributed by the package maintainer. These last are recorded in a format compatible with quilt — a tool that facilitates the management of a series of patches.

.orig.tar.gz 文件包括原开发者提供的源代码。要求 Debian 的软件包维护者不要修改它,以便检查原来的文件与集成后的文件 (比较校验码就知道) 并且尊重其他著者的意愿。

The .debian.tar.xz contains all of the modifications made by the Debian maintainer, especially the addition of a debian directory containing the instructions to execute to construct a Debian package.

工具 解压缩源码包

使用原始软件包时,您可使用 dpkg-source 指令 (从 dpkg-dev 软件包取得) 解压缩它:

  1. $

You can also use apt to download a source package and unpack it right away. It requires that the appropriate deb-src lines be present in the /etc/apt/sources.list file, however (for further details, see 第 6.1 节 “写入sources.list文件”). These are used to list the “sources” of source packages (meaning the servers on which a group of source packages are hosted).

  1. $

5.3.2. Debian 中的使用

Debian 的基础是原始软件包。Debian 所有的软件包都从原始软件包而来,对软件包的修改也是针对原始软件包。运行软件包出了问题后,Debian 维护者修改原始软件包后,再编译为运行软件包。维护者的工作成果都在 Debian 的原始软件包内:您可轻易地回到原始软件包找出源头。

When a new version of a package (source package and one or more binary packages) arrives on the Debian server, the source package is the most important. Indeed, it will then be used by a network of machines of different architectures for compilation on the various architectures supported by Debian. The fact that the developer also sends one or more binary packages for a given architecture (usually i386 or amd64) is relatively unimportant, since these could just as well have been automatically generated.

https://buildd.debian.org/

GOING FURTHER Source only maintainer uploads

Right after the release of Debian 10 Buster the Release Team announced that maintainer binary uploads will no longer be accepted for main and all binary packages in this component will be built automatically from mandatory source-only uploads.