內容目錄
There are some techniques you should know for checking a package for errors before uploading it to the public archives.
It's also a good idea to carry out testing on a machine other than your own. You must watch closely for any warnings or errors for all the tests described here.
If you find a new autogenerated patch file such as
debian-changes-* in the
debian/patches directory after building your non-native
Debian package in 3.0 (quilt) format, chances are you
changed some files by accident or the build script modified the upstream
source. If it is your mistake, fix it. If it is caused by the build
script, fix the root cause with dh-autoreconf as in 節 4.4.3, “定製 rules 檔案” or work around it with
source/options as in 節 5.25, “source/options”.
You must test your package for whether it installs without problem. The debi(1) command helps you to test installing all the generated binary packages.
$ sudo debi gentoo_0.9.12-1_i386.changes
To prevent installation problem on different systems, you must make sure
that there are no filenames conflicting with other existing packages, using
the Contents- file
downloaded from the Debian archive. The apt-file command
may be handy for this task. If there are collisions, please take action to
avoid this real problem, whether by renaming the file, moving a common file
to a separate package that multiple packages can depend on, using the
alternatives mechanism (see
update-alternatives(1)) in coordination with the
maintainers of other affected packages, or declaring a
i386Conflicts relationship in the
debian/control file.
All maintainer scripts (that is, preinst,
prerm, postinst, and
postrm files) are hard to write correctly unless they
are auto-generated by the debhelper
programs. So do not use them if you are a novice maintainer (see 節 5.19, “{pre,post}{inst,rm}”).
If the package makes use of these non-trivial maintainer scripts, be sure to test not only for install but also for remove, purge, and upgrade processes. Many maintainer script bugs show up when packages are removed or purged. Use the dpkg command as follows to test them.
$ sudo dpkg -r gentoo $ sudo dpkg -P gentoo $ sudo dpkg -i gentoo_version-revision_i386.deb
整個測試過程應按照以下序列操作:
如果可能,安裝前一個版本的套件;
從前一個版本升級套件;
降級套件到前一個版本(可選);
徹底刪除該套件;
全新安裝該套件;
反安裝該套件;
再次安裝該套件。
徹底刪除該套件;
如果這是你的第一個套件,你應該使用其他版本號創建一個測試用的套件來完成升級測試,這樣可以避免將來的問題。
請牢記如果你的套件已經在以往版本的 Debian 中發佈,人們通常會從最近發佈的 Debian 發佈裏的版本升級,所以也要測試從那個版本升級到當前的版本。
Although downgrading is not officially supported, supporting it is a friendly gesture.
使用 lintian(1) 檢査你的 .changes
檔案。lintian 命令會運行很多測試腳本來檢査常見的打包錯誤。[77]
$ lintian -i -I --show-overrides gentoo_0.9.12-1_i386.changes
Of course, replace the filename with the name of the
.changes file generated for your package. The output
of the lintian command uses the following flags.
E: for error; a sure policy violation or packaging error.
W: for warning; a possible policy violation or packaging
error.
I: for info; information on certain aspects of packaging.
N: 代表註釋:幫助你調試的詳細訊息。
O: 代表已覆蓋:一個被 lintian-overrides
檔案覆蓋的訊息,但由於使用 --show-overrides 選項而顯示。
When you see warnings, tune the package to avoid them or verify that the
warnings are spurious. If spurious, set up
lintian-overrides files as described in 節 5.14, “{”.
package.,source/}lintian-overrides
Note that you can build the package with dpkg-buildpackage and run lintian on it in one command, if you use debuild(1) or pdebuild(1).
You can list files in the binary Debian package with the debc(1) command.
$ debc package.changes
你可以使用 debdiff(1) 命令比較兩個 Debian 原始碼套件的內容。
$ debdiffold-package.dscnew-package.dsc
你還可以使用 debdiff(1) 命令比較兩個 Debian 二進位套件的檔案列表。
$ debdiffold-package.changesnew-package.changes
These are useful to identify what has been changed in the source packages and to check for inadvertent changes made when updating binary packages, such as unintentionally misplacing or removing files.
你可以使用 interdiff(1) 命令比較兩個 diff.gz
檔案。這對於更新使用舊的 1.0 原始碼格式的套件時,檢査是否有意外的變更非常有用。
$ interdiff -zold-package.diff.gznew-package.diff.gz
The new 3.0 source format stores changes in multiple
patch files as described in 節 5.26, “patches/*”. You can trace
changes of each debian/patches/* file using
interdiff, too.
很多檔案檢査操作可以通過使用類似 mc(1) 的檔案管理器來完成,它可以幫助你直接査看
*.deb 檔案的內容,除此之外還可以用於
*.udeb、*.debian.tar.gz、*.diff.gz
和 *.orig.tar.gz 檔案。
Be on the lookout for extra unneeded files or zero length files, both in the
binary and source package. Often cruft doesn't get cleaned up properly;
adjust your rules file to compensate for this.
[77] 如果你按照 節 6.3, “debuild 命令” 中的敘述定義了
/etc/devscripts.conf 或
~/.devscripts 檔案,就不需要再添加 lintian 選項
-i -I --show-overrides。