1

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

Is there any other simple way of removing deb packages that were installed from non-Ubuntu (unofficial) sources?

11
  • 1
    The PPA was not disabled. What shows grep -r apt/dists /etc/apt/? Commented Apr 27 at 19:34
  • 1
    They should be listed in the software store or synphatic and uninstalled from there. While it is recommended best practice, My own upgrading since 10.04 has not been bother by having them still installed. Commented Apr 27 at 20:16
  • @AndreiBorzenkov Your command returns empty. I was expecting ppa-purge to disable the PPAs. Are you saying I should have done something else first? Commented Apr 27 at 22:29
  • @crip659 Indeed, I also haven't had problems, but I wanted to follow best practices. Did you mean I should look at the software store and uninstall packages one by one? Commented Apr 27 at 22:30
  • What shows grep -Fr josm.openstreetmap.de /etc/apt? Commented Apr 28 at 3:50

2 Answers 2

3

First why ppa-purge did not work. ppa-purge is not a general Debian archive source management tool - as its name suggests it is a hack to work with PPAs (Personal Package Archives). PPA URL has a well defined structure - for a ppa:user/project it is https://ppa.launchpadcontent.net/user/project/ubuntu and in your case ppa-purge looked for apt/dists string. But your source is not a PPA and this search failed. It means, ppa-purge did not disable this source and attempt to reinstall the package just found the same version as was already installed.

It still found the only package installed from this repository, so you can simply reinstall Ubuntu version of it and disable this source.

As for your general question - I am not aware of such a tool. The closest to listing non-Ubuntu packages I can think of is

apt list '?narrow(!(~OUbuntu|~OUbuntuESM|~OUbuntuESMApps|~OCanonical)~i)'

It is possible that there are more Origins belonging to Canonical, but it should give pretty good start. You can examine the list and decide what to do further.

This command can result in false positives because there is no information about package Origin in the package itself. If the repository (source) from which this package had been installed is no more defined, such package will not have any Origin at all. Consider the list from my system:

anydesk/all,now 8.0.2 amd64 [installed]
avinfo/now 1.0.a15+20090102-1 amd64 [installed,local]
canonical-oem-keyring/now 2009.07.23+build3 all [installed,local]
canonical-poke/now 999 all [installed,local]
chromium-common/noble,now 147.0.7727.116-1xtradeb1.2404.1 amd64 [installed,automatic]
chromium-l10n/noble,noble,now 147.0.7727.116-1xtradeb1.2404.1 all [installed]
chromium-sandbox/noble,now 147.0.7727.116-1xtradeb1.2404.1 amd64 [installed,automatic]
chromium/noble,now 147.0.7727.116-1xtradeb1.2404.1 amd64 [installed]
deb-multimedia-keyring/now 2016.8.1 all [installed,local]
firefox-locale-ru/noble,now 150.0+build1-0ubuntu0.24.04.1~mt1 amd64 [installed]
firefox/noble,now 150.0+build1-0ubuntu0.24.04.1~mt1 amd64 [installed]
gh/unknown,now 2.92.0 amd64 [installed]
oem-browser-defaults/now 20kittyhawk3 all [installed,local]
remmina-common/noble-updates,noble-updates 1.4.35+dfsg-0ubuntu5.2 all [upgradable from: 1.4.35+dfsg-0ubuntu5.1]
remmina-plugin-rdp/noble-updates 1.4.35+dfsg-0ubuntu5.2 amd64 [upgradable from: 1.4.35+dfsg-0ubuntu5.1]
remmina-plugin-secret/noble-updates 1.4.35+dfsg-0ubuntu5.2 amd64 [upgradable from: 1.4.35+dfsg-0ubuntu5.1]
remmina-plugin-vnc/noble-updates 1.4.35+dfsg-0ubuntu5.2 amd64 [upgradable from: 1.4.35+dfsg-0ubuntu5.1]
remmina/noble-updates 1.4.35+dfsg-0ubuntu5.2 amd64 [upgradable from: 1.4.35+dfsg-0ubuntu5.1]
thunderbird-gnome-support/noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 amd64 [installed]
thunderbird-locale-en-gb/noble,noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 all [installed]
thunderbird-locale-en-us/noble,noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 all [installed]
thunderbird-locale-en/noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 amd64 [installed]
thunderbird-locale-ru/noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 amd64 [installed]
thunderbird/noble,now 1:140.10.0+build1-0ubuntu0.24.04.1~mt2 amd64 [installed]
ubuntu-extras-keyring/now 2010.09.27 all [installed,local]
zoom/now 6.7.2.6498 amd64 [installed,local]

Packages marked local are those for which no source is found. But some packages did belong to the Ubuntu version that was preinstalled on the notebook initially, like oem-browser-defaults or canonical-oem-keyring. I believe it was Ubuntu 14.04.

For the same reason it shows upgradeable packages from update repositories. Because currently installed version is no more present in packages list, there is no way to determine its Origin.

BTW I never noticed canonical-poke which

Description: send "I am alive" ping to Canonical

2

You could check /etc/apt/sources.list file and *.list and *.sources files in /etc/apt/sources.list.d/ for any non-Ubuntu repositories. Disable/remove the repositories that you want to. In recent Ubuntu releases the default Ubuntu repositories are defined in /etc/apt/sources.list.d/ubuntu.sources so you don't want to remove that. I tried sudo add-apt-repository -r in removing the JOSM repository in Ubuntu 24.04 and it did not work well in my experience. Maybe a newer version of it works better. Anyway, you can manually remove the files or rename them to have e.g. .save filename postfix or disable some repository in a file.

Thereafter you just need to sync packages to match the remaining repository definitions. I made a script called apt-downgrade to do the job. It is currently available in my Launchpad git repository. Unfortunately browsing the code does not work currently, but you can clone the repository by git using a command given in the repository page. It creates a directory containing the script. Copy the script to /usr/local/bin/ and run apt-downgrade -h for help.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.