Exemple #1
0
    def getHeader(self, pkg, msgCallback = None, progressCallback = None):
        for dir in self.dir_list:
            fileNames = glob.glob(
                "%s/%s.%s.hdr" % (dir, up2dateUtils.pkgToString(pkg), pkg[4]))
            # if we find anything, bail
            if len(fileNames):
                break


        if len(fileNames):
            hdr = self.__readHeaderFromFile(fileNames, pkg)
            if hdr:
                return hdr
            else:
                # the header aint there, return none so the rest
                # of the crap will go fetch it again
                return None

        else:
            for dir in self.dir_list:
                fileNames = glob.glob(
                    "%s/%s.noarch.hdr" % (dir, up2dateUtils.pkgToString(pkg)))

            # see if it is a .hdr file, if not try reading it as an rpm
            if len(fileNames):
                hdr = self.__readHeaderFromFile(fileNames, pkg)
                if hdr:
                    return hdr
                else:
                    hdr = self.__readHeaderFromRpm(fileNames,pkg)
                    return hdr
Exemple #2
0
    def getHeader(self, pkg, msgCallback = None, progressCallback = None):
        for dir in self.dir_list:
            fileNames = glob.glob(
                "%s/%s.%s.hdr" % (dir, up2dateUtils.pkgToString(pkg), pkg[4]))
            # if we find anything, bail
            if len(fileNames):
                break


        if len(fileNames):
            hdr = self.__readHeaderFromFile(fileNames, pkg)
            if hdr:
                return hdr
            else:
                # the header aint there, return none so the rest
                # of the crap will go fetch it again
                return None

        else:
            for dir in self.dir_list:
                fileNames = glob.glob(
                    "%s/%s.noarch.hdr" % (dir, up2dateUtils.pkgToString(pkg)))

            # see if it is a .hdr file, if not try reading it as an rpm
            if len(fileNames):
                hdr = self.__readHeaderFromFile(fileNames, pkg)
                if hdr:
                    return hdr
                else:
                    hdr = self.__readHeaderFromRpm(fileNames,pkg)
                    return hdr
Exemple #3
0
    def getHeader(self, pkg, msgCallback = None, progressCallback = None):
        baseFileName = "%s-%s-%s.%s.rpm" % (pkg[0], pkg[1], pkg[2], pkg[4])
        for dir in self.dir_list:
            tmpFileNames = glob.glob("%s/%s" % (dir, baseFileName))
            fileName = "%s/%s" % (self.cfg["storageDir"], baseFileName)

        fileNames = tmpFileNames
        if len(fileNames):
            if os.access(fileNames[0], os.R_OK):
                if not re.search("rpm$", fileNames[0]):
                    # it wasnt an rpm, so must be a header
                    if os.stat(fileNames[0])[6] == 0:
                        return None
                    fd = open(fileNames[0], "r")
                    # if this header is corrupt, rpmlib exits and we stop ;-<
                    try:
                        hdr = rpmUtils.readHeaderBlob(fd.read())
                    except:
                        return None
                    self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                    fd.close()
                    self.__saveHeader(hdr)
                    return hdr
                else:
                    fd = os.open(fileNames[0], 0)
                    # verify just the md5
                    self.ts.pushVSFlags(~(rpm.RPMVSF_NOMD5|rpm.RPMVSF_NEEDPAYLOAD))
                    try:
                        #hdr = rpm.headerFromPackage(fd)
                        hdr = self.ts.hdrFromFdno(fd)
                    except:
                        os.close(fd)
                        self.ts.popVSFlags()
                        raise up2dateErrors.RpmError(_("Error reading header"))
                    self.ts.popVSFlags()
                    os.close(fd)
                    self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                    self.__saveHeader(hdr)
                    return hdr
                    
            else:
                 return None        
        else:
            for dir in self.dir_list:
                fileNames = glob.glob("%s/%s.noarch.*" %
                                      (dir,
                                       up2dateUtils.pkgToString(pkg)))
            if len(fileNames):
                if os.access(fileNames[0], os.R_OK):
                    if not re.search("rpm$", fileNames[0]):
                        # it's not an rpm, must be a header
                        if os.stat(fileNames[0])[6] == 0:
                            return None
                        fd = open(fileNames[0], "r")
                        try:
                            hdr = rpmUtils.readHeaderBlob(fd.read())
                        except:
                            self.log.log_me("Corrupt header %s, skipping, "\
                                       "will download later..." % fileNames[0])
                            return None
                        fd.close()
                        self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                        return hdr
                    else:
                        if os.access(fileNames[0], os.R_OK):
                            fd = os.open(fileNames[0], 0)
                            try:
                                #hdr = rpm.headerFromPackage(fd)
                                hdr = self.ts.hdrFromFdno(fd)
                            except:
                                os.close(fd)
                                raise up2dateErrors.RpmError(_(
                                    "Error reading header"))
                            os.close(fd)
                            self.log.log_me("Reading header from: %s" % fileNames)
                            self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                            return hdr
                        else:
                            return None
                else:
                    return None
            else:
                return None
Exemple #4
0
    def getHeader(self, pkg, msgCallback = None, progressCallback = None):
        baseFileName = "%s-%s-%s.%s.rpm" % (pkg[0], pkg[1], pkg[2], pkg[4])
        for dir in self.dir_list:
            tmpFileNames = glob.glob("%s/%s" % (dir, baseFileName))
            fileName = "%s/%s" % (self.cfg["storageDir"], baseFileName)

        fileNames = tmpFileNames
        if len(fileNames):
            if os.access(fileNames[0], os.R_OK):
                if not re.search("rpm$", fileNames[0]):
                    # it wasnt an rpm, so must be a header
                    if os.stat(fileNames[0])[6] == 0:
                        return None
                    fd = open(fileNames[0], "r")
                    # if this header is corrupt, rpmlib exits and we stop ;-<
                    try:
                        hdr = rpmUtils.readHeaderBlob(fd.read())
                    except:
                        return None
                    self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                    fd.close()
                    self.__saveHeader(hdr)
                    return hdr
                else:
                    fd = os.open(fileNames[0], 0)
                    # verify just the md5
                    self.ts.pushVSFlags(~(rpm.RPMVSF_NOMD5|rpm.RPMVSF_NEEDPAYLOAD))
                    try:
                        #hdr = rpm.headerFromPackage(fd)
                        hdr = self.ts.hdrFromFdno(fd)
                    except:
                        os.close(fd)
                        self.ts.popVSFlags()
                        raise up2dateErrors.RpmError("Error reading header")
                    self.ts.popVSFlags()
                    os.close(fd)
                    self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                    self.__saveHeader(hdr)
                    return hdr
                    
            else:
                 return None        
        else:
            for dir in self.dir_list:
                fileNames = glob.glob("%s/%s.noarch.*" %
                                      (dir,
                                       up2dateUtils.pkgToString(pkg)))
            if len(fileNames):
                if os.access(fileNames[0], os.R_OK):
                    if not re.search("rpm$", fileNames[0]):
                        # it's not an rpm, must be a header
                        if os.stat(fileNames[0])[6] == 0:
                            return None
                        fd = open(fileNames[0], "r")
                        try:
                            hdr = rpmUtils.readHeaderBlob(fd.read())
                        except:
                            self.log.log_me("Corrupt header %s, skipping, "\
                                       "will download later..." % fileNames[0])
                            return None
                        fd.close()
                        self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                        return hdr
                    else:
                        if os.access(fileNames[0], os.R_OK):
                            fd = os.open(fileNames[0], 0)
                            try:
                                #hdr = rpm.headerFromPackage(fd)
                                hdr = self.ts.hdrFromFdno(fd)
                            except:
                                os.close(fd)
                                raise up2dateErrors.RpmError("Error reading header")
                            os.close(fd)
                            self.log.log_me("Reading header from: %s" % fileNames)
                            self.headerCache[up2dateUtils.pkgToStringArch(pkg)] = hdr
                            return hdr
                        else:
                            return None
                else:
                    return None
            else:
                return None