简体   繁体   English

将新的配置参数添加到程序包的配置文件中时该怎么办?

[英]What should I do when I add a new config parameter to config file of my package?

I am dealing with making some packages of some projects. 我正在处理一些项目的软件包。

Assume I have a config file like that in my project. 假设我的项目中有一个类似的配置文件。

name=foo
mail=foo@foo.com

After installation user edits config file with his/her information. 安装后,用户使用其信息编辑配置文件。

name=user
mail=user@somedomain.com

When a update comes, for the purpose of not ruin the users config file, I do not replace conf file with new ones as all packages should do. 当有更新时,为了不破坏用户的配置文件,我不像所有软件包一样将conf文件替换为新文件。

There is no problem up to this point. 到现在为止没有问题。

What if I add a new parameter to my config file? 如果我在配置文件中添加新参数怎么办? For example, 例如,

name=foo
mail=foo@foo.com
age=23 

If I replace config file with new one, user will lost its settings. 如果我用新的替换配置文件,用户将丢失其设置。 If I don't, my new parameter could not be used. 如果没有,则无法使用新参数。 I wonder what is the general procedures for this conditions? 我想知道这种情况的一般程序是什么? My question is valid no matter what package types it is (ie rpm, deb or tbz). 我的问题是有效的,无论它是什么包类型(即rpm,deb或tbz)。

I'm not sure I see the problem. 我不确定是否看到了问题。 As long as the software can handle the absence of the field in the config file (ie, use a reasonable default), then there is no difference in the two scenarios you describe. 只要软件可以处理配置文件中字段的缺失(即使用合理的默认值),那么在您描述的两种情况下就没有区别。 If you software cannot handle the absence of the field, I would argue that is a bug. 如果您的软件无法处理该字段的缺失,那么我认为这是一个错误。

@William Pursell: Just because you don't see the problem, that does not mean that there isn't a problem. @威廉·普塞尔(William Pursell):仅仅因为您没有看到问题,并不意味着就没有问题。

This definitively is a problem and it has plagued me since I maintain deb packages. 这肯定是一个问题,自从我维护了deb软件包以来,这困扰了我。 For example: many configuration files contain commented configuration items and other comments that the package user is supposed to read and understand before applying his configuration changes. 例如:许多配置文件包含注释的配置项以及程序包用户应在应用其配置更改之前阅读并理解的其他注释。 If, in the normal course of software development, there are new configuration items, new default values, or different semantics to existing ones, the comments have to be adapted. 如果在软件开发的正常过程中,存在新的配置项,新的默认值或与现有配置不同的语义,则必须修改注释。 This is the package maintainer's job. 这是软件包维护者的工作。 But at the same time, the package must not mess with the configuration changes already applied by the user. 但是同时,该程序包一定不能弄乱用户已经应用的配置更改。

When I do this in Debian/Ubuntu, the package user is confronted with this intimidating question: 当我在Debian / Ubuntu中执行此操作时,软件包用户会遇到以下令人生畏的问题:

Configuration file `/etc/...'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** ... (Y/I/N/O/D/Z) [default=N] ?

for every single file. 对于每个文件。 That is, for some package upgrades, the user has to type yes/no/maybe :-) many times, every time. 也就是说,对于某些软件包升级,用户每次必须多次键入是/否/也许是:-)。 Fact is that the package user usually does not know what this is all about. 事实是,软件包用户通常不知道这是怎么回事。 She has to dig into the files, diff versions, and do some guessing in order to figure out a reasonable answer. 她必须深入研究文件,差异版本并进行一些猜测,以找出合理的答案。 An answer, by the way, that the package maintainer could have made already, if the packaging system would allow it. 顺便说一句,如果包装系统允许,包装维护者可能已经做出了答案。

I recognize that there may not exist a general solution to this problem. 我认识到可能不存在针对此问题的一般解决方案。 But I'd love to hear how other package maintainers cope with the situation. 但我很想听听其他包装维护者如何应对这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该在主管配置文件中输入哪个进程号? - What process number should I put in my supervisor config file? 我该如何在VIM配置中进行更改? (删除箭头) - What do I change in my VIM config to do this? (remove the arrows) 我应该使用什么过程来构建linux配置页面? - What process should I use to build a linux config page? 我应该在哪里保存我的配置文件 Rust - Where should I save my config files in Rust 当我更改.config文件或制作内核包时,如何防止重新编译所有linux内核对象? - How to prevent recompile all of linux kernel objects when I have changed .config file or made kernel package? 当脚本中的用户发生变化时,我的脚本文件停止执行我该怎么办 - My script file stopped executing when there change in user in script what should i do 如何获取正确的.config文件来编译特定于我的硬件的Linux内核源代码? - How do I get the correct .config file for compiling the Linux kernel source specific to my hardware? 如何在VIM配置中进行此更改? - How do I make this change in my VIM config? 如何将nginx -t(配置测试)的输出写入文件? - How do I write the output of nginx -t (config test) to a file? 如何从 linux 命令验证 Erlang 配置文件 - How do I validate an Erlang config file from a linux command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM