extras-buildsys/utils/pushscript Utils.py,1.4,1.5
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Fri Oct 27 21:00:24 UTC 2006
- Previous message: rpms/kdeartwork-extras/devel .cvsignore, 1.2, 1.3 kdeartwork-extras.spec, 1.1, 1.2 sources, 1.2, 1.3
- Next message: rpms/csound/devel .cvsignore, 1.3, 1.4 csound-5.03.0-no-usr-local.patch, 1.1, 1.2 csound-5.03.0-remote-fixes.patch, 1.1, 1.2 csound.spec, 1.4, 1.5 sources, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: mschwendt
Update of /cvs/fedora/extras-buildsys/utils/pushscript
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18191
Modified Files:
Utils.py
Log Message:
Work around createrepo < 0.4.5 (upstream bug 595). Even if a future
upgrade of createrepo may work fine and never chokes on files in
".olddir", we here take over backing up files in "repodata" dir.
Index: Utils.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Utils.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Utils.py 24 Oct 2006 22:41:38 -0000 1.4
+++ Utils.py 27 Oct 2006 21:00:21 -0000 1.5
@@ -33,15 +33,22 @@
if DEBUG:
print ' DEBUG:', msg
-def run_and_check(cmd):
+def run(cmd):
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
if result != 0:
print >> sys.stderr, 'Error running command: %s ' % cmd
if result > 127:
- sys.exit(1)
- sys.exit(result)
+ return 1
+ return result
+ else:
+ return 0
+
+def run_and_check(cmd):
+ result = run(cmd)
+ if result:
+ sys.exit(result)
def load_config_module(project):
@@ -111,23 +118,9 @@
install_copy(src,dest)
-def create_repository(cfg,repodir,debuginfo=True):
- """create/update repository metadata for a given directory and
- consider a 'debug' sub-repository by default"""
-
+def _create_repository(cfg,repodir,debuginfo=True):
print 'Creating repository %s' % repodir
-
- if not os.path.exists(repodir):
- os.makedirs(repodir)
-
- # TODO: Why remove the repodata dir? Isn't that entirely createrepo's
- # work? (also further below for "debug")
- # ? -> https://devel.linux.duke.edu/bugzilla/show_bug.cgi?id=595
- rpdata = os.path.join(repodir, 'repodata')
- debugprint('removing tree %s' % rpdata)
- if os.path.exists(rpdata) and not DEBUG:
- shutil.rmtree(rpdata)
-
+
compsarg = ''
if os.path.exists( os.path.join(repodir,compsname) ):
compsarg = '-g %s ' % compsname
@@ -135,7 +128,8 @@
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)
+ if run(cmd):
+ raise Exception
if debuginfo:
# If there's a debug subdir, make that a repo, too.
@@ -147,9 +141,58 @@
if os.path.exists(rpdata) and not DEBUG:
shutil.rmtree(rpdata)
cmd = '%s -c %s -q %s' % (cfg.createrepo, cfg.cr_cachedir, dbg_repodir)
- run_and_check(cmd)
+ if run(cmd):
+ raise Exception
+
+
+def _restore_repodata_dir(tmpdir,targetdir): # helper function
+ for f in os.listdir(tmpdir):
+ sourcefile = os.path.join(tmpdir,f)
+ targetfile = os.path.join(targetdir,f)
+ if os.path.exists(targetfile): # don't overwrite new files
+ if os.path.isdir(targetfile):
+ shutil.rmtree(sourcefile)
+ else:
+ os.remove(sourcefile)
+ else:
+ shutil.move(sourcefile,targetfile)
+def create_repository(cfg,repodir,debuginfo=True):
+ """create/update repository metadata for a given directory and
+ consider a 'debug' sub-repository by default"""
+
+ rpdata = os.path.join(repodir,'repodata')
+ for d in [repodir,rpdata]:
+ if not os.path.exists(d):
+ os.makedirs(d)
+
+ # Not only help createrepo < 0.4.5, but more important, create
+ # a backup of the "repodata" directory and restore repoview files,
+ # because it sucks to recreate them everytime from scratch.
+ # We used to remove the entire repodata directory because of:
+ # https://devel.linux.duke.edu/bugzilla/show_bug.cgi?id=595
+
+ tmpdir = tempfile.mkdtemp('','.push',repodir)
+ if tmpdir == repodir: # paranoid, should never happen
+ sys.exit(errno.EPERM)
+ try:
+ for f in os.listdir(rpdata):
+ sourcefile = os.path.join(rpdata,f)
+ targetfile = os.path.join(tmpdir,f)
+ shutil.move(sourcefile,targetfile)
+
+ _create_repository(cfg,repodir,debuginfo)
+
+ _restore_repodata_dir(tmpdir,rpdata)
+ shutil.rmtree(tmpdir)
+ except: # everything is bad at this point
+ print 'ERROR: Creating temporary working directory failed.'
+ _restore_repodata_dir(tmpdir,rpdata)
+ shutil.rmtree(tmpdir)
+ sys.exit(errno.EPERM)
+
+
def is_repo_changed(repodir):
"""Checks if the repository has changed and needs to be reindexed"""
ref_file = os.path.join(repodir, 'repodata', 'repomd.xml')
- Previous message: rpms/kdeartwork-extras/devel .cvsignore, 1.2, 1.3 kdeartwork-extras.spec, 1.1, 1.2 sources, 1.2, 1.3
- Next message: rpms/csound/devel .cvsignore, 1.3, 1.4 csound-5.03.0-no-usr-local.patch, 1.1, 1.2 csound-5.03.0-remote-fixes.patch, 1.1, 1.2 csound.spec, 1.4, 1.5 sources, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the scm-commits
mailing list