Linux - Package Repository

About

A Package Repository is where OS package are stored.

This repository are used by package manager such as yum to search and install packages

Command

List

With yum

yum repolist

Output example:

repo id                                     repo name                                                                             status
base/7/x86_64                               CentOS-7 - Base                                                                         10,072
epel/7/x86_64                               EPEL YUM repo                                                                         13,511+1
extras/7/x86_64                             CentOS-7 - Extras                                                                          448
remi-safe                                   Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                               4,080
updates/7/x86_64                            CentOS-7 - Updates                                                                       1,207

  • yum-config-manager
# with configuration all
yum-config-manager
# only one
yum-config-manager repositoryId
# example
yum-config-manager epel

Enable / Disable

  • dnf (replace yum)
dnf config-manager --enable repository  # where repository is the unique repository ID
dnf config-manager --disable repository  # where repository is the unique repository ID
  • Deprecated: yum
yum-config-manager --enable repository  # where repository is the unique repository ID
yum-config-manager --disable repository  # where repository is the unique repository ID

Add

Adding a repository for yum is adding a config file at /etc/yum.repos.d/repository-name.repo

With ansible, see yum-repository

- name: 'Package - Add the netdata repository'
  yum_repository:
    name: netdata
    description: Netdata Repo
    baseurl: https://packagecloud.io/netdata/netdata/el/$releasever/$basearch/
    gpgcheck: no
    repo_gpgcheck: yes

Configuration

# config
yum-config-manager
# or
ls /etc/yum.repos.d
CentOS-Base.repo       CentOS-Sources.repo        epel-testing.repo         remi-glpi94.repo   remi-php72.repo
CentOS-CR.repo         CentOS-Vault.repo          epel-testing.repo.rpmnew  remi-modular.repo  remi-php73.repo
CentOS-Debuginfo.repo  CentOS-x86_64-kernel.repo  remi-glpi91.repo          remi-php54.repo    remi-php74.repo
CentOS-fasttrack.repo  epel.repo                  remi-glpi92.repo          remi-php70.repo    remi.repo
CentOS-Media.repo      epel.repo.rpmnew           remi-glpi93.repo          remi-php71.repo    remi-safe.repo
.............

Install a key

Your package manager should install the repository public key.

Example with rpm

# Microsoft repository key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Exclude a package from updates

At the command line

  • from an update
yum -x python-3 update
yum --exclude httpd,php update

In the global conf file

In the the conf file

  • Exclude Single Package
exclude=python-3*        
  • Exclude Multiple Packages
exclude=httpd php        

In the repo conf file

In the repo file .repo in /etc/yum/repos.d/ or /etc/yum.repos.d directory with the exclude property

cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
exclude=python-3* 

Exclude Globbaly

Edit the /etc/yum.conf

Example:

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
exclude=nginx

Well-known repo

EPEL

EPEL (Extra Packages for Enterprise Linux) - EPEL is a open source and free community based package repository project from Fedora team for Linux distribution. You will find most of the package but open-source.

Microsoft

# Import the key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
# Create the repo metadata
sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'

Oracle

The Oracle public yum server offers a free and convenient way to install packages from the Enterprise Linux and Oracle VM installation media via a yum client.

All configuration steps are detailed in the Oracle Public Yum home page

[root@oel11g yum.repos.d]# cat /etc/enterprise-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)  <------OEL 5 Update 3
  • Download and copy the appropriate yum configuration file in place:
cd /etc/yum.repos.d
dir
wget http://public-yum.oracle.com/public-yum-el5.repo
--21:01:30--  http://public-yum.oracle.com/public-yum-el5.repo
Resolving public-yum.oracle.com... 141.146.44.34
Connecting to public-yum.oracle.com|141.146.44.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1864 (1.8K) [text/plain]
Saving to: public-yum-el5.repo

100%[=======================================>] 1,864       --.-K/s   in 0s

21:01:30 (518 MB/s) - public-yum-el5.repo saved [1864/1864]

  • Open the yum configuration file in a text editor
  • Locate the section in the file for the repository you plan to update from, e.g. [el5_u3_base]
  • Change with vi enabled=0 to enabled=1
vi public-yum-el5.repo

Example:

[el5_u3_base]
name=Enterprise Linux $releasever U3 - $basearch - base
baseurl=http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/3/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5
gpgcheck=1
enabled=1





Discover More
EPEL (Extra Packages for Enterprise Linux)

EPEL is open source and free community based package repository project from Fedora team for Linux distribution including: RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux. ...
What is the yum command (Yellowdog Updater Modified) ?

yum is a software package manager. It is a tool for installing, updating, and removing packages and their dependencies on RPM-based systems. It automatically computes dependencies and figures out what...



Share this page:
Follow us:
Task Runner