构建一个预配置的debian包 [英] Building a preconfigured debian package

查看:272
本文介绍了构建一个预配置的debian包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试建立一个debian包,它会自动配置我所有的机器使用相同的配置文件和设置。 alter / etc / default / hostapd。我目前这样做通过使用dh_install将文件复制到/ etc / default / hostapd与我想要的配置。



这导致错误: / p>

 尝试覆盖'/ etc / default / hostapd',这也是在包hostapd 

创建一个覆盖/ etc / default / hostapd等设置的debian软件包的正确方法是什么?

解决方案

错误的原因是任何将文件写入系统的包都被标记为其所有者。当两个包拥有相同的文件时,deb机制不喜欢。



您最好的选择是使用dpkg-divert为了将另一个包的文件重命名为不同的名称。在您的preinst脚本中,输入以下命令(假设您的包名为 my_package

 dpkg-divert  - /default/hostapd.saved。 my_package  --package  my_package  --rename --add / etc / default / hostapd 

在你的postrm脚本中,你需要使用相反的命令(未测试,RTFM来获得正确的语法):

 dpkg- divert --dvert /etc/default/hostapd.saved。 my_package  --package  my_package  --rename --remove / etc / default / hostapd 

至少在过去,有一个更简单的(虽然不太安全)选项在debian控制文件中放置一个conffile字段,告诉系统这个软件包安装文件覆盖另一个包的文件我不知道我会推荐这个方法,但是,因为它可能会破坏的情况下卸载。


I am trying to build a debian package which automatically configures all my machines to use the same configuration files and settings.

For example I am trying to set things like alter /etc/default/hostapd. I am currently doing this by using dh_install to copy a file to /etc/default/hostapd with the configuration I want it to have.

This results in the error:

trying to overwrite '/etc/default/hostapd', which is also in package hostapd

What is the correct way to create a debian package which overwrites the settings such as /etc/default/hostapd ?

解决方案

The reason for the error is because any package that writes a file to the system is marked as its owner. The deb mechanism does not like it when two packages own the same file.

Your best option is to use dpkg-divert in order to rename the other package's file to a different name. In your preinst script, put the following command (assuming your package is called my_package:

dpkg-divert --divert /etc/default/hostapd.saved.my_package --package my_package --rename --add /etc/default/hostapd

In your postrm script, you need to put the opposite command (untested, RTFM to get the precise syntax correctly):

dpkg-divert --divert /etc/default/hostapd.saved.my_package --package my_package --rename --remove /etc/default/hostapd

At least in the past, there was a simpler (though less safe) option to put a "conffile" field in the debian control file. This tells the system that this package installs files that overwrite another package's files. I'm not sure I would recommend this method, however, as it might break things in case of uninstall.

这篇关于构建一个预配置的debian包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆