In the recommendations of best practices to upgrade an Ubuntu distribution (and in a previous similar post), it is recommended to:
Disable all non-Ubuntu (unoficial) deb sources, including disabling PPAs. Uninstall the deb packages that those sources provided. Return your deb packages to as close to stock condition as possible.
I know sources can be disabled in the Software and Updates application, by using add-apt-repository -r, or by adding Enabled: no to the .sources files. But how can I also uninstall the deb packages that were installed from those sources?
I have seen ppa-purge being mentioned, but it did not work properly for me. To give an example for josm that did not seem to do anything:
❯ sudo ppa-purge -s josm.openstreetmap.de ppa:apt/dists
Updating packages lists
PPA to be removed: apt dists
Package revert list generated:
josm/questing
Updating packages lists
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
josm is already the newest version (1.5.svn19555).
Selected version '1.5.svn19555' (josm.openstreetmap.de [all]) for 'josm'
Solving dependencies... Done
0 to upgrade, 0 to newly install, 0 to remove and 28 not to upgrade.
PPA purged successfully
The output of apt policy still includes:
Package files
...
500 https://josm.openstreetmap.de/apt questing/universe amd64 Packages
release n=questing,c=universe,b=amd64
origin josm.openstreetmap.de
and the contents of /etc/apt/sources.list.d/josm.sources remain (i.e., they do not include Enabled: no):
Types: deb
URIs: https://josm.openstreetmap.de/apt
Suites: questing
Components: universe
Architectures: amd64
Signed-By: /etc/apt/keyrings/josm-apt.gpg