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] --buildsrpm {--spec spec --sources src --symlink-deref‐
12       erence | --scm-enable}
13
14       mock  [options] --chroot <cmd>
15
16       mock  [options] {--init|clean|shell}
17
18       mock  [options] --installdeps {SRPM|RPM|SPEC}
19
20       mock  [options] -i, --install PACKAGE [PACKAGE...]
21
22       mock  [options] --update [PACKAGE...]
23
24       mock  [options] --remove PACKAGE [PACKAGE...]
25
26       mock  [options] --orphanskill
27
28       mock  [options] -p, --print-root-path
29
30       mock  [options] --copyin path [path...] destination
31
32       mock  [options] --copyout path [path...] destination
33
34       mock  [options] --scm-enable [--scm-option key=value ...]
35
36       mock  [options] -l, --list-snapshots
37
38       mock  [options] --snapshot [snapshot-name]
39
40       mock  [options] --rollback-to [snapshot-name]
41
42       mock  [options] --remove-snapshot [snapshot-name]
43
44       mock  [options] --umount
45
46       mock  [options] --pm-cmd [arguments ...]
47
48       mock  [options] --yum-cmd [arguments ...]
49
50       mock  [options] --dnf-cmd [arguments ...]
51
52
53

DESCRIPTION

55       Mock is a simple program that will build source RPMs inside  a  chroot.
56       It  doesn't  do  anything fancy other than populating a chroot with the
57       contents specified by  a  configuration  file,  then  build  any  input
58       SRPM(s) in that chroot.
59
60       The  content  of  a  chroot is specified by the configuration specified
61       with   the   -r   option.   The   default   configuration    file    is
62       /etc/mock/default.cfg,  which  is  usually  a  symlink  to  one  of the
63       installed configurations.
64
65       There is a site-wide configuration  file,  /etc/mock/site-defaults.cfg,
66       which  can be used to specify site-wide options. The shipped version of
67       this file has no active options, but does have a list  of  all  of  the
68       configuration  options  examples  of how to set them, and their default
69       values.
70
71       For backward compatibility,  old-style  commands,  ("rebuild",  "init",
72       "clean",  etc.) without leading '--' are still accepted, but are depre‐
73       cated. See COMMANDS section, below, for the  detailed  listing  of  all
74       commands.
75
76       To  use mock, a user should become a member of the mock group by adding
77       their username to the mock line in /etc/group. This can  be  done  with
78       the following command:
79
80               sudo /usr/sbin/usermod -a -G mock $USER
81
82       Note that mock is not intended to be run directly as root.
83
84       Warning:  Mock  is  running  some  parts of code under root privileges.
85       There are known ways how to get root access once  a  user  is  in  mock
86       group  (and  once  he  can  to  run mock). This is possible when a user
87       abuses the mock configuration options. Please do not add anyone who  is
88       not trustworthy to the mock group!
89
90
91

COMMANDS

93       --buildsrpm
94              Build  the  specified  SRPM  either  from a spec file and source
95              file/directory or SCM. The chroot (including the results  direc‐
96              tory) is cleaned first, unless --no-clean is specified.
97
98       --clean
99              Purge the chroot tree.
100
101       --copyin
102              Copies  the  source  paths  (files  or directory trees) into the
103              chroot at the specified destination path.
104
105       --copyout
106              Copies the source paths (files  or  directory  trees)  from  the
107              chroot to the specified destination path.
108
109       --chroot COMMAND [ARGS...]
110              Run  the  specified  command non-interactively within the chroot
111              (no 'clean' is performed). Command output will be  sent  to  the
112              log files. Note that COMMAND is shell expanded only if there are
113              no ARGS. Otherwise, there is no shell expansion.
114
115       --debug-config
116              Print all options in config_opts.
117
118       --dnf-cmd
119              Execute following arguments with DNF with installroot set to the
120              chroot  path.  DNF must be installed on the system.  It will use
121              the binary which is specified in 'dnf_command' option  in  site-
122              defaults.cfg  config,  which  by  default is /usr/bin/dnf.  This
123              option will enforce --dnf.
124
125       --init Initialize a chroot (clean, install chroot packages, etc.).
126
127       -i, --install
128              Do a yum install PACKAGE inside the chroot. No 'clean'  is  per‐
129              formed.
130
131       --installdeps
132              Find  out deps for SRPM or RPM, and do a yum install to put them
133              in the chroot. No 'clean' is performed
134
135       -l, --list-snapshots
136              List all existing snapshots of the chroot belonging to the  cur‐
137              rent  configuration.   Current  base  snapshot is marked with an
138              asterisk (*)
139
140       --mount
141              Mount all everything mounted in the chroot  path  including  the
142              root  itself  that might have been an LVM volume, TMPFS or over‐
143              layfs.
144
145       --orphanskill
146              No-op mode that simply checks that no stray processes  are  run‐
147              ning  in the chroot. Kills any processes that it finds using the
148              specified root.
149
150       --pm-cmd
151              Execute following arguments with  the  current  package  manager
152              with installroot set to the chroot path.
153
154       -p, --print-root-path
155              Prints a path to the currently used chroot directory.
156
157       --rebuild
158              If  no  command  is  specified,  rebuild is assumed. Rebuild the
159              specified SRPM(s). The chroot (including the results  directory)
160              is cleaned first, unless --no-clean is specified.
161
162       --remove
163              Do  a  yum  remove PACKAGE inside the chroot. No 'clean' is per‐
164              formed.
165
166       --remove-snapshot
167              Remove given snapshot freeing the space it occupied. This action
168              cannot  be undone.  This feature is available only when lvm_root
169              or overlayfs plugin is installed and enabled.
170
171       --rollback-to
172              Return chroot to the state in the specified snapshot and set  it
173              as the current base to which clean actions will return. It won't
174              delete nor modify the snapshot that was set as base  previously.
175              This  feature  is  available only when the lvm_root or overlayfs
176              plugin is installed and enabled.
177
178       --scm-enable
179              Enable building  from  an  SCM  (CVS/Git/SVN/DistGit).  The  SCM
180              repository  must  be  configured in site-defaults.cfg before SCM
181              checkouts are possible. SCM package and branch  can  be  defined
182              with  --scm-option  arguments,  see  site-defaults.cfg  for more
183              information.
184
185       --scrub=TYPE
186              Completely remove the specified chroot or cache dir  or  all  of
187              the  chroot  and  cache.   TYPE  is  one  of all, chroot, cache,
188              root-cache, c-cache, yum-cache or dnf-cache. In fact,  dnf-cache
189              is just alias for yum-cache, and both remove Dnf and Yum cache.
190
191       --shell [COMMAND [ARGS...]]
192              Run  the  specified  command interactively within the chroot (no
193              'clean' is performed). If no command specified, /bin/sh is  run.
194              Note  that  COMMAND is shell expanded using the shell in chroot.
195              Note that this command does not produce logs.
196
197       --sources=SOURCES
198              Specifies sources (either a single file or a directory of files)
199              to use to build an SRPM (used only with --buildsrpm).
200
201       --spec=SPEC
202              Specifies spec file to use to build an SRPM.
203
204       --update [PACKAGE...]
205              Do  a  package  update  inside  the  chroot. The package list is
206              optional, if omitted, all packages will be updated.  No  'clean'
207              is performed.
208
209       --snapshot
210              Make  a  snapshot of the current state of the chroot. That snap‐
211              shot will be set as  the  current  base  to  which  --clean  and
212              implicit  clean  happening  during  rebuild command will return.
213              This feature is available only when the  lvm_root  or  overlayfs
214              plugin is installed and enabled.
215
216       --umount
217              Umount  all  everything mounted in the chroot path including the
218              root itself that might have been an LVM volume, TMPFS or  overa‐
219              lyfs.
220
221       --yum-cmd
222              Execute following arguments with YUM with installroot set to the
223              chroot path. Yum must be installed on the system.  It  will  use
224              the  binary  which is specified in 'yum_command' option in site-
225              defaults.cfg config, which by  default  is  /usr/bin/yum.   Note
226              that in config files for Fedora 22+ this value is overwritten in
227              chroot  config  to  default  to  /usr/bin/yum-deprecated.   This
228              option will enforce --yum.
229
230       Note:  While  you can specify more commands on a command line, only one
231       can be executed. The last command will win.
232
233
234

OPTIONS

236       --arch=ARCH
237              Calls the Linux personality() syscall to tell the kernel to emu‐
238              late  a secondary architecture. For example, building i386 pack‐
239              ages on an x86_64 buildhost.
240
241       --forcearch=ARCH
242              Pass --forcearch to DNF. This will enable  to  install  packages
243              for  different  architecture. Works only for DNF and you have to
244              have package qemu-user-static installed.
245
246       --cache-alterations
247              Rebuild the root cache after making alterations  to  the  chroot
248              (i.e.  --install).  This  option is useful only when using tmpfs
249              plugin.
250
251       --cleanup-after
252              Clean chroot after building. Use with --resultdir.  Only  active
253              for '--rebuild'.
254
255       --configdir=CONFIGDIR
256              Change directory where config files are found
257
258       --config-opts=KEY=VALUE
259              Override  configuration option. Can be used multiple times. When
260              used multiple times for the same key, it will create  an  array.
261              This  is evaluated first (after parsing configs) so any special‐
262              ized command line option can override  values  defined  in  this
263              option.
264
265       --cwd=DIR
266              Change  to  the  specified  directory  (relative  to the chroot)
267              before running command when using --chroot
268
269       -D "MACRO EXPR", --define="MACRO EXPR"
270              Specify macro definitions used for the build.  This  option  may
271              be used multiple times, just as the rpmbuild --define option can
272              be.  For example:
273
274              --define "with_extra_cheese 1" --define="packager Monkey"
275
276       --disable-plugin=PLUGIN
277              Disable the specified plugin.  This option may be used  multiple
278              times.
279
280       --disablerepo=REPO
281              Pass --disablerepo option to package manager to disable a repos‐
282              itory.  It can be specified multiple times.
283
284       --dnf  Use DNF as the current package manager. You should have DNF (and
285              dnf-plugins-core) installed on your system.
286
287       --enable-plugin=PLUGIN
288              Enable  the  specified plugin.  This option may be used multiple
289              times.
290
291       --enablerepo=REPO
292              Pass --enablerepo option to package manager to enable a  reposi‐
293              tory.  It can be specified multiple times.
294
295       --enable-network
296              Enable  networking. If you want to have reproducible builds then
297              your builds should run without a network.  This option overrides
298              config_opts['rpmbuild_networking']            and           con‐
299              fig_opts['use_host_resolv'], setting both True.
300
301       -h, --help
302              Show usage information and exit.
303
304       --macro-file=FILE
305              Use pre-defined rpm macro  file.  Macros  passed  to  '--define'
306              override macros of the same name from FILE.
307
308       --new-chroot
309              Use new chroot (systemd-nspawn). This is the default.
310
311       -n, --no-clean
312              Do not clean chroot before building a package.
313
314       --nocheck
315              Pass --nocheck to rpmbuild to skip 'make check' tests.
316
317       -N, --no-cleanup-after
318              Don't  clean  chroot  after  building.  If  automatic cleanup is
319              enabled, use this to disable.
320
321       --offline
322              Run in an 'offline' mode where we tell 'yum' to  run  completely
323              from  the  local cache. Also, disables cache expiry for the mock
324              yum cache.
325
326       --old-chroot
327              use old chroot instead of systemd-nspawn.
328
329       --plugin-option PLUGIN:KEY=VALUE
330              Set plugin specific parameter. This option may be used  multiple
331              times.  Examples:
332
333              --plugin-option=root_cache:age_check=False
334
335              --plugin-option=mount:dirs=("/dev/device",
336              "/mount/path/in/chroot/", "vfstype", "mount_options")
337
338       --postinstall
339              Try to install built packages in the same buildroot right  after
340              the build.
341
342       -q, --quiet
343              Be quiet.
344
345       -r CONFIG, --root=CONFIG
346              Uses    specified    chroot    configuration   as   defined   in
347              /etc/mock/<CONFIG>.cfg. Optionally if CONFIG ends in '.cfg',  it
348              is  interpreted  as full path to config file. If none specified,
349              uses the chroot config linked to by /etc/mock/default.cfg.
350
351       --resultdir=RESULTDIR
352              Change directory where resulting files (RPMs and build logs) are
353              written.  Resultdir  can contain python-string substitutions for
354              any variable in the chroot config. For example:
355
356              --resultdir=./my/"%(dist)s"/"%(target_arch)s"/
357
358              This option enables automatic cleanup, this can  be  changed  in
359              config  file (by cleanup_on_success, cleanup_on_failure configu‐
360              ration         options)         or         overridden         by
361              --no-cleanup-after/--cleanup-after arguments.
362
363       --rootdir=ROOTDIR
364              The  path for where the chroot should be built. By default it is
365              created in /var/lib/mock/<CONFIG>/root/.
366
367       --rpmbuild-opts=OPTIONS
368              Pass additional options to rpmbuild. To pass more  options,  put
369              them in quotes.
370
371       --rpmbuild_timeout=SECONDS
372              Fail build if rpmbuild takes longer than 'timeout' seconds
373
374       --scm-option=OPTIONS
375              define an SCM option (may be used more than once).
376
377       --short-circuit=STAGE
378              Use  rpmbuild's short-circuit mechanism to skip already executed
379              stages of the build.  It doesn't produce RPMs, and  it's  useful
380              only  for  debugging packaging. Implies --no-clean. STAGE speci‐
381              fies which stage will be executed as the first.  Available  val‐
382              ues: prep, build, install, binary.
383
384       --symlink-dereference
385              Follow symlinks in sources (used only with --buildsrpm).
386
387       --target=ARCH
388              This  argument  is passed to rpmbuild to specify the target arch
389              to build. It defaults to whatever is specified  for  --arch,  or
390              whatever  is  specified  in the config file as config_opts['tar‐
391              get_arch'].
392
393       --trace
394              Enables verbose tracing of  function  enter/exit  with  function
395              arguments and return codes. Useful for debugging mock itself.
396
397       --uniqueext=text
398              Arbitrary, unique extension to append to chroot directory name
399
400       --unpriv
401              Drop privileges before running command when using --chroot
402
403       -v, --verbose
404              Output verbose progress information.
405
406       --version
407              Show version number and exit.
408
409       --with=OPTION
410              Enable  configure OPTION for the build.  This option may be used
411              multiple times.  For example:
412
413              --with=extra_cheese
414
415       --without=OPTION
416              Disable configure OPTION for the build.  This option may be used
417              multiple times.  For example:
418
419              --without=anchovies
420
421       --yum  Use yum as the current package manager. This is the default.
422
423
424       --bootstrap-chroot
425              build  in  two  stages,  using chroot rpm for creating the build
426              chroot
427
428       --no-bootstrap-chroot
429              build in a single stage, using system rpm for creating the build
430              chroot
431
432

FILES

434       /etc/mock/ - default configuration directory
435
436       /var/lib/mock  -  directory  where chroots and results are created. You
437       should not put there your input files.
438

EXAMPLES

440       To rebuild test.src.rpm using the Fedora 14 configuration for x86_64
441
442            mock -r fedora-14-x86_64 --rebuild /path/to/test.src.rpm
443
444       Note that the available  configurations  are  found  in  the  /etc/mock
445       directory  with  the extension .cfg. To specify a configuration use the
446       filename without the trailing .cfg extension.
447
448       To place the output RPMs and logs in a specified location.
449
450            mock       -r       fedora-14-i386        --resultdir=./my-results
451            /path/to/your.src.rpm
452
453       To  build  a  package  from  the  default  SCM repository configured in
454       site-defaults.cfg use the following arguments.
455
456            mock -r fedora-14-i386 --scm-enable --scm-option package=pkg
457
458       To execute a command inside of chroot.
459
460            mock -r fedora-21-x86_64 --chroot -- rpm --eval %dist
461
462            mock -r fedora-21-x86_64 --chroot 'rpm --eval %dist'
463
464       To build rawhide package using yum:
465
466            mock -r fedora-rawhide-x86_64 --yum --rebuild your.src.rpm
467
468       Query rpm database inside chroot using Yum:
469
470            mock -r fedora-rawhide-x86_64 --yum-cmd whatprovides foo
471
472       List package manager history using package manager which is  configured
473       in chroot config (can be either DNF or YUM):
474
475            mock -r fedora-rawhide-x86_64 --pm-cmd history list
476
477

BUGS

479       To report bugs in mock, go to:
480
481            https://apps.fedoraproject.org/packages/mock/.
482
483       Select  the Bugs tab. If there is a bug similar to the one you are see‐
484       ing, add your information to the comments. If not, press Open A New Bug
485       and fill in the form.
486

AUTHORS

488       Michael Brown <mebrown@michaels-house.net>
489
490       Clark Williams <williams@redhat.com>
491
492       Seth Vidal
493
494       and a cast of...tens
495

SEE ALSO

497       mockchain(1), rpmbuild(8), yum(8), dnf(8), https://github.com/rpm-soft
498       ware-management/mock/wiki
499
500
501
502Seth                               1.4.16"                             mock(1)
Impressum