1

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

  1. Synaptic → Menu:Settings → Repositories → Updates: Enable Unsupported Updates (backports) (Note: I use it as PPA example)
  2. Reload package lists
  3. Search for debhelper, select it. Menu:Packages → Force Version ...: Select and install the version from backports (Usually the highest version)
  4. Menu:Settings → Repositories → Updates: Disable Unsupported Updates (backports) (Note: I use it as PPA example)
  5. Reload package lists

Compare now between these two lists:

  1. Synaptic → SideBar:Status → Installed (local & obsolete)

    Synaptic - local & obsolete packages

  2. 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:~$ 
    
8
  • you can list all installed packages using dpkg -l
    – Fractalyse
    Apr 23, 2020 at 13:19
  • @Fractalyse, not the complete list of installed packages. There is an idiom misunderstanding, let me update the question.
    – user.dz
    Apr 23, 2020 at 13:21
  • 1
    askubuntu.com/q/965942/158442?
    – muru
    Apr 23, 2020 at 16:57
  • @muru yes that's exactly, it works for me. The questions are not quite the same also I want to look if there other commands/options. So would you please write an answer.
    – user.dz
    Apr 23, 2020 at 17:10
  • 1
    maybe something like this: aptitude search '?narrow(!?origin(.*), ?installed)'
    – user986805
    Apr 23, 2020 at 18:07

3 Answers 3

3

Find installed packages that does not originate from any source.list or cannot be downloaded.

$ aptitude search \
  '?narrow(?or(!?origin(), ?obsolete), ?installed)'

Or short form:

$ aptitude search '~S (!~O|~o)  ~i'
  • ?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.
2
  • Thank you for the answer. It works and I am surprised even it list more packages. After I verify with apt-cache and packages.ubuntu.com, found those packages are the upgradable local packages (local version package that's not in repository and it lower than the highest one in repository). This is more compete list.
    – user.dz
    Apr 23, 2020 at 19:10
  • yes, narrow matches filter and pattern on individual package versions.
    – user986805
    Apr 23, 2020 at 19:59
2

apt list --installed labels packages as local 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.:

apt list --installed | awk -F/ '/local]/{print $1}'

You could also probably make a similar check using the Python APT API.

2
  • Thank you, it works perfectly, it has same list as with synaptic . I will give the API a shot later.
    – user.dz
    Apr 23, 2020 at 17:35
  • if you need a localized version: askubuntu.com/a/1192228/986805
    – user986805
    Apr 23, 2020 at 19:27
1

With apt-show-versions | grep -e 'No available version' -e 'newer than version' you should get the list of packages:

  • without a version in any repo.
  • or have higher version than the one in repo.

Probably you need to install it beforehand with sudo apt install apt-show-versions

3
  • Thank you for the answer. It is a partial solution, it covers some cases. grep 'No available version' shows only obsolute packages. Using grep -e 'No available version' -e 'newer than version', it adds local packages with version higher than repository. So, it misses only local packages with version lower than repository because they are mixed with other packages require updates.
    – user.dz
    Apr 23, 2020 at 16:50
  • So those local packages will have same line as other package from repository that can be upgraded ( 'upgradable to').
    – user.dz
    Apr 23, 2020 at 16:57
  • 1
    After, I re-verify with Bac0n's answer here askubuntu.com/a/1229887/26246 . This answer works and it gives similar results to muru's answer askubuntu.com/a/1229857/26246 , same what I asked in the question (synaptic doesn't show local upgradable packages in that list).
    – user.dz
    Apr 23, 2020 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.