Friday, March 26, 2021

YUM repositories

Introduction
============

In order to access a YUM repository, you must create a .repo file under
/etc/yum.repos.d or put it directly inside /etc/yum.conf. But the former is much
preferred. Once a .repo file is created under /etc/yum.repos.d, given that all
its options are valid and the path to repository (baseurl) is accessible, you
would be able to see it under "yum repolist" command output. Here is a sample
.repo file. Options can either be on uppercase or lowercase.
[local]  # this is the repo id
name=My local repo
baseurl=file:///localrepo  # valid locations are http://, ftp://, file:///path, ..
#mirrorlist=file:///root  # alternative to baseurl; can point to a file containing multiple baseurls
enabled=1  # 1 (enabled), 0 (disabled), not specifying this means it is enabled
gpgcheck=0  # 1 (enabled), 0 (disabled); tells whether yum to perform gpg signature check on the packages

Here is another example now with yum variables involved.
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Where:
  $releasever = usually the number part in "cat /etc/redhat-release" output
  $basearch = architecture (as seen in "uname -p")
  $infra = whatever inside /etc/yum/vars/infra (mine is set to "stock")

Decoding the URL Paths
======================

So if we are going to decode the mirror path for a
"CentOS Linux release 7.3.1611 (Core)" 64-bit server, it would be:

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock

Notice that the 7.3.1611 was stripped down to 7 on the url path. That is the
case sometimes. Those yum variables can be overwritten if you create a file
with same name under /etc/yum/vars. In Centos 7.3.1611, there is only one file
inside that directory which is infra whose content is set to "stock".

Common types of repositories you might encounter
================================================

1. Base - packages that came from installation discs
2. Updates - usually from external repos containing updates for packages
             installed from base
3. EPEL/extras - extra packages that is not included from base

Advance options for yum.conf
============================

Here are some advance options for yum.conf that rarely used but I believe is
helpful. Updating yum.conf doesn't need to restart any service. It will read the
settings the next time you run a transaction via "yum" command.

showdupesfromrepos=[0|1]

  - default is 0
  - if you have multiple repos, by default "yum list " will search
    all those repos and display only the package with the latest version leaving
    the others hidden from your view
  - setting this option to "1" will list also the other packages from other
    repos despite of its version
  - even if set to "1", this doesn't affect "yum install ;" where
    it by default install the latest package
  - without specifying this in yum.conf, you can do this in every yum
    transaction by adding "--showduplicates" option

Sources
=======

yum.conf(5)  - contains options for main config file as well as options for
               custom .repo files under /etc/yum.repos.d
yum(8)  - command line options for "yum"

No comments:

Post a Comment