Checking for uninstallability on other architectures

Sometimes one has to debug why a package is uninstallable, or some other apt problem, in other architectures than their own. This can be done by running apt with that other architecture in its configuration. I use this function to help me:

  fakeapt() {
      root='/var/tmp/fakeapt'
      dist="$1"
      shift
      arch="$1"
      shift
      apt-get \
          -o APT::Get::List-Cleanup="false" \
          -o Dir::Cache=$root \
          -o Dir::State=$root \
          -o Dir::State::status=$root/status.empty \
          -o Dir::Etc::SourceList=$root/sources.list.$dist \
          -o APT::Architecture=$arch \
          "$@"
  }

And then one can run it like this (it’s a bit long, but that’s how one goes to find out why a package is uninstallable, recursively adding each broken package in the run):

  % fakeapt sid hppa update
  % fakeapt sid hppa install -s kdebase
    The following packages have unmet dependencies:
      kdebase: Depends: kdebase-kio-plugins (>= 4:3.5.7-2) but it is not going to be installed
  % fakeapt sid hppa install -s kdebase-kio-plugins
    The following packages have unmet dependencies:
      kdebase-kio-plugins: Depends: libopenexr2c2a (>= 1.2.2) but it is not going to be installed
  % fakeapt sid hppa install -s kdebase-kio-plugins libopenexr2c2a
    The following packages have unmet dependencies:
      kdebase-kio-plugins: Depends: kdelibs4c2a (>= 4:3.5.7-1) but it is not going to be installed
  % fakeapt sid hppa install -s kdebase-kio-plugins libopenexr2c2a kdelibs4c2a
    The following packages have unmet dependencies:
      kdelibs4c2a: Depends: libopenexr2ldbl (>= 1.2.2) but it is not going to be installed
  % fakeapt sid hppa install -s kdebase-kio-plugins libopenexr2c2a kdelibs4c2a libopenexr2ldbl
    The following packages have unmet dependencies:
      libopenexr2ldbl: Conflicts: libopenexr2c2a but 1.2.2-4.3 is to be installed

A bit of initialization is needed:

  % mkdir -p /var/tmp/fakeapt/{archives,lists}/partial
  % touch /var/tmp/fakeapt/status.empty
  % for d in testing sid; do
      echo deb http://ftp.XX.debian.org/debian $d main >/var/tmp/fakeapt/sources.list.$d
  done