[PATCH] Introduce the option to define MACRO for RPM

bgaifullin at mirantis.com bgaifullin at mirantis.com
Mon Sep 21 07:32:52 UTC 2015


From: Bulat Gaifullin <bgaifullin at mirantis.com>

example:
yum-builddep -y --define="version 1.0" --define="release 1" /tmp/package.spec
---
yum-builddep.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/yum-builddep.py b/yum-builddep.py
index 5f59ab8..d08b1f7 100755
--- a/yum-builddep.py
+++ b/yum-builddep.py
@@ -67,6 +67,9 @@ class YumBuildDep(YumUtilBase):
        if hasattr(rpm, 'reloadConfig'):
            self.optparser.add_option("--target",
                              help="set target architecture for spec parsing")
+        self.optparser.add_option("--define", action='append', default=[],
+                                  metavar="\"MACRO EXPR\"",
+                                  help="define the rpm MACRO with value EXPR")
        self.main()

    def main(self):
@@ -190,6 +193,10 @@ class YumBuildDep(YumUtilBase):
        if hasattr(rpm, 'reloadConfig'):
            reloadworks = True

+        if opts.define:
+            for macro in opts.define:
+                rpm.addMacro(*macro.split(' ', 1))
+
        for arg in self.cmds:
            if arg.endswith('.src.rpm'):
                try:
@@ -228,7 +235,7 @@ class YumBuildDep(YumUtilBase):
        for srpm in toActOn:
            self.logger.info('Getting requirements for %s' % srpm)
            self.install_deps(srpm.requiresList(), opts)
-    
+
        for name in specnames:
            # (re)load rpm config for target if set
            if reloadworks and opts.target:
-- 
2.3.8 (Apple Git-58)



More information about the Yum-devel mailing list