In a Debian archive file, the package name and the version string is typically separated by an underscore, for instance foo-bar_1.2.3.tar.gz. The top directory in the archive, on the other hand, has a hyphen instead of an underscore, for instance foo-bar-1.2.3. What is the reason for this and where is this convention described?
1 Answer
It's very helpful for the names of the .tar.gz and other files that make up the Debian source package to be uniform, since they end up installed on mirror sites in a fixed structure. Here, an underscore is used in order to remove ambiguity: hyphens are permitted in both the package name and the version, so if a hyphen were also used as the separator then it wouldn't be clear which was which. The naming is described (non-normatively) in an appendix to the Debian Policy Manual, although some of the details of which files form part of source packages are out of date in that appendix and dpkg-source(1) is a better reference there.
I don't recall ever seeing a clear reason for why dpkg-source unpacks source packages to <package>-<upstream_version> rather than to <package>_<upstream_version>, although my best guess is that it was simply because that was the usual convention for how tarballs distributed by upstream maintainers would unpack at the time dpkg-source was written (and to a large extent still is), so it made things look least surprising.
the package name and the version stringto hyphens inthe top directory in the archive. StephenKitt's comment mentions this too.