diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-02-18 01:39:05 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-02-18 01:39:05 +0000 |
commit | cedd37d9e27625b3b92b7efcd4630cb7e1481563 (patch) | |
tree | b17fbc7b5e4fb1ea0788227de73b5359e7bcde2e | |
parent | 3eec9ae38927c16b0c358ec55d61f1f81f05fbf9 (diff) | |
download | portage-cedd37d9e27625b3b92b7efcd4630cb7e1481563.tar.gz portage-cedd37d9e27625b3b92b7efcd4630cb7e1481563.tar.bz2 portage-cedd37d9e27625b3b92b7efcd4630cb7e1481563.zip |
Add a return value to fixdbentries that indicates whether or not modifications were performed. Use this to avoid unnecessary recomposition of tbz2 files.
svn path=/main/trunk/; revision=2729
-rw-r--r-- | pym/portage.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py index bedb9318d..91ed17e71 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3652,8 +3652,10 @@ def getmaskingstatus(mycpv): return rValue def fixdbentries(update_iter, dbdir): - """python replacement for the fixdbentries script, replaces old_value - with new_value for package names in files in dbdir.""" + """Performs update commands which result in search and replace operations + for each of the files in dbdir (excluding CONTENTS and environment.bz2). + Returns True when actual modifications are necessary and False otherwise.""" + modified = False for myfile in [f for f in os.listdir(dbdir) if f not in ("CONTENTS", "environment.bz2")]: file_path = os.path.join(dbdir, myfile) f = open(file_path, "r") @@ -3672,6 +3674,8 @@ def fixdbentries(update_iter, dbdir): mycontent = re.sub(old_value+"([^a-zA-Z0-9-])", new_value+"\\1", mycontent) if mycontent is not orig_content: write_atomic(file_path, mycontent) + modified = True + return modified class packagetree: def __init__(self,virtual,clone=None): @@ -5371,8 +5375,8 @@ class binarytree(packagetree): writemsg("*") mytbz2=xpak.tbz2(tbz2path) mytbz2.decompose(mytmpdir,cleanup=1) - fixdbentries(mybiglist, mytmpdir) - mytbz2.recompose(mytmpdir,cleanup=1) + if fixdbentries(mybiglist, mytmpdir): + mytbz2.recompose(mytmpdir,cleanup=1) return 1 def populate(self, getbinpkgs=0,getbinpkgsonly=0): |