Site icon TechGit

How to Set Package, PPA, Apt Repository Priority in Ubuntu

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:

  1. Lock a package in specified version.
  2. More than one repositories have the same package, but you want to install or receive package updates from a certain repository.
  3. 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:

After setting up the config file, refresh system package cache via sudo apt update command and done.

Original Article

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version