I encountered an issue when building debian package.
我在构建debian软件包时遇到了一个问题。
As for the document of the rules file: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#rules
关于规则文件:https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#规则
-
debian/rules build runs dh build; which in turn runs the following:
debian/规则构建运行dh构建;这反过来又运行以下内容:
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:
fakeroot debian/rules二进制运行fakeroot dh二进制;这反过来又运行以下内容:
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.
但是当我运行dh二进制指令时,输出包含dh构建,即no-act。这意味着./configure和make命令在构建debian包期间运行两次。这很奇怪。
I used dpkg-buildpackage -us -uc
to build debian package.
我使用dpkg-build - package -us -uc来构建debian软件包。
UPDATE: I saw it actually did not run twice, but why --no-act shows the dh build
output runs twice?
更新:我看到它实际上并没有运行两次,但是为什么——no-act显示dh构建输出运行两次?
1 个解决方案
#1
2
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.
首先,回答第一个问题,debian /规则构建之间的差异和二进制规则是在debian政策概述§4.9。简而言之,构建目标应该只执行“构建”步骤,而不执行任何需要root(或fakeroot)特权的操作,比如将文件共享到uid 0或“安装”东西。另一方面,二进制应该采取所有必要的步骤来构建适当的二进制debs。二进制应该包括构建的所有步骤,如果它们还没有完成的话。
Here are a couple facts about dh
that you might be missing:
以下是一些关于dh的事实,你可能会漏掉:
-
dh
keeps track of thedh_*
commands that get run as part of a build sequence (for example, as part ofdh build
ordh 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,dh
will consider it already run for the purposes of command sequencing.dh跟踪作为构建序列的一部分运行的dh_*命令(例如,作为dh构建或dh二进制的一部分),甚至在调用之间。通过查看debian/$package.debhelper.log的内容,您可以看到它认为已经运行了哪些命令。如果一个命令列在那里,dh将考虑它已经为命令排序而运行。
-
dh $sequence --no-act
takes thatdebian/$package.debhelper.log
file into account as well. So when you rundh 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 thebuild
target. But if you actually rundh build
first 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.dh $sequence -no-act也考虑了debian/$package.debhelper.log文件。因此,当您运行dh二进制文件时——不对一个新的、干净的构建目录执行操作时,您将看到一长串命令,包括那些需要为构建目标执行的命令。但是如果你先运行dh构建,然后尝试dh二进制——无行为,它就不会再显示构建步骤了。它将只显示准备和创建实际的.deb包的步骤。
#1
2
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.
首先,回答第一个问题,debian /规则构建之间的差异和二进制规则是在debian政策概述§4.9。简而言之,构建目标应该只执行“构建”步骤,而不执行任何需要root(或fakeroot)特权的操作,比如将文件共享到uid 0或“安装”东西。另一方面,二进制应该采取所有必要的步骤来构建适当的二进制debs。二进制应该包括构建的所有步骤,如果它们还没有完成的话。
Here are a couple facts about dh
that you might be missing:
以下是一些关于dh的事实,你可能会漏掉:
-
dh
keeps track of thedh_*
commands that get run as part of a build sequence (for example, as part ofdh build
ordh 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,dh
will consider it already run for the purposes of command sequencing.dh跟踪作为构建序列的一部分运行的dh_*命令(例如,作为dh构建或dh二进制的一部分),甚至在调用之间。通过查看debian/$package.debhelper.log的内容,您可以看到它认为已经运行了哪些命令。如果一个命令列在那里,dh将考虑它已经为命令排序而运行。
-
dh $sequence --no-act
takes thatdebian/$package.debhelper.log
file into account as well. So when you rundh 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 thebuild
target. But if you actually rundh build
first 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.dh $sequence -no-act也考虑了debian/$package.debhelper.log文件。因此,当您运行dh二进制文件时——不对一个新的、干净的构建目录执行操作时,您将看到一长串命令,包括那些需要为构建目标执行的命令。但是如果你先运行dh构建,然后尝试dh二进制——无行为,它就不会再显示构建步骤了。它将只显示准备和创建实际的.deb包的步骤。