The aptitude search term ?origin matches the Origin value in the repository's Release file.
For example, on a very basic install of 22.04 the output of apt-cache policy lists the following repositories. In this output the search term ?origin compares to the o= value, which is Ubuntu for all of the repositories on this machine.
root@ubuntu:~# apt-cache policy
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=main,b=amd64
origin security.ubuntu.com
500 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin archive.ubuntu.com
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=main,b=amd64
origin archive.ubuntu.com
500 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin archive.ubuntu.com
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=main,b=amd64
origin archive.ubuntu.com
Browsing the repository's Release file shows corresponding values. E.g. http://us.archive.ubuntu.com/ubuntu/dists/jammy/Release contains
Origin: Ubuntu
Label: Ubuntu
Suite: jammy
Version: 22.04
Codename: jammy
With aptitude you can search the available packages from this Origin with a command like
aptitude search "?origin(Ubuntu)"
You can search for "packages which I installed from non-Ubuntu sources". The ?origin(.*) search term can be added to avoid issues with packages that may not have any origin.
aptitude search "?and(?installed, ?not(?origin(Ubuntu)))"
or
aptitude search "?and(?installed, ?origin(.*), ?not(?origin(Ubuntu)))"
As a more complex example, one of my favorite commands is to find all packages with an update available from the official Ubuntu repositories (including UbuntuESM).
aptitude search "?and(?upgradable, ?narrow(?version(CANDIDATE), ?origin(^Ubuntu~(ESM~){0,1}$)))"
The origin name is particularly confusing because
- The search term
?origin does not match the display format %O value, as noted in the original question.
apt_preferences lets you specify an origin, but that origin matches the repository hostname. E.g. archive.ubuntu.com.
unattended-upgrades has configuration for Allowed-Origins that is really a combination of the repository values.
syncthing
If I add the syncthing repository then the syncthing package exists with both Ubuntu and Syncthing origins.
The output of apt-cache policy shows the following information about the repository.
500 https://apt.syncthing.net syncthing/stable amd64 Packages
release o=Syncthing,a=syncthing,n=debian,l=Syncthing,c=stable,b=amd64
origin apt.syncthing.net
The output of apt-cache policy syncthing shows packages available from Syncthing and Ubuntu repositories.
root@ubuntu:~# apt-cache policy syncthing
syncthing:
Installed: (none)
Candidate: 1.23.6
Version table:
1.23.6 500
500 https://apt.syncthing.net syncthing/stable amd64 Packages
1.23.5 500
500 https://apt.syncthing.net syncthing/stable amd64 Packages
1.18.0~ds1-3ubuntu0.2 500
500 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
1.18.0~ds1-3 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
An aptitude search like ?and(?origin(Ubuntu), ?exact-name(syncthing)) will match syncthing because there is a version of that package that matches.
Some tests I tried
root@ubuntu:~# aptitude search "?and(?origin(Ubuntu), ?exact-name(syncthing))" -F "%p,%m#,%O#" | column -t
syncthing,Syncthing Release Management <[email protected]>,Syncthing:syncthing [amd64]
root@ubuntu:~# aptitude search "?any-version(?and(?origin(Ubuntu), ?exact-name(syncthing)))" -F "%p,%m#,%O#" | column -t
syncthing,Syncthing Release Management <[email protected]>,Syncthing:syncthing [amd64]
root@ubuntu:~# aptitude search "?all-versions(?and(?origin(Ubuntu), ?exact-name(syncthing)))" -F "%p,%m#,%O#" | column -t
You can try to use search terms like ?narrow to restrict to specific versions of packages. This should show installed packages where the installed version has an Origin that is not Ubuntu.
aptitude search "?narrow(?version(CURRENT),?and(?origin(.*),?not(?origin(^Ubuntu))))"
notes
I wish I had a source I could reference. This just information I have figured out in the past through testing.
?origin(ubuntu). VS Code's release file does contain the string "ubuntu" — right in the Origin field, even — but matches the negated!?origin(ubuntu)instead. – Ben Blank Aug 06 '23 at 05:00