1mock(1)                             Vidal"                             mock(1)
2
3
4

NAME

6       mock - build SRPMs in a chroot
7

SYNTAX

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

DESCRIPTION

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

COMMANDS

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       -l, --list-snapshots
158              List all existing snapshots of the chroot belonging to the  cur‐
159              rent configuration.  Current base snapshot is marked with an as‐
160              terisk (*)
161
162       --mount
163              Mount all everything mounted in the chroot  path  including  the
164              root  itself  that might have been an LVM volume, TMPFS or over‐
165              layfs.
166
167       --orphanskill
168              No-op mode that simply checks that no stray processes  are  run‐
169              ning  in the chroot. Kills any processes that it finds using the
170              specified root.
171
172       --pm-cmd
173              Execute following arguments with  the  current  package  manager
174              with installroot set to the chroot path.
175
176       -p, --print-root-path
177              Prints a path to the currently used chroot directory.
178
179       --rebuild
180              If  no  command  is  specified,  rebuild is assumed. Rebuild the
181              specified SRPM(s). The chroot (including the results  directory)
182              is cleaned first, unless --no-clean is specified.
183
184       --remove
185              Do  a  yum  remove PACKAGE inside the chroot. No 'clean' is per‐
186              formed.
187
188       --remove-snapshot
189              Remove given snapshot freeing the space it occupied. This action
190              cannot  be undone.  This feature is available only when lvm_root
191              or overlayfs plugin is installed and enabled.
192
193       --rollback-to
194              Return chroot to the state in the specified snapshot and set  it
195              as the current base to which clean actions will return. It won't
196              delete nor modify the snapshot that was set as base  previously.
197              This  feature  is  available only when the lvm_root or overlayfs
198              plugin is installed and enabled.
199
200       --scm-enable
201              Enable building  from  an  SCM  (CVS/Git/SVN/DistGit).  The  SCM
202              repository  must  be  configured in site-defaults.cfg before SCM
203              checkouts are possible. SCM package and branch  can  be  defined
204              with  --scm-option arguments, see site-defaults.cfg for more in‐
205              formation.
206
207       --scrub=TYPE
208              Completely remove the specified chroot or cache dir  or  all  of
209              the  chroot  and  cache.  TYPE is one of all, chroot, bootstrap,
210              cache, root-cache, c-cache, yum-cache  or  dnf-cache.  In  fact,
211              dnf-cache  is  just alias for yum-cache, and both remove Dnf and
212              Yum cache.
213
214       --shell [--] [COMMAND [ARGS...]]
215              Shell mode.  Run the specified command interactively within  the
216              chroot  (no  --clean  is  performed).   If no command specified,
217              /bin/sh is run and prompt is provided.
218
219              Be aware that mock first parses all the command-line  arguments,
220              so  the  ARGS  could  be mistakenly evaluated as mock's options.
221              Thats why you almost always want to use the -- separator.
222
223              This mode does not produce logs (nothing is appended to root.log
224              in --resultdir).
225
226              The  COMMAND  and ARGS are shell expanded using the shell in ch‐
227              root (unless they mistakenly expand in host's  terminal  shell).
228              E.g. the following two commands are equivalent:
229                  mock --shell -- ls -l '*'
230                  mock --shell 'ls -l *'
231              But the following is something entierly different:
232                  mock --shell -- ls -l *
233
234       --sources=SOURCES
235              Specifies sources (either a single file or a directory of files)
236              to use to build an SRPM (used only with --buildsrpm).
237
238       --spec=SPEC
239              Specifies spec file to use to build an SRPM.
240
241       --update [PACKAGE...]
242              Do a package update inside the chroot. The package list  is  op‐
243              tional,  if omitted, all packages will be updated. No 'clean' is
244              performed.
245
246       --snapshot
247              Make a snapshot of the current state of the chroot.  That  snap‐
248              shot  will  be  set as the current base to which --clean and im‐
249              plicit clean happening during rebuild command will return.  This
250              feature  is available only when the lvm_root or overlayfs plugin
251              is installed and enabled.
252
253       --umount
254              Umount all everything mounted in the chroot path  including  the
255              root  itself that might have been an LVM volume, TMPFS or overa‐
256              lyfs.
257
258       --yum-cmd
259              Execute following arguments with YUM with installroot set to the
260              chroot  path.  Yum must be installed on the system.  It will use
261              the binary which is specified in 'yum_command' option  in  site-
262              defaults.cfg  config,  which  by  default is /usr/bin/yum.  Note
263              that in config files for Fedora 22+ this value is overwritten in
264              chroot  config  to default to /usr/bin/yum-deprecated.  This op‐
265              tion will enforce --yum.
266
267       Note: While you can specify more commands on a command line,  only  one
268       can be executed. The last command will win.
269
270
271

OPTIONS

273       -a, --addrepo=REPO
274              Add  this repo baseurl to the yumconfig for the chroot. This can
275              be specified multiple times. Let's you point to  multiple  paths
276              beyond the default to pull build deps from.
277
278
279       --arch=ARCH
280              Calls the Linux personality() syscall to tell the kernel to emu‐
281              late a secondary architecture. For example, building i386  pack‐
282              ages on an x86_64 buildhost.
283
284       --additional-package=PACKAGE
285              An  additional  package  (on  top  of in-package specified Buil‐
286              dRequires) to be installed into the buildroot before  the  build
287              is  done.   Can  be  specified  multiple times.  Works only with
288              --rebuild.
289
290       --forcearch=ARCH
291              Pass --forcearch to DNF. This will enable  to  install  packages
292              for  different  architecture. Works only for DNF and you have to
293              have package qemu-user-static installed.
294
295       --cache-alterations
296              Rebuild the root cache after making alterations  to  the  chroot
297              (i.e.  --install).  This  option is useful only when using tmpfs
298              plugin.
299
300       --cleanup-after
301              Clean chroot after building. Use with --resultdir.  Only  active
302              for '--rebuild'.
303
304       --configdir=CONFIGDIR
305              Change directory where config files are found
306
307       --config-opts=KEY=VALUE
308              Override  configuration option. Can be used multiple times. When
309              used multiple times for the same key, it will create  an  array.
310              This  is evaluated first (after parsing configs) so any special‐
311              ized command line option can override values defined in this op‐
312              tion.
313
314       --continue
315              If a pkg fails to build, continue to the next one, default is to
316              stop.
317
318              Works only with --chain.
319
320       --cwd=DIR
321              Change to the specified directory (relative to the  chroot)  be‐
322              fore running command when using --chroot or --shell.
323
324       -D "MACRO EXPR", --define="MACRO EXPR"
325              Specify  macro  definitions used for the build.  This option may
326              be used multiple times, just as the rpmbuild --define option can
327              be.  For example:
328
329              --define "with_extra_cheese 1" --define="packager Monkey"
330
331       --disable-plugin=PLUGIN
332              Disable  the specified plugin.  This option may be used multiple
333              times.
334
335       --disablerepo=REPO
336              Pass --disablerepo option to package manager to disable a repos‐
337              itory.  It can be specified multiple times.
338
339       --dnf  Use DNF as the current package manager. You should have DNF (and
340              dnf-plugins-core) installed on your system. This is the default.
341
342       --enable-plugin=PLUGIN
343              Enable the specified plugin.  This option may be  used  multiple
344              times.
345
346       --enablerepo=REPO
347              Pass  --enablerepo option to package manager to enable a reposi‐
348              tory.  It can be specified multiple times.
349
350       --enable-network
351              Enable networking. If you want to have reproducible builds  then
352              your builds should run without a network.  This option overrides
353              config_opts['rpmbuild_networking'] and config_opts['use_host_re‐
354              solv'], setting both True.
355
356       --isolation={auto|nspawn|simple}
357              What  should be used for isolation of chroot.  The simple method
358              uses  chroot()  call.   The  nspawn   method  utilizes  systemd-
359              nspawn(1)  and  runs  the  commands  inside container.  The auto
360              tries to use nspawn, and falls back to simple  if  system-nspawn
361              can not be used (e.g. if mock is run in container).  The default
362              is auto.
363
364       --localrepo=REPO
365              Set the path to put the results/repo in (works only  in  --chain
366              mode).  Will make a tempdir if not set.
367
368       -c     If  package  fails,  continue  to  the  next  one (works only in
369              --chain mode).
370
371       -h, --help
372              Show usage information and exit.
373
374       --macro-file=FILE
375              Use pre-defined rpm macro  file.  Macros  passed  to  '--define'
376              override macros of the same name from FILE.
377
378       --new-chroot
379              Deprecated. Use --isolation=nspawn.
380
381       -n, --no-clean
382              Do not clean chroot before building a package.
383
384       --nocheck
385              Pass --nocheck to rpmbuild to skip 'make check' tests.
386
387       -N, --no-cleanup-after
388              Don't  clean  chroot after building. If automatic cleanup is en‐
389              abled, use this to disable.
390
391       --offline
392              Run in an 'offline' mode where we tell 'yum' to  run  completely
393              from  the  local cache. Also, disables cache expiry for the mock
394              yum cache.
395
396       --old-chroot
397              Deprecated. Use --isolation=simple.
398
399       --plugin-option PLUGIN:KEY=VALUE
400              Set plugin specific parameter. This option may be used  multiple
401              times.  Examples:
402
403              --plugin-option=root_cache:age_check=False
404
405              --plugin-option=mount:dirs=("/dev/device",   "/mount/path/in/ch‐
406              root/", "vfstype", "mount_options")
407
408       --postinstall
409              Try to install built packages in the same buildroot right  after
410              the build.
411
412       -q, --quiet
413              Be quiet.
414
415       --recurse
416              Build  all  pkgs,  record  the  failures and try to rebuild them
417              again and again until everything gets built (or until the set of
418              pkgs failing to build are the same over) sets --continue.  Works
419              only with --chain.
420
421       -r CONFIG, --root=CONFIG
422              Uses  specified  chroot  configuration  as  defined  in  ~/.con‐
423              fig/mock/<CONFIG>.cfg  or /etc/mock/<CONFIG>.cfg.  Optionally if
424              CONFIG ends in '.cfg', it is interpreted as full path to  config
425              file.  If  none  specified,  uses the chroot config linked to by
426              /etc/mock/default.cfg.
427
428       --resultdir=RESULTDIR
429              Change directory where resulting files (RPMs and build logs) are
430              written.  Resultdir  can contain python-string substitutions for
431              any variable in the chroot config. For example:
432
433              --resultdir=./my/"{{dist}}"/"{{target_arch}}"/
434
435              This option enables automatic cleanup, this can  be  changed  in
436              config  file (by cleanup_on_success, cleanup_on_failure configu‐
437              ration    options)    or    overridden    by    --no-cleanup-af‐
438              ter/--cleanup-after arguments.
439
440              Note  that  this option does not have an effect for --chain com‐
441              mand. You can use --localrepo instead.
442
443       --rootdir=ROOTDIR
444              The path for where the chroot should be built. By default it  is
445              created in /var/lib/mock/<CONFIG>/root/.
446
447       --rpmbuild-opts=OPTIONS
448              Pass  additional  options to rpmbuild. To pass more options, put
449              them in quotes.
450
451       --rpmbuild_timeout=SECONDS
452              Fail build if rpmbuild takes longer than 'timeout' seconds
453
454       --scm-option=OPTIONS
455              define an SCM option (may be used more than once).
456
457       --short-circuit=STAGE
458              Use rpmbuild's short-circuit mechanism to skip already  executed
459              stages  of  the build.  It doesn't produce RPMs, and it's useful
460              only for debugging packaging. Implies --no-clean.  STAGE  speci‐
461              fies  which stage will be executed as the first.  Available val‐
462              ues: prep, build, install, binary.
463
464       --symlink-dereference
465              Follow symlinks in sources (used only with --buildsrpm).
466
467       --target=ARCH
468              This argument is passed to rpmbuild to specify the  target  arch
469              to  build.  It  defaults to whatever is specified for --arch, or
470              whatever is specified in the config  file  as  config_opts['tar‐
471              get_arch'].
472
473       --tmp_prefix=PREFIX
474              Tmp dir prefix - will default to username-pid if not specified.
475
476       --trace
477              Enables verbose tracing of function enter/exit with function ar‐
478              guments and return codes. Useful for debugging mock itself.
479
480       --uniqueext=text
481              Arbitrary, unique extension to append to chroot directory name
482
483       --unpriv
484              Drop privileges before running command when using --chroot
485
486       -v, --verbose
487              Output verbose progress information.
488
489       --version
490              Show version number and exit.
491
492       --with=OPTION
493              Enable configure OPTION for the build.  This option may be  used
494              multiple times.  For example:
495
496              --with=extra_cheese
497
498       --without=OPTION
499              Disable configure OPTION for the build.  This option may be used
500              multiple times.  For example:
501
502              --without=anchovies
503
504       --yum  Use yum as the current package manager.
505
506
507       --bootstrap-chroot
508              build in two stages, using chroot rpm for creating the build ch‐
509              root
510
511       --no-bootstrap-chroot
512              build in a single stage, using system rpm for creating the build
513              chroot
514
515
516       --use-bootstrap-image
517              Instead of creating a bootstrap chroot from scrath,  use  podman
518              image  specified  in config_opts['bootstrap_image'], extract it,
519              and use it as a cache for the bootstrap chroot.  This is  useful
520              when  host rpm version is not compatible with the target system,
521              or when using mock on non-RPM distributions.  This option  turns
522              --bootstrap-chroot on.
523
524
525       --no-bootstrap-image
526              don't create bootstrap chroot from container image
527
528

FILES

530       /etc/mock/ - default configuration directory
531
532       /var/lib/mock  -  directory  where chroots and results are created. You
533       should not put there your input files.
534

EXAMPLES

536       To rebuild test.src.rpm using the Fedora 14 configuration for x86_64
537
538            mock -r fedora-14-x86_64 --rebuild /path/to/test.src.rpm
539
540       Note that the available configurations are found in the  /etc/mock  di‐
541       rectory  with  the  extension  .cfg. To specify a configuration use the
542       filename without the trailing .cfg extension.
543
544       To place the output RPMs and logs in a specified location.
545
546            mock       -r       fedora-14-i386        --resultdir=./my-results
547            /path/to/your.src.rpm
548
549       To  build  a  package  from  the  default  SCM repository configured in
550       site-defaults.cfg use the following arguments.
551
552            mock -r fedora-14-i386 --scm-enable --scm-option package=pkg
553
554       To execute a command inside of chroot.
555
556            mock -r fedora-21-x86_64 --chroot -- rpm --eval %dist
557
558            mock -r fedora-21-x86_64 --chroot 'rpm --eval %dist'
559
560       To build rawhide package using yum:
561
562            mock -r fedora-rawhide-x86_64 --yum --rebuild your.src.rpm
563
564       Query rpm database inside chroot using Yum:
565
566            mock -r fedora-rawhide-x86_64 --yum-cmd whatprovides foo
567
568       List package manager history using package manager which is  configured
569       in chroot config (can be either DNF or YUM):
570
571            mock -r fedora-rawhide-x86_64 --pm-cmd history list
572
573

BUGS

575       To report bugs in mock, go to:
576
577            https://apps.fedoraproject.org/packages/mock/.
578
579       Select  the Bugs tab. If there is a bug similar to the one you are see‐
580       ing, add your information to the comments. If not, press Open A New Bug
581       and fill in the form.
582

AUTHORS

584       Michael Brown <mebrown@michaels-house.net>
585
586       Clark Williams <williams@redhat.com>
587
588       Seth Vidal
589
590       and a cast of...tens
591

SEE ALSO

593       rpmbuild(8),      yum(8),      dnf(8),     https://rpm-software-manage
594       ment.github.io/mock/
595
596
597
598Seth                                2.15"                              mock(1)
Impressum