summaryrefslogtreecommitdiff
path: root/DistUpgrade/DistUpgrade.py
diff options
context:
space:
mode:
authorMichael Vogt <egon@top>2005-12-05 16:14:53 +0100
committerMichael Vogt <egon@top>2005-12-05 16:14:53 +0100
commit66ba55b25018996af69e2a50d0623fd6893b7a61 (patch)
tree54921477011015f10fd157d9616a6d103ae5c5c4 /DistUpgrade/DistUpgrade.py
parenta0ee71f0b7268127ec6da4ca22f002775aba64c0 (diff)
downloadpython-apt-66ba55b25018996af69e2a50d0623fd6893b7a61.tar.gz
* sources.list does a proper backup now
Diffstat (limited to 'DistUpgrade/DistUpgrade.py')
-rw-r--r--DistUpgrade/DistUpgrade.py25
1 files changed, 22 insertions, 3 deletions
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())