防止创建配置文件
我正在尝试构建一个包,其中在 /etc
下有一些不是配置的文件。即使我在 debian
目录中创建一个空的 package.conffiles
,它们也会自动包含在 conffiles
中。
如何阻止 dh_installdeb 这样做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不确定我是否理解 rafl 的答案,但是从
debhelper=9.20120115ubuntu3
开始,dh_installdeb
几乎无条件地将/etc
下面的所有内容添加到配置文件中:< code>debian/conffiles 添加配置文件但不覆盖它们。可以在 debian/rules 中手动覆盖。例如,为了防止任何文件被注册为conffiles:(
当然,缩进必须是hard tab)
I’m not sure I understand rafl’s answer, but
dh_installdeb
as ofdebhelper=9.20120115ubuntu3
adds everything below/etc
to conffiles nearly unconditionally:debian/conffiles
adds conffiles but does not override them.It’s possible to override manually in
debian/rules
. For example, in order to prevent any files from being registered as conffiles:(of course, indentation must be hard tab)
可以使用 debian/.preinst 中的 preinst 脚本中定义升级规则“nofollow">dpkg-maintscript-helper 。
更多信息:
删除 Debian 软件包中过时的配置文件的正确方法
It's possible to define a upgrade rule at preinst script in
debian/<package-name>.preinst
using dpkg-maintscript-helper.More info:
The right way to remove an obsolete conffile in a Debian package
这是我对瓦西里答案的延伸。它有效地执行 dh_installdeb 的操作,但不会自动添加
/etc
文件。通过这种方式,您可以再次完全控制哪些文件被视为配置文件,哪些文件不是。(当然,如果粘贴到规则文件中,请使用 REAL 选项卡)。
这个答案使用BASH(或/bin/sh,它要么是符号链接到BASH,要么是它的变体)。可能有一种方法可以通过仅使用 makefile 内部命令来实现此目的,但我不太擅长这些。
即使从同一源构建多个二进制包,它也应该起作用,并且它尊重普通的 debian/conffiles 以及特定于包的 debian/${pkg}.conffiles 。 。
Here is what I came up with as an extension of Vasiliy's answer. It effectively does what dh_installdeb does but without automatically adding
/etc
files. This way you regain full control again over what files are considered conffiles and what are not.(Of course, use REAL tabs if pasting into your rules file).
This answer uses BASH (or /bin/sh which is either symlinked to BASH or is a variant of it). There may be a way to achieve this by using only makefile internal commands, but I'm not that good with those.
This should work even when building multiple binary packages from the same source and it respects the plain
debian/conffiles
as well as the package-specificdebian/${pkg}.conffiles
.最初,这个答案建议提供您自己的
debian/conffiles
文件,仅列出要安装的实际配置文件。显然,这只用于添加更多配置文件,但不会覆盖整个conffiles
文件。然而,我不太明白你为什么想要这样。如果这些文件不是配置文件,用户将不会编辑它们,因此自动配置文件处理不会妨碍您进行升级。另外,如果它们实际上不是配置文件,我强烈建议将它们简单地安装到 /etc 以外的位置,也可以避免出现问题。
Originally, this answer suggested providing your own
debian/conffiles
files only listing actual configuration files to be installed. Apparently that only serves to add more configuration files but won't override the wholeconffiles
file.However, I can't quite see why you'd even want that. If the files are not configuration files, the user won't edit them, so none of the automatic conffile handling will get in your way on upgrades. Also, if they're not actually config files, I'd highly recommend to simply install them to a place other than /etc, avoiding your issue as well.