summaryrefslogtreecommitdiffstats
path: root/py
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 /py
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>
Diffstat (limited to 'py')
-rwxr-xr-xpy/mock.py14
1 files changed, 14 insertions, 0 deletions
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: