Product SiteDocumentation Site

2.4.3. Testing a Package with Mock

These steps show how to test a package with the help of Mock. Mock creates chroots and builds packages in them. Its only task is to reliably populate a chroot and attempt to build a package in that chroot. Use Mock to test that you have accurate definitions of the build dependencies in your spec file.

Procedure 2.6. Testing a package with Mock

  1. As root, run the following command to add your normal user that you intend to use with Mock to the mock group:
     usermod -a G mock user_name && newgrp mock 
  2. Create a source package with the following command:
     rpmbuild -bs package.spec 
    where package.spec is the name of the spec file for your package.
  3. To test a package locally with Mock, run the following command:
     mock -r config_name rebuild path_to_source_package 
    where config_name is the name of the configuration name. The configuration file name contains the name of the used system architecture and operating system (for example Fedora 18). Refer to the /etc/mock/ directory for a list of available configuration files.
    For example, to test the ~/rpmbuild/SRPMS/eject-2.1.5-0.1.fc18.src.rpm package for the AMD64 (x86_64) architecture on Fedora 18, run the following command:
     mock -r epel-6-x86_64 ~/rpmbuild/SRPMS/eject-2.1.5-0.1.fc18.src.rpm