From 4dd5d69f9902ae00534d430dc1351ee9ec165bb7 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 24 Jun 2007 19:06:10 +0000 Subject: [PATCH] sort the world file before writing it and ensure that it's terminated by a newline (bug #180706, trunk r6976 and r6999) svn path=/main/branches/2.1.2/; revision=7000 --- bin/emaint | 3 ++- bin/emerge | 10 ++++++---- bin/regenworld | 3 ++- pym/portage_update.py | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/emaint b/bin/emaint index e86920a2f..0353a52ce 100755 --- a/bin/emaint +++ b/bin/emaint @@ -58,7 +58,8 @@ class WorldHandler(object): def fix(self): errors = [] try: - portage.write_atomic(self.world_file, "\n".join(self.okay)) + portage.write_atomic(self.world_file, + "\n".join(sorted(self.okay)) + "\n") except portage_exception.PortageException: errors.append(self.world_file + " could not be opened for writing") return errors diff --git a/bin/emerge b/bin/emerge index 2502387d2..43c7efc27 100755 --- a/bin/emerge +++ b/bin/emerge @@ -584,10 +584,12 @@ def clean_world(vardb, cpv): else: #this doesn't match the package we're unmerging; keep it. newworldlist.append(x) - + + newworldlist.sort() + portage_util.ensure_dirs(os.path.join(vardb.root, portage.PRIVATE_PATH), gid=portage.portage_gid, mode=02770) - portage_util.write_atomic(world_filename, "\n".join(newworldlist)) + portage_util.write_atomic(world_filename, "\n".join(newworldlist)+"\n") def genericdict(mylist): mynewdict={} @@ -3028,7 +3030,7 @@ class MergeTask(object): "--pretend" in self.myopts): portage.write_atomic( os.path.join(self.target_root, portage.WORLD_FILE), - "\n".join(myfavdict.values())) + "\n".join(sorted(myfavdict.values())) + "\n") mtimedb["resume"]["mergelist"]=mymergelist[:] mtimedb.commit() @@ -3281,7 +3283,7 @@ class MergeTask(object): ") Updating world file ("+x[pkgindex]+")") portage.write_atomic( os.path.join(myroot, portage.WORLD_FILE), - "\n".join(myfavdict.values())) + "\n".join(sorted(myfavdict.values()))+"\n") if "--pretend" not in self.myopts and \ "--fetchonly" not in self.myopts and \ diff --git a/bin/regenworld b/bin/regenworld index ebac4a591..601653406 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -92,4 +92,5 @@ for mykey in biglist: print "add to world:",myfavkey worldlist.append(myfavkey) -portage.write_atomic(os.path.join("/", portage.WORLD_FILE), "\n".join(worldlist)) +portage.write_atomic(os.path.join("/", portage.WORLD_FILE), + "\n".join(sorted(worldlist)) + "\n") diff --git a/pym/portage_update.py b/pym/portage_update.py index c3746d34d..f1cf7c6e5 100644 --- a/pym/portage_update.py +++ b/pym/portage_update.py @@ -202,7 +202,8 @@ def update_config_files(config_root, protect, protect_mask, update_iter): sys.stdout.write("p") sys.stdout.flush() - write_atomic(os.path.join(config_root, WORLD_FILE), "\n".join(worldlist)) + worldlist.sort() + write_atomic(os.path.join(config_root, WORLD_FILE), "\n".join(worldlist)+"\n") protect_obj = ConfigProtect( config_root, protect, protect_mask) -- 2.26.2