$linuxjunkies
>

mock

A tool that builds RPM packages in an isolated chroot environment to ensure clean, reproducible builds without affecting the host system.

mock is a build tool primarily used in Red Hat-based Linux distributions (Fedora, RHEL, CentOS) to compile source code into binary RPM packages. It creates a minimal, isolated chroot jail with only the necessary build dependencies, preventing the build process from polluting your host system or causing version conflicts.

The tool is especially valuable for maintaining software quality because each build starts from a clean slate. Developers can specify which distribution and architecture to target, making it easy to test whether a package builds correctly on multiple systems without needing separate machines.

Example usage: mock -r fedora-39-x86_64 /path/to/package.src.rpm builds a source RPM in an isolated Fedora 39 environment. Mock downloads required dependencies, configures the chroot, compiles the code, and produces a binary RPM—all without touching your actual system.

Related terms