【AlmaLinux9】EPELリポジトリの追加方法

AlmaLinux9にEPEL(Extra Packages for Enterprise Linux)リポジトリを追加する方法です。

EPELリポジトリとは?

EPELリポジトリはFedoraプロジェクトの有志が運用しているサードパーティのリポジトリで、AlmaLinux標準のリポジトリにないパッケージを追加することができるようになります。

Fedoraプロジェクトのwikiには下記のように説明されています。

https://fedoraproject.org/wiki/EPEL/ja

エンタープライズ Linux 用の拡張パッケージ(EPEL) は、 Red Hat Enterprise Linux (RHEL) 向けの高品質なアドオンパッケージであり、CentOS や Scientific Linux (SL) のような RHEL からスピンオフしたディストリビューションと互換性のある、Fedora プロジェクトで有志によって作成されたパッケージになります。Fedora は RHEL のアップストリームであり、EPEL のアドオンパッケージは主に RHEL 向けにビルドされた Fedora リポジトリをソースとしています。

EPELリポジトリの追加

AlmaLinux9ではdnfで「epel-release」をインストールすることで、EPELリポジトリを簡単に追加することが出来ます。

dnf-plugins-coreインストール

EPELで提供されるパッケージのいくつかがCRBリポジトリを必要とするため、CRBリポジトリも使用できるようにする設定を行います。

最初に、コマンドからリポジトリの有効化・無効化を設定出来るようにするため、「dnf-plugins-core」をインストールします。

「dnf-plugins-core」をインストールすると、「dnf config-manager」というコマンドを使用できるようになるので、それを使用してCRBリポジトリを有効化します。

# dnf install -y dnf-plugins-core
# dnf config-manager --enable crb

EPELリポジトリのインストール

dnfを使って、「epel-release」と「epel-next-release」をインストールします。

これで、両方のリポジトリが使用できるようになります。

# dnf -y install epel-release
# dnf install -y epel-next-release

リポジトリの設定ファイル

インストールしたリポジトリの設定ファイルは、「/etc/yum.repos.d/」ディレクトリに作成されています。

# ls /etc/yum.repos.d/
almalinux-appstream.repo         almalinux-rt.repo
almalinux-baseos.repo            almalinux-saphana.repo
almalinux-crb.repo               almalinux-sap.repo
almalinux-extras.repo            epel-cisco-openh264.repo
almalinux-highavailability.repo  epel-next.repo
almalinux-nfv.repo               epel-next-testing.repo
almalinux-plus.repo              epel.repo
almalinux-resilientstorage.repo  epel-testing.repo

有効化されているリポジトリの確認

「dnf repolist --enabled」コマンドで、現在有効化されているリポジトリの一覧を確認することが出来ます。

# dnf repolist --enabled
repo id             repo name
appstream           AlmaLinux 9 - AppStream
baseos              AlmaLinux 9 - BaseOS
crb                 AlmaLinux 9 - CRB
epel                Extra Packages for Enterprise Linux 9 - x86_64
epel-cisco-openh264 Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64
epel-next           Extra Packages for Enterprise Linux 9 - Next - x86_64
extras              AlmaLinux 9 - Extras

EPELリポジトリの無効化

リポジトリのインストールが完了しましたら、勝手にEPELリポジトリからパッケージがインストールされしまわないように、「dnf config-manager --disable」kコマンドで「EPEL」と「EPEL-NEXT」リポジトリを無効化しておきます。

# dnf config-manager --disable epel
# dnf config-manager --disable epel-next

「dnf repolist --enabled」で確認してみると、有効化されているリポジトリ一覧から「epel」と「epel-next」が消えていることが確認できます。

# dnf repolist --enabled
repo id             repo name
appstream           AlmaLinux 9 - AppStream
baseos              AlmaLinux 9 - BaseOS
crb                 AlmaLinux 9 - CRB
epel-cisco-openh264 Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64
extras              AlmaLinux 9 - Extras

変更箇所

「dnf config-manager」でリポジトリを無効化・有効化した際には「/etc/yum.repo.d」ディレクトリ内にあるリポジトリの設定ファイルが変更されます。

EPELリポジトリの場合は「/etc/yum.repos.d/epel.repo」がリポジトリの設定ファイルなので、こちらが実際に変更されるファイルとなります。

リポジトリの有効化・無効化は「enabled=1」の部分で設定されていて、「dnf config-manager」で設定を変更すると、この部分が変更されます。

  • 有効:enabled=1
  • 無効:enabled=0
変更前

リポジトリをインストールした直後は、有効化されているので「enabled=1」となっています。

[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
変更後

「dnf config-manager --disable epel」でリポジトリを無効化すると、「enabled=0」に変更されます。

[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0    ### 0へ変更される
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever

手動でリポジトリを有効・無効の設定を行う方法

リポジトリの設定ファイルをvi等のエディターで編集して、enbledの部分の設定を行うことでリポジトリを無効化・有効化の設定を行うことが出来ます。

EPELリポジトリを使ってパッケージをインストールする方法

無効化しているリポジトリを使用してdnfでパッケージをインストールする場合は、「--enablerepo」オプションを使って「epel」リポジトリを指定してパッケージのインストールを行います。

# dnf --enablerepo=epel install パッケージ名

複数のリポジトリを一度に指定したい場合は「,」で区切ってリポジトリを指定します。

# dnf --enablerepo=epel,epel-next install パッケージ名

コメント

タイトルとURLをコピーしました