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       --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

OPTIONS

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

FILES

539       /etc/mock/ - default configuration directory
540
541       /var/lib/mock  -  directory  where chroots and results are created. You
542       should not put there your input files.
543

EXAMPLES

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

BUGS

584       To report an issue with Mock, go to:
585
586            https://github.com/rpm-software-management/mock/issues
587
588       Search  through the list of existing issues.  If there is a similar is‐
589       sue to the one you are seeing, add your information  in  new  comments.
590       If not, press New issue and fill in the form.
591

AUTHORS

593       Michael Brown <mebrown@michaels-house.net>
594
595       Clark Williams <williams@redhat.com>
596
597       Seth Vidal
598
599       and a cast of...tens
600

SEE ALSO

602       rpmbuild(8),      yum(8),      dnf(8),     https://rpm-software-manage
603       ment.github.io/mock/
604
605
606
607Seth                                 5.3"                              mock(1)
Impressum