From Fedora Project Wiki

< Projects‎ | Mock

(Created page with "== Scm Plugin == This plugin provides integration to Scm systems (Git, Svn...). This module does not use Plugin infrastructure of Mock, but is is provides as standalone pack...")
 
No edit summary
Line 25: Line 25:
While you can specify this in configuration file, this is less flexible and you may rather use command line options. E.g. <code>config_opts['scm_opts']['method'] = 'git'</code> is the same as <code>--scm-option method=git</code> or <code>config_opts['scm_opts']['branch'] = 'master'</code> is the same as <code>--scm-option branch=master</code>.
While you can specify this in configuration file, this is less flexible and you may rather use command line options. E.g. <code>config_opts['scm_opts']['method'] = 'git'</code> is the same as <code>--scm-option method=git</code> or <code>config_opts['scm_opts']['branch'] = 'master'</code> is the same as <code>--scm-option branch=master</code>.


== Tar file ==
When either <code>write_tar</code> is set to True or /var/lib/mock/<chroot>/root/builddir/build/SOURCES/ contains <code>.write_tar</code>. Mock will create tar file from whole. This is what you probably want to. Otherwise you have to manually create the tar file and put it there yourself before you run mock command.
Extension and compression method is chosen automatically according your Source line in spec file. Therefore if there is:
    Source: http://foo.com/%{name}-%{version}.tar.xz
then mock will create tar file with .tar.xz extension and compressed by xz. Similarly if you choose .tar.gz or .tar.bz2 or any other known extension.
== Example ==
== Example ==
In this example, mock will clone <code>master</code> branch of <code>github.com/xsuchy/rpmconf.git</code> and use <code>./rpmconf.spec</code> in that directory to build rpm package:
    mock -r fedora-22-x86_64 --scm-enable --scm-option method=git --scm-option package=rpmconf --scm-option git_get=set --scm-option spec=rpmconf.spec \
      --scm-option branch=master --scm-option write_tar=True --scm-option git_get='git clone https://github.com/xsuchy/rpmconf.git'

Revision as of 14:54, 1 July 2015

Scm Plugin

This plugin provides integration to Scm systems (Git, Svn...).

This module does not use Plugin infrastructure of Mock, but is is provides as standalone package mock-scm so we dare to call it plugin.

Configuration

In your config file insert the following lines:


   config_opts['scm'] = True
   config_opts['scm_opts']['method'] = 'git'
   config_opts['scm_opts']['cvs_get'] = 'cvs -d /srv/cvs co SCM_BRN SCM_PKG'
   config_opts['scm_opts']['git_get'] = 'git clone SCM_BRN git://localhost/SCM_PKG.git SCM_PKG'
   config_opts['scm_opts']['svn_get'] = 'svn co file:///srv/svn/SCM_PKG/SCM_BRN SCM_PKG'
   config_opts['scm_opts']['spec'] = 'SCM_PKG.spec'
   config_opts['scm_opts']['ext_src_dir'] = '/dev/null'
   config_opts['scm_opts']['write_tar'] = True
   config_opts['scm_opts']['git_timestamps'] = True
   config_opts['scm_opts']['exclude_vcs'] = True
   config_opts['scm_opts']['package'] = 'mypkg'
   config_opts['scm_opts']['branch'] = 'master'

While you can specify this in configuration file, this is less flexible and you may rather use command line options. E.g. config_opts['scm_opts']['method'] = 'git' is the same as --scm-option method=git or config_opts['scm_opts']['branch'] = 'master' is the same as --scm-option branch=master.

Tar file

When either write_tar is set to True or /var/lib/mock/<chroot>/root/builddir/build/SOURCES/ contains .write_tar. Mock will create tar file from whole. This is what you probably want to. Otherwise you have to manually create the tar file and put it there yourself before you run mock command.

Extension and compression method is chosen automatically according your Source line in spec file. Therefore if there is:

   Source: http://foo.com/%{name}-%{version}.tar.xz

then mock will create tar file with .tar.xz extension and compressed by xz. Similarly if you choose .tar.gz or .tar.bz2 or any other known extension.

Example

In this example, mock will clone master branch of github.com/xsuchy/rpmconf.git and use ./rpmconf.spec in that directory to build rpm package:

   mock -r fedora-22-x86_64 --scm-enable --scm-option method=git --scm-option package=rpmconf --scm-option git_get=set --scm-option spec=rpmconf.spec \
      --scm-option branch=master --scm-option write_tar=True --scm-option git_get='git clone https://github.com/xsuchy/rpmconf.git'