Add an hacked up option parser
Start on a yum object
This commit is contained in:
		
							parent
							
								
									7307757c2e
								
							
						
					
					
						commit
						35a57f82e2
					
				| @ -14,26 +14,52 @@ | ||||
| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| 
 | ||||
| import sys | ||||
| import yum.comps | ||||
| import yum | ||||
| from optparse import OptionParser | ||||
| 
 | ||||
| 
 | ||||
| def get_arguments(): | ||||
| # hack job for now, I'm sure this could be better for our uses | ||||
|     usage = "usage: %s [options]" % sys.argv[0] | ||||
|     parser = OptionParser(usage=usage) | ||||
|     parser.add_option("--destdir", default=".", dest="destdir", | ||||
|       help='destination directory (defaults to current directory)') | ||||
|     parser.add_option("--comps", default="comps.xml", dest="comps", | ||||
|       help='comps file to use') | ||||
|     parser.add_option("--yumconf", default="yum.conf", dest="yumconf", | ||||
|       help='yum config file to use') | ||||
| 
 | ||||
| 
 | ||||
|     (opts, args) = parser.parse_args() | ||||
|     #if len(opts) < 1: | ||||
|     #    parser.print_help() | ||||
|     #    sys.exit(0) | ||||
|     return (opts, args) | ||||
| 
 | ||||
| def get_packagelist(myComps): | ||||
| # Get the list of packages from the comps file | ||||
|     pkglist = [] | ||||
|     for group in myComps.groups: | ||||
|         pkglist += group.packages | ||||
|     return pkglist | ||||
| 
 | ||||
| def create_yumobj(yumconf): | ||||
| # Create a yum object to act upon | ||||
|     myYum = yum.yumBase() | ||||
|     myYum.doConfigSetup(fn=yumconf) | ||||
|     myYum.doRepoSetup() | ||||
|     return myYum | ||||
| 
 | ||||
| def main(): | ||||
|     (opts, args) = get_arguments() | ||||
|     try: | ||||
|         print sys.argv[1] | ||||
|         compsobj = yum.comps.Comps() | ||||
|         for srcfile in sys.argv[1:]: | ||||
|             compsobj.add(srcfile) | ||||
|         compsobj.add(opts.comps) | ||||
| 
 | ||||
|         print get_packagelist(compsobj) | ||||
| 
 | ||||
|     except IOError: | ||||
|         print >> sys.stderr, "gather.py: No such file:\'%s\'" % sys.argv[1] | ||||
|         print >> sys.stderr, "gather.py: No such file:\'%s\'" % opts.comps | ||||
|         sys.exit(1) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 jkeating@localhost.localdomain
						jkeating@localhost.localdomain