我在自定义 .deb 包及其触发器方面遇到了一个反复出现的问题。我们为我们的部署制作了一些“元包”,以强制和检查一些配置。我们的想法是让许多服务器保持“相同”的配置,而无需在每次更新时手动检查。我们以它们为例:grafana-conf和elasticsearch-conf。
为了在“子包”更新时执行重新配置脚本,我们使用以下触发器。
- grafana-conf触发器:
interest /usr/share/grafana
interest grafana-reconfigure
- elasticsearch-conf触发器:
interest /usr/share/elasticsearch/bin
interest elastic-reconfigure
有时,它会按预期工作,但在某些情况下,dpkg 会说存在触发循环。在这种情况下,如果elasticsearch
和grafana
在同一事务上得到更新,我们会收到以下消息:
[...]
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for dbus (1.12.16-2ubuntu2.3) ...
Setting up unrelated-package (1.2.1) ...
dpkg: cycle found while processing triggers:
chain of packages whose triggers are or may be responsible:
elasticsearch-conf -> grafana-conf
packages' pending triggers which are or may be unresolvable:
grafana-conf: /usr/share/grafana
elasticsearch-conf: /usr/share/elasticsearch/bin
initramfs-tools: update-initramfs
dpkg: error processing package grafana-conf (--configure):
triggers looping, abandoned
dpkg: cycle found while processing triggers:
chain of packages whose triggers are or may be responsible:
elasticsearch-conf -> elasticsearch-conf -> elasticsearch-conf
packages' pending triggers which are or may be unresolvable:
elasticsearch-conf: /usr/share/elasticsearch/bin
initramfs-tools: update-initramfs
dpkg: error processing package elasticsearch-conf (--configure):
triggers looping, abandoned
Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
[...]
Errors were encountered while processing:
grafana-conf
elasticsearch-conf
我们已经测试了触发器的许多变体,但我们不明白那里出了什么问题。阅读 debian/deb 文档说一切都应该正常工作。
有人能帮助我/我们了解我们遗漏了什么(可能很基本的)错误吗?提前谢谢您!
附言:命名触发器grafana-reconfigure
正在底部的 postinst 脚本中被调用grafana-conf。我们尝试删除此类调用,但循环仍然出现。当然,dpkg-trigger
它永远不会在“触发器”调用中被调用。命名触发器elastic-reconfigure
根本没有被使用。
Ps2:在其他一些场景中我遇到了如下循环:grafana-conf -> grafana-conf -> grafana-conf