Mock-urpm
From Mandriva Community Wiki
Contents |
Overview
Mock-urpm is a modified version of mock taken from Fedora.
Mock is program that will build source and binary RPMs inside a chroot. The content of a chroot is specified by the configuration specified with the -r option.
Mock-urpm features
- build packages in chroot (mount all required directories, install the minimal system, install build-requires and build the package)
- create cache of the minimal chroot system. If cache is found when building a package, then this cache is reused (and preliminary updated using urpmi)
- during installation, automatically creates 'mock-urpm' group and adds the user from SUDO_USER to this group (if user exists). This user is then used by mock when it needs to drop its own privileges.
- provides plugin interface. Significant part of mock functionality is implemented using plugins (tmpfs, ccache, selinux, root-cache, bind-mount)
- uses tmpfs (can be enabled in config file (config_opts['plugin_conf']['tmpfs_enable'] = True) or by command line argument --enable tmpfs)
- has a selinux support plugin. I've turned it off for now, but it can be valuable
- can replace /etc/hosts in chroot by the given one
- can work with git/cvs/svn. Though I have not testet it at all.
- can copy files in/out the chroot, start shell inside the chroot. (warn: if the last run used tmpfs, chroot will be empty)
- bash-autocomplete is not well-researched by me now, but its standard version works sometimes :)
- if build process hangs, it can be terminated automatically by timeout
- many settings can be found in config files. Build configuration files are /etc/mock-urpm/*.cfg. While package installation the correct config for your system will tied to guess and linked into /etc/mock-urpm/default.cfg. If not - do it yourself. In addition, another config file can be specified with -r option.
Future plans
- urpmi works only with local system setting, you can only specify some of them by changing "urpmi_options" in config. Set of media and some other sings have to be added.
- add ability to execute urpmi with --urpmi-root (not --root) option.
- improve mock output information while installation packages in chroot (Installed packahes: # of #)
How to use
If package is installed using sudo (SUDO_USER env variable is not empty), then the user is configured well, you can run something like 'sudo mock-urpm /path/to/src/rpm --enable tmpfs'
Logs and RPM files can be found in /var/lib/mock-urpm/{rootname}/results
SCM intagration
Configure the scm options in site-defaults.cfg file.
Set config_opts['scm_opts']['method'] to 'git', 'svn' or 'cvs'. Set the correct config_opts['scm_opts']['*_get'] command for your SCM. 'SCM_BRN' and 'SCM_PKG' in commands will be replaced by the branch and package name.
Now you can call 'mock-urpm --scm-enable --scm-option package=PKG_NAME --scm-option branch=BRANCH_NAME' It will download files, create tar.gz if needed (if magic file .write_tar presents in the downloaded project root directory or if config_opts['scm_opts']['write_tar'] is set to True) and will build the package.
All the other information can be found in mock-urpm man pages.

