How to prioritize packages, PPA and Apt repositories on Ubuntu

This is a simple tutorial that shows you how to prioritize specific packages and apt repositories on Ubuntu, Debian and Linux Mint.

Ubuntu installs software packages from a variety of sources, including Ubuntu Universe repositories (using Ubuntu software), Ubuntu PPA (LibreOffice, Kodi, GIMP, etc.) and app-specific apt repositories (Chrome, VirtualBox, Opera, etc.). More).

You can also install the app from other Linux distributions. For example, you can install Linux Mint’s IPTV player, Web App Mananger, and Chromium Browser (in deb format) on Ubuntu.

Reasons to set priorities:

However, when installing from a mixed software source, you may be asked the following questions:

  1. Locks the package with the specified version.
  2. I have the same package in multiple repositories, but I want to install or receive package updates from a particular repository.
  3. Install only one or two packages from the repository, but reject everything else.

Create and set package priorities.

Adding a rule file under the /etc/apt/preferences.d/ directory and fixing the priority will fix the problem.

Open a terminal from the system app launcher and run commands to create and edit configuration files (replace gedit on other systems).

sudo gedit /etc/apt/preferences.d/99mint-repository

In this case I 99mint-repository Added file and the following line:

# 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

How to prioritize packages, PPA and Apt repositories on Ubuntu

As you can see, each entry has 3 lines (except for the descriptive line that starts with # at the beginning), separated by blank lines.

3 lines starting with Package: First specified the package: “webapp-manager”, “chromium”, and “*” (all).

About the “pin:” line:

The second line specifies the pin definition. Pin: Version 1.0.99 *, “*” indicates a “wildcard”, that is, all versions of the package that start with 1.0.99.

You can also use the release or origin for the specified package source. For example:

Pin: release o=LP-PPA-team-xbmc
Pin: release l=linuxmint
Pin: origin

The release parameters are a (archive), c (component), v (version), o (origin), and l (label).

Then you can find the release and origin values ​​by running the command.

apt-cache policy |more

How to prioritize packages, PPA and Apt repositories on Ubuntu

About the number of pin priorities:

The value on the third line can be set as follows.

  • Over 1000. Even if you want to replace (downgrade) an installed package with a higher version, install the target release version.
  • 990-999. Install the version even if it is not from the target release, unless the installed version is the latest.
  • 500-899. Install a version if there is no available version that belongs to the target release, or unless the installed version is the latest.
  • 100 to 499. Install the version unless there is no available version belonging to another distribution or the installed version is newer.
  • 1 to 99. Install the version only if there is no installed version of the package.
  • -1 or less.Prevent the version from being installed

After configuring the configuration file, update the system package cache as follows: sudo apt update Command and completion.

Share this:

  • More