This is a simple tutorial shows how to set the priority of a certain package and/or apt repository in Ubuntu, Debian, Linux Mint.
In Ubuntu, we install software packages from different sources, including Ubuntu universe repositories (using Ubuntu Software), Ubuntu PPAs (e.g., LibreOffice, Kodi, GIMP, and more), apps’ own apt repositories (e.g, Chrome, VirtualBox, Opera, and more).
We can even install apps from other Linux Distributions. For instance, installing Linux Mint’s IPTV player, Web App Mananger, and Chromium Browser (in deb format) in Ubuntu is possible.
Why setting priority:
However, installing from mixed software sources may cause following questions:
- Lock a package in specified version.
- More than one repositories have the same package, but you want to install or receive package updates from a certain repository.
- Install only one or two packages from the repository, but refuse all others.
Create and set package priority:
By adding a rule file under /etc/apt/preferences.d/ directory, and pinning a priority will fix the issues.
Just open terminal from system app launcher, and run command to create and edit a config file (replace gedit for other system):
sudo gedit /etc/apt/preferences.d/99mint-repository
In the case, I created a
99mint-repository file and added following lines:
# Allow upgrading only webapp-manager from Ulyssa repository Package: webapp-manager Pin: release n=ulyana Pin-Priority: 500 # Also allow upgrading chromium (Added by another post). Package: chromium Pin: release n=ulyana Pin-Priority: 500 # Never prefer other packages from the Ulyssa repository Package: * Pin: release n=ulyana Pin-Priority: 1
As you can see, each entry has 3 lines (exclude the description line started with # at the beginning), and separated with a blank line.
The three lines started with Package: at the beginning specified the packages: “webapp-manager”, “chromium”, and “*” (everything).
About the “Pin: ” line:
The second line specifies the pin definition. It can be Pin: version 1.0.99*, the “*” is a “wildcard”, that says the package with all versions beginning with 1.0.99.
You can also use release or origin to specified package source. For example:
Pin: release o=LP-PPA-team-xbmc
Pin: release l=linuxmint
Pin: origin packages.linuxmint.com
The parameters for release are: a (archive), c (components), v (version), o (origin) and l (label).
And you can find out the values for release and origin by running command:
apt-cache policy |more
About the number of Pin-Priority:
The value of the third line can be set to:
- 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
After setting up the config file, refresh system package cache via
sudo apt update command and done.