Logo Search packages:      
Sourcecode: yum version File versions  Download package

def rpmUtils::updates::Updates::doUpdates (   self  ) 

check for key lists as populated then commit acts of evil to
   determine what is updated and/or obsoleted, populate self.updatesdict

Definition at line 199 of file updates.py.

00199                        :
        """check for key lists as populated then commit acts of evil to
           determine what is updated and/or obsoleted, populate self.updatesdict
        """
        
        
        # best bet is to chew through the pkgs and throw out the new ones early
        # then deal with the ones where there are a single pkg installed and a 
        # single pkg available
        # then deal with the multiples

        # we should take the whole list as a 'newlist' and remove those entries
        # which are clearly:
        #   1. updates 
        #   2. identical to the ones in ourdb
        #   3. not in our archdict at all
        
        simpleupdate = []
        complexupdate = []
        
        updatedict = {} # (old n, a, e, v, r) : [(new n, a, e, v, r)]
                        # make the new ones a list b/c while we _shouldn't_
                        # have multiple updaters, we might and well, it needs
                        # to be solved one way or the other <sigh>
        newpkgs = []
        newpkgs = self.availdict
        
        archlist = rpmUtils.arch.getArchList(self.myarch)
                
        for (n, a) in newpkgs.keys():
            # remove stuff not in our archdict
            # high log here
            if a is None:
                for (arch, e,v,r) in newpkgs[(n, a)]:
                    if arch not in archlist:
                        newpkgs[(n, a)].remove((arch, e,v,r))
                continue
                
            if a not in archlist:
                # high log here
                del newpkgs[(n, a)]
                continue

        # remove the older stuff - if we're doing an update we only want the
        # newest evrs                
        for (n, a) in newpkgs.keys():
            if a is None:
                continue

            (new_e,new_v,new_r) = self.returnNewest(newpkgs[(n, a)])
            for (e, v, r) in newpkgs[(n, a)]:
                if (new_e, new_v, new_r) != (e, v, r):
                    newpkgs[(n, a)].remove((e, v, r))

                
        for (n, a) in newpkgs.keys():
            if a is None: # the None archs are only for lookups
                continue
           
            # simple ones - look for exact matches or older stuff
            if self.installdict.has_key((n, a)):
                for (rpm_e, rpm_v, rpm_r) in self.installdict[(n, a)]:
                    try:
                        (e, v, r) = self.returnNewest(newpkgs[(n,a)])
                    except rpmUtils.RpmUtilsError:
                        continue
                    else:
                        rc = rpmUtils.miscutils.compareEVR((e, v, r), (rpm_e, rpm_v, rpm_r))
                        if rc <= 0:
                            try:
                                newpkgs[(n, a)].remove((e, v, r))
                            except ValueError:
                               pass

        # get rid of all the empty dict entries:
        for nakey in newpkgs.keys():
            if len(newpkgs[nakey]) == 0:
                del newpkgs[nakey]


        # ok at this point our newpkgs list should be thinned, we should have only
        # the newest e,v,r's and only archs we can actually use
        for (n, a) in newpkgs.keys():
            if a is None: # the None archs are only for lookups
                continue
    
            if self.installdict.has_key((n, None)):
                installarchs = []
                availarchs = []
                for (a, e, v ,r) in newpkgs[(n, None)]:
                    availarchs.append(a)
                for (a, e, v, r) in self.installdict[(n, None)]:
                    installarchs.append(a)

                if len(availarchs) > 1 or len(installarchs) > 1:
                    self.debugprint('putting %s in complex update' % n)
                    complexupdate.append(n)
                else:
                    #log(4, 'putting %s in simple update list' % name)
                    self.debugprint('putting %s in simple update' % n)
                    simpleupdate.append((n, a))

        # we have our lists to work with now
    
        # simple cases
        for (n, a) in simpleupdate:
            # try to be as precise as possible
            if n in self.exactarchlist:
                if self.installdict.has_key((n, a)):
                    (rpm_e, rpm_v, rpm_r) = self.returnNewest(self.installdict[(n, a)])
                    if newpkgs.has_key((n,a)):
                        (e, v, r) = self.returnNewest(newpkgs[(n, a)])
                        rc = rpmUtils.miscutils.compareEVR((e, v, r), (rpm_e, rpm_v, rpm_r))
                        if rc > 0:
                            # this is definitely an update - put it in the dict
                            if not updatedict.has_key((n, a, rpm_e, rpm_v, rpm_r)):
                                updatedict[(n, a, rpm_e, rpm_v, rpm_r)] = []
                            updatedict[(n, a, rpm_e, rpm_v, rpm_r)].append((n, a, e, v, r))
    
            else:
                # we could only have 1 arch in our rpmdb and 1 arch of pkg 
                # available - so we shouldn't have to worry about the lists, here
                # we just need to find the arch of the installed pkg so we can 
                # check it's (e, v, r)
                (rpm_a, rpm_e, rpm_v, rpm_r) = self.installdict[(n, None)][0]
                if newpkgs.has_key((n, None)):
                    for (a, e, v, r) in newpkgs[(n, None)]:
                        rc = rpmUtils.miscutils.compareEVR((e, v, r), (rpm_e, rpm_v, rpm_r))
                        if rc > 0:
                            # this is definitely an update - put it in the dict
                            if not updatedict.has_key((n, rpm_a, rpm_e, rpm_v, rpm_r)):
                                updatedict[(n, rpm_a, rpm_e, rpm_v, rpm_r)] = []
                            updatedict[(n, rpm_a, rpm_e, rpm_v, rpm_r)].append((n, a, e, v, r))


        # complex cases

        # we're multilib/biarch
        # we need to check the name.arch in two different trees
        # one for the multiarch itself and one for the compat arch
        # ie: x86_64 and athlon(i686-i386) - we don't want to descend
        # x86_64->i686 
        archlists = []
        if rpmUtils.arch.isMultiLibArch(arch=self.myarch):
            if rpmUtils.arch.multilibArches.has_key(self.myarch):
                biarches = [self.myarch]
            else:
                biarches = [self.myarch, rpmUtils.arch.arches[self.myarch]]

            multicompat = rpmUtils.arch.getMultiArchInfo(self.myarch)[0]
            multiarchlist = rpmUtils.arch.getArchList(multicompat)
            archlists = [ biarches, multiarchlist ]
        else:
            archlists = [ archlist ]
            
        for n in complexupdate:
            for thisarchlist in archlists:
                # we need to get the highest version and the archs that have it
                # of the installed pkgs            
                tmplist = []
                for (a, e, v, r) in self.installdict[(n, None)]:
                    tmplist.append((n, a, e, v, r))

                highestinstalledpkgs = self.returnHighestVerFromAllArchsByName(n,
                                         thisarchlist, tmplist)
                                         
                
                tmplist = []
                for (a, e, v, r) in newpkgs[(n, None)]:
                    tmplist.append((n, a, e, v, r))                        
                
                highestavailablepkgs = self.returnHighestVerFromAllArchsByName(n,
                                         thisarchlist, tmplist)

                hapdict = self.makeNADict(highestavailablepkgs, 0)
                hipdict = self.makeNADict(highestinstalledpkgs, 0)

                # now we have the two sets of pkgs
                if n in self.exactarchlist:
                    for (n, a) in hipdict:
                        if hapdict.has_key((n, a)):
                            self.debugprint('processing %s.%s' % (n, a))
                            # we've got a match - get our versions and compare
                            (rpm_e, rpm_v, rpm_r) = hipdict[(n, a)][0] # only ever going to be first one
                            (e, v, r) = hapdict[(n, a)][0] # there can be only one
                            rc = rpmUtils.miscutils.compareEVR((e, v, r), (rpm_e, rpm_v, rpm_r))
                            if rc > 0:
                                # this is definitely an update - put it in the dict
                                if not updatedict.has_key((n, a, rpm_e, rpm_v, rpm_r)):
                                    updatedict[(n, a, rpm_e, rpm_v, rpm_r)] = []
                                updatedict[(n, a, rpm_e, rpm_v, rpm_r)].append((n, a, e, v, r))
                else:
                    self.debugprint('processing %s' % n)
                    # this is where we have to have an arch contest if there
                    # is more than one arch updating with the highest ver
                    instarchs = []
                    availarchs = []
                    for (n,a) in hipdict.keys():
                        instarchs.append(a)
                    for (n,a) in hapdict.keys():
                        availarchs.append(a)
                    
                    rpm_a = rpmUtils.arch.getBestArchFromList(instarchs, myarch=self.myarch)
                    a = rpmUtils.arch.getBestArchFromList(availarchs, myarch=self.myarch)

                    if rpm_a is None or a is None:
                        continue
                        
                    (rpm_e, rpm_v, rpm_r) = hipdict[(n, rpm_a)][0] # there can be just one
                    (e, v, r) = hapdict[(n, a)][0] # just one, I'm sure, I swear!

                    rc = rpmUtils.miscutils.compareEVR((e, v, r), (rpm_e, rpm_v, rpm_r))

                    if rc > 0:
                        # this is definitely an update - put it in the dict
                        if not updatedict.has_key((n, rpm_a, rpm_e, rpm_v, rpm_r)):
                            updatedict[(n, rpm_a, rpm_e, rpm_v, rpm_r)] = []
                        updatedict[(n, rpm_a, rpm_e, rpm_v, rpm_r)].append((n, a, e, v, r))
                   
                   
        self.updatesdict = updatedict                    
        
    def reduceListByNameArch(self, pkglist, name=None, arch=None):


Generated by  Doxygen 1.6.0   Back to index