2006-10-10 18:09:34 +00:00
|
|
|
#!/usr/bin/python -tt
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
import sys
|
2006-10-10 22:08:38 +00:00
|
|
|
import yum
|
|
|
|
|
2006-10-11 01:05:28 +00:00
|
|
|
def create_yumobj(yumconf):
|
2006-10-11 03:59:50 +00:00
|
|
|
# Create a yum object to act upon. This may move to a higher
|
|
|
|
# level file and get passed to this module.
|
2006-10-11 01:05:28 +00:00
|
|
|
myYum = yum.yumBase()
|
|
|
|
myYum.doConfigSetup(fn=yumconf)
|
|
|
|
myYum.doRepoSetup()
|
2006-10-11 03:52:50 +00:00
|
|
|
myYum.doSackSetup()
|
2006-10-11 01:05:28 +00:00
|
|
|
return myYum
|
2006-10-10 22:08:38 +00:00
|
|
|
|
2006-10-11 03:52:50 +00:00
|
|
|
def download_packages(yumobj, pkglist):
|
2006-10-11 03:59:50 +00:00
|
|
|
# for now a simple function to download packages.
|
|
|
|
# Needed are ways to define where to put the packages,
|
|
|
|
# cleaning up multiple returns from searching
|
2006-10-11 03:52:50 +00:00
|
|
|
pkgobjs = []
|
|
|
|
for pkg in pkglist:
|
|
|
|
pkgobjs.extend(yumobj.pkgSack.searchNevra(name=pkg))
|
|
|
|
for pkgobj in pkgobjs:
|
|
|
|
pkgobj.repo.getPackage(pkgobj)
|
|
|
|
|
2006-10-11 01:05:28 +00:00
|
|
|
def main():
|
|
|
|
# This is used for testing the module
|
2006-10-11 01:19:16 +00:00
|
|
|
(opts, args) = get_arguments()
|
2006-10-10 18:09:34 +00:00
|
|
|
try:
|
|
|
|
compsobj = yum.comps.Comps()
|
2006-10-10 22:08:38 +00:00
|
|
|
compsobj.add(opts.comps)
|
2006-10-10 18:09:34 +00:00
|
|
|
|
2006-10-11 01:19:16 +00:00
|
|
|
print get_packagelist(compsobj)
|
2006-10-10 18:09:34 +00:00
|
|
|
|
|
|
|
except IOError:
|
2006-10-10 22:08:38 +00:00
|
|
|
print >> sys.stderr, "gather.py: No such file:\'%s\'" % opts.comps
|
2006-10-10 18:09:34 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2006-10-11 01:20:59 +00:00
|
|
|
from optparse import OptionParser
|
2006-10-11 01:19:16 +00:00
|
|
|
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')
|
2006-10-10 18:09:34 +00:00
|
|
|
|
2006-10-11 01:19:16 +00:00
|
|
|
|
|
|
|
(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
|
|
|
|
main()
|