Linux software updates – How to resolve changed configuration files.

Sometimes, when you’re updating software on your Linux machine, the person maintaining the package will have also updated the default configuration file that ships with the software.

This is an issue if you have customised that configuration file on your system – the system doesn’t know whether it should keep your version, use the new one, or something else. So it asks you to decide what to do about it.

I’m using Debian, which uses the dpkg package management system – that name may be unfamiliar, but if you’ve used any of the Debain family (Ubuntu, Mint, MX, elementary etc.) you will have used one of the friendlier wrappers around it: apt or apt-get.

Today, it’s the Collabora Office configuration file that has been updated:

Configuration file '/etc/loolwsd/loolwsd.xml'
 ==> 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.
*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ?
  • The first option is self-explanatory – you’ll lose any customizations you’ve made, but that might be OK for you.
  • Keeping your currently-installed version is usually OK – well designed software shouldn’t break because it’s missing a line in an old configuration file.

In either case the system will keep a copy of the one you don’t pick, so you can change your mind later. If you choose to use the package mantainer’s version, there will be a copy of your old one with .dpkg-old added to the filename. If you keep you own config file, the package maintainer’s version will be saved alongside it, with .dpkg-dist added to the filename.

  • Choosing option D can help you decide – but ultimately doesn’t resolve the situation.
  • Option Z is the point of today’s post – this is how you can fix the situation.

Lets hit Z, and this is what I get:

 The default action is to keep your current version.
*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ? Z
Useful environment variables:
Type 'exit' when you're done.

The system tells you about 3 environment variables that might be useful to help fix the situation. here I’ve use the echo command (with a $ before the environment variable name) to see what’s in them:

root@waldorf:/# echo $DPKG_SHELL_REASON
root@waldorf:/# echo $DPKG_CONFFILE_OLD
root@waldorf:/# echo $DPKG_CONFFILE_NEW

DPKG_CONFFILE_PROMPT isn’t much use to us, but the other two are. We can start a program to compare and merge the differences between the two. I’m using Neovim in diff mode – there are lots of otherways of doing this – I’d suggest you do your research and find your preferred merge tool or text editor.

root@waldorf:/# nvim -d $DPKG_CONFFILE_OLD $DPKG_CONFFILE_NEW

I wont to get into the details of how to use [Neo]vim, but if you’re already a vim user and haven’t used diff mode before, these commands will get you started. You can find more info in the documentation.

<Ctrl-w> lMove to the right window
<Ctrl-w> hMove to the left window
]cMove to the next change
[cMove to the previous change
:diffgetCopy the change you’re on from the other window
:diffputPush the change from your current window into the other one.

Note that the last two commands will make the files the same at that point

Modifiy one of the files (I typically modify my old file – pulling the changes from the new one that I want, and leaving the ones that I don’t), then save and exit your text editor or mergetool

Type exit at the prompt, then the system will ask you again what you want to do:

*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ?

In this case I’ll choose N or O because I’ve made the changes I want to the original config file.

Leave a Reply

Your email address will not be published. Required fields are marked *