extras-buildsys/utils/pushscript RepoSupport.py, NONE, 1.1 RepoSupportExample.py, NONE, 1.1 Config_Extras.py, 1.3, 1.4 MultiLib.py, 1.2, 1.3

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Sat Sep 30 18:34:17 UTC 2006


Author: mschwendt

Update of /cvs/fedora/extras-buildsys/utils/pushscript
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18403

Modified Files:
	Config_Extras.py MultiLib.py 
Added Files:
	RepoSupport.py RepoSupportExample.py 
Log Message:
merge more (now configurable) stuff



--- NEW FILE RepoSupport.py ---
#!/usr/bin/python
# -*- mode: Python; indent-tabs-mode: nil; -*-
#
# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import os, tempfile

class RepoSupport:
    """helper functions and constants for yum/repomd usage"""
    
    def __init__(self,cfg):
        # List of distribution release names in repository.
        self.allreleases = cfg.alldists
        
        # Architecture directory names per distribution release in repository.
        self.archdict = cfg.archdict

        self.baserepos = cfg.baserepos
        self.testrepos = cfg.testrepos
        self.reponames = cfg.reponames
        self.repourls = cfg.repourls
        
    def AllReleases(self):
        """return list of all distribution release names"""
        return self.allreleases

    def ReleaseArchsDict(self):
        """return map with list of architectures per release"""
        return self.archdict

    def ReleaseRepoList(self,dist):
        """return list of repository base-ids for the given release"""
        return self.baserepos.get(dist) or []

    def RepoName(self, repo, release, arch):
        name = self.reponames.get(repo) or None
        if name:
            return '%s %s - %s' % (name,release,arch)
        else:
            return ''
    
    def RepoNamesDict(self):
        """return map with list of repository descriptions per release"""
        return self.reponames

    def GenerateConfig(self, releases, cachedir=''):
        """return temporary yum.conf with repository definitions for the
        specified releases"""
        try:
            (fd, conffile) = tempfile.mkstemp()
        except:
            conffile = tempfile.mktemp()
        fd = os.open(conffile,os.O_RDWR|os.O_CREAT)
        confheader = """[main]
cachedir=%s
debuglevel=2
logfile=/dev/null
pkgpolicy=newest
reposdir=/dev/null
exactarch=1
obsoletes=1
retries=20

""" % (cachedir)
        os.write(fd,confheader)
        for release in releases:
            assert release in self.AllReleases()
            for repo in self.baserepos[release]+self.testrepos[release]:
                for arch in self.archdict[release]:
                    reposection = """[%s]
name=%s
baseurl=%s
enabled=0

""" % (self.RepoId(repo,release,arch),
       self.RepoName(repo,release,arch),
       self.repourls[repo] % (release,arch))
                    os.write(fd,reposection)
                
        os.close(fd)
        return conffile

    def RepoId(self, repo, release, arch):
        return '%s-%s-%s' % (repo,release,arch)
    
    def GenerateRepoIds(self, release, testing=False):
        """return list of all repository ids for the specified release"""
        repoids = []
        assert release in self.AllReleases()
        for arch in self.archdict[release]:
            for r in self.baserepos[release]:
                repoid = self.RepoId(r,release,arch)
                repoids.append(repoid)
            if testing:
                for r in self.testrepos[release]:
                    repoid = self.RepoId(r,release,arch)
                    repoids.append(repoid)
        return repoids



--- NEW FILE RepoSupportExample.py ---
#!/usr/bin/python
# -*- mode: Python; indent-tabs-mode: nil; -*-

import os
import Utils, RepoSupport

if __name__ == '__main__':
    cfg = Utils.load_config_module('Extras')
    rs = RepoSupport.RepoSupport(cfg)
    print rs.AllReleases()
    print rs.GenerateRepoIds('5',testing=True)
    print rs.GenerateRepoIds('3')
    print rs.ReleaseArchsDict()['development']
    print rs.ReleaseRepoList('5')
    print rs.RepoNamesDict()['fedora-core']
    conf = rs.GenerateConfig(['5','4'])
    print conf
    os.system('cat %s' % conf)
    os.remove(conf)


Index: Config_Extras.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Config_Extras.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Config_Extras.py	29 Sep 2006 23:53:41 -0000	1.3
+++ Config_Extras.py	30 Sep 2006 18:34:14 -0000	1.4
@@ -53,9 +53,9 @@
 # map: dist -> target arch -> list of pkg name regexp patterns
 # We don't check virtual package names, unless it's a virtual -devel pkg.
 # black-list takes precedence over white-list
-blacklists = { 'development' : { 'x86_64' : [] },
+multiblacklists = { 'development' : { 'x86_64' : [] },
                }
-whitelists = { 'development' : { 'x86_64' : [ 'wine', 'wine-arts', 'wine-devel' ] },
+multiwhitelists = { 'development' : { 'x86_64' : [ 'wine', 'wine-arts', 'wine-devel' ] },
                # 'development' : { 'x86_64' : [ '.*-devel', 'wine', 'wine-arts', 'wine-devel' ] },
                #'6' : { 'x86_64' : [ 'wine', 'wine-arts', 'wine-devel' ] },
                '5' : { 'x86_64' : [ 'wine', 'wine-arts', 'wine-devel' ] },
@@ -73,6 +73,35 @@
 # repository symlinks to remove/create since they confuse createrepo
 repobuild_linkdict = {}
 
+# For RepoSupport.py features.
+baserepos = { '3' : ['fedora-core','fedora-core-updates','fedora-extras'],
+              '4' : ['fedora-core','fedora-core-updates','fedora-extras'],
+              '5' : ['fedora-core','fedora-core-updates','fedora-extras'],
+              'development' : ['fedora-core','fedora-extras']
+              }
+
+# For RepoSupport.py features.
+testrepos = { '3' : ['fedora-core-updates-testing'],
+              '4' : ['fedora-core-updates-testing'],
+              '5' : ['fedora-core-updates-testing'],
+              'development' : []
+              }
+
+# For RepoSupport.py features.
+reponames = { 'fedora-core' : 'Fedora Core',
+              'fedora-core-updates' : 'Fedora Core Released Updates',
+              'fedora-core-updates-testing' : 'Fedora Core Test Updates',
+              'fedora-extras' : 'Fedora Extras'
+              }
+
+# For RepoSupport.py features.
+# (%s, %s) = (release, arch)
+repourls = { 'fedora-core' : 'http://download.fedora.redhat.com/pub/fedora/linux/core/%s/%s/os/',
+             'fedora-core-updates' : 'http://download.fedora.redhat.com/pub/fedora/linux/core/updates/%s/%s/',
+             'fedora-core-updates-testing' : 'http://download.fedora.redhat.com/pub/fedora/linux/core/updates/testing/%s/%s/',
+             'fedora-extras' : 'file:///srv/rpmbuild/extras/tree/extras/%s/%s/'
+             }
+
 sync_cmd = 'extras-sync'
 
 createrepo = '/usr/bin/createrepo'


Index: MultiLib.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/MultiLib.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MultiLib.py	29 Sep 2006 16:18:42 -0000	1.2
+++ MultiLib.py	30 Sep 2006 18:34:14 -0000	1.3
@@ -19,7 +19,7 @@
 import glob, pickle, re
 import rpm, rpmUtils.arch, rpmUtils.transaction, rpmUtils.miscutils
 
-import Utils
+import Utils, RepoSupport
 
 # TODO
 sys.path.insert(0,'/srv/extras-push/work/extras-repoclosure')
@@ -29,7 +29,6 @@
     from yum.packageSack import ListPackageSack
 except: # yum < 2.9
     from repomd.packageSack import ListPackageSack
-from RepoSupport import RepoSupport
 
 DEBUG = False
 Utils.setdebug(DEBUG)
@@ -49,12 +48,12 @@
     a package can have virtual names, this takes a list of names as input.
     Returns: True or False"""
     for n in namelist:
-        if cfg.blacklists.has_key(dist) and cfg.blacklists[dist].has_key(targetarch):
-            for r in cfg.blacklists[dist][targetarch]:
+        if cfg.multiblacklists.has_key(dist) and cfg.multiblacklists[dist].has_key(targetarch):
+            for r in cfg.multiblacklists[dist][targetarch]:
                 if re.compile('^'+r+'$').search(n):
                     return False
-        if cfg.whitelists.has_key(dist) and cfg.whitelists[dist].has_key(targetarch):
-            for r in cfg.whitelists[dist][targetarch]:
+        if cfg.multiwhitelists.has_key(dist) and cfg.multiwhitelists[dist].has_key(targetarch):
+            for r in cfg.multiwhitelists[dist][targetarch]:
                 if re.compile('^'+r+'$').search(n):
                     return True
     return False # reject by default
@@ -229,22 +228,22 @@
     missingdict[targetarch].setdefault('rpms',[])
     missingdict[targetarch].setdefault('debug',[])
     
-    rs = RepoSupport()  # TODO
+    rs = RepoSupport.RepoSupport(cfg)
     conf = rs.GenerateConfig([dist])
 
     repoids = []
     srcarch = rpmUtils.arch.getBaseArch( rpmUtils.arch.multilibArches[targetarch][0] )
     # Only look at basearch repo.
     a = srcarch
-    for r in rs.ReleaseRepoDict()[dist]:
-        if r.find('extras') < 0:
+    for r in rs.ReleaseRepoList(dist):
+        if r.find(cfg.project) < 0:  # only look at our project's repos
             continue
-        repoid = '%s-%s-%s' % (r,dist,a)
-        repoids.append(repoid)
+        repoids.append(rs.RepoId(r,dist,a))
     print repoids
 
     # Only look at multicompat packages.
     my = Resolver(arch = srcarch, config = conf)
+    os.remove(conf)
     for repo in my.repos.repos.values():
         if repo.id not in repoids:
             repo.disable()




More information about the scm-commits mailing list