LinuxCommandLibrary

createrepo

Create a YUM repository

TLDR

Initialize a basic repository in a directory

$ createrepo [path/to/directory]
copy

Initialize a repository, exclude test RPMs and display verbose logs
$ createrepo [[-v|--verbose]] [[-x|--excludes]] [test_*.rpm] [path/to/directory]
copy

Initialize a repository, using SHA1 as the checksum algorithm, and ignoring symbolic links
$ createrepo [[-S|--skip-symlinks]] [[-s|--checksum]] [sha1] [path/to/directory]
copy

SYNOPSIS

createrepo [options] <directory>

PARAMETERS

-c FILE, --config=FILE
    Use specified config file for options

-d, --delete-missing
    Remove metadata for packages no longer in directory

-g FILE, --groupfile=FILE
    Include comps.xml group file in repodata

-i FILE, --inherit=FILE
    Inherit metadata from specified repoview file

-m STRINGS, --metadata=STRINGS
    Metadata filenames to generate (primary,filelists,other)

-o DIR, --outputdir=DIR
    Place repodata in specified output directory

-p, --pretty
    Pretty-print XML files (human-readable, larger)

-q, --quiet
    Suppress non-error output

-s TYPE, --checksum=TYPE
    Checksum type (sha, sha256, sha512, md5)

-u, --update
    Update existing repodata without full rebuild

--database
    Use SQLite database for faster updates (default)

--no-database
    Disable SQLite database usage

--retain-old-md
    Keep old metadata files

-v, --verbose
    Increase output verbosity

--version
    Display version info

-h, --help
    Show help

DESCRIPTION

createrepo is a utility for creating repository metadata (repodata) for directories containing RPM packages. It generates essential XML files like repomd.xml, primary.xml.gz, filelists.xml.gz, and other.xml.gz in a repodata subdirectory. This metadata enables package managers such as YUM and DNF to index, query, and install packages efficiently from custom repositories served via HTTP, FTP, or local access.

Commonly used in RPM-based distributions like Fedora, RHEL, and CentOS for building local mirrors, intranet repos, or distribution points. It supports features like updating existing repodata, custom checksums (SHA256, SHA1), group file integration for package groups, and pretty-printed XML for readability. For large directories, it processes packages sequentially, parsing RPM headers and file lists.

Modern systems favor createrepo_c, a faster C reimplementation, but createrepo (Python-based) remains available for compatibility.

CAVEATS

Only supports RPM packages; large repos consume significant time/disk. Requires rpm tools. Use createrepo_c for better performance on modern systems.
Deprecated Python version; checksum defaults may change.

BASIC EXAMPLE

createrepo /path/to/rpms
Creates repodata in /path/to/rpms/repodata/

UPDATE EXAMPLE

createrepo -u -d /path/to/repo
Updates repodata, removes missing packages

HISTORY

Developed in 2005 as part of the YUM project by Seth Vidal (Fedora). Python-based original for ease of extension. Replaced by faster createrepo_c (C99, 2014+) in Fedora 22+ and RHEL 8+ for production use.

SEE ALSO

createrepo_c(1), modifyrepo(1), repomanage(1), dnf(8), yum(8)

Copied to clipboard