# Copyright (C) 2009 One Laptop Per Child # Licensed under the terms of the GNU GPL v2 or later; see COPYING for details. import os import sys from gzip import GzipFile from StringIO import StringIO import ooblib addrepos = [] excludes = set() farch = ooblib.read_config('global', 'fedora_arch').strip() # read in repos for var in os.environ: if not var.startswith("CFG_yumcfg__addrepo"): continue value = os.environ[var] for_excludes, name, url = value.split(',', 2) for_excludes = bool(int(for_excludes)) addrepos.append((for_excludes, name, url)) # generate excludes info for for_excludes, name, url in addrepos: if not for_excludes: continue fd = ooblib.cachedurlopen(url + "/repodata/primary.xml.gz") data = fd.read() fd.close() fd = GzipFile(fileobj=StringIO(data)) ooblib.add_packages_from_xml(fd, excludes, farch) # write shell code to generate yum repo files for for_excludes, name, url in addrepos: print "cat > /etc/yum.repos.d/%s.repo < /etc/yum/olpc-exclude <