2015-04-02 46 views
-1

我是使用rpm打包nodejs应用程序的新手段。如何处理nodejs应用程序的rpm配置更改

要求是我们总是合并我们可能在配置文件中所做的任何更改,而不清除sys管理员可能已经更改的任何设置。

正如你所猜测的,nodejs应用程序的配置文件在json中。

我调查了spec文件中的%config和%config(noreplace),并且noreplace更适合于如果我们在新的配置文件中添加了一些新的东西,然后将这些更改添加到现有文件而无需清除系统管理员可能做的任何更改。

我发现了很少的工具/ shell脚本,但我不确定是否有更直接的方法或最佳实践来实现这一点?

+0

我不知道我明白你在问什么,但一般来说,如果在rpm中有一个管理员可编辑的配置文件,那么它会被标记为'%config (noreplace)',并由管理员将其与新的上游配置文件进行比较,并在任何更改中手动合并。 – 2015-04-02 19:02:04

+0

我已经更新了这个问题。要求是合并配置文件中的潜在更改。这是非常基本的,在开发过程中,我们有时会向配置中添加密钥,但使用rpm(noreplace)时,这些密钥永远不会将其放到我们安装软件的位置。那么你在这种情况下做什么? – nolimit 2015-04-02 19:37:50

+0

为了让它看起来很清晰,我们可以检查并合并新转速变化到已经安装的转速吗?还是通常的做法是由系统管理员来合并更改(如果有)? – nolimit 2015-04-02 19:41:01

回答

0

您需要的是一种方法来检测.rpmsave文件%post部分规范。它可能看起来像这样:

%post 
# Check this during an update to the RPM $1 = 2 
if [ "$1" = "2" ] 
then 
    ######################################################################## 
    # apply updates to config files, preserving any customizations 
    # 1) restore original (customized) file if renamed to file.rpmsave 
    # 2) run all config files through config_updates.pl 
    ######################################################################## 
    # 
    # RPM query will get config files from old and new rpm, so there will be dups 
    # 
    IFS=$'\n' 
    # Eliminate dups by passing query through sort -u %name is RPM name 
    config_files=(`rpm -qc %name | sort -u`) 
    unset IFS 
    for AF in "${config_files[@]}" 
    do 
    # Search for config files with .rpmsave extension 
    [ -f "$RF.rpmsave" ] && { 
     # Save the new $RF file (cp -vf $RF $RF.new) 
     # Copy the original rpm config file renamed during 
     # the update with.rpmsave extension 
     # back to $RF (cp -vf $RF.rpmsave $RF) 
     # Launch another script to merge $RF.new into $RF. 
     %dir_to_config_script/config_updates.pl -file=$RF 
    } 
    done 
fi 
相关问题