From 66ba55b25018996af69e2a50d0623fd6893b7a61 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 5 Dec 2005 16:14:53 +0100 Subject: * sources.list does a proper backup now --- DistUpgrade/DistUpgrade.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'DistUpgrade/DistUpgrade.py') diff --git a/DistUpgrade/DistUpgrade.py b/DistUpgrade/DistUpgrade.py index 40cf3d1a..7e8242bd 100644 --- a/DistUpgrade/DistUpgrade.py +++ b/DistUpgrade/DistUpgrade.py @@ -7,6 +7,7 @@ import gtk.gdk import gtk.glade import apt +import apt_pkg import sys from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp @@ -102,7 +103,11 @@ class DistUpgradeControler(object): # check if it's a mirror (or offical site) for mirror in valid_mirrors: if sources.is_mirror(mirror,entry.uri): - if entry.dist in fromDists: + if entry.dist in toDists: + # so the sources.list is already set to the new + # distro + foundToDist = True + elif entry.dist in fromDists: foundToDist = True entry.dist = toDists[fromDists.index(entry.dist)] else: @@ -124,8 +129,22 @@ class DistUpgradeControler(object): "the upgrade was found.\n")) # write (well, backup first ;) ! - sources.backup() + backup_ext = ".distUpgrade" + sources.backup(backup_ext) sources.save() + + # re-check if the written sources are valid, if not revert and + # bail out + try: + sourceslist = apt_pkg.GetPkgSourceList() + sourceslist.ReadMainList() + except SystemError: + sources.restoreBackup(backup_ext) + self._view.error(_("Repository information invalid"), + _("Upgrading the repository information " + "resulted in a invalid file. Please " + "report this as a bug.")) + return False return True def breezyUpgrade(self): @@ -142,7 +161,7 @@ class DistUpgradeControler(object): # then update the package index files - # then open the cache + # then open the cache (again) self._view.updateStatus(_("Reading cache")) self._cache = apt.Cache(self._view.getOpCacheProgress()) -- cgit v1.2.3