Projects/Mock

From FedoraProject

< Projects(Difference between revisions)
Jump to: navigation, search
(Imported from MoinMoin)
 
(mentioned cfg generation)
 
(15 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 +
{{autolang|base=yes}}
 +
 
= Mock =
 
= Mock =
  
Line 4: Line 6:
  
 
== Status ==
 
== Status ==
Mock is currently being used for all Fedora builds. It is called by [[Projects/Plague|  Plague]]  (<=FC-6) and [[Koji|  Koji]] (>=F-7) to build chroots and packages.
+
Mock is currently being used for all Fedora builds. It is called by [[Koji]] to build chroots and packages.
  
 
== Download ==
 
== Download ==
Line 13: Line 15:
  
 
== Setup ==
 
== Setup ==
 +
All users that are to use mock must be added to the 'mock' group.
  
All users that are to use mock must be added to the mock group.
+
<code>usermod -a -G mock [User name] && newgrp mock</code>
  
 
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.
 
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.
Line 20: Line 23:
 
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.
 
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.
  
== Using ==
+
== Using Mock outside your git sandbox ==
<pre>
+
Create your SRPM using 'rpmbuild -bs'. Then change to the directory where your srpm was created.
Usage:
+
usage:
+
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
+
commands:
+
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
+
  
Options:
+
Now you can start mock with
--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
+
--resultdir=RESULTDIR
+
path for resulting files to be put
+
--uniqueext=UNIQUEEXT
+
Arbitrary, unique extension to append to buildroot
+
directory name
+
--configdir=CONFIGDIR
+
Change where config files are found
+
--rpmbuild_timeout=RPMBUILD_TIMEOUT
+
Fail build if rpmbuild takes longer than 'timeout'
+
seconds
+
--enable-plugin=ENABLED_PLUGINS
+
Enable plugin. Currently-available plugins: ('ccache',
+
'yum_cache', 'root_cache', 'bind_mount')
+
--disable-plugin=DISABLED_PLUGINS
+
Disable plugin. Currently-available plugins:
+
('ccache', 'yum_cache', 'root_cache', 'bind_mount')
+
</pre>
+
  
For example, to rebuild a package for i386 on the development branch of Fedora:
+
<code>mock -r <configname> rebuild package-1.2-3.src.rpm</code>
  
* <code>mock rebuild -r fedora-devel-i386 /path/to/rpm</code>
+
where <configname> is the name of a configuration from /etc/mock/, without the /etc/mock path prefix and without the .cfg suffix.
  
See /etc/mock for the available targets. If you have the bash-completion package installed, it will tab complete the targets for you.
+
If using mock version older than 0.8.8 or on a system with python 2.4, and building i386 packages on x86_64, prepend setarch i386 to the mock command line: setarch i386 mock -r <configfile> rebuild package-1.2-3.src.rpm. Newer versions of mock no longer need the setarch command, although it does not hurt anything if it is there.
 +
 
 +
Note that you can track the progress of mock using the logs stored in <code>/var/lib/mock/<configfile>/result</code>
  
 
== Problems ==
 
== Problems ==
If you encounter a bug running mock, please file it in [http://bugzilla.redhat.com Bugzilla] , product "Fedora Hosted Projects", component mock.
+
If you encounter a bug running mock, please file it in [https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=mock Bugzilla], product "Fedora", component mock ([https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&product=Fedora&component=mock&bug_status=NEW&bug_status=ASSIGNED&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&bug_status=VERIFIED&bug_status=FAILS_QA&bug_status=RELEASE_PENDING&bug_status=POST Open Bugs]).
 +
 
 +
If your problem is specific to EPEL, then [https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora%20EPEL&component=mock file it] against the "Fedora EPEL" product instead ([https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&product=Fedora%20EPEL&component=mock&bug_status=NEW&bug_status=ASSIGNED&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&bug_status=VERIFIED&bug_status=FAILS_QA&bug_status=RELEASE_PENDING&bug_status=POST Open Bugs]).
  
 +
== Generate custom config file ==
 +
Of course you may copy one and edit it manually, however if koji is already using such an config?
 +
Then you can use  '''mock-config --help''' for information how to generate one.
 +
* eg koji mock-config --tag f21-build --arch=aarch64  f21
 
== See Also ==
 
== See Also ==
  
[[Extras/MockTricks]]  has some useful tips for using mock.<BR>
+
* [[Using_Mock_to_test_package_builds]]  has some useful tips for using mock.
[[Docs/Drafts/MockSetupUsingLocalMirror]]  Setting up a local mirror using Mock. <BR>
+
* [[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.
+
* [[Legacy/Mock]]  has some useful tips for building packages in mock for older Fedora and Red Hat Linux releases.

Latest revision as of 16:55, 3 February 2014

Contents

[edit] 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.

[edit] Status

Mock is currently being used for all Fedora builds. It is called by Koji to build chroots and packages.

[edit] Download

https://fedorahosted.org/mock/ has all the latest builds. It can be installed with "yum install mock".

To check out the current code:

[edit] Setup

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

usermod -a -G mock [User name] && newgrp mock

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.

[edit] Using Mock outside your git sandbox

Create your SRPM using 'rpmbuild -bs'. Then change to the directory where your srpm was created.

Now you can start mock with

mock -r <configname> rebuild package-1.2-3.src.rpm

where <configname> is the name of a configuration from /etc/mock/, without the /etc/mock path prefix and without the .cfg suffix.

If using mock version older than 0.8.8 or on a system with python 2.4, and building i386 packages on x86_64, prepend setarch i386 to the mock command line: setarch i386 mock -r <configfile> rebuild package-1.2-3.src.rpm. Newer versions of mock no longer need the setarch command, although it does not hurt anything if it is there.

Note that you can track the progress of mock using the logs stored in /var/lib/mock/<configfile>/result

[edit] Problems

If you encounter a bug running mock, please file it in Bugzilla, product "Fedora", component mock (Open Bugs).

If your problem is specific to EPEL, then file it against the "Fedora EPEL" product instead (Open Bugs).

[edit] Generate custom config file

Of course you may copy one and edit it manually, however if koji is already using such an config? Then you can use mock-config --help for information how to generate one.

* eg koji mock-config --tag f21-build --arch=aarch64  f21

[edit] See Also