EDIT: Last version is 1.0.4.
This is a script, which I wrote as a successor to the great cruft script by ecatmur.
Unfortunately ecatmur is not really maintaining this thing anymore, so I wrote a similar script borrowing some parts of cruft but trying to avoid some of the shortcomings of it.
(I think Ed wrote a successor himself - cruft2.py - but he never announced it and I don't know if he's working on it.)
The pretty verbose help message for this beast follows:
It is really easy to install:findcruft -h wrote:findcruft v1.0.4
Usage:
findcruft [ -h | -? ]
findcruft [ -D ] [ -f targetdir ]
findcruft > cruftlist
FINDCRUFT_CONFDIR=/path/to/confdir findcruft
Options:
-h:
Print this help message and exit.
-?:
Print short usage information and exit.
-D:
Switch to debug mode. Gives some diagnostic
information and does not clean the temporary
files after finishing.
-f targetdir:
Switch to force mode. Found cruft is packed
into a tar.bz2 archive in targetdir and
deleted.
This program compares the files on your filesystem to the ones
managed by portage and prints out files which do not belong to
any package.
Additionally it uses the files in /usr/local/lib/findcruft to
exclude false positives, i.e. configuration and similar files
which are not managed by portage, but should nevertheless be on
the system. You can manipulate the location of this directory
by the FINDCRUFT_CONFDIR environment variable.
All of the files in this directory are sourced into findcruft
(and hence processed by bash). Thus, you can use all of bash's
programming features. Additionally the following portage settings
are grabbed from the configuration and can be used in all files:
$PORTDIR, $DISTDIR, $PKGDIR, $PORT_LOGDIR, $PORTDIR_OVERLAY,
$PORTAGE_TMPDIR, $CCACHE_DIR, $ARCH, and $CHOST
The file ignore should output a list of directories which will
be completely ignored, i.e. they are neither searched during the
find phase nor during the building of the false positive list (as
long as you do not do it in your nopackage.local). You can also
add your own additions in an ignore.local file. This is handy if
you have some network file systems or similar which you do not
want to put under too heavy load.
The file symlink should output a list of symlink-target pairs,
which is applied to the contents of packages managed by portage.
This is necessary, because some packages install their files
e.g. into /usr/man, but this is a symlink to /usr/share/man.
You can add your own symlinks to symlink.local. For example if
/opt is a symlink to /usr/opt (because /opt was too big for the
root partition and you wanted it to be on the /usr partition
together with the other large applications) then add a line
echo /opt /usr/opt to symlink.local.
The other files are expected to output a list of false positive
files one file per line onto stdout. So, if you want to ignore
a single file you can just do echo /full/path/to/file. You can
use the predefined functions cruftfile /full/path/file_regexp and
cruftdir /full/path/dir_regexp, which do a grep on the unmanaged
files and ignore all files matching the given regexp or all
directories matching the regexp and their contents, respectively.
Look into the included files for more elaborated examples.
You can also use the functions from the file functions in these
rule files:
* nsplugin plugin.so plugin.a plugin.la adds all files given as
arguments to the false positives in the plugin directory for
Netscape style browsers (Mozilla, Firefox, ...).
* fontdir relative/path /absolute/path adds the generated cache,
directory, and scale files for font directories to the false
positives. If a relative path is given the directory is assumed
to reside under /usr/share/fonts.
* xpiapp relative/path /absolute/path adds the typical false
positives for XPI applications such as Mozilla and Firefox to
the list (i.e. things in the chrome and components directories,
etc.). Relative pathes are assumed under /usr/lib.
The file nopackage contains a list of false positives without
corresponding package (for some of these one might argue, that
they belong to some of the base packages, which are present on
any system, perhaps they will be moved to the corresponding
package sometime). The file nopackage.local can be used for
local settings.
The rest of the files is organized in a category/package
hierarchy. If a package is present on the system (according to
/var/db/pkg) the corresponding file is sourced with the
variables $VERSION set to the version and $SLOT set to the slot
of the package.
Please make additions to ignore, symlink, and nopackage in the
corresponding *.local files, so that they do not get overwritten,
when you unpack a new rule archive into the directory.
Code: Select all
$ cd
$ wget http://user.cs.tu-berlin.de/~sean/findcruft-1.0.4.tar.bz2
$ cd /usr/local
$ su -c "tar -xjf ${HOME}/findcruft-1.0.4.tar.bz2"Code: Select all
$ findcruft > cruftfilesThe files listed are the ones findcruft couldn't find a reason to exist for.
You can consider to delete them, but beware: They might as well be important application data.
If you think they are false positives and know to which package they belong you can create/edit a rule file in /usr/local/lib/findcruft/<category>/<package>.
Then, we can exchange these rule files in this thread and build new rule archives from time to time.
If it is a false positive due to a personal/local setting on your machine, you can add it into /usr/local/lib/findcruft/nopackage.local.
There it won't interfere with the exchanged rules.
Greetings,
sean



