mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
Compare commits
2 Commits
d283dccc1e
...
7fd8ac8265
Author | SHA1 | Date | |
---|---|---|---|
7fd8ac8265 | |||
a03f5c5e6b |
@ -311,7 +311,7 @@
|
|||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.classList.add("nav-link");
|
link.classList.add("nav-link");
|
||||||
|
|
||||||
link.textContent = version.version;
|
link.textContent = new Date(1000 * version.created).toISOStringShort();
|
||||||
link.href = "#";
|
link.href = "#";
|
||||||
link.onclick = _ => {
|
link.onclick = _ => {
|
||||||
const logs = data
|
const logs = data
|
||||||
|
@ -117,7 +117,7 @@ class Application(ApplicationPackages, ApplicationRepository):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
packages(list[Package]): list of source packages of which dependencies have to be processed
|
packages(list[Package]): list of source packages of which dependencies have to be processed
|
||||||
process_dependencies(bool): if no set, dependencies will not be processed
|
process_dependencies(bool): if set to ``False``, dependencies will not be processed
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[Package]: updated packages list. Packager for dependencies will be copied from the original package
|
list[Package]: updated packages list. Packager for dependencies will be copied from the original package
|
||||||
@ -130,6 +130,9 @@ class Application(ApplicationPackages, ApplicationRepository):
|
|||||||
>>> packages = application.with_dependencies(packages, process_dependencies=True)
|
>>> packages = application.with_dependencies(packages, process_dependencies=True)
|
||||||
>>> application.print_updates(packages, log_fn=print)
|
>>> application.print_updates(packages, log_fn=print)
|
||||||
"""
|
"""
|
||||||
|
if not process_dependencies or not packages:
|
||||||
|
return packages
|
||||||
|
|
||||||
def missing_dependencies(source: Iterable[Package]) -> dict[str, str | None]:
|
def missing_dependencies(source: Iterable[Package]) -> dict[str, str | None]:
|
||||||
# append list of known packages with packages which are in current sources
|
# append list of known packages with packages which are in current sources
|
||||||
satisfied_packages = known_packages | {
|
satisfied_packages = known_packages | {
|
||||||
@ -145,22 +148,29 @@ class Application(ApplicationPackages, ApplicationRepository):
|
|||||||
if dependency not in satisfied_packages
|
if dependency not in satisfied_packages
|
||||||
}
|
}
|
||||||
|
|
||||||
if not process_dependencies or not packages:
|
def new_packages(root: Package) -> dict[str, Package]:
|
||||||
return packages
|
portion = {root.base: root}
|
||||||
|
while missing := missing_dependencies(portion.values()):
|
||||||
|
for package_name, packager in missing.items():
|
||||||
|
if (source_dir := self.repository.paths.cache_for(package_name)).is_dir():
|
||||||
|
# there is local cache, load package from it
|
||||||
|
leaf = Package.from_build(source_dir, self.repository.architecture, packager)
|
||||||
|
else:
|
||||||
|
leaf = Package.from_aur(package_name, packager)
|
||||||
|
portion[leaf.base] = leaf
|
||||||
|
|
||||||
|
# register package in the database
|
||||||
|
self.repository.reporter.set_unknown(leaf)
|
||||||
|
|
||||||
|
return portion
|
||||||
|
|
||||||
known_packages = self._known_packages()
|
known_packages = self._known_packages()
|
||||||
with_dependencies = {package.base: package for package in packages}
|
with_dependencies: dict[str, Package] = {}
|
||||||
|
for package in packages:
|
||||||
while missing := missing_dependencies(with_dependencies.values()):
|
with self.in_package_context(package.base, package.version): # use the same context for the logger
|
||||||
for package_name, username in missing.items():
|
try:
|
||||||
if (source_dir := self.repository.paths.cache_for(package_name)).is_dir():
|
with_dependencies |= new_packages(package)
|
||||||
# there is local cache, load package from it
|
except Exception:
|
||||||
package = Package.from_build(source_dir, self.repository.architecture, username)
|
self.logger.exception("could not process dependencies of %s, skip the package", package.base)
|
||||||
else:
|
|
||||||
package = Package.from_aur(package_name, username)
|
|
||||||
with_dependencies[package.base] = package
|
|
||||||
|
|
||||||
# register package in the database
|
|
||||||
self.repository.reporter.set_unknown(package)
|
|
||||||
|
|
||||||
return list(with_dependencies.values())
|
return list(with_dependencies.values())
|
||||||
|
@ -53,7 +53,7 @@ class Handler:
|
|||||||
Wrapper for all command line actions, though each derived class implements :func:`run()` method, it usually
|
Wrapper for all command line actions, though each derived class implements :func:`run()` method, it usually
|
||||||
must not be called directly. The recommended way is to call :func:`execute()` class method, e.g.::
|
must not be called directly. The recommended way is to call :func:`execute()` class method, e.g.::
|
||||||
|
|
||||||
>>> from ahriman.application.handlers import Add
|
>>> from ahriman.application.handlers.add import Add
|
||||||
>>>
|
>>>
|
||||||
>>> Add.execute(args)
|
>>> Add.execute(args)
|
||||||
"""
|
"""
|
||||||
|
@ -113,6 +113,40 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
|
|||||||
], any_order=True)
|
], any_order=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_with_dependencies_exception(application: Application, package_ahriman: Package,
|
||||||
|
package_python_schedule: Package, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must skip packages if exception occurs
|
||||||
|
"""
|
||||||
|
def create_package_mock(package_base) -> MagicMock:
|
||||||
|
mock = MagicMock()
|
||||||
|
mock.base = package_base
|
||||||
|
mock.depends_build = []
|
||||||
|
mock.packages_full = [package_base]
|
||||||
|
return mock
|
||||||
|
|
||||||
|
package_python_schedule.packages = {
|
||||||
|
package_python_schedule.base: package_python_schedule.packages[package_python_schedule.base]
|
||||||
|
}
|
||||||
|
package_ahriman.packages[package_ahriman.base].depends = ["devtools", "python", package_python_schedule.base]
|
||||||
|
package_ahriman.packages[package_ahriman.base].make_depends = ["python-build", "python-installer"]
|
||||||
|
|
||||||
|
packages = {
|
||||||
|
package_ahriman.base: package_ahriman,
|
||||||
|
package_python_schedule.base: package_python_schedule,
|
||||||
|
"python": create_package_mock("python"),
|
||||||
|
"python-installer": create_package_mock("python-installer"),
|
||||||
|
}
|
||||||
|
|
||||||
|
mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p.name == "python")
|
||||||
|
mocker.patch("ahriman.models.package.Package.from_aur", side_effect=lambda *args: packages[args[0]])
|
||||||
|
mocker.patch("ahriman.models.package.Package.from_build", side_effect=Exception)
|
||||||
|
mocker.patch("ahriman.application.application.Application._known_packages",
|
||||||
|
return_value={"devtools", "python-build", "python-pytest"})
|
||||||
|
|
||||||
|
assert not application.with_dependencies([package_ahriman], process_dependencies=True)
|
||||||
|
|
||||||
|
|
||||||
def test_with_dependencies_skip(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
def test_with_dependencies_skip(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must skip processing of dependencies
|
must skip processing of dependencies
|
||||||
|
Loading…
Reference in New Issue
Block a user