[Wolves] feck.

Aquarius aquarius-lists at kryogenix.org
Thu May 13 15:12:49 BST 2004


fizzy spoo'd forth:
> I was trying to go through stuff a few at a time, say
> ten at a go.  I'd put in the ten, then discover that
> one of the packages is a dependency for something
> important and then have to go on a mission to find out
> which package was causing the problem.

OK, pretty hacky, but it might help:



import commands,sys

pkgout = commands.getoutput('dpkg --list | grep ^i')
pkgs = [(a.split()[1],a.split(None,3)[3]) for a in pkgout.split('\n')]

removers = []
removedeps = []

def ask(q,d,acc):
  while 1:
    v = raw_input(q+" ")
    if len(v) == 0: v = d
    v = v[0].lower()
    if v in acc: break
  return v
		    
for p,d in pkgs:
  if p in removedeps: continue
  depends = commands.getoutput("apt-cache rdepends %s | grep '^  '" % p)
  depends = [a.strip() for a in depends.split('\n')]
  dependstr = ','.join(depends)
  while 1:
    print "%s - %s" % (p,d)
    print "Reqd. by:",
    if len(depends) == 0:
      print "Nothing!"
    else:
      print dependstr
    v = ask("add to [R]emove list, [s]kip, [p]rint remove list, [q]uit (R/s/p/q)","r","rspq")
    if v == "r":
      removers.append(p)
      removedeps.extend(depends)
      break
    elif v == "s":
      break
    elif v == "p":
      print "apt-get --purge remove",
      print ' '.join(removers)
      if ask("quit (Y/n)","y","yn") == "y":
        sys.exit(0)
    elif v == "q":
      if len(removers) == 0:
        sys.exit(0)
      else:
        if ask("quit (Y/n)","y","yn") == "y":
          sys.exit(0)

	  
	  
You should be able to do it in bits: go through some packages, select
to remove or not remove them, then do "p" to show you the apt-get
command to remove them. Then either carry on (making the command
bigger) or "q"uit, run the command, and then come back to it later.

If it breaks, you get to keep both pieces. :-)

Not sure what version of python you need, but it might be 2.3. Then
again, you should have python installed anyway.

Don't remove python until you've finished removing other packages,
since once you've quit the script won't run if there's no python ;)

Aq.

-- 
Why am I not surprised that Microsoft would make these things HTTP
Equivs? What next? Extending HTTP 1.1 so that "GET" is followed by "or
else"?
	   -- Steven Champeon <schampeo at hesketh.com>, webdesign-l



More information about the Wolves mailing list