Most packages contain files that you don’t need: for example translations in languages that you don’t understand, or documentation that you don’t read. Wouldn’t it be nice if you could get rid of them and save a few megabytes? Good news: since dpkg 1.15.8 you can!
dpkg has two options
--path-exclude=glob-pattern that control what files are installed or not. The pattern work the same than what you’re used to on the shell (see the glob(7) manual page).
Passing those options on the command-line would be impractical, so the best way to use them is to put them in a file in
/etc/dpkg/dpkg.cfg.d/. Beware, the order of the options does matter: when a file matches several options, the last one makes the decision.
A typical usage is to first exclude a directory and then to re-include parts of that directory that you want to keep. For example if you want to drop gettext translations and translated manual pages except French, you could put this in
# Drop locales except French path-exclude=/usr/share/locale/* path-include=/usr/share/locale/fr/* path-include=/usr/share/locale/locale.alias # Drop translated manual pages except French path-exclude=/usr/share/man/* path-include=/usr/share/man/man[1-9]/* path-include=/usr/share/man/fr*/*
Note that the files will vanish progressively every time that a package is upgraded. If you want to save space immediately, you have to reinstall the packages present in your system.
aptitude reinstall or
apt-get --reinstall install might help. In theory with aptitude you can even do
aptitude reinstall ~i but it tends to not work because one package is not available (either because it was installed manually or because the installed version has been superseded by a newer version on the mirror).
Found it useful? Click here to see how you can encourage me to provide more articles like this one.