Debian:在 initscript 中保留自定义更改

Mar*_*ter 5 debian apt

我不得不修改 Postfix 的 initscript/etc/init.d/postfix以根据我的特殊需要对其进行自定义。现在我想确保,如果postfix将来更新软件包(我正在运行 Debian Wheezy Stable,但仍然可能有安全更新),我修改后的 initscript 不会被覆盖。据我了解,包在覆盖config文件之前会询问,而不是 initscripts。

推荐的方法是什么(干净地)?

slm*_*slm 7

我想你正在寻找dpkg-divert.

来自文档:11.8 如何覆盖由包安装的文件,以便可以使用不同的版本?.

文档摘录

假设系统管理员或本地用户希望使用程序“login-local”而不是 Debian 登录包提供的程序“login”。

不要:

覆盖/bin/loginlogin-local

包管理系统不会知道此更改,并且会/bin/login在安装或更新时login(或提供 的任何包/bin/login)简单地覆盖您的自定义。

而是,做

执行:

   $ sudo dpkg-divert --divert /bin/login.debian /bin/login
Run Code Online (Sandbox Code Playgroud)

为了使Debian的所有将来的安装login包文件写入/bin/login/bin/login.debian代替。

然后执行:

   $ sudo cp login-local /bin/login
Run Code Online (Sandbox Code Playgroud)

将您自己的本地构建程序移动到位。

运行dpkg-divert --list以查看当前在您的系统上处于活动状态的转移。

详细信息在手册页中给出dpkg-divert(8)

我会确定原始 Postfix init 脚本与哪个包分开,并使用您的修改版本转移这个文件。


Gil*_*il' 5

All files under /etc are classified as “conffiles” (by Debian policy, it's specified in the package, not built in to dpkg). Dpkg prompts whether to overwrites each changed conffile on upgrade. Init scripts are no exception.

If you don't want to get prompted, or if you need this on a file in a package that isn't a conffile, you can use a diversion.

dpkg-divert --add --local --rename --divert /etc/init/postfix.debian /etc/init/postfix
Run Code Online (Sandbox Code Playgroud)