How can I view the differences between the current state of a conffile and the clean state when the package was installed?
I am running Ubuntu Server upgrade from 12.04 to 14.04. The installer claims that several configuration files were changed locally:
Configuration file `/etc/bash.bashrc'
==> 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.
*** bash.bashrc (Y/I/N/O/D/Z) [default=N] ?
(Source of the example: https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/)
When I choose D to check differences, my current conffile is compared to the clean state in the new package version.
Sometimes there are lots of lines that were changed between the package versions and are not local modifications for sure. I would like to filter such changes and display the true local modifications. Otherwise an important single-line local modification can be easily overlooked.
For example php.ini
has 447 changed lines according to:
diff /usr/share/php5/php.ini-production /etc/php5/apache2/php.ini | grep -E '^[<>]' -c
Archive(backup) your config files before modifying them.
A possible system would result in...
/etc/.archives/bash.bashrc.00 would be the original distributed version. You could use dates instead of numbers if you don't mind long names...
You could write a script to make this easier too.
Press Z to enter shell.
Get the name of the package which provided the file. During a system upgrade,
apt
anddpkg
commands point to the new version already, so you need another source to check your previous version: Open http://packages.ubuntu.com/ and enter the file name in Search the contents of packages. Select the system version (“distribution”) you are upgrading from.If you found nothing, return to the conflict resolution interface (
exit
) and press D to display differences. Check the diff header, it shows the desired file name:In this case, it is
/usr/share/php5/php.ini-production
. Search the webpage for this file.Choose the correct package name, your system’s architecture and get the URL of the package (the link below You can download the requested file from…).
Download the package.
Extract the file you want to compare.
Check the difference.
The instructions are based on https://askubuntu.com/a/627018/250300.