Anargy PPA – Pinning
If you only want one or a few packages from our PPA, but not all, use Pinning to do this.
Pinning is the mechanism to tell your Ubuntu to give packages a higher or lower priority. The default priority for packages is 500.
Create a file in the directory /etc/apt/preferences.d/ with two clauses. The first one says give all the packages in the Anargy PPA a lower priority than the regular one (so that they are not preferred even if they have a higher version number). The second clause partly overrides the first by saying give the package in that ppa with the name “nginx” the same priority as other packages so that it will get installed (by it having a higher version number).
$ cat /etc/apt/preferences.d/pin-anargy # Never prefer other packages from Anargy PPA Package: * Pin: release o=LP-PPA-anargy-jammy Pin-Priority: -1 # Allow upgrading Nginx from Anargy PPA Package: nginx Pin: release o=LP-PPA-anargy-jammy Pin-Priority: 500
It may seem complicated, but is actually pretty straight forward. To get the required string for the “Pin: release” option we use the command apt-cache policy.
$ apt-cache policy ... 500 https://ppa.launchpadcontent.net/anargy/jammy/ubuntu jammy/main amd64 Packages release v=22.04,o=LP-PPA-anargy-jammy,a=jammy,n=jammy,l=Ubuntu 22.04,c=main,b=amd64 origin ppa.launchpadcontent.net ... Pinned packages: nginx -> 1.25.2-1~anargy+jammy with priority 500
About the number of Pin Priority
- 1000 or higher. Install a version from the target release even if it would replace (downgrade) an installed package with a higher version.
- 990 to 999. Install a version even if it does not come from the target release, unless the installed version is more recent.
- 500 to 899. Install a version unless there is a version available belonging to the target release or the installed version is more recent.
- 100 to 499. Install a version unless there is a version available belonging to some other distribution or the installed version is more recent.
- 1 to 99. Install a version only if there is no installed version of the package.
- -1 or lower. Prevent the version from being installed