Debian – How to de-select packages of a certain architecture in aptitude

aptitudedebianUbuntu

I'm upgrading some Debian machines from i386 arch to amd64. The process is fairly straitforward:

  • Boot a amd64 kernel
  • For libraries which are multiarch-capable, install their amd64 companion libraries
  • Manually install amd64 versions of dpkg and apt
  • Start installing the amd64 versions of packages over their i386 counterparts

All of this goes fairly smoothly, and I've been able to write scripts which help, but then I run into a problem: When I run aptitude, it thinks that I still want to install the old i386 versions of everything (in addition to the amd64 versions). So, my aptitude screen looks something like:

ii   iptables ...
pi   iptables:i386 ...
ii   iptraf ...
pi   iptraf:i386 ...

So, packages like iptables:i386 will show as "purged, but marked for install". This leads to several hundred collisions. Up until now, I've just been going through, one-by-one, and de-selecting them. I didn't have much luck with my attempts at using "dpkg –set-selections"

So, the official question is: Does anybody know of a trick to "un-mark for install" (in aptitude) the i386 versions of every package which already has a amd64 version installed?

Best Answer

The package actions for aptitude are stored in /var/lib/aptitude/pkgstates, this is separate from any dpkg states. You might want to back the above file up before trying the following in case the results are undesirable and it is difficult for you to get back to where you were. The following should do what you are looking for (remember to quit any running aptitude instance first and also run as root):

aptitude -F %p search '~ri386 ~ainstall' | cut -d : -f 1 >i386
aptitude -F %p search '~ramd64 ~i | ~ramd64 ~ainstall' | cut -d : -f 1 | sort >amd64
aptitude --schedule-only keep $(comm -13 amd64 i386 | sed 's/$/:i386/')
rm i386 amd64

When you restart the GUI, hopefully you have what you are looking for :)

Related Question