Esempio n. 1
0
    def mark_packages(self, package_names: Set[str]) -> None:
        for name in package_names:
            if name.endswith(":any"):
                name = name[:-4]

            if self.cache.is_virtual_package(name):
                name = self.cache.get_providing_packages(name)[0].name

            logger.debug(
                "Marking {!r} (and its dependencies) to be fetched".format(
                    name))

            name_arch, version = get_pkg_name_parts(name)
            if name_arch not in self.cache:
                raise errors.PackageNotFoundError(name_arch)

            package = self.cache[name_arch]
            if version is not None:
                self._set_pkg_version(package, version)

            logger.debug(f"package: {package!r}")

            # Disable automatic resolving of broken packages here
            # because if that fails it raises a SystemError and the
            # API doesn't expose enough information about the problem.
            # Instead we let apt-get show a verbose error message later.
            # Also, make sure this package is marked as auto-installed,
            # which will propagate to its dependencies.
            package.mark_install(auto_fix=False, from_user=False)

            # Now mark this package as NOT automatically installed, which
            # will leave its dependencies marked as auto-installed, which
            # allows us to clean them up if necessary.
            package.mark_auto(False)

            self._verify_marked_install(package)
Esempio n. 2
0
 def test_get_pkg_name_parts_no_arch(self):
     name, version = get_pkg_name_parts("hello=2.10-1")
     self.assertThat(name, Equals("hello"))
     self.assertThat(version, Equals("2.10-1"))
Esempio n. 3
0
 def test_get_pkg_name_parts_all(self):
     name, version = get_pkg_name_parts("hello:i386=2.10-1")
     self.assertThat(name, Equals("hello:i386"))
     self.assertThat(version, Equals("2.10-1"))
Esempio n. 4
0
 def test_get_pkg_name_parts_name_only(self):
     name, version = get_pkg_name_parts("hello")
     self.assertThat(name, Equals("hello"))
     self.assertThat(version, Equals(None))