I encountered an issue when building debian package.
As for the document of the rules file: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#rules
debian/rules build runs dh build; which in turn runs the following:
dh_testdir dh_auto_configure dh_auto_build dh_auto_testfakeroot debian/rules binary runs fakeroot dh binary; which in turn runs the following:
dh_testroot dh_prep dh_installdirs dh_auto_install dh_install dh_installdocs ... dh_builddeb
But when I run dh binary --no-act command, the output includes dh build --no-act. This means the ./configure and make commands are run two times during build the debian package. It's weird.
I used dpkg-buildpackage -us -uc to build debian package.
UPDATE: I saw it actually did not run twice, but why --no-act shows the dh build output runs twice?
First, to answer the first question, the differences between the
debian/rulesbuildandbinaryrules are outlined in Debian Policy §4.9. In brief, thebuildtarget should only perform "building" steps, and not do anything that requires root (or fakeroot) privileges, such as chowning files to uid 0 or "installing" things.binary, on the other hand, should take all the necessary steps to build the appropriate binary debs.binaryshould include all the steps ofbuildif they haven't already been done.Here are a couple facts about
dhthat you might be missing:dhkeeps track of thedh_*commands that get run as part of a build sequence (for example, as part ofdh buildordh binary), even between invocations. You can see what commands it thinks it has already run by looking at the contents ofdebian/$package.debhelper.log. If a command is listed in there,dhwill consider it already run for the purposes of command sequencing.dh $sequence --no-acttakes thatdebian/$package.debhelper.logfile into account as well. So when you rundh binary --no-acton a fresh, clean build dir, you'll see a long list of commands, including those that need to be done for thebuildtarget. But if you actually rundh buildfirst and then trydh binary --no-act, it won't show the build steps anymore. It will only show the steps for preparing and creating the actual .deb package.