~landscape/smart/staging

« back to all changes in this revision

Viewing changes to smart/backends/rpm/header.py

  • Committer: Andreas Hasenack
  • Date: 2009-04-15 16:25:16 UTC
  • mfrom: (818.6.25 trunk)
  • mto: This revision was merged to the branch mainline in revision 838.
  • Revision ID: andreas@canonical.com-20090415162516-ybxkoi79udl3thgn
Merged upstream trunk into landscape trunk, which basically brings in version 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
ENCODINGS = ["utf8", "iso-8859-1"]
53
53
 
 
54
 
 
55
def get_header_filenames(header):
 
56
    filenames = header[rpm.RPMTAG_OLDFILENAMES]
 
57
    if not filenames and header[rpm.RPMTAG_BASENAMES]:
 
58
        dirindexes = header[rpm.RPMTAG_DIRINDEXES]
 
59
        if type(dirindexes) != list:
 
60
            dirindexes = [dirindexes]
 
61
        dirnames = header[rpm.RPMTAG_DIRNAMES]
 
62
        if type(dirnames) != list:
 
63
            dirnames = [dirnames]
 
64
        basenames = header[rpm.RPMTAG_BASENAMES]
 
65
        if type(basenames) != list:
 
66
            basenames = [basenames]
 
67
        filenames = [dirnames[dirindexes[i]] + basename
 
68
                     for i, basename in enumerate(basenames)]
 
69
    elif type(filenames) != list:
 
70
        filenames = [filenames]
 
71
    return filenames
 
72
 
 
73
 
54
74
class RPMHeaderPackageInfo(PackageInfo):
55
75
 
56
76
    class LazyHeader(object):
120
140
 
121
141
    def getPathList(self):
122
142
        if self._path is None:
123
 
            paths = self._h[rpm.RPMTAG_OLDFILENAMES]
124
 
            if type(paths) != list:
125
 
                paths = [paths]
 
143
            paths = get_header_filenames(self._h)
126
144
            modes = self._h[rpm.RPMTAG_FILEMODES]
127
145
            if modes:
128
146
                if type(modes) != list:
323
341
                searcher.addResult(pkg, ratio)
324
342
                continue
325
343
            if searcher.path:
326
 
                paths = h[rpm.RPMTAG_OLDFILENAMES]
 
344
                paths = get_header_filenames(h)
327
345
                if paths:
328
 
                    if type(paths) != list:
329
 
                        paths = [paths]
330
346
                    for spath, cutoff in searcher.path:
331
347
                        for path in paths:
332
348
                            _, newratio = globdistance(spath, path, cutoff, ic)
474
490
        h, offset = rpm.readHeaderFromFD(file.fileno())
475
491
        bfp = self.buildFileProvides
476
492
        while h:
477
 
            fnlst = h[1027] # RPMTAG_OLDFILENAMES
478
 
            if type(fnlst) != list:
479
 
                fnlst = [fnlst]
480
 
            for fn in fnlst:
 
493
            for fn in get_header_filenames(h):
481
494
                fn = fndict.get(fn)
482
495
                if fn and offset in self._offsets:
483
496
                    bfp(self._offsets[offset], (RPMProvides, fn, None))
487
500
    def loadFileProvidesHDL(self, fndict):
488
501
        bfp = self.buildFileProvides
489
502
        for offset, h in enumerate(self._hdl):
490
 
            fnlst = h[1027] # RPMTAG_OLDFILENAMES
491
 
            if type(fnlst) != list:
492
 
                fnlst = [fnlst]
493
 
            for fn in fnlst:
 
503
            for fn in get_header_filenames(h):
494
504
                fn = fndict.get(fn)
495
505
                if fn and offset in self._offsets:
496
506
                    bfp(self._offsets[offset], (RPMProvides, fn, None))
677
687
                iface.error("%s: %s" % (os.path.basename(filepath), e))
678
688
            else:
679
689
                file.close()
680
 
                fnlst = h[1027] # RPMTAG_OLDFILENAMES
681
 
                if type(fnlst) != list:
682
 
                    fnlst = [fnlst]
683
 
                for fn in fnlst:
 
690
                for fn in get_header_filenames(h):
684
691
                    fn = fndict.get(fn)
685
692
                    if fn:
686
693
                        bfp(self._offsets[i], (RPMProvides, fn, None))