Debian 打包中规则文件的用途和作用是什么

Debian 打包中规则文件的用途和作用是什么

我正在尝试将使用 Netbeans 7.3 开发的 C++ 应用程序打包到 Debian 中。以下是其中的一部分Makefile

APPNAME=remotedevicecontroller
install:
    install config.xml /etc/${APPNAME}.conf.xml
    install devices.rules /etc/udev/rules.d/${APPNAME}.rules
    install error.log /var/log/${APPNAME}.log
    install init.conf /etc/init/${APPNAME}.conf
    install init.d /etc/init.d/${APPNAME}
    install ${CND_ARTIFACT_NAME_${CONF}} /usr/local/bin/${APPNAME}
    chmod u+x ${CND_ARTIFACT_NAME_${CONF}}
    ./${CND_ARTIFACT_NAME_${CONF}} -i

我正在关注如何创建 .DEB 软件包Debian 新维护者指南dpkg-buildpackage -rfakeroot。成功完成上述所有步骤后,运行时遇到以下错误

$ dpkg-buildpackage -rfakeroot
dpkg-buildpackage: source package remotedevicecontroller
dpkg-buildpackage: source version 1.0-1
dpkg-buildpackage: source changed by satya gowtham kudupudi (gowtham) <[email protected]>
dpkg-buildpackage: host architecture i386
 dpkg-source --before-build remotedevicecontroller-1.0
 fakeroot debian/rules clean
dh clean
dh: No packages to build.
 dpkg-source -b remotedevicecontroller-1.0
dpkg-source: info: using source format `3.0 (quilt)'
dpkg-source: info: building remotedevicecontroller using existing ./remotedevicecontroller_1.0.orig.tar.gz
dpkg-source: info: building remotedevicecontroller in remotedevicecontroller_1.0-1.debian.tar.gz
dpkg-source: info: building remotedevicecontroller in remotedevicecontroller_1.0-1.dsc
 debian/rules build
dh build
dh: No packages to build.
 fakeroot debian/rules binary
dh binary
dh: No packages to build.
 signfile remotedevicecontroller_1.0-1.dsc

You need a passphrase to unlock the secret key for
user: "satya gowtham kudupudi (gowtham) <[email protected]>"
2048-bit RSA key, ID 9A2853A0, created 2013-08-22

gpg: gpg-agent is not available in this session

 dpkg-genchanges  >../remotedevicecontroller_1.0-1_i386.changes
dpkg-genchanges: error: cannot read files list file: No such file or directory
dpkg-buildpackage: error: dpkg-genchanges gave error exit status 2

http://www.debian.org/doc/manuals/maint-guide/dreq.en.html#defaultrules没有解释rulesfile 的作用是什么。

%:
    dh $@

是什么意思?为什么这么dpkg-buildpackage -rfakerootdh: No packages to build.

答案1

rules文件负责实际创建软件包的所有工作。它是一个 Makefile,其目标是编译和安装应用程序,然后.deb从已安装的文件创建文件。它还有一个目标是清理所有构建文件,这样您最终只会得到一个源包。正如Debian 政策手册说:

该文件必须是一个可执行的 makefile,并包含用于编译包和从源构建二进制包的特定于包的配方。

这一切都很好,但这里实际发生了什么:

%:
    dh $@

dh是一个辅助命令,它调用其他 Make 目标并运行一系列debhelper命令。它的手册页手册页图标描述它:

   dh runs a sequence of debhelper commands. The supported sequences
   correspond to the targets of a debian/rules file: build-arch, build-
   indep, build, clean, install-indep, install-arch, install, binary-arch,
   binary-indep, and binary.

再次强调,这只是一个简化操作的辅助文件。您实际上不需要使用它,但它可以让您的生活变得更加轻松。要查看每个目标中实际运行的命令,请运行:

dh binary-arch --no-act

现在谈谈您的具体问题...我认为这与您的文件无关rules。如果没有看到实际的源包,很难确定问题是什么。不过我大胆猜测您的文件中没有二进制包节debian/control。在下面的代码片段中,第一个“节”描述了源包,而第二个“节”描述了它将构建的二进制包:

Source: hello
Section: devel
Priority: optional
Maintainer: Ubuntu Developers <[email protected]>
XSBC-Original-Maintainer: Jane Doe <[email protected]>
Standards-Version: 3.9.1
Build-Depends: debhelper (>= 7)
Homepage: http://www.gnu.org/software/hello/

Package: hello
Architecture: any
Depends: ${shlibs:Depends}
Description: The classic greeting, and a good example
 The GNU hello program produces a familiar, friendly greeting. It
 allows non-programmers to use a classic computer science tool which
 would otherwise be unavailable to them. Seriously, though: this is
 an example of how to do a Debian package. It is the Debian version of
 the GNU Project's `hello world' program (which is itself an example
 for the GNU Project).

答案2

我在 中犯的一个非常重要的错误Makefile是没有使用$(DESTDIR)。我发布它是为了帮助那些因这个常见错误而难以构建 debian 软件包的人。所以正确的Makefile应该是:

APPNAME=remotedevicecontroller
install:
    install config.xml ${DESTDIR}/etc/${APPNAME}.conf.xml
    install devices.rules ${DESTDIR}/etc/udev/rules.d/${APPNAME}.rules
    install error.log ${DESTDIR}/var/log/${APPNAME}.log
    install init.conf ${DESTDIR}/etc/init/${APPNAME}.conf
    install init.d ${DESTDIR}/etc/init.d/${APPNAME}
    install ${CND_ARTIFACT_NAME_${CONF}} ${DESTDIR}/usr/local/bin/${APPNAME}
    chmod u+x ${CND_ARTIFACT_NAME_${CONF}}
    ./${CND_ARTIFACT_NAME_${CONF}} -i

如果某些make目标失败,则覆盖文件中相应的 dh_make 目标rules可能有助于成功打包。

override_dh_auto_test:
%:
    dh clean
    dh binary

我的应用程序中的目标test出现了错误,但这并不重要,所以我覆盖了dh_auto_test

并且请记住在再次尝试之前清理失败尝试留下的所有跟踪文件。

相关内容