summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Zullinger <tmz@pobox.com>2007-12-03 20:58:03 -0500
committerMichael E Brown <michael_e_brown@dell.com>2007-12-04 17:28:01 -0600
commit3364f97752b54f0f507475934fe486a7c8c79a1d (patch)
tree02765557436b3ceb5893e6be76a4e1aa8653a222
parent38751f05060ef76e8777a21f3e5fe88f4baf7001 (diff)
downloadmock-3364f97752b54f0f507475934fe486a7c8c79a1d.tar.gz
mock-3364f97752b54f0f507475934fe486a7c8c79a1d.tar.xz
mock-3364f97752b54f0f507475934fe486a7c8c79a1d.zip
add --define option to pass rpm macros on the command line
Signed-off-by: Michael E Brown <michael_e_brown@dell.com>
-rw-r--r--docs/mock.15
-rwxr-xr-xpy/mock.py14
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:
diff --git a/py/mock.py b/py/mock.py
index e40f029..8f085b2 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -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: