~mvo/update-manager/not-automatic

« back to all changes in this revision

Viewing changes to UpdateManager/Core/MyCache.py

  • Committer: Michael Vogt
  • Date: 2009-02-16 10:31:16 UTC
  • Revision ID: michael.vogt@ubuntu.com-20090216103116-2y9medz16uv97euc
refactoring, cleaner code that works UI agnostic

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
        assert self._depcache.BrokenCount == 0 and self._depcache.DelCount == 0
83
83
        self._depcache.Upgrade()
84
84
        return wouldDelete
 
85
    def _has_ver_with_not_automatic_origin(self, pkg):
 
86
        """
 
87
        internal helper that checks if one pkg version has the
 
88
        NotAutomatic flag
 
89
        """
 
90
        for ver in pkg._pkg.VersionList:
 
91
            for (verFileIter, index) in ver.FileList:
 
92
                if verFileIter.NotAutomatic:
 
93
                    return True
 
94
        return False
 
95
    def notAutomaticUpgradable(self, pkg):
 
96
        """
 
97
        check if 'pkg' is upgradable but has the 'NotAutomatic' flag
 
98
        """
 
99
        if (pkg.isInstalled and
 
100
            not pkg.isUpgradable and
 
101
            pkg.candidateOrigin and
 
102
            self._has_ver_with_not_automatic_origin(pkg)):
 
103
            # FIXME: check version is actuall higher
 
104
            return True
 
105
        return False
 
106
    def markUpgradeInstall(self, pkg):
 
107
        """
 
108
        mark package for upgrade/install. we have a special version
 
109
        here because update-manager deals with NotAutomatic by
 
110
        explictely selecting it if there is no candidate already
 
111
        """
 
112
        # handle NotAutomatic: yes packages special
 
113
        if self.notAutomaticUpgradable(pkg):
 
114
            for ver in pkg._pkg.VersionList:
 
115
                print "looking at: ", ver
 
116
                for (verFileIter, index) in ver.FileList:
 
117
                    if verFileIter.NotAutomatic:
 
118
                        print "setting candidate ver: ", ver
 
119
                        pkg._depcache.SetCandidateVer(pkg._pkg, ver)
 
120
                        print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
 
121
                        pkg._depcache.MarkInstall(pkg._pkg)
 
122
                        print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
 
123
                        break
 
124
        pkg.markInstall()
 
125
        print pkg.markedInstall
 
126
        print pkg.markedUpgrade
 
127
        
85
128
    def matchPackageOrigin(self, pkg, matcher):
86
129
        """ match 'pkg' origin against 'matcher', take versions between
87
130
            installedVersion and candidateVersion into account too