diff options
-rw-r--r-- | docs/mock.1 | 5 | ||||
-rwxr-xr-x | py/mock.py | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/mock.1 b/docs/mock.1 index 3adc047..ca212b5 100644 --- a/docs/mock.1 +++ b/docs/mock.1 @@ -56,6 +56,11 @@ Dont clean chroot after building. If automatic cleanup is enabled, use this to d \fB\-\-arch=\fR\fIARCH\fP Specify target build arch. .TP +\fB\-\-define=\fR"\fINAME VALUE\fP" +Specify macro definitions used for the build. This option may be used multiple times, just as the rpmbuild \-\-define option can be. For example: + +\fB\-\-define="vendor Not Fedora" \-\-define="packager Some guy"\fR +.TP \fB\-\-resultdir=\fR\fIRESULTDIR\fP 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: @@ -103,6 +103,9 @@ def command_parse(config_opts): " cleanup is enabled, use this to disable.", ) parser.add_option("--arch", action ="store", dest="arch", default=None, help="target build arch") + parser.add_option("--define", action="append", dest="rpmmacros", + default=[], type="string", metavar="'NAME VALUE'", + help="define an rpm macro (may be used more than once)") parser.add_option("--resultdir", action="store", type="string", default=None, help="path for resulting files to be put") parser.add_option("--uniqueext", action="store", type="string", @@ -221,6 +224,17 @@ def set_config_opts_per_cmdline(config_opts, options, args): if not options.clean: config_opts['clean'] = options.clean + for macro in options.rpmmacros: + try: + k, v = macro.split(" ", 1) + if not k.startswith('%'): + k = '%%%s' % k + config_opts['macros'].update({k: v}) + except: + raise mock.exception.BadCmdline( + "Bad option for '--define' (%s). Use --define 'name value'" + % macro) + if options.resultdir: config_opts['resultdir'] = os.path.expanduser(options.resultdir) if options.uniqueext: |