Using Mock is easy
There are a lot of articles and documentation pages explaining how to use Mock but I am hesitant to share them with new Fedora packagers because they make the tool look much scarier than it actually is. Using Mock is easy!
rpmbuild which builds packages directly on your computer
without any isolation, Mock spawns a container with a minimal
build environment and builds your package inside. As a consequence:
- A bug in the package won’t break your system
- Two people building a package on different computers will always get the same results
BuildRequiresthat you forgot to put into the spec file will be revealed
Install Mock from the Fedora repositories.
sudo dnf install mock
By default, Mock can be used only by the root user. Please don’t run
sudo and instead add yourself to the
sudo usermod -a -G mock $USER
Mock takes an SRPM and produces an RPM package for a given Fedora version and architecture. If you don’t have an SRPM package yet, you need to build it from a spec file first. If you downloaded an SRPM package from the internet or already built it, you can skip this step.
rpmbuild -bs /path/to/your/foo.spec
And pass the resulting SRPM to Mock.
By default Mock builds the RPM packages for the Fedora version and
architecture that matches your system. If you want to specify a
different target, use the
-r parameter and press
<TAB> twice to see
all the possible options.