Other languages Deutsch ; English ; français ; |
Synopsis: 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, RHEL/CentOS, openSUSE Leap (openSUSE Leap 15.0 and up), and openSUSE Tumbleweed as distribution targets for building packages. |
Contents
- 1 Install and Setup
- 2 Build packages with Mock
- 3 Build a series of packages with Mockchain
- 4 Using packages not in repositories
- 5 Building packages to use packages from tainted or nonfree
- 6 Building packages to target Cauldron
- 7 Configuring for your needs
- 8 Configuring a proxy mirror
- 9 Documentation
Install and Setup
- Install
mock
andmock-mageia-configs
:
If using DNF
# dnf install mock mock-mageia-configs |
If using urpmi
# urpmi mock mock-mageia-configs |
- 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 8 x86_64, just run the following command:
mock --root mageia-8-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 can tell Mock to start from there:
mock --root mageia-8-x86_64 --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!
Mock also supports non-native architectures (like armv7hl and aarch64), and will transparently handle emulation as long as qemu-user-static
is installed. Just use the correct root referencing the desired architecture 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:
mock --chain --root mageia-8-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.
Using packages not in repositories
Often the building of a package has precedent package dependencies which are not yet in official repositories. For that, the process needs two steps, one for package integration and the second for the build itself which uses the previous packages:
mock -r mageia-8-x86_64 --install </path/to/package1.rpm> </path/to/package2.rpm> … |
mock --no-clean -r mageia-8-x86_64 --source SOURCES --spec SPECS/<mon paquet>.spec |
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 8 x86_64 with tainted packages, just run the following command:
mock --root mageia-8-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> |
Configuring for your needs
You can apply some settings to adapt mock to your needs or your machine. For this, you can create a configuration file ~/.config/mock.cfg
A default one can be copied from /usr/share/doc/mock/site-defaults.cfg
as documentation.
Here are some examples:
# Working directories for mock config_opts['basedir'] = '/var/lib/mock/' config_opts['cache_topdir'] = '/var/cache/mock' # use 3 cores in compression stage. Replace T3 with T<n> where <n> is the number of available cores. config_opts['macros']['%_binary_payload'] = 'w19T3.zstdio' |
Configuring a proxy mirror
You can see that mock download very often the metadata for dnf. Here a solution to accelerate the download and avoid failures at this step.
First, configure Urpmi-proxy on your machine or a server on your network.
Then edit /etc/mock/templates/mageia-cauldron.tpl
on the client side, and indicate your server as mirror address in baseurl lines (2), and comment mirrorlist lines. For example, when the server is rpi-aarch64.home:
baseurl=http://rpi-aarch64.home/mageia/distrib/cauldron/{{ repo_arch }}/media/core/release/ #mirrorlist=https://www.mageia.org/mirrorlist/?release=cauldron&arch={{ repo_arch }}§ion=core&repo=release |
You can also edit /etc/mock/templates/mageia-branched.tpl
in a similar way.