From Fedora Project Wiki

(Imported from MoinMoin)
m (1 revision(s))
(No difference)

Revision as of 16:26, 24 May 2008


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.


Mock is currently being used for all Fedora builds. It is called by Plague (<=FC-6) and Koji (>=F-7) to build chroots and packages.

Download has all the latest builds. It can be installed with "yum install mock".

To check out the current code:


All users that are to use mock must be added to the mock group.

Configuration files are in /etc/mock. Mock versions 0.8.0 and higher cache the downloaded rpm packages (via the yum_cache plugin), which speeds up subsequent builds by a considerable margin. Nevertheless, you may wish to change the default configuration to point to local repositories to speed up builds.

By default, builds are done in /var/lib/mock, so be sure you have room. Starting with mock 0.8.0 and higher, you can change this via the 'basedir' config option.


mock [options]  {init|clean}
mock [options]  [rebuild]  /path/to/srpm(s)
mock [options]  {shell|chroot} <cmd>
mock [options]  installdeps {SRPM|RPM}
mock [options]  install PACKAGE
rebuild     - build the specified SRPM(s) [default command] 
chroot      - run the specified command within the chroot
shell       - run an interactive shell within specified chroot
clean       - clean out the specified chroot
init        - initialize the chroot, do not build anything
installdeps - install build dependencies for a specified SRPM
install     - install packages using yum

--version             show program's version number and exit
-h, --help            show this help message and exit
-r CHROOT             chroot name/config file name default: default
--no-clean            do not clean chroot before building
--cleanup-after       Clean chroot after building. Use with --resultdir.
Only active for 'rebuild'.
--no-cleanup-after    Dont clean chroot after building. If automatic cleanup
is enabled, use this to disable.
--arch=ARCH           target build arch
path for resulting files to be put
Arbitrary, unique extension to append to buildroot
directory name
Change where config files are found
Fail build if rpmbuild takes longer than 'timeout'
Enable plugin. Currently-available plugins: ('ccache',
'yum_cache', 'root_cache', 'bind_mount')
Disable plugin. Currently-available plugins:
('ccache', 'yum_cache', 'root_cache', 'bind_mount')

For example, to rebuild a package for i386 on the development branch of Fedora:

  • mock rebuild -r fedora-devel-i386 /path/to/rpm

See /etc/mock for the available targets. If you have the bash-completion package installed, it will tab complete the targets for you.


If you encounter a bug running mock, please file it in Bugzilla , product "Fedora Hosted Projects", component mock.

See Also

Extras/MockTricks has some useful tips for using mock.
Docs/Drafts/MockSetupUsingLocalMirror Setting up a local mirror using Mock.
Legacy/Mock has some useful tips for building packages in mock for older Fedora and Red Hat Linux releases.