I used to look for local packages using Synaptic. Those packages which are locally installed but have no exact match in the current active repositories. As it is explained in this post: What does “local or obsolete” mean in Synaptic.
I finds that feature very helpful when it comes to debugging unmet dependencies issues. While I know how to get list of obsolete packages, I couldn't find a way for local packages.
So, is there any equivalent command line that lists all local packages?
Note to explain idioms I used.
- orphan package: installed automatically as dependency, then dependent was removed.
- obsolete package: installed but no package with same (name,architecture) in the repository.
- local package: installed but no package with same (name,architecture,version) in the repository.
So I don't mean the all installed packages.
Test Case
- Synaptic → Menu:Settings → Repositories → Updates: Enable Unsupported Updates (backports) (Note: I use it as PPA example)
- Reload package lists
- Search for
debhelper
, select it. Menu:Packages → Force Version ...: Select and install the version from backports (Usually the highest version) - Menu:Settings → Repositories → Updates: Disable Unsupported Updates (backports) (Note: I use it as PPA example)
- Reload package lists
Compare now between these two lists:
Synaptic → SideBar:Status → Installed (local & obsolete)
aptitude search '~o'
user@user-vb:~$ aptitude search '~o' i A linux-headers-4.15.0-19 - Header files related to Linux kernel version 4.15.0 i A linux-headers-4.15.0-19-generic - Linux kernel headers for version 4.15.0 on 64 bit x86 SMP i A linux-image-4.15.0-19-generic - Signed kernel image generic i A linux-modules-4.15.0-19-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 i A linux-modules-extra-4.15.0-19-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 user@user-vb:~$
Find installed packages that does not originate from any source.list or cannot be downloaded.
Or short form:
?narrow
(filter, pattern)Select packages which matches both filter and pattern.
?or
(pattern, pattern)Matches any of the patterns or both.
?origin
(pattern)Select packages with given origin.
?obsolete
Matches installed packages that cannot be downloaded.
?installed
Select installed packages.
?not
(pattern) or!
Select any package not matching the pattern.
apt list --installed
labels packages aslocal
in a way that seems to agree with your definition (see my answer here). You could filter only packages so labelled with ask, grep, etc.:You could also probably make a similar check using the Python APT API.
With
apt-show-versions | grep -e 'No available version' -e 'newer than version'
you should get the list of packages:Probably you need to install it beforehand with
sudo apt install apt-show-versions