extras-buildsys/utils/pushscript Config_Extras.py, 1.8, 1.9 Push.py, 1.6, 1.7 RepoBuild.py, 1.2, 1.3 Utils.py, 1.2, 1.3 MultiLib.py, 1.8, 1.9

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Tue Oct 24 20:28:21 UTC 2006


Author: mschwendt

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

Modified Files:
	Config_Extras.py Push.py RepoBuild.py Utils.py MultiLib.py 
Log Message:
Utils.py:
- make the create_repo* helper functions more flexible
- add reusable *repodirs functions

RepoBuild.py, MultiLib.py:
- use the modified Utils.create_repository()

Push.py, Config_*.py:
- make it possible to divert signed packages and install them into
  a place outside the default repository
- use new Utils.*repodirs() functions




Index: Config_Extras.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Config_Extras.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Config_Extras.py	23 Oct 2006 23:00:19 -0000	1.8
+++ Config_Extras.py	24 Oct 2006 20:28:19 -0000	1.9
@@ -74,6 +74,9 @@
 # repository symlinks to remove/create since they confuse createrepo
 repobuild_linkdict = {}
 
+diversion_dict = { 'mugshot' : stagesdir+'/fedora-extras'+'/mugshot',
+                   }
+
 # For RepoSupport.py features (TODO: use rpmUtils?)
 targetarchs = { 'i386' : 'i686',
                 'x86_64' : 'x86_64',


Index: Push.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Push.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Push.py	23 Oct 2006 11:24:35 -0000	1.6
+++ Push.py	24 Oct 2006 20:28:19 -0000	1.7
@@ -292,11 +292,11 @@
     pass
 
 
-def push(dist,needsignroot,destroot,name,pkgrelroot):
+def push(dist,needsignroot,destroot,name,pkgrelroot,buildreport=True):
     """push the files found within a single package build-results directory"""
     rollback = []
     try:
-        push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot)
+        push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot,buildreport)
     except:
         print 'ERROR: Rollback:', rollback
         for f in rollback:
@@ -309,7 +309,7 @@
         raise
 
 
-def push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot):
+def push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot,buildreport):
     print '  %s-%s' % (name,os.path.basename(pkgrelroot))
     
     filedict = {}
@@ -401,7 +401,8 @@
     # Mark successfully signed packages as PUSHED.
     mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
     rollback = []
-    rundirfile.write(buildreportinfo)
+    if buildreport:
+        rundirfile.write(buildreportinfo)
     rundirfile.close()
     
 
@@ -413,13 +414,11 @@
     distdir = '%s-%s-%s' % (cfg.distro, dist, cfg.project)
     needsignroot = os.path.join(cfg.stagesdir, distdir)
     destroot = os.path.join(cfg.treedir, dist)
+    if not DEBUG and not os.path.exists(destroot):
+        os.makedirs(destroot)
     changed = False
     
-    repodirs = [os.path.join(destroot, 'SRPMS')]
-    for arch in cfg.archdict[dist]:
-        repodirs.append(os.path.join(destroot, arch))
-        repodirs.append(os.path.join(destroot, arch, 'debug'))
-    for repodir in repodirs:
+    for repodir in Utils.get_std_repodirs(cfg,dist,destroot):
         # We check for changes already here in case the repo has changed
         # due to external activities such as removing files etc, and will
         # recheck it again later if needed when we're done with this sign
@@ -484,8 +483,17 @@
         results = get_build_results(signtmpdir)
         for (name,pkgrelroots) in results:
             for pkgrelroot in pkgrelroots:
+                if name in cfg.diversion_dict:  # install this elsewhere?
+                    buildreport = False
+                    targetroot = os.path.join(cfg.diversion_dict[name],dist)
+                    if os.path.exists(targetroot):
+                        shutil.rmtree(targetroot)
+                    Utils.make_std_repodirs(cfg,dist,targetroot)
+                else:
+                    buildreport = True
+                    targetroot = destroot
                 try:
-                    push(dist,needsignroot,destroot,name,pkgrelroot)
+                    push(dist,needsignroot,targetroot,name,pkgrelroot,buildreport)
                 except PushWarning, e:
                     print e
     except:
@@ -497,7 +505,7 @@
 
     # All done, now check if something changed unless we already know it did:
     if not changed:
-        for repodir in repodirs:
+        for repodir in Utils.get_std_repodirs(cfg,dist,destroot):
             changed = Utils.is_repo_changed(repodir)
             if changed:
                 Utils.debugprint("Dist %s (%s) was changed" % (dist, repodir))


Index: RepoBuild.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/RepoBuild.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RepoBuild.py	29 Sep 2006 23:53:41 -0000	1.2
+++ RepoBuild.py	24 Oct 2006 20:28:19 -0000	1.3
@@ -23,16 +23,18 @@
         print "No distribution release named '%s' found" % dist
         sys.exit(errno.EINVAL)
 
-    Utils.create_src_repo(cfg,dist)  # source rpms
+    reporoot = os.path.join(cfg.treedir, dist)
+    repodir = os.path.join(reporoot,'SRPMS')
+    Utils.create_repository(cfg,repodir,debuginfo=False)  # source rpms
 
     # get rid of symlinks that are in the way (of createrepo)
     for link in cfg.repobuild_linkdict.get(dist) or []:
-        flink = os.path.join(cfg.treedir, dist, link)
+        flink = os.path.join(reporoot, link)
         if os.path.exists(flink):
             os.unlink(flink)
 
     for arch in cfg.archdict[dist]:
-        Utils.create_arch_repo(cfg,dist,arch)  # binary+debuginfo rpms
+        Utils.create_repository(cfg,os.path.join(reporoot,arch))  # binary+debuginfo rpms
 
     # recreate symlinks
     for link in cfg.repobuild_linkdict.get(dist) or []:


Index: Utils.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Utils.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Utils.py	29 Sep 2006 16:23:13 -0000	1.2
+++ Utils.py	24 Oct 2006 20:28:19 -0000	1.3
@@ -111,8 +111,9 @@
         install_copy(src,dest)
 
 
-def create_repository(cfg,repodir):
-    """create/update repository metadata for a given directory"""
+def create_repository(cfg,repodir,debuginfo=True):
+    """create/update repository metadata for a given directory and
+    consider a 'debug' sub-repository by default"""
 
     print 'Creating repository %s' % repodir
     
@@ -131,26 +132,17 @@
     if os.path.exists( os.path.join(repodir,compsname) ):
         compsarg = '-g %s ' % compsname
     excludearg = ''
-    if os.path.exists( os.path.join(repodir,'debug') ):
+    if debuginfo and os.path.exists( os.path.join(repodir,'debug') ):
         excludearg = "-x \'*debuginfo*\'"
     cmd = '%s -c %s -q %s %s %s' % (cfg.createrepo, cfg.cr_cachedir, compsarg, excludearg, repodir)
     run_and_check(cmd)
-
-
-def create_arch_repo(cfg,dist,arch):
-    """create/update repository metadata for a given dist+arch pair and
-its 'debug' sub-directory, if available"""
-    repodir = os.path.join(cfg.treedir, dist, arch)
-    create_repository(cfg,repodir)
-    # If there's a debug subdir, make that a repo, too.
-    dbg_repodir = os.path.join(repodir, 'debug')
-    if os.path.exists(dbg_repodir):
-        create_repository(cfg,dbg_repodir)
-
-
-def create_src_repo(cfg,dist):
-    """create/update repository metadata for a given dist"""
-    create_repository( cfg, os.path.join(cfg.treedir,dist,'SRPMS') )
+    if debuginfo:
+        # If there's a debug subdir, make that a repo, too.
+        dbg_repodir = os.path.join(repodir, 'debug')
+        if os.path.exists(dbg_repodir):
+            print 'Creating repository %s' % dbg_repodir
+            cmd = '%s -c %s -q %s' % (cfg.createrepo, cfg.cr_cachedir, dbg_repodir)
+            run_and_check(cmd)
 
 
 def is_repo_changed(repodir):
@@ -183,6 +175,24 @@
     return False
 
 
+def get_std_repodirs(cfg,dist,reporoot):
+    """return list of all repository directories (below reporoot) for
+    this distribution version"""
+    repodirs = [os.path.join(reporoot,'SRPMS')]
+    for arch in cfg.archdict[dist]:
+        repodirs.append(os.path.join(reporoot,arch))
+        repodirs.append(os.path.join(reporoot,arch,'debug'))
+    return repodirs
+
+
+def make_std_repodirs(cfg,dist,reporoot):
+    """create all repository directories (below reporoot) for
+    this distribution version, if they don't exist"""
+    for repodir in get_std_repodirs(cfg,dist,reporoot):
+        if not DEBUG and not os.path.exists(repodir):
+            os.makedirs(repodir)
+
+                     
 def fix_mdcache_access(workdir,cachedir):
 # Work around explicit directory mode 0755 in yum/repos.py (that
 # is too restrictive for our extras_signers group) and an utime


Index: MultiLib.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/MultiLib.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MultiLib.py	19 Oct 2006 22:56:40 -0000	1.8
+++ MultiLib.py	24 Oct 2006 20:28:19 -0000	1.9
@@ -296,7 +296,7 @@
         for arch in cfg.archdict[dist]:  # list of repo archs
             changedagain = resolveMissing(cfg,dist,arch)
             if changedagain:
-                Utils.create_arch_repo(cfg,dist,arch)
+                Utils.create_repository(cfg,os.path.join(cfg.treedir,dist,arch))
 
 
 if __name__ == '__main__':




More information about the scm-commits mailing list