[yum-commits] yum-builddep.py

Panu Matilainen pmatilai at osuosl.org
Thu Sep 1 06:18:29 UTC 2011


 yum-builddep.py |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 76a2bbb7728bfacb364de8eacf88d7a91735820a
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date:   Thu Sep 1 09:09:28 2011 +0300

    Add support for --target in yum-builddep (BZ 734983)
    
    This adds support for specifying alternative target architecture
    for spec parsing for rpm versions that support it (as of this writing
    only rpm.org HEAD has it), eg on x86_64 you might want to do
    'yum-builddep --target=i686 foo.spec'. Additionally on rpm-python
    versions which support it, reset the entire config after each spec parse
    whether target is set or not to avoid funny side-effects such as global
    macro definitions leaking from one spec to another.

diff --git a/yum-builddep.py b/yum-builddep.py
index dfcf585..642c66c 100755
--- a/yum-builddep.py
+++ b/yum-builddep.py
@@ -63,6 +63,9 @@ class YumBuildDep(YumUtilBase):
         self.logger = logging.getLogger("yum.verbose.cli.yumbuildep")                             
         # Add util commandline options to the yum-cli ones
         self.optparser = self.getOptionParser() 
+        if hasattr(rpm, 'reloadConfig'):
+            self.optparser.add_option("--target",
+                              help="set target architecture for spec parsing")
         self.main()
 
     def main(self):
@@ -179,10 +182,14 @@ class YumBuildDep(YumUtilBase):
         specnames = []
         srpms = []
         specworks = False
+        reloadworks = False
 
         # See if we can use spec files for buildrequires
         if hasattr(rpm, 'spec') and hasattr(rpm.spec, 'sourceHeader'):
             specworks = True
+        # See if we can reload rpm configuration
+        if hasattr(rpm, 'reloadConfig'):
+            reloadworks = True
 
         for arg in self.cmds:
             if arg.endswith('.src.rpm'):
@@ -225,12 +232,20 @@ class YumBuildDep(YumUtilBase):
             self.install_deps(srpm.requiresList())
     
         for name in specnames:
+            # (re)load rpm config for target if set
+            if reloadworks and opts.target:
+                rpm.reloadConfig(opts.target)
+
             try:
                 spec = rpm.spec(name)
             except ValueError:
                 self.logger.error("Bad spec: %s" % name)
                 continue
 
+            # reset default rpm config after each parse to avoid side-effects
+            if reloadworks:
+                rpm.reloadConfig()
+
             buildreqs = []
             for d in rpm.ds(spec.sourceHeader, 'requires'):
                 buildreqs.append(d.DNEVR()[2:])


More information about the Yum-commits mailing list