'Buyer's Remorse' with apt

This morning I installed some updates that asked me if I wanted to replace configuration files:

Configuration file '/etc/apache2/envvars'
 ==> 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.
*** envvars (Y/I/N/O/D/Z) [default=N] ? N

I kept my current configuration, but after that, I started wondering:

Is there a way to see what the new config file would have looked like, after the fact?


Solution 1:

I haven't tested this but logic dictates that you could review the file contained in the package that was updating. I'm assuming the apache2 package for your current distribution selectable from this page (you can confirm by checking your dpkg.log)

DEB files are archives, which always contain the three files — debian-binary, control.tar.gz, and data.tar.gz. We can use dpkg-deb and tar command to extract and view the files from the deb package, as shown below.

Simply extract the files from the package to a temporary location. As an example: dpkg-deb -x packagename.deb /tmp Adjusting the package name and target location as necessary.

Having extracted the content of the package, next extract the content of the included data.tar.gz component with tar -xvzf data.tar.gz

Locate the included envvars file (you could use find ./ -name envvars from the location you extracted the data.tar.gz file.

Having located the file navigate to that directory and use diff envvars /etc/apache2/envvars to display the differences between your current configuration file and the suggested one. Sources:

http://www.thegeekstuff.com/2010/04/view-and-extract-packages/

man dpkg

man dpkg-deb

man diff

Solution 2:

I'm accepting Elder Geek's answer because it works and seems to be the most generally applicable without being too labor intensive. Waltinator's answer seems to me that it would work but I am leery of reinstalling.

However, I did come up with 2 additional ways to address this problem.

  1. I have a clone of my server running in a Virtualbox VM. I took a snapshot, applied the update (choosing the package maintainer's versions), copied those versions off to a shared drive, then deleted the snapshot, and did the update for reals.

    Downside: normally I do the update in the virtual machine first before the real machine, so I would have to know to take the snapshot first. Maybe this is good practice before applying any apache2 update? I will have to think about that.

  2. This is the easiest answer of all, but I do not know if it is generally applicable. I was using aptitude and updating apache2, and in the /etc/apache2/ folder, I found copies of the package maintainer's config files that I had rejected! They were named apache2.conf.dkpg-dist and envvars.dpkg-dist! How cool is that?

Downside: I don't know if this only happens with aptitude and\or apache2, this may not be generally applicable.