Blame SOURCES/BZ-1437636-yum-builddep-add-define-opt.patch

911d2c
diff --git a/docs/yum-builddep.1 b/docs/yum-builddep.1
911d2c
index fbe32bd..54dce0e 100644
911d2c
--- a/docs/yum-builddep.1
911d2c
+++ b/docs/yum-builddep.1
911d2c
@@ -17,6 +17,12 @@ disabled) or it can be a local source RPM or a spec file.
911d2c
 .PP 
911d2c
 Note, that only the BuildRequires information within the SRPM header information is used to determine build dependencies. This will specifically omit any dependencies that are required only for specific architectures.
911d2c
 .PP
911d2c
+.SH "GENERAL OPTIONS"
911d2c
+.IP "\fB\--target ARCH\fP"
911d2c
+Set target architecture for spec parsing.
911d2c
+.IP "\fB\--define 'MACRO EXPR'\fP"
911d2c
+Define the rpm MACRO with value EXPR for spec parsing.
911d2c
+.PP
911d2c
 .SH "EXAMPLES"
911d2c
 .IP "Download and install all the RPMs needed to build the kernel RPM:"
911d2c
 \fByumdownloader --source kernel && rpm2cpio kernel*src.rpm | cpio -i kernel.spec && \\ \fP
911d2c
diff --git a/yum-builddep.py b/yum-builddep.py
911d2c
index 5f59ab8..dfdd31b 100755
911d2c
--- a/yum-builddep.py
911d2c
+++ b/yum-builddep.py
911d2c
@@ -67,6 +67,13 @@ class YumBuildDep(YumUtilBase):
911d2c
         if hasattr(rpm, 'reloadConfig'):
911d2c
             self.optparser.add_option("--target",
911d2c
                               help="set target architecture for spec parsing")
911d2c
+            self.optparser.add_option(
911d2c
+                "--define",
911d2c
+                action="append",
911d2c
+                default=[],
911d2c
+                metavar="'MACRO EXPR'",
911d2c
+                help="define the rpm MACRO with value EXPR for spec parsing",
911d2c
+            )
911d2c
         self.main()
911d2c
 
911d2c
     def main(self):
911d2c
@@ -229,11 +236,28 @@ class YumBuildDep(YumUtilBase):
911d2c
             self.logger.info('Getting requirements for %s' % srpm)
911d2c
             self.install_deps(srpm.requiresList(), opts)
911d2c
     
911d2c
+        # Parse macro defines
911d2c
+        macros = []
911d2c
+        error = False
911d2c
+        for define in opts.define:
911d2c
+            words = define.split(None, 1)
911d2c
+            if len(words) == 1:
911d2c
+                self.logger.error('Error: No EXPR given for MACRO %%%s'
911d2c
+                                  % words[0])
911d2c
+                error = True
911d2c
+                continue
911d2c
+            macros.append(words)
911d2c
+        if error:
911d2c
+            sys.exit(1)
911d2c
+
911d2c
         for name in specnames:
911d2c
             # (re)load rpm config for target if set
911d2c
             if reloadworks and opts.target:
911d2c
                 rpm.reloadConfig(opts.target)
911d2c
 
911d2c
+            for macro in macros:
911d2c
+                rpm.addMacro(*macro)
911d2c
+
911d2c
             try:
911d2c
                 spec = rpm.spec(name)
911d2c
             except ValueError: