Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I installed php5-fpm package using apt; then I made some changes to the PHP configuration files.

Now I would get the diffs between the original files versions (the ones of the package installed) and the current versions (modified by me). How to do it?

share|improve this question
    
It is hard to understand what exactly you want to know. It is not even clear what your situation is. –  Hauke Laging Apr 17 '13 at 11:01
    
I don't know if apt can tell you that, but what I do recommend is to put /etc under revision control (I use mercurial for that) and add and commit on a regular basis. That way you can roll back to original files, or to intermediate changed states and with hg diff you can see changes. If you cannot find a way to do this with apt, backup your changed files, reinstall the packag(es), bring the config files under revision control and copy back your changes. After that you can do a diff. –  Anthon Apr 17 '13 at 11:03
    
@HaukeLaging I am not good at english, I'm sorry –  mdesantis Apr 17 '13 at 14:18
    
@Anthon thank you for the suggestion :-) –  mdesantis Apr 17 '13 at 14:18

3 Answers 3

up vote 5 down vote accepted

Try something like this:

# exit on failure
set -e

package=php5-fpm
mkdir $package
cd $package

# you could also get the file from a package mirror if you have
#  an older version of apt-get that doesn't support 'download' 
#  or if you would like more control over what package version
#  you are downloading.
# (e.g. http://archive.ubuntu.com/ubuntu/pool/main/)
apt-get download $package

# deb package files are ar archives
ar vx ${package}*.deb
# containing some compressed tar archives
tar xzf data.tar.gz
# now you have the files

# you can get diffs for all of the files in etc if you would like
find etc -type f |
while read file ; do
    diff $file /$file
done

As suggested by others, definitely put your configuration files under revision control. That way, you can see exactly what you changed and when you changed it.

share|improve this answer
    
Thank you! I had to modify a bit the code: gist.github.com/ProGNOMmers/5404609 if you update your question with working code I will be happy to accept it –  mdesantis Apr 17 '13 at 14:13
    
I'm glad my solution worked for you. I have included your changes and fixes in my code. –  paraxor Apr 17 '13 at 14:44

etc directory

For tracking changes to your /etc directory you can do as @Athon has suggested and use git, subversion, mercurial, etc. to version control that directory. You can also use a tool such as etckeeper. There's a tutorial here as well as here.

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, bazaar or darcs repository. It hooks into apt to automatically commit changes made to /etc during package upgrades. It tracks file metadata that git does not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with version control.

package files

To my knowledge apt does not have a way to check the files on disk vs. the files that are in the actual .deb. Neither does dpkg, the tool that apt is actually using to do the management of files.

However you can use a tool such as debsums to compare some of the files you have installed, it only looks at their checksums (md5sum) of what's in the .deb file vs. what's on your systems disk.

See this serverfault question for more details about debsum and dpkg checksumming, as well as this askubuntu question.

debsum example

% debsums openssh-server
/usr/lib/openssh/sftp-server                                                  OK
/usr/sbin/sshd                                                                OK
/usr/share/lintian/overrides/openssh-server                                   OK
/usr/share/man/man5/sshd_config.5.gz                                          OK
/usr/share/man/man8/sshd.8.gz                                                 OK
/usr/share/man/man8/sftp-server.8.gz                                          OK
share|improve this answer
    
thank you a lot! I didn't know about the practice to keep /etc under revision control, and etckeeper seems the right solution in order to manage it; I will adopt it –  mdesantis Apr 17 '13 at 14:16

I wrote the following simple script to automatically retrieve the original file from the right Debian package and diff the current file against it: https://gitorious.org/mybin/mybin/source/master:debdiffconf

Use it as follows: debdiffconf FILE

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.