Skip to main content

Create Basic Local RPM Repo

·477 words·3 mins
System-Administration Linux Packaging Rpm Fedora Redhat Suse
Table of Contents

Requirements
#

The first thing is that the createrepo package needs to be locally installed:

# RHEL/Fedora
$ dnf install createrepo

# SUSE
$ zypper install createrepo_c

Next, is the directory that the repository will reside in, such as:

$ mkdir -p /opt/test-repo/

And finally, is a package or set of packages that the repository that will be made available from it, as an example a newer version of a package than is available from your base distro:

$ cd /opt/test-repo/

# RHEL/Fedora
$ wget https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/aarch64/os/Packages/m/meson-0.60.3-2.fc36.noarch.rpm

# SUSE
$ wget https://download.opensuse.org/distribution/leap/15.3/repo/oss/noarch/meson-0.54.2-3.3.1.noarch.rpm

Generate Repository Metadata
#

With the content in place, all that is needed is to call createrepo on the directory:

$ createrepo /opt/test-repo/

This will create the repository metadata in a subdirectory repodata, so it would look something like this:

/opt/test-repo/
├── meson-0.60.3-2.fc36.noarch.rpm
└── repodata
    ├── 4f7968455f554aef91ca1f2097eeb84500743e52754a974a069262bfa6233cc5-primary.xml.zst
    ├── 7e71e424aa5d8f711fcd44be5617c5cf8cb571e980479d05af23bb71617859b8-other.xml.zst
    ├── 91deaaa6a8a92c0e538eaba97981690d4d553e7b1d362e07a2531180a15b3af8-filelists.xml.zst
    └── repomd.xml

Add local repository to the package manager
#

yum/dnf (RHEL/Fedora)
#

Add a repo file to the /etc/yum.repos.d/ directory, with relevant data representing the local repository:

[local-test-repo]
name=Test Local Repository
baseurl=file:///opt/test-repo/
enabled=1
gpgcheck=0
metadata_expire=1

Then tell the package manager to update the repository metadata, and check for the new packages, for example:

$ dnf update
$ dnf info meson --showduplicates

will yield output like this:

Name         : meson
Version      : 0.60.3
Release      : 2.fc36
Architecture : noarch
Size         : 1.3 M
Source       : meson-0.60.3-2.fc36.src.rpm
Repository   : local-test-repo
Summary      : High productivity build system
URL          : https://mesonbuild.com/
License      : ASL 2.0
Description  : Meson is a build system designed to optimize programmer
             : productivity. It aims to do this by providing simple, out-of-the-box
             : support for modern software development tools and practices, such as
             : unit tests, coverage reports, Valgrind, CCache and the like.

Notable would be the Repository item, which is the repository that was just added: local-test-repo.

zypper (SUSE)
#

Add a repo file to the /etc/zypp/repos.d/ directory, with relevant data representing the local repository:

[local-test-repo]
name=Test Local Repository
baseurl=file:///opt/test-repo/
enabled=1
gpgcheck=0
metadata_expire=1

Then tell the package manager to update the repository metadata, and check for the new packages, for example:

$ zypper refresh
$ zypper info -r 'local-test-repo' meson

will yield output like this:

Repository     : Test Local repository
Name           : meson
Version        : 0.54.2-3.3.1
Arch           : noarch
Vendor         : SUSE LLC <https://www.suse.com/>
Installed Size : 5.8 MiB
Installed      : No
Status         : not installed
Source package : meson-0.54.2-3.3.1.src
Upstream URL   : http://mesonbuild.com/
Summary        : Python-based build system
Description    : 
    Meson is a build system designed to optimise programmer productivity.
    It aims to do this by providing support for software development
    tools and practices, such as unit tests, coverage reports, Valgrind,
    CCache and the like. Supported languages include C, C++, Fortran,
    Java, Rust. Build definitions are written in a non-turing complete
    Domain Specific Language.

Notable would be the Repository item, which is the repository that was just added: Test Local repository.