[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Cruft -- find any leftover files on your system

Hello world,

I felt like doing some scripting over the weekend, and managed
to come up with "cruft", version 0.9 of which is available from
http://va.debian.org/~ajt/ in i386 .deb format, or as deb-source. 

Please note, it's a pre-release, so I'm not particularly sure that
I've ironed out all the bugs, and it *does* run as root so bad things
*can* happen. That said, none have happened to *me*, yet, so... :)

Anyway, it's based on an idea of, iirc, Manoj's -- writing a script 
that does a "find /" and then compares the output of that to the .list
files that dpkg maintains, to see just how accurate dpkg's picture
of your system is.

Considering that doing that alone left a few thousand files unaccounted
for, I added a few extra rules, and tidied up the output and the like
a little, and ended up with a program that checks through:

	dpkg's database
	the alternatives database
	user's home directories
	rc.d scripts
	lost+found files
	/usr/local files
	/home/ftp files

(and then goes ahead and just accepts everything in /dev, /etc, /usr/src,
and /var/www because I couldn't think of good ways to determine what
should be in them :( )

It's also possible to add local "explanations" for files, for example
my system has an unpack-the-tgz installation of a program called "possum"
in /home/possum, so I've added a short script that produces a list of
all those files in /usr/local/lib/cruft/explain/possum, which cruft
automatically includes in its considerations.

When it's done, it produces two sets of reports:

	files that should be on your system, according to one set of
	"explanations" (eg, the alternatives database thinks it should
	have /etc/alternatives/editor.1 pointing somewhere, but there's
	no such file in /etc), but aren't.

and	files that are on your system, but cruft couldn't see a reason
	for them to be there.

The former are categorized by "explanation", the latter by mount point,
and all are dumped in /var/spool/cruft/, at the moment.

It takes about ten minutes to run on my system (600MB in /usr, another
600MB scattered through /var and /home, all IDE), which doesn't seem
too bad, although I'm hoping I can shave a little off that time. On my
system it uses up about 10MB in /var/spool/cruft, and can get up to
about 5MB in /tmp while sort(1) dumps temporary data.

I'd appreciate it if some of you kind folks would be willing to have a
look through it and perhaps run it over your system and if you can 
either give me some procedures for making sense of a few more files that
are left lying around on your system; or suggestions on improving the
output format.

I'd _really_ like some way of working out what stuff should be in /etc,
and what stuff shouldn't, but a number of the files in there are made
in postinsts and I couldn't come up with a nice way of dealing with that.

As an example of the output it produces, here's the contents of 
/var/spool/cruft/miss_*, and /var/spool/cruft/unex_in_{home,root}.






Finally, thanks to the folks on #debian for their tips, tricks and
diverting banter when I got stuck, and in particular to Adam "doogie"
Heath, for his suggestions and complaining that error messages like 
"rm: *: No such file or directory" aren't really as reassuring as they 
could be. :)


Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. PGP encrypted mail preferred.

      ``It's not a vision, or a fear. It's just a thought.''

Attachment: pgp4fCobcL4dv.pgp
Description: PGP signature

Reply to: