[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: mock 0.8.9



Michael E Brown wrote:
> On Tue, Dec 04, 2007 at 06:27:33PM +0200, Ville Skyttä wrote:
>> That's nice, but even better IMHO would be something that could be
>> used to pass arbitrary options (or at least -D, --define, --with,
>> --without and --target) as-is to rpmbuild, for example everything
>> after a "--", like

More!  More!.  Damn user demands. (Just kidding, of course Ville.  ;)

> So, we could probably easily implement --with{,out} using this code
> as a base.

Okay, here's another set of patches to implement --with{,out} options.
I used git-format-patch this time, and probably did it awkwardly.  But
hopefully not too badly.  Just in case (and for non-git users), I'll
also attach a single diff that should apply cleanly to mock-0.8.14.

Comments and improvements welcome. :)

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Play "wheels on the bus" and get the hell out of my sight.
    -- Stewie Griffin

From 153cdbd620cffaebddfceb747c66d727270b1313 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz pobox com>
Date: Mon, 3 Dec 2007 20:58:03 -0500
Subject: [PATCH] add --define option to pass rpm macros on the command line

---
 docs/mock.1 |    5 +++++
 py/mock.py  |   14 ++++++++++++++
 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 bb5df8c..490c77e 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="'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",
@@ -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 'name value'"
+                % macro)
+
     if options.resultdir:
         config_opts['resultdir'] = os.path.expanduser(options.resultdir)
     if options.uniqueext:
-- 
1.5.3.6

From 875080a4ea11b7e46c9aa8a378d490d7156ca8c9 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz pobox com>
Date: Tue, 4 Dec 2007 05:28:13 -0500
Subject: [PATCH] use 'MACRO EXPR' in --define docs to match the rpmbuild docs

---
 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 490c77e..b78d37a 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -105,7 +105,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")
@@ -233,7 +233,7 @@ def set_config_opts_per_cmdline(config_opts, options):
             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:
-- 
1.5.3.6

From 6157b70e994c9325c96d47f55b52607003466c3b Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz pobox com>
Date: Tue, 4 Dec 2007 15:38:24 -0500
Subject: [PATCH] add --with and --without options to enable/disable options in a srpm

---
 docs/mock.1 |   12 +++++++++++-
 py/mock.py  |   12 ++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

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 b78d37a..a4cefa7 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -107,6 +107,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",
@@ -225,6 +231,12 @@ def set_config_opts_per_cmdline(config_opts, options):
     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)
-- 
1.5.3.6

diff --git a/docs/mock.1 b/docs/mock.1
index 3adc047..28c2629 100644
--- a/docs/mock.1
+++ b/docs/mock.1
@@ -56,6 +56,21 @@ 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\-\-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 cb558e0..0fbb1fc 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -103,6 +103,15 @@ 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("--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",
@@ -221,6 +230,23 @@ def set_config_opts_per_cmdline(config_opts, options):
     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)
+            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: pgpcgYkzP7tms.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]