1mock(1) Vidal" mock(1)
2
3
4
6 mock - build SRPMs in a chroot
7
9 mock [options] --rebuild SRPM [SRPM...]
10
11 mock [options] --chain SRPM [SRPM...]
12
13 mock [options] --buildsrpm {--spec spec --sources src --symlink-deref‐
14 erence | --scm-enable}
15
16 mock [options] --chroot <cmd>
17
18 mock [options] {--init|clean|shell}
19
20 mock [options] --installdeps {SRPM|RPM|SPEC}
21
22 mock [options] -i, --install PACKAGE [PACKAGE...]
23
24 mock [options] --update [PACKAGE...]
25
26 mock [options] --remove PACKAGE [PACKAGE...]
27
28 mock [options] --orphanskill
29
30 mock [options] -p, --print-root-path
31
32 mock [options] --copyin path [path...] destination
33
34 mock [options] --copyout path [path...] destination
35
36 mock [options] --scm-enable [--scm-option key=value ...]
37
38 mock [options] -l, --list-snapshots
39
40 mock [options] --snapshot [snapshot-name]
41
42 mock [options] --rollback-to [snapshot-name]
43
44 mock [options] --remove-snapshot [snapshot-name]
45
46 mock [options] --umount
47
48 mock [options] --pm-cmd [arguments ...]
49
50 mock [options] --yum-cmd [arguments ...]
51
52 mock [options] --dnf-cmd [arguments ...]
53
54
55
57 Mock is a simple program that will build source RPMs inside a chroot.
58 It doesn't do anything fancy other than populating a chroot with the
59 contents specified by a configuration file, then build any input
60 SRPM(s) in that chroot.
61
62 The content of a chroot is specified by the configuration specified
63 with the -r option. The default configuration file is
64 /etc/mock/default.cfg, which is usually a symlink to one of the
65 installed configurations.
66
67 There is a site-wide configuration file, /etc/mock/site-defaults.cfg,
68 which can be used to specify site-wide options. The shipped version of
69 this file has no active options, but does have a list of all of the
70 configuration options examples of how to set them, and their default
71 values.
72
73 To change configuration only for the current user please use ~/.con‐
74 fig/mock.cfg configuration file.
75
76 For backward compatibility, old-style commands, ("rebuild", "init",
77 "clean", etc.) without leading '--' are still accepted, but are depre‐
78 cated. See COMMANDS section, below, for the detailed listing of all
79 commands.
80
81 To use mock, a user should become a member of the mock group by adding
82 their username to the mock line in /etc/group. This can be done with
83 the following command:
84
85 sudo /usr/sbin/usermod -a -G mock $USER
86
87 Note that mock is not intended to be run directly as root.
88
89 Warning: Mock is running some parts of code under root privileges.
90 There are known ways how to get root access once a user is in mock
91 group (and once he can to run mock). This is possible when a user
92 abuses the mock configuration options. Please do not add anyone who is
93 not trustworthy to the mock group!
94
95
96
98 --buildsrpm
99 Build the specified SRPM either from a spec file and source
100 file/directory or SCM. The chroot (including the results direc‐
101 tory) is cleaned first, unless --no-clean is specified.
102
103 --chain
104 When passing more than one SRPM, it will try to build failed
105 builds if at least one subsequent SRPM succeed. This mimic the
106 behaviour of deprecated mockchain.
107
108 --clean
109 Purge the chroot tree.
110
111 --copyin
112 Copies the source paths (files or directory trees) into the
113 chroot at the specified destination path.
114
115 --copyout
116 Copies the source paths (files or directory trees) from the
117 chroot to the specified destination path.
118
119 --chroot [--] COMMAND [ARGS...]
120 Run the specified command non-interactively within the chroot
121 (no --clean is performed).
122
123 This mode is similar to shell mode, except that the output is
124 logged and the COMMAND and ARGS arguments are't shell expanded
125 in chroot when the variant with CMD+ARGS is used, see the dif‐
126 ference in mock output:
127 mock --quiet --chroot -- echo '*'
128 *
129 mock --quiet --chroot -- 'echo *'
130 bin boot builddir dev etc home lib lib64 media mnt opt ...
131 See also --shell.
132
133 --debug-config
134 Print all options in config_opts.
135
136 --dnf-cmd
137 Execute following arguments with DNF with installroot set to the
138 chroot path. DNF must be installed on the system. It will use
139 the binary which is specified in 'dnf_command' option in site-
140 defaults.cfg config, which by default is /usr/bin/dnf. This
141 option will enforce --dnf.
142
143 --init Initialize a chroot (clean, install chroot packages, etc.).
144
145 -i, --install
146 Do a yum install PACKAGE inside the chroot. No 'clean' is per‐
147 formed.
148
149 --installdeps
150 Find out deps for SRPM or RPM, and do a yum install to put them
151 in the chroot. No 'clean' is performed
152
153 -l, --list-snapshots
154 List all existing snapshots of the chroot belonging to the cur‐
155 rent configuration. Current base snapshot is marked with an
156 asterisk (*)
157
158 --mount
159 Mount all everything mounted in the chroot path including the
160 root itself that might have been an LVM volume, TMPFS or over‐
161 layfs.
162
163 --orphanskill
164 No-op mode that simply checks that no stray processes are run‐
165 ning in the chroot. Kills any processes that it finds using the
166 specified root.
167
168 --pm-cmd
169 Execute following arguments with the current package manager
170 with installroot set to the chroot path.
171
172 -p, --print-root-path
173 Prints a path to the currently used chroot directory.
174
175 --rebuild
176 If no command is specified, rebuild is assumed. Rebuild the
177 specified SRPM(s). The chroot (including the results directory)
178 is cleaned first, unless --no-clean is specified.
179
180 --remove
181 Do a yum remove PACKAGE inside the chroot. No 'clean' is per‐
182 formed.
183
184 --remove-snapshot
185 Remove given snapshot freeing the space it occupied. This action
186 cannot be undone. This feature is available only when lvm_root
187 or overlayfs plugin is installed and enabled.
188
189 --rollback-to
190 Return chroot to the state in the specified snapshot and set it
191 as the current base to which clean actions will return. It won't
192 delete nor modify the snapshot that was set as base previously.
193 This feature is available only when the lvm_root or overlayfs
194 plugin is installed and enabled.
195
196 --scm-enable
197 Enable building from an SCM (CVS/Git/SVN/DistGit). The SCM
198 repository must be configured in site-defaults.cfg before SCM
199 checkouts are possible. SCM package and branch can be defined
200 with --scm-option arguments, see site-defaults.cfg for more
201 information.
202
203 --scrub=TYPE
204 Completely remove the specified chroot or cache dir or all of
205 the chroot and cache. TYPE is one of all, chroot, bootstrap,
206 cache, root-cache, c-cache, yum-cache or dnf-cache. In fact,
207 dnf-cache is just alias for yum-cache, and both remove Dnf and
208 Yum cache.
209
210 --shell [--] [COMMAND [ARGS...]]
211 Shell mode. Run the specified command interactively within the
212 chroot (no --clean is performed). If no command specified,
213 /bin/sh is run and prompt is provided.
214
215 Be aware that mock first parses all the command-line arguments,
216 so the ARGS could be mistakenly evaluated as mock's options.
217 Thats why you almost always want to use the -- separator.
218
219 This mode does not produce logs (nothing is appended to root.log
220 in --resultdir).
221
222 The COMMAND and ARGS are shell expanded using the shell in
223 chroot (unless they mistakenly expand in host's terminal shell).
224 E.g. the following two commands are equivalent:
225 mock --shell -- ls -l '*'
226 mock --shell 'ls -l *'
227 But the following is something entierly different:
228 mock --shell -- ls -l *
229
230 --sources=SOURCES
231 Specifies sources (either a single file or a directory of files)
232 to use to build an SRPM (used only with --buildsrpm).
233
234 --spec=SPEC
235 Specifies spec file to use to build an SRPM.
236
237 --update [PACKAGE...]
238 Do a package update inside the chroot. The package list is
239 optional, if omitted, all packages will be updated. No 'clean'
240 is performed.
241
242 --snapshot
243 Make a snapshot of the current state of the chroot. That snap‐
244 shot will be set as the current base to which --clean and
245 implicit clean happening during rebuild command will return.
246 This feature is available only when the lvm_root or overlayfs
247 plugin is installed and enabled.
248
249 --umount
250 Umount all everything mounted in the chroot path including the
251 root itself that might have been an LVM volume, TMPFS or overa‐
252 lyfs.
253
254 --yum-cmd
255 Execute following arguments with YUM with installroot set to the
256 chroot path. Yum must be installed on the system. It will use
257 the binary which is specified in 'yum_command' option in site-
258 defaults.cfg config, which by default is /usr/bin/yum. Note
259 that in config files for Fedora 22+ this value is overwritten in
260 chroot config to default to /usr/bin/yum-deprecated. This
261 option will enforce --yum.
262
263 Note: While you can specify more commands on a command line, only one
264 can be executed. The last command will win.
265
266
267
269 -a, --addrepo=REPO
270 Add this repo baseurl to the yumconfig for the chroot. This can
271 be specified multiple times. Let's you point to multiple paths
272 beyond the default to pull build deps from.
273
274 This has effect only for --chain command
275
276 --arch=ARCH
277 Calls the Linux personality() syscall to tell the kernel to emu‐
278 late a secondary architecture. For example, building i386 pack‐
279 ages on an x86_64 buildhost.
280
281 --forcearch=ARCH
282 Pass --forcearch to DNF. This will enable to install packages
283 for different architecture. Works only for DNF and you have to
284 have package qemu-user-static installed.
285
286 --cache-alterations
287 Rebuild the root cache after making alterations to the chroot
288 (i.e. --install). This option is useful only when using tmpfs
289 plugin.
290
291 --cleanup-after
292 Clean chroot after building. Use with --resultdir. Only active
293 for '--rebuild'.
294
295 --configdir=CONFIGDIR
296 Change directory where config files are found
297
298 --config-opts=KEY=VALUE
299 Override configuration option. Can be used multiple times. When
300 used multiple times for the same key, it will create an array.
301 This is evaluated first (after parsing configs) so any special‐
302 ized command line option can override values defined in this
303 option.
304
305 --continue
306 If a pkg fails to build, continue to the next one, default is to
307 stop.
308
309 --cwd=DIR
310 Change to the specified directory (relative to the chroot)
311 before running command when using --chroot
312
313 -D "MACRO EXPR", --define="MACRO EXPR"
314 Specify macro definitions used for the build. This option may
315 be used multiple times, just as the rpmbuild --define option can
316 be. For example:
317
318 --define "with_extra_cheese 1" --define="packager Monkey"
319
320 --disable-plugin=PLUGIN
321 Disable the specified plugin. This option may be used multiple
322 times.
323
324 --disablerepo=REPO
325 Pass --disablerepo option to package manager to disable a repos‐
326 itory. It can be specified multiple times.
327
328 --dnf Use DNF as the current package manager. You should have DNF (and
329 dnf-plugins-core) installed on your system. This is the default.
330
331 --enable-plugin=PLUGIN
332 Enable the specified plugin. This option may be used multiple
333 times.
334
335 --enablerepo=REPO
336 Pass --enablerepo option to package manager to enable a reposi‐
337 tory. It can be specified multiple times.
338
339 --enable-network
340 Enable networking. If you want to have reproducible builds then
341 your builds should run without a network. This option overrides
342 config_opts['rpmbuild_networking'] and con‐
343 fig_opts['use_host_resolv'], setting both True.
344
345 --isolation={auto|nspawn|simple}
346 What should be used for isolation of chroot. The simple method
347 uses chroot() call. The nspawn method utilizes systemd-
348 nspawn(1) and runs the commands inside container. The auto
349 tries to use nspawn, and falls back to simple if system-nspawn
350 can not be used (e.g. if mock is run in container). The default
351 is auto.
352
353 --localrepo=REPO
354 Set the path to put the results/repo in (works only in --chain
355 mode). Will make a tempdir if not set.
356
357 -c If package fails, continue to the next one (works only in
358 --chain mode).
359
360 -h, --help
361 Show usage information and exit.
362
363 --macro-file=FILE
364 Use pre-defined rpm macro file. Macros passed to '--define'
365 override macros of the same name from FILE.
366
367 --new-chroot
368 Deprecated. Use --isolation=nspawn.
369
370 -n, --no-clean
371 Do not clean chroot before building a package.
372
373 --nocheck
374 Pass --nocheck to rpmbuild to skip 'make check' tests.
375
376 -N, --no-cleanup-after
377 Don't clean chroot after building. If automatic cleanup is
378 enabled, use this to disable.
379
380 --offline
381 Run in an 'offline' mode where we tell 'yum' to run completely
382 from the local cache. Also, disables cache expiry for the mock
383 yum cache.
384
385 --old-chroot
386 Deprecated. Use --isolation=simple.
387
388 --plugin-option PLUGIN:KEY=VALUE
389 Set plugin specific parameter. This option may be used multiple
390 times. Examples:
391
392 --plugin-option=root_cache:age_check=False
393
394 --plugin-option=mount:dirs=("/dev/device",
395 "/mount/path/in/chroot/", "vfstype", "mount_options")
396
397 --postinstall
398 Try to install built packages in the same buildroot right after
399 the build.
400
401 -q, --quiet
402 Be quiet.
403
404 --recurse
405 Build all pkgs, record the failures and try to rebuild them
406 again and again until everything gets built (or until the set of
407 pkgs failing to build are the same over) sets --continue.
408
409 -r CONFIG, --root=CONFIG
410 Uses specified chroot configuration as defined in ~/.con‐
411 fig/mock/<CONFIG>.cfg or /etc/mock/<CONFIG>.cfg. Optionally if
412 CONFIG ends in '.cfg', it is interpreted as full path to config
413 file. If none specified, uses the chroot config linked to by
414 /etc/mock/default.cfg.
415
416 --resultdir=RESULTDIR
417 Change directory where resulting files (RPMs and build logs) are
418 written. Resultdir can contain python-string substitutions for
419 any variable in the chroot config. For example:
420
421 --resultdir=./my/"{{dist}}"/"{{target_arch}}"/
422
423 This option enables automatic cleanup, this can be changed in
424 config file (by cleanup_on_success, cleanup_on_failure configu‐
425 ration options) or overridden by
426 --no-cleanup-after/--cleanup-after arguments.
427
428 Note that this option does not have an effect for --chain com‐
429 mand. You can use --localrepo instead.
430
431 --rootdir=ROOTDIR
432 The path for where the chroot should be built. By default it is
433 created in /var/lib/mock/<CONFIG>/root/.
434
435 --rpmbuild-opts=OPTIONS
436 Pass additional options to rpmbuild. To pass more options, put
437 them in quotes.
438
439 --rpmbuild_timeout=SECONDS
440 Fail build if rpmbuild takes longer than 'timeout' seconds
441
442 --scm-option=OPTIONS
443 define an SCM option (may be used more than once).
444
445 --short-circuit=STAGE
446 Use rpmbuild's short-circuit mechanism to skip already executed
447 stages of the build. It doesn't produce RPMs, and it's useful
448 only for debugging packaging. Implies --no-clean. STAGE speci‐
449 fies which stage will be executed as the first. Available val‐
450 ues: prep, build, install, binary.
451
452 --symlink-dereference
453 Follow symlinks in sources (used only with --buildsrpm).
454
455 --target=ARCH
456 This argument is passed to rpmbuild to specify the target arch
457 to build. It defaults to whatever is specified for --arch, or
458 whatever is specified in the config file as config_opts['tar‐
459 get_arch'].
460
461 --tmp_prefix=PREFIX
462 Tmp dir prefix - will default to username-pid if not specified.
463
464 --trace
465 Enables verbose tracing of function enter/exit with function
466 arguments and return codes. Useful for debugging mock itself.
467
468 --uniqueext=text
469 Arbitrary, unique extension to append to chroot directory name
470
471 --unpriv
472 Drop privileges before running command when using --chroot
473
474 -v, --verbose
475 Output verbose progress information.
476
477 --version
478 Show version number and exit.
479
480 --with=OPTION
481 Enable configure OPTION for the build. This option may be used
482 multiple times. For example:
483
484 --with=extra_cheese
485
486 --without=OPTION
487 Disable configure OPTION for the build. This option may be used
488 multiple times. For example:
489
490 --without=anchovies
491
492 --yum Use yum as the current package manager.
493
494
495 --bootstrap-chroot
496 build in two stages, using chroot rpm for creating the build
497 chroot
498
499 --no-bootstrap-chroot
500 build in a single stage, using system rpm for creating the build
501 chroot
502
503
504 --use-bootstrap-image
505 Instead of creating a bootstrap chroot from scrath, use podman
506 image specified in config_opts['bootstrap_image'], extract it,
507 and use it as a cache for the bootstrap chroot. This is useful
508 when host rpm version is not compatible with the target system,
509 or when using mock on non-RPM distributions. This option turns
510 --bootstrap-chroot on.
511
512
513 --no-bootstrap-image
514 don't create bootstrap chroot from container image
515
516
518 /etc/mock/ - default configuration directory
519
520 /var/lib/mock - directory where chroots and results are created. You
521 should not put there your input files.
522
524 To rebuild test.src.rpm using the Fedora 14 configuration for x86_64
525
526 mock -r fedora-14-x86_64 --rebuild /path/to/test.src.rpm
527
528 Note that the available configurations are found in the /etc/mock
529 directory with the extension .cfg. To specify a configuration use the
530 filename without the trailing .cfg extension.
531
532 To place the output RPMs and logs in a specified location.
533
534 mock -r fedora-14-i386 --resultdir=./my-results
535 /path/to/your.src.rpm
536
537 To build a package from the default SCM repository configured in
538 site-defaults.cfg use the following arguments.
539
540 mock -r fedora-14-i386 --scm-enable --scm-option package=pkg
541
542 To execute a command inside of chroot.
543
544 mock -r fedora-21-x86_64 --chroot -- rpm --eval %dist
545
546 mock -r fedora-21-x86_64 --chroot 'rpm --eval %dist'
547
548 To build rawhide package using yum:
549
550 mock -r fedora-rawhide-x86_64 --yum --rebuild your.src.rpm
551
552 Query rpm database inside chroot using Yum:
553
554 mock -r fedora-rawhide-x86_64 --yum-cmd whatprovides foo
555
556 List package manager history using package manager which is configured
557 in chroot config (can be either DNF or YUM):
558
559 mock -r fedora-rawhide-x86_64 --pm-cmd history list
560
561
563 To report bugs in mock, go to:
564
565 https://apps.fedoraproject.org/packages/mock/.
566
567 Select the Bugs tab. If there is a bug similar to the one you are see‐
568 ing, add your information to the comments. If not, press Open A New Bug
569 and fill in the form.
570
572 Michael Brown <mebrown@michaels-house.net>
573
574 Clark Williams <williams@redhat.com>
575
576 Seth Vidal
577
578 and a cast of...tens
579
581 rpmbuild(8), yum(8), dnf(8), https://github.com/rpm-software-manage‐
582 ment/mock/wiki
583
584
585
586Seth 2.2" mock(1)