diff options
author | Will Woods <wwoods@redhat.com> | 2009-02-18 18:54:11 -0500 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2009-02-18 18:54:11 -0500 |
commit | 02a4a42ce3ae80b94dd2af32c61a4ef97f328168 (patch) | |
tree | d3577378e76a92aa97372939ae207d7c467c3ab1 /debuginfofs-mirror | |
parent | 1ae8e3c7328352ba78f2ad982cd5b0c7a1bd18e5 (diff) | |
download | debuginfofs-02a4a42ce3ae80b94dd2af32c61a4ef97f328168.tar.gz debuginfofs-02a4a42ce3ae80b94dd2af32c61a4ef97f328168.tar.xz debuginfofs-02a4a42ce3ae80b94dd2af32c61a4ef97f328168.zip |
New yum-based debuginfo downloader (in progress)
Diffstat (limited to 'debuginfofs-mirror')
-rwxr-xr-x | debuginfofs-mirror | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/debuginfofs-mirror b/debuginfofs-mirror new file mode 100755 index 0000000..5433a77 --- /dev/null +++ b/debuginfofs-mirror @@ -0,0 +1,101 @@ +#!/usr/bin/python +# Given Fedora arch and version, fetch all debuginfo packages from the mirrors +# Copyright 2009 Red Hat, Inc. +# +# 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 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Author: Will Woods <wwoods@redhat.com> + +import os +import sys +import logging +import optparse +import ConfigParser +sys.path.insert(0,'/usr/share/yum-cli') +from utils import YumUtilBase +from yum.parser import varReplace +from yum.yumRepo import YumRepository + +configfile = '/etc/debuginfofs.conf' +c = ConfigParser.RawConfigParser() +try: + c.read(configfile) + conf = dict(c.items('general')) +except (IOError, + ConfigParser.MissingSectionHeaderError, + ConfigParser.NoSectionError): + print "Error: no 'cachedir' in %s" % configfile + sys.exit(1) + +# FIXME get these from commandline (and validate 'em) +conf['releasever']='10' +conf['basearch']='i386' + +repolist=('fedora','fedora-updates','fedora-updates-testing') + +class DebuginfoFSDownloader(YumUtilBase): + NAME = 'debuginfofs-mirror' + VERSION = '0.1' + USAGE = 'usage: %s' % NAME # XXX update this + def __init__(self): + YumUtilBase.__init__(self, + DebuginfoFSDownloader.NAME, + DebuginfoFSDownloader.VERSION, + DebuginfoFSDownloader.USAGE) + self.logger = logging.getLogger("yum.verbose.cli.debuginfofs") + +y = DebuginfoFSDownloader() +y.doConfigSetup() +# TODO check for RepoError +# Kinda stupid, setting up and then immediately tearing down all repos.. +y.repos.disableRepo('*') +# No yum cache needed, since we're saving the packages ourselves +y.repos.setCacheDir(conf['cachedir']) +y.conf.cache = 0 +y.repos.setCache(0) +# TODO: optionally allow caching? +# kind of a cheap hack +my_yumvar = y.conf.yumvar +my_yumvar.update(conf) + +for repoid in repolist: + try: + d = dict([(k,varReplace(v,my_yumvar)) for k,v in c.items(repoid)]) + except ConfigParser.NoSectionError: + print "No section named %s in config" % repoid + continue + if 'mirrorlist' in d: + print "Adding repo %s with mirrorlist %s" % (repoid,d['mirrorlist']) + repo = YumRepository(repoid + '-debuginfofs') + repo.name = repo.id + repo.mirrorlist = d['mirrorlist'] + repo.cache = 0 + repo.enable() + y.repos.add(repo) + y.repos.doSetup(thisrepo=repo.id) + + packages = y.pkgSack.returnPackages() + for p in packages: + repo = y.repos.getRepo(p.repoid) + remote = p.returnSimple('relativepath') + local = os.path.join(conf['cachedir'],os.path.basename(remote)) + p.localpath = local + # TODO: Check to see if we've already got it in cache + # TODO: Check to see if it's already unpacked + # Download + #path = repo.getPackage(p) + # TODO: Unpack + # TODO: Remove cached package + # TODO: Hardlink |