This script tries to list all the cruft on a system with as few as possible false positives to help you keep your system in good working order.
Note that plenty of packages drop extra files all over the place; any extra help is appreciated.
NOTE: This is not the whole script, I got bored updating it in two places so this is just a sample. Follow the below link for the actual script.
Code: Select all
#!/bin/bash
#
# Author: Ed Catmur <ed@catmur.co.uk>
# Licensed under the GNU Public License, version 2.
#
# Copyright © Ed Catmur 2004
# Contains code believed to be copyright © Gentoo Technologies, Inc.
has_version() {
if /usr/lib/portage/bin/portageq 'has_version' "${ROOT}" "$1"; then
return 0
else
return 1
fi
}
best_version() {
if /usr/lib/portage/bin/portageq 'best_version' "${ROOT}" "$1"; then
return 0
else
return 1
fi
}
#
# name: python_version
# desc: run without arguments and it will export the version of python
# currently in use as $PYVER
#
python_version() {
local tmpstr
python=${python:-/usr/bin/python}
tmpstr="$(${python} -V 2>&1 )"
export PYVER_ALL="${tmpstr#Python }"
export PYVER_MAJOR=$(echo ${PYVER_ALL} | cut -d. -f1)
export PYVER_MINOR=$(echo ${PYVER_ALL} | cut -d. -f2)
export PYVER_MICRO=$(echo ${PYVER_ALL} | cut -d. -f3-)
export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
}
ROOT="/"
# Files and directory trees to omit, ordered alphabetically.
# If a package drops files or directories in more than one place, move its
# definitions to the appropriate stanza. ldconfig symlinks go in the last
# stanza. Put large lists of single files next to the CONTENTS listing code.
PRUNE="
/boot
/dev
$([ -h /etc/runlevels/boot/clock ] && echo "/etc/adjtime")
$([ -d /proc/asound ] && echo "/etc/asound.state")
$(has_version net-wireless/bluez-utils && echo "/etc/bluetooth/link_key")
/etc/config-archive
$(echo /etc/cron.{hourly,daily,weekly,monthly})
/etc/csh.env
/etc/dnsdomainname
$(echo /etc/env.d/??hostname)
$(echo /etc/env.d/??locale)
$(has_version dev-java/java-config && echo "/etc/env.d/20java")
$(has_version sys-devel/prelink && echo "/etc/env.d/99prelink")
/etc/gconf/gconf.xml.defaults
/etc/gentoo-release
/etc/group /etc/group-
/etc/gshadow /etc/gshadow-
$(has_version x11-libs/gtk+ && echo "/etc/gtk-2.0/gtk.immodules")
/etc/hostname
/etc/hosts
/etc/ioctl.save
/etc/ld.so.cache
/etc/ld.so.conf
/etc/localtime
/etc/make.conf
/etc/make.profile
/etc/modprobe.conf /etc/modprobe.conf.old
/etc/modprobe.devfs /etc/modprobe.devfs.old
/etc/modules.conf /etc/modules.conf.old
/etc/motd
/etc/mtab
$(has_version x11-libs/pango && echo "/etc/pango/pango.modules")
/etc/passwd /etc/passwd-
/etc/portage
$(has_version net-dialup/ppp && echo "/etc/ppp")
$(has_version sys-devel/prelink && echo "/etc/prelink.cache")
/etc/profile.env
/etc/resolv.conf
/etc/runlevels
...
$(has_version app-admin/syslog-ng && echo "/var/run/syslog-ng.pid")
/var/run/utmp
$(echo /var/spool/cron/crontabs/*)
$(echo /var/spool/cron/lastrun/cron.{hourly,daily,weekly,monthly})
/var/tmp/distfiles
/var/tmp/portage
/var/tmp/portage-pkg
/var/tmp/sync
"
# Packages which drop files or directories on more than one place go here,
# listed alphabetically by cp.
has_version app-text/docbook-sgml-dtd \
&& PRUNE="${PRUNE}
$(cat /var/db/pkg/app-text/docbook-sgml-dtd-*/SLOT | sed 's:^:/etc/sgml/sgml-docbook-:; s:$:.cat:')
/etc/sgml/sgml.cenv
/etc/sgml/sgml.env"
...
has_version x11-misc/electricsheep \
&& PRUNE="${PRUNE}
$(echo /usr/share/electricsheep-{frown,smile,splash-{0,1}}.tif)
/var/cache/sheep"
# Packages which omit ldconfig symlinks (to test, delete the symlink and see
# if ldconfig recreates it). Specify at least to minor, these are ugly.
has_version '=gnome-extra/vfs-menu-applet-0.1*' \
&& PRUNE="${PRUNE} /usr/lib/libvfsmenu-applet.0"
has_version '=net-fs/samba-3.0*' \
&& PRUNE="${PRUNE} /usr/lib/libsmbclient.so.0"
has_version '=media-libs/xvid-1.0*' \
&& PRUNE="${PRUNE} /usr/lib/libxvidcore.so.4"
has_version '=media-video/nvidia-glx-1.0*' \
&& PRUNE="${PRUNE} /usr/X11R6/lib/libXvMCNVIDIA_dynamic.so.1"
# awk: filter out pyc and pyo files for which the corresponding .py exists
find / '(' -false $(echo $PRUNE | xargs -n 1 echo -or -path) \
')' -prune -or -print \
| sort \
| awk '/\.py$/ { py=$0; } $0 !~ "^"py"[co]$"' \
>/tmp/allfiles
(
echo "/"
# sed code stolen from qpkg
cat /var/db/pkg/*/*/CONTENTS \
| sed -e "s:\(^obj \)\(.*\)\( .*\)\{2\}$:\2:;
s:\(^sym \)\(.*\)\( -> \)\(.*\)\( .*\)$:\2:;
s:\(^dir \)\(.*\)$:\2:"
# Generate cached man pages
for manx in /usr/share/man/man*; do
x=${manx#/usr/share/man/man}
for manp in $manx/*; do
p=${manp#$manx/};
echo "/var/cache/man/cat$x/${p%.gz}.bz2"
done
done
# The gnome-games ebuild doesn't install scores files that already
# exist on the filesystem (silly!)
has_version gnome-extra/gnome-games \
&& for game in $(
cat /var/db/pkg/gnome-extra/gnome-games-*/CONTENTS \
| grep '^obj /usr/bin/'\
| sed "s:\(^obj \)/usr/bin/\(.*\)\( .*\)\{2\}$:\2:"
); do
find /var/lib/games/${game}.*.scores /var/lib/games/${game}.scores 2>/dev/null
done
) \
| sort \
| uniq \
>/tmp/portagefiles
comm -2 -3 /tmp/allfiles /tmp/portagefiles





