Aqui está um script que faz isso. Porém, nenhuma saída amigável à máquina.
sudo apt-get install python-apt
e você está pronto para ir.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import apt
from apt.cache import Filter, FilteredCache
MB = 1024*1024
class InstalledFilter(Filter):
def apply(self, pkg):
return pkg.is_installed
def iter_base_deps(cache, package):
deps = []
version = package.installed
for dep_type in ('Depends', 'PreDepends', 'Recommends'):
deps.extend(version.get_dependencies(dep_type))
for dep in deps:
for base_dep in dep:
if base_dep.name in cache:
yield base_dep
def main():
package_ref_count = {}
results = []
cache = FilteredCache(apt.Cache())
cache.set_filter(InstalledFilter())
for package in cache:
for base_dep in iter_base_deps(cache, package):
if base_dep.name in package_ref_count:
package_ref_count[base_dep.name] += 1
else:
package_ref_count[base_dep.name] = 1
for package in cache:
base_deps_size = 0
base_deps = []
for base_dep in iter_base_deps(cache, package):
if package_ref_count[base_dep.name] == 1:
base_deps.append(base_dep)
base_deps_size += cache[base_dep.name].installed.installed_size
total_size = package.installed.installed_size + base_deps_size
results.append((total_size, package, base_deps_size, base_deps))
for total_size, package, base_deps_size, base_deps in sorted(results, reverse=True):
if package.name in package_ref_count:
continue
if total_size < MB:
break
self_size = package.installed.installed_size
base_dep_count = len(base_deps)
print('{:.1f} MB {}'.format(total_size/MB, package.name) + \
(' with {} deps'.format(base_dep_count) if base_dep_count else ''))
if base_dep_count:
print(' {:.1f} MB self'.format(self_size/MB))
for base_dep in base_deps:
size = cache[base_dep.name].installed.installed_size
print(' {:.1f} MB {}'.format(size/MB, base_dep.name))
if __name__ == '__main__':
main()
Exemplo de saída:
72.6 MB gthumb with 4 deps
3.0 MB self
61.0 MB libwebkit2gtk-3.0-25
8.0 MB gthumb-data
0.1 MB gstreamer0.10-gnomevfs
0.5 MB flex
apt-cache show packagename
lista, entre outras coisas, o tamanho instalado de um pacote e as dependências de um pacote. Também háapt-cache rdepends package
para listar os pacotes que usam esse pacote. Você pode querer começar por aí.