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

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

OPTIONS

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

FILES

520       /etc/mock/ - default configuration directory
521
522       /var/lib/mock  -  directory  where chroots and results are created. You
523       should not put there your input files.
524

EXAMPLES

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

BUGS

565       To report bugs in mock, go to:
566
567            https://apps.fedoraproject.org/packages/mock/.
568
569       Select  the Bugs tab. If there is a bug similar to the one you are see‐
570       ing, add your information to the comments. If not, press Open A New Bug
571       and fill in the form.
572

AUTHORS

574       Michael Brown <mebrown@michaels-house.net>
575
576       Clark Williams <williams@redhat.com>
577
578       Seth Vidal
579
580       and a cast of...tens
581

SEE ALSO

583       rpmbuild(8),  yum(8),  dnf(8),  https://github.com/rpm-software-manage
584       ment/mock/wiki
585
586
587
588Seth                                 2.9"                              mock(1)
Impressum