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

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