Manpages

NAME

mock − build SRPMs in a chroot

SYNTAX

mock [options] −−rebuild SRPM [SRPM...]

mock [options] −−buildsrpm {−−spec spec −−sources src −−symlink−dereference | −−scm−enable}

mock [options] −−chroot <cmd>

mock [options] {−−init|clean|shell}

mock [options] −−installdeps {SRPM|RPM}

mock [options] −i, −−install PACKAGE [PACKAGE...]

mock [options] −−update [PACKAGE...]

mock [options] −−remove PACKAGE [PACKAGE...]

mock [options] −−orphanskill

mock [options] −p, −−print−root−path

mock [options] −−copyin path [path...] destination

mock [options] −−copyout path [path...] destination

mock [options] −−scm−enable [−−scm−option key=value ...]

mock [options] −l, −−list−snapshots

mock [options] −−snapshot [snapshot−name]

mock [options] −−rollback−to [snapshot−name]

mock [options] −−remove−snapshot [snapshot−name]

mock [options] −−umount

mock [options] −−pm−cmd [arguments ...]

mock [options] −−yum−cmd [arguments ...]

mock [options] −−dnf−cmd [arguments ...]

DESCRIPTION

Mock is a simple program that will build source RPMs inside a chroot. It doesn’t do anything terribly fancy other than populate a chroot with the contents specified by a configuration file, then build any input SRPM(s) in that chroot.

The content of a chroot is specified by the configuration specified with the −r option. The default configuration file is /etc/mock/default.cfg, which is usually a symlink to one of the installed configurations.

There is a site-wide configuration file, /etc/mock/site−defaults.cfg, which can be used to specify site−wide options. The shipped version of this file has no active options, but does have a list of all of the configuration options, examples of how to set them, and their default values.

For backwards compatibility, old-style commands, ("rebuild", "init", "clean", etc.) without leading ’−−’ are still accepted, but are deprecated. See COMMANDS section, below, for detailed listing of all commands.

To use mock, a user should become a member of the mock group by adding their username to the mock line in /etc/group. This can be done with the following command:

sudo /usr/sbin/usermod −a −G mock $USER

Note that mock is not intended to be run directly as root.

Warning: Mock is running some parts of code under root privileges. There are known ways how to get root access once user is in mock group (and once he is able to run mock). This is possible when user abuse the mock configuration options. Please do not add anyone who is not trustworthy to the mock group!

COMMANDS

−−buildsrpm

Builds the specified SRPM either from a spec file and source file/directory or from SCM. The chroot is cleaned first, unless −−no−clean is specified.

−−clean

Purge the chroot tree.

−−copyin

Copies the source paths (files or directory trees) into the chroot at the specified destination path.

−−copyout

Copies the source paths (files or directory trees) from the chroot to the specified destination path.

−−chroot COMMAND [ARGS...]

Run the specified command non−interactively within the chroot (no ’clean’ is performed). Command output will be sent to the log files. Note that COMMAND is shell expanded only if there are no ARGS. Otherwise there is no shell expansion.

−−dnf−cmd

Execute following arguments with DNF with installroot set to the chroot path. DNF must be installed on the system. It will use the binary which is specified in ’dnf_command’ option in site−defaults.cfg config, which by default is /usr/bin/dnf. This option will enforce −−dnf.

−−init

Initialize a chroot (clean, install chroot packages, etc.)

−i, −−install

Do a yum install PACKAGE inside the chroot. No ’clean’ is performed

−−installdeps

Find out deps for SRPM or RPM, and do a yum install to put them in the chroot. No ’clean’ is performed

−l, −−list−snapshots

List all existing snapshots of the chroot belonging to current configuration. Current base snapshot is marked with an asterisk (*)

−−mount

Mount all everything mounted in the chroot path including the root itself that might have been a LVM volume or TMPFS.

−−orphanskill

No−op mode that simply checks that no stray processes are running in the chroot. Kills any processes that it finds using specified root.

−−pm−cmd

Execute following arguments with current package manager with installroot set to the chroot path.

−p, −−print−root−path

Prints a path to the currently used chroot directory.

−−rebuild

If no command is specified, rebuild is assumed. Rebuilds the specified SRPM(s). The chroot is cleaned first, unless −−no−clean is specified.

−−remove

Do a yum remove PACKAGE inside the chroot. No ’clean’ is performed

−−remove−snapshot

Remove given snapshot freeing the space it occupied. This action cannot be undone. This feature is available only when lvm_root plugin is installed and enabled.

−−rollback−to

Return chroot to the state in specified snapshot and set it as the current base to which clean actions will return. It won’t delete nor modify the snapshot that was set as base previously. This feature is available only when lvm_root plugin is installed and enabled.

−−scm−enable

Enable building from an SCM (CVS/Git/SVN). The SCM repository must be configured in site−defaults.cfg before SCM checkouts are possible. SCM package and branch can be defined with −−scm−option arguments, see site−defaults.cfg for more information.

−−scrub=TYPE

Completely remove the specified chroot or cache dir or all of the chroot and cache. TYPE is one of all, chroot, cache, root−cache, c−cache, yum−cache or dnf−cache. In fact, dnf−cache is just alias for yum−cache and both removes Dnf and Yum cache.

−−shell [COMMAND [ARGS...]]

Run the specified command interactively within the chroot (no ’clean’ is performed). If no command specified, /bin/sh is run. Note that COMMAND is shell expanded using shell in chroot.

−−sources=SOURCES

Specifies sources (either a single file or a directory of files) to use to build an SRPM (used only with −−buildsrpm).

−−spec=SPEC

Specifies spec file to use to build an SRPM (used only with −−buildsrpm).

−−update [PACKAGE...]

Do a package update inside the chroot. The package list is optional, if omitted, all packages will be updated. No ’clean’ is performed

−−snapshot

Make a snapshot of the current state of the chroot. That snapshot will be set as the current base to which −−clean and implicit clean happening during rebuild command will return. This feature is available only when lvm_root plugin is installed and enabled.

−−umount

Umount all everything mounted in the chroot path including the root itself that might have been a LVM volume or TMPFS.

−−yum−cmd

Execute following arguments with YUM with installroot set to the chroot path. Yum must be installed on the system. It will use the binary which is specified in ’yum_command’ option in site−defaults.cfg config, which by default is /usr/bin/yum. Note that in config files for Fedora 22+ this value is overwriten in chroot config to default to /usr/bin/yum−deprecated. This option will enforce −−yum.

Note: While you can specify more commands on command line, only one can
be executed. The last command will win.

OPTIONS

−−arch=ARCH

Calls the linux personality() syscall to tell the kernel to emulate a secondary architecture. For example, building i386 packages on an x86_64 buildhost.

−−cache−alterations

Rebuild the root cache after making alterations to the chroot (i.e. −−install). Only useful when using tmpfs plugin.

−−cleanup−after

Clean chroot after building. Use with −−resultdir. Only active for ’−−rebuild’.

−−configdir=CONFIGDIR

Change directory where config files are found

−−cwd=DIR

Change to the specified directory (relative to the chroot) before running command when using −−chroot

−D "MACRO EXPR", −−define="MACRO EXPR"

Specify macro definitions used for the build. This option may be used multiple times, just as the rpmbuild −−define option can be. For example:

−−define "with_extra_cheese 1" −−define="packager Monkey"

−−disable−plugin=PLUGIN

Disable the specified plugin. This option may be used multiple times.

−−disablerepo=REPO

Pass −−disablerepo option to package manager to disable a repository. It can be specified multiple times.

−−dnf

Use DNF as the current package manager. You should have DNF (and dnf−plugins−core) installed on your system.

−−enable−plugin=PLUGIN

Enable the specified plugin. This option may be used multiple times.

−−enablerepo=REPO

Pass −−enablerepo option to package manager to enable a repository. It can be specified multiple times.

−h, −−help

Show usage information and exit.

−−macro−file=FILE

Use pre−defined rpm macro file. Macros passed to ’−−define’ override macros of the same name from FILE.

−−new−chroot

use new chroot (systemd−nspawn) − this is experimental and will break existing scripts.

−n, −−no−clean

Do not clean chroot before building package.

−−nocheck

Pass −−nocheck to rpmbuild to skip ’make check’ tests.

−−no−cleanup−after

Don’t clean chroot after building. If automatic cleanup is enabled, use this to disable.

−−offline

Run in ’offline’ mode where we tell ’yum’ to run completely from local cache. Also disables cache expiry for the mock yum cache.

−−old−chroot

use old chroot instead of systemd−nspawn.

−−plugin−option PLUGIN:KEY=VALUE

Set plugin specific parameter. This option may be used multiple times.

−−postinstall

Try to install built packages in the same buildroot right after build.

−q, −−quiet

Be quiet.

−r CONFIG, −−root=CONFIG

Uses specified chroot configuration as defined in /etc/mock/<CONFIG>.cfg. Optionally if CONFIG ends in ’.cfg’, it is interpreted as full path to config file. If none specified, uses the chroot config linked to by /etc/mock/default.cfg.

−−resultdir=RESULTDIR

Change directory where resulting files (RPMs and build logs) are written. Resultdir can contain python−string substitutions for any variable in the chroot config. For example:

−−resultdir=./my/"%(dist)s"/"%(target_arch)s"/

This option enables automatic cleanup, this can be changed in config file (by cleanup_on_success, cleanup_on_failure configuration options) or overridden by −−no−cleanup−after/−−cleanup−after arguments.

−−rootdir=ROOTDIR

Path for where the chroot should be built. By default it is created in /var/lib/mock/<CONFIG>/root/.

−−rpmbuild−opts=OPTIONS

Pass additional options to rpmbuild. To pass more options, put them in quotes.

−−rpmbuild_timeout=SECONDS

Fail build if rpmbuild takes longer than ’timeout’ seconds

−−scm−option=OPTIONS

define an SCM option (may be used more than once).

−−short−circuit=STAGE

Use rpmbuild’s short−circuit mechanism to skip already executed stages of build. It doesn’t produce RPMs, it’s useful only for debugging packaging. Implies −−no−clean. STAGE specifies which stage will be executed as the first. Available values: prep, build, install, binary.

−−symlink−dereference

Follow symlinks in sources (used only with −−buildsrpm).

−−target=ARCH

This argument is passed to rpmbuild to specify the target arch to build. It defaults to whatever is specified for −−arch, or whatever is specified in the config file as config_opts[’target_arch’].

−−trace

Enables verbose tracing of function enter/exit with function arguments and return codes. Useful for debugging mock itself.

−−uniqueext=text

Arbitrary, unique extension to append to chroot directory name

−−unpriv

Drop privileges before running command when using −−chroot

−v, −−verbose

Output verbose progress information.

−−version

Show version number and exit.

−−with=OPTION

Enable configure OPTION for build. This option may be used multiple times. For example:

−−with=extra_cheese

−−without=OPTION

Disable configure OPTION for build. This option may be used multiple times. For example:

−−without=anchovies

−−yum

Use yum as the current package manager. This is the default.

FILES

/etc/mock/ − default configuration directory

/var/lib/mock − directory where chroots are created

EXAMPLES

To rebuild test.src.rpm using the Fedora 14 configuration for x86_64

mock −r fedora−14−x86_64 −−rebuild /path/to/test.src.rpm

Note that the available configurations are found in the /etc/mock directory with the extension .cfg. To specify a configuration use the filename without the trailing .cfg extension.

To place the output RPMs and logs in a specified location.

mock −r fedora−14−i386 −−resultdir=./my−results /path/to/your.src.rpm

To build a package from the default SCM repository configured in site−defaults.cfg use the following arguments.

mock −r fedora−14−i386 −−scm−enable −−scm−option package=pkg

To build execute command inside of chroot.

mock −r fedora−21−x86_64 −−chroot −− rpm −−eval %dist

mock −r fedora−21−x86_64 −−chroot ’rpm −−eval %dist’

To build rawhide package using yum:

mock −r fedora−rawhide−x86_64 −−yum −−rebuild your.src.rpm

Query rpm database inside chroot using Yum:

mock −r fedora−rawhide−x86_64 −−yum−cmd whatprovides foo

List package manager history using package manager which is configured in chroot config (can be either DNF or YUM):

mock −r fedora−rawhide−x86_64 −−pm−cmd history list

BUGS

To report bugs in mock, go to:

https://apps.fedoraproject.org/packages/mock/.

Select the Bugs tab. If there is a bug similar to the one you are seeing, add your information to the comments. If not, press Open A New Bug and fill in the form.

AUTHORS

Michael Brown <mebrown1.3.2-2"michaels−house.net>

Clark Williams <williams1.3.2-2"redhat.com>

Seth Vidal <skvidal1.3.2-2"linux.duke.edu>

and a cast of...tens

SEE ALSO

mockchain(1), rpmbuild(8), yum(8), https://fedoraproject.org/wiki/Mock