
createrepo: Initialize an RPM repository
createrepo: Initialize an RPM repository
Overview
- createrepo scans a directory and builds the metadata (XML and SQLite) so yum/dnf can serve packages from it.
- Useful for local mirrors, testing, or offline installations.
Quick start
- Basic initialization in a directory:
createrepo /path/to/directory
- Initialize a repository while excluding certain RPMs and showing verbose logs:
createrepo -v -x test_*.rpm /path/to/directory
- Initialize with a specific checksum algorithm (SHA1) and skip symbolic links:
createrepo -S sha1 --skip-symlinks /path/to/directory
What happens when you run it
- createrepo reads the RPMs present in the target directory and generates metadata files under that directory (typically repodata/ with primary.xml, filelists.xml, other.xml and a sqlite backend).
- The result is a self-contained repository that your package manager can consume.
Common pitfalls
- Running in the wrong directory: If you point to an empty or unrelated directory, you’ll get an empty repodata/ and packages won’t be usable.
- Tip: Run from the actual repository root and verify with ls and ls repodata/ after execution.
- Relying on default checksums: If you need compatibility with older clients, consider explicitly choosing a checksum (e.g., -S sha1). Some newer environments default to different algorithms.
- Not updating after changes: After adding/removing packages, re-run createrepo to refresh metadata so clients see the changes.
Tips and options at a glance
- Basic usage uses a single path:
- createrepo /path/to/directory
- Exclude patterns and verbose output:
- createrepo -v -x pattern1 -x pattern2 /path/to/directory
- Checksum and symlink behavior:
- createrepo -S sha1 —skip-symlinks /path/to/directory
Common workflow example
- Create a local repo from an existing directory with default metadata:
createrepo /var/www/html/repos/myrepo
- Rebuild metadata after adding new RPMs:
createrepo /var/www/html/repos/myrepo
- If you’re testing exclusions and verbose output:
createrepo -v -x test_*.rpm /var/www/html/repos/myrepo
Where to look for help
- man createrepo
- man pages mirrored online: https://manned.org/createrepo
Summary
- createrepo is a practical tool for turning a directory of RPMs into a usable repository with metadata.
- Start simple, then layer in exclusions and specific checksums as your use case requires.