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
|
2006-10-24 13:44:11 +00:00
|
|
|
# the Free Software Foundation; version 2 of the License.
|
2006-10-10 18:09:34 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2006-10-10 22:08:38 +00:00
|
|
|
import yum
|
2006-10-12 04:38:36 +00:00
|
|
|
import os
|
2006-11-17 19:02:37 +00:00
|
|
|
import shutil
|
2006-12-10 01:48:08 +00:00
|
|
|
import sys
|
2007-08-15 23:19:13 +00:00
|
|
|
import pypungi
|
|
|
|
import logging
|
2007-11-28 02:42:37 +00:00
|
|
|
import urlgrabber.progress
|
|
|
|
|
|
|
|
class CallBack(urlgrabber.progress.TextMeter):
|
|
|
|
"""A call back function used with yum."""
|
|
|
|
|
|
|
|
def progressbar(self, current, total, name=None):
|
|
|
|
return
|
2006-10-10 22:08:38 +00:00
|
|
|
|
2007-08-09 03:50:33 +00:00
|
|
|
class PungiYum(yum.YumBase):
|
|
|
|
"""Subclass of Yum"""
|
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
self.pungiconfig = config
|
|
|
|
yum.YumBase.__init__(self)
|
|
|
|
|
|
|
|
def doLoggingSetup(self, debuglevel, errorlevel):
|
|
|
|
"""Setup the logging facility."""
|
|
|
|
|
|
|
|
logdir = os.path.join(self.pungiconfig.get('default', 'destdir'), 'logs')
|
|
|
|
if not os.path.exists(logdir):
|
|
|
|
os.makedirs(logdir)
|
|
|
|
if self.pungiconfig.get('default', 'flavor'):
|
|
|
|
logfile = os.path.join(logdir, '%s.%s.log' % (self.pungiconfig.get('default', 'flavor'),
|
|
|
|
self.pungiconfig.get('default', 'arch')))
|
|
|
|
else:
|
|
|
|
logfile = os.path.join(logdir, '%s.log' % (self.pungiconfig.get('default', 'arch')))
|
|
|
|
|
|
|
|
yum.logging.basicConfig(level=yum.logging.DEBUG, filename=logfile)
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
def doFileLogSetup(self, uid, logfile):
|
|
|
|
# This function overrides a yum function, allowing pungi to control
|
|
|
|
# the logging.
|
|
|
|
pass
|
2007-08-09 03:50:33 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
class Gather(pypungi.PungiBase):
|
2007-08-25 14:04:25 +00:00
|
|
|
def __init__(self, config, ksparser):
|
2007-08-26 18:08:27 +00:00
|
|
|
pypungi.PungiBase.__init__(self, config)
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
# Set our own logging name space
|
|
|
|
self.logger = logging.getLogger('Pungi.Gather')
|
2007-02-16 14:37:52 +00:00
|
|
|
|
2007-08-17 13:14:18 +00:00
|
|
|
# Create the stdout/err streams and only send INFO+ stuff there
|
|
|
|
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
|
|
|
|
console = logging.StreamHandler()
|
|
|
|
console.setFormatter(formatter)
|
|
|
|
console.setLevel(logging.INFO)
|
|
|
|
self.logger.addHandler(console)
|
|
|
|
|
2007-08-25 14:04:25 +00:00
|
|
|
self.ksparser = ksparser
|
2007-08-08 14:08:47 +00:00
|
|
|
self.polist = []
|
|
|
|
self.srpmlist = []
|
|
|
|
self.resolved_deps = {} # list the deps we've already resolved, short circuit.
|
|
|
|
|
|
|
|
# Create a yum object to use
|
2007-08-09 03:50:33 +00:00
|
|
|
self.ayum = PungiYum(config)
|
2007-08-26 18:08:27 +00:00
|
|
|
self.ayum.doLoggingSetup(6, 6)
|
|
|
|
yumconf = yum.config.YumConf()
|
|
|
|
yumconf.debuglevel = 6
|
|
|
|
yumconf.errorlevel = 6
|
2007-11-28 02:42:37 +00:00
|
|
|
yumconf.cachedir = self.config.get('default', 'cachedir')
|
2007-08-26 18:08:27 +00:00
|
|
|
yumconf.persistdir = os.path.join(self.workdir, 'yumlib')
|
|
|
|
yumconf.installroot = os.path.join(self.workdir, 'yumroot')
|
|
|
|
yumconf.uid = os.geteuid()
|
|
|
|
yumconf.cache = 0
|
2007-11-28 02:42:37 +00:00
|
|
|
yumconf.failovermethod = 'priority'
|
2007-08-27 14:33:28 +00:00
|
|
|
yumvars = yum.config._getEnvVar()
|
|
|
|
yumvars['releasever'] = self.config.get('default', 'version')
|
2007-08-27 16:41:26 +00:00
|
|
|
yumvars['basearch'] = yum.rpmUtils.arch.getBaseArch(myarch=self.config.get('default', 'arch'))
|
2007-08-27 14:33:28 +00:00
|
|
|
yumconf.yumvar = yumvars
|
2007-08-26 18:08:27 +00:00
|
|
|
self.ayum._conf = yumconf
|
|
|
|
self.ayum.repos.setCacheDir(self.ayum.conf.cachedir)
|
|
|
|
|
2007-08-27 14:02:03 +00:00
|
|
|
arch = self.config.get('default', 'arch')
|
2007-08-27 16:41:26 +00:00
|
|
|
if arch == 'i386':
|
2007-08-27 14:02:03 +00:00
|
|
|
yumarch = 'athlon'
|
|
|
|
elif arch == 'ppc':
|
|
|
|
yumarch = 'ppc64'
|
|
|
|
elif arch == 'sparc':
|
|
|
|
yumarch = 'sparc64v'
|
|
|
|
else:
|
|
|
|
yumarch = arch
|
|
|
|
|
2007-08-26 18:08:27 +00:00
|
|
|
self.ayum.compatarch = yumarch
|
|
|
|
arches = yum.rpmUtils.arch.getArchList(yumarch)
|
2007-08-21 16:40:44 +00:00
|
|
|
arches.append('src') # throw source in there, filter it later
|
2007-08-26 18:08:27 +00:00
|
|
|
|
|
|
|
# deal with our repos
|
2007-09-12 21:38:01 +00:00
|
|
|
try:
|
|
|
|
ksparser.handler.repo.methodToRepo()
|
|
|
|
except:
|
|
|
|
pass
|
2007-09-12 20:42:06 +00:00
|
|
|
|
2007-08-26 18:08:27 +00:00
|
|
|
for repo in ksparser.handler.repo.repoList:
|
|
|
|
self.logger.info('Adding repo %s' % repo.name)
|
|
|
|
thisrepo = yum.yumRepo.YumRepository(repo.name)
|
|
|
|
thisrepo.name = repo.name
|
|
|
|
# add excludes and such here when pykickstart gets them
|
|
|
|
if repo.mirrorlist:
|
2007-08-27 16:41:26 +00:00
|
|
|
thisrepo.mirrorlist = yum.parser.varReplace(repo.mirrorlist, self.ayum.conf.yumvar)
|
|
|
|
self.logger.info('Mirrorlist for repo %s is %s' % (thisrepo.name, thisrepo.mirrorlist))
|
2007-08-26 18:08:27 +00:00
|
|
|
else:
|
2007-08-27 16:41:26 +00:00
|
|
|
thisrepo.baseurl = yum.parser.varReplace(repo.baseurl, self.ayum.conf.yumvar)
|
|
|
|
self.logger.info('URL for repo %s is %s' % (thisrepo.name, thisrepo.baseurl))
|
|
|
|
thisrepo.basecachedir = self.ayum.conf.cachedir
|
|
|
|
thisrepo.enablegroups = True
|
2007-08-27 14:33:28 +00:00
|
|
|
self.ayum.repos.add(thisrepo)
|
2007-08-27 16:41:26 +00:00
|
|
|
self.ayum.repos.enableRepo(thisrepo.id)
|
|
|
|
self.ayum._getRepos(thisrepo=thisrepo.id, doSetup = True)
|
2007-08-26 18:08:27 +00:00
|
|
|
|
2007-11-28 02:42:37 +00:00
|
|
|
self.ayum.repos.setProgressBar(CallBack())
|
|
|
|
self.ayum.repos.callback = CallBack()
|
|
|
|
|
|
|
|
self.ayum.cleanMetadata() # clean metadata that might be in the cache from previous runs
|
|
|
|
self.ayum.cleanSqlite() # clean metadata that might be in the cache from previous runs
|
|
|
|
|
2007-08-26 18:08:27 +00:00
|
|
|
self.logger.info('Getting sacks for arches %s' % arches)
|
2007-08-08 14:08:47 +00:00
|
|
|
self.ayum._getSacks(archlist=arches)
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2007-08-21 16:40:44 +00:00
|
|
|
def _filtersrc(self, po):
|
|
|
|
"""Filter out package objects that are of 'src' arch."""
|
|
|
|
|
|
|
|
if po.arch == 'src':
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2007-05-24 06:06:25 +00:00
|
|
|
def verifyCachePkg(self, po, path): # Stolen from yum
|
|
|
|
"""check the package checksum vs the cache
|
|
|
|
return True if pkg is good, False if not"""
|
|
|
|
|
|
|
|
(csum_type, csum) = po.returnIdSum()
|
|
|
|
|
|
|
|
try:
|
|
|
|
filesum = yum.misc.checksum(csum_type, path)
|
|
|
|
except yum.Errors.MiscError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
if filesum != csum:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2006-10-16 04:42:43 +00:00
|
|
|
def getPackageDeps(self, po):
|
2007-03-15 20:25:57 +00:00
|
|
|
"""Add the dependencies for a given package to the
|
|
|
|
transaction info"""
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info('Checking deps of %s.%s' % (po.name, po.arch))
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2007-01-23 23:03:52 +00:00
|
|
|
reqs = po.requires
|
|
|
|
provs = po.provides
|
2006-10-11 22:53:52 +00:00
|
|
|
|
|
|
|
for req in reqs:
|
2007-02-07 03:53:43 +00:00
|
|
|
if self.resolved_deps.has_key(req):
|
|
|
|
continue
|
2006-10-11 22:53:52 +00:00
|
|
|
(r,f,v) = req
|
2007-01-23 23:03:52 +00:00
|
|
|
if r.startswith('rpmlib(') or r.startswith('config('):
|
|
|
|
continue
|
|
|
|
if req in provs:
|
|
|
|
continue
|
|
|
|
|
2007-08-08 14:08:47 +00:00
|
|
|
deps = self.ayum.whatProvides(r, f, v).returnPackages()
|
2007-06-12 00:45:32 +00:00
|
|
|
if not deps:
|
|
|
|
self.logger.warn("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
|
2006-10-11 22:53:52 +00:00
|
|
|
continue
|
|
|
|
|
2007-06-20 02:19:19 +00:00
|
|
|
depsack = yum.packageSack.ListPackageSack(deps)
|
|
|
|
|
|
|
|
for dep in depsack.returnNewestByNameArch():
|
2007-08-08 14:08:47 +00:00
|
|
|
self.ayum.tsInfo.addInstall(dep)
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch))
|
2007-02-07 03:53:43 +00:00
|
|
|
|
|
|
|
self.resolved_deps[req] = None
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2007-03-02 15:24:03 +00:00
|
|
|
def getPackagesFromGroup(self, group):
|
2007-08-26 18:42:59 +00:00
|
|
|
"""Get a list of package names from a ksparser group object
|
2007-03-02 04:06:41 +00:00
|
|
|
|
|
|
|
Returns a list of package names"""
|
|
|
|
|
|
|
|
packages = []
|
|
|
|
|
|
|
|
# Check if we have the group
|
2007-08-26 18:42:59 +00:00
|
|
|
if not self.ayum.comps.has_group(group.name):
|
2007-03-02 04:06:41 +00:00
|
|
|
self.logger.error("Group %s not found in comps!" % group)
|
|
|
|
return packages
|
|
|
|
|
|
|
|
# Get the group object to work with
|
2007-08-26 18:42:59 +00:00
|
|
|
groupobj = self.ayum.comps.return_group(group.name)
|
2007-03-02 04:06:41 +00:00
|
|
|
|
|
|
|
# Add the mandatory packages
|
|
|
|
packages.extend(groupobj.mandatory_packages.keys())
|
|
|
|
|
|
|
|
# Add the default packages unless we don't want them
|
2007-08-26 23:44:38 +00:00
|
|
|
if group.include == 1:
|
2007-03-02 04:06:41 +00:00
|
|
|
packages.extend(groupobj.default_packages.keys())
|
|
|
|
|
|
|
|
# Add the optional packages if we want them
|
2007-08-26 23:44:38 +00:00
|
|
|
if group.include == 2:
|
2007-08-26 18:42:59 +00:00
|
|
|
packages.extend(groupobj.default_packages.keys())
|
2007-03-02 04:06:41 +00:00
|
|
|
packages.extend(groupobj.optional_packages.keys())
|
|
|
|
|
2007-03-15 17:35:05 +00:00
|
|
|
# Deal with conditional packages
|
|
|
|
# Populate a dict with the name of the required package and value
|
|
|
|
# of the package objects it would bring in. To be used later if
|
|
|
|
# we match the conditional.
|
|
|
|
for condreq, cond in groupobj.conditional_packages.iteritems():
|
2007-08-08 14:08:47 +00:00
|
|
|
pkgs = self.ayum.pkgSack.searchNevra(name=condreq)
|
2007-03-15 17:35:05 +00:00
|
|
|
if pkgs:
|
2007-08-21 16:40:44 +00:00
|
|
|
pkgs = self.ayum.bestPackagesFromList(pkgs, arch=self.ayum.compatarch)
|
2007-08-08 14:08:47 +00:00
|
|
|
if self.ayum.tsInfo.conditionals.has_key(cond):
|
|
|
|
self.ayum.tsInfo.conditionals[cond].extend(pkgs)
|
2007-03-15 17:35:05 +00:00
|
|
|
else:
|
2007-08-08 14:08:47 +00:00
|
|
|
self.ayum.tsInfo.conditionals[cond] = pkgs
|
2007-03-15 17:35:05 +00:00
|
|
|
|
2007-03-02 04:06:41 +00:00
|
|
|
return packages
|
|
|
|
|
2006-10-12 14:37:34 +00:00
|
|
|
def getPackageObjects(self):
|
2006-10-12 04:38:36 +00:00
|
|
|
"""Cycle through the list of packages, get package object
|
|
|
|
matches, and resolve deps.
|
|
|
|
|
|
|
|
Returns a list of package objects"""
|
|
|
|
|
2006-10-16 05:11:08 +00:00
|
|
|
final_pkgobjs = {} # The final list of package objects
|
2007-03-02 04:06:41 +00:00
|
|
|
searchlist = [] # The list of package names/globs to search for
|
2007-03-15 20:25:57 +00:00
|
|
|
matchdict = {} # A dict of objects to names
|
2007-03-02 04:06:41 +00:00
|
|
|
|
2007-03-15 17:35:05 +00:00
|
|
|
# First remove the excludes
|
2007-08-26 18:42:59 +00:00
|
|
|
self.ayum.conf.exclude.extend(self.ksparser.handler.packages.excludedList)
|
2007-08-08 14:08:47 +00:00
|
|
|
self.ayum.excludePackages()
|
2007-03-15 17:35:05 +00:00
|
|
|
|
2007-08-26 18:42:59 +00:00
|
|
|
# Check to see if we need the base group
|
|
|
|
if self.ksparser.handler.packages.addBase:
|
|
|
|
self.ksparser.handler.packages.add(['@base'])
|
|
|
|
|
2007-03-15 17:35:05 +00:00
|
|
|
# Get a list of packages from groups
|
2007-08-26 18:42:59 +00:00
|
|
|
for group in self.ksparser.handler.packages.groupList:
|
2007-03-02 15:24:03 +00:00
|
|
|
searchlist.extend(self.getPackagesFromGroup(group))
|
2007-03-02 04:06:41 +00:00
|
|
|
|
|
|
|
# Add the adds
|
2007-08-26 18:42:59 +00:00
|
|
|
searchlist.extend(self.ksparser.handler.packages.packageList)
|
2007-03-02 04:06:41 +00:00
|
|
|
|
2007-03-02 16:33:01 +00:00
|
|
|
# Make the search list unique
|
|
|
|
searchlist = yum.misc.unique(searchlist)
|
|
|
|
|
2007-03-02 04:06:41 +00:00
|
|
|
# Search repos for things in our searchlist, supports globs
|
2007-08-08 14:08:47 +00:00
|
|
|
(exactmatched, matched, unmatched) = yum.packages.parsePackages(self.ayum.pkgSack.returnPackages(), searchlist, casematch=1)
|
2007-08-21 16:40:44 +00:00
|
|
|
matches = filter(self._filtersrc, exactmatched + matched)
|
2007-02-09 01:25:41 +00:00
|
|
|
|
2007-03-15 20:25:57 +00:00
|
|
|
# Populate a dict of package objects to their names
|
|
|
|
for match in matches:
|
|
|
|
matchdict[match.name] = match
|
|
|
|
|
2007-03-15 18:25:24 +00:00
|
|
|
# Get the newest results from the search
|
2007-02-09 01:25:41 +00:00
|
|
|
mysack = yum.packageSack.ListPackageSack(matches)
|
|
|
|
for match in mysack.returnNewestByNameArch():
|
2007-08-08 14:08:47 +00:00
|
|
|
self.ayum.tsInfo.addInstall(match)
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.debug('Found %s.%s' % (match.name, match.arch))
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2007-02-09 01:25:41 +00:00
|
|
|
for pkg in unmatched:
|
2007-03-15 20:25:57 +00:00
|
|
|
if not pkg in matchdict.keys():
|
2007-11-27 19:54:17 +00:00
|
|
|
self.logger.warn('Could not find a match for %s in any configured repo' % pkg)
|
2007-02-09 01:25:41 +00:00
|
|
|
|
2007-08-08 14:08:47 +00:00
|
|
|
if len(self.ayum.tsInfo) == 0:
|
2006-10-12 04:38:36 +00:00
|
|
|
raise yum.Errors.MiscError, 'No packages found to download.'
|
|
|
|
|
2007-03-15 20:25:57 +00:00
|
|
|
moretoprocess = True
|
|
|
|
while moretoprocess: # Our fun loop
|
2007-03-16 17:31:31 +00:00
|
|
|
moretoprocess = False
|
2007-08-08 14:08:47 +00:00
|
|
|
for txmbr in self.ayum.tsInfo:
|
2007-03-15 20:25:57 +00:00
|
|
|
if not final_pkgobjs.has_key(txmbr.po):
|
|
|
|
final_pkgobjs[txmbr.po] = None # Add the pkg to our final list
|
|
|
|
self.getPackageDeps(txmbr.po) # Get the deps of our package
|
2007-03-16 17:31:31 +00:00
|
|
|
moretoprocess = True
|
2006-10-16 03:59:41 +00:00
|
|
|
|
2006-10-16 05:11:08 +00:00
|
|
|
self.polist = final_pkgobjs.keys()
|
2007-08-16 14:02:43 +00:00
|
|
|
self.logger.info('Finished gathering package objects.')
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
def getSRPMList(self):
|
|
|
|
"""Cycle through the list of package objects and
|
|
|
|
find the sourcerpm for them. Requires yum still
|
|
|
|
configured and a list of package objects"""
|
|
|
|
|
|
|
|
for po in self.polist:
|
2007-02-06 18:54:06 +00:00
|
|
|
srpm = po.sourcerpm.split('.src.rpm')[0]
|
2006-12-10 01:48:08 +00:00
|
|
|
if not srpm in self.srpmlist:
|
|
|
|
self.srpmlist.append(srpm)
|
|
|
|
|
2007-09-12 14:08:04 +00:00
|
|
|
def _downloadPackageList(self, polist, relpkgdir):
|
2006-10-11 22:53:52 +00:00
|
|
|
"""Cycle through the list of package objects and
|
|
|
|
download them from their respective repos."""
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
downloads = []
|
2007-09-12 14:08:04 +00:00
|
|
|
for pkg in polist:
|
2007-08-15 23:19:13 +00:00
|
|
|
downloads.append('%s.%s' % (pkg.name, pkg.arch))
|
|
|
|
downloads.sort()
|
|
|
|
self.logger.info("Download list: %s" % downloads)
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2007-09-12 14:08:04 +00:00
|
|
|
pkgdir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'flavor'),
|
|
|
|
relpkgdir)
|
2006-11-17 23:01:10 +00:00
|
|
|
|
2006-10-14 23:11:46 +00:00
|
|
|
if not os.path.exists(pkgdir):
|
|
|
|
os.makedirs(pkgdir)
|
|
|
|
|
2007-11-28 02:42:37 +00:00
|
|
|
probs = self.ayum.downloadPkgs(polist)
|
|
|
|
|
|
|
|
if len(probs.keys()) > 0:
|
|
|
|
self.log.error("Errors were encountered while downloading packages.")
|
|
|
|
for key in probs.keys():
|
|
|
|
errors = yum.misc.unique(probs[key])
|
|
|
|
for error in errors:
|
|
|
|
self.log.error("%s: %s" % (key, error))
|
|
|
|
sys.exit(1)
|
2007-09-12 14:08:04 +00:00
|
|
|
|
2007-11-28 02:42:37 +00:00
|
|
|
for po in polist:
|
2007-09-12 14:08:04 +00:00
|
|
|
basename = os.path.basename(po.relativepath)
|
|
|
|
|
2007-11-28 02:42:37 +00:00
|
|
|
local = po.localPkg()
|
2007-09-12 14:08:04 +00:00
|
|
|
target = os.path.join(pkgdir, basename)
|
|
|
|
|
2007-11-28 02:42:37 +00:00
|
|
|
# Link downloaded package in (or link package from file repo)
|
|
|
|
try:
|
|
|
|
pypungi._link(local, target, force=True)
|
2006-10-11 22:53:52 +00:00
|
|
|
continue
|
2007-11-28 02:42:37 +00:00
|
|
|
except:
|
|
|
|
self.logger.error("Unable to link %s from the yum cache." % po.name)
|
|
|
|
sys.exit(1)
|
2007-08-16 18:16:48 +00:00
|
|
|
|
|
|
|
self.logger.info('Finished downloading packages.')
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2007-09-12 14:08:04 +00:00
|
|
|
def downloadPackages(self):
|
|
|
|
"""Download the package objects obtained in getPackageObjects()."""
|
|
|
|
|
|
|
|
self._downloadPackageList(self.polist,
|
|
|
|
os.path.join(self.config.get('default', 'arch'),
|
|
|
|
self.config.get('default', 'osdir'),
|
|
|
|
self.config.get('default', 'product_path')))
|
|
|
|
|
2007-08-25 00:45:54 +00:00
|
|
|
def makeCompsFile(self):
|
|
|
|
"""Gather any comps files we can from repos and merge them into one."""
|
|
|
|
|
|
|
|
# get our list of repos
|
|
|
|
repos = self.ayum.repos.repos.values()
|
|
|
|
|
|
|
|
compsstub = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">\n<comps>\n'
|
|
|
|
|
|
|
|
closestub = '\n</comps>\n'
|
|
|
|
|
|
|
|
ourcompspath = os.path.join(self.workdir, '%s-%s-comps.xml' % (self.config.get('default', 'name'), self.config.get('default', 'version')))
|
|
|
|
|
|
|
|
ourcomps = open(ourcompspath, 'w')
|
|
|
|
|
|
|
|
ourcomps.write(compsstub)
|
|
|
|
|
|
|
|
# iterate through the list and get what comps we can.
|
|
|
|
# Strip the first three lines and the last line of substance off
|
|
|
|
# once done, write it to our comps file
|
|
|
|
for repo in repos:
|
|
|
|
try:
|
|
|
|
groupfile = repo.getGroups()
|
|
|
|
except yum.Errors.RepoMDError, e:
|
|
|
|
self.logger.warn("No group data found for %s" % repo.id)
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
compslines = open(groupfile, 'r').readlines()
|
|
|
|
for line in compslines:
|
|
|
|
if line.startswith('</comps>'):
|
|
|
|
end = compslines.index(line)
|
|
|
|
|
|
|
|
for line in compslines:
|
|
|
|
if line.startswith('<comps>'):
|
|
|
|
start = compslines.index(line) + 1
|
|
|
|
|
|
|
|
ourcomps.writelines(compslines[start:end])
|
|
|
|
|
|
|
|
ourcomps.write(closestub)
|
|
|
|
ourcomps.close()
|
|
|
|
|
|
|
|
# Run the xslt filter over our comps file
|
|
|
|
compsfilter = ['/usr/bin/xsltproc', '--novalid']
|
|
|
|
compsfilter.append('-o')
|
|
|
|
compsfilter.append(ourcompspath)
|
|
|
|
compsfilter.append('/usr/share/pungi/comps-cleanup.xsl')
|
|
|
|
compsfilter.append(ourcompspath)
|
|
|
|
|
|
|
|
pypungi._doRunCommand(compsfilter, self.logger)
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
def downloadSRPMs(self):
|
|
|
|
"""Cycle through the list of srpms and
|
|
|
|
find the package objects for them, Then download them."""
|
|
|
|
|
|
|
|
srpmpolist = []
|
|
|
|
|
|
|
|
for srpm in self.srpmlist:
|
2006-12-11 22:13:02 +00:00
|
|
|
(sname, sver, srel) = srpm.rsplit('-', 2)
|
2006-12-10 01:48:08 +00:00
|
|
|
try:
|
2007-08-21 16:40:44 +00:00
|
|
|
srpmpo = self.ayum.pkgSack.searchNevra(name=sname, ver=sver, rel=srel, arch='src')[0]
|
2006-12-10 01:48:08 +00:00
|
|
|
if not srpmpo in srpmpolist:
|
|
|
|
srpmpolist.append(srpmpo)
|
|
|
|
except IndexError:
|
|
|
|
print >> sys.stderr, "Error: Cannot find a source rpm for %s" % srpm
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# do the downloads
|
2007-09-12 14:08:04 +00:00
|
|
|
self._downloadPackageList(srpmpolist, os.path.join('source', 'SRPMS'))
|