Re: get list of config files (with aptitude) tha were manually changed
On Wed, Dec 24, 2008 at 06:29:27PM -0500, "A. F. Cano" <afc@shibaya.lonestar.org> was heard to say:
> I know that this is checked somehow as I have been asked which config
> file to install or leave alone when upgrading various packages with
> aptitude.
I don't know any tool to do this offhand. But all the information is
in /var/lib/dpkg/status, so it's easy to do this with a script. The
attached Python script will print out the names of all the conffiles on
your system that have been changed or removed since they were installed.
If you are a non-root user, it also lists conffiles that you can't read;
on my system there are 7 of those.
Warning: my testing consisted of running it on my computer and
eyeballing the results to check that they made sense. If it breaks you
get to keep both pieces.
Daniel
#!/usr/bin/python
import hashlib
import re
f = file('/var/lib/dpkg/status')
conffile_start = re.compile('^Conffiles:\n')
in_conffile = False
for line in f:
if in_conffile:
if line[0] <> ' ':
in_conffile = False
else:
# This breaks if any conffile has spaces in its name.
entries = line.split()
filename = entries[0]
expected_md5 = entries[1]
hasher = hashlib.md5()
try:
f2 = file(filename)
l = f2.read(4096)
while l <> '':
hasher.update(l)
l = f2.read(4096)
seen_md5 = hasher.hexdigest()
if seen_md5 <> expected_md5:
print filename, expected_md5, seen_md5
except:
print filename, expected_md5
else:
if conffile_start.match(line):
in_conffile = True
Reply to: