Package: aptitude Version: 0.4.0-3 Severity: wishlist Tags: patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
For keeping /var/cache/apt/archives sweetly small, I would like to have a command to keep all package files for packages which are installed and remove everything else. autoclean does too little for me (leaving package files which are not installed) and obviously clean does too much (I am quite often on dial-up so I would love to have my package files for additional security). Just to explain better what I mean I hacked together simple (and dirty) script in Python to illustrate it. See attached. Thanks, Matej - -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (600, 'unstable'), (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.13.3 Locale: LANG=cs_CZ.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8) Versions of packages aptitude depends on: ii apt [libapt-pkg-libc6.3-6-3.1 0.6.42.3 Advanced front-end for dpkg ii libc6 2.3.5-8 GNU C Library: Shared libraries an ii libgcc1 1:4.0.2-4 GCC support library ii libncursesw5 5.5-1 Shared libraries for terminal hand ii libsigc++-2.0-0c2 2.0.16-1 type-safe Signal Framework for C++ ii libstdc++6 4.0.2-4 The GNU Standard C++ Library v3 Versions of packages aptitude recommends: ii aptitude-doc-cs [aptitude-doc 0.4.0-3 Czech manual for aptitude, a termi - -- no debconf information -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFDhHor4J/vJdlkhKwRAp29AJ4/r/d6KWNOvRHjsbObRHvViPxi2QCfePFQ lNAUpFAtiM4+osJkt8qYVkQ= =ae8I -----END PGP SIGNATURE-----
#!/usr/bin/python """Program to clean /var/cache/apt/archives folder from files for packages which are not installed. It doesn't take any arguments. USE AT YOUR OWN RISK, THIS MAY HURT YOU!!!""" # $Id: midclean.py,v 1.2 2005-11-23 06:00:36 matej Exp $ import os,re,sys currentlyInstalledRaw = os.popen("aptitude search -F '%p %V' '~i'", "r").readlines() currentlyInstalled = [line.split() for line in currentlyInstalledRaw] # currentlyInstalled is list of lists looking like this: # [...,['zoem', '05-154-1']] currNames = tuple([x[0] for x in currentlyInstalled]) currVersions = tuple([x[1] for x in currentlyInstalled]) currDir = os.getcwd() os.chdir("/var/cache/apt/archives/") packagesStoredNamesRaw = os.popen("ls *.deb").readlines() packagesStoredNames = [[line.strip().split("_",2)[:2],line.strip()] \ for line in packagesStoredNamesRaw] # packagesStoredNames is again list of lists looking like this: # [...,[['zoem', '05-154-1'], 'zoem_05-154-1_i386.deb']] for item in packagesStoredNames: if not(item[0][0] in currNames) and not(item[0][1] in currVersions): print "Removing %s." % item[1] os.remove(item[1])