X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=best-pkging-practices.dbk;h=43cf469043eaa4602d4d0dabd9d483eb99ba9485;hb=e81cdebedab690ef881d87af6f533e51c026565c;hp=f1130c201501d35ba885d879ae58665001d8cb50;hpb=8a77d09ebb4f5b985db6da174892a3a66d5aa272;p=developers-reference.git diff --git a/best-pkging-practices.dbk b/best-pkging-practices.dbk index f1130c2..43cf469 100644 --- a/best-pkging-practices.dbk +++ b/best-pkging-practices.dbk @@ -1,11 +1,13 @@ + "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ + %commondata; +]> Best Packaging Practices Debian's quality is largely due to the Debian Policy, which +url="&url-debian-policy;">Debian Policy, which defines explicit baseline requirements which all Debian packages must fulfill. Yet there is also a shared history of experience which goes beyond the Debian Policy, an accumulation of years of experience in packaging. Many very @@ -32,7 +34,7 @@ usually the file maintainers spend the most time on. The rationale for using helper scripts in debian/rules is that they let maintainers use and share common logic among many packages. Take for instance the question of installing menu entries: you need to put the file -into /usr/lib/menu (or /usr/lib/menu +into /usr/share/menu (or /usr/lib/menu for executable binary menufiles, if this is needed), and add commands to the maintainer scripts to register and unregister the menu entries. Since this is a very common thing for packages to do, why should each maintainer rewrite all @@ -78,7 +80,7 @@ Some people feel that vanilla debian/rules files are better, since you don't have to learn the intricacies of any helper system. This decision is completely up to you. Use what works for you. Many examples of vanilla debian/rules files are available at . +url="&url-rules-files;">. @@ -142,6 +144,8 @@ the same software but with different configuration options. The vim source package is an example of how to manage this using an hand-crafted debian/rules file. + @@ -151,7 +155,7 @@ this using an hand-crafted debian/rules file. The following practices are relevant to the debian/control file. They supplement the Policy +url="&url-debian-policy;ch-binary.html#s-descriptions">Policy on package descriptions. @@ -199,8 +203,7 @@ Postscript or postscript. If you are having problems writing your description, you may wish to send it -along to debian-l10n-english@lists.debian.org and request -feedback. +along to &email-debian-l10n-english; and request feedback. @@ -276,10 +279,10 @@ it. Both ispell and aspell have special modes for checking debian/control files: - -d american -g debian/control +ispell -d american -g debian/control - -d en -D -c debian/control +aspell -d en -D -c debian/control Users usually expect these questions to be answered in the package description: @@ -306,9 +309,9 @@ package, this should be mentioned. -If the package is experimental, or there are other reasons it should not be -used, if there are other packages that should be used instead, it should be -here as well. +If the package is experimental, or there are other reasons +it should not be used, if there are other packages that should be used instead, +it should be here as well. @@ -318,36 +321,20 @@ implementation? more features? different features? Why should I choose this package. +
Upstream home page -We recommend that you add the URL for the package's home page to the package -description in debian/control. This information should be -added at the end of description, using the following format: - - - . - Homepage: http://some-project.some-place.org/ - - -Note the spaces prepending the line, which serves to break the lines correctly. -To see an example of how this displays, see . - - -If there is no home page for the software, this should naturally be left out. - - -Note that we expect this field will eventually be replaced by a proper -debian/control field understood by dpkg -and packages.debian.org. If you don't want to bother -migrating the home page from the description to this field, you should probably -wait until that is available. Please make sure that this line matches the -regular expression /^ Homepage: [^ ]*$/, as this allows -packages.debian.org to parse it correctly. +We recommend that you add the URL for the package's home page in the +Homepage field of the Source section +in debian/control. Adding this information in the +package description itself is considered deprecated.
@@ -358,7 +345,7 @@ There are additional fields for the location of the Version Control System in debian/control.
-XS-Vcs-Browser +Vcs-Browser Value of this field should be a http:// URL pointing to a web-browsable copy of the Version Control System repository used to maintain @@ -372,7 +359,7 @@ tagged as pending in the bug tracking system).
-XS-Vcs-* +Vcs-* Value of this field should be a string identifying unequivocally the location of the Version Control System repository used to maintain the given package, if @@ -401,15 +388,17 @@ of the vim package is shown. Note how the URL is in the svn:// scheme (instead of svn+ssh://) and how it points to the trunk/ branch. The use of the -XS-Vcs-Browser field described above is also shown. +Vcs-Browser and Homepage fields +described above is also shown. Source: vim Section: editors Priority: optional <snip> - XS-Vcs-Svn: svn://svn.debian.org/svn/pkg-vim/trunk/packages/vim - XS-Vcs-Browser: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim + Vcs-Svn: svn://svn.debian.org/svn/pkg-vim/trunk/packages/vim + Vcs-Browser: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim + Homepage: http://www.vim.org
@@ -421,7 +410,7 @@ the URL is in the svn:// scheme (instead of Best practices for <filename>debian/changelog</filename> The following practices supplement the Policy +url="&url-debian-policy;ch-docs.html#s-changelogs">Policy on changelog files.
@@ -559,24 +548,27 @@ inserting the title of each different bug.
Supplementing changelogs with NEWS.Debian files -Important news about changes in a package can also be put in NEWS.Debian files. +Important news about changes in a package can also be put in +NEWS.Debian files. The news will be displayed by tools like apt-listchanges, before all the rest of the changelogs. This is the preferred means to let the user know about significant changes in a package. It is better than using debconf notes since -it is less annoying and the user can go back and refer to the NEWS.Debian file -after the install. And it's better than listing major changes in -README.Debian, since the user can easily miss such notes. +it is less annoying and the user can go back and refer to the +NEWS.Debian file after the install. And it's better than listing +major changes in README.Debian, since the user can easily +miss such notes. The file format is the same as a debian changelog file, but leave off the asterisks and describe each news item with a full paragraph when necessary rather than the more concise summaries that would go in a changelog. It's a -good idea to run your file through dpkg-parsechangelog to check its formatting -as it will not be automatically checked during build as the changelog is. Here -is an example of a real NEWS.Debian file: +good idea to run your file through dpkg-parsechangelog to +check its formatting as it will not be automatically checked during build as +the changelog is. Here is an example of a real NEWS.Debian + file: - (3.0pl1-74) unstable; urgency=low +cron (3.0pl1-74) unstable; urgency=low The checksecurity script is no longer included with the cron package: it now has its own package, checksecurity. If you liked the @@ -586,21 +578,34 @@ is an example of a real NEWS.Debian file: -- Steve Greenland <stevegr@debian.org> Sat, 6 Sep 2003 17:15:03 -0500 -The NEWS.Debian file is installed as -/usr/share/doc/<package>/NEWS.Debian.gz. It is compressed, and always -has that name even in Debian native packages. If you use debhelper, -dh_installchangelogs will install debian/NEWS files for you. +The NEWS.Debian file is installed as +/usr/share/doc/package/NEWS.Debian.gz. +It is compressed, and always has that name even in Debian native packages. +If you use debhelper, dh_installchangelogs + will install debian/NEWS files for you. -Unlike changelog files, you need not update NEWS.Debian files with every -release. Only update them if you have something particularly newsworthy that -user should know about. If you have no news at all, there's no need to ship a -NEWS.Debian file in your package. No news is good news! +Unlike changelog files, you need not update NEWS.Debian +files with every release. Only update them if you have something particularly +newsworthy that user should know about. If you have no news at all, there's no +need to ship a NEWS.Debian file in your package. No news +is good news!
+ +
Best practices for maintainer scripts @@ -609,7 +614,7 @@ Maintainer scripts include the files debian/postinst, debian/postrm. These scripts take care of any package installation or deinstallation setup which isn't handled merely by the creation or removal of files and directories. The following instructions supplement the -Debian Policy. +Debian Policy. Maintainer scripts must be idempotent. That means that you need to make sure @@ -644,27 +649,12 @@ maintainer script. If you need to check for the existence of a command, you should use something like - - [ -x /usr/sbin/install-docs ]; then ... - +if [ -x /usr/sbin/install-docs ]; then ... If you don't wish to hard-code the path of a command in your maintainer script, the following POSIX-compliant shell function may help: - -() { - OLDIFS=$IFS - IFS=: - for p in $PATH; do - if [ -x $p/$* ]; then - IFS=$OLDIFS - return 0 - fi - done - IFS=$OLDIFS - return 1 -} - +&example-pathfind; You can use this function to search $PATH for a command name, passed as an argument. It returns true (zero) if the command was found, @@ -736,8 +726,8 @@ Most Debian package maintainers are not native English speakers. So, writing properly phrased templates may not be easy for them. -Please use (and abuse) debian-l10n-english@lists.debian.org -mailing list. Have your templates proofread. +Please use (and abuse) &email-debian-l10n-english; mailing +list. Have your templates proofread. Badly written templates give a poor image of your package, of your work...or @@ -761,7 +751,7 @@ translated by translation teams or even individuals. Please use gettext-based templates. Install po-debconf on your development system and read its -documentation (man po-debconf is a good start). +documentation (man po-debconf is a good start). Avoid changing templates too often. Changing templates text induces more work @@ -773,21 +763,21 @@ templates, the translator's name and e-mail addresses are mentioned in the po files headers. -The use of the podebconf-report-po from the po-debconf -package is highly recommended to warn translators which have incomplete -translations and request them for updates. +The use of the podebconf-report-po from the po-debconf package is highly recommended to warn +translators which have incomplete translations and request them for updates. If in doubt, you may also contact the translation team for a given language -(debian-l10n-xxxxx@lists.debian.org), or the -debian-i18n@lists.debian.org mailing list. +(debian-l10n-xxxxx@&lists-host;), or the +&email-debian-i18n; mailing list. -Calls for translations posted to debian-i18n@lists.debian.org -with the debian/po/templates.pot file attached or -referenced in a URL are encouraged. Be sure to mentions in these calls for new -translations which languages you have existing translations for, in order to -avoid duplicate work. +Calls for translations posted to &email-debian-i18n; with the +debian/po/templates.pot file attached or referenced in a +URL are encouraged. Be sure to mentions in these calls for new translations +which languages you have existing translations for, in order to avoid duplicate +work.
@@ -804,7 +794,7 @@ If you don't do so, the whole template will not be translated as long as a translator will send you an update. -To unfuzzy translations, you can proceed the +To unfuzzy translations, you can proceed the following way: @@ -814,10 +804,8 @@ Put all incomplete PO files out of the way. You can check the completeness by using (needs the gettext package installed): - - i in debian/po/*po; do echo -n $i: ; msgfmt -o /dev/null ---statistics $i; done - +for i in debian/po/*po; do echo -n $i: ; msgfmt -o /dev/null +--statistics $i; done @@ -843,9 +831,7 @@ modified in translations. You can see this by running the above again use the following command: - - i in debian/po/*po; do msgattrib --output-file=$i --clear-fuzzy $i; done - +for i in debian/po/*po; do msgattrib --output-file=$i --clear-fuzzy $i; done @@ -1189,7 +1175,7 @@ using English. Example, taken from the geneweb package templates: -: geneweb/lang +Template: geneweb/lang Type: select __Choices: Afrikaans (af), Bulgarian (bg), Catalan (ca), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), English (en), Esperanto (eo), Estonian (et), Finnish (fi), French (fr), German (de), Hebrew (he), Icelandic (is), Italian (it), Latvian (lv), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv) # This is the default choice. Translators may put their own language here @@ -1283,13 +1269,12 @@ differences between two versions of the documentation, so, for instance, they can see what needs to be retranslated. It is recommended that the translated documentation maintain a note about what source control revision the translation is based on. An interesting system is provided by doc-check in the boot-floppies package, which shows an overview of -the translation status for any given language, using structured comments for -the current revision of the file to be translated and, for a translated file, -the revision of the original file the translation is based on. You might wish -to adapt and provide that in your CVS area. +url="&url-i18n-doc-check;">doc-check in the +boot-floppies package, which shows an +overview of the translation status for any given language, using structured +comments for the current revision of the file to be translated and, for a +translated file, the revision of the original file the translation is based on. +You might wish to adapt and provide that in your CVS area. If you maintain XML or SGML documentation, we suggest that you isolate any @@ -1303,6 +1288,15 @@ easier, for instance, to keep URLs up to date across multiple files.
Common packaging situations +
Packages using <command>autoconf</command>/<command>automake</command> @@ -1311,7 +1305,7 @@ Keeping autoconf's config.sub and especially on more volatile architectures. Some very good packaging practices for any package using autoconf and/or automake have been synthesized in -/usr/share/doc/autotools-dev/README.Debian.gz from the +&file-bpp-autotools; from the autotools-dev package. You're strongly encouraged to read this file and to follow the given recommendations. @@ -1327,7 +1321,7 @@ library can result in dozens of dependent packages breaking. Good practices for library packaging have been grouped in the library +url="&url-libpkg-guide;">the library packaging guide.
@@ -1336,7 +1330,7 @@ packaging guide. Documentation Be sure to follow the Policy on +url="&url-debian-policy;ch-docs.html">Policy on documentation. @@ -1369,7 +1363,7 @@ packaging rules and practices: Perl related packages have a Perl +url="&url-perl-policy;">Perl policy, some examples of packages following that policy are libdbd-pg-perl (binary perl module) or libmldbm-perl (arch independent perl module). @@ -1378,30 +1372,30 @@ role="package">libmldbm-perl (arch independent perl module). Python related packages have their python policy; see -/usr/share/doc/python/python-policy.txt.gz in the -python package. +&file-python-policy; in the python package. Emacs related packages have the emacs +url="&url-emacs-policy;">emacs policy. Java related packages have their java +url="&url-java-policy;">java policy. Ocaml related packages have their own policy, found in -/usr/share/doc/ocaml/ocaml_packaging_policy.gz from the -ocaml package. A good example is the -camlzip source package. +&file-ocaml-policy; from the ocaml package. A good example is the camlzip source package. @@ -1414,12 +1408,33 @@ in the sgml-base-doc package. Lisp packages should register themselves with common-lisp-controller, about which see -/usr/share/doc/common-lisp-controller/README.packaging. +&file-lisp-controller;. +
+ +
Architecture-independent data @@ -1436,7 +1451,7 @@ you avoid needless duplication of the same data into eleven or more .debs, one per each architecture. While this adds some extra overhead into the Packages files, it saves a lot of disk space on Debian mirrors. Separating out architecture-independent data also reduces processing -time of lintian or linda (see lintian (see ) when run over the entire Debian archive.
@@ -1448,12 +1463,12 @@ If you need a certain locale during build, you can create a temporary file via this trick:
-If you set LOCPATH to the equivalent of /usr/lib/locale, and LC_ALL to the name +If you set LOCPATH to the equivalent of /usr/lib/locale, and LC_ALL to the name of the locale you generate, you should get what you want without being root. Something like this: -=debian/tmpdir/usr/lib/locale +LOCALE_PATH=debian/tmpdir/usr/lib/locale LOCALE_NAME=en_IN LOCALE_CHARSET=UTF-8 @@ -1475,26 +1490,17 @@ sections, to hunt down unused libraries. But when passed the right argument, it tries to catch other useless packages. -For example, with --guess-dummy, deborphan tries to search all transitional -packages which were needed for upgrade but which can now safely be removed. +For example, with --guess-dummy, deborphan +tries to search all transitional packages which were needed for upgrade but +which can now safely be removed. For that, it looks for the string dummy or transitional in their short description. So, when you are creating such a package, please make sure to add this text to your short description. If you are looking for examples, just run: - - --cache search .|grep dummy - - -or - - --cache search .|grep transitional - - -. +apt-cache search .|grep dummy or +apt-cache search .|grep transitional. @@ -1508,7 +1514,7 @@ upstream source. Pristine source The defining characteristic of a pristine source tarball is that the -.orig.tar.gz file is byte-for-byte identical to a tarball officially +.orig.tar.gz file is byte-for-byte identical to a tarball officially distributed by the upstream author. We cannot prevent upstream authors from changing the tarball they distribute without also incrementing the version number, so there can be no guarantee that a pristine @@ -1517,8 +1523,8 @@ distributing at any point in time. All that can be expected is that it is identical to something that upstream once did distribute. If a difference arises later (say, if upstream notices that he wasn't using maximal comression in his original distribution and then -re-gzips it), that's just too bad. Since there is no good -way to upload a new .orig.tar.gz for the same version, there is not even any +re-gzips it), that's just too bad. Since there is no good +way to upload a new .orig.tar.gz for the same version, there is not even any point in treating this situation as a bug. This makes it possible to use checksums to easily verify that all changes between Debian's version and upstream's are contained in the Debian diff. Also, if the original @@ -1538,7 +1544,7 @@ tarballs as pristine source. Its strategy is equivalent to the following: It unpacks the tarball in an empty temporary directory by doing - path/to/<packagename>_<upstream-version>.orig.tar.gz | tar xf - +zcat path/to/<packagename>_<upstream-version>.orig.tar.gz | tar xf -
@@ -1572,12 +1578,12 @@ gzipped tar at all, or if upstream's tarball contains non-DFSG-free material that you must remove before uploading. -In these cases the developer must construct a suitable .orig.tar.gz file -himself. We refer to such a tarball as a repackaged upstream source. Note -that a repackaged upstream source is different from a Debian-native package. A -repackaged source still comes with Debian-specific changes in a separate -.diff.gz and still has a version number composed of -<upstream-version> and +In these cases the developer must construct a suitable .orig.tar.gz + file himself. We refer to such a tarball as a repackaged upstream +source. Note that a repackaged upstream source is different from a +Debian-native package. A repackaged source still comes with Debian-specific +changes in a separate .diff.gz and still has a version +number composed of <upstream-version> and <debian-revision>. @@ -1590,7 +1596,7 @@ archive. Use your own discretion here, but be prepared to defend your decision if you repackage source that could have been pristine. -A repackaged .orig.tar.gz +A repackaged .orig.tar.gz @@ -1601,7 +1607,7 @@ repackaged source was obtained, and how this can be reproduced in the get-orig-source target in your debian/rules file that repeats the process, as described in the Policy Manual, Main +url="&url-debian-policy;ch-source.html#s-debianrules">Main building script: debian/rules. @@ -1613,6 +1619,7 @@ come from the upstream author(s), or whose contents has been changed by you. would lead to the source failing to build without assistance from the Debian diff, it might be appropriate to instead edit the files, omitting only the non-free parts of them, and/or explain the situation in a README.Debian-source + file in the root of the source tree. But in that case please also urge the upstream author to make the non-free components easier seperable from the rest of the source. @@ -1670,9 +1677,10 @@ postfix indicating the encoding should be appended to the original filename. Note that you don't need to depend on sharutils to get the uudecode program if you use perl's pack function. -The code could look like -file: perl -ne 'print(pack u, $$_);' -$(file) > $(file).uuencoded uudecode-file: perl -ne 'print(unpack u, $$_);' -$(file).uuencoded > $(file) . The file would then be +The code could look like + +&example-uu; +. The file would then be decoded and copied to its place during the build process. Thus the change will be visible quite easy. @@ -1714,33 +1722,34 @@ Some debug packages may contain an entire special debugging build of a library or other binary, but most of them can save space and build time by instead containing separated debugging symbols that gdb can find and load on the fly when debugging a program or library. The convention in Debian is to keep these -symbols in /usr/lib/debug/path, where -path is the path to the executable or library. For +symbols in /usr/lib/debug/path, where +path is the path to the executable or library. For example, debugging symbols for /usr/bin/foo go in /usr/lib/debug/usr/bin/foo, and debugging symbols for /usr/lib/libfoo.so.1 go in /usr/lib/debug/usr/lib/libfoo.so.1. -The debugging symbols can be extracted from an object file using objcopy ---only-keep-debug. Then the object file can be stripped, and objcopy ---add-gnu-debuglink used to specify the path to the debugging symbol file. +The debugging symbols can be extracted from an object file using +objcopy --only-keep-debug. Then the object file can be stripped, +and objcopy --add-gnu-debuglink used to specify the path +to the debugging symbol file. objcopy 1 explains in detail how this works. -The dh_strip command in debhelper supports creating debug packages, and can -take care of using objcopy to separate out the debugging symbols for you. If -your package uses debhelper, all you need to do is call dh_strip ---dbg-package=libfoo-dbg, and add an entry to debian/control for the debug -package. +The dh_strip command in debhelper supports creating debug +packages, and can take care of using objcopy to separate +out the debugging symbols for you. If your package uses debhelper, all you +need to do is call dh_strip --dbg-package=libfoo-dbg, and +add an entry to debian/control for the debug package. Note that the Debian package should depend on the package that it provides debugging symbols for, and this dependency should be versioned. For example: -: libfoo-dbg (= ${binary:Version}) +Depends: libfoo-dbg (= ${binary:Version})