We're developing a java product that's installed via rpm.We have a set of config files that a user can edit. These config files are java properties files in the form:com.acme.pkg1.setting=something customized 1com.acme.pkg2.setting=something original 2These files are marked in the SPEC file with %config(noreplace), so after an upgrade, we could have an .rpmnew file next to it:com.acme.pkg1.setting=something original 1com.acme.pkg2.setting=something original 2com.acme.pkg3.setting=something original 3Is there a way to merge these files in such a way that only new keys are added to the original file?My idea was:filter the keys sort the keys use comm(1), something like: comm -23 file.rpmnew.keys file.keys > new.keys extract key=value from file.rpmnew matching new.keysappend result to original fileHow can we achieve all this in from an rpm post-update script?Preferably using only standard linux utilities (comm, diff, sed, awk, grep, ...)?
Shell script to merge properties file (sed/awk/comm/diff) for rpm upgrade
shell script;rpm;merge
Build raw original and raw target values without settings:sed s/=.*//g file_original.ini > file_original.rawsed s/=.*//g file_target.ini > file_target.rawI assume that target will have more options than the original. Build the difference:grep -vf original.raw target.raw > newvals.datAdd the new Values:cp -p file_original.ini file_original.ini.rpmsavegrep -f newvals.dat file_target.ini >>file_original.iniThat`s the basic idea. It needs lots of error handling, clean tmp-file creation and tidying up. 