Michael E Brown wrote: > Patches welcome. Here's one. This adds a --define option, which may be used multiple times. Usage is pretty much like the rpm --define option: $ mock --define="with_extra_cheese 1" --define="packager Monkey" ... Rather than pass the define options directly to rpmbuild, they are added to the .rpmmacros file in the chroot. I'm not sure if there's much difference in practice. If anyone knows differently, please speak up. -- Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Giving a politician access to your wallet is like giving a dog access to your refrigerator. -- Tim Barber
diff --git a/docs/mock.1 b/docs/mock.1 index 3adc047..17b5081 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"\fIMACRO EXPR\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="with_extra_cheese 1" \-\-define="packager Monkey"\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 bb5df8c..b78d37a 100755 --- a/py/mock.py +++ b/py/mock.py @@ -104,6 +104,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="'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") parser.add_option("--uniqueext", action="store", type="string", @@ -222,6 +225,17 @@ def set_config_opts_per_cmdline(config_opts, options): 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 'macro expr'" + % macro) + if options.resultdir: config_opts['resultdir'] = os.path.expanduser(options.resultdir) if options.uniqueext:
Attachment:
pgpVEfSSe8Yws.pgp
Description: PGP signature
-- fedora-devel-list mailing list fedora-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-list