From Mageia wiki
Jump to: navigation, search

Mock is an easy-to-use package builder that lets you build packages in a clean container environment. It currently supports Mageia (Mageia 6 and up), Fedora, and RHEL/CentOS as distribution targets for building packages.

Install and Setup

  • Install mock and mock-mageia-configs:
  # dnf install mock mock-mageia-configs # If using DNF
  # urpmi mock mock-mageia-configs # If using urpmi
  • Add your user to the 'mock' group:
  # usermod -a -G mock <username>
  • Initialize the new group:
  $ newgrp mock

Alternatively, instead of using newgrp, you can log out and log back in to have it take effect.

Build packages with Mock

Mock can be used for building packages for the same host architecture as well as other compatible architectures. For example, i586 packages can be built from x86_64 hosts.

If you want to build a package from a source package for Mageia 6 x86_64, just run the following command:

 mock --root mageia-6-x86_64 --rebuild </path/to/package.src.rpm> --resultdir </path/to/write/built/packages>

However, if you're starting from sources and a spec file, you may also want to use mock to generate the source package as well:

 mock --root mageia-6-x86_64 --buildsrpm --spec </path/to/package.spec> --sources </path/to/sourcedir> --resultdir </path/to/write/built/packages>

Note that usage of "--resultdir" is optional, and if not used, the default result dir is "/var/lib/mock/root-name/result".

To build for i586, simply swap x86_64 for i586 and it will just work!

Build a series of packages with Mockchain

Mockchain is a tool that lets you pass it a series of source packages to build in order. Using it is very simple:

 mockchain --root mageia-6-x86_64 </path/to/package1.src.rpm> </path/to/package2.src.rpm> ...

It will create a somewhat random directory to do builds and output the results and print them on-screen, so that you know where to get them after they're done.

Building packages to use packages from tainted or nonfree

If you want to build packages to use packages from tainted or nonfree, append "-tainted" or "-nonfree" to the root name.

For example, to build a package from a source package for Mageia 6 x86_64 with tainted packages, just run the following command:

 mock --root mageia-6-x86_64-tainted --rebuild </path/to/package.src.rpm> --resultdir </path/to/write/built/packages>

Building packages to target Cauldron

If you want to build packages to target Cauldron, swap the release version for "cauldron".

For example, to build a package from a source package for Mageia Cauldron x86_64, just run the following command:

 mock --root mageia-cauldron-x86_64 --rebuild </path/to/package.src.rpm> --resultdir </path/to/write/built/packages>

Documentation

Return to the Packagers portal