From 38751f05060ef76e8777a21f3e5fe88f4baf7001 Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Tue, 4 Dec 2007 17:00:26 -0600 Subject: error when trying to build multiple srpms without --resultdir. --- py/mock.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'py') diff --git a/py/mock.py b/py/mock.py index cb558e0..e40f029 100755 --- a/py/mock.py +++ b/py/mock.py @@ -213,7 +213,7 @@ def setup_default_config_opts(config_opts): } decorate(traceLog(log)) -def set_config_opts_per_cmdline(config_opts, options): +def set_config_opts_per_cmdline(config_opts, options, args): "takes processed cmdline args and sets config options." # do some other options and stuff if options.arch: @@ -245,6 +245,10 @@ def set_config_opts_per_cmdline(config_opts, options): raise mock.exception.BadCmdline( "Must specify --resultdir when using --cleanup-after") + if len(args) > 1 and not options.resultdir: + raise mock.exception.BadCmdline( + "Must specify --resultdir when building multiple RPMS.") + if options.cleanup_after == False: config_opts['cleanup_on_success'] = False config_opts['cleanup_on_failure'] = False @@ -378,7 +382,7 @@ def main(ret): # cmdline options override config options log.info("mock.py version %s starting..." % __VERSION__) - set_config_opts_per_cmdline(config_opts, options) + set_config_opts_per_cmdline(config_opts, options, args) # do whatever we're here to do chroot = mock.backend.Root(config_opts, uidManager) -- cgit From 3364f97752b54f0f507475934fe486a7c8c79a1d Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Mon, 3 Dec 2007 20:58:03 -0500 Subject: add --define option to pass rpm macros on the command line Signed-off-by: Michael E Brown --- py/mock.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'py') 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: -- cgit From 2679d3cae92a1178b586fc1c07b1fbfcac88972a Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Tue, 4 Dec 2007 05:28:13 -0500 Subject: use 'MACRO EXPR' in --define docs to match the rpmbuild docs Signed-off-by: Michael E Brown --- py/mock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'py') diff --git a/py/mock.py b/py/mock.py index 8f085b2..f626bca 100755 --- a/py/mock.py +++ b/py/mock.py @@ -104,7 +104,7 @@ def command_parse(config_opts): 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'", + default=[], type="string", metavar="'MACRO EXPR'", 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") @@ -232,7 +232,7 @@ def set_config_opts_per_cmdline(config_opts, options, args): config_opts['macros'].update({k: v}) except: raise mock.exception.BadCmdline( - "Bad option for '--define' (%s). Use --define 'name value'" + "Bad option for '--define' (%s). Use --define 'macro expr'" % macro) if options.resultdir: -- cgit From 339fada0f033950b7165fbd98efdf9323f37f6be Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Tue, 4 Dec 2007 15:38:24 -0500 Subject: add --with and --without options to enable/disable options in a srpm Signed-off-by: Michael E Brown --- py/mock.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'py') diff --git a/py/mock.py b/py/mock.py index f626bca..7426e56 100755 --- a/py/mock.py +++ b/py/mock.py @@ -106,6 +106,12 @@ def command_parse(config_opts): parser.add_option("--define", action="append", dest="rpmmacros", default=[], type="string", metavar="'MACRO EXPR'", help="define an rpm macro (may be used more than once)") + parser.add_option("--with", action="append", dest="rpmwith", + default=[], type="string", metavar="option", + help="enable configure option for build (may be used more than once)") + parser.add_option("--without", action="append", dest="rpmwithout", + default=[], type="string", metavar="option", + help="disable configure option for build (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", @@ -224,6 +230,12 @@ def set_config_opts_per_cmdline(config_opts, options, args): if not options.clean: config_opts['clean'] = options.clean + for option in options.rpmwith: + options.rpmmacros.append("_with_%s 1" % option) + + for option in options.rpmwithout: + options.rpmmacros.append("_with_%s 0" % option) + for macro in options.rpmmacros: try: k, v = macro.split(" ", 1) -- cgit