Blob Blame History Raw
--- a/yumdownloader.py	2008-01-30 01:03:15.000000000 -0500
+++ b/yumdownloader.py	2008-03-07 10:54:06.000000000 -0500
@@ -26,6 +26,7 @@
 from urlgrabber.progress import TextMeter
 import shutil
 
+import rpmUtils
 
 class YumDownloader(YumUtilBase):
     NAME = 'yumdownloader'
@@ -64,9 +65,12 @@
                 self.logger.error("Error: Could not make cachedir, exiting")
                 sys.exit(50)
             self.repos.setCacheDir(cachedir)
-            # Turn of cache
-            self.conf.cache = 0
 
+            # Turn off cache
+            self.conf.cache = 0
+            # make sure the repos know about it, too
+            self.repos.setCache(0)
+            
         # Setup yum (Ts, RPM db, Repo & Sack)
         self.doUtilYumSetup(opts)
         # Setup source repos
@@ -116,14 +120,12 @@
         
     def downloadPackages(self,opts):
         
-        avail = self.pkgSack.returnPackages()
-    
         toDownload = []
     
         packages = self.cmds
         for pkg in packages:
             toActOn = []
-            exactmatch, matched, unmatched = parsePackages(avail, [pkg])
+            exactmatch, matched, unmatched = parsePackages(self.pkgSack.returnPackages(), [pkg])
             installable = yum.misc.unique(exactmatch + matched)
             if len(unmatched) > 0: # if we get back anything in unmatched, it fails
                 self.logger.error('No Match for argument %s' % pkg)
@@ -158,9 +160,12 @@
             if toActOn:
                 if opts.source:
                     toDownload.extend(self.bestPackagesFromList(toActOn, 'src'))
+                elif opts.archlist:
+                    for arch in opts.archlist.split(','):
+                        toDownload.extend(self.bestPackagesFromList(toActOn, arch))
                 else:
                     toDownload.extend(self.bestPackagesFromList(toActOn))
-        
+                    
         # If the user supplies to --resolve flag, resolve dependencies for
         # all packages
         # note this might require root access because the headers need to be
@@ -215,18 +220,20 @@
                                    size=os.stat(path).st_size)
                     shutil.copy2(path, local)
                     progress.end(progress.size) 
-   
+            
     # sligly modified from the one in YumUtilBase    
     def doUtilYumSetup(self,opts):
         """do a default setup for all the normal/necessary yum components,
            really just a shorthand for testing"""
         try:
-            self._getTs()
-            self._getRpmDB()
             self._getRepos()
             # if '--source' is used the add src to the archlist
             if opts.source:
                 archlist = rpmUtils.arch.getArchList() + ['src']    
+            elif opts.archlist:
+                archlist = []
+                for a in opts.archlist.split(','):
+                    archlist.extend(rpmUtils.arch.getArchList(a))
             else:
                 archlist = rpmUtils.arch.getArchList()
             self._getSacks(archlist=archlist)
@@ -251,7 +258,8 @@
           help='resolve dependencies and download required packages')
         parser.add_option("--source", default=False, dest="source", action="store_true",
           help='operate on source packages')
-        
+        parser.add_option("--archlist",
+          help="only download packages of certain architecture(s)")        
 if __name__ == '__main__':
     util = YumDownloader()