2

How to remove all packages for a given architecture (i.e: i386, armhf, etc.)?

karel
  • 114,770
develCuy
  • 124
  • 2
    please [edit] your question and show us apt-cache policy libgirepository-1.0-1 and sudo apt update – nobody Jun 07 '22 at 15:02
  • 1
    Unfortunately I can't because did a workaround, extracting packages manually, I needed the .a files for a build. Btw, my method for removing all packages from a given architecture would be useful for somebody – develCuy Jun 09 '22 at 14:29

1 Answers1

2

Removing all packages for a given architecture is a little bit more complicated that it would seem to be at first glance because you should avoid removing any essential packages. To remove all packages for a given architecture (for example, i386) open the terminal and type:

sudo apt remove $(dpkg-query -f '${Package} ' -W *:i386 | sed -E 's/ /:i386 /g')

This command could uninstall an unexpectedly large number of packages, so it is recommended to execute a dry run command first. My dry run on Ubuntu 22.04 simulated removing 68 packages including libc6:i386 and gave the following warning message:

WARNING: The following essential packages will be removed.  
This should NOT be done unless you know exactly what you are doing!  
  libcrypt1:i386 libc6:i386 (due to libcrypt1:i386)

To simulate the results of sudo apt remove $(dpkg-query -f '${Package} ' -W *:i386 | sed -E 's/ /:i386 /g') without actually uninstalling any packages run the following command:

apt remove --simulate $(dpkg-query -f '${Package} ' -W *:i386 | sed -E 's/ /:i386 /g')

Please note that there is no sudo at the beginning of this command, so no packages will be uninstalled.

karel
  • 114,770