防止创建配置文件

发布于 2024-09-12 11:45:09 字数 185 浏览 5 评论 0 原文

我正在尝试构建一个包,其中在 /etc 下有一些不是配置的文件。即使我在 debian 目录中创建一个空的 package.conffiles,它们也会自动包含在 conffiles 中。

如何阻止 dh_installdeb 这样做?

I'm trying to build a package which has some files under /etc that are not configuration. They are included in the conffiles automatically even if I create an empty package.conffiles in the debian directory.

How can I stop dh_installdeb from doing that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暮色兮凉城 2024-09-19 11:45:10

我不确定我是否理解 rafl 的答案,但是从 debhelper=9.20120115ubuntu3 开始,dh_installdeb 几乎无条件地将 /etc 下面的所有内容添加到配置文件中:< code>debian/conffiles 添加配置文件但不覆盖它们。

可以在 debian/rules 中手动覆盖。例如,为了防止任何文件被注册为conffiles:(

override_dh_installdeb:
    dh_installdeb
    find ${CURDIR}/debian/*/DEBIAN -name conffiles -delete

当然,缩进必须是hard tab)

I’m not sure I understand rafl’s answer, but dh_installdeb as of debhelper=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:

override_dh_installdeb:
    dh_installdeb
    find ${CURDIR}/debian/*/DEBIAN -name conffiles -delete

(of course, indentation must be hard tab)

俏︾媚 2024-09-19 11:45:10

可以使用 debian/.preinst 中的 preinst 脚本中定义升级规则“nofollow">dpkg-maintscript-helper

#!/bin/sh
# preinst script for <package-name>

set -e

case "$1" in
    install|upgrade)
      if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
        dpkg-maintscript-helper rm_conffile /etc/foo/conf.d/bar <Previous package version> -- "$@"
      fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

exit 0

更多信息:
删除 Debian 软件包中过时的配置文件的正确方法

It's possible to define a upgrade rule at preinst script in debian/<package-name>.preinst using dpkg-maintscript-helper.

#!/bin/sh
# preinst script for <package-name>

set -e

case "$1" in
    install|upgrade)
      if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
        dpkg-maintscript-helper rm_conffile /etc/foo/conf.d/bar <Previous package version> -- "$@"
      fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

exit 0

More info:
The right way to remove an obsolete conffile in a Debian package

够钟 2024-09-19 11:45:10

这是我对瓦西里答案的延伸。它有效地执行 dh_installdeb 的操作,但不会自动添加 /etc 文件。通过这种方式,您可以再次完全控制哪些文件被视为配置文件,哪些文件不是。

override_dh_installdeb:
  dh_installdeb
  @echo "Recreating conffiles without auto-adding /etc files"
  @for dir in ${CURDIR}/debian/*/DEBIAN; do \
      PKG=$(basename $(dirname $dir)); \
      FILES=""; \
      if [ -f ${CURDIR}/debian/conffiles ]; then \
          FILES="${CURDIR}/debian/conffiles"; \
      fi; \
      if [ -f ${CURDIR}/debian/${PKG}.conffiles ]; then \
          FILES="$FILES ${CURDIR}/debian/${PKG}.conffiles"; \
      fi; \
      if [ -n "$FILES" ]; then \
          cat $FILES | sort -u > $dir/conffiles; \
      elif [ -f $dir/conffiles ]; then \
          rm $dir/conffiles; \
      fi; \
  done

(当然,如果粘贴到规则文件中,请使用 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.

override_dh_installdeb:
  dh_installdeb
  @echo "Recreating conffiles without auto-adding /etc files"
  @for dir in ${CURDIR}/debian/*/DEBIAN; do \
      PKG=$(basename $(dirname $dir)); \
      FILES=""; \
      if [ -f ${CURDIR}/debian/conffiles ]; then \
          FILES="${CURDIR}/debian/conffiles"; \
      fi; \
      if [ -f ${CURDIR}/debian/${PKG}.conffiles ]; then \
          FILES="$FILES ${CURDIR}/debian/${PKG}.conffiles"; \
      fi; \
      if [ -n "$FILES" ]; then \
          cat $FILES | sort -u > $dir/conffiles; \
      elif [ -f $dir/conffiles ]; then \
          rm $dir/conffiles; \
      fi; \
  done

(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-specific debian/${pkg}.conffiles.

愁以何悠 2024-09-19 11:45:10

最初,这个答案建议提供您自己的 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 whole conffiles 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文