4

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_test
    
  • fakeroot 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?

the paul
  • 8,972
  • 1
  • 36
  • 53
chenzhiwei
  • 441
  • 6
  • 14

1 Answers1

5

First, to answer the first question, the differences between the debian/rules build and binary rules are outlined in Debian Policy §4.9. In brief, the build target 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. binary should include all the steps of build if they haven't already been done.

Here are a couple facts about dh that you might be missing:

  1. dh keeps track of the dh_* commands that get run as part of a build sequence (for example, as part of dh build or dh binary), even between invocations. You can see what commands it thinks it has already run by looking at the contents of debian/$package.debhelper.log. If a command is listed in there, dh will consider it already run for the purposes of command sequencing.

  2. dh $sequence --no-act takes that debian/$package.debhelper.log file into account as well. So when you run dh binary --no-act on a fresh, clean build dir, you'll see a long list of commands, including those that need to be done for the build target. But if you actually run dh build first and then try dh 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.

the paul
  • 8,972
  • 1
  • 36
  • 53