Example #1
0
 def set_from_mirror_list(self, mirrorlist):
     nf = self.download(mirrorlist, False)
     if not nf:
         return
     f = os.fdopen(os.dup(solv.xfileno(nf)), 'r')
     solv.xfclose(nf)
     urls = []
     for l in f.readline():
         l = l.strip()
         if l[0:6] == 'http://' or l[0:7] == 'https://':
             urls.append(l)
     self.set_from_urls(urls)
     f.close()
Example #2
0
    def load_if_changed(self):
        logging.info("Checking rpmmd repo '{0}'.".format(self.name))
        sys.stdout.flush()
        f = self.download("repodata/repomd.xml", False)
        if not f:
            logging.info("  - no repomd.xml file, skipping")
            self.handle.free(True)
            del self.handle
            return False

        # Calculate a cookie from repomd contents.
        chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256)
        chksum.add_fp(f)
        self['cookie'] = chksum.raw()

        if self.use_cached_repo(None, True):
            logging.info("  - using cached metadata")
            solv.xfclose(f)
            return True
        os.lseek(solv.xfileno(f), 0, os.SEEK_SET)
        self.handle.add_repomdxml(f, 0)
        solv.xfclose(f)
        logging.info("  - fetching metadata")
        (filename, filechksum) = self.find('primary')
        if filename:
            f = self.download(filename, True, [filechksum], True)
            if f:
                self.handle.add_rpmmd(f, None, 0)
                solv.xfclose(f)
            if 'incomplete' in self:
                return False # Hopeless, need good primary.
        (filename, filechksum) = self.find('updateinfo')
        if filename:
            f = self.download(filename, True, [filechksum], True)
            if f:
                self.handle.add_updateinfoxml(f, 0)
                solv.xfclose(f)
        self.add_exts()
        if 'incomplete' not in self:
            self.write_cached_repo(None)
        # Must be called after writing the repo.
        self.handle.create_stubs()
        return True
Example #3
0
 def set_from_metalink(self, metalink):
     nf = self.download(metalink, False)
     if not nf:
         return None
     f = os.fdopen(os.dup(solv.xfileno(nf)), 'r')
     solv.xfclose(nf)
     urls = []
     chksums = []
     for l in f.readlines():
         l = l.strip()
         m = re.match(r'^https?://.+/', l)
         if m:
             urls.append(m.group(0))
         m = re.match(r'^<hash type="sha256">([0-9a-fA-F]{64})</hash>', l)
         if m:
             chksums.append(solv.Chksum(solv.REPOKEY_TYPE_SHA256, m.group(1)))
         m = re.match(r'^<url.*>(https?://.+)repodata/repomd.xml</url>', l)
         if m:
             urls.append(m.group(1))
     if len(urls) == 0:
         chksums = [] # in case the metalink is about a different file
     f.close()
     self.set_from_urls(urls)
     return chksums