Difference between revisions of "Mock-urpm"

From Rosalab Wiki
Jump to: navigation, search
(add categ)
Line 1: Line 1:
 
'''Mock''' is a program that builds packages inside a chroot, originally by Fedora Project.  The chroot contents are defined by a set of config files.
 
'''Mock''' is a program that builds packages inside a chroot, originally by Fedora Project.  The chroot contents are defined by a set of config files.
  
To install, run "urpmi mock-urpm"; this will set up proper users, so you can instantly fire
+
This package can be found in Rosa repositories. The newest version - in my private repository [http://abf.rosalinux.ru/downloads/akirilenko_personal/repository/rosa2012lts/x86_64/main/release/ x86_64] or [http://abf.rosalinux.ru/downloads/akirilenko_personal/repository/rosa2012lts/i586/main/release/ i586].
sudo mock-urpm /path/to/src/rpm --enable tmpfs
+
  
See logs in /var/lib/mock-urpm/{rootname}/results.
+
To install, run "sudo urpmi mock-urpm"; this will set up proper users, so you can instantly fire
 +
 
 +
sudo mock-urpm /path/to/src.rpm --enable tmpfs
 +
 
 +
 
 +
See logs and results in /var/lib/mock-urpm/{rootname}/results.
  
 
Read more at "man mock-urpm".  The tool originates from Fedora, see an [http://fedoraproject.org/wiki/Using_Mock_to_test_package_builds article about mock] there.
 
Read more at "man mock-urpm".  The tool originates from Fedora, see an [http://fedoraproject.org/wiki/Using_Mock_to_test_package_builds article about mock] there.
  
''This page is under constructionIts Russian version is more detailed, though.''.
+
 
 +
===Description===
 +
Mock-urpm  is  a  simple  program  that will build source RPMs inside a chroot. It doesn't do anything terribly fancy other than populate a chroot with the contents
 +
specified by a configuration file, then build any input SRPM(s) in that chroot.
 +
 
 +
The content of a chroot is specified by the configuration specified with the -r option. The default configuration file is /etc/mock-urpm/default.cfg, which is usu‐
 +
ally a symlink to one of the installed configurations.
 +
 
 +
There  is  a site-wide configuration file, /etc/mock-urpm/site-defaults.cfg, which can be used to specify site-wide options. The shipped version of this file has no
 +
active options, but does have a list of all of the configuration options, examples of how to set them, and their default values.
 +
 
 +
To use mock-urpm, a user should become a member of the mock-urpm group by adding their username to the mock-urpm line in /etc/group. This can be done with the  fol‐
 +
lowing command:
 +
 
 +
sudo /usr/sbin/usermod -a -G mock-urpm $USER
 +
 
 +
This command is executed automatically after the packet installation.  Note that mock is not intended to be run
 +
directly as root.
 +
 
 +
 
 +
===SCM===
 +
Using SCM (GIT/CVS/SVN) is really easy. Edit config files (there are examples with comments in site-defaults.cfg). Write the correct 'method' option ('git',
 +
 
 +
mock-urpm --scm-enable --scm-option package=PKG_NAME --scm-option branch=BRANCH_NAME SCM
 +
 
 +
must have a .spec file. Sources can be placed in tarball, but  putting '.write_tar' file to the project root will make mock-urpm to create NAME-VERSION.tar.gz archive.
 +
 
 +
 
 +
===Commands===
 +
 
 +
{| border="1"
 +
|+ align="bottom" style="font-size: 10px; font-weight: bold;" | mock-urpm commands
 +
! style="background:#efefef;" | Command
 +
! style="background:#efefef;" | Description
 +
|-
 +
| --clean || Purge the chroot tree.
 +
|-
 +
| --scrub=TYPE || Completely remove the specified chroot or cache dir or all of the chroot and cache.  TYPE is one of all, chroot, cache, root-cache or c-cache.
 +
|-
 +
| --init || Initialize a chroot (clean, install chroot packages, etc.)
 +
|-
 +
| --rebuild || If no command is specified, rebuild is assumed. Rebuilds the specified SRPM(s). The buildroot is cleaned first, unless --no-clean is specified.
 +
|-
 +
| --buildsrpm || Builds the specified SRPM either from a spec file and source file/directory or from SCM. The buildroot is cleaned first, unless --no-clean is specified.
 +
|-
 +
| --shell || Run the specified command interactively within the chroot (which must already be initialized -- no 'clean' is performed). If no command specified, /bin/sh is run.
 +
|-
 +
| --chroot || Run the specified command non-interactively within the chroot (which must already be initialized -- no 'clean' is performed). Command output will be sent  to the log files.
 +
|-
 +
| --installdeps || Find out deps for SRPM or RPM, and do a urpmi install to put them in the buildroot. Buildroot must already be initialized -- no 'clean' is performed
 +
|-
 +
| --install || Do a urpmi install PACKAGE inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
 +
|-
 +
| --update || Do a urpmi update inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
 +
|-
 +
| --orphanskill || No-op mode that simply checks that no stray processes are running in the chroot. Kills any processes that it finds using specified root.
 +
|-
 +
| --copyin || Copies the source paths (files or directory trees) into the chroot at the specified destination path.
 +
|-
 +
| --copyout || Copies the source paths (files or directory trees) from the chroot to the specified destination path.
 +
|- --scm-enable || Enable  building  from  an  SCM  (CVS/Git/SVN). The SCM repository must be configured in site-defaults.cfg before SCM checkouts are possible. SCM package and branch can be defined with --scm-option arguments, see site-defaults.cfg for more information.
 +
|}
 +
 
 +
===Options===
 +
{| border="1"
 +
|+ align="bottom" style="font-size: 10px; font-weight: bold;" | mock-urpm options
 +
! style="background:#efefef;" | Option
 +
! style="background:#efefef;" | Description
 +
|-
 +
| -r CHROOT, --root=CHROOT || Uses specified chroot configuration as defined in /etc/mock/<chroot>.cfg. If none specified, uses the chroot linked to by /etc/mock/default.cfg
 +
|-
 +
| --no-clean || Do not clean chroot before building package.
 +
|-
 +
| --cleanup-after || Clean chroot after building. Use with --resultdir. Only active for '--rebuild'.
 +
|-
 +
| --no-cleanup-after || Don't clean chroot after building. If automatic cleanup is enabled, use this to disable.
 +
|-
 +
| --target=ARCH || This argument is passed to rpmbuild to specify the target arch to build. It defaults to whatever is specified for --arch, or whatever  is  specified  in  the config file as config_opts['target_arch'].
 +
|-
 +
| --arch=ARCH || Calls the linux personality() syscall to tell the kernel to emulate a secondary architecture. For example, building i386 packages on an x86_64 buildhost.
 +
|-
 +
| -D "MACRO EXPR", --define="MACRO EXPR" || Specify macro definitions used for the build.  This option may be used multiple times, just as the rpmbuild --define option can be.  For example: --define "with_extra_cheese 1" --define="packager Monkey"
 +
|-
 +
| --with=OPTION || Enable configure OPTION for build.  This option may be used multiple times.  For example: --with=extra_cheese
 +
|-
 +
| --without=OPTION || Disable configure OPTION for build.  This option may be used multiple times.  For example: --without=anchovies
 +
|-
 +
| --resultdir=RESULTDIR || Change  directory  where  resulting files (RPMs and build logs) are written. Resultdir can contain python-string substitutions for any variable in the chroot config. For example: --resultdir=./my/"%(dist)s"/"%(target_arch)s"/
 +
|-
 +
| --uniqueext=text || Arbitrary, unique extension to append to buildroot directory name
 +
|-
 +
| --configdir=CONFIGDIR || Change directory where config files are found
 +
|-
 +
| --rpmbuild_timeout=SECONDS || Fail build if rpmbuild takes longer than 'timeout' seconds
 +
|-
 +
| --unpriv || Drop privileges before running command when using --chroot
 +
|-
 +
| --cwd=DIR || Change to the specified directory (relative to the chroot) before running command when using --chroot
 +
|-
 +
| -q, --quiet || Be quiet.
 +
|-
 +
| -v, --verbose || Output verbose progress information.
 +
|-
 +
| --trace || Enables verbose tracing of function enter/exit with function arguments and return codes. Useful for debugging mock itself.
 +
|-
 +
| --enable-plugin=PLUGIN || Enable the specified plugin.  This option may be used multiple times.
 +
|-
 +
| --disable-plugin=PLUGIN || Disable the specified plugin.  This option may be used multiple times.
 +
|-
 +
| -h, --help || Show usage information and exit.
 +
|-
 +
| --version || Show version number and exit.
 +
|}
 +
 
 +
 
 +
=== Examples ===
 +
To rebuild test.src.rpm using the configuration for x86_64 named "my_configuration"
 +
 +
mock -r my_configuration-x86_64 --rebuild /path/to/test.src.rpm
 +
 
 +
Note that the available configurations are found in the /etc/mock-urpm directory with the extension .cfg. To specify a configuration use the  filename  without  the
 +
trailing .cfg extension.
 +
 
 +
To place the output RPMs and logs in a specified location.
 +
 
 +
mock --resultdir=./my-results /path/to/your.src.rpm
 +
 
 +
To build a package from the default SCM repository configured in site-defaults.cfg or in user config use the following arguments.
 +
 
 +
mock --scm-enable --scm-option package=pkg
 +
 
  
 
[[ru:Mock-urpm]]
 
[[ru:Mock-urpm]]
 
[[Category:ROSA Developer Tools]]
 
[[Category:ROSA Developer Tools]]

Revision as of 14:45, 23 May 2012

Mock is a program that builds packages inside a chroot, originally by Fedora Project. The chroot contents are defined by a set of config files.

This package can be found in Rosa repositories. The newest version - in my private repository x86_64 or i586.

To install, run "sudo urpmi mock-urpm"; this will set up proper users, so you can instantly fire

sudo mock-urpm /path/to/src.rpm --enable tmpfs


See logs and results in /var/lib/mock-urpm/{rootname}/results.

Read more at "man mock-urpm". The tool originates from Fedora, see an article about mock there.


Description

Mock-urpm is a simple program that will build source RPMs inside a chroot. It doesn't do anything terribly fancy other than populate a chroot with the contents specified by a configuration file, then build any input SRPM(s) in that chroot.

The content of a chroot is specified by the configuration specified with the -r option. The default configuration file is /etc/mock-urpm/default.cfg, which is usu‐ ally a symlink to one of the installed configurations.

There is a site-wide configuration file, /etc/mock-urpm/site-defaults.cfg, which can be used to specify site-wide options. The shipped version of this file has no active options, but does have a list of all of the configuration options, examples of how to set them, and their default values.

To use mock-urpm, a user should become a member of the mock-urpm group by adding their username to the mock-urpm line in /etc/group. This can be done with the fol‐ lowing command:

sudo /usr/sbin/usermod -a -G mock-urpm $USER 

This command is executed automatically after the packet installation. Note that mock is not intended to be run directly as root.


SCM

Using SCM (GIT/CVS/SVN) is really easy. Edit config files (there are examples with comments in site-defaults.cfg). Write the correct 'method' option ('git',

mock-urpm --scm-enable --scm-option package=PKG_NAME --scm-option branch=BRANCH_NAME SCM 

must have a .spec file. Sources can be placed in tarball, but putting '.write_tar' file to the project root will make mock-urpm to create NAME-VERSION.tar.gz archive.


Commands

mock-urpm commands
Command Description
--clean Purge the chroot tree.
--scrub=TYPE Completely remove the specified chroot or cache dir or all of the chroot and cache. TYPE is one of all, chroot, cache, root-cache or c-cache.
--init Initialize a chroot (clean, install chroot packages, etc.)
--rebuild If no command is specified, rebuild is assumed. Rebuilds the specified SRPM(s). The buildroot is cleaned first, unless --no-clean is specified.
--buildsrpm Builds the specified SRPM either from a spec file and source file/directory or from SCM. The buildroot is cleaned first, unless --no-clean is specified.
--shell Run the specified command interactively within the chroot (which must already be initialized -- no 'clean' is performed). If no command specified, /bin/sh is run.
--chroot Run the specified command non-interactively within the chroot (which must already be initialized -- no 'clean' is performed). Command output will be sent to the log files.
--installdeps Find out deps for SRPM or RPM, and do a urpmi install to put them in the buildroot. Buildroot must already be initialized -- no 'clean' is performed
--install Do a urpmi install PACKAGE inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
--update Do a urpmi update inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
--orphanskill No-op mode that simply checks that no stray processes are running in the chroot. Kills any processes that it finds using specified root.
--copyin Copies the source paths (files or directory trees) into the chroot at the specified destination path.
--copyout Copies the source paths (files or directory trees) from the chroot to the specified destination path.

Options

mock-urpm options
Option Description
-r CHROOT, --root=CHROOT Uses specified chroot configuration as defined in /etc/mock/<chroot>.cfg. If none specified, uses the chroot linked to by /etc/mock/default.cfg
--no-clean Do not clean chroot before building package.
--cleanup-after Clean chroot after building. Use with --resultdir. Only active for '--rebuild'.
--no-cleanup-after Don't clean chroot after building. If automatic cleanup is enabled, use this to disable.
--target=ARCH This argument is passed to rpmbuild to specify the target arch to build. It defaults to whatever is specified for --arch, or whatever is specified in the config file as config_opts['target_arch'].
--arch=ARCH Calls the linux personality() syscall to tell the kernel to emulate a secondary architecture. For example, building i386 packages on an x86_64 buildhost.
-D "MACRO EXPR", --define="MACRO EXPR" Specify macro definitions used for the build. This option may be used multiple times, just as the rpmbuild --define option can be. For example: --define "with_extra_cheese 1" --define="packager Monkey"
--with=OPTION Enable configure OPTION for build. This option may be used multiple times. For example: --with=extra_cheese
--without=OPTION Disable configure OPTION for build. This option may be used multiple times. For example: --without=anchovies
--resultdir=RESULTDIR Change directory where resulting files (RPMs and build logs) are written. Resultdir can contain python-string substitutions for any variable in the chroot config. For example: --resultdir=./my/"%(dist)s"/"%(target_arch)s"/
--uniqueext=text Arbitrary, unique extension to append to buildroot directory name
--configdir=CONFIGDIR Change directory where config files are found
--rpmbuild_timeout=SECONDS Fail build if rpmbuild takes longer than 'timeout' seconds
--unpriv Drop privileges before running command when using --chroot
--cwd=DIR Change to the specified directory (relative to the chroot) before running command when using --chroot
-q, --quiet Be quiet.
-v, --verbose Output verbose progress information.
--trace Enables verbose tracing of function enter/exit with function arguments and return codes. Useful for debugging mock itself.
--enable-plugin=PLUGIN Enable the specified plugin. This option may be used multiple times.
--disable-plugin=PLUGIN Disable the specified plugin. This option may be used multiple times.
-h, --help Show usage information and exit.
--version Show version number and exit.


Examples

To rebuild test.src.rpm using the configuration for x86_64 named "my_configuration"

mock -r my_configuration-x86_64 --rebuild /path/to/test.src.rpm

Note that the available configurations are found in the /etc/mock-urpm directory with the extension .cfg. To specify a configuration use the filename without the trailing .cfg extension.

To place the output RPMs and logs in a specified location.

mock --resultdir=./my-results /path/to/your.src.rpm

To build a package from the default SCM repository configured in site-defaults.cfg or in user config use the following arguments.

mock --scm-enable --scm-option package=pkg