Ejemplo n.º 1
0
def _dnf_resolve(state, mpp_depsolve):
    deps = []

    arch = mpp_depsolve["architecture"]
    mpid = mpp_depsolve["module-platform-id"]
    repos = mpp_depsolve.get("repos", [])
    packages = mpp_depsolve.get("packages", [])
    excludes = mpp_depsolve.get("excludes", [])

    if len(packages) > 0:
        with tempfile.TemporaryDirectory() as persistdir:
            base = _dnf_base(repos, mpid, persistdir, state.dnf_cache, arch)
            base.install_specs(packages, exclude=excludes)
            base.resolve()

            for tsi in base.transaction:
                if tsi.action not in dnf.transaction.FORWARD_ACTIONS:
                    continue

                checksum_type = hawkey.chksum_name(tsi.pkg.chksum[0])
                checksum_hex = tsi.pkg.chksum[1].hex()
                pkg = {
                    "checksum": f"{checksum_type}:{checksum_hex}",
                    "name": tsi.pkg.name,
                    "path": tsi.pkg.relativepath,
                }
                deps.append(pkg)

    return deps
Ejemplo n.º 2
0
 def returnIdSum(self):
     """ Return the chksum type and chksum string how the legacy yum expects
         it.
     """
     (chksum_type, chksum) = self._chksum
     return (hawkey.chksum_name(chksum_type),
             binascii.hexlify(chksum).decode())
Ejemplo n.º 3
0
Archivo: package.py Proyecto: mavit/dnf
 def returnIdSum(self):
     """ Return the chksum type and chksum string how the legacy yum expects
         it.
     """
     if self._chksum is None:
         return (None, None)
     (chksum_type, chksum) = self._chksum
     return (hawkey.chksum_name(chksum_type), binascii.hexlify(chksum).decode())
Ejemplo n.º 4
0
 def download_package(self, package):
     if package in self.packages:
         # It's a package under test, nothing to download
         return package.location
     repo = self.repos_by_name[package.reponame]
     checksum_type = hawkey.chksum_name(package.chksum[0])
     checksum = binascii.hexlify(package.chksum[1]).decode('ascii')
     return repo.download_package(package.location,
                                  checksum_type=checksum_type,
                                  checksum=checksum)
Ejemplo n.º 5
0
 def verifyLocalPkg(self):
     if self.reponame == hawkey.SYSTEM_REPO_NAME:
         raise ValueError, "Can not verify an installed package."
     if self.reponame == hawkey.CMDLINE_REPO_NAME:
         return True # local package always verifies against itself
     (chksum_type, chksum) = self.chksum
     chksum_type = hawkey.chksum_name(chksum_type)
     sum_in_md = binascii.hexlify(chksum)
     real_sum = yum.misc.checksum(chksum_type, self.localPkg(),
                                  datasize=self.size)
     return real_sum == sum_in_md
Ejemplo n.º 6
0
 def verifyLocalPkg(self):
     if self.reponame == hawkey.SYSTEM_REPO_NAME:
         raise ValueError, "Can not verify an installed package."
     if self.reponame == hawkey.CMDLINE_REPO_NAME:
         return True  # local package always verifies against itself
     (chksum_type, chksum) = self.chksum
     chksum_type = hawkey.chksum_name(chksum_type)
     sum_in_md = binascii.hexlify(chksum)
     real_sum = yum.misc.checksum(chksum_type,
                                  self.localPkg(),
                                  datasize=self.size)
     return real_sum == sum_in_md
Ejemplo n.º 7
0
Archivo: drpm.py Proyecto: rcutmore/dnf
    def _target_params(self):
        delta = self.delta
        ctype, csum = delta.chksum
        ctype = hawkey.chksum_name(ctype)
        chksum = hexlify(csum).decode()

        ctype_code = getattr(librepo, ctype.upper(), librepo.CHECKSUM_UNKNOWN)
        if ctype_code == librepo.CHECKSUM_UNKNOWN:
            logger.warn(_("unsupported checksum type: %s"), ctype)

        return {
            'relative_url' : delta.location,
            'checksum_type' : ctype_code,
            'checksum' : chksum,
            'expectedsize' : delta.downloadsize,
            'base_url' : delta.baseurl,
        }
Ejemplo n.º 8
0
    def _target_params(self):
        delta = self.delta
        ctype, csum = delta.chksum
        ctype = hawkey.chksum_name(ctype)
        chksum = hexlify(csum).decode()

        ctype_code = libdnf.repo.PackageTarget.checksumType(ctype)
        if ctype_code == libdnf.repo.PackageTarget.ChecksumType_UNKNOWN:
            logger.warning(_("unsupported checksum type: %s"), ctype)

        return {
            'relative_url': delta.location,
            'checksum_type': ctype_code,
            'checksum': chksum,
            'expectedsize': delta.downloadsize,
            'base_url': delta.baseurl,
        }
Ejemplo n.º 9
0
    def _target_params(self):
        delta = self.delta
        ctype, csum = delta.chksum
        ctype = hawkey.chksum_name(ctype)
        chksum = hexlify(csum).decode()

        ctype_code = libdnf.repo.PackageTarget.checksumType(ctype)
        if ctype_code == libdnf.repo.PackageTarget.ChecksumType_UNKNOWN:
            logger.warning(_("unsupported checksum type: %s"), ctype)

        return {
            'relative_url' : delta.location,
            'checksum_type' : ctype_code,
            'checksum' : chksum,
            'expectedsize' : delta.downloadsize,
            'base_url' : delta.baseurl,
        }
Ejemplo n.º 10
0
def _dnf_resolve(state, mpp_depsolve):
    deps = []

    arch = mpp_depsolve["architecture"]
    mpid = mpp_depsolve["module-platform-id"]
    repos = mpp_depsolve.get("repos", [])
    packages = mpp_depsolve.get("packages", [])
    excludes = mpp_depsolve.get("excludes", [])
    baseurl = mpp_depsolve.get("baseurl")

    baseurls = {
        repo["id"]: repo.get("baseurl", baseurl) for repo in repos
    }

    if len(packages) > 0:
        with tempfile.TemporaryDirectory() as persistdir:
            base = _dnf_base(repos, mpid, persistdir, state.dnf_cache, arch)
            base.install_specs(packages, exclude=excludes)
            base.resolve()

            for tsi in base.transaction:
                if tsi.action not in dnf.transaction.FORWARD_ACTIONS:
                    continue

                checksum_type = hawkey.chksum_name(tsi.pkg.chksum[0])
                checksum_hex = tsi.pkg.chksum[1].hex()

                path = tsi.pkg.relativepath
                base = baseurls[tsi.pkg.reponame]
                # dep["path"] often starts with a "/", even though it's meant to be
                # relative to `baseurl`. Strip any leading slashes, but ensure there's
                # exactly one between `baseurl` and the path.
                url = urllib.parse.urljoin(base + "/", path.lstrip("/"))

                pkg = {
                    "checksum": f"{checksum_type}:{checksum_hex}",
                    "name": tsi.pkg.name,
                    "url": url,
                }
                deps.append(pkg)

    return deps
Ejemplo n.º 11
0
 def test_chksum_name(self):
     name = hawkey.chksum_name(hawkey.CHKSUM_SHA256)
     self.assertEqual(name, "sha256")
Ejemplo n.º 12
0
 def test_chksum_name(self):
     name = hawkey.chksum_name(hawkey.CHKSUM_SHA256)
     self.assertEqual(name, "sha256")
Ejemplo n.º 13
0
 def returnIdSum(self):
     """ Return the chksum type and chksum string how the legacy yum expects
         it.
     """
     (chksum_type, chksum) = self.chksum
     return (hawkey.chksum_name(chksum_type), binascii.hexlify(chksum))
Ejemplo n.º 14
0
Archivo: drpm.py Proyecto: zde/dnf
 def returnIdSum(self):
     ctype, csum = self.chksum
     return chksum_name(ctype), hexlify(csum).decode()