~ubuntu-core-dev/ubuntu/xenial/ubuntu-release-upgrader/xenial

« back to all changes in this revision

Viewing changes to DistUpgrade/DistUpgrade.py

  • Committer: Michael Vogt
  • Date: 2005-12-05 12:58:50 UTC
  • Revision ID: egon@top-20051205125850-b0e7d4af37fa31ab
* DistUpgrade/ tool started
* SoftwareProperties/aptsources.py:
  - added "backup" and some comments
* UpdateManager/UpdateManager.py:
  - comments updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python2.4
 
2
 
 
3
import pygtk
 
4
pygtk.require('2.0')
 
5
import gtk
 
6
import gtk.gdk
 
7
import gtk.glade
 
8
 
 
9
import apt
 
10
from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp
 
11
from UpdateManager.GtkProgress import GtkOpProgress
 
12
from SoftwareProperties.aptsources import SourcesList, SourceEntry
 
13
from gettext import gettext as _
 
14
 
 
15
class DistUpgradeProgress(object):
 
16
    pass
 
17
 
 
18
 
 
19
class DistUpgradeView(object):
 
20
    " abstraction for the upgrade view "
 
21
    def __init__(self):
 
22
        pass
 
23
    def getOpCacheProgress(self):
 
24
        " return a OpProgress() subclass for the given graphic"
 
25
        return apt.progress.OpProgress()
 
26
    def updateStatus(self, msg):
 
27
        """ update the current status of the distUpgrade based
 
28
            on the current view
 
29
        """
 
30
        pass
 
31
    def askYesNoQuestion(self,msg):
 
32
        pass
 
33
 
 
34
class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp):
 
35
    " gtk frontend of the distUpgrade tool "
 
36
    def __init__(self):
 
37
        # FIXME: i18n must be somewhere relative do this dir
 
38
        SimpleGladeApp.__init__(self, "DistUpgrade.glade",
 
39
                                None, domain="update-manager")
 
40
        self._opCacheProgress = GtkOpProgress(self.progressbar_cache)
 
41
    def getOpCacheProgress(self):
 
42
        return self._opCacheProgress
 
43
    def updateStatus(self, msg):
 
44
        self.label_status = "<b>%s</b>" % msg
 
45
 
 
46
class DistUpgradeControler(object):
 
47
    def __init__(self, distUpgradeView):
 
48
        self._view = distUpgradeView
 
49
 
 
50
    def sanityCheck(self):
 
51
        pass
 
52
 
 
53
    def updateSourcesList(self, fromDist, to):
 
54
        sources = SourcesList()
 
55
        sources.backup()
 
56
        for entry in sources:
 
57
            # check if it's a mirror (or offical site)
 
58
            if sources.is_mirror(entry.uri, "archive.ubuntu.com"):
 
59
                if entry.dist == fromDist:
 
60
                    entry.dist = to
 
61
                else:
 
62
                    # disable all entries that are official but don't
 
63
                    # point to the "from" dist
 
64
                    entry.disabled = True
 
65
            else:
 
66
                # disable non-official entries that point to dist
 
67
                if entry.dist == fromDist:
 
68
                    entry.disabled = True
 
69
        sources.save()
 
70
 
 
71
    def breezyUpgrade(self):
 
72
        # sanity check (check for ubuntu-desktop, brokenCache etc)
 
73
        self._view.updateStatus(_("Checking the system"))
 
74
        self.sanityCheck()
 
75
 
 
76
        # update sources.list
 
77
        self._view.updateStatus(_("Updating repository information"))
 
78
        self.updateSourcesList(fromDist="hoary",to="breezy")
 
79
 
 
80
        # then update the package index files
 
81
 
 
82
 
 
83
        # then open the cache
 
84
        self._view.updateStatus(_("Reading cache"))
 
85
        self._cache = apt.Cache(self._view.getOpCacheProgress())
 
86
 
 
87
        # do pre-upgrade stuff
 
88
 
 
89
        # calc the dist-upgrade and see if the removals are ok/expected
 
90
 
 
91
        # do the dist-upgrade
 
92
 
 
93
        # do post-upgrade stuff
 
94
 
 
95
        # done, ask for reboot
 
96
 
 
97
    def run(self):
 
98
        self.breezyUpgrade()
 
99
 
 
100
 
 
101
if __name__ == "__main__":
 
102
    view = GtkDistUpgradeView()
 
103
    app = DistUpgradeControler(view)
 
104
    app.run()