mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-11-22 09:39:30 +00:00
Compare commits
22
Commits
2.23.1
..
a10b1a9364
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a10b1a9364 | ||
|
|
f0d523492d | ||
|
|
dc4f2be65b | ||
|
|
9ba74413e3 | ||
|
|
d3b569bfa2 | ||
|
|
64a7e9b288 | ||
|
|
5ad8a2a7d0 | ||
|
|
c56a319267 | ||
|
|
96558886bd | ||
|
|
4a745321ec | ||
|
|
4446c950ec | ||
|
|
8d569e6075 | ||
|
|
c375236327 | ||
|
|
ddbb4b06ff | ||
|
|
2d66b67123 | ||
|
|
27cfcd07eb | ||
|
|
2080f1e06f | ||
|
|
2544d44051 | ||
|
|
b07ad8cc0c | ||
|
|
c38cb5f680 | ||
|
|
f776b33310 | ||
|
|
eafa1b417a |
No files matched your search
@@ -16,7 +16,7 @@ pacman -S --noconfirm --asdeps base-devel npm python-build python-hatchling pyth
|
||||
# optional dependencies
|
||||
if [[ -z $MINIMAL_INSTALL ]]; then
|
||||
# web server
|
||||
pacman -S --noconfirm --asdeps python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-aiohttp-sse-git python-cryptography python-jinja
|
||||
pacman -S --noconfirm --asdeps python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-aiohttp-sse python-cryptography python-jinja
|
||||
# additional features
|
||||
pacman -S --noconfirm --asdeps gnupg ipython python-boto3 python-cerberus python-matplotlib python-systemd rsync
|
||||
fi
|
||||
@@ -41,6 +41,7 @@ systemd-machine-id-setup
|
||||
|
||||
# remove unused dependencies
|
||||
pacman -Qdtq | pacman -Rscn --noconfirm -
|
||||
find "/var/cache/pacman/pkg" -type f -delete
|
||||
|
||||
# initial setup command as root
|
||||
[[ -z $MINIMAL_INSTALL ]] && WEB_ARGS=("--web-port" "8080")
|
||||
@@ -60,6 +61,6 @@ sudo -u ahriman -- ahriman --log-handler console package-add --now ahriman
|
||||
# check if package was actually installed
|
||||
test -n "$(find "/var/lib/ahriman/repository/github/x86_64" -name "ahriman*pkg*")"
|
||||
# run package check
|
||||
sudo -u ahriman -- ahriman repo-update
|
||||
sudo -u ahriman -- ahriman --log-handler console repo-update --refresh
|
||||
# stop web service lol
|
||||
[[ -z $WEB_PID ]] || kill $WEB_PID
|
||||
@@ -103,11 +103,11 @@ jobs:
|
||||
|
||||
- name: Update packages
|
||||
run: |
|
||||
sudo -u ahriman ahriman \
|
||||
! sudo -u ahriman ahriman \
|
||||
--log-handler "$AHRIMAN_OUTPUT" \
|
||||
repo-update \
|
||||
--exit-code \
|
||||
|| true
|
||||
--refresh
|
||||
|
||||
- name: Add patch
|
||||
run: |
|
||||
|
||||
@@ -222,6 +222,7 @@ Again, the most checks can be performed by `tox` command, though some additional
|
||||
* On the other hand, it is allowed to change method signatures, however, it is recommended to add new parameters as optional if possible. Deprecated API can be dropped during major release.
|
||||
* Enumerations (`Enum` classes) are allowed and recommended. However, it is recommended to use `StrEnum` class if there are from/to string conversions and `IntEnum` otherwise.
|
||||
* `Generator` return type is not allowed. Generator functions must return generic `Iterator` object. Documentation should be described as `Yields`, however, because of pylint checks. Unfortunately, `Iterable` return type is not available for generators also, because of specific `contextlib.contextmanager` case.
|
||||
* Tests must not be parametrized. It is better to write separate test, which covers specific line of code rather than testing all over again.
|
||||
|
||||
### Other checks
|
||||
|
||||
@@ -229,6 +230,17 @@ The projects also uses typing checks (provided by `mypy`) and some linter checks
|
||||
|
||||
Frontend checks normally are performed by `eslint` (e.g. `npx run eslint`).
|
||||
|
||||
## AI usage policy
|
||||
|
||||
AI tools may be used when working on the project, including writing code, tests, and documentation, debugging problems, and preparing issue reports. Contributors remain responsible for everything they submit, including content generated or suggested by AI.
|
||||
|
||||
* Review and understand every submitted change. You must be able to explain the implementation, respond to review feedback, and correct any problems.
|
||||
* Do not list AI tools as commit authors or co-authors, including in `Co-authored-by` trailers. Authorship must remain with the human contributors responsible for the changes.
|
||||
* Discussions in issues and pull requests must be led by humans. Participate personally, explain your reasoning, and respond to questions and review feedback yourself. AI tools may help with wording or translation, but must not conduct discussions on your behalf.
|
||||
* Verify claims, references, and reproduction steps before submitting an issue or pull request. Do not submit unreviewed AI output or claim that checks passed unless they were run and you verified the results.
|
||||
|
||||
Maintainers may close submissions that do not meet these requirements. Using AI does not transfer responsibility for reviewing or fixing a contribution to maintainers.
|
||||
|
||||
## Developers how to
|
||||
|
||||
### Run automated checks
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH AHRIMAN "1" "2026\-10\-20" "ahriman 2.23.1" "ArcH linux ReposItory MANager"
|
||||
.TH AHRIMAN "1" "2026\-10\-30" "ahriman 2.23.6" "ArcH linux ReposItory MANager"
|
||||
.SH NAME
|
||||
ahriman \- ArcH linux ReposItory MANager
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.23.1"
|
||||
__version__ = "2.23.6"
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import sys
|
||||
|
||||
from ahriman.application.ahriman import run
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run())
|
||||
@@ -22,7 +22,7 @@ from collections.abc import Callable, Iterable
|
||||
from ahriman.application.application.application_packages import ApplicationPackages
|
||||
from ahriman.application.application.application_repository import ApplicationRepository
|
||||
from ahriman.core.formatters import UpdatePrinter
|
||||
from ahriman.core.tree import Tree
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@@ -95,43 +95,39 @@ class Application(ApplicationPackages, ApplicationRepository):
|
||||
"""
|
||||
self.repository.triggers.on_stop()
|
||||
|
||||
def print_updates(self, packages: list[Package], *, log_fn: Callable[[str], None]) -> None:
|
||||
def print_updates(self, plan: BuildPlan, log_fn: Callable[[str], None], *, bump_pkgrel: bool = True) -> None:
|
||||
"""
|
||||
print list of packages to be built. This method will build dependency tree and print updates accordingly
|
||||
print packages and their reasons, grouped by dependency step
|
||||
|
||||
Args:
|
||||
packages(list[Package]): package list to be printed
|
||||
plan(BuildPlan): packages and selection reasons to be printed
|
||||
log_fn(Callable[[str], None]): logger function to log updates
|
||||
bump_pkgrel(bool, optional): whether duplicate releases are expected to increment
|
||||
"""
|
||||
local_versions = {package.base: package.version for package in self.repository.packages()}
|
||||
UpdatePrinter(plan, local_versions, bump_pkgrel=bump_pkgrel)(verbose=True, log_fn=log_fn)
|
||||
|
||||
tree = Tree.resolve(packages)
|
||||
for level in tree:
|
||||
for package in level:
|
||||
UpdatePrinter(package, local_versions.get(package.base))(verbose=True, log_fn=log_fn, separator=" -> ")
|
||||
|
||||
def with_dependencies(self, packages: list[Package], *, process_dependencies: bool) -> list[Package]:
|
||||
def with_dependencies(self, plan: BuildPlan, *, process_dependencies: bool) -> BuildPlan:
|
||||
"""
|
||||
add missing dependencies to list of packages. This will extract known packages, check dependencies of
|
||||
the supplied packages and add packages which are not presented in the list of known packages.
|
||||
add missing dependencies to a build plan and record which packages require them
|
||||
|
||||
Args:
|
||||
packages(list[Package]): list of source packages of which dependencies have to be processed
|
||||
plan(BuildPlan): selected packages and their reasons
|
||||
process_dependencies(bool): if set to ``False``, dependencies will not be processed
|
||||
|
||||
Returns:
|
||||
list[Package]: updated packages list. Packager for dependencies will be copied from the original package
|
||||
BuildPlan: selected packages and their dependencies
|
||||
|
||||
Examples:
|
||||
In the most cases, in order to avoid build failure, it is required to add missing packages, which can be
|
||||
done by calling::
|
||||
|
||||
>>> application = ...
|
||||
>>> packages = application.with_dependencies(packages, process_dependencies=True)
|
||||
>>> application.print_updates(packages, log_fn=print)
|
||||
>>> plan = application.with_dependencies(plan, process_dependencies=True)
|
||||
>>> application.update(plan)
|
||||
"""
|
||||
if not process_dependencies or not packages:
|
||||
return packages
|
||||
if not process_dependencies or not plan:
|
||||
return plan
|
||||
|
||||
def missing_dependencies(sources: Iterable[Package]) -> dict[str, str | None]:
|
||||
# append list of known packages with packages which are in current sources
|
||||
@@ -157,20 +153,29 @@ class Application(ApplicationPackages, ApplicationRepository):
|
||||
leaf = Package.from_build(source_dir, self.repository.repository_id.architecture, packager)
|
||||
else:
|
||||
leaf = Package.from_aur(package_name, packager, include_provides=True)
|
||||
portion[leaf.base] = leaf
|
||||
# for split packages we need to load all available subpackages here
|
||||
if (existing := portion.get(leaf.base)) is not None:
|
||||
leaf.packages.update(existing.packages)
|
||||
|
||||
portion[leaf.base] = leaf
|
||||
# register package in the database
|
||||
self.reporter.set_unknown(leaf)
|
||||
|
||||
return portion
|
||||
|
||||
known_packages = self._known_packages()
|
||||
with_dependencies: dict[str, Package] = {}
|
||||
for package in packages:
|
||||
for package in plan:
|
||||
with self.in_package_context(package.base, package.version): # use the same context for the logger
|
||||
try:
|
||||
with_dependencies |= new_packages(package)
|
||||
packages = new_packages(package)
|
||||
except Exception:
|
||||
self.logger.exception("could not process dependencies of %s, skip the package", package.base)
|
||||
continue
|
||||
|
||||
return list(with_dependencies.values())
|
||||
# update existing package
|
||||
item = plan.item(package.base)
|
||||
plan.add(packages.pop(package.base), item.reason, item.requester)
|
||||
# append dependencies
|
||||
plan.update(packages.values(), BuildPlanReason.RequiredBy, package.base)
|
||||
|
||||
return plan
|
||||
@@ -23,6 +23,7 @@ from ahriman.application.application.application_properties import ApplicationPr
|
||||
from ahriman.application.application.workers import Updater
|
||||
from ahriman.core.build_tools.sources import Sources
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.packagers import Packagers
|
||||
from ahriman.models.result import Result
|
||||
@@ -182,7 +183,7 @@ class ApplicationRepository(ApplicationProperties):
|
||||
return result
|
||||
|
||||
def updates(self, filter_packages: Iterable[str], *,
|
||||
aur: bool, local: bool, manual: bool, vcs: bool, check_files: bool) -> list[Package]:
|
||||
aur: bool, local: bool, manual: bool, vcs: bool, check_files: bool) -> BuildPlan:
|
||||
"""
|
||||
get list of packages to run update process
|
||||
|
||||
@@ -193,25 +194,21 @@ class ApplicationRepository(ApplicationProperties):
|
||||
manual(bool): include or exclude manual updates
|
||||
vcs(bool): enable or disable checking of VCS packages
|
||||
check_files(bool): check for broken dependencies
|
||||
|
||||
Returns:
|
||||
list[Package]: list of out-of-dated packages
|
||||
BuildPlan: selected packages and their reasons
|
||||
"""
|
||||
updates = {}
|
||||
plan = BuildPlan()
|
||||
|
||||
# always add already built packages, because they will be always added
|
||||
updates.update({
|
||||
package.base: package
|
||||
for package in self.repository.load_archives(self.repository.packages_built())
|
||||
})
|
||||
plan.update(self.repository.load_archives(self.repository.packages_built()), BuildPlanReason.PreBuilt)
|
||||
|
||||
if aur:
|
||||
updates.update({package.base: package for package in self.repository.updates_aur(filter_packages, vcs=vcs)})
|
||||
plan.update(self.repository.updates_aur(filter_packages, vcs=vcs), BuildPlanReason.RegularUpdate)
|
||||
if local:
|
||||
updates.update({package.base: package for package in self.repository.updates_local(vcs=vcs)})
|
||||
plan.update(self.repository.updates_local(vcs=vcs), BuildPlanReason.LocalSourceUpdate)
|
||||
if manual:
|
||||
updates.update({package.base: package for package in self.repository.updates_manual()})
|
||||
plan.update(self.repository.updates_manual(), BuildPlanReason.QueuedRequest)
|
||||
if check_files:
|
||||
updates.update({package.base: package for package in self.repository.updates_dependencies(filter_packages)})
|
||||
plan.update(self.repository.updates_dependencies(filter_packages), BuildPlanReason.BrokenImplicitDependency)
|
||||
|
||||
return [package for _, package in sorted(updates.items())]
|
||||
return plan
|
||||
@@ -21,8 +21,10 @@ import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.application.handlers.update import Update
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.utils import extract_user
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.packagers import Packagers
|
||||
@@ -52,12 +54,14 @@ class Rebuild(Handler):
|
||||
packages = Rebuild.extract_packages(application, args.status, from_database=args.from_database)
|
||||
packages = application.repository.packages_depend_on(packages, args.depends_on)
|
||||
|
||||
Rebuild.check_status(args.exit_code, packages)
|
||||
plan = BuildPlan().update(packages, BuildPlanReason.Rebuild)
|
||||
application.print_updates(plan, Update.log_fn(application, dry_run=args.dry_run), bump_pkgrel=args.increment)
|
||||
|
||||
if args.dry_run:
|
||||
application.print_updates(packages, log_fn=print)
|
||||
Rebuild.check_status(args.exit_code, plan)
|
||||
return
|
||||
|
||||
result = application.update(packages, Packagers(args.username), bump_pkgrel=args.increment)
|
||||
result = application.update(plan, Packagers(args.username), bump_pkgrel=args.increment)
|
||||
Rebuild.check_status(args.exit_code, not result.is_empty)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -23,6 +23,7 @@ from ahriman import __version__
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.formatters import UpdatePrinter
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
@@ -56,7 +57,8 @@ class ServiceUpdates(Handler):
|
||||
if same_version:
|
||||
return
|
||||
|
||||
UpdatePrinter(remote, local_version)(verbose=True, separator=" -> ")
|
||||
plan = BuildPlan().update([remote], BuildPlanReason.RegularUpdate)
|
||||
UpdatePrinter(plan, {remote.base: local_version})(verbose=True)
|
||||
ServiceUpdates.check_status(args.exit_code, same_version)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -147,20 +147,19 @@ class Update(Handler):
|
||||
application(Application): application instance
|
||||
args(argparse.Namespace): command line args
|
||||
"""
|
||||
packages = application.updates(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
|
||||
check_files=args.check_files)
|
||||
plan = application.updates(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
|
||||
check_files=args.check_files)
|
||||
plan = application.with_dependencies(plan, process_dependencies=args.dependencies)
|
||||
if args.changes: # generate changes if requested
|
||||
application.changes(packages)
|
||||
application.changes(plan)
|
||||
|
||||
application.print_updates(plan, Update.log_fn(application, dry_run=args.dry_run), bump_pkgrel=args.increment)
|
||||
if args.dry_run: # exit from application if no build requested
|
||||
Update.check_status(args.exit_code, packages) # status code check
|
||||
Update.check_status(args.exit_code, plan) # status code check
|
||||
return
|
||||
|
||||
packages = application.with_dependencies(packages, process_dependencies=args.dependencies)
|
||||
packagers = Packagers(args.username, {package.base: package.packager for package in packages})
|
||||
|
||||
application.print_updates(packages, log_fn=application.logger.info)
|
||||
result = application.update(packages, packagers, bump_pkgrel=args.increment)
|
||||
packagers = Packagers(args.username, {package.base: package.packager for package in plan})
|
||||
result = application.update(plan, packagers, bump_pkgrel=args.increment)
|
||||
Update.check_status(args.exit_code, not result.is_empty)
|
||||
|
||||
arguments = [
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import re
|
||||
import shlex
|
||||
import tree_sitter_bash
|
||||
|
||||
from collections.abc import Iterator
|
||||
from collections.abc import Iterable, Iterator
|
||||
from enum import StrEnum
|
||||
from tree_sitter import Language, Node, Parser
|
||||
from typing import IO, cast
|
||||
|
||||
from ahriman.core.configuration.shell_interpolator import ShellInterpolator
|
||||
from ahriman.core.exceptions import PkgbuildParserError
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
|
||||
@@ -78,7 +78,7 @@ class PkgbuildNodeField(StrEnum):
|
||||
Value = "value"
|
||||
|
||||
|
||||
class PkgbuildParser:
|
||||
class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
"""
|
||||
PKGBUILD parser implementation in python
|
||||
|
||||
@@ -97,48 +97,38 @@ class PkgbuildParser:
|
||||
original source, with their formatting preserved. Assignments inside shell statements and control-flow nodes are
|
||||
extracted without checking whether those statements would run.
|
||||
|
||||
Each iteration parses the stored source independently, starting from the beginning.
|
||||
|
||||
Examples:
|
||||
Parse package assignments::
|
||||
|
||||
>>> source = b"pkgname=example\\npkgver=1\\n"
|
||||
>>> for patch in PkgbuildParser(BytesIO(source)).parse():
|
||||
>>> for patch in PkgbuildParser(BytesIO(source)):
|
||||
... print(patch.key, patch.value)
|
||||
|
||||
Function bodies are returned as function patches::
|
||||
|
||||
>>> source = b"pkgver() { printf 1; }"
|
||||
>>> for patch in list(PkgbuildParser(BytesIO(source)).parse())
|
||||
>>> for patch in PkgbuildParser(BytesIO(source)):
|
||||
... print(patch.key, patch.value)
|
||||
"""
|
||||
|
||||
_BRACE_EXPANSION = re.compile(r"(.*)\{([^{}]+)\}(.*)")
|
||||
_ESCAPED_CHARACTERS = {
|
||||
"\\$": "$",
|
||||
"\\`": "`",
|
||||
"\\\"": "\"",
|
||||
"\\\n": "",
|
||||
}
|
||||
|
||||
def __init__(self, stream: IO[bytes]) -> None:
|
||||
""""""
|
||||
"""
|
||||
Args:
|
||||
stream(IO[bytes]): input PKGBUILD stream
|
||||
"""
|
||||
self._content = stream.read()
|
||||
|
||||
@staticmethod
|
||||
def _expand_array(value: str, *, expand: bool = True) -> list[str]:
|
||||
"""
|
||||
expand comma-separated brace expressions in a value
|
||||
|
||||
Args:
|
||||
value(str): value that may contain a brace expression
|
||||
expand(bool, optional): whether brace expansion is allowed (Default value = True)
|
||||
|
||||
Returns:
|
||||
list[str]: expanded values if applicable
|
||||
"""
|
||||
match = PkgbuildParser._BRACE_EXPANSION.fullmatch(value)
|
||||
# if there is no comma inside it should be treated as normal value
|
||||
if match is None or not expand or "," not in match.group(2):
|
||||
return [value]
|
||||
|
||||
prefix, values, suffix = match.groups()
|
||||
return [f"{prefix}{item}{suffix}" for item in values.split(",")]
|
||||
|
||||
@staticmethod
|
||||
def _text(node: Node) -> str:
|
||||
def text(node: Node) -> str:
|
||||
"""
|
||||
read the original source text represented by a syntax tree node
|
||||
|
||||
@@ -150,6 +140,50 @@ class PkgbuildParser:
|
||||
"""
|
||||
return cast(bytes, node.text).decode("utf8", errors="backslashreplace")
|
||||
|
||||
@staticmethod
|
||||
def unquote(value: str) -> str:
|
||||
"""
|
||||
remove shell quotes and escapes from a single value
|
||||
|
||||
Args:
|
||||
value(str): shell value to unquote
|
||||
|
||||
Returns:
|
||||
str: unquoted value
|
||||
"""
|
||||
return "".join(shlex.split(value, comments=False, posix=True))
|
||||
|
||||
@staticmethod
|
||||
def value(node: Node) -> str:
|
||||
"""
|
||||
extract a string value from a syntax tree node
|
||||
|
||||
Args:
|
||||
node(Node): syntax tree node to extract
|
||||
|
||||
Returns:
|
||||
str: extracted string value
|
||||
"""
|
||||
def unescape(source: str) -> str:
|
||||
for original, replacement in PkgbuildParser._ESCAPED_CHARACTERS.items():
|
||||
source = source.replace(original, replacement)
|
||||
return source
|
||||
|
||||
if node.type == PkgbuildNodeType.Concatenation:
|
||||
return "".join(PkgbuildParser.value(child) for child in node.named_children)
|
||||
|
||||
value = PkgbuildParser.text(node)
|
||||
match node.type:
|
||||
case PkgbuildNodeType.String | PkgbuildNodeType.StringContent:
|
||||
if node.type == PkgbuildNodeType.String:
|
||||
value = PkgbuildParser.unquote(value)
|
||||
# protect escaped backslashes from being interpreted a second time.
|
||||
return "\\".join(unescape(part) for part in value.split("\\\\"))
|
||||
case PkgbuildNodeType.Number | PkgbuildNodeType.RawString | PkgbuildNodeType.Word:
|
||||
return PkgbuildParser.unquote(value)
|
||||
case _:
|
||||
return value
|
||||
|
||||
def _assignment(self, node: Node) -> PkgbuildPatch:
|
||||
"""
|
||||
convert an assignment node
|
||||
@@ -160,40 +194,91 @@ class PkgbuildParser:
|
||||
Returns:
|
||||
PkgbuildPatch: parsed assignment
|
||||
"""
|
||||
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.Name))
|
||||
value = cast(Node, node.child_by_field_name(PkgbuildNodeField.Value))
|
||||
key = self._text(name)
|
||||
key = self.text(cast(Node, node.child_by_field_name(PkgbuildNodeField.Name)))
|
||||
value = node.child_by_field_name(PkgbuildNodeField.Value)
|
||||
# bash permits assignments without a value (for example ``IFS=``).
|
||||
# tree-sitter represents those assignments without a value node.
|
||||
if value is None:
|
||||
return PkgbuildPatch(key, "")
|
||||
|
||||
match value.type:
|
||||
case PkgbuildNodeType.Array:
|
||||
array_values = []
|
||||
values = []
|
||||
for element in filter(lambda child: child.type != PkgbuildNodeType.Comment, value.named_children):
|
||||
item = self._value(element)
|
||||
values = self._expand_array(item, expand=element.type == PkgbuildNodeType.Concatenation)
|
||||
array_values.extend(values)
|
||||
return PkgbuildPatch(key, array_values)
|
||||
values.extend(self._expand_array(element))
|
||||
return PkgbuildPatch(key, values)
|
||||
|
||||
case _:
|
||||
return PkgbuildPatch(key, self._value(value))
|
||||
return PkgbuildPatch(key, self.value(value))
|
||||
|
||||
def _read(self, node: Node) -> Iterator[PkgbuildPatch]:
|
||||
def _expand_array(self, node: Node) -> list[str]:
|
||||
"""
|
||||
expand simple comma-separated brace groups in an array element
|
||||
|
||||
Args:
|
||||
node(Node): array element to expand
|
||||
|
||||
Returns:
|
||||
list[str]: expanded element values
|
||||
"""
|
||||
if node.type != PkgbuildNodeType.Concatenation:
|
||||
return [self.value(node)]
|
||||
|
||||
values = [""]
|
||||
children = node.named_children
|
||||
while children:
|
||||
match children[:3]:
|
||||
case [
|
||||
Node(type=PkgbuildNodeType.Word, text=b"{"),
|
||||
Node(type=PkgbuildNodeType.Word) as content,
|
||||
Node(type=PkgbuildNodeType.Word, text=b"}"),
|
||||
] if "," in (escaped := self.text(content).replace("\\,", ShellInterpolator.DATA_LINK_ESCAPE)):
|
||||
parts = [
|
||||
self.unquote(part).replace(ShellInterpolator.DATA_LINK_ESCAPE, ",")
|
||||
for part in escaped.split(",")
|
||||
]
|
||||
children = children[3:]
|
||||
|
||||
case _:
|
||||
parts = [self.value(children.pop(0))]
|
||||
|
||||
values = [prefix + part for prefix in values for part in parts]
|
||||
|
||||
return values
|
||||
|
||||
def _read(self, node: Node, values: dict[str | None, PkgbuildPatch]) -> Iterator[PkgbuildPatch]:
|
||||
"""
|
||||
find assignments and functions in a syntax tree node
|
||||
|
||||
Args:
|
||||
node(Node): syntax tree node to inspect
|
||||
values(dict[str | None, PkgbuildPatch]): cached assignments
|
||||
|
||||
Yields:
|
||||
PkgbuildPatch: parsed entries
|
||||
"""
|
||||
match node.type:
|
||||
case PkgbuildNodeType.VariableAssignment if not any(child.type == PkgbuildNodeType.Append for child in node.children):
|
||||
yield self._assignment(node)
|
||||
case PkgbuildNodeType.VariableAssignment if any(child.type == PkgbuildNodeType.Append for child in node.children):
|
||||
patch = self._assignment(node)
|
||||
match values.get(patch.key), patch.value:
|
||||
case PkgbuildPatch(value=str() as previous), str() as appended:
|
||||
patch = PkgbuildPatch(patch.key, previous + appended)
|
||||
case PkgbuildPatch(value=str() as previous), list() as appended:
|
||||
patch = PkgbuildPatch(patch.key, [previous, *appended])
|
||||
case PkgbuildPatch(value=list() as previous), list() as appended:
|
||||
patch = PkgbuildPatch(patch.key, previous + appended)
|
||||
values[patch.key] = patch
|
||||
yield patch
|
||||
|
||||
case PkgbuildNodeType.VariableAssignment:
|
||||
patch = self._assignment(node)
|
||||
values[patch.key] = patch
|
||||
yield patch
|
||||
|
||||
case PkgbuildNodeType.FunctionDefinition:
|
||||
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.Name))
|
||||
body = cast(Node, node.child_by_field_name(PkgbuildNodeField.Body))
|
||||
yield PkgbuildPatch(f"{self._text(name)}()", self._text(body))
|
||||
yield PkgbuildPatch(f"{self.text(name)}()", self.text(body))
|
||||
|
||||
case _:
|
||||
# descend into statements, but skip command arguments and values
|
||||
@@ -205,31 +290,7 @@ class PkgbuildParser:
|
||||
PkgbuildNodeType.String,
|
||||
PkgbuildNodeType.Word,
|
||||
):
|
||||
yield from self._read(child)
|
||||
|
||||
def _value(self, node: Node) -> str:
|
||||
"""
|
||||
extract a string value from a syntax tree node
|
||||
|
||||
Args:
|
||||
node(Node): syntax tree node to extract
|
||||
|
||||
Returns:
|
||||
str: extracted string value
|
||||
"""
|
||||
if node.type in (PkgbuildNodeType.Concatenation, PkgbuildNodeType.String):
|
||||
return "".join(self._value(child) for child in node.named_children)
|
||||
|
||||
value = self._text(node)
|
||||
match node.type:
|
||||
case PkgbuildNodeType.StringContent:
|
||||
value = f'"{value}"'
|
||||
case PkgbuildNodeType.Number | PkgbuildNodeType.RawString | PkgbuildNodeType.Word:
|
||||
pass
|
||||
case _:
|
||||
return value
|
||||
|
||||
return "".join(shlex.split(value, comments=False, posix=True))
|
||||
yield from self._read(child, values)
|
||||
|
||||
def parse(self) -> Iterator[PkgbuildPatch]:
|
||||
"""
|
||||
@@ -255,4 +316,13 @@ class PkgbuildParser:
|
||||
f"syntax error at line {error.start_point.row + 1}, column {error.start_point.column + 1}"
|
||||
)
|
||||
|
||||
yield from self._read(tree.root_node)
|
||||
yield from self._read(tree.root_node, {})
|
||||
|
||||
def __iter__(self) -> Iterator[PkgbuildPatch]:
|
||||
"""
|
||||
iterate over the parsed entries
|
||||
|
||||
Returns:
|
||||
Iterator[PkgbuildPatch]: parsed entries
|
||||
"""
|
||||
return self.parse()
|
||||
@@ -46,7 +46,7 @@ class Printer:
|
||||
if not verbose and not prop.is_required:
|
||||
continue
|
||||
indent = "\t" * prop.indent
|
||||
log_fn(f"{indent}{prop.name}{separator}{prop.value}")
|
||||
log_fn(f"{indent}{prop.name}{separator if prop.separator is None else prop.separator}{prop.value}")
|
||||
|
||||
def properties(self) -> list[Property]:
|
||||
"""
|
||||
|
||||
@@ -17,30 +17,38 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections.abc import Iterator
|
||||
|
||||
from ahriman.core.formatters.string_printer import StringPrinter
|
||||
from ahriman.core.tree import Tree
|
||||
from ahriman.core.utils import full_version, parse_version
|
||||
from ahriman.models.build_plan import BuildPlan
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.property import Property
|
||||
|
||||
|
||||
class UpdatePrinter(StringPrinter):
|
||||
"""
|
||||
print content of the package update
|
||||
print content of the packages update
|
||||
|
||||
Attributes:
|
||||
package(Package): remote (new) package object
|
||||
local_version(str | None): local version of the package if any
|
||||
plan(BuildPlan): plan to display
|
||||
local_versions(dict[str, str]): published package versions indexed by base
|
||||
bump_pkgrel(bool): whether duplicate package releases are expected to increment
|
||||
"""
|
||||
|
||||
def __init__(self, remote: Package, local_version: str | None) -> None:
|
||||
def __init__(self, plan: BuildPlan, local_versions: dict[str, str], *, bump_pkgrel: bool = True) -> None:
|
||||
"""
|
||||
Args:
|
||||
remote(Package): remote (new) package object
|
||||
local_version(str | None): local version of the package if any
|
||||
plan(BuildPlan): plan to display
|
||||
local_versions(dict[str, str]): published package versions indexed by base
|
||||
bump_pkgrel(bool, optional): whether duplicate package releases are expected to increment
|
||||
(Default value = True)
|
||||
"""
|
||||
StringPrinter.__init__(self, remote.base)
|
||||
self.package = remote
|
||||
self.local_version = local_version
|
||||
StringPrinter.__init__(self, "Build plan" if plan else "No packages selected")
|
||||
self.plan = plan
|
||||
self.local_versions = local_versions
|
||||
self.bump_pkgrel = bump_pkgrel
|
||||
|
||||
def properties(self) -> list[Property]:
|
||||
"""
|
||||
@@ -49,9 +57,48 @@ class UpdatePrinter(StringPrinter):
|
||||
Returns:
|
||||
list[Property]: list of content properties
|
||||
"""
|
||||
if (pkgrel := self.package.next_pkgrel(self.local_version)) is not None:
|
||||
epoch, pkgver, _ = parse_version(self.package.version)
|
||||
return [
|
||||
prop
|
||||
for level in Tree.resolve(self.plan)
|
||||
for package in level
|
||||
for prop in self.properties_package(package)
|
||||
]
|
||||
|
||||
def properties_package(self, package: Package) -> Iterator[Property]:
|
||||
"""
|
||||
generate list of properties for the specific package
|
||||
|
||||
Args:
|
||||
package(Package): package object
|
||||
|
||||
Yields:
|
||||
Property: list of properties belonging to the package
|
||||
"""
|
||||
# package header
|
||||
yield Property(package.base, "", is_required=True)
|
||||
|
||||
# set version update message
|
||||
local_version, remote_version = self.versions(package)
|
||||
yield Property(local_version, remote_version, is_required=True, indent=2, separator=" -> ")
|
||||
|
||||
# set reason
|
||||
item = self.plan.item(package.base)
|
||||
reason = item.reason.value if item.requester is None else f"{item.reason} {item.requester}"
|
||||
yield Property("Reason", reason, indent=2)
|
||||
|
||||
def versions(self, package: Package) -> tuple[str, str]:
|
||||
"""
|
||||
generate version property
|
||||
|
||||
Returns:
|
||||
tuple[str, str]: extract current and updated versions for the package
|
||||
"""
|
||||
local_version = self.local_versions.get(package.base)
|
||||
|
||||
if self.bump_pkgrel and (pkgrel := package.next_pkgrel(local_version)) is not None:
|
||||
epoch, pkgver, _ = parse_version(package.version)
|
||||
effective_new_version = full_version(epoch, pkgver, pkgrel)
|
||||
else:
|
||||
effective_new_version = self.package.version
|
||||
return [Property(self.local_version or "N/A", effective_new_version, is_required=True)]
|
||||
effective_new_version = package.version
|
||||
|
||||
return local_version or "N/A", effective_new_version
|
||||
@@ -188,6 +188,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
self.reporter.set_pending(local.base)
|
||||
self.event(local.base, EventType.PackageOutdated, "Locally pulled sources are outdated")
|
||||
result.append(remote)
|
||||
|
||||
except Exception:
|
||||
self.logger.exception("could not process package at %s", cache_dir)
|
||||
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections.abc import Iterable, Iterator
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
from typing import Any, Self
|
||||
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
class BuildPlanReason(StrEnum):
|
||||
"""
|
||||
reason why package was selected for a build plan
|
||||
|
||||
Attributes:
|
||||
BrokenImplicitDependency(BuildPlanReason): package has a broken implicit dependency
|
||||
LocalSourceUpdate(BuildPlanReason): locally sourced package has an update
|
||||
PreBuilt(BuildPlanReason): package has already been built
|
||||
QueuedRequest(BuildPlanReason): package was manually queued
|
||||
Rebuild(BuildPlanReason): package was selected for rebuild
|
||||
RegularUpdate(BuildPlanReason): package has an AUR update
|
||||
RequiredBy(BuildPlanReason): package is required by another selected package
|
||||
"""
|
||||
|
||||
BrokenImplicitDependency = "broken implicit dependency"
|
||||
LocalSourceUpdate = "local source update"
|
||||
PreBuilt = "pre-built"
|
||||
QueuedRequest = "queued request"
|
||||
Rebuild = "rebuild"
|
||||
RegularUpdate = "regular update"
|
||||
RequiredBy = "required by"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BuildPlanItem:
|
||||
"""
|
||||
one package and the reason it appears in a build plan
|
||||
|
||||
Attributes:
|
||||
package(Package): package selected for the plan
|
||||
reason(BuildPlanReason): why the package was selected
|
||||
requester(str | None): package that requires this package
|
||||
"""
|
||||
|
||||
package: Package
|
||||
reason: BuildPlanReason
|
||||
requester: str | None = None
|
||||
|
||||
|
||||
class BuildPlan(Iterable[Package]):
|
||||
"""
|
||||
in-memory preview of the packages selected for a build operation
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
initialize an empty build plan
|
||||
"""
|
||||
self._items: dict[str, BuildPlanItem] = {}
|
||||
|
||||
@property
|
||||
def items(self) -> list[BuildPlanItem]:
|
||||
"""
|
||||
get plan items in stable package-base order
|
||||
|
||||
Returns:
|
||||
list[BuildPlanItem]: selected plan items
|
||||
"""
|
||||
return [self._items[base] for base in sorted(self._items)]
|
||||
|
||||
@property
|
||||
def packages(self) -> list[Package]:
|
||||
"""
|
||||
get packages in stable package-base order
|
||||
|
||||
Returns:
|
||||
list[Package]: selected packages
|
||||
"""
|
||||
return [item.package for item in self.items]
|
||||
|
||||
def add(self, package: Package, reason: BuildPlanReason, requester: str | None = None) -> BuildPlanItem:
|
||||
"""
|
||||
add or update a package in the plan
|
||||
|
||||
Args:
|
||||
package(Package): package selected for the plan
|
||||
reason(BuildPlanReason): reason for selecting it
|
||||
requester(str | None, optional): package requiring this dependency (Default value = None)
|
||||
|
||||
Returns:
|
||||
BuildPlanItem: plan item for the package
|
||||
"""
|
||||
item = self._items[package.base] = BuildPlanItem(package, reason, requester)
|
||||
return item
|
||||
|
||||
def item(self, package_base: str) -> BuildPlanItem:
|
||||
"""
|
||||
get a plan item by package base
|
||||
|
||||
Args:
|
||||
package_base(str): package base to look up
|
||||
|
||||
Returns:
|
||||
BuildPlanItem: matching item
|
||||
"""
|
||||
return self._items[package_base]
|
||||
|
||||
def update(self, packages: Iterable[Package], reason: BuildPlanReason, requester: str | None = None) -> Self:
|
||||
"""
|
||||
bulk update packages with the same reason
|
||||
|
||||
Args:
|
||||
packages(Iterable[Package]): list of new packages to be added
|
||||
reason(BuildPlanReason): reason for selecting them
|
||||
requester(str | None, optional): package requiring these dependencies (Default value = None)
|
||||
|
||||
Returns:
|
||||
Self: updated plan instance
|
||||
"""
|
||||
for package in packages:
|
||||
self.add(package, reason, requester)
|
||||
return self
|
||||
|
||||
def __contains__(self, item: Package) -> bool:
|
||||
"""
|
||||
check whether plan holds a package or not
|
||||
|
||||
Args:
|
||||
item(Package): package to lookup
|
||||
|
||||
Returns:
|
||||
bool: ``True`` in case if the package is already in the plan and ``False`` otherwise
|
||||
"""
|
||||
return item.base in self._items
|
||||
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
"""
|
||||
check if other is the same object
|
||||
|
||||
Args:
|
||||
other(Any): other object instance
|
||||
|
||||
Returns:
|
||||
bool: ``True`` if the other object is the same and ``False`` otherwise
|
||||
"""
|
||||
if not isinstance(other, BuildPlan):
|
||||
return False
|
||||
return self.items == other.items
|
||||
|
||||
def __iter__(self) -> Iterator[Package]:
|
||||
"""
|
||||
iterate over selected packages in stable package-base order
|
||||
|
||||
Returns:
|
||||
Package: selected package
|
||||
"""
|
||||
return iter(self.packages)
|
||||
|
||||
def __len__(self) -> int:
|
||||
"""
|
||||
get number of selected packages
|
||||
|
||||
Returns:
|
||||
int: number of selected packages
|
||||
"""
|
||||
return len(self._items)
|
||||
@@ -80,8 +80,7 @@ class Pkgbuild(Mapping[str, Any]):
|
||||
Returns:
|
||||
Self: constructed instance of self
|
||||
"""
|
||||
parser = PkgbuildParser(stream)
|
||||
fields = {patch.key: patch for patch in parser.parse()}
|
||||
fields = {patch.key: patch for patch in PkgbuildParser(stream)}
|
||||
|
||||
# pkgbase is optional field, the pkgname must be used instead if not set
|
||||
# however, pkgname is not presented is "package()" functions which we are parsing here too,
|
||||
|
||||
@@ -31,9 +31,11 @@ class Property:
|
||||
value(Any): property value
|
||||
is_required(bool): if set to ``True`` then this property is required
|
||||
indent(int): property indentation level
|
||||
separator(str | None): optional override for separator
|
||||
"""
|
||||
|
||||
name: str
|
||||
value: Any
|
||||
is_required: bool = field(default=False, kw_only=True)
|
||||
indent: int = 1
|
||||
separator: str | None = None
|
||||
@@ -4,8 +4,10 @@ from typing import Any
|
||||
from unittest.mock import MagicMock, call as MockCall
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.core.tree import Leaf, Tree
|
||||
from ahriman.core.tree import Tree
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_description import PackageDescription
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
||||
@@ -54,13 +56,11 @@ def test_print_updates(application: Application, package_ahriman: Package, mocke
|
||||
"""
|
||||
must print updates
|
||||
"""
|
||||
tree = Tree([Leaf(package_ahriman)])
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.tree.Tree.resolve", return_value=tree.levels())
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
application.print_updates([package_ahriman], log_fn=print)
|
||||
print_mock.assert_called_once_with(verbose=True, log_fn=print, separator=" -> ")
|
||||
application.print_updates(BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate), log_fn=print)
|
||||
print_mock.assert_called_once_with(verbose=True, log_fn=print, separator=": ")
|
||||
|
||||
|
||||
def test_with_dependencies(application: Application, package_ahriman: Package, package_python_schedule: Package,
|
||||
@@ -99,8 +99,11 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
|
||||
return_value={"devtools", "python-build", "python-pytest"})
|
||||
status_client_mock = mocker.patch("ahriman.core.status.Client.set_unknown")
|
||||
|
||||
result = application.with_dependencies([package_ahriman], process_dependencies=True)
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
result = application.with_dependencies(plan, process_dependencies=True)
|
||||
assert {package.base: package for package in result} == packages
|
||||
assert result.item(package_ahriman.base).requester is None
|
||||
assert result.item(package_python_schedule.base).requester == package_ahriman.base
|
||||
package_aur_mock.assert_has_calls([
|
||||
MockCall(package_python_schedule.base, package_ahriman.packager, include_provides=True),
|
||||
MockCall("python-installer", package_ahriman.packager, include_provides=True),
|
||||
@@ -117,6 +120,42 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
|
||||
], any_order=True)
|
||||
|
||||
|
||||
def test_with_dependencies_split(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must preserve resolved subpackages during dependency resolution
|
||||
"""
|
||||
def package(base: str, name: str, dependencies: list[str]) -> Package:
|
||||
return Package(
|
||||
base=base,
|
||||
version="1-1",
|
||||
remote=package_ahriman.remote,
|
||||
packages={name: PackageDescription(depends=dependencies)},
|
||||
)
|
||||
|
||||
packages = {
|
||||
"ahriman-core": package("ahriman", "ahriman-core", ["python-tree-sitter-bash"]),
|
||||
"ahriman-web": package("ahriman", "ahriman-web", ["ahriman-core"]),
|
||||
"python-tree-sitter-bash": package("python-tree-sitter-bash", "python-tree-sitter-bash", []),
|
||||
}
|
||||
mocker.patch("ahriman.application.application.Application._known_packages", return_value=set())
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=False)
|
||||
mocker.patch("ahriman.models.package.Package.from_aur", side_effect=lambda name, *args, **kwargs: packages[name])
|
||||
mocker.patch("ahriman.core.status.Client.set_unknown")
|
||||
|
||||
plan = BuildPlan().update([
|
||||
package("ahriman", "ahriman", ["ahriman-core", "ahriman-web"])
|
||||
], BuildPlanReason.QueuedRequest)
|
||||
result = application.with_dependencies(plan, process_dependencies=True)
|
||||
assert [[item.base for item in level] for level in Tree.resolve(result)] == [
|
||||
["python-tree-sitter-bash"], ["ahriman"],
|
||||
]
|
||||
|
||||
plan_item = result.item("ahriman")
|
||||
assert plan_item.package.packages.keys() == {"ahriman", "ahriman-core", "ahriman-web"}
|
||||
assert plan_item.reason == BuildPlanReason.QueuedRequest
|
||||
assert plan_item.requester is None
|
||||
|
||||
|
||||
def test_with_dependencies_exception(application: Application, package_ahriman: Package,
|
||||
package_python_schedule: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
@@ -148,7 +187,10 @@ def test_with_dependencies_exception(application: Application, package_ahriman:
|
||||
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)
|
||||
plan = BuildPlan()
|
||||
plan.add(package_ahriman, BuildPlanReason.RegularUpdate)
|
||||
assert application.with_dependencies(plan, process_dependencies=True) is plan
|
||||
assert plan.packages == [package_ahriman]
|
||||
|
||||
|
||||
def test_with_dependencies_skip(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
@@ -157,8 +199,9 @@ def test_with_dependencies_skip(application: Application, package_ahriman: Packa
|
||||
"""
|
||||
packages_mock = mocker.patch("ahriman.application.application.Application._known_packages")
|
||||
|
||||
assert application.with_dependencies([package_ahriman], process_dependencies=False) == [package_ahriman]
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
assert application.with_dependencies(plan, process_dependencies=False).packages == [package_ahriman]
|
||||
packages_mock.assert_not_called()
|
||||
|
||||
assert application.with_dependencies([], process_dependencies=True) == []
|
||||
assert not application.with_dependencies(BuildPlan(), process_dependencies=True)
|
||||
packages_mock.assert_not_called()
|
||||
@@ -2,12 +2,12 @@ import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.rebuild import Rebuild
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.packagers import Packagers
|
||||
@@ -48,15 +48,18 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on",
|
||||
return_value=[package_ahriman])
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.Rebuild)
|
||||
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
|
||||
application_packages_mock.assert_called_once_with([package_ahriman], None)
|
||||
application_mock.assert_called_once_with([package_ahriman], Packagers(args.username), bump_pkgrel=args.increment)
|
||||
check_mock.assert_has_calls([MockCall(False, [package_ahriman]), MockCall(False, True)])
|
||||
print_mock.assert_called_once_with(plan, pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
|
||||
application_mock.assert_called_once_with(plan, Packagers(args.username), bump_pkgrel=args.increment)
|
||||
check_mock.assert_called_once_with(False, True)
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@@ -94,8 +97,9 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_called_once_with(False, [package_ahriman])
|
||||
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.Rebuild)
|
||||
check_mock.assert_called_once_with(False, plan)
|
||||
print_mock.assert_called_once_with(plan, pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
|
||||
|
||||
|
||||
def test_run_filter(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
@@ -109,6 +113,7 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, repo
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
@@ -125,6 +130,7 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
@@ -147,7 +153,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, [])
|
||||
check_mock.assert_called_once_with(True, BuildPlan())
|
||||
|
||||
|
||||
def test_run_build_empty_exception(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
@@ -161,11 +167,12 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
|
||||
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages")
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_has_calls([MockCall(True, [package_ahriman]), MockCall(True, False)])
|
||||
check_mock.assert_called_once_with(True, False)
|
||||
|
||||
|
||||
def test_extract_packages(application: Application, mocker: MockerFixture) -> None:
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
_, repository_id = configuration.check_loaded()
|
||||
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
||||
package_mock.assert_called_once_with(package_ahriman.base, None)
|
||||
application_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" -> ")
|
||||
application_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=": ")
|
||||
check_mock.assert_called_once_with(args.exit_code, False)
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from ahriman.application.handlers.update import Update
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.packagers import Packagers
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@@ -65,22 +66,23 @@ def test_perform_action(args: argparse.Namespace, application: Application, pack
|
||||
result.add_updated(package_ahriman)
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
||||
return_value=[package_ahriman])
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
return_value=plan)
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=plan)
|
||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
Update.perform_action(application, args)
|
||||
application_mock.assert_called_once_with([package_ahriman],
|
||||
application_mock.assert_called_once_with(plan,
|
||||
Packagers(args.username, {package_ahriman.base: "packager"}),
|
||||
bump_pkgrel=args.increment)
|
||||
updates_mock.assert_called_once_with(
|
||||
args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, check_files=args.check_files)
|
||||
changes_mock.assert_called_once_with([package_ahriman])
|
||||
dependencies_mock.assert_called_once_with([package_ahriman], process_dependencies=args.dependencies)
|
||||
changes_mock.assert_called_once_with(plan)
|
||||
dependencies_mock.assert_called_once_with(plan, process_dependencies=args.dependencies)
|
||||
check_mock.assert_called_once_with(False, True)
|
||||
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
|
||||
print_mock.assert_called_once_with(plan, pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
|
||||
|
||||
|
||||
def test_perform_action_empty_exception(args: argparse.Namespace, application: Application,
|
||||
@@ -91,11 +93,13 @@ def test_perform_action_empty_exception(args: argparse.Namespace, application: A
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
args.dry_run = True
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=BuildPlan())
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
||||
Update.perform_action(application, args)
|
||||
check_mock.assert_called_once_with(True, [])
|
||||
print_mock.assert_called_once_with(BuildPlan(), pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
|
||||
check_mock.assert_called_once_with(True, BuildPlan())
|
||||
|
||||
|
||||
def test_perform_action_update_empty_exception(args: argparse.Namespace, application: Application,
|
||||
@@ -106,10 +110,11 @@ def test_perform_action_update_empty_exception(args: argparse.Namespace, applica
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=plan)
|
||||
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=plan)
|
||||
mocker.patch("ahriman.application.application.Application.changes")
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
||||
Update.perform_action(application, args)
|
||||
@@ -125,15 +130,21 @@ def test_perform_action_dry_run(args: argparse.Namespace, application: Applicati
|
||||
args.dry_run = True
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
||||
return_value=plan)
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=plan)
|
||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||
|
||||
Update.perform_action(application, args)
|
||||
updates_mock.assert_called_once_with(
|
||||
args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, check_files=args.check_files)
|
||||
application_mock.assert_not_called()
|
||||
changes_mock.assert_called_once_with([package_ahriman])
|
||||
check_mock.assert_called_once_with(False, [package_ahriman])
|
||||
changes_mock.assert_called_once_with(plan)
|
||||
dependencies_mock.assert_called_once_with(plan, process_dependencies=args.dependencies)
|
||||
print_mock.assert_called_once_with(plan, pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
|
||||
check_mock.assert_called_once_with(False, plan)
|
||||
|
||||
|
||||
def test_perform_action_no_changes(args: argparse.Namespace, application: Application, mocker: MockerFixture) -> None:
|
||||
@@ -145,7 +156,9 @@ def test_perform_action_no_changes(args: argparse.Namespace, application: Applic
|
||||
args.changes = False
|
||||
mocker.patch("ahriman.application.application.Application.update")
|
||||
mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
mocker.patch("ahriman.application.application.Application.updates")
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=BuildPlan())
|
||||
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=BuildPlan())
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||
|
||||
Update.perform_action(application, args)
|
||||
|
||||
@@ -18,9 +18,48 @@ def test_expand_array() -> None:
|
||||
parser = PkgbuildParser(BytesIO(b"array=(prefix{first,second}suffix)"))
|
||||
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefixfirstsuffix", "prefixsecondsuffix"])]
|
||||
|
||||
parser = PkgbuildParser(BytesIO(br"array=(prefix{first\,second,third}suffix)"))
|
||||
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefixfirst,secondsuffix", "prefixthirdsuffix"])]
|
||||
|
||||
parser = PkgbuildParser(BytesIO(b"""array=("prefix{first,second}suffix")"""))
|
||||
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefix{first,second}suffix"])]
|
||||
|
||||
parser = PkgbuildParser(BytesIO(b"""array=(x"{a,b}" x'{a,b}' "{x,y}"{a,b})"""))
|
||||
assert list(parser) == [PkgbuildPatch("array", ["x{a,b}", "x{a,b}", "{x,y}a", "{x,y}b"])]
|
||||
|
||||
parser = PkgbuildParser(BytesIO(b"""array=(${v:-a,b}suffix ${v:-a,b}{,.sig} $(echo '{a,b}')suffix)"""))
|
||||
assert list(parser) == [PkgbuildPatch("array", [
|
||||
"${v:-a,b}suffix", "${v:-a,b}", "${v:-a,b}.sig", "$(echo '{a,b}')suffix",
|
||||
])]
|
||||
|
||||
|
||||
def test_parse_append_array() -> None:
|
||||
"""
|
||||
must retain original array elements when appending and iterating again
|
||||
"""
|
||||
parser = PkgbuildParser(BytesIO(
|
||||
b"source=(base.patch)\nsource+=(extra.patch)\nsource+=(last.patch)\nsource=(reset.patch)\nsource+=(extra.patch)"
|
||||
))
|
||||
expected = [
|
||||
PkgbuildPatch("source", ["base.patch"]),
|
||||
PkgbuildPatch("source", ["base.patch", "extra.patch"]),
|
||||
PkgbuildPatch("source", ["base.patch", "extra.patch", "last.patch"]),
|
||||
PkgbuildPatch("source", ["reset.patch"]),
|
||||
PkgbuildPatch("source", ["reset.patch", "extra.patch"]),
|
||||
]
|
||||
assert list(parser) == expected
|
||||
|
||||
|
||||
def test_parse_append_array_to_string() -> None:
|
||||
"""
|
||||
must preserve a string as the first element when appending an array
|
||||
"""
|
||||
parser = PkgbuildParser(BytesIO(b"source=base.patch\nsource+=(extra.patch)"))
|
||||
assert list(parser) == [
|
||||
PkgbuildPatch("source", "base.patch"),
|
||||
PkgbuildPatch("source", ["base.patch", "extra.patch"]),
|
||||
]
|
||||
|
||||
|
||||
def test_parse_array() -> None:
|
||||
"""
|
||||
@@ -71,7 +110,7 @@ def test_parse_array_exception() -> None:
|
||||
"""
|
||||
parser = PkgbuildParser(BytesIO(b"var=(first second"))
|
||||
with pytest.raises(PkgbuildParserError):
|
||||
assert list(parser.parse())
|
||||
list(parser.parse())
|
||||
|
||||
|
||||
def test_parse_function() -> None:
|
||||
@@ -119,11 +158,11 @@ def test_parse_function_exception() -> None:
|
||||
"""
|
||||
parser = PkgbuildParser(BytesIO(b"var() echo hello world } "))
|
||||
with pytest.raises(PkgbuildParserError):
|
||||
assert list(parser.parse())
|
||||
list(parser.parse())
|
||||
|
||||
parser = PkgbuildParser(BytesIO(b"var() { echo hello world"))
|
||||
with pytest.raises(PkgbuildParserError):
|
||||
assert list(parser.parse())
|
||||
list(parser.parse())
|
||||
|
||||
|
||||
def test_parse_function_inner_shell() -> None:
|
||||
@@ -243,4 +282,12 @@ def test_parse(resource_path_root: Path) -> None:
|
||||
_ver="$(cat CMakeLists.txt | grep -e SO_MAJOR_VERSION -e SO_MINOR_VERSION -e SO_BUILD_VERSION | cut -d '"' -f2 | head -n3)"
|
||||
echo "$(echo ${_ver} | tr ' ' .).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
|
||||
}"""),
|
||||
PkgbuildPatch("var", "say \"hello\""),
|
||||
PkgbuildPatch("var", "a\\b"),
|
||||
PkgbuildPatch("var", "$name"),
|
||||
PkgbuildPatch("var", "`date`"),
|
||||
PkgbuildPatch("var", "firstsecond"),
|
||||
PkgbuildPatch("var", "a\\qb"),
|
||||
PkgbuildPatch("var", "\\$name"),
|
||||
PkgbuildPatch("var", "first\nsecond"),
|
||||
]
|
||||
@@ -23,6 +23,7 @@ from ahriman.core.formatters import (
|
||||
VersionPrinter
|
||||
)
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.build_status import BuildStatus
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.package import Package
|
||||
@@ -219,7 +220,8 @@ def update_printer(package_ahriman: Package) -> UpdatePrinter:
|
||||
Returns:
|
||||
UpdatePrinter: update printer test instance
|
||||
"""
|
||||
return UpdatePrinter(package_ahriman, None)
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
return UpdatePrinter(plan, {})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -53,6 +53,18 @@ def test_print_indent(mocker: MockerFixture) -> None:
|
||||
log_mock.assert_has_calls([MockCall("key: value"), MockCall("\tkey: value"), MockCall("\t\tkey: value")])
|
||||
|
||||
|
||||
def test_print_separator(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must use property separator instead of default separator
|
||||
"""
|
||||
log_mock = MagicMock()
|
||||
|
||||
mocker.patch("ahriman.core.formatters.Printer.properties", return_value=[Property("key", "value", separator=" ")])
|
||||
Printer().print(verbose=True, log_fn=log_mock)
|
||||
|
||||
log_mock.assert_called_once_with("\tkey value")
|
||||
|
||||
|
||||
def test_properties() -> None:
|
||||
"""
|
||||
must return empty properties list
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from ahriman.core.formatters import UpdatePrinter
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.property import Property
|
||||
|
||||
|
||||
@@ -13,25 +15,52 @@ def test_properties_na(update_printer: UpdatePrinter) -> None:
|
||||
"""
|
||||
must return N/A if local version is unknown
|
||||
"""
|
||||
assert update_printer.properties() == [Property("N/A", update_printer.package.version, is_required=True)]
|
||||
package = update_printer.plan.packages[0]
|
||||
assert update_printer.properties() == [
|
||||
Property(package.base, "", is_required=True),
|
||||
Property("N/A", package.version, is_required=True, indent=2, separator=" -> "),
|
||||
Property("Reason", BuildPlanReason.RegularUpdate.value, indent=2),
|
||||
]
|
||||
|
||||
|
||||
def test_properties_bump_pkgrel(update_printer: UpdatePrinter) -> None:
|
||||
def test_properties_package_required_by(package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must include requestee package to properties
|
||||
"""
|
||||
plan = BuildPlan()
|
||||
plan.add(package_python_schedule, BuildPlanReason.RequiredBy, requester="ahriman")
|
||||
|
||||
properties = list(UpdatePrinter(plan, {}, bump_pkgrel=False).properties_package(package_python_schedule))
|
||||
assert properties[-1].value == "required by ahriman"
|
||||
|
||||
|
||||
def test_versions_bump_pkgrel(update_printer: UpdatePrinter) -> None:
|
||||
"""
|
||||
must bump pkgrel if local version is the same
|
||||
"""
|
||||
update_printer.local_version = update_printer.package.version
|
||||
assert update_printer.properties() == [Property(update_printer.package.version, "2.6.0-1.1", is_required=True)]
|
||||
package = update_printer.plan.packages[0]
|
||||
update_printer.local_versions[package.base] = package.version
|
||||
assert update_printer.versions(package) == (package.version, "2.6.0-1.1")
|
||||
|
||||
|
||||
def test_properties_keep_pkgrel(update_printer: UpdatePrinter) -> None:
|
||||
def test_versions_keep_pkgrel(update_printer: UpdatePrinter) -> None:
|
||||
"""
|
||||
must keep pkgrel if local version is not the same
|
||||
"""
|
||||
update_printer.local_version = "2.5.0-1"
|
||||
assert update_printer.properties() == [
|
||||
Property(update_printer.local_version, update_printer.package.version, is_required=True),
|
||||
]
|
||||
package = update_printer.plan.packages[0]
|
||||
update_printer.local_versions[package.base] = "2.5.0-1"
|
||||
assert update_printer.versions(package) == ("2.5.0-1", package.version)
|
||||
|
||||
|
||||
def test_versions_no_increment(update_printer: UpdatePrinter) -> None:
|
||||
"""
|
||||
must preserve the package version when release incrementing is disabled
|
||||
"""
|
||||
package = update_printer.plan.packages[0]
|
||||
update_printer.local_versions[package.base] = package.version
|
||||
update_printer.bump_pkgrel = False
|
||||
|
||||
assert update_printer.versions(package) == (package.version, package.version)
|
||||
|
||||
|
||||
def test_title(update_printer: UpdatePrinter) -> None:
|
||||
|
||||
@@ -578,6 +578,7 @@ def test_walk(resource_path_root: Path) -> None:
|
||||
resource_path_root / "models" / "package_pacman-static_pkgbuild",
|
||||
resource_path_root / "models" / "package_python-pytest-loop_pkgbuild",
|
||||
resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild",
|
||||
resource_path_root / "models" / "package_ttf-google-fonts-git_pkgbuild",
|
||||
resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild",
|
||||
resource_path_root / "models" / "package_yay_pkgbuild",
|
||||
resource_path_root / "models" / "pkgbuild",
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_add(package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must replace the package and reason for the same base
|
||||
"""
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
plan.add(package_ahriman, BuildPlanReason.QueuedRequest)
|
||||
plan.add(package_python_schedule, BuildPlanReason.LocalSourceUpdate)
|
||||
|
||||
assert package_ahriman in plan
|
||||
assert package_python_schedule in plan
|
||||
assert plan.item(package_ahriman.base).reason == BuildPlanReason.QueuedRequest
|
||||
|
||||
|
||||
def test_add_with_requester(package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must keep the last requester for a dependency
|
||||
"""
|
||||
plan = BuildPlan()
|
||||
plan.add(package_python_schedule, BuildPlanReason.RequiredBy, requester="ahriman")
|
||||
plan.add(package_python_schedule, BuildPlanReason.RequiredBy, requester="python-ahriman")
|
||||
|
||||
assert plan.item(package_python_schedule.base).requester == "python-ahriman"
|
||||
|
||||
|
||||
def test_update(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must update instance with new packages
|
||||
"""
|
||||
plan = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
assert package_ahriman in plan
|
||||
|
||||
|
||||
def test_eq(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must compare two plans
|
||||
"""
|
||||
plan1 = BuildPlan().update([package_ahriman], BuildPlanReason.RegularUpdate)
|
||||
assert plan1 == plan1
|
||||
|
||||
plan2 = BuildPlan().update([package_ahriman], BuildPlanReason.QueuedRequest)
|
||||
assert plan1 != plan2
|
||||
|
||||
|
||||
def test_eq_other() -> None:
|
||||
"""
|
||||
must return False in case if object is not an instance of build plan
|
||||
"""
|
||||
assert BuildPlan() != 42
|
||||
@@ -50,7 +50,7 @@ def test_from_io(pkgbuild_ahriman: Pkgbuild, mocker: MockerFixture) -> None:
|
||||
must correctly load from io
|
||||
"""
|
||||
load_mock = mocker.patch("ahriman.core.alpm.pkgbuild_parser.PkgbuildParser.parse",
|
||||
return_value=pkgbuild_ahriman.fields.values())
|
||||
return_value=iter(pkgbuild_ahriman.fields.values()))
|
||||
assert Pkgbuild.from_io(BytesIO(b"mock")) == pkgbuild_ahriman
|
||||
load_mock.assert_called_once_with()
|
||||
|
||||
@@ -60,9 +60,9 @@ def test_from_io_pkgbase(pkgbuild_ahriman: Pkgbuild, mocker: MockerFixture) -> N
|
||||
must assign missing pkgbase if pkgname is presented
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.pkgbuild_parser.PkgbuildParser.parse", side_effect=[
|
||||
[value for key, value in pkgbuild_ahriman.fields.items() if key not in ("pkgbase",)],
|
||||
[value for key, value in pkgbuild_ahriman.fields.items() if key not in ("pkgbase", "pkgname",)],
|
||||
[value for key, value in pkgbuild_ahriman.fields.items()] + [PkgbuildPatch("pkgbase", "pkgbase")],
|
||||
iter([value for key, value in pkgbuild_ahriman.fields.items() if key not in ("pkgbase",)]),
|
||||
iter([value for key, value in pkgbuild_ahriman.fields.items() if key not in ("pkgbase", "pkgname",)]),
|
||||
iter([value for key, value in pkgbuild_ahriman.fields.items()] + [PkgbuildPatch("pkgbase", "pkgbase")]),
|
||||
])
|
||||
|
||||
assert Pkgbuild.from_io(BytesIO(b"mock"))["pkgbase"] == pkgbuild_ahriman["pkgname"]
|
||||
@@ -75,7 +75,7 @@ def test_from_io_empty(pkgbuild_ahriman: Pkgbuild, mocker: MockerFixture) -> Non
|
||||
must skip empty patches
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.pkgbuild_parser.PkgbuildParser.parse",
|
||||
return_value=list(pkgbuild_ahriman.fields.values()) + [PkgbuildPatch("", "")])
|
||||
return_value=iter(list(pkgbuild_ahriman.fields.values()) + [PkgbuildPatch("", "")]))
|
||||
assert Pkgbuild.from_io(BytesIO(b"mock")) == pkgbuild_ahriman
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ def test_parse_ahriman(resource_path_root: Path) -> None:
|
||||
must parse real PKGBUILDs correctly (ahriman)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_ahriman_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "ahriman",
|
||||
"pkgname": "ahriman",
|
||||
@@ -279,6 +279,8 @@ def test_parse_ahriman(resource_path_root: Path) -> None:
|
||||
"53d37efec812afebf86281716259f9ea78a307b83897166c72777251c3eebcb587ecee375d907514781fb2a5c808cbb24ef9f3f244f12740155d0603bf213131",
|
||||
"62b2eccc352d33853ef243c9cddd63663014aa97b87242f1b5bc5099a7dbd69ff3821f24ffc58e1b7f2387bd4e9e9712cc4c67f661b1724ad99cdf09b3717794",
|
||||
],
|
||||
"build()": None,
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +289,7 @@ def test_parse_gcc10(resource_path_root: Path) -> None:
|
||||
must parse real PKGBUILDs correctly (gcc10)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_gcc10_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "gcc10",
|
||||
"pkgname": [
|
||||
@@ -354,6 +356,12 @@ def test_parse_gcc10(resource_path_root: Path) -> None:
|
||||
"_CHOST": "${CHOST:=}",
|
||||
"_MAKEFLAGS": "${MAKEFLAGS:=}",
|
||||
"_libdir": "usr/lib/gcc/${CHOST}/${pkgver%%+*}",
|
||||
"prepare()": None,
|
||||
"build()": None,
|
||||
"check()": None,
|
||||
"package_gcc10-libs()": None,
|
||||
"package_gcc10()": None,
|
||||
"package_gcc10-fortran()": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +370,7 @@ def test_parse_jellyfin_ffmpeg6_bin(resource_path_root: Path) -> None:
|
||||
must parse real PKGBUILDs correctly (jellyfin-ffmpeg6-bin)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "jellyfin-ffmpeg6-bin",
|
||||
"pkgname": "jellyfin-ffmpeg6-bin",
|
||||
@@ -396,6 +404,189 @@ def test_parse_jellyfin_ffmpeg6_bin(resource_path_root: Path) -> None:
|
||||
"source_aarch64": ["https://repo.jellyfin.org/releases/ffmpeg/${pkgver}-${pkgrel}/jellyfin-ffmpeg_${pkgver}-${pkgrel}_portable_linuxarm64-gpl.tar.xz"],
|
||||
"sha256sums_x86_64": ["32cbe40942d26072faa1182835ccc89029883766de11778c731b529aa632ff37"],
|
||||
"sha256sums_aarch64": ["22b8f2a3c92c6b1c9e6830a6631f08f3f0a7ae80739ace71ad30704a28045184"],
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_pacman_static(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (pacman-static)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_pacman-static_pkgbuild")
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "pacman-static",
|
||||
"pkgname": "pacman-static",
|
||||
"pkgver": "7.0.0.r6.gc685ae6",
|
||||
"_cares_ver": "1.34.4",
|
||||
"_nghttp2_ver": "1.64.0",
|
||||
"_curlver": "8.12.1",
|
||||
"_sslver": "3.4.1",
|
||||
"_zlibver": "1.3.1",
|
||||
"_xzver": "5.6.4",
|
||||
"_bzipver": "1.0.8",
|
||||
"_zstdver": "1.5.6",
|
||||
"_libarchive_ver": "3.7.7",
|
||||
"_gpgerrorver": "1.51",
|
||||
"_libassuanver": "3.0.0",
|
||||
"_gpgmever": "1.24.2",
|
||||
"pkgrel": "15",
|
||||
"_git_tag": "7.0.0",
|
||||
"_git_patch_level_commit": "c685ae6412af04cae1eaa5d6bda8c277c7ffb8c8",
|
||||
"pkgdesc": "Statically-compiled pacman (to fix or install systems without libc)",
|
||||
"arch": [
|
||||
"i486",
|
||||
"i686",
|
||||
"pentium4",
|
||||
"x86_64",
|
||||
"arm",
|
||||
"armv6h",
|
||||
"armv7h",
|
||||
"aarch64"
|
||||
],
|
||||
"url": "https://www.archlinux.org/pacman/",
|
||||
"license": ["GPL-2.0-or-later"],
|
||||
"depends": ["pacman"],
|
||||
"makedepends": [
|
||||
"meson",
|
||||
"musl",
|
||||
"kernel-headers-musl",
|
||||
"git",
|
||||
],
|
||||
"options": [
|
||||
"!emptydirs",
|
||||
"!lto",
|
||||
],
|
||||
"source": [
|
||||
"git+https://gitlab.archlinux.org/pacman/pacman.git#tag=v${_git_tag}?signed",
|
||||
"pacman-revertme-makepkg-remove-libdepends-and-libprovides.patch::https://gitlab.archlinux.org/pacman/pacman/-/commit/354a300cd26bb1c7e6551473596be5ecced921de.patch",
|
||||
"https://github.com/nghttp2/nghttp2/releases/download/v$_nghttp2_ver/nghttp2-$_nghttp2_ver.tar.xz",
|
||||
"https://github.com/c-ares/c-ares/releases/download/v${_cares_ver}/c-ares-${_cares_ver}.tar.gz",
|
||||
"https://github.com/c-ares/c-ares/releases/download/v${_cares_ver}/c-ares-${_cares_ver}.tar.gz.asc",
|
||||
"https://curl.haxx.se/download/curl-${_curlver}.tar.gz",
|
||||
"https://curl.haxx.se/download/curl-${_curlver}.tar.gz.asc",
|
||||
"https://github.com/openssl/openssl/releases/download/openssl-${_sslver}/openssl-${_sslver}.tar.gz",
|
||||
"https://github.com/openssl/openssl/releases/download/openssl-${_sslver}/openssl-${_sslver}.tar.gz.asc",
|
||||
"ca-dir.patch",
|
||||
"openssl-3.0.7-no-atomic.patch",
|
||||
"https://zlib.net/zlib-${_zlibver}.tar.gz",
|
||||
"https://zlib.net/zlib-${_zlibver}.tar.gz.asc",
|
||||
"git+https://github.com/tukaani-project/xz#tag=v${_xzver}",
|
||||
"https://sourceware.org/pub/bzip2/bzip2-${_bzipver}.tar.gz",
|
||||
"https://sourceware.org/pub/bzip2/bzip2-${_bzipver}.tar.gz.sig",
|
||||
"https://github.com/facebook/zstd/releases/download/v${_zstdver}/zstd-${_zstdver}.tar.zst",
|
||||
"https://github.com/facebook/zstd/releases/download/v${_zstdver}/zstd-${_zstdver}.tar.zst.sig",
|
||||
"https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${_gpgerrorver}.tar.bz2",
|
||||
"https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${_gpgerrorver}.tar.bz2.sig",
|
||||
"https://gnupg.org/ftp/gcrypt/libassuan/libassuan-${_libassuanver}.tar.bz2",
|
||||
"https://gnupg.org/ftp/gcrypt/libassuan/libassuan-${_libassuanver}.tar.bz2.sig",
|
||||
"https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${_gpgmever}.tar.bz2",
|
||||
"https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${_gpgmever}.tar.bz2.sig",
|
||||
"https://github.com/libarchive/libarchive/releases/download/v${_libarchive_ver}/libarchive-${_libarchive_ver}.tar.xz",
|
||||
"https://github.com/libarchive/libarchive/releases/download/v${_libarchive_ver}/libarchive-${_libarchive_ver}.tar.xz.asc",
|
||||
],
|
||||
"validpgpkeys": [
|
||||
"6645B0A8C7005E78DB1D7864F99FFE0FEAE999BD",
|
||||
"B8151B117037781095514CA7BBDFFC92306B1121",
|
||||
"27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2",
|
||||
"DA7D64E4C82C6294CB73A20E22E3D13B5411B7CA",
|
||||
"27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2",
|
||||
"8657ABB260F056B1E5190839D9C4D26D0E604491",
|
||||
"7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C",
|
||||
"A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C",
|
||||
"EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5",
|
||||
"BA5473A2B0587B07FB27CF2D216094DFD0CB81EF",
|
||||
"8657ABB260F056B1E5190839D9C4D26D0E604491",
|
||||
"7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C",
|
||||
"A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C",
|
||||
"EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5",
|
||||
"5ED46A6721D365587791E2AA783FCD8E58BCAFBA",
|
||||
"3690C240CE51B4670D30AD1C38EE757D69184620",
|
||||
"EC3CFE88F6CA0788774F5C1D1AA44BE649DE760A",
|
||||
"4EF4AC63455FC9F4545D9B7DEF8FE99528B52FFD",
|
||||
"D8692123C4065DEA5E0F3AB5249B39D24F25E3B6",
|
||||
"031EC2536E580D8EA286A9F22071B08A33BD3F06",
|
||||
"6DAA6E64A76D2840571B4902528897B826403ADA",
|
||||
"AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD",
|
||||
"A5A45B12AD92D964B89EEE2DEC560C81CEC2276E",
|
||||
"DB2C7CF1B4C265FAEF56E3FC5848A18B8F14184B",
|
||||
],
|
||||
"sha512sums": [
|
||||
"44e00c2bc259fe6a85de71f7fd8a43fcfd1b8fb7d920d2267bd5b347e02f1dab736b3d96e31faf7b535480398e2348f7c0b9914e51ca7e12bab2d5b8003926b4",
|
||||
"1a108c4384b6104e627652488659de0b1ac3330640fc3250f0a283af7c5884daab187c1efc024b2545262da1911d2b0b7b0d5e4e5b68bb98db25a760c9f1fb1a",
|
||||
"b544196c3b7a55faacd11700d11e2fe4f16a7418282c9abb24a668544a15293580fd1a2cc5f93367c8a17c7ee45335c6d2f5c68a72dd176d516fd033f203eeec",
|
||||
"3285e14d94bc736d6caddfe7ad7e3c6a6e69d49b079c989bb3e8aba4da62c022e38229d1e691aaa030b7d3bcd89e458d203f260806149a71ad9adb31606eae02",
|
||||
"SKIP",
|
||||
"9fcdcceab8bce43e888db79a38c775ff15790a806d3cc5cc96f396a829c6da2383b258481b5642153da14087943f6ef607af0aa3b75df6f41b95c6cd61d835eb",
|
||||
"SKIP",
|
||||
"1de6307c587686711f05d1e96731c43526fa3af51e4cd94c06c880954b67f6eb4c7db3177f0ea5937d41bc1f8cadcf5bce75025b5c1a46a469376960f1001c5f",
|
||||
"SKIP",
|
||||
"b1873dbb7a49460b007255689102062756972de5cc2d38b12cc9f389b6be412da6797579b1acd3717a8cd2ee118fd9801b94e55f063d4328f050f0876a5eb53c",
|
||||
"b5887ea77417fae49b6cb1e9fa782d3021f268d5219701d87a092235964f73fa72a31428b630445517f56f2bb69dcbbb24119ef9dbf8b4e40a753369a9f9a16f",
|
||||
"580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f",
|
||||
"SKIP",
|
||||
"e3216eca5fae2c9ce419e698bfbe186903088dad0a579749cb49bcde8f9d4073b98bf1570fe69190a9a41feb2a7c9814498ec9b867527de1c74ff75a1cbdfc17",
|
||||
"083f5e675d73f3233c7930ebe20425a533feedeaaa9d8cc86831312a6581cefbe6ed0d08d2fa89be81082f2a5abdabca8b3c080bf97218a1bd59dc118a30b9f3",
|
||||
"SKIP",
|
||||
"21f9da445afd76acaf3acb22d216c2b584d95e8c68e00f5cb3f6673f2d556dd14a7593344adf8ffd194bba3314387ee0e486d6248f6c935abca2edd8a4cf95ed",
|
||||
"SKIP",
|
||||
"4489f615c6a0389577a7d1fd7d3917517bb2fe032abd9a6d87dfdbd165dabcf53f8780645934020bf27517b67a064297475888d5b368176cf06bc22f1e735e2b",
|
||||
"SKIP",
|
||||
"7c5c95c1b85bef2d4890c068a5a8ea8a1fe0d8def6ab09e5f34fc2746d8808bbb0fc168e3bd66d52ee5ed799dcf9f258f4125cda98c8384f6411bcad8d8b3139",
|
||||
"SKIP",
|
||||
"ad69101d1fceef6cd1dd6d5348f6f2be06912da6b6a7d0fece3ce08cf35054e6953b80ca9c4748554882892faa44e7c54e705cf25bbf2b796cd4ad12b09da185",
|
||||
"SKIP",
|
||||
"2524f71f4c2ebc254a1927279be3394e820d0a0c6dec7ef835a862aa08c35756edaa4208bcdc710dd092872b59c200b555b78670372e2830822e278ff1ec4e4a",
|
||||
"SKIP",
|
||||
],
|
||||
"LDFLAGS": "$LDFLAGS -static",
|
||||
"CC": "musl-gcc -fno-stack-protector",
|
||||
"CXX": "musl-gcc -fno-stack-protector",
|
||||
"CFLAGS": "${CFLAGS/-fstack-protector-strong/} -D_LARGEFILE64_SOURCE",
|
||||
"CXXFLAGS": "${CXXFLAGS/-fstack-protector-strong/} -D_LARGEFILE64_SOURCE",
|
||||
"PKGEXT": ".pkg.tar.xz",
|
||||
"prepare()": None,
|
||||
"build()": None,
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_python_pytest_loop(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (python-pytest-loop)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_python-pytest-loop_pkgbuild")
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "python-pytest-loop",
|
||||
"_pname": "${pkgbase#python-}",
|
||||
"_pyname": "${_pname//-/_}",
|
||||
"pkgname": ["python-${_pname}"],
|
||||
"pkgver": "1.0.13",
|
||||
"pkgrel": "1",
|
||||
"pkgdesc": "Pytest plugin for looping test execution.",
|
||||
"arch": ["any"],
|
||||
"url": "https://github.com/anogowski/pytest-loop",
|
||||
"license": ["MPL-2.0"],
|
||||
"makedepends": [
|
||||
"python-hatchling",
|
||||
"python-versioningit",
|
||||
"python-wheel",
|
||||
"python-build",
|
||||
"python-installer",
|
||||
],
|
||||
"checkdepends": [
|
||||
"python-pytest",
|
||||
],
|
||||
"source": [
|
||||
"https://files.pythonhosted.org/packages/source/${_pyname:0:1}/${_pyname}/${_pyname}-${pkgver}.tar.gz",
|
||||
],
|
||||
"md5sums": [
|
||||
"98365f49606d5068f92350f1d2569a5f",
|
||||
],
|
||||
"build()": None,
|
||||
"check()": None,
|
||||
"package_python-pytest-loop()": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +595,7 @@ def test_parse_tpacpi_bat_git(resource_path_root: Path) -> None:
|
||||
must parse real PKGBUILDs correctly (tpacpi-bat-git)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "tpacpi-bat-git",
|
||||
"pkgname": "tpacpi-bat-git",
|
||||
@@ -421,45 +612,95 @@ def test_parse_tpacpi_bat_git(resource_path_root: Path) -> None:
|
||||
"backup": ["etc/conf.d/tpacpi"],
|
||||
"source": ["git+https://github.com/teleshoes/tpacpi-bat.git"],
|
||||
"b2sums": ["SKIP"],
|
||||
"pkgver()": None,
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_yay(resource_path_root: Path) -> None:
|
||||
def test_parse_ttf_google_fonts_git(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (yay)
|
||||
must parse real PKGBUILDs correctly (ttf-google-fonts-git)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_yay_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_ttf-google-fonts-git_pkgbuild")
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert "ttf-google-fonts-git" in pkgbuild.packages()
|
||||
assert values == {
|
||||
"pkgbase": "yay",
|
||||
"pkgname": "yay",
|
||||
"pkgver": "12.3.5",
|
||||
"pkgname": "ttf-google-fonts-git",
|
||||
"pkgver": "r11002.cdabad3d0",
|
||||
"pkgrel": "1",
|
||||
"pkgdesc": "Yet another yogurt. Pacman wrapper and AUR helper written in go.",
|
||||
"arch": [
|
||||
"i686",
|
||||
"pentium4",
|
||||
"x86_64",
|
||||
"arm",
|
||||
"armv7h",
|
||||
"armv6h",
|
||||
"aarch64",
|
||||
"riscv64",
|
||||
],
|
||||
"url": "https://github.com/Jguer/yay",
|
||||
"options": ["!lto"],
|
||||
"license": ["GPL-3.0-or-later"],
|
||||
"epoch": "1",
|
||||
"pkgdesc": "TrueType fonts from the Google Fonts project (git version)",
|
||||
"arch": ["any"],
|
||||
"url": "https://github.com/google/fonts",
|
||||
"license": ["custom:SIL Open Font License", "custom:Ubuntu Font License v1.0"],
|
||||
"depends": [
|
||||
"pacman>6.1",
|
||||
"git",
|
||||
"adobe-source-code-pro-fonts",
|
||||
"adobe-source-sans-fonts",
|
||||
"adobe-source-serif-fonts",
|
||||
"cantarell-fonts",
|
||||
"noto-fonts",
|
||||
"noto-fonts-extra",
|
||||
"ttf-anonymous-pro",
|
||||
"ttf-caladea",
|
||||
"ttf-croscore",
|
||||
"ttf-fira-sans",
|
||||
"ttf-fira-mono",
|
||||
"ttf-inconsolata",
|
||||
"ttf-lato",
|
||||
"ttf-merriweather",
|
||||
"ttf-merriweather-sans",
|
||||
"ttf-opensans",
|
||||
"ttf-oswald",
|
||||
"ttf-quintessential",
|
||||
"ttf-roboto",
|
||||
"ttf-roboto-mono",
|
||||
"ttf-signika",
|
||||
"ttf-ubuntu-font-family",
|
||||
],
|
||||
"optdepends": [
|
||||
"sudo: privilege elevation",
|
||||
"doas: privilege elevation",
|
||||
"makedepends": ["git", "fontconfig"],
|
||||
"conflicts": [
|
||||
"jsmath-fonts",
|
||||
"lohit-fonts",
|
||||
"ttf-andika",
|
||||
"ttf-arabeyes-fonts",
|
||||
"ttf-cardo",
|
||||
"ttf-comfortaa",
|
||||
"ttf-google-fonts-typewolf",
|
||||
"ttf-lora-cyrillic",
|
||||
"ttf-lekton",
|
||||
"ttf-medievalsharp",
|
||||
"ttf-nova",
|
||||
"ttf-oxygen",
|
||||
"ttf-oxygen-git",
|
||||
"ttf-pt-fonts",
|
||||
"ttf-source-code-pro-ibx",
|
||||
"ttf-source-sans-pro-ibx",
|
||||
"ttf-vollkorn-ibx",
|
||||
],
|
||||
"makedepends": ["go>=1.21"],
|
||||
"source": ["${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz"],
|
||||
"sha256sums": ["2fb6121a6eb4c5e6afaf22212b2ed15022500a4bc34bb3dc0f9782c1d43c3962"],
|
||||
"provides": [
|
||||
"jsmath-fonts",
|
||||
"lohit-fonts",
|
||||
"ttf-andika",
|
||||
"ttf-cardo",
|
||||
"ttf-carlito",
|
||||
"ttf-comfortaa",
|
||||
"ttf-lora-cyrillic",
|
||||
"ttf-lekton",
|
||||
"ttf-medievalsharp",
|
||||
"ttf-nova",
|
||||
"ttf-oxygen",
|
||||
"ttf-oxygen-git",
|
||||
"ttf-pt-fonts",
|
||||
"ttf-source-code-pro-ibx",
|
||||
"ttf-source-sans-pro-ibx",
|
||||
"ttf-vollkorn-ibx",
|
||||
],
|
||||
"source": ["git+${url}.git"],
|
||||
"sha512sums": ["SKIP"],
|
||||
"pkgbase": "ttf-google-fonts-git",
|
||||
"pkgver()": None,
|
||||
"prepare()": None,
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -468,7 +709,7 @@ def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
|
||||
must parse real PKGBUILDs correctly (vim-youcompleteme-git)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "vim-youcompleteme-git",
|
||||
"_gocode": "y",
|
||||
@@ -523,134 +764,49 @@ def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
|
||||
"10a64c468d1dd2a384e0e5fd4eb2582fd9f1dfa706b6d2d2bb88fb0fbfc2718d",
|
||||
"9a5bee818a4995bc52e91588059bef42728d046808206bfb93977f4e3109e50c",
|
||||
],
|
||||
"pkgver()": None,
|
||||
"prepare()": None,
|
||||
"build()": None,
|
||||
"package()": None,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_python_pytest_loop(resource_path_root: Path) -> None:
|
||||
def test_parse_yay(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (python-pytest-loop)
|
||||
must parse real PKGBUILDs correctly (yay)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_python-pytest-loop_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_yay_pkgbuild")
|
||||
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
|
||||
assert values == {
|
||||
"pkgbase": "python-pytest-loop",
|
||||
"_pname": "${pkgbase#python-}",
|
||||
"_pyname": "${_pname//-/_}",
|
||||
"pkgname": ["python-${_pname}"],
|
||||
"pkgver": "1.0.13",
|
||||
"pkgbase": "yay",
|
||||
"pkgname": "yay",
|
||||
"pkgver": "12.3.5",
|
||||
"pkgrel": "1",
|
||||
"pkgdesc": "Pytest plugin for looping test execution.",
|
||||
"arch": ["any"],
|
||||
"url": "https://github.com/anogowski/pytest-loop",
|
||||
"license": ["MPL-2.0"],
|
||||
"makedepends": [
|
||||
"python-hatchling",
|
||||
"python-versioningit",
|
||||
"python-wheel",
|
||||
"python-build",
|
||||
"python-installer",
|
||||
],
|
||||
"checkdepends": [
|
||||
"python-pytest",
|
||||
],
|
||||
"source": [
|
||||
"https://files.pythonhosted.org/packages/source/${_pyname:0:1}/${_pyname}/${_pyname}-${pkgver}.tar.gz",
|
||||
],
|
||||
"md5sums": [
|
||||
"98365f49606d5068f92350f1d2569a5f",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_parse_pacman_static(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (pacman-static)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_pacman-static_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
assert values == {
|
||||
"pkgbase": "pacman-static",
|
||||
"pkgname": "pacman-static",
|
||||
"pkgver": "7.0.0.r6.gc685ae6",
|
||||
"_cares_ver": "1.34.4",
|
||||
"_nghttp2_ver": "1.64.0",
|
||||
"_curlver": "8.12.1",
|
||||
"_sslver": "3.4.1",
|
||||
"_zlibver": "1.3.1",
|
||||
"_xzver": "5.6.4",
|
||||
"_bzipver": "1.0.8",
|
||||
"_zstdver": "1.5.6",
|
||||
"_libarchive_ver": "3.7.7",
|
||||
"_gpgerrorver": "1.51",
|
||||
"_libassuanver": "3.0.0",
|
||||
"_gpgmever": "1.24.2",
|
||||
"pkgrel": "15",
|
||||
"_git_tag": "7.0.0",
|
||||
"_git_patch_level_commit": "c685ae6412af04cae1eaa5d6bda8c277c7ffb8c8",
|
||||
"pkgdesc": "Statically-compiled pacman (to fix or install systems without libc)",
|
||||
"pkgdesc": "Yet another yogurt. Pacman wrapper and AUR helper written in go.",
|
||||
"arch": [
|
||||
"i486",
|
||||
"i686",
|
||||
"pentium4",
|
||||
"x86_64",
|
||||
"arm",
|
||||
"armv6h",
|
||||
"armv7h",
|
||||
"aarch64"
|
||||
"armv6h",
|
||||
"aarch64",
|
||||
"riscv64",
|
||||
],
|
||||
"url": "https://www.archlinux.org/pacman/",
|
||||
"license": ["GPL-2.0-or-later"],
|
||||
"depends": ["pacman"],
|
||||
"makedepends": [
|
||||
"meson",
|
||||
"musl",
|
||||
"kernel-headers-musl",
|
||||
"url": "https://github.com/Jguer/yay",
|
||||
"options": ["!lto"],
|
||||
"license": ["GPL-3.0-or-later"],
|
||||
"depends": [
|
||||
"pacman>6.1",
|
||||
"git",
|
||||
],
|
||||
"options": [
|
||||
"!emptydirs",
|
||||
"!lto",
|
||||
"optdepends": [
|
||||
"sudo: privilege elevation",
|
||||
"doas: privilege elevation",
|
||||
],
|
||||
"source": [
|
||||
"git+https://gitlab.archlinux.org/pacman/pacman.git#tag=v${_git_tag}?signed",
|
||||
"pacman-revertme-makepkg-remove-libdepends-and-libprovides.patch::https://gitlab.archlinux.org/pacman/pacman/-/commit/354a300cd26bb1c7e6551473596be5ecced921de.patch",
|
||||
],
|
||||
"validpgpkeys": [
|
||||
"6645B0A8C7005E78DB1D7864F99FFE0FEAE999BD",
|
||||
"B8151B117037781095514CA7BBDFFC92306B1121",
|
||||
],
|
||||
"sha512sums": [
|
||||
"44e00c2bc259fe6a85de71f7fd8a43fcfd1b8fb7d920d2267bd5b347e02f1dab736b3d96e31faf7b535480398e2348f7c0b9914e51ca7e12bab2d5b8003926b4",
|
||||
"1a108c4384b6104e627652488659de0b1ac3330640fc3250f0a283af7c5884daab187c1efc024b2545262da1911d2b0b7b0d5e4e5b68bb98db25a760c9f1fb1a",
|
||||
"b544196c3b7a55faacd11700d11e2fe4f16a7418282c9abb24a668544a15293580fd1a2cc5f93367c8a17c7ee45335c6d2f5c68a72dd176d516fd033f203eeec",
|
||||
"3285e14d94bc736d6caddfe7ad7e3c6a6e69d49b079c989bb3e8aba4da62c022e38229d1e691aaa030b7d3bcd89e458d203f260806149a71ad9adb31606eae02",
|
||||
"SKIP",
|
||||
"9fcdcceab8bce43e888db79a38c775ff15790a806d3cc5cc96f396a829c6da2383b258481b5642153da14087943f6ef607af0aa3b75df6f41b95c6cd61d835eb",
|
||||
"SKIP",
|
||||
"1de6307c587686711f05d1e96731c43526fa3af51e4cd94c06c880954b67f6eb4c7db3177f0ea5937d41bc1f8cadcf5bce75025b5c1a46a469376960f1001c5f",
|
||||
"SKIP",
|
||||
"b1873dbb7a49460b007255689102062756972de5cc2d38b12cc9f389b6be412da6797579b1acd3717a8cd2ee118fd9801b94e55f063d4328f050f0876a5eb53c",
|
||||
"b5887ea77417fae49b6cb1e9fa782d3021f268d5219701d87a092235964f73fa72a31428b630445517f56f2bb69dcbbb24119ef9dbf8b4e40a753369a9f9a16f",
|
||||
"580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f",
|
||||
"SKIP",
|
||||
"e3216eca5fae2c9ce419e698bfbe186903088dad0a579749cb49bcde8f9d4073b98bf1570fe69190a9a41feb2a7c9814498ec9b867527de1c74ff75a1cbdfc17",
|
||||
"083f5e675d73f3233c7930ebe20425a533feedeaaa9d8cc86831312a6581cefbe6ed0d08d2fa89be81082f2a5abdabca8b3c080bf97218a1bd59dc118a30b9f3",
|
||||
"SKIP",
|
||||
"21f9da445afd76acaf3acb22d216c2b584d95e8c68e00f5cb3f6673f2d556dd14a7593344adf8ffd194bba3314387ee0e486d6248f6c935abca2edd8a4cf95ed",
|
||||
"SKIP",
|
||||
"4489f615c6a0389577a7d1fd7d3917517bb2fe032abd9a6d87dfdbd165dabcf53f8780645934020bf27517b67a064297475888d5b368176cf06bc22f1e735e2b",
|
||||
"SKIP",
|
||||
"7c5c95c1b85bef2d4890c068a5a8ea8a1fe0d8def6ab09e5f34fc2746d8808bbb0fc168e3bd66d52ee5ed799dcf9f258f4125cda98c8384f6411bcad8d8b3139",
|
||||
"SKIP",
|
||||
"ad69101d1fceef6cd1dd6d5348f6f2be06912da6b6a7d0fece3ce08cf35054e6953b80ca9c4748554882892faa44e7c54e705cf25bbf2b796cd4ad12b09da185",
|
||||
"SKIP",
|
||||
"2524f71f4c2ebc254a1927279be3394e820d0a0c6dec7ef835a862aa08c35756edaa4208bcdc710dd092872b59c200b555b78670372e2830822e278ff1ec4e4a",
|
||||
"SKIP",
|
||||
],
|
||||
"LDFLAGS": "$LDFLAGS -static",
|
||||
"CC": "musl-gcc -fno-stack-protector",
|
||||
"CXX": "musl-gcc -fno-stack-protector",
|
||||
"CFLAGS": "${CFLAGS/-fstack-protector-strong/}",
|
||||
"CXXFLAGS": "${CXXFLAGS/-fstack-protector-strong/}",
|
||||
"PKGEXT": ".pkg.tar.xz",
|
||||
"makedepends": ["go>=1.21"],
|
||||
"source": ["${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz"],
|
||||
"sha256sums": ["2fb6121a6eb4c5e6afaf22212b2ed15022500a4bc34bb3dc0f9782c1d43c3962"],
|
||||
"build()": None,
|
||||
"package()": None,
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import runpy
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
|
||||
def test_main(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run the application and exit with its status
|
||||
"""
|
||||
run = mocker.patch("ahriman.application.ahriman.run", return_value=42)
|
||||
exit_mock = mocker.patch("sys.exit")
|
||||
|
||||
runpy.run_module("ahriman", run_name="__main__")
|
||||
run.assert_called_once_with()
|
||||
exit_mock.assert_called_once_with(42)
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
pkgbase='ahriman'
|
||||
pkgname=('ahriman' 'ahriman-core' 'ahriman-triggers' 'ahriman-web')
|
||||
pkgver=2.23.1
|
||||
pkgver=2.23.6
|
||||
pkgrel=1
|
||||
pkgdesc="ArcH linux ReposItory MANager"
|
||||
arch=('any')
|
||||
@@ -80,7 +80,7 @@ package_ahriman-triggers() {
|
||||
package_ahriman-web() {
|
||||
pkgname='ahriman-web'
|
||||
pkgdesc="ArcH linux ReposItory MANager, web server"
|
||||
depends=("$pkgbase-core=$pkgver" 'python-aiohttp-cors' 'python-aiohttp-jinja2' 'python-aiohttp-sse-git')
|
||||
depends=("$pkgbase-core=$pkgver" 'python-aiohttp-cors' 'python-aiohttp-jinja2' 'python-aiohttp-sse')
|
||||
optdepends=('python-aioauth-client: OAuth2 authorization support'
|
||||
'python-aiohttp-apispec>=3.0.0: autogenerated API documentation'
|
||||
'python-aiohttp-openmetrics: HTTP metrics support'
|
||||
|
||||
+5
-4
@@ -7,14 +7,15 @@ ARG BUILD_DATE
|
||||
## create build user
|
||||
RUN useradd -m -d "/home/build" -s "/usr/bin/nologin" build
|
||||
|
||||
## extract container creation date and set mirror for this timestamp, set PKGEXT and refresh database next
|
||||
RUN echo "Server = https://archive.archlinux.org/repos/${BUILD_DATE//-//}/\$repo/os/\$arch" > "/etc/pacman.d/mirrorlist" && \
|
||||
pacman -Syyuu --noconfirm
|
||||
## extract container creation date and set mirror for this timestamp
|
||||
RUN echo "Server = https://archive.archlinux.org/repos/${BUILD_DATE//-//}/\$repo/os/\$arch" > "/etc/pacman.d/mirrorlist"
|
||||
## setup package cache
|
||||
RUN runuser -u build -- mkdir "/tmp/pkg" && \
|
||||
echo "PKGDEST=/tmp/pkg" >> "/etc/makepkg.conf" && \
|
||||
echo "[options]" >> "/etc/pacman.conf" && \
|
||||
echo "CacheDir = /tmp/pkg/" >> "/etc/pacman.conf"
|
||||
## refresh root image
|
||||
RUN pacman -Syyuu --noconfirm
|
||||
|
||||
## install anc configure sudo
|
||||
RUN pacman -S --noconfirm --asdeps sudo && \
|
||||
@@ -59,7 +60,7 @@ RUN runuser -u build -- install-aur-package \
|
||||
python-aiohttp-jinja2 \
|
||||
python-aiohttp-session \
|
||||
python-aiohttp-security \
|
||||
python-aiohttp-sse-git \
|
||||
python-aiohttp-sse \
|
||||
python-requests-unixsocket2 \
|
||||
python-tree-sitter \
|
||||
python-tree-sitter-bash
|
||||
|
||||
Vendored
+4
-2
@@ -65,7 +65,7 @@ digraph G {
|
||||
ahriman_core_alpm_pacman [fillcolor="#9f2b04",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman"];
|
||||
ahriman_core_alpm_pacman_database [fillcolor="#a15035",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman_database"];
|
||||
ahriman_core_alpm_pacman_handle [fillcolor="#cc5933",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman_handle"];
|
||||
ahriman_core_alpm_pkgbuild_parser [fillcolor="#a15035",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npkgbuild_parser"];
|
||||
ahriman_core_alpm_pkgbuild_parser [fillcolor="#914830",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npkgbuild_parser"];
|
||||
ahriman_core_alpm_remote [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote",shape="box"];
|
||||
ahriman_core_alpm_remote_aur [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote\.\naur",shape="box"];
|
||||
ahriman_core_alpm_remote_official [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote\.\nofficial",shape="box"];
|
||||
@@ -567,7 +567,7 @@ digraph G {
|
||||
ahriman_core_alpm_pacman_database -> ahriman_core_alpm_pacman [fillcolor="#a15035",weight="3"];
|
||||
ahriman_core_alpm_pacman_handle -> ahriman_core_alpm_pacman [fillcolor="#cc5933",weight="3"];
|
||||
ahriman_core_alpm_pacman_handle -> ahriman_models_package [fillcolor="#cc5933",minlen="3"];
|
||||
ahriman_core_alpm_pkgbuild_parser -> ahriman_models_pkgbuild [fillcolor="#a15035",minlen="3"];
|
||||
ahriman_core_alpm_pkgbuild_parser -> ahriman_models_pkgbuild [fillcolor="#914830",minlen="3"];
|
||||
ahriman_core_alpm_remote -> ahriman_application_handlers_search [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_alpm_remote -> ahriman_core_build_tools_package_archive [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_alpm_remote -> ahriman_core_repository_repository [fillcolor="blue",minlen="2",weight="2"];
|
||||
@@ -667,6 +667,7 @@ digraph G {
|
||||
ahriman_core_configuration -> ahriman_application_lock [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_configuration -> ahriman_core_alpm_pacman [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration -> ahriman_core_alpm_pacman_database [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration -> ahriman_core_alpm_pkgbuild_parser [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration -> ahriman_core_archive_archive_trigger [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration -> ahriman_core_auth_auth [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration -> ahriman_core_auth_mapping [fillcolor="blue",minlen="2",weight="2"];
|
||||
@@ -734,6 +735,7 @@ digraph G {
|
||||
ahriman_core_configuration_configuration_multi_dict -> ahriman_core_configuration_configuration [fillcolor="#b85c3d",weight="3"];
|
||||
ahriman_core_configuration_schema -> ahriman_application_handlers_validate [fillcolor="#ce603b",minlen="3"];
|
||||
ahriman_core_configuration_schema -> ahriman_core_triggers_trigger [fillcolor="#ce603b",minlen="2",weight="2"];
|
||||
ahriman_core_configuration_shell_interpolator -> ahriman_core_alpm_pkgbuild_parser [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_configuration_shell_interpolator -> ahriman_core_configuration_configuration [fillcolor="blue",weight="3"];
|
||||
ahriman_core_configuration_shell_template -> ahriman_core_configuration_shell_interpolator [fillcolor="#ce603b",weight="3"];
|
||||
ahriman_core_configuration_shell_template -> ahriman_models_pkgbuild_patch [fillcolor="#ce603b",minlen="3"];
|
||||
|
||||
@@ -28,6 +28,14 @@ ahriman.models.auth\_settings module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.models.build\_plan module
|
||||
---------------------------------
|
||||
|
||||
.. automodule:: ahriman.models.build_plan
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.models.build\_status module
|
||||
-----------------------------------
|
||||
|
||||
|
||||
@@ -42,5 +42,5 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"type": "module",
|
||||
"version": "2.23.1"
|
||||
"version": "2.23.6"
|
||||
}
|
||||
@@ -37,7 +37,9 @@ import PackageRebuildDialog from "components/dialogs/PackageRebuildDialog";
|
||||
import PackageTableToolbar from "components/table/PackageTableToolbar";
|
||||
import StatusCell from "components/table/StatusCell";
|
||||
import { useDebounce } from "hooks/useDebounce";
|
||||
import { navigate, packageHref } from "hooks/useLocationQuery";
|
||||
import { usePackageTable } from "hooks/usePackageTable";
|
||||
import { useRepository } from "hooks/useRepository";
|
||||
import type { PackageRow } from "models/PackageRow";
|
||||
import React, { useMemo } from "react";
|
||||
|
||||
@@ -59,6 +61,7 @@ function createListColumn(
|
||||
|
||||
export default function PackageTable(): React.JSX.Element {
|
||||
const table = usePackageTable();
|
||||
const { currentRepository } = useRepository();
|
||||
const { handleRemove, handleUpdate, isAuthorized } = table;
|
||||
const apiRef = useGridApiRef();
|
||||
const debouncedSearch = useDebounce(table.searchText, 300);
|
||||
@@ -79,11 +82,20 @@ export default function PackageTable(): React.JSX.Element {
|
||||
headerName: "package base",
|
||||
minWidth: 150,
|
||||
renderCell: params =>
|
||||
params.row.webUrl ?
|
||||
<Link href={params.row.webUrl} rel="noopener noreferrer" target="_blank" underline="hover">
|
||||
{params.value as string}
|
||||
</Link>
|
||||
: params.value as string,
|
||||
<Link
|
||||
href={packageHref(currentRepository?.key ?? "", params.row.base)}
|
||||
onClick={event => {
|
||||
const modified = event.ctrlKey || event.metaKey || event.shiftKey || event.altKey;
|
||||
if (event.button === 0 && !modified) {
|
||||
event.preventDefault();
|
||||
navigate(packageHref(currentRepository?.key ?? "", params.row.base));
|
||||
}
|
||||
}}
|
||||
tabIndex={params.tabIndex}
|
||||
underline="hover"
|
||||
>
|
||||
{params.value as string}
|
||||
</Link>,
|
||||
},
|
||||
{ align: "right", field: "version", headerAlign: "right", headerName: "version", width: 180 },
|
||||
createListColumn("packages", "packages", { flex: 1, minWidth: 120 }),
|
||||
@@ -124,7 +136,7 @@ export default function PackageTable(): React.JSX.Element {
|
||||
],
|
||||
} satisfies GridColDef<PackageRow>] : [],
|
||||
],
|
||||
[handleRemove, handleUpdate, isAuthorized],
|
||||
[currentRepository, handleRemove, handleUpdate, isAuthorized],
|
||||
);
|
||||
|
||||
return <Box sx={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
||||
@@ -195,6 +207,7 @@ export default function PackageTable(): React.JSX.Element {
|
||||
<PackageRebuildDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "rebuild"} />
|
||||
<KeyImportDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "keyImport"} />
|
||||
<PackageInfoDialog
|
||||
key={`${currentRepository?.key}/${table.selectedPackage}`}
|
||||
onClose={() => table.setSelectedPackage(null)}
|
||||
open={table.selectedPackage !== null}
|
||||
packageBase={table.selectedPackage}
|
||||
|
||||
@@ -18,31 +18,23 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { RepositoryContext } from "contexts/RepositoryContext";
|
||||
import { navigate, packageHref, useLocationQuery } from "hooks/useLocationQuery";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import React, { type ReactNode, useCallback, useMemo, useState, useSyncExternalStore } from "react";
|
||||
|
||||
function subscribeToHash(callback: () => void): () => void {
|
||||
window.addEventListener("hashchange", callback);
|
||||
return () => window.removeEventListener("hashchange", callback);
|
||||
}
|
||||
|
||||
function getHashSnapshot(): string {
|
||||
return window.location.hash.replace("#", "");
|
||||
}
|
||||
import React, { type ReactNode, useCallback, useMemo, useState } from "react";
|
||||
|
||||
export function RepositoryProvider({ children }: { children: ReactNode }): React.JSX.Element {
|
||||
const [repositories, setRepositories] = useState<RepositoryId[]>([]);
|
||||
const hash = useSyncExternalStore(subscribeToHash, getHashSnapshot);
|
||||
const repositoryKey = new URLSearchParams(useLocationQuery()).get("repository_id");
|
||||
|
||||
const currentRepository = useMemo(() => {
|
||||
if (repositories.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return repositories.find(repository => repository.key === hash) ?? repositories[0] ?? null;
|
||||
}, [repositories, hash]);
|
||||
return repositories.find(repository => repository.key === repositoryKey) ?? repositories[0] ?? null;
|
||||
}, [repositories, repositoryKey]);
|
||||
|
||||
const setCurrentRepository = useCallback((repository: RepositoryId) => {
|
||||
window.location.hash = repository.key;
|
||||
navigate(packageHref(repository.key, null));
|
||||
}, []);
|
||||
|
||||
const value = useMemo(() => ({
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
function subscribe(callback: () => void): () => void {
|
||||
window.addEventListener("popstate", callback);
|
||||
return () => window.removeEventListener("popstate", callback);
|
||||
}
|
||||
|
||||
function getSnapshot(): string {
|
||||
return window.location.search;
|
||||
}
|
||||
|
||||
export function useLocationQuery(): string {
|
||||
return useSyncExternalStore(subscribe, getSnapshot);
|
||||
}
|
||||
|
||||
export function packageHref(repositoryKey: string, packageBase: string | null): string {
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
query.set("repository_id", repositoryKey);
|
||||
if (packageBase) {
|
||||
query.set("package", packageBase);
|
||||
} else {
|
||||
query.delete("package");
|
||||
}
|
||||
return `${window.location.pathname}?${query}`;
|
||||
}
|
||||
|
||||
export function navigate(href: string): void {
|
||||
if (href === `${window.location.pathname}${window.location.search}`) {
|
||||
return;
|
||||
}
|
||||
window.history.pushState(null, "", href);
|
||||
window.dispatchEvent(new PopStateEvent("popstate"));
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
import type { GridFilterModel } from "@mui/x-data-grid";
|
||||
import { useLocalStorage } from "hooks/useLocalStorage";
|
||||
import { navigate, packageHref, useLocationQuery } from "hooks/useLocationQuery";
|
||||
import { useRepository } from "hooks/useRepository";
|
||||
import { useState } from "react";
|
||||
|
||||
export type DialogType = "dashboard" | "add" | "rebuild" | "keyImport";
|
||||
@@ -43,7 +45,14 @@ export interface UseTableStateResult {
|
||||
export function useTableState(): UseTableStateResult {
|
||||
const [selectionModel, setSelectionModel] = useState<string[]>([]);
|
||||
const [dialogOpen, setDialogOpen] = useState<DialogType | null>(null);
|
||||
const [selectedPackage, setSelectedPackage] = useState<string | null>(null);
|
||||
const { currentRepository } = useRepository();
|
||||
const packageBase = new URLSearchParams(useLocationQuery()).get("package");
|
||||
const selectedPackage = currentRepository && packageBase ? packageBase : null;
|
||||
const setSelectedPackage = (base: string | null): void => {
|
||||
if (currentRepository) {
|
||||
navigate(packageHref(currentRepository.key, base));
|
||||
}
|
||||
};
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
const [paginationModel, setPaginationModel] = useLocalStorage("ahriman-packages-pagination", {
|
||||
|
||||
+7
-1
@@ -29,6 +29,8 @@ def _test_path(source_root: Path, source_file: Path) -> Path:
|
||||
return relative_path.parent / f"test_{source_name}"
|
||||
else:
|
||||
return relative_path.parent / f"test_view_{source_name}"
|
||||
case (*_, source_name) if source_name.startswith("__"):
|
||||
return relative_path.parent / f"test_{source_name.replace("__", "")}"
|
||||
case _:
|
||||
return relative_path.parent / f"test_{source_file.name}"
|
||||
|
||||
@@ -37,6 +39,10 @@ def test_test_coverage() -> None:
|
||||
"""
|
||||
must have test files for each source file
|
||||
"""
|
||||
def filter_files(filename: str) -> bool:
|
||||
return filename.suffix == ".py" \
|
||||
and filename.name not in ("__init__.py",)
|
||||
|
||||
package_roots = [
|
||||
Path("ahriman-core"),
|
||||
Path("ahriman-triggers"),
|
||||
@@ -46,6 +52,6 @@ def test_test_coverage() -> None:
|
||||
for package_root in package_roots:
|
||||
source_root = package_root / "src"
|
||||
|
||||
for source_file in filter(lambda fn: fn.suffix == ".py" and fn.name != "__init__.py", walk(source_root)):
|
||||
for source_file in filter(filter_files, walk(source_root)):
|
||||
test_file = package_root / "tests" / _test_path(source_root, source_file)
|
||||
assert test_file.is_file(), test_file
|
||||
@@ -0,0 +1,151 @@
|
||||
# Maintainer: Andrew Crerar <crerar@archlinux.org>
|
||||
# Contributor: Mohammadreza Abdollahzadeh <morealaz at gmail dot com>
|
||||
# Contributor: FadeMind <fademind@gmail.com>
|
||||
# Contributor: Vlad M. <vlad@archlinux.net>
|
||||
# Contributor: Sebastian Stammler <stammler.s@gmail.com>
|
||||
# Contributor: Sarkasper <echo a2FzcGVyLm1lbnRlbkBnbXguY29tCg== | base64 -d>
|
||||
# Contributor: Daniel Micay <danielmicay@gmail.com>
|
||||
# Contributor: Michalis Georgiou <mechmg93@gmail.comr>
|
||||
# Contributor: Alexander De Sousa <archaur.xandy21@spamgourmet.com>
|
||||
|
||||
pkgname=ttf-google-fonts-git
|
||||
pkgver=r11002.cdabad3d0
|
||||
pkgrel=1
|
||||
epoch=1
|
||||
pkgdesc="TrueType fonts from the Google Fonts project (git version)"
|
||||
arch=('any')
|
||||
url="https://github.com/google/fonts"
|
||||
license=('custom:SIL Open Font License' 'custom:Ubuntu Font License v1.0')
|
||||
|
||||
depends=('adobe-source-code-pro-fonts'
|
||||
'adobe-source-sans-fonts'
|
||||
'adobe-source-serif-fonts'
|
||||
'cantarell-fonts'
|
||||
'noto-fonts'
|
||||
'noto-fonts-extra'
|
||||
'ttf-anonymous-pro'
|
||||
'ttf-caladea'
|
||||
'ttf-croscore'
|
||||
'ttf-fira-sans'
|
||||
'ttf-fira-mono'
|
||||
'ttf-inconsolata'
|
||||
'ttf-lato'
|
||||
'ttf-merriweather'
|
||||
'ttf-merriweather-sans'
|
||||
'ttf-opensans'
|
||||
'ttf-oswald'
|
||||
'ttf-quintessential'
|
||||
'ttf-roboto'
|
||||
'ttf-roboto-mono'
|
||||
'ttf-signika'
|
||||
'ttf-ubuntu-font-family')
|
||||
makedepends=('git' 'fontconfig')
|
||||
conflicts=('jsmath-fonts'
|
||||
'lohit-fonts'
|
||||
'ttf-andika'
|
||||
'ttf-arabeyes-fonts'
|
||||
'ttf-cardo'
|
||||
'ttf-comfortaa'
|
||||
'ttf-google-fonts-typewolf'
|
||||
'ttf-lora-cyrillic'
|
||||
'ttf-lekton'
|
||||
'ttf-medievalsharp'
|
||||
'ttf-nova'
|
||||
'ttf-oxygen'
|
||||
'ttf-oxygen-git'
|
||||
'ttf-pt-fonts'
|
||||
'ttf-source-code-pro-ibx'
|
||||
'ttf-source-sans-pro-ibx'
|
||||
'ttf-vollkorn-ibx')
|
||||
provides=('jsmath-fonts'
|
||||
'lohit-fonts'
|
||||
'ttf-andika'
|
||||
'ttf-cardo'
|
||||
'ttf-carlito'
|
||||
'ttf-comfortaa'
|
||||
'ttf-lora-cyrillic'
|
||||
'ttf-lekton'
|
||||
'ttf-medievalsharp'
|
||||
'ttf-nova'
|
||||
'ttf-oxygen'
|
||||
'ttf-oxygen-git'
|
||||
'ttf-pt-fonts'
|
||||
'ttf-source-code-pro-ibx'
|
||||
'ttf-source-sans-pro-ibx'
|
||||
'ttf-vollkorn-ibx')
|
||||
source=(git+"${url}".git)
|
||||
sha512sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd fonts
|
||||
|
||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd fonts
|
||||
|
||||
# NOTE: Adobe Blank is not meant to be installed.
|
||||
# See: https://github.com/google/fonts/issues/2106#issuecomment-520067314
|
||||
rm --recursive "${srcdir}/fonts/ofl/adobeblank"
|
||||
}
|
||||
|
||||
package() {
|
||||
# NOTE: These are the font families that already exist in the [extra] repo
|
||||
# or should not be installed by this package, due to user reports
|
||||
# of system instability.
|
||||
declare -A omitted_font_families=(
|
||||
[anonymous-pro]=1
|
||||
[arimo]=1
|
||||
[caladea]=1
|
||||
[cantarell]=1
|
||||
[carlito]=1
|
||||
[cousine]=1
|
||||
[dai-banna-sil]=1
|
||||
[fira-sans]=1
|
||||
[fira-mono]=1
|
||||
[inconsolata]=1
|
||||
[merriweather]=1
|
||||
[merriweather-sans]=1
|
||||
[noto-color-emoji]=1
|
||||
[noto-sans]=1
|
||||
[noto-sans-tamil]=1
|
||||
[noto-serif]=1
|
||||
[open-sans]=1
|
||||
[oswald]=1
|
||||
[quintessential]=1
|
||||
[roboto]=1
|
||||
[roboto-condensed]=1
|
||||
[roboto-mono]=1
|
||||
[source-sans-3]=1
|
||||
[source-sans-pro]=1
|
||||
[source-serif-4]=1
|
||||
[source-serif-pro]=1
|
||||
[tinos]=1
|
||||
[ubuntu]=1
|
||||
[ubuntu-mono]=1
|
||||
)
|
||||
|
||||
|
||||
while IFS= read -rd '' file; do
|
||||
font_family=$(fc-query -f '%{family[0]|downcase|translate( ,-)}\n' "$file" | sed -n '1p')
|
||||
|
||||
# NOTE: Skip the rest of the loop if we're not supposed to be touching this family
|
||||
((omitted_font_families["$font_family"])) && continue
|
||||
|
||||
pkg_font_path="$pkgdir"/usr/share/fonts/"$font_family"
|
||||
install -Dm644 "$file" -t "$pkg_font_path" # TODO: Check and make sure $font_family is being created
|
||||
|
||||
# NOTE: If the font's license already exists, we don't need to copy the license again.
|
||||
src_license_path="${file%/*}"/OFL.txt
|
||||
pkg_font_license="$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE."$font_family"
|
||||
if [[ -f "$src_license_path" && ! -f "$pkg_font_license" ]]; then
|
||||
install -Dm644 "$src_license_path" "$pkg_font_license"
|
||||
fi
|
||||
done < <(find "$srcdir" -type f -iname \*.ttf -print0)
|
||||
|
||||
# NOTE: Since the zcool xiaowei chinese font has special characters. We need to change
|
||||
# the folder name to prevent errors during package compression.
|
||||
mv "$pkgdir"/usr/share/fonts/站酷小薇体 "$pkgdir"/usr/share/fonts/zcool-xiaowei-regular
|
||||
mv "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE.站酷小薇体 "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE.zcool-xiaowei-regular
|
||||
}
|
||||
@@ -113,3 +113,15 @@ pkgver() {
|
||||
_ver="$(cat CMakeLists.txt | grep -e SO_MAJOR_VERSION -e SO_MINOR_VERSION -e SO_BUILD_VERSION | cut -d '"' -f2 | head -n3)"
|
||||
echo "$(echo ${_ver} | tr ' ' .).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
# escapes and newlines inside double-quoted assignments
|
||||
var="say \"hello\""
|
||||
var="a\\b"
|
||||
var="\$name"
|
||||
var="\`date\`"
|
||||
var="first\
|
||||
second"
|
||||
var="a\qb"
|
||||
var="\\\\$name"
|
||||
var="first
|
||||
second"
|
||||
Reference in new issue
Block a user