使用 Debhelper 管理配置文件

使用 Debhelper 管理配置文件

我使用 Debhelper 为 Debian 打包了一个应用程序。该应用程序的配置文件位于/opt/{package}/releases/default/而不是下/etc/{package}/,无法轻易移动。直到最近,要将此配置文件标记为 conffile,只需将其包含在打包文件中debian/{package}.conffiles。这产生了预期的效果,即 apt/dpkg 会在升级时检测到配置文件的本地更改并以智能方式处理它,而不是用打包版本破坏本地更改。

将软件包工具升级到较新版本后,我不再享受此好处。手册页 dh_installdeb(1) 内容如下:

{package}.conffiles:
  Historically, this file was needed to manually mark files files as 
  conffiles.  However, it has become de facto obsolete since debhelper 
  automatically computed which files should be marked as conffiles.

此外,来自 Debian 新维护者指南:

5.3. conffiles
  dh_installdeb(1) automatically flags any files under the /etc directory 
  as conffiles, so if your program only has conffiles there you do not 
  need to specify them in this file. For most package types, the only place 
  conffiles should ever be is under /etc, and so this file doesn't need to exist.

我的问题是如何通过保存配置文件来实现旧的行为/opt/

答案1

Debian 政策说配置文件必须在/etc,如果无法修改包以直接读取,则使用符号链接/etc

10.7.2. 位置

你的软件包创建或使用的任何配置文件都必须位于/etc. [...]

如果您的软件包在 之外创建或使用了 配置文件/etc,并且无法修改软件包以供/etc直接使用,请将文件放入/etc并从软件包所需的位置创建到这些文件的符号链接。

相关内容