Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

createrepo

Create the index (repodata) for a folder of RPM files, so dnf can use it as a repository.

Level
Everyday Linux
Group
Software packages
Needs root
For changes
Package
createrepo_c
Also called
createrepo_c

What it does

A repository is just a folder with .rpm files and a repodata/ folder with the index. createrepo DIR (on RHEL the fast C version createrepo_c) reads all packages and writes the index. Then point a .repo file to the folder (baseurl=file:///DIR) or share it with a web server.

After you add or remove packages, run it again with --update (faster).

How to write it

createrepo [OPTION]... DIRECTORY

Options 21

Most used

--update
Reuse old data; only read new or changed packages.
-o, --outputdir DIR
Write repodata to another folder.
-x, --excludes PATTERN
Leave out packages matching the pattern.
-i, --pkglist FILE
Only the packages listed in the file.
-n, --includepkg PACKAGE
Add this package file (more allowed).
-g, --groupfile FILE
Add a comps file with package groups.
-s, --checksum TYPE
Checksum type (sha256 default).
--workers N
Number of worker threads.
-d, --database
Also create SQLite databases.
--no-database
Do not create SQLite databases.
--skip-stat
Do not check file times with --update.
--retain-old-md N
Keep this many old metadata files.
--revision TEXT
Set a revision string.
--distro TEXT, --content TEXT, --repo TEXT
Add tags to the metadata.
--compress-type TYPE
Compression of metadata (gz, xz, zstd …).
--zck
Also create zchunk metadata.
--deltas
Create delta RPMs.
-q, --quiet
Quiet.
-v, --verbose
Verbose.
-V, --version
Show the version.
-h, --help
Show help.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Install the tool

    dnf install -y createrepo_c

    Gives the createrepo and createrepo_c commands.

  2. 2Make a repository of a folder

    createrepo /srv/myrepo

    Creates /srv/myrepo/repodata/.

  3. 3Use it on this machine

    cat /etc/yum.repos.d/myrepo.repo
    [myrepo]
    name=My packages
    baseurl=file:///srv/myrepo
    gpgcheck=0

    Then dnf repolist shows it.

  4. 4Update after adding packages

    cp new-tool-2.0-1.el10.x86_64.rpm /srv/myrepo/; createrepo --update /srv/myrepo

    Faster than a full run.

  5. 5Share the repository over HTTP

    dnf install -y httpd; ln -s /srv/myrepo /var/www/html/myrepo

    Clients use baseurl=http://server1/myrepo (check SELinux labels: restorecon or semanage fcontext).

  6. 6Build an offline mirror of needed packages

    dnf download --resolve --destdir=/srv/myrepo ansible-core
    createrepo /srv/myrepo

    For servers without internet.

  7. 7Add package groups

    createrepo -g comps.xml /srv/myrepo

    Then dnf group list shows your groups.

  8. 8Leave out test packages

    createrepo -x '*-debuginfo-*' /srv/myrepo

    Smaller index.

  9. 9Sign your packages (security)

    rpm --addsign /srv/myrepo/*.rpm

    Needs a GPG key in ~/.rpmmacros; then clients can use gpgcheck=1.

  10. 10Clean the dnf cache after changes

    dnf clean metadata; dnf makecache

    Clients see the new packages.

Exit codes

0 :: Done. 1 :: Error.

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man 8 createrepo