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