Skip to content

Problem with obsolete packages

While crossgrading quite old system that have lived through a lot of dist-upgrades, I found a problem. When I run corssgrading it throws, quite unclear error:

# crossgrader amd64        
Installing initramfs binary architecture check hook...
arch check hook already installed.
Hook installation failed.
Hit http://mirror.yandex.ru/debian bullseye InRelease                                                                                                                                                            
Fetched 0 B in 0s (0 B/s)                                                                                                                                                                                        
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 281, in __getitem__
    rawpkg = self._cache[key]
KeyError: 'libgdbm3:amd64'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/debian_crossgrader/utils/apt.py", line 87, in find_package_objs
    package = apt_cache[target_name]
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 283, in __getitem__
    raise KeyError('The cache has no package named %r' % key)
KeyError: "The cache has no package named 'libgdbm3:amd64'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/crossgrader", line 33, in <module>
    sys.exit(load_entry_point('debian-crossgrader==0.0.3', 'console_scripts', 'crossgrader')())
  File "/usr/lib/python3/dist-packages/debian_crossgrader/__main__.py", line 262, in main
    first_stage(args)
  File "/usr/lib/python3/dist-packages/debian_crossgrader/__main__.py", line 21, in first_stage
    targets = crossgrader.list_first_stage_targets(
  File "/usr/lib/python3/dist-packages/debian_crossgrader/crossgrader.py", line 735, in list_first_stage_targets
    return self.find_package_objs(targets, default_arch=self.target_arch,
  File "/usr/lib/python3/dist-packages/debian_crossgrader/crossgrader.py", line 613, in find_package_objs
    return apt_utils.find_package_objs(names, self._apt_cache, **kwargs)
  File "/usr/lib/python3/dist-packages/debian_crossgrader/utils/apt.py", line 92, in find_package_objs
    raise PackageNotFoundError(target_name)
debian_crossgrader.utils.apt.PackageNotFoundError: libgdbm3:amd64 could not be found in APT's cache

I figured out that the cause of this error is that my system has a lot of obsolete packages that does not have :amd64 counterpart in current repo, as they came from old debian releases.

I've already added MR !2 (merged) with instructions about listing and removing these packages before crossgrading.

But nevertheless. Installed packages without :amd64 counterpart is quite common case. This can be not only obsolete packages case. They can be installed manually, or came from some thirdparty repository.
So it would be nice to get proper error message in this case, explaining the cause of the problem. It would be also nice to get full list of such packages. Removing them one by one is tiresome...