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
|
2006-10-10 22:08:38 +00:00
|
|
|
|
2006-10-11 22:53:52 +00:00
|
|
|
class Gather(yum.YumBase):
|
2006-11-17 23:01:10 +00:00
|
|
|
def __init__(self, config, pkglist):
|
2007-02-16 14:37:52 +00:00
|
|
|
self.workdir = os.path.join(config.get('default', 'destdir'),
|
|
|
|
'work',
|
|
|
|
config.get('default', 'flavor'),
|
|
|
|
config.get('default', 'arch'))
|
|
|
|
|
2006-10-12 04:38:36 +00:00
|
|
|
# Create a yum object to use
|
2006-10-11 22:53:52 +00:00
|
|
|
yum.YumBase.__init__(self)
|
2007-02-14 22:33:07 +00:00
|
|
|
self.config = config
|
2007-02-16 14:37:52 +00:00
|
|
|
self.doConfigSetup(fn=config.get('default', 'yumconf'), debuglevel=6, errorlevel=6, root=os.path.join(self.workdir, 'yumroot'))
|
|
|
|
self.config.cachedir = os.path.join(self.workdir, 'yumcache')
|
2006-10-17 03:11:58 +00:00
|
|
|
self.cleanMetadata() # clean metadata that might be in the cache from previous runs
|
2006-10-17 05:38:16 +00:00
|
|
|
self.cleanSqlite() # clean metadata that might be in the cache from previous runs
|
2006-10-12 04:38:36 +00:00
|
|
|
self.doRepoSetup()
|
2007-01-23 23:03:52 +00:00
|
|
|
self.doTsSetup()
|
|
|
|
self.doRpmDBSetup()
|
2006-11-17 23:01:10 +00:00
|
|
|
if config.get('default', 'arch') == 'i386':
|
2006-10-17 06:07:51 +00:00
|
|
|
arches = yum.rpmUtils.arch.getArchList('i686')
|
2007-02-06 18:51:53 +00:00
|
|
|
self.compatarch = 'i686'
|
2006-12-12 17:21:28 +00:00
|
|
|
elif config.get('default', 'arch') == 'ppc':
|
|
|
|
arches = yum.rpmUtils.arch.getArchList('ppc64')
|
2007-02-06 18:51:53 +00:00
|
|
|
self.compatarch = 'ppc64'
|
2007-05-15 17:06:34 +00:00
|
|
|
elif config.get('default', 'arch') == 'sparc':
|
|
|
|
arches = yum.rpmUtils.arch.getArchList('sparc64v')
|
|
|
|
self.compatarch = 'sparc64v'
|
2006-10-17 06:07:51 +00:00
|
|
|
else:
|
2006-11-17 23:01:10 +00:00
|
|
|
arches = yum.rpmUtils.arch.getArchList(config.get('default', 'arch'))
|
2007-02-06 18:51:53 +00:00
|
|
|
self.compatarch = config.get('default', 'arch')
|
2007-03-02 15:24:03 +00:00
|
|
|
#self.doSackSetup(arches)
|
|
|
|
self.doSackSetup(archlist=arches) # work around temp break in yum api
|
2007-01-23 23:03:52 +00:00
|
|
|
self.doSackFilelistPopulate()
|
2006-10-23 19:50:44 +00:00
|
|
|
self.logger = yum.logging.getLogger("yum.verbose.pungi")
|
2006-10-12 14:37:34 +00:00
|
|
|
self.pkglist = pkglist
|
|
|
|
self.polist = []
|
2006-12-10 01:48:08 +00:00
|
|
|
self.srpmlist = []
|
2007-02-07 03:53:43 +00:00
|
|
|
self.resolved_deps = {} # list the deps we've already resolved, short circuit.
|
2007-03-02 04:06:41 +00:00
|
|
|
# Create a comps object and add our comps file for group definitions
|
2007-03-02 15:24:03 +00:00
|
|
|
self.compsobj = yum.comps.Comps()
|
|
|
|
self.compsobj.add(self.config.get('default', 'comps'))
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2007-02-14 22:33:07 +00:00
|
|
|
def doLoggingSetup(self, debuglevel, errorlevel):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Setup the logging facility."""
|
|
|
|
|
|
|
|
|
2007-02-14 22:33:07 +00:00
|
|
|
logdir = os.path.join(self.config.get('default', 'destdir'), 'logs')
|
|
|
|
if not os.path.exists(logdir):
|
|
|
|
os.makedirs(logdir)
|
2007-06-13 22:03:29 +00:00
|
|
|
if self.config.get('default', 'flavor'):
|
|
|
|
logfile = os.path.join(logdir, '%s.%s.log' % (self.config.get('default', 'flavor'),
|
|
|
|
self.config.get('default', 'arch')))
|
|
|
|
else:
|
|
|
|
logfile = os.path.join(logdir, '%s.log' % (self.config.get('default', 'arch')))
|
|
|
|
|
2007-02-15 19:17:39 +00:00
|
|
|
yum.logging.basicConfig(level=yum.logging.DEBUG, filename=logfile)
|
2007-02-14 22:33:07 +00:00
|
|
|
|
|
|
|
def doFileLogSetup(self, uid, logfile):
|
2007-02-15 19:17:39 +00:00
|
|
|
# This function overrides a yum function, allowing pungi to control
|
|
|
|
# the logging.
|
2007-02-14 22:33:07 +00:00
|
|
|
pass
|
|
|
|
|
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
|
|
|
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
2006-10-15 21:30:01 +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-03-15 18:17:53 +00:00
|
|
|
deps = self.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-03-15 20:40:01 +00:00
|
|
|
self.tsInfo.addInstall(dep)
|
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
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-03-02 04:06:41 +00:00
|
|
|
"""Get a list of package names from a comps object
|
|
|
|
|
|
|
|
Returns a list of package names"""
|
|
|
|
|
|
|
|
packages = []
|
|
|
|
optional = None
|
|
|
|
nodefaults = None
|
|
|
|
|
|
|
|
# Check for an option regarding default/optional packages
|
|
|
|
last = group.split()[-1]
|
|
|
|
if last == '--optional':
|
|
|
|
optional = True
|
|
|
|
group = group.split(' --optional')[0]
|
|
|
|
|
|
|
|
if last == '--nodefaults':
|
|
|
|
nodefaults = True
|
|
|
|
group = group.split(' --nodefaults')[0]
|
|
|
|
|
|
|
|
# Check if we have the group
|
2007-03-02 15:24:03 +00:00
|
|
|
if not self.compsobj.has_group(group):
|
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-03-02 15:24:03 +00:00
|
|
|
groupobj = self.compsobj.return_group(group)
|
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
|
|
|
|
if not nodefaults:
|
|
|
|
packages.extend(groupobj.default_packages.keys())
|
|
|
|
|
|
|
|
# Add the optional packages if we want them
|
|
|
|
if optional:
|
|
|
|
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():
|
|
|
|
pkgs = self.pkgSack.searchNevra(name=condreq)
|
|
|
|
if pkgs:
|
|
|
|
pkgs = self.bestPackagesFromList(pkgs)
|
|
|
|
if self.tsInfo.conditionals.has_key(cond):
|
|
|
|
self.tsInfo.conditionals[cond].extend(pkgs)
|
|
|
|
else:
|
|
|
|
self.tsInfo.conditionals[cond] = pkgs
|
|
|
|
|
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
|
|
|
|
|
|
|
grouplist = []
|
|
|
|
excludelist = []
|
|
|
|
addlist = []
|
|
|
|
|
|
|
|
# Cycle through the package list and pull out the groups
|
|
|
|
for line in self.pkglist:
|
2007-03-02 15:24:03 +00:00
|
|
|
line = line.strip()
|
|
|
|
if line.startswith('#'):
|
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('Skipping comment: %s' % line)
|
2007-03-02 04:06:41 +00:00
|
|
|
continue
|
|
|
|
if line.startswith('@'):
|
2007-03-02 15:24:03 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('Adding group: %s' % line)
|
2007-03-02 04:06:41 +00:00
|
|
|
grouplist.append(line.strip('@'))
|
|
|
|
continue
|
|
|
|
if line.startswith('-'):
|
2007-03-02 15:24:03 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('Adding exclude: %s' % line)
|
2007-03-02 04:06:41 +00:00
|
|
|
excludelist.append(line.strip('-'))
|
|
|
|
continue
|
|
|
|
else:
|
2007-03-02 15:24:03 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('Adding package: %s' % line)
|
2007-03-02 04:06:41 +00:00
|
|
|
addlist.append(line)
|
|
|
|
|
2007-03-15 17:35:05 +00:00
|
|
|
# First remove the excludes
|
|
|
|
self.conf.exclude.extend(excludelist)
|
|
|
|
self.excludePackages()
|
|
|
|
|
|
|
|
# Get a list of packages from groups
|
2007-03-02 04:06:41 +00:00
|
|
|
for group in 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
|
|
|
|
searchlist.extend(addlist)
|
|
|
|
|
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-03-02 15:24:03 +00:00
|
|
|
(exactmatched, matched, unmatched) = yum.packages.parsePackages(self.pkgSack.returnPackages(), searchlist, casematch=1)
|
2007-02-09 01:25:41 +00:00
|
|
|
matches = exactmatched + matched
|
|
|
|
|
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-03-15 18:25:24 +00:00
|
|
|
self.tsInfo.addInstall(match)
|
2007-03-15 20:25:57 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('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-03-15 18:25:24 +00:00
|
|
|
self.logger.warn('Could not find a match for %s' % pkg)
|
2007-02-09 01:25:41 +00:00
|
|
|
|
2007-03-15 20:25:57 +00:00
|
|
|
if len(self.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-03-15 20:25:57 +00:00
|
|
|
for txmbr in self.tsInfo:
|
|
|
|
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()
|
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)
|
|
|
|
|
|
|
|
|
2006-10-12 14:37:34 +00:00
|
|
|
def downloadPackages(self):
|
2006-10-11 22:53:52 +00:00
|
|
|
"""Cycle through the list of package objects and
|
|
|
|
download them from their respective repos."""
|
|
|
|
|
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
2006-10-12 04:38:36 +00:00
|
|
|
downloads = []
|
2006-10-12 14:37:34 +00:00
|
|
|
for pkg in self.polist:
|
2006-10-16 03:59:41 +00:00
|
|
|
downloads.append('%s.%s' % (pkg.name, pkg.arch))
|
2006-10-16 04:42:43 +00:00
|
|
|
downloads.sort()
|
2006-10-12 04:38:36 +00:00
|
|
|
self.logger.info("Download list: %s" % downloads)
|
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
# Package location within destdir, name subject to change/config
|
|
|
|
pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
|
2007-01-25 04:42:40 +00:00
|
|
|
self.config.get('default', 'flavor'),
|
|
|
|
self.config.get('default', 'arch'),
|
|
|
|
self.config.get('default', 'osdir'),
|
2006-11-20 14:52:27 +00:00
|
|
|
self.config.get('default', 'product_path'))
|
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)
|
|
|
|
|
2006-10-12 14:37:34 +00:00
|
|
|
for pkg in self.polist:
|
2006-10-11 22:53:52 +00:00
|
|
|
repo = self.repos.getRepo(pkg.repoid)
|
2007-02-06 18:54:06 +00:00
|
|
|
remote = pkg.relativepath
|
2006-10-11 22:53:52 +00:00
|
|
|
local = os.path.basename(remote)
|
2006-11-17 23:01:10 +00:00
|
|
|
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
2007-05-24 06:06:25 +00:00
|
|
|
if os.path.exists(local) and self.verifyCachePkg(pkg, local):
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
2006-10-11 22:53:52 +00:00
|
|
|
self.logger.info("%s already exists and appears to be complete" % local)
|
2007-02-13 22:20:01 +00:00
|
|
|
target = os.path.join(pkgdir, os.path.basename(remote))
|
2007-02-12 21:29:19 +00:00
|
|
|
if os.path.exists(target):
|
|
|
|
os.remove(target) # avoid traceback after interrupted download
|
2007-02-12 20:57:58 +00:00
|
|
|
os.link(local, target)
|
2006-10-11 22:53:52 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
# Disable cache otherwise things won't download
|
|
|
|
repo.cache = 0
|
2006-11-17 23:01:10 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
2006-10-11 22:53:52 +00:00
|
|
|
self.logger.info('Downloading %s' % os.path.basename(remote))
|
|
|
|
pkg.localpath = local # Hack: to set the localpath to what we want.
|
2006-11-17 19:02:37 +00:00
|
|
|
|
|
|
|
# do a little dance for file:// repos...
|
|
|
|
path = repo.getPackage(pkg)
|
|
|
|
if not os.path.exists(local) or not os.path.samefile(path, local):
|
|
|
|
shutil.copy2(path, local)
|
|
|
|
|
2006-10-14 23:11:46 +00:00
|
|
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
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 = []
|
|
|
|
|
|
|
|
# Work around for yum bug
|
|
|
|
for sack in self.pkgSack.sacks.values():
|
2007-02-26 18:06:31 +00:00
|
|
|
sack.added = {}
|
2006-12-10 01:48:08 +00:00
|
|
|
sack.excludes = {}
|
|
|
|
|
|
|
|
self.pkgSack.excludes = {}
|
|
|
|
|
|
|
|
# We need to reset the yum object
|
|
|
|
self.pkgSack = None
|
|
|
|
|
|
|
|
# Setup the sack with just src arch
|
|
|
|
self.doSackSetup(archlist=['src'])
|
|
|
|
|
|
|
|
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:
|
2006-12-10 02:31:00 +00:00
|
|
|
srpmpo = self.pkgSack.searchNevra(name=sname, ver=sver, rel=srel)[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
|
|
|
|
pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
|
2007-01-25 04:42:40 +00:00
|
|
|
self.config.get('default', 'flavor'), 'source', 'SRPMS')
|
2006-12-10 01:48:08 +00:00
|
|
|
|
|
|
|
if not os.path.exists(pkgdir):
|
|
|
|
os.makedirs(pkgdir)
|
|
|
|
|
|
|
|
for pkg in srpmpolist:
|
|
|
|
repo = self.repos.getRepo(pkg.repoid)
|
2007-02-06 18:54:06 +00:00
|
|
|
remote = pkg.relativepath
|
2006-12-10 01:48:08 +00:00
|
|
|
local = os.path.basename(remote)
|
|
|
|
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
2007-05-24 06:06:25 +00:00
|
|
|
if os.path.exists(local) and self.verifyCachePkg(pkg, local):
|
2006-12-10 01:48:08 +00:00
|
|
|
|
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info("%s already exists and appears to be complete" % local)
|
2007-05-25 22:50:37 +00:00
|
|
|
if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and self.verifyCachePkg(pkg, os.path.join(pkgdir, os.path.basename(remote))):
|
2006-12-10 01:48:08 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info("%s already exists in tree and appears to be complete" % local)
|
|
|
|
else:
|
|
|
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Disable cache otherwise things won't download
|
|
|
|
repo.cache = 0
|
|
|
|
if not self.config.has_option('default', 'quiet'):
|
|
|
|
self.logger.info('Downloading %s' % os.path.basename(remote))
|
|
|
|
pkg.localpath = local # Hack: to set the localpath to what we want.
|
|
|
|
|
|
|
|
# do a little dance for file:// repos...
|
|
|
|
path = repo.getPackage(pkg)
|
|
|
|
if not os.path.exists(local) or not os.path.samefile(path, local):
|
|
|
|
shutil.copy2(path, local)
|
|
|
|
|
|
|
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|