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(-) 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 --- docs/mock.1 | 5 +++++ py/mock.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+) 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: -- 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 --- docs/mock.1 | 4 ++-- py/mock.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/mock.1 b/docs/mock.1 index ca212b5..17b5081 100644 --- a/docs/mock.1 +++ b/docs/mock.1 @@ -56,10 +56,10 @@ 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" +\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="vendor Not Fedora" \-\-define="packager Some guy"\fR +\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 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 --- docs/mock.1 | 12 +++++++++++- py/mock.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/mock.1 b/docs/mock.1 index 17b5081..28c2629 100644 --- a/docs/mock.1 +++ b/docs/mock.1 @@ -59,7 +59,17 @@ Specify target build arch. \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 +\fB\-\-define "with_extra_cheese 1" \-\-define="packager Monkey"\fR +.TP +\fB\-\-with=\fR\fIOPTION\fP +Enable configure OPTION for build. This option may be used multiple times. For example: + +\fB\-\-with extra_cheese\fR +.TP +\fB\-\-without=\fR\fIOPTION\fP +Disable configure OPTION for build. This option may be used multiple times. For example: + +\fB\-\-without anchovies\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 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 From ee52f57c99cca3c3c274f75574b61b7b7d3a186d Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Tue, 4 Dec 2007 17:35:35 -0600 Subject: whitespace fixups. --- docs/mock.1 | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/mock.1 b/docs/mock.1 index 28c2629..e6a501d 100644 --- a/docs/mock.1 +++ b/docs/mock.1 @@ -1,9 +1,9 @@ .TH "mock" "1" "0.7" "Seth Vidal" "" .SH "NAME" -.LP +.LP mock \- build SRPMs in a chroot .SH "SYNTAX" -.LP +.LP mock [options] \fB\-\-rebuild\fR \fISRPM [\fISRPM...\fR] .LP mock [options] \fB\-\-chroot\fR \fI\fR @@ -15,11 +15,11 @@ mock [options] \fB\-\-installdeps\fR {SRPM|RPM} mock [options] \fB\-\-install\fR PACKAGE .SH "DESCRIPTION" -.LP +.LP Mock is a simple program that will build source RPMs inside a chroot. It doesn't do anything terribly fancy other than populate a chroot with the contents specified by a configuration file, then build any input SRPM(s) in -that chroot. +that chroot. .LP The content of a chroot is specified by the configuration specified with the \fB\-r\fR option. The default configuration file is /etc/mock/default.cfg, @@ -34,43 +34,43 @@ For backwards compatibility, old-style commands, ("rebuild", "init", "clean", etc.) without leading '\-\-' are still accepted, but are deprecated. See COMMANDS section, below, for detailed listing of all commands. .SH "OPTIONS" -.LP -.TP +.LP +.TP \fB\-r\fR \fICHROOT\fP Uses specified chroot configuration as defined in /etc/mock/<\fIchroot\fP>.cfg. If none specified, uses the chroot linked -to by /etc/mock/default.cfg -.TP +to by /etc/mock/default.cfg +.TP \fB\-\-offline\fR Run in 'offline' mode where we tell 'yum' to run completely from local cache. Also disables cache expiry for the mock yum cache. -.TP +.TP \fB\-\-no\-clean\fR Do not clean chroot before building package. -.TP +.TP \fB\-\-cleanup\-after\fR Clean chroot after building. Use with \-\-resultdir. Only active for '\-\-rebuild'. -.TP +.TP \fB\-\-no\-cleanup\-after\fR Dont clean chroot after building. If automatic cleanup is enabled, use this to disable. -.TP +.TP \fB\-\-arch=\fR\fIARCH\fP Specify target build arch. -.TP +.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 +.TP \fB\-\-with=\fR\fIOPTION\fP Enable configure OPTION for build. This option may be used multiple times. For example: \fB\-\-with extra_cheese\fR -.TP +.TP \fB\-\-without=\fR\fIOPTION\fP Disable configure OPTION for build. This option may be used multiple times. For example: \fB\-\-without anchovies\fR -.TP +.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: @@ -84,33 +84,33 @@ Change directory where config files are found .TP \fB\-\-rpmbuild_timeout=\fR\fISECONDS\fP Fail build if rpmbuild takes longer than 'timeout' seconds -.TP +.TP \fB\-\-help\fR Show usage information and exit. -.TP +.TP \fB\-\-version\fR Show version number and exit. .SH "COMMANDS" .LP .TP \fB\-\-clean\fR \- purge the chroot tree -.TP +.TP \fB\-\-init\fR \- initialize a chroot (clean, install chroot packages, etc.) .TP \fB\-\-rebuild\fR \- If no command is specified, rebuild is assumed. Rebuilds the specified SRPM(s). The buildroot is cleaned first, unless --no-clean is specified. -.TP +.TP \fB\-\-chroot\fR|\fB\-\-shell\fR \- run the specified command within the chroot (which must already be initialized -- no 'clean' is performed). If no command specified, /bin/sh is run. .TP \fB\-\-installdeps\fR \- find out deps for SRPM or RPM, and do a yum install to put them in the buildroot. Buildroot must already be initialized -- no 'clean' is performed .TP \fB\-\-install\fR \- Do a yum install PACKAGE inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed .SH "FILES" -.LP +.LP \fI/etc/mock/\fP \- default configuration directory .LP \fI/var/lib/mock\fP \- directory where chroots are created .SH "EXAMPLES" -.LP +.LP To rebuild test.src.rpm under the default chroot: .LP .RS 5 @@ -136,15 +136,15 @@ button. If there is a bug similar to the one you are seeing, add your information to the comments. If not, go to the new bug page using the same product and component and fill in the form. .SH "AUTHORS" -.LP +.LP Michael Brown -.LP +.LP Clark Williams -.LP +.LP Seth Vidal .LP and a cast of...tens .SH "SEE ALSO" -.LP +.LP yum(8) rpmbuild(8) http://fedoraproject.org/wiki/Projects/Mock -- cgit