Projects/Mock

From FedoraProject

< Projects(Difference between revisions)
Jump to: navigation, search
(cleanup page and add the current reference)
(Plugins)
 
(14 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
= Mock =
 
= 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.
+
Mock is a tool for building packages. It can build packages for different architectures and different Fedora or RHEL versions than the build host has. 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 also offers a multi-package tool, mockchain, that can build chains of packages that depend on each other.
 +
 
 +
Mock is capable of building SRPMs  from source configuration management if the mock-scm package is present, then building the SRPM into RPMs. See --scm-enable in the documentation.
  
 
== Status ==
 
== Status ==
Mock is currently being used for all Fedora builds. It is called by [[Koji]] to build chroots and packages.
+
 
 +
Mock is currently being used for all Fedora builds. It is called by [[Koji]] and [https://copr.fedoraproject.org Copr] to build chroots and packages.
  
 
== Download ==
 
== Download ==
https://fedorahosted.org/mock/ has all the latest builds.  It can be installed with "yum install mock".
 
  
To check out the current code:
+
If you want to contribute to code, please checkout https://fedorahosted.org/mock/ for more inforations.
* <code>git clone git://git.fedorahosted.org/git/mock.git mock</code>
+
 
 +
Otherwise just run "yum install mock".
  
 
== Setup ==
 
== Setup ==
Line 22: Line 27:
  
 
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.
 +
 +
== Plugins ==
 +
 +
* [[Projects/Mock/Plugin/BindMount|bind_mount]] - bind mountpoints inside the chroot
 +
* [[Projects/Mock/Plugin/CCache|ccache]] - compiler cache plugin
 +
* [[Projects/Mock/Plugin/ChrootScan|chroot_scan]] - allows you to retrieve build artifacts from buildroot (e.g. additional logs, coredumps)
 +
* [[Projects/Mock/Plugin/CompressLogs|compress_logs]] - compress logs
 +
* [[Projects/Mock/Plugin/LvmRoot|lvm_root]] - caching buildroots using LVM
 +
* [[Projects/Mock/Plugin/Mount|mount]] - allows you to mount directories into chroot
 +
* [[Projects/Mock/Plugin/PackageState|package_state]] - dumps list of available and installed packages
 +
* [[Projects/Mock/Plugin/RootCache|root_cache]] - cache buildroots (as tar file).
 +
* [[Projects/Mock/Plugin/SELinux|selinux]] - on SELinux enabled box, this plugin will pretend, that SELinux is disabled in build environment.
 +
* [[Projects/Mock/Plugin/Sign|sign]] - call command on the produced rpm.
 +
* [[Projects/Mock/Plugin/Tmpfs|tmpfs]] - mount buildroot directory as tmpfs
 +
* [[Projects/Mock/Plugin/YumCache|yum_cache]] - mount /var/cache/yum of your machine to chroot
  
 
== Using Mock outside your git sandbox ==
 
== Using Mock outside your git sandbox ==
Line 31: Line 51:
  
 
where <configname> is the name of a configuration from /etc/mock/, without the /etc/mock path prefix and without the .cfg suffix.
 
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 <code>/var/lib/mock/<configfile>/result</code>
 
Note that you can track the progress of mock using the logs stored in <code>/var/lib/mock/<configfile>/result</code>
Line 40: Line 58:
  
 
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]).
 
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. E.g.:
 +
koji mock-config --tag f21-build --arch=aarch64  f21
  
 
== See Also ==
 
== See Also ==

Latest revision as of 14:18, 27 April 2015

Contents

[edit] Mock

Mock is a tool for building packages. It can build packages for different architectures and different Fedora or RHEL versions than the build host has. 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 also offers a multi-package tool, mockchain, that can build chains of packages that depend on each other.

Mock is capable of building SRPMs from source configuration management if the mock-scm package is present, then building the SRPM into RPMs. See --scm-enable in the documentation.

[edit] Status

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

[edit] Download

If you want to contribute to code, please checkout https://fedorahosted.org/mock/ for more inforations.

Otherwise just run "yum install mock".

[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] Plugins

  • bind_mount - bind mountpoints inside the chroot
  • ccache - compiler cache plugin
  • chroot_scan - allows you to retrieve build artifacts from buildroot (e.g. additional logs, coredumps)
  • compress_logs - compress logs
  • lvm_root - caching buildroots using LVM
  • mount - allows you to mount directories into chroot
  • package_state - dumps list of available and installed packages
  • root_cache - cache buildroots (as tar file).
  • selinux - on SELinux enabled box, this plugin will pretend, that SELinux is disabled in build environment.
  • sign - call command on the produced rpm.
  • tmpfs - mount buildroot directory as tmpfs
  • yum_cache - mount /var/cache/yum of your machine to chroot

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

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. E.g.:

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

[edit] See Also