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'
|
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-02-15 19:17:39 +00:00
|
|
|
logfile = os.path.join(logdir, '%s.%s.log' % (self.config.get('default', 'flavor'),
|
|
|
|
self.config.get('default', 'arch')))
|
|
|
|
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-01-23 23:03:52 +00:00
|
|
|
def _provideToPkg(self, req): #this is stolen from Anaconda
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Return a list of best possible providers for a requirement.
|
|
|
|
|
|
|
|
Returns a list or None"""
|
|
|
|
|
|
|
|
|
2007-02-15 21:25:52 +00:00
|
|
|
bestlist = None
|
|
|
|
(r, f, v) = req
|
|
|
|
|
|
|
|
satisfiers = []
|
|
|
|
for po in self.whatProvides(r, f, v):
|
|
|
|
# if we already have something installed which does the provide
|
|
|
|
# then that's obviously the one we want to use. this takes
|
|
|
|
# care of the case that we select, eg, kernel-smp and then
|
|
|
|
# have something which requires kernel
|
|
|
|
if self.tsInfo.getMembers(po.pkgtup):
|
|
|
|
return [po]
|
|
|
|
if po not in satisfiers:
|
|
|
|
satisfiers.append(po)
|
|
|
|
|
|
|
|
if satisfiers:
|
|
|
|
bestlist = self.bestPackagesFromList(satisfiers, arch=self.compatarch)
|
|
|
|
return bestlist
|
|
|
|
return None
|
2007-01-23 23:03:52 +00:00
|
|
|
|
2006-10-16 04:42:43 +00:00
|
|
|
def getPackageDeps(self, po):
|
2006-10-11 22:53:52 +00:00
|
|
|
"""Return the dependencies for a given package, as well
|
|
|
|
possible solutions for those dependencies.
|
|
|
|
|
2006-10-12 04:38:36 +00:00
|
|
|
Returns the deps as a list"""
|
|
|
|
|
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-16 22:29:12 +00:00
|
|
|
pkgresults = {}
|
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-01-24 21:27:28 +00:00
|
|
|
deps = self._provideToPkg(req)
|
|
|
|
if deps is None:
|
2007-01-23 23:03:52 +00:00
|
|
|
self.logger.warning("Unresolvable dependency %s in %s" % (r, po.name))
|
2006-10-11 22:53:52 +00:00
|
|
|
continue
|
|
|
|
|
2007-01-24 21:27:28 +00:00
|
|
|
for dep in deps:
|
|
|
|
if not pkgresults.has_key(dep):
|
|
|
|
pkgresults[dep] = None
|
|
|
|
self.tsInfo.addInstall(dep)
|
2007-02-07 03:53:43 +00:00
|
|
|
|
|
|
|
self.resolved_deps[req] = None
|
2006-10-11 22:53:52 +00:00
|
|
|
|
2006-10-16 22:29:12 +00:00
|
|
|
return pkgresults.keys()
|
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())
|
|
|
|
|
|
|
|
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
|
|
|
unprocessed_pkgs = {} # list of packages yet to depsolve ## Use dicts for speed
|
|
|
|
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
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
# First, get a list of packages from groups
|
|
|
|
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)
|
|
|
|
|
|
|
|
# Remove the excludes
|
|
|
|
for exclude in excludelist:
|
|
|
|
for x in range(searchlist.count(exclude)): # why is there no list.removeall?
|
|
|
|
searchlist.remove(exclude)
|
2006-10-12 04:38:36 +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-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-02 04:06:41 +00:00
|
|
|
# Get the newest results from the search, if not "excluded" (catches things added by globs)
|
2007-02-09 01:25:41 +00:00
|
|
|
mysack = yum.packageSack.ListPackageSack(matches)
|
|
|
|
for match in mysack.returnNewestByNameArch():
|
2007-03-02 04:06:41 +00:00
|
|
|
if not match.name in excludelist:
|
|
|
|
unprocessed_pkgs[match] = None
|
|
|
|
self.tsInfo.addInstall(match)
|
2006-10-16 03:03:45 +00:00
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
if not self.config.has_option('default', 'quiet'):
|
2006-10-16 05:11:08 +00:00
|
|
|
for pkg in unprocessed_pkgs.keys():
|
2006-10-16 03:03:45 +00:00
|
|
|
self.logger.info('Found %s.%s' % (pkg.name, pkg.arch))
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2007-02-09 01:25:41 +00:00
|
|
|
for pkg in unmatched:
|
|
|
|
self.logger.warn('Could not find a match for %s' % pkg)
|
|
|
|
|
2006-10-12 04:38:36 +00:00
|
|
|
if len(unprocessed_pkgs) == 0:
|
|
|
|
raise yum.Errors.MiscError, 'No packages found to download.'
|
|
|
|
|
|
|
|
while len(unprocessed_pkgs) > 0: # Our fun loop
|
2006-10-16 05:11:08 +00:00
|
|
|
for pkg in unprocessed_pkgs.keys():
|
|
|
|
if not final_pkgobjs.has_key(pkg):
|
|
|
|
final_pkgobjs[pkg] = None # Add the pkg to our final list
|
2006-10-16 04:42:43 +00:00
|
|
|
deplist = self.getPackageDeps(pkg) # Get the deps of our package
|
2006-10-12 04:38:36 +00:00
|
|
|
|
|
|
|
for dep in deplist: # Cycle through deps, if we don't already have it, add it.
|
2006-10-16 05:11:08 +00:00
|
|
|
if not unprocessed_pkgs.has_key(dep) and not final_pkgobjs.has_key(dep):
|
|
|
|
unprocessed_pkgs[dep] = None
|
2006-10-12 04:38:36 +00:00
|
|
|
|
2006-10-16 05:11:08 +00:00
|
|
|
del unprocessed_pkgs[pkg] # Clear the package out of our todo list.
|
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)
|
2006-10-11 22:53:52 +00:00
|
|
|
if (os.path.exists(local) and
|
2007-02-06 18:54:06 +00:00
|
|
|
str(os.path.getsize(local)) == pkg.packagesize):
|
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-02-06 18:54:06 +00:00
|
|
|
if os.path.exists(local) and str(os.path.getsize(local)) == pkg.packagesize:
|
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-02-06 18:54:06 +00:00
|
|
|
if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and str(os.path.getsize(os.path.join(pkgdir, os.path.basename(remote)))) == pkg.packagesize:
|
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)))
|