Compare commits

...
69 Commits
Author SHA1 Message Date
arcanis 0bd22a049c type: add type annotation pylint check
Also run pylint against tests tree
2026-11-18 14:30:17 +02:00
arcanis 71c5d58264 fix: remove packages with broken dependencies from build plan and mark
them as failed
2026-11-18 11:20:43 +02:00
arcanis 22c763ed52 build: update frontend dependencies 2026-11-18 10:36:39 +02:00
arcanis 36b7972b26 style: add more pylint checks and update code for them 2026-11-18 10:36:19 +02:00
arcanis 4f839a7e6a feat: simplify buildplan api and keep original reasons 2026-11-18 10:35:46 +02:00
arcanis a10b1a9364 fix: keep discovered subpackages in place 2026-11-16 19:51:53 +02:00
arcanis f0d523492d feat: implement detailed build plan 2026-11-15 03:25:01 +02:00
arcanis dc4f2be65b build: update regress job to actually check that there are not updates 2026-11-06 14:01:36 +02:00
arcanis 9ba74413e3 feat: add module entrypoint
small useless feature, but the application can now be run with python -m
ahriman
2026-11-06 13:40:47 +02:00
arcanis d3b569bfa2 Release 2.23.6 2026-10-30 16:33:14 +02:00
arcanis 64a7e9b288 docs: take note on parametrized tests 2026-10-30 16:17:07 +02:00
arcanis 5ad8a2a7d0 fix: improve parsing of escaped symbols inside string 2026-10-30 16:16:50 +02:00
arcanis c56a319267 fix: handle array expansion without regex 2026-10-30 13:25:39 +02:00
arcanis 96558886bd fix: handle array append correctly 2026-10-29 14:27:14 +02:00
arcanis 4a745321ec docs: update contribution guide with ai policy 2026-10-26 13:05:18 +02:00
arcanis 4446c950ec Release 2.23.5 2026-10-25 02:17:21 +03:00
arcanis 8d569e6075 fix: pylint check 2026-10-25 02:16:59 +03:00
arcanis c375236327 Release 2.23.4 2026-10-25 02:12:43 +03:00
arcanis ddbb4b06ff fix: commit forgotten test file 2026-10-25 02:12:24 +03:00
arcanis 2d66b67123 Release 2.23.3 2026-10-25 02:09:35 +03:00
arcanis 27cfcd07eb fix: handle empty assignment correctly in PKGBUILD 2026-10-25 02:09:13 +03:00
arcanis 2080f1e06f Release 2.23.2 2026-10-25 01:45:45 +03:00
arcanis 2544d44051 fix: refresh databases on repo-update command 2026-10-24 16:48:23 +03:00
arcanis b07ad8cc0c build: clear pacman cache to resolve hashsums mismatch 2026-10-24 12:37:10 +03:00
arcanis c38cb5f680 feat: restore iterable method in parser 2026-10-24 12:20:29 +03:00
arcanis f776b33310 feat: preserve links to packages
This changes url handling in status page. Firstly, instead of using
hash for repository, now they are handled by query parameter. Secondly,
it adds a query parameter for package base. And lastly, it changes
behaviour for clicking on the package link, now it opens status page,
which allows to e.g. open a tab in background
2026-10-22 11:33:06 +03:00
arcanis eafa1b417a build: replace aiohttp-sse-git with aiohttp-sse
The upstream has released new version, which includes all required fixes
for the newest aiohttp
2026-10-20 16:23:56 +03:00
arcanis d0aff05be5 Release 2.23.1 2026-10-20 00:31:19 +03:00
arcanis 8a6b71a425 docs: commit docs requirements.txt 2026-10-20 00:30:57 +03:00
arcanis 0e7e2a9128 Release 2.23.0 2026-10-20 00:28:44 +03:00
arcanis bb1fb86036 fix: fix docker build with new dependencies 2026-10-20 00:00:40 +03:00
arcanis 6e7651a176 fix: handle version subcommand correctly
After package split it was looking for metapackage and lookup was broken
because it doesn't contain any python metadata
2026-10-19 23:26:23 +03:00
arcanis 9e5468313e feat: migrate pkgbuild parser to tree-sitter (#168) 2026-10-19 23:10:58 +03:00
arcanis 9b65e01d2f feat: show notification on hold action 2026-10-19 10:22:42 +03:00
arcanis 7f28e47ac4 fix: add files to git with force flag
It has been reported that AUR repositories might contain .gitignore,
which prevents PKGBUILD/.SRCINFO/whatever to be added without --force
flag. This commit simply adds force flag for all those operations, which
should be fine, because we don't commit wildcards

Closes #167
2026-10-17 12:17:40 +03:00
arcanis 0b371b3e77 feat: add tooltip for held packages 2026-10-16 13:09:17 +03:00
arcanis ef47c6fa72 feat: distinguish between repo update and package update in ui 2026-10-16 13:03:48 +03:00
arcanis 81ea175034 bug: always keep existing package version in archive 2026-10-16 12:11:51 +03:00
arcanis b73be7abcc feat: only remove packages from build queue which were actually built 2026-10-16 11:49:52 +03:00
arcanis 4537969d5d fix: handle is_held flag in all update processes
Previos implementation has ignored this flag in dependencies checks,
local package update and so on
2026-10-14 13:44:37 +03:00
arcanis 47c39f93b7 feat: align tables vertically in center 2026-10-13 13:22:00 +03:00
arcanis 3ac5f13f18 Release 2.22.2 2026-10-13 12:44:51 +03:00
arcanis e20deea1dd fix: fix typescript dependencies 2026-10-13 12:11:29 +03:00
arcanis 118ffdffe5 fix: update event bus for the last aiohttp-sse api change 2026-10-13 11:21:24 +03:00
arcanis 19ca1ac797 feat: detect dependencies resolution error 2026-10-13 10:31:11 +03:00
arcanis 16afb50c19 feat: add update and remove buttons to the status table 2026-09-23 16:04:42 +03:00
arcanis 23c834e186 refactor: drop enum_values helper, use direct cast to tuple instead 2026-09-21 11:40:38 +03:00
arcanis cd374dfbdf docs: update contributing guide 2026-08-18 15:13:41 +03:00
arcanis 25ecefab83 Release 2.22.1 2026-08-18 12:15:35 +03:00
arcanis b0248ed1cd refactor: split include option 2026-08-18 12:15:05 +03:00
arcanis 5d27fb1248 Release 2.22.0 2026-08-18 11:57:10 +03:00
arcanis 0faf3910c6 refactor: shell script simplification 2026-08-18 11:40:30 +03:00
arcanis fc520de146 docs: mention environment variables change in migration 2026-08-18 11:10:05 +03:00
arcanis c640239f8a build: move toxfile to tools packages 2026-08-18 01:22:18 +03:00
arcanis 024b6a014f build: update frontend dependencies 2026-08-17 13:44:40 +03:00
arcanis e12e844312 build: remove unused backslashes 2026-08-17 13:22:51 +03:00
arcanis eaac507d12 feat: limit environment variables passed to sudo 2026-08-17 12:26:56 +03:00
arcanis 117db10932 docs: update setup instructions to follow new logic 2026-08-17 12:13:46 +03:00
arcanis 9b544f9e45 docs: add devtools_configs option to docs 2026-08-15 20:25:28 +03:00
arcanis 3548b434be feat: full rootless setup (#165)
* use local devtools configs instead of global ones

* make docker image rootless

* add migration notes

* fix setup command

* fix regress jo
2026-08-14 13:34:42 +03:00
arcanis 695424fa16 feat: remove makepkg.conf local configuration, use ahriman own
configuration instead

We used .makepkg.conf solely for two features - MAKEFLAGS and PACKAGER,
which could be actually easily implemented by using environment
variables
2026-08-13 16:39:13 +03:00
arcanis 255ebe117a feat: read includes from list of directories 2026-08-13 16:39:13 +03:00
arcanis a9a12cd247 feat: get rid of sudoers modification during setup command
This commit introduces small shell wrapper, which calls archbuild
mimicing symlinked command. It allows to distribute static sudoers file.

Additionally build_command option has been renamed to devtools_wrapper
in order to allow to keep backward compatibility
2026-08-13 14:26:49 +03:00
arcanis 8dc198aa2b build: tox cleanup 2026-08-13 14:26:49 +03:00
arcanis 1133b75c33 refactor: implement generic optional import mechanisms
this project is actively using optional imports, which leads to
duplicate handling here and there. This commit implements logic in
special method to reduce complexity and simplify tests paths
2026-08-13 14:26:49 +03:00
arcanis 777bedf772 build: handle local imports in pylint check correctly 2026-08-13 14:26:49 +03:00
arcanis cc6ca46342 build: fix mypy type install 2026-08-13 14:26:49 +03:00
arcanis 2eb51ba85a Release 2.21.1 2026-07-21 10:46:21 +03:00
arcanis 36e28aba99 fix: always load tab on remount
it fixes a bug, which leads to missing tab content load when opening
package info
2026-07-21 10:44:20 +03:00
333 changed files with 5664 additions and 4106 deletions

No files matched your search

+7 -6
View File
@@ -10,15 +10,15 @@ echo -e '[arcanisrepo]\nServer = https://repo.arcanis.me/$arch\nSigLevel = Never
# refresh the image # refresh the image
pacman -Syyu --noconfirm pacman -Syyu --noconfirm
# main dependencies # main dependencies
pacman -S --noconfirm devtools git npm pyalpm python-bcrypt python-filelock python-inflection python-pyelftools python-requests python-systemd sudo pacman -S --noconfirm --asdeps devtools git pyalpm python-bcrypt python-filelock python-inflection python-pyelftools python-requests python-tree-sitter python-tree-sitter-bash
# make dependencies # make dependencies
pacman -S --noconfirm --asdeps base-devel python-build python-hatchling python-installer python-tox python-wheel pacman -S --noconfirm --asdeps base-devel npm python-build python-hatchling python-installer python-tox python-wheel
# optional dependencies # optional dependencies
if [[ -z $MINIMAL_INSTALL ]]; then if [[ -z $MINIMAL_INSTALL ]]; then
# web server # web server
pacman -S --noconfirm 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 # additional features
pacman -S --noconfirm gnupg ipython python-boto3 python-cerberus python-matplotlib rsync pacman -S --noconfirm --asdeps gnupg ipython python-boto3 python-cerberus python-matplotlib python-systemd rsync
fi fi
# FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container # FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container
cp "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn" cp "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn"
@@ -41,10 +41,11 @@ systemd-machine-id-setup
# remove unused dependencies # remove unused dependencies
pacman -Qdtq | pacman -Rscn --noconfirm - pacman -Qdtq | pacman -Rscn --noconfirm -
find "/var/cache/pacman/pkg" -type f -delete
# initial setup command as root # initial setup command as root
[[ -z $MINIMAL_INSTALL ]] && WEB_ARGS=("--web-port" "8080") [[ -z $MINIMAL_INSTALL ]] && WEB_ARGS=("--web-port" "8080")
ahriman -a x86_64 -r "github" service-setup --packager "ahriman bot <ahriman@example.com>" "${WEB_ARGS[@]}" sudo -u ahriman -- ahriman -a x86_64 -r "github" service-setup --packager "ahriman bot <ahriman@example.com>" "${WEB_ARGS[@]}"
# enable services # enable services
systemctl enable ahriman@x86_64-github.timer systemctl enable ahriman@x86_64-github.timer
if [[ -z $MINIMAL_INSTALL ]]; then if [[ -z $MINIMAL_INSTALL ]]; then
@@ -60,6 +61,6 @@ sudo -u ahriman -- ahriman --log-handler console package-add --now ahriman
# check if package was actually installed # check if package was actually installed
test -n "$(find "/var/lib/ahriman/repository/github/x86_64" -name "ahriman*pkg*")" test -n "$(find "/var/lib/ahriman/repository/github/x86_64" -name "ahriman*pkg*")"
# run package check # run package check
sudo -u ahriman -- ahriman repo-update sudo -u ahriman -- ahriman --log-handler console repo-update --refresh
# stop web service lol # stop web service lol
[[ -z $WEB_PID ]] || kill $WEB_PID [[ -z $WEB_PID ]] || kill $WEB_PID
+9 -7
View File
@@ -18,8 +18,8 @@ jobs:
image: arcan1s/ahriman:edge image: arcan1s/ahriman:edge
env: env:
AHRIMAN_PORT: 8080 AHRIMAN_PORT: 8080
AHRIMAN_UNIX_SOCKET: /var/lib/ahriman/ahriman/ahriman-web.sock AHRIMAN_UNIX_SOCKET: /var/lib/ahriman/ahriman-web.sock
options: --privileged --entrypoint entrypoint-web options: --privileged --user root --entrypoint entrypoint-web
ports: ports:
- 8080 - 8080
volumes: volumes:
@@ -31,8 +31,8 @@ jobs:
AHRIMAN_DEBUG: y AHRIMAN_DEBUG: y
AHRIMAN_OUTPUT: console AHRIMAN_OUTPUT: console
AHRIMAN_PORT: 8080 AHRIMAN_PORT: 8080
AHRIMAN_UNIX_SOCKET: /var/lib/ahriman/ahriman/ahriman-web.sock AHRIMAN_UNIX_SOCKET: /var/lib/ahriman/ahriman-web.sock
options: --privileged options: --privileged --user root
volumes: volumes:
- repo:/var/lib/ahriman - repo:/var/lib/ahriman
@@ -40,7 +40,9 @@ jobs:
- run: pacman -Sy - run: pacman -Sy
- name: Init repository - name: Init repository
run: entrypoint help run: |
chown ahriman:ahriman /var/lib/ahriman
sudo -E -u ahriman -- entrypoint help
- name: Print configuration - name: Print configuration
run: | run: |
@@ -101,11 +103,11 @@ jobs:
- name: Update packages - name: Update packages
run: | run: |
sudo -u ahriman ahriman \ ! sudo -u ahriman ahriman \
--log-handler "$AHRIMAN_OUTPUT" \ --log-handler "$AHRIMAN_OUTPUT" \
repo-update \ repo-update \
--exit-code \ --exit-code \
|| true --refresh
- name: Add patch - name: Add patch
run: | run: |
+21 -23
View File
@@ -1,10 +1,14 @@
[tool.pylint.main] [tool.pylint.main]
init-hook = "sys.path.append('tools')" init-hook = "sys.path.append('tools')"
load-plugins = [ load-plugins = [
"pylint.extensions.docparams",
"pylint.extensions.bad_builtin", "pylint.extensions.bad_builtin",
"pylint.extensions.check_elif",
"pylint.extensions.docparams",
"pylint.extensions.overlapping_exceptions",
"pylint.extensions.typing",
"pylint_plugins.definition_order", "pylint_plugins.definition_order",
"pylint_plugins.import_order", "pylint_plugins.import_order",
"pylint_plugins.type_annotations",
] ]
[tool.pylint.classes] [tool.pylint.classes]
@@ -17,29 +21,23 @@ max-parents = 15
[tool.pylint."messages control"] [tool.pylint."messages control"]
disable = [ disable = [
"raw-checker-failed",
"bad-inline-option",
"locally-disabled",
"file-ignored",
"suppressed-message",
"useless-suppression",
"deprecated-pragma",
"use-symbolic-message-instead",
"use-implicit-booleaness-not-comparison-to-string",
"use-implicit-booleaness-not-comparison-to-zero",
"missing-module-docstring",
"line-too-long",
"no-name-in-module",
"import-outside-toplevel",
"invalid-name",
"raise-missing-from",
"wrong-import-order",
"too-few-public-methods",
"too-many-instance-attributes",
"broad-exception-caught", "broad-exception-caught",
"fixme",
"too-many-arguments",
"duplicate-code",
"cyclic-import", "cyclic-import",
"duplicate-code",
"fixme",
"import-outside-toplevel",
"line-too-long",
"missing-module-docstring",
"no-name-in-module",
"raise-missing-from",
"raw-checker-failed",
"suppressed-message",
"too-few-public-methods",
"too-many-arguments",
"too-many-instance-attributes",
"too-many-positional-arguments", "too-many-positional-arguments",
"wrong-import-order",
] ]
[tool.pylint.string]
check-quote-consistency = true
+19 -1
View File
@@ -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. * 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. * 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. * `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 ### 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`). 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 ## Developers how to
### Run automated checks ### Run automated checks
@@ -247,13 +259,19 @@ tox -e docs
Must be usually done if there are changes in modules structure. Must be usually done if there are changes in modules structure.
### Before making a new release
1. Make sure that all pipelines are green.
2. Make sure that documentation is up-to-date.
3. Run [regress job](https://github.com/arcan1s/ahriman/actions/workflows/regress.yml). The successful link must be attached to release.
### Create release ### Create release
```shell ```shell
tox -m release -- major.minor.patch tox -m release -- major.minor.patch
``` ```
The command above will generate documentation, tags, etc., and will push them to GitHub. Other things will be handled by GitHub workflows automatically. The command above will generate documentation, tags, etc., and will push them to GitHub. Other things will be handled by GitHub workflows automatically. As soon as related github action completes, there will be a new release created. Edit it to add additional information if needed.
### Hotfixes policy ### Hotfixes policy
+1 -1
View File
@@ -31,7 +31,7 @@ For installation details kindly refer to the [documentation](https://ahriman.rea
Every available option is described in the [documentation](https://ahriman.readthedocs.io/en/stable/configuration.html). Every available option is described in the [documentation](https://ahriman.readthedocs.io/en/stable/configuration.html).
The application provides reasonable defaults which allow to use it out-of-box; however additional steps (like configuring build toolchain and sudoers) are recommended and can be easily achieved by following install instructions. The application provides reasonable defaults which allow to use it out-of-box; however additional steps (like configuring build toolchain) are recommended and can be easily achieved by following install instructions.
## [FAQ](https://ahriman.readthedocs.io/en/stable/faq/index.html) ## [FAQ](https://ahriman.readthedocs.io/en/stable/faq/index.html)
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
set -euo pipefail
usage() {
local cmd="${0##*/}"
echo "Usage: $cmd [options] -- [archbuild args]"
echo " -r <repository> Repository name"
echo " -a <architecture> Repository architecture"
echo " -c <directory> Read devtools pacman configurations from this directory"
}
repository=
architecture=
pacman_config_dir=
while getopts ":r:a:c:" arg; do
case "$arg" in
r) repository="$OPTARG" ;;
a) architecture="$OPTARG" ;;
c) pacman_config_dir="$OPTARG" ;;
*) usage >&2; exit 1 ;;
esac
done
if [[ -z $repository || -z $architecture ]]; then
usage >&2
exit 1
fi
if [[ -n $pacman_config_dir && ! -d $pacman_config_dir ]]; then
echo "devtools configuration directory does not exist: $pacman_config_dir" >&2
exit 1
fi
source "/usr/share/devtools/lib/archroot.sh"
check_root "SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,NPROC,MAKEFLAGS,PACKAGER,GNUPGHOME" "${BASH_SOURCE[0]}" "$@"
# because devtools doesn't allow to read configuration from custom path
# here is a workaround, which uses unshare to bind-mount directory with configuration files
# for specific process
if [[ -n $pacman_config_dir && -z ${AHRIMAN_ARCHBUILD_MOUNTED:-} ]]; then
pacman_config_dir="$(readlink -e -- "$pacman_config_dir")"
export AHRIMAN_ARCHBUILD_MOUNTED=1
exec unshare --mount --propagation private \
bash -c 'mount --bind -- "$0" /usr/share/devtools/pacman.conf.d && exec "$@"' \
"$pacman_config_dir" "${BASH_SOURCE[0]}" "$@"
fi
exec bash -c 'source "/usr/bin/archbuild" "$@"' \
"${repository}-${architecture}-build" "${@:$OPTIND}"
@@ -1,6 +1,7 @@
[settings] [settings]
; Relative path to directory with configuration files overrides. Overrides will be applied in alphabetic order. ; Relative path to directory with configuration files overrides. Overrides will be applied in alphabetic order.
include = ahriman.ini.d include[] = ahriman.ini.d
include[] = ${repository:root}/.config/ahriman/ahriman.ini.d
; Relative path to configuration used by logging package. ; Relative path to configuration used by logging package.
logging = ahriman.ini.d/logging.ini logging = ahriman.ini.d/logging.ini
; Perform database migrations on the application start. Do not touch this option unless you know what you are doing. ; Perform database migrations on the application start. Do not touch this option unless you know what you are doing.
@@ -34,18 +35,24 @@ retry_backoff = 1.0
[build] [build]
; List of additional flags passed to archbuild command. ; List of additional flags passed to archbuild command.
;archbuild_flags = ;archbuild_flags =
; Path to local directory with devtools configuration files, which will be bind-mounted for devtools.
devtools_configs = ${repository:root}/.config/ahriman/pacman.conf.d
; Path to build command. ; Path to build command.
;build_command = devtools_wrapper = ahriman-archbuild
; List of packages to be ignored during automatic updates. ; List of packages to be ignored during automatic updates.
;ignore_packages = ;ignore_packages =
; Include debug packages. ; Include debug packages.
;include_debug_packages = yes ;include_debug_packages = yes
; List of additional flags passed to make via environment variable via makepkg command.
;make_flags =
; List of additional flags passed to makechrootpkg command. ; List of additional flags passed to makechrootpkg command.
;makechrootpkg_flags = ;makechrootpkg_flags =
; Minimal age in seconds since the latest AUR package modification before automatic updates are allowed.
;min_age = 0
; List of additional flags passed to makepkg command. ; List of additional flags passed to makepkg command.
makepkg_flags = --nocolor --ignorearch makepkg_flags = --nocolor --ignorearch
; Minimal age in seconds since the latest AUR package modification before automatic updates are allowed.
;min_age = 0
; Default packager identifier to be used for package builds
;packager =
; List of paths to be used for implicit dependency scan. Regular expressions are supported. ; List of paths to be used for implicit dependency scan. Regular expressions are supported.
scan_paths = ^usr/lib(?!/cmake).*$ scan_paths = ^usr/lib(?!/cmake).*$
; List of enabled triggers in the order of calls. ; List of enabled triggers in the order of calls.
@@ -1,140 +1,134 @@
# AUTOMATICALLY GENERATED by `shtab` # AUTOMATICALLY GENERATED by https://github.com/tqdm/shtab
# Usage:
# 1) Copy this to somewhere (e.g. ~/.local/share/bash_completion/ahriman).
# 2) Add the following line to your .bashrc:
# source ~/.local/share/bash_completion/ahriman
# See also: https://github.com/scop/bash-completion/blob/main/doc/configuration.md
_shtab_ahriman_subparsers=('add' 'aur-search' 'check' 'clean' 'config' 'config-validate' 'copy' 'daemon' 'help' 'help-commands-unsafe' 'help-updates' 'help-version' 'init' 'key-import' 'package-add' 'package-archives' 'package-changes' 'package-changes-remove' 'package-copy' 'package-hold' 'package-pkgbuild' 'package-pkgbuild-remove' 'package-remove' 'package-rollback' 'package-status' 'package-status-remove' 'package-status-update' 'package-unhold' 'package-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'rebuild' 'remove' 'remove-unknown' 'repo-backup' 'repo-check' 'repo-clean' 'repo-config' 'repo-config-validate' 'repo-create-keyring' 'repo-create-mirrorlist' 'repo-daemon' 'repo-init' 'repo-rebuild' 'repo-remove-unknown' 'repo-report' 'repo-restore' 'repo-setup' 'repo-sign' 'repo-statistics' 'repo-status-update' 'repo-sync' 'repo-tree' 'repo-triggers' 'repo-update' 'report' 'run' 'search' 'service-clean' 'service-config' 'service-config-validate' 'service-key-import' 'service-repositories' 'service-run' 'service-setup' 'service-shell' 'service-tree-migrate' 'setup' 'shell' 'sign' 'status' 'status-update' 'sync' 'update' 'user-add' 'user-list' 'user-remove' 'version' 'web' 'web-reload') _shtab_ahriman_subparsers=(add aur-search check clean config config-validate copy daemon help help-commands-unsafe help-updates help-version init key-import package-add package-archives package-changes package-changes-remove package-copy package-hold package-pkgbuild package-pkgbuild-remove package-remove package-rollback package-status package-status-remove package-status-update package-unhold package-update patch-add patch-list patch-remove patch-set-add rebuild remove remove-unknown repo-backup repo-check repo-clean repo-config repo-config-validate repo-create-keyring repo-create-mirrorlist repo-daemon repo-init repo-rebuild repo-remove-unknown repo-report repo-restore repo-setup repo-sign repo-statistics repo-status-update repo-sync repo-tree repo-triggers repo-update report run search service-clean service-config service-config-validate service-key-import service-repositories service-run service-setup service-shell service-tree-migrate setup shell sign status status-update sync update user-add user-list user-remove version web web-reload)
_shtab_ahriman_option_strings=('-h' '--help' '-a' '--architecture' '-c' '--configuration' '--force' '-l' '--lock' '--log-handler' '-q' '--quiet' '--report' '--no-report' '-r' '--repository' '--unsafe' '-V' '--version' '--wait-timeout') _shtab_ahriman_add_option_strings=(-h --help --changes --no-changes --dependencies --no-dependencies -e --exit-code --increment --no-increment -n --now -s --source -u --username -v --variable -y --refresh)
_shtab_ahriman_add_option_strings=('-h' '--help' '--changes' '--no-changes' '--dependencies' '--no-dependencies' '-e' '--exit-code' '--increment' '--no-increment' '-n' '--now' '-s' '--source' '-u' '--username' '-v' '--variable' '-y' '--refresh') _shtab_ahriman_aur_search_option_strings=(-h --help -e --exit-code --info --no-info --sort-by)
_shtab_ahriman_aur_search_option_strings=('-h' '--help' '-e' '--exit-code' '--info' '--no-info' '--sort-by') _shtab_ahriman_check_option_strings=(-h --help --changes --no-changes --check-files --no-check-files -e --exit-code --vcs --no-vcs -y --refresh)
_shtab_ahriman_check_option_strings=('-h' '--help' '--changes' '--no-changes' '--check-files' '--no-check-files' '-e' '--exit-code' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_clean_option_strings=(-h --help --cache --no-cache --chroot --no-chroot --manual --no-manual --packages --no-packages --pacman --no-pacman)
_shtab_ahriman_clean_option_strings=('-h' '--help' '--cache' '--no-cache' '--chroot' '--no-chroot' '--manual' '--no-manual' '--packages' '--no-packages' '--pacman' '--no-pacman') _shtab_ahriman_config_option_strings=(-h --help --info --no-info --secure --no-secure)
_shtab_ahriman_config_option_strings=('-h' '--help' '--info' '--no-info' '--secure' '--no-secure') _shtab_ahriman_config_validate_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_config_validate_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_copy_option_strings=(-h --help -e --exit-code --remove)
_shtab_ahriman_copy_option_strings=('-h' '--help' '-e' '--exit-code' '--remove') _shtab_ahriman_daemon_option_strings=(-h --help -i --interval --aur --no-aur --changes --no-changes --check-files --no-check-files --dependencies --no-dependencies --dry-run --increment --no-increment --local --no-local --manual --no-manual --partitions --no-partitions -u --username --vcs --no-vcs -y --refresh)
_shtab_ahriman_daemon_option_strings=('-h' '--help' '-i' '--interval' '--aur' '--no-aur' '--changes' '--no-changes' '--check-files' '--no-check-files' '--dependencies' '--no-dependencies' '--dry-run' '--increment' '--no-increment' '--local' '--no-local' '--manual' '--no-manual' '--partitions' '--no-partitions' '-u' '--username' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_help_option_strings=(-h --help)
_shtab_ahriman_help_option_strings=('-h' '--help') _shtab_ahriman_help_commands_unsafe_option_strings=(-h --help)
_shtab_ahriman_help_commands_unsafe_option_strings=('-h' '--help') _shtab_ahriman_help_updates_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_help_updates_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_help_version_option_strings=(-h --help)
_shtab_ahriman_help_version_option_strings=('-h' '--help') _shtab_ahriman_init_option_strings=(-h --help --build-as-user --from-configuration --generate-salt --no-generate-salt --makeflags-jobs --no-makeflags-jobs --mirror --multilib --no-multilib --packager --server --sign-key --sign-target --web-port --web-unix-socket)
_shtab_ahriman_init_option_strings=('-h' '--help' '--build-as-user' '--from-configuration' '--generate-salt' '--no-generate-salt' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--server' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket') _shtab_ahriman_key_import_option_strings=(-h --help --key-server)
_shtab_ahriman_key_import_option_strings=('-h' '--help' '--key-server') _shtab_ahriman_package_add_option_strings=(-h --help --changes --no-changes --dependencies --no-dependencies -e --exit-code --increment --no-increment -n --now -s --source -u --username -v --variable -y --refresh)
_shtab_ahriman_package_add_option_strings=('-h' '--help' '--changes' '--no-changes' '--dependencies' '--no-dependencies' '-e' '--exit-code' '--increment' '--no-increment' '-n' '--now' '-s' '--source' '-u' '--username' '-v' '--variable' '-y' '--refresh') _shtab_ahriman_package_archives_option_strings=(-h --help -e --exit-code --info --no-info)
_shtab_ahriman_package_archives_option_strings=('-h' '--help' '-e' '--exit-code' '--info' '--no-info') _shtab_ahriman_package_changes_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_package_changes_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_package_changes_remove_option_strings=(-h --help)
_shtab_ahriman_package_changes_remove_option_strings=('-h' '--help') _shtab_ahriman_package_copy_option_strings=(-h --help -e --exit-code --remove)
_shtab_ahriman_package_copy_option_strings=('-h' '--help' '-e' '--exit-code' '--remove') _shtab_ahriman_package_hold_option_strings=(-h --help)
_shtab_ahriman_package_hold_option_strings=('-h' '--help') _shtab_ahriman_package_pkgbuild_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_package_pkgbuild_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_package_pkgbuild_remove_option_strings=(-h --help)
_shtab_ahriman_package_pkgbuild_remove_option_strings=('-h' '--help') _shtab_ahriman_package_remove_option_strings=(-h --help)
_shtab_ahriman_package_remove_option_strings=('-h' '--help') _shtab_ahriman_package_rollback_option_strings=(-h --help --hold --no-hold -u --username)
_shtab_ahriman_package_rollback_option_strings=('-h' '--help' '--hold' '--no-hold' '-u' '--username') _shtab_ahriman_package_status_option_strings=(-h --help --ahriman -e --exit-code --info --no-info -s --status)
_shtab_ahriman_package_status_option_strings=('-h' '--help' '--ahriman' '-e' '--exit-code' '--info' '--no-info' '-s' '--status') _shtab_ahriman_package_status_remove_option_strings=(-h --help)
_shtab_ahriman_package_status_remove_option_strings=('-h' '--help') _shtab_ahriman_package_status_update_option_strings=(-h --help -s --status)
_shtab_ahriman_package_status_update_option_strings=('-h' '--help' '-s' '--status') _shtab_ahriman_package_unhold_option_strings=(-h --help)
_shtab_ahriman_package_unhold_option_strings=('-h' '--help') _shtab_ahriman_package_update_option_strings=(-h --help --changes --no-changes --dependencies --no-dependencies -e --exit-code --increment --no-increment -n --now -s --source -u --username -v --variable -y --refresh)
_shtab_ahriman_package_update_option_strings=('-h' '--help' '--changes' '--no-changes' '--dependencies' '--no-dependencies' '-e' '--exit-code' '--increment' '--no-increment' '-n' '--now' '-s' '--source' '-u' '--username' '-v' '--variable' '-y' '--refresh') _shtab_ahriman_patch_add_option_strings=(-h --help)
_shtab_ahriman_patch_add_option_strings=('-h' '--help') _shtab_ahriman_patch_list_option_strings=(-h --help -e --exit-code -v --variable)
_shtab_ahriman_patch_list_option_strings=('-h' '--help' '-e' '--exit-code' '-v' '--variable') _shtab_ahriman_patch_remove_option_strings=(-h --help -v --variable)
_shtab_ahriman_patch_remove_option_strings=('-h' '--help' '-v' '--variable') _shtab_ahriman_patch_set_add_option_strings=(-h --help -t --track)
_shtab_ahriman_patch_set_add_option_strings=('-h' '--help' '-t' '--track') _shtab_ahriman_rebuild_option_strings=(-h --help --depends-on --dry-run --from-database --increment --no-increment -e --exit-code -s --status -u --username)
_shtab_ahriman_rebuild_option_strings=('-h' '--help' '--depends-on' '--dry-run' '--from-database' '--increment' '--no-increment' '-e' '--exit-code' '-s' '--status' '-u' '--username') _shtab_ahriman_remove_option_strings=(-h --help)
_shtab_ahriman_remove_option_strings=('-h' '--help') _shtab_ahriman_remove_unknown_option_strings=(-h --help --dry-run)
_shtab_ahriman_remove_unknown_option_strings=('-h' '--help' '--dry-run') _shtab_ahriman_repo_backup_option_strings=(-h --help)
_shtab_ahriman_repo_backup_option_strings=('-h' '--help') _shtab_ahriman_repo_check_option_strings=(-h --help --changes --no-changes --check-files --no-check-files -e --exit-code --vcs --no-vcs -y --refresh)
_shtab_ahriman_repo_check_option_strings=('-h' '--help' '--changes' '--no-changes' '--check-files' '--no-check-files' '-e' '--exit-code' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_repo_clean_option_strings=(-h --help --cache --no-cache --chroot --no-chroot --manual --no-manual --packages --no-packages --pacman --no-pacman)
_shtab_ahriman_repo_clean_option_strings=('-h' '--help' '--cache' '--no-cache' '--chroot' '--no-chroot' '--manual' '--no-manual' '--packages' '--no-packages' '--pacman' '--no-pacman') _shtab_ahriman_repo_config_option_strings=(-h --help --info --no-info --secure --no-secure)
_shtab_ahriman_repo_config_option_strings=('-h' '--help' '--info' '--no-info' '--secure' '--no-secure') _shtab_ahriman_repo_config_validate_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_repo_config_validate_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_repo_create_keyring_option_strings=(-h --help)
_shtab_ahriman_repo_create_keyring_option_strings=('-h' '--help') _shtab_ahriman_repo_create_mirrorlist_option_strings=(-h --help)
_shtab_ahriman_repo_create_mirrorlist_option_strings=('-h' '--help') _shtab_ahriman_repo_daemon_option_strings=(-h --help -i --interval --aur --no-aur --changes --no-changes --check-files --no-check-files --dependencies --no-dependencies --dry-run --increment --no-increment --local --no-local --manual --no-manual --partitions --no-partitions -u --username --vcs --no-vcs -y --refresh)
_shtab_ahriman_repo_daemon_option_strings=('-h' '--help' '-i' '--interval' '--aur' '--no-aur' '--changes' '--no-changes' '--check-files' '--no-check-files' '--dependencies' '--no-dependencies' '--dry-run' '--increment' '--no-increment' '--local' '--no-local' '--manual' '--no-manual' '--partitions' '--no-partitions' '-u' '--username' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_repo_init_option_strings=(-h --help --build-as-user --from-configuration --generate-salt --no-generate-salt --makeflags-jobs --no-makeflags-jobs --mirror --multilib --no-multilib --packager --server --sign-key --sign-target --web-port --web-unix-socket)
_shtab_ahriman_repo_init_option_strings=('-h' '--help' '--build-as-user' '--from-configuration' '--generate-salt' '--no-generate-salt' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--server' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket') _shtab_ahriman_repo_rebuild_option_strings=(-h --help --depends-on --dry-run --from-database --increment --no-increment -e --exit-code -s --status -u --username)
_shtab_ahriman_repo_rebuild_option_strings=('-h' '--help' '--depends-on' '--dry-run' '--from-database' '--increment' '--no-increment' '-e' '--exit-code' '-s' '--status' '-u' '--username') _shtab_ahriman_repo_remove_unknown_option_strings=(-h --help --dry-run)
_shtab_ahriman_repo_remove_unknown_option_strings=('-h' '--help' '--dry-run') _shtab_ahriman_repo_report_option_strings=(-h --help)
_shtab_ahriman_repo_report_option_strings=('-h' '--help') _shtab_ahriman_repo_restore_option_strings=(-h --help -o --output)
_shtab_ahriman_repo_restore_option_strings=('-h' '--help' '-o' '--output') _shtab_ahriman_repo_setup_option_strings=(-h --help --build-as-user --from-configuration --generate-salt --no-generate-salt --makeflags-jobs --no-makeflags-jobs --mirror --multilib --no-multilib --packager --server --sign-key --sign-target --web-port --web-unix-socket)
_shtab_ahriman_repo_setup_option_strings=('-h' '--help' '--build-as-user' '--from-configuration' '--generate-salt' '--no-generate-salt' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--server' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket') _shtab_ahriman_repo_sign_option_strings=(-h --help)
_shtab_ahriman_repo_sign_option_strings=('-h' '--help') _shtab_ahriman_repo_statistics_option_strings=(-h --help --chart -e --event --from-date --limit --offset --to-date)
_shtab_ahriman_repo_statistics_option_strings=('-h' '--help' '--chart' '-e' '--event' '--from-date' '--limit' '--offset' '--to-date') _shtab_ahriman_repo_status_update_option_strings=(-h --help -s --status)
_shtab_ahriman_repo_status_update_option_strings=('-h' '--help' '-s' '--status') _shtab_ahriman_repo_sync_option_strings=(-h --help)
_shtab_ahriman_repo_sync_option_strings=('-h' '--help') _shtab_ahriman_repo_tree_option_strings=(-h --help -p --partitions)
_shtab_ahriman_repo_tree_option_strings=('-h' '--help' '-p' '--partitions') _shtab_ahriman_repo_triggers_option_strings=(-h --help)
_shtab_ahriman_repo_triggers_option_strings=('-h' '--help') _shtab_ahriman_repo_update_option_strings=(-h --help --aur --no-aur --changes --no-changes --check-files --no-check-files --dependencies --no-dependencies --dry-run -e --exit-code --increment --no-increment --local --no-local --manual --no-manual -u --username --vcs --no-vcs -y --refresh)
_shtab_ahriman_repo_update_option_strings=('-h' '--help' '--aur' '--no-aur' '--changes' '--no-changes' '--check-files' '--no-check-files' '--dependencies' '--no-dependencies' '--dry-run' '-e' '--exit-code' '--increment' '--no-increment' '--local' '--no-local' '--manual' '--no-manual' '-u' '--username' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_report_option_strings=(-h --help)
_shtab_ahriman_report_option_strings=('-h' '--help') _shtab_ahriman_run_option_strings=(-h --help)
_shtab_ahriman_run_option_strings=('-h' '--help') _shtab_ahriman_search_option_strings=(-h --help -e --exit-code --info --no-info --sort-by)
_shtab_ahriman_search_option_strings=('-h' '--help' '-e' '--exit-code' '--info' '--no-info' '--sort-by') _shtab_ahriman_service_clean_option_strings=(-h --help --cache --no-cache --chroot --no-chroot --manual --no-manual --packages --no-packages --pacman --no-pacman)
_shtab_ahriman_service_clean_option_strings=('-h' '--help' '--cache' '--no-cache' '--chroot' '--no-chroot' '--manual' '--no-manual' '--packages' '--no-packages' '--pacman' '--no-pacman') _shtab_ahriman_service_config_option_strings=(-h --help --info --no-info --secure --no-secure)
_shtab_ahriman_service_config_option_strings=('-h' '--help' '--info' '--no-info' '--secure' '--no-secure') _shtab_ahriman_service_config_validate_option_strings=(-h --help -e --exit-code)
_shtab_ahriman_service_config_validate_option_strings=('-h' '--help' '-e' '--exit-code') _shtab_ahriman_service_key_import_option_strings=(-h --help --key-server)
_shtab_ahriman_service_key_import_option_strings=('-h' '--help' '--key-server') _shtab_ahriman_service_repositories_option_strings=(-h --help --id-only --no-id-only)
_shtab_ahriman_service_repositories_option_strings=('-h' '--help' '--id-only' '--no-id-only') _shtab_ahriman_service_run_option_strings=(-h --help)
_shtab_ahriman_service_run_option_strings=('-h' '--help') _shtab_ahriman_service_setup_option_strings=(-h --help --build-as-user --from-configuration --generate-salt --no-generate-salt --makeflags-jobs --no-makeflags-jobs --mirror --multilib --no-multilib --packager --server --sign-key --sign-target --web-port --web-unix-socket)
_shtab_ahriman_service_setup_option_strings=('-h' '--help' '--build-as-user' '--from-configuration' '--generate-salt' '--no-generate-salt' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--server' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket') _shtab_ahriman_service_shell_option_strings=(-h --help -o --output)
_shtab_ahriman_service_shell_option_strings=('-h' '--help' '-o' '--output') _shtab_ahriman_service_tree_migrate_option_strings=(-h --help)
_shtab_ahriman_service_tree_migrate_option_strings=('-h' '--help') _shtab_ahriman_setup_option_strings=(-h --help --build-as-user --from-configuration --generate-salt --no-generate-salt --makeflags-jobs --no-makeflags-jobs --mirror --multilib --no-multilib --packager --server --sign-key --sign-target --web-port --web-unix-socket)
_shtab_ahriman_setup_option_strings=('-h' '--help' '--build-as-user' '--from-configuration' '--generate-salt' '--no-generate-salt' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--server' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket') _shtab_ahriman_shell_option_strings=(-h --help -o --output)
_shtab_ahriman_shell_option_strings=('-h' '--help' '-o' '--output') _shtab_ahriman_sign_option_strings=(-h --help)
_shtab_ahriman_sign_option_strings=('-h' '--help') _shtab_ahriman_status_option_strings=(-h --help --ahriman -e --exit-code --info --no-info -s --status)
_shtab_ahriman_status_option_strings=('-h' '--help' '--ahriman' '-e' '--exit-code' '--info' '--no-info' '-s' '--status') _shtab_ahriman_status_update_option_strings=(-h --help -s --status)
_shtab_ahriman_status_update_option_strings=('-h' '--help' '-s' '--status') _shtab_ahriman_sync_option_strings=(-h --help)
_shtab_ahriman_sync_option_strings=('-h' '--help') _shtab_ahriman_update_option_strings=(-h --help --aur --no-aur --changes --no-changes --check-files --no-check-files --dependencies --no-dependencies --dry-run -e --exit-code --increment --no-increment --local --no-local --manual --no-manual -u --username --vcs --no-vcs -y --refresh)
_shtab_ahriman_update_option_strings=('-h' '--help' '--aur' '--no-aur' '--changes' '--no-changes' '--check-files' '--no-check-files' '--dependencies' '--no-dependencies' '--dry-run' '-e' '--exit-code' '--increment' '--no-increment' '--local' '--no-local' '--manual' '--no-manual' '-u' '--username' '--vcs' '--no-vcs' '-y' '--refresh') _shtab_ahriman_user_add_option_strings=(-h --help --key --packager -p --password -R --role)
_shtab_ahriman_user_add_option_strings=('-h' '--help' '--key' '--packager' '-p' '--password' '-R' '--role') _shtab_ahriman_user_list_option_strings=(-h --help -e --exit-code -R --role)
_shtab_ahriman_user_list_option_strings=('-h' '--help' '-e' '--exit-code' '-R' '--role') _shtab_ahriman_user_remove_option_strings=(-h --help)
_shtab_ahriman_user_remove_option_strings=('-h' '--help') _shtab_ahriman_version_option_strings=(-h --help)
_shtab_ahriman_version_option_strings=('-h' '--help') _shtab_ahriman_web_option_strings=(-h --help)
_shtab_ahriman_web_option_strings=('-h' '--help') _shtab_ahriman_web_reload_option_strings=(-h --help)
_shtab_ahriman_web_reload_option_strings=('-h' '--help') _shtab_ahriman_option_strings=(-h --help -a --architecture -c --configuration --force -l --lock --log-handler -q --quiet --report --no-report -r --repository --unsafe -V --version --wait-timeout)
_shtab_ahriman_pos_0_choices=('add' 'aur-search' 'check' 'clean' 'config' 'config-validate' 'copy' 'daemon' 'help' 'help-commands-unsafe' 'help-updates' 'help-version' 'init' 'key-import' 'package-add' 'package-archives' 'package-changes' 'package-changes-remove' 'package-copy' 'package-hold' 'package-pkgbuild' 'package-pkgbuild-remove' 'package-remove' 'package-rollback' 'package-status' 'package-status-remove' 'package-status-update' 'package-unhold' 'package-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'rebuild' 'remove' 'remove-unknown' 'repo-backup' 'repo-check' 'repo-clean' 'repo-config' 'repo-config-validate' 'repo-create-keyring' 'repo-create-mirrorlist' 'repo-daemon' 'repo-init' 'repo-rebuild' 'repo-remove-unknown' 'repo-report' 'repo-restore' 'repo-setup' 'repo-sign' 'repo-statistics' 'repo-status-update' 'repo-sync' 'repo-tree' 'repo-triggers' 'repo-update' 'report' 'run' 'search' 'service-clean' 'service-config' 'service-config-validate' 'service-key-import' 'service-repositories' 'service-run' 'service-setup' 'service-shell' 'service-tree-migrate' 'setup' 'shell' 'sign' 'status' 'status-update' 'sync' 'update' 'user-add' 'user-list' 'user-remove' 'version' 'web' 'web-reload') _shtab_ahriman_add__s_choices=(auto archive aur directory local remote repository)
_shtab_ahriman___log_handler_choices=('console' 'syslog' 'journald') _shtab_ahriman_add___source_choices=(auto archive aur directory local remote repository)
_shtab_ahriman_add__s_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_aur_search___sort_by_choices=(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)
_shtab_ahriman_add___source_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_init___sign_target_choices=(disabled packages repository)
_shtab_ahriman_aur_search___sort_by_choices=('description' 'first_submitted' 'id' 'last_modified' 'maintainer' 'name' 'num_votes' 'out_of_date' 'package_base' 'package_base_id' 'popularity' 'repository' 'submitter' 'url' 'url_path' 'version') _shtab_ahriman_package_add__s_choices=(auto archive aur directory local remote repository)
_shtab_ahriman_init___sign_target_choices=('disabled' 'packages' 'repository') _shtab_ahriman_package_add___source_choices=(auto archive aur directory local remote repository)
_shtab_ahriman_package_add__s_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_package_status__s_choices=(unknown pending building failed success)
_shtab_ahriman_package_add___source_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_package_status___status_choices=(unknown pending building failed success)
_shtab_ahriman_package_status__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_package_status_update__s_choices=(unknown pending building failed success)
_shtab_ahriman_package_status___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_package_status_update___status_choices=(unknown pending building failed success)
_shtab_ahriman_package_status_update__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_package_update__s_choices=(auto archive aur directory local remote repository)
_shtab_ahriman_package_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_package_update___source_choices=(auto archive aur directory local remote repository)
_shtab_ahriman_package_update__s_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_rebuild__s_choices=(unknown pending building failed success)
_shtab_ahriman_package_update___source_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository') _shtab_ahriman_rebuild___status_choices=(unknown pending building failed success)
_shtab_ahriman_rebuild__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_repo_init___sign_target_choices=(disabled packages repository)
_shtab_ahriman_rebuild___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_repo_rebuild__s_choices=(unknown pending building failed success)
_shtab_ahriman_repo_init___sign_target_choices=('disabled' 'packages' 'repository') _shtab_ahriman_repo_rebuild___status_choices=(unknown pending building failed success)
_shtab_ahriman_repo_rebuild__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_repo_setup___sign_target_choices=(disabled packages repository)
_shtab_ahriman_repo_rebuild___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_repo_statistics__e_choices=(build-log package-held package-outdated package-removed package-status-changed package-update-failed package-updated service-status-changed)
_shtab_ahriman_repo_setup___sign_target_choices=('disabled' 'packages' 'repository') _shtab_ahriman_repo_statistics___event_choices=(build-log package-held package-outdated package-removed package-status-changed package-update-failed package-updated service-status-changed)
_shtab_ahriman_repo_statistics__e_choices=('build-log' 'package-held' 'package-outdated' 'package-removed' 'package-status-changed' 'package-update-failed' 'package-updated' 'service-status-changed') _shtab_ahriman_repo_status_update__s_choices=(unknown pending building failed success)
_shtab_ahriman_repo_statistics___event_choices=('build-log' 'package-held' 'package-outdated' 'package-removed' 'package-status-changed' 'package-update-failed' 'package-updated' 'service-status-changed') _shtab_ahriman_repo_status_update___status_choices=(unknown pending building failed success)
_shtab_ahriman_repo_status_update__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_search___sort_by_choices=(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)
_shtab_ahriman_repo_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_service_setup___sign_target_choices=(disabled packages repository)
_shtab_ahriman_search___sort_by_choices=('description' 'first_submitted' 'id' 'last_modified' 'maintainer' 'name' 'num_votes' 'out_of_date' 'package_base' 'package_base_id' 'popularity' 'repository' 'submitter' 'url' 'url_path' 'version') _shtab_ahriman_setup___sign_target_choices=(disabled packages repository)
_shtab_ahriman_service_setup___sign_target_choices=('disabled' 'packages' 'repository') _shtab_ahriman_status__s_choices=(unknown pending building failed success)
_shtab_ahriman_setup___sign_target_choices=('disabled' 'packages' 'repository') _shtab_ahriman_status___status_choices=(unknown pending building failed success)
_shtab_ahriman_status__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_status_update__s_choices=(unknown pending building failed success)
_shtab_ahriman_status___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_status_update___status_choices=(unknown pending building failed success)
_shtab_ahriman_status_update__s_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_user_add__R_choices=(unauthorized read reporter full)
_shtab_ahriman_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success') _shtab_ahriman_user_add___role_choices=(unauthorized read reporter full)
_shtab_ahriman_user_add__R_choices=('unauthorized' 'read' 'reporter' 'full') _shtab_ahriman_user_list__R_choices=(unauthorized read reporter full)
_shtab_ahriman_user_add___role_choices=('unauthorized' 'read' 'reporter' 'full') _shtab_ahriman_user_list___role_choices=(unauthorized read reporter full)
_shtab_ahriman_user_list__R_choices=('unauthorized' 'read' 'reporter' 'full') _shtab_ahriman_pos_0_choices=(add aur-search check clean config config-validate copy daemon help help-commands-unsafe help-updates help-version init key-import package-add package-archives package-changes package-changes-remove package-copy package-hold package-pkgbuild package-pkgbuild-remove package-remove package-rollback package-status package-status-remove package-status-update package-unhold package-update patch-add patch-list patch-remove patch-set-add rebuild remove remove-unknown repo-backup repo-check repo-clean repo-config repo-config-validate repo-create-keyring repo-create-mirrorlist repo-daemon repo-init repo-rebuild repo-remove-unknown repo-report repo-restore repo-setup repo-sign repo-statistics repo-status-update repo-sync repo-tree repo-triggers repo-update report run search service-clean service-config service-config-validate service-key-import service-repositories service-run service-setup service-shell service-tree-migrate setup shell sign status status-update sync update user-add user-list user-remove version web web-reload)
_shtab_ahriman_user_list___role_choices=('unauthorized' 'read' 'reporter' 'full') _shtab_ahriman___log_handler_choices=(console syslog journald)
_shtab_ahriman_pos_0_nargs=A...
_shtab_ahriman__h_nargs=0
_shtab_ahriman___help_nargs=0
_shtab_ahriman___force_nargs=0
_shtab_ahriman__q_nargs=0
_shtab_ahriman___quiet_nargs=0
_shtab_ahriman___report_nargs=0
_shtab_ahriman___no_report_nargs=0
_shtab_ahriman___unsafe_nargs=0
_shtab_ahriman__V_nargs=0
_shtab_ahriman___version_nargs=0
_shtab_ahriman_add_pos_0_nargs=+ _shtab_ahriman_add_pos_0_nargs=+
_shtab_ahriman_add__h_nargs=0 _shtab_ahriman_add__h_nargs=0
_shtab_ahriman_add___help_nargs=0 _shtab_ahriman_add___help_nargs=0
@@ -157,7 +151,7 @@ _shtab_ahriman_aur_search__e_nargs=0
_shtab_ahriman_aur_search___exit_code_nargs=0 _shtab_ahriman_aur_search___exit_code_nargs=0
_shtab_ahriman_aur_search___info_nargs=0 _shtab_ahriman_aur_search___info_nargs=0
_shtab_ahriman_aur_search___no_info_nargs=0 _shtab_ahriman_aur_search___no_info_nargs=0
_shtab_ahriman_check_pos_0_nargs=* _shtab_ahriman_check_pos_0_nargs='*'
_shtab_ahriman_check__h_nargs=0 _shtab_ahriman_check__h_nargs=0
_shtab_ahriman_check___help_nargs=0 _shtab_ahriman_check___help_nargs=0
_shtab_ahriman_check___changes_nargs=0 _shtab_ahriman_check___changes_nargs=0
@@ -223,7 +217,7 @@ _shtab_ahriman_daemon__y_nargs=0
_shtab_ahriman_daemon___refresh_nargs=0 _shtab_ahriman_daemon___refresh_nargs=0
_shtab_ahriman_help__h_nargs=0 _shtab_ahriman_help__h_nargs=0
_shtab_ahriman_help___help_nargs=0 _shtab_ahriman_help___help_nargs=0
_shtab_ahriman_help_commands_unsafe_pos_0_nargs=* _shtab_ahriman_help_commands_unsafe_pos_0_nargs='*'
_shtab_ahriman_help_commands_unsafe__h_nargs=0 _shtab_ahriman_help_commands_unsafe__h_nargs=0
_shtab_ahriman_help_commands_unsafe___help_nargs=0 _shtab_ahriman_help_commands_unsafe___help_nargs=0
_shtab_ahriman_help_updates__h_nargs=0 _shtab_ahriman_help_updates__h_nargs=0
@@ -291,7 +285,7 @@ _shtab_ahriman_package_rollback__h_nargs=0
_shtab_ahriman_package_rollback___help_nargs=0 _shtab_ahriman_package_rollback___help_nargs=0
_shtab_ahriman_package_rollback___hold_nargs=0 _shtab_ahriman_package_rollback___hold_nargs=0
_shtab_ahriman_package_rollback___no_hold_nargs=0 _shtab_ahriman_package_rollback___no_hold_nargs=0
_shtab_ahriman_package_status_pos_0_nargs=* _shtab_ahriman_package_status_pos_0_nargs='*'
_shtab_ahriman_package_status__h_nargs=0 _shtab_ahriman_package_status__h_nargs=0
_shtab_ahriman_package_status___help_nargs=0 _shtab_ahriman_package_status___help_nargs=0
_shtab_ahriman_package_status___ahriman_nargs=0 _shtab_ahriman_package_status___ahriman_nargs=0
@@ -302,7 +296,7 @@ _shtab_ahriman_package_status___no_info_nargs=0
_shtab_ahriman_package_status_remove_pos_0_nargs=+ _shtab_ahriman_package_status_remove_pos_0_nargs=+
_shtab_ahriman_package_status_remove__h_nargs=0 _shtab_ahriman_package_status_remove__h_nargs=0
_shtab_ahriman_package_status_remove___help_nargs=0 _shtab_ahriman_package_status_remove___help_nargs=0
_shtab_ahriman_package_status_update_pos_0_nargs=* _shtab_ahriman_package_status_update_pos_0_nargs='*'
_shtab_ahriman_package_status_update__h_nargs=0 _shtab_ahriman_package_status_update__h_nargs=0
_shtab_ahriman_package_status_update___help_nargs=0 _shtab_ahriman_package_status_update___help_nargs=0
_shtab_ahriman_package_unhold_pos_0_nargs=+ _shtab_ahriman_package_unhold_pos_0_nargs=+
@@ -349,7 +343,7 @@ _shtab_ahriman_remove_unknown___help_nargs=0
_shtab_ahriman_remove_unknown___dry_run_nargs=0 _shtab_ahriman_remove_unknown___dry_run_nargs=0
_shtab_ahriman_repo_backup__h_nargs=0 _shtab_ahriman_repo_backup__h_nargs=0
_shtab_ahriman_repo_backup___help_nargs=0 _shtab_ahriman_repo_backup___help_nargs=0
_shtab_ahriman_repo_check_pos_0_nargs=* _shtab_ahriman_repo_check_pos_0_nargs='*'
_shtab_ahriman_repo_check__h_nargs=0 _shtab_ahriman_repo_check__h_nargs=0
_shtab_ahriman_repo_check___help_nargs=0 _shtab_ahriman_repo_check___help_nargs=0
_shtab_ahriman_repo_check___changes_nargs=0 _shtab_ahriman_repo_check___changes_nargs=0
@@ -442,7 +436,7 @@ _shtab_ahriman_repo_setup___makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___no_makeflags_jobs_nargs=0 _shtab_ahriman_repo_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___multilib_nargs=0 _shtab_ahriman_repo_setup___multilib_nargs=0
_shtab_ahriman_repo_setup___no_multilib_nargs=0 _shtab_ahriman_repo_setup___no_multilib_nargs=0
_shtab_ahriman_repo_sign_pos_0_nargs=* _shtab_ahriman_repo_sign_pos_0_nargs='*'
_shtab_ahriman_repo_sign__h_nargs=0 _shtab_ahriman_repo_sign__h_nargs=0
_shtab_ahriman_repo_sign___help_nargs=0 _shtab_ahriman_repo_sign___help_nargs=0
_shtab_ahriman_repo_statistics__h_nargs=0 _shtab_ahriman_repo_statistics__h_nargs=0
@@ -453,10 +447,10 @@ _shtab_ahriman_repo_sync__h_nargs=0
_shtab_ahriman_repo_sync___help_nargs=0 _shtab_ahriman_repo_sync___help_nargs=0
_shtab_ahriman_repo_tree__h_nargs=0 _shtab_ahriman_repo_tree__h_nargs=0
_shtab_ahriman_repo_tree___help_nargs=0 _shtab_ahriman_repo_tree___help_nargs=0
_shtab_ahriman_repo_triggers_pos_0_nargs=* _shtab_ahriman_repo_triggers_pos_0_nargs='*'
_shtab_ahriman_repo_triggers__h_nargs=0 _shtab_ahriman_repo_triggers__h_nargs=0
_shtab_ahriman_repo_triggers___help_nargs=0 _shtab_ahriman_repo_triggers___help_nargs=0
_shtab_ahriman_repo_update_pos_0_nargs=* _shtab_ahriman_repo_update_pos_0_nargs='*'
_shtab_ahriman_repo_update__h_nargs=0 _shtab_ahriman_repo_update__h_nargs=0
_shtab_ahriman_repo_update___help_nargs=0 _shtab_ahriman_repo_update___help_nargs=0
_shtab_ahriman_repo_update___aur_nargs=0 _shtab_ahriman_repo_update___aur_nargs=0
@@ -533,8 +527,6 @@ _shtab_ahriman_service_setup___multilib_nargs=0
_shtab_ahriman_service_setup___no_multilib_nargs=0 _shtab_ahriman_service_setup___no_multilib_nargs=0
_shtab_ahriman_service_shell__h_nargs=0 _shtab_ahriman_service_shell__h_nargs=0
_shtab_ahriman_service_shell___help_nargs=0 _shtab_ahriman_service_shell___help_nargs=0
_shtab_ahriman_service_shell__v_nargs=0
_shtab_ahriman_service_shell___verbose_nargs=0
_shtab_ahriman_service_tree_migrate__h_nargs=0 _shtab_ahriman_service_tree_migrate__h_nargs=0
_shtab_ahriman_service_tree_migrate___help_nargs=0 _shtab_ahriman_service_tree_migrate___help_nargs=0
_shtab_ahriman_setup__h_nargs=0 _shtab_ahriman_setup__h_nargs=0
@@ -547,12 +539,10 @@ _shtab_ahriman_setup___multilib_nargs=0
_shtab_ahriman_setup___no_multilib_nargs=0 _shtab_ahriman_setup___no_multilib_nargs=0
_shtab_ahriman_shell__h_nargs=0 _shtab_ahriman_shell__h_nargs=0
_shtab_ahriman_shell___help_nargs=0 _shtab_ahriman_shell___help_nargs=0
_shtab_ahriman_shell__v_nargs=0 _shtab_ahriman_sign_pos_0_nargs='*'
_shtab_ahriman_shell___verbose_nargs=0
_shtab_ahriman_sign_pos_0_nargs=*
_shtab_ahriman_sign__h_nargs=0 _shtab_ahriman_sign__h_nargs=0
_shtab_ahriman_sign___help_nargs=0 _shtab_ahriman_sign___help_nargs=0
_shtab_ahriman_status_pos_0_nargs=* _shtab_ahriman_status_pos_0_nargs='*'
_shtab_ahriman_status__h_nargs=0 _shtab_ahriman_status__h_nargs=0
_shtab_ahriman_status___help_nargs=0 _shtab_ahriman_status___help_nargs=0
_shtab_ahriman_status___ahriman_nargs=0 _shtab_ahriman_status___ahriman_nargs=0
@@ -560,12 +550,12 @@ _shtab_ahriman_status__e_nargs=0
_shtab_ahriman_status___exit_code_nargs=0 _shtab_ahriman_status___exit_code_nargs=0
_shtab_ahriman_status___info_nargs=0 _shtab_ahriman_status___info_nargs=0
_shtab_ahriman_status___no_info_nargs=0 _shtab_ahriman_status___no_info_nargs=0
_shtab_ahriman_status_update_pos_0_nargs=* _shtab_ahriman_status_update_pos_0_nargs='*'
_shtab_ahriman_status_update__h_nargs=0 _shtab_ahriman_status_update__h_nargs=0
_shtab_ahriman_status_update___help_nargs=0 _shtab_ahriman_status_update___help_nargs=0
_shtab_ahriman_sync__h_nargs=0 _shtab_ahriman_sync__h_nargs=0
_shtab_ahriman_sync___help_nargs=0 _shtab_ahriman_sync___help_nargs=0
_shtab_ahriman_update_pos_0_nargs=* _shtab_ahriman_update_pos_0_nargs='*'
_shtab_ahriman_update__h_nargs=0 _shtab_ahriman_update__h_nargs=0
_shtab_ahriman_update___help_nargs=0 _shtab_ahriman_update___help_nargs=0
_shtab_ahriman_update___aur_nargs=0 _shtab_ahriman_update___aur_nargs=0
@@ -603,6 +593,17 @@ _shtab_ahriman_web__h_nargs=0
_shtab_ahriman_web___help_nargs=0 _shtab_ahriman_web___help_nargs=0
_shtab_ahriman_web_reload__h_nargs=0 _shtab_ahriman_web_reload__h_nargs=0
_shtab_ahriman_web_reload___help_nargs=0 _shtab_ahriman_web_reload___help_nargs=0
_shtab_ahriman_pos_0_nargs=A...
_shtab_ahriman__h_nargs=0
_shtab_ahriman___help_nargs=0
_shtab_ahriman___force_nargs=0
_shtab_ahriman__q_nargs=0
_shtab_ahriman___quiet_nargs=0
_shtab_ahriman___report_nargs=0
_shtab_ahriman___no_report_nargs=0
_shtab_ahriman___unsafe_nargs=0
_shtab_ahriman__V_nargs=0
_shtab_ahriman___version_nargs=0
# $1=COMP_WORDS[1] # $1=COMP_WORDS[1]
@@ -630,7 +631,7 @@ _set_parser_defaults() {
completed_positional_actions=0 completed_positional_actions=0
_set_new_action "pos_${completed_positional_actions}" true _set_new_action "pos_$completed_positional_actions" true
} }
# $1=action identifier # $1=action identifier
@@ -680,7 +681,7 @@ _shtab_ahriman() {
local prefix=_shtab_ahriman local prefix=_shtab_ahriman
local word_index=0 local word_index=0
local pos_only=0 # "--" delimeter not encountered yet local pos_only=0 # "--" delimiter not encountered yet
_set_parser_defaults _set_parser_defaults
word_index=1 word_index=1
@@ -690,13 +691,13 @@ _shtab_ahriman() {
local this_word="${COMP_WORDS[$word_index]}" local this_word="${COMP_WORDS[$word_index]}"
if [[ $pos_only = 1 || " $this_word " != " -- " ]]; then if [[ $pos_only = 1 || " $this_word " != " -- " ]]; then
if [[ -n $sub_parsers && " ${sub_parsers[@]} " == *" ${this_word} "* ]]; then if [[ -n $sub_parsers && " ${sub_parsers[@]} " == *" $this_word "* ]]; then
# valid subcommand: add it to the prefix & reset the current action # valid subcommand: add it to the prefix & reset the current action
prefix="${prefix}_$(_shtab_replace_nonword $this_word)" prefix="${prefix}_$(_shtab_replace_nonword $this_word)"
_set_parser_defaults _set_parser_defaults
fi fi
if [[ " ${current_option_strings[@]} " == *" ${this_word} "* ]]; then if [[ " ${current_option_strings[@]} " == *" $this_word "* ]]; then
# a new action should be acquired (due to recognised option string or # a new action should be acquired (due to recognised option string or
# no more input expected from current action); # no more input expected from current action);
# the next positional action can fill in here # the next positional action can fill in here
@@ -710,10 +711,10 @@ _shtab_ahriman() {
(( $word_index + 1 - $current_action_args_start_index - $pos_only >= \ (( $word_index + 1 - $current_action_args_start_index - $pos_only >= \
$current_action_nargs )); then $current_action_nargs )); then
$current_action_is_positional && let "completed_positional_actions += 1" $current_action_is_positional && let "completed_positional_actions += 1"
_set_new_action "pos_${completed_positional_actions}" true _set_new_action "pos_$completed_positional_actions" true
fi fi
else else
pos_only=1 # "--" delimeter encountered pos_only=1 # "--" delimiter encountered
fi fi
let "word_index+=1" let "word_index+=1"
@@ -721,23 +722,32 @@ _shtab_ahriman() {
# Generate the completions # Generate the completions
if [[ $pos_only = 0 && "${completing_word}" == -* ]]; then COMPREPLY=()
if [[ $pos_only = 0 && "$completing_word" == -* &&
( -z "$current_action_compgen" || "$current_action_is_positional" = true ) ]]; then
# optional argument started: use option strings # optional argument started: use option strings
COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") ) while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
elif [[ "${previous_word}" == ">" || "${previous_word}" == ">>" || compgen -W "${current_option_strings[*]}" -- "$completing_word")
"${previous_word}" =~ ^[12]">" || "${previous_word}" =~ ^[12]">>" ]]; then elif [[ "$previous_word" =~ ^[0-9\&]*[\<\>]\>?$ ]]; then
# handle redirection operators # handle redirection operators
COMPREPLY=( $(compgen -f -- "${completing_word}") ) compopt -o filenames 2>/dev/null || : # bash>=4
while IFS= read -r line; do COMPREPLY+=("$line"); done < <(compgen -f -- "$completing_word")
else else
# use choices & compgen # use choices & compgen
local IFS=$'\n' # items may contain spaces, so delimit using newline local action_compgen_word="$completing_word"
COMPREPLY=( $([ -n "${current_action_compgen}" ] \ # handle tab-completing in the middle of a line (#248 <- #116)
&& "${current_action_compgen}" "${completing_word}") ) [[ -n "$current_action_compgen" && "$completing_word" == -* ]] && action_compgen_word=""
unset IFS [ -n "$current_action_compgen" ] && {
COMPREPLY+=( $(compgen -W "${current_action_choices[*]}" -- "${completing_word}") ) [[ "$current_action_compgen" =~ _(file|dir|glob|FILE|DIR|GLOB)|File|Dir|Glob ]] &&
compopt -o filenames 2>/dev/null || : # bash>=4
while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
"$current_action_compgen" "$action_compgen_word")
}
while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
compgen -W "${current_action_choices[*]}" -- "$completing_word")
fi fi
return 0 return 0
} }
complete -o filenames -F _shtab_ahriman ahriman complete -F _shtab_ahriman ahriman
@@ -1,4 +1,4 @@
.TH AHRIMAN "1" "2026\-07\-21" "ahriman 2.21.0" "ArcH linux ReposItory MANager" .TH AHRIMAN "1" "2026\-10\-30" "ahriman 2.23.6" "ArcH linux ReposItory MANager"
.SH NAME .SH NAME
ahriman \- ArcH linux ReposItory MANager ahriman \- ArcH linux ReposItory MANager
.SH SYNOPSIS .SH SYNOPSIS
@@ -990,7 +990,7 @@ usage: ahriman service\-setup [\-h] [\-\-build\-as\-user BUILD_AS_USER] [\-\-fro
[\-\-sign\-key SIGN_KEY] [\-\-sign\-target {disabled,packages,repository}] [\-\-web\-port WEB_PORT] [\-\-sign\-key SIGN_KEY] [\-\-sign\-target {disabled,packages,repository}] [\-\-web\-port WEB_PORT]
[\-\-web\-unix\-socket WEB_UNIX_SOCKET] [\-\-web\-unix\-socket WEB_UNIX_SOCKET]
create initial service configuration, requires root create initial service configuration as the repository owner
.SH OPTIONS \fI\,'ahriman service\-setup'\/\fR .SH OPTIONS \fI\,'ahriman service\-setup'\/\fR
.TP .TP
@@ -1,92 +1,97 @@
#compdef ahriman #compdef ahriman
# AUTOMATICALLY GENERATED by `shtab` # AUTOMATICALLY GENERATED by https://github.com/tqdm/shtab
# Usage:
# 1) Copy this to a file named _ahriman (e.g. ~/.local/share/zsh_completion/_ahriman).
# 2) Add the following line to your .zshrc:
# fpath=(~/.local/share/zsh_completion $fpath)
# See also: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
_shtab_ahriman_commands() { _shtab_ahriman_commands() {
local _commands=( local _commands=(
"add:add existing or new package to the build queue" add:'add existing or new package to the build queue'
"aur-search:search for package in AUR using API" aur-search:'search for package in AUR using API'
"check:check for packages updates. Same as repo-update --dry-run --no-manual" check:'check for packages updates. Same as repo-update --dry-run --no-manual'
"clean:remove local caches" clean:'remove local caches'
"config:dump configuration for the specified architecture" config:'dump configuration for the specified architecture'
"config-validate:validate configuration and print found errors" config-validate:'validate configuration and print found errors'
"copy:copy package and its metadata from another repository" copy:'copy package and its metadata from another repository'
"daemon:start process which periodically will run update process" daemon:'start process which periodically will run update process'
"help:show help message for application or command and exit" help:'show help message for application or command and exit'
"help-commands-unsafe:list unsafe commands as defined in default args" help-commands-unsafe:'list unsafe commands as defined in default args'
"help-updates:request AUR for current version and compare with current service version" help-updates:'request AUR for current version and compare with current service version'
"help-version:print application and its dependencies versions" help-version:'print application and its dependencies versions'
"init:create initial service configuration, requires root" init:'create initial service configuration as the repository owner'
"key-import:import PGP key from public sources to the repository user" key-import:'import PGP key from public sources to the repository user'
"package-add:add existing or new package to the build queue" package-add:'add existing or new package to the build queue'
"package-archives:list available archive versions for the package" package-archives:'list available archive versions for the package'
"package-changes:retrieve package changes stored in database" package-changes:'retrieve package changes stored in database'
"package-changes-remove:remove the package changes stored remotely" package-changes-remove:'remove the package changes stored remotely'
"package-copy:copy package and its metadata from another repository" package-copy:'copy package and its metadata from another repository'
"package-hold:hold package from automatic updates" package-hold:'hold package from automatic updates'
"package-pkgbuild:retrieve package PKGBUILD stored in database" package-pkgbuild:'retrieve package PKGBUILD stored in database'
"package-pkgbuild-remove:remove the package PKGBUILD stored remotely" package-pkgbuild-remove:'remove the package PKGBUILD stored remotely'
"package-remove:remove package from the repository" package-remove:'remove package from the repository'
"package-rollback:rollback package to specified version from archives" package-rollback:'rollback package to specified version from archives'
"package-status:request status of the package" package-status:'request status of the package'
"package-status-remove:remove the package from the status page" package-status-remove:'remove the package from the status page'
"package-status-update:update package status on the status page" package-status-update:'update package status on the status page'
"package-unhold:remove package hold, allowing automatic updates" package-unhold:'remove package hold, allowing automatic updates'
"package-update:add existing or new package to the build queue" package-update:'add existing or new package to the build queue'
"patch-add:create or update patched PKGBUILD function or variable" patch-add:'create or update patched PKGBUILD function or variable'
"patch-list:list available patches for the package" patch-list:'list available patches for the package'
"patch-remove:remove patches for the package" patch-remove:'remove patches for the package'
"patch-set-add:create or update source patches" patch-set-add:'create or update source patches'
"rebuild:force rebuild whole repository" rebuild:'force rebuild whole repository'
"remove:remove package from the repository" remove:'remove package from the repository'
"remove-unknown:remove packages which are missing in AUR and do not have local PKGBUILDs" remove-unknown:'remove packages which are missing in AUR and do not have local PKGBUILDs'
"repo-backup:backup repository settings and database" repo-backup:'backup repository settings and database'
"repo-check:check for packages updates. Same as repo-update --dry-run --no-manual" repo-check:'check for packages updates. Same as repo-update --dry-run --no-manual'
"repo-clean:remove local caches" repo-clean:'remove local caches'
"repo-config:dump configuration for the specified architecture" repo-config:'dump configuration for the specified architecture'
"repo-config-validate:validate configuration and print found errors" repo-config-validate:'validate configuration and print found errors'
"repo-create-keyring:create package which contains list of trusted keys as set by configuration. Note, that this action will only create package, the package itself has to be built manually" repo-create-keyring:'create package which contains list of trusted keys as set by configuration. Note, that this action will only create package, the package itself has to be built manually'
"repo-create-mirrorlist:create package which contains list of available mirrors as set by configuration. Note, that this action will only create package, the package itself has to be built manually" repo-create-mirrorlist:'create package which contains list of available mirrors as set by configuration. Note, that this action will only create package, the package itself has to be built manually'
"repo-daemon:start process which periodically will run update process" repo-daemon:'start process which periodically will run update process'
"repo-init:create initial service configuration, requires root" repo-init:'create initial service configuration as the repository owner'
"repo-rebuild:force rebuild whole repository" repo-rebuild:'force rebuild whole repository'
"repo-remove-unknown:remove packages which are missing in AUR and do not have local PKGBUILDs" repo-remove-unknown:'remove packages which are missing in AUR and do not have local PKGBUILDs'
"repo-report:generate repository report according to current settings" repo-report:'generate repository report according to current settings'
"repo-restore:restore settings and database" repo-restore:'restore settings and database'
"repo-setup:create initial service configuration, requires root" repo-setup:'create initial service configuration as the repository owner'
"repo-sign:(re-)sign packages and repository database according to current settings" repo-sign:'(re-)sign packages and repository database according to current settings'
"repo-statistics:fetch repository statistics" repo-statistics:'fetch repository statistics'
"repo-status-update:update repository status on the status page" repo-status-update:'update repository status on the status page'
"repo-sync:sync repository files to remote server according to current settings" repo-sync:'sync repository files to remote server according to current settings'
"repo-tree:dump repository tree based on packages dependencies" repo-tree:'dump repository tree based on packages dependencies'
"repo-triggers:run triggers on empty build result as configured by settings" repo-triggers:'run triggers on empty build result as configured by settings'
"repo-update:check for packages updates and run build process if requested" repo-update:'check for packages updates and run build process if requested'
"report:generate repository report according to current settings" report:'generate repository report according to current settings'
"run:run multiple commands on success run of the previous command" run:'run multiple commands on success run of the previous command'
"search:search for package in AUR using API" search:'search for package in AUR using API'
"service-clean:remove local caches" service-clean:'remove local caches'
"service-config:dump configuration for the specified architecture" service-config:'dump configuration for the specified architecture'
"service-config-validate:validate configuration and print found errors" service-config-validate:'validate configuration and print found errors'
"service-key-import:import PGP key from public sources to the repository user" service-key-import:'import PGP key from public sources to the repository user'
"service-repositories:list all available repositories" service-repositories:'list all available repositories'
"service-run:run multiple commands on success run of the previous command" service-run:'run multiple commands on success run of the previous command'
"service-setup:create initial service configuration, requires root" service-setup:'create initial service configuration as the repository owner'
"service-shell:drop into python shell" service-shell:'drop into python shell'
"service-tree-migrate:migrate repository tree between versions" service-tree-migrate:'migrate repository tree between versions'
"setup:create initial service configuration, requires root" setup:'create initial service configuration as the repository owner'
"shell:drop into python shell" shell:'drop into python shell'
"sign:(re-)sign packages and repository database according to current settings" sign:'(re-)sign packages and repository database according to current settings'
"status:request status of the package" status:'request status of the package'
"status-update:update package status on the status page" status-update:'update package status on the status page'
"sync:sync repository files to remote server according to current settings" sync:'sync repository files to remote server according to current settings'
"update:check for packages updates and run build process if requested" update:'check for packages updates and run build process if requested'
"user-add:update user for web services with the given password and role. In case if password was not entered it will be asked interactively" user-add:'update user for web services with the given password and role. In case if password was not entered it will be asked interactively'
"user-list:list users from the user mapping and their roles" user-list:'list users from the user mapping and their roles'
"user-remove:remove user from the user mapping and update the configuration" user-remove:'remove user from the user mapping and update the configuration'
"version:print application and its dependencies versions" version:'print application and its dependencies versions'
"web:start web server" web:'start web server'
"web-reload:reload web server configuration" web-reload:'reload web server configuration'
) )
_describe 'ahriman commands' _commands _describe 'ahriman commands' _commands
} }
@@ -99,7 +104,7 @@ _shtab_ahriman_options=(
{-l,--lock}"[lock file (default\: ahriman.pid)]:lock:" {-l,--lock}"[lock file (default\: ahriman.pid)]:lock:"
"--log-handler[explicit log handler specification. If none set, the handler will be guessed from environment (default\: None)]:log_handler:(console syslog journald)" "--log-handler[explicit log handler specification. If none set, the handler will be guessed from environment (default\: None)]:log_handler:(console syslog journald)"
{-q,--quiet}"[force disable any logging (default\: False)]" {-q,--quiet}"[force disable any logging (default\: False)]"
{--report,--no-report}"[force enable or disable reporting to web service (default\: True)]:report:" {--report,--no-report}"[force enable or disable reporting to web service (default\: True)]"
{-r,--repository}"[filter by target repository (default\: None)]:repository:" {-r,--repository}"[filter by target repository (default\: None)]:repository:"
"--unsafe[allow to run ahriman as non-ahriman user. Some actions might be unavailable (default\: False)]" "--unsafe[allow to run ahriman as non-ahriman user. Some actions might be unavailable (default\: False)]"
"(- : *)"{-V,--version}"[show program\'s version number and exit]" "(- : *)"{-V,--version}"[show program\'s version number and exit]"
@@ -111,10 +116,10 @@ _shtab_ahriman_defaults_added=0
_shtab_ahriman_add_options=( _shtab_ahriman_add_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]"
{-n,--now}"[run update function after (default\: False)]" {-n,--now}"[run update function after (default\: False)]"
{-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)" {-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
@@ -129,7 +134,7 @@ _shtab_ahriman_add_defaults_added=0
_shtab_ahriman_aur_search_options=( _shtab_ahriman_aur_search_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--info,--no-info}"[show additional package information (default\: False)]:info:" {--info,--no-info}"[show additional package information (default\: False)]"
"--sort-by[sort field by this field. In case if two packages have the same value of the specified field, they will be always sorted by name (default\: name)]:sort_by:(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)" "--sort-by[sort field by this field. In case if two packages have the same value of the specified field, they will be always sorted by name (default\: name)]:sort_by:(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)"
"(*):search terms, can be specified multiple times, the result will match all terms:" "(*):search terms, can be specified multiple times, the result will match all terms:"
) )
@@ -139,10 +144,10 @@ _shtab_ahriman_aur_search_defaults_added=0
_shtab_ahriman_check_options=( _shtab_ahriman_check_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
"(*)::filter check by package base (default\: None):" "(*)::filter check by package base (default\: None):"
) )
@@ -152,11 +157,11 @@ _shtab_ahriman_check_defaults_added=0
_shtab_ahriman_clean_options=( _shtab_ahriman_clean_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--cache,--no-cache}"[clear directory with package caches (default\: False)]:cache:" {--cache,--no-cache}"[clear directory with package caches (default\: False)]"
{--chroot,--no-chroot}"[clear build chroot (default\: False)]:chroot:" {--chroot,--no-chroot}"[clear build chroot (default\: False)]"
{--manual,--no-manual}"[clear manually added packages queue (default\: False)]:manual:" {--manual,--no-manual}"[clear manually added packages queue (default\: False)]"
{--packages,--no-packages}"[clear directory with built packages (default\: False)]:packages:" {--packages,--no-packages}"[clear directory with built packages (default\: False)]"
{--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]:pacman:" {--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]"
) )
# guard to ensure default positional specs are added only once per session # guard to ensure default positional specs are added only once per session
@@ -164,8 +169,8 @@ _shtab_ahriman_clean_defaults_added=0
_shtab_ahriman_config_options=( _shtab_ahriman_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]:info:" {--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]"
{--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]:secure:" {--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]"
":filter settings by section (default\: None):" ":filter settings by section (default\: None):"
":filter settings by key (default\: None):" ":filter settings by key (default\: None):"
) )
@@ -195,17 +200,17 @@ _shtab_ahriman_copy_defaults_added=0
_shtab_ahriman_daemon_options=( _shtab_ahriman_daemon_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{-i,--interval}"[interval between runs in seconds (default\: 43200)]:interval:" {-i,--interval}"[interval between runs in seconds (default\: 43200)]:interval:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]:aur:" {--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
"--dry-run[just perform check for updates, same as check command (default\: False)]" "--dry-run[just perform check for updates, same as check command (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]:local:" {--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]"
{--manual,--no-manual}"[include or exclude manual updates (default\: True)]:manual:" {--manual,--no-manual}"[include or exclude manual updates (default\: True)]"
{--partitions,--no-partitions}"[instead of updating whole repository, split updates into chunks (default\: True)]:partitions:" {--partitions,--no-partitions}"[instead of updating whole repository, split updates into chunks (default\: True)]"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
) )
@@ -247,10 +252,10 @@ _shtab_ahriman_init_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:" "--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:"
"--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:" "--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:"
{--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]:generate_salt:" {--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]:makeflags_jobs:" {--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]"
"--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:" "--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]:multilib:" {--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]"
"--packager[packager name and email]:packager:" "--packager[packager name and email]:packager:"
"--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:" "--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:"
"--sign-key[sign key id (default\: None)]:sign_key:" "--sign-key[sign key id (default\: None)]:sign_key:"
@@ -273,10 +278,10 @@ _shtab_ahriman_key_import_defaults_added=0
_shtab_ahriman_package_add_options=( _shtab_ahriman_package_add_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]"
{-n,--now}"[run update function after (default\: False)]" {-n,--now}"[run update function after (default\: False)]"
{-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)" {-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
@@ -291,7 +296,7 @@ _shtab_ahriman_package_add_defaults_added=0
_shtab_ahriman_package_archives_options=( _shtab_ahriman_package_archives_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--info,--no-info}"[show additional package information (default\: False)]:info:" {--info,--no-info}"[show additional package information (default\: False)]"
":package base:" ":package base:"
) )
@@ -361,7 +366,7 @@ _shtab_ahriman_package_remove_defaults_added=0
_shtab_ahriman_package_rollback_options=( _shtab_ahriman_package_rollback_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--hold,--no-hold}"[hold package afterwards (default\: True)]:hold:" {--hold,--no-hold}"[hold package afterwards (default\: True)]"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
":package base:" ":package base:"
":package version:" ":package version:"
@@ -374,7 +379,7 @@ _shtab_ahriman_package_status_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--ahriman[get service status itself (default\: False)]" "--ahriman[get service status itself (default\: False)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--info,--no-info}"[show additional package information (default\: False)]:info:" {--info,--no-info}"[show additional package information (default\: False)]"
{-s,--status}"[filter packages by status (default\: None)]:status:(unknown pending building failed success)" {-s,--status}"[filter packages by status (default\: None)]:status:(unknown pending building failed success)"
"(*)::filter status by package base (default\: None):" "(*)::filter status by package base (default\: None):"
) )
@@ -409,10 +414,10 @@ _shtab_ahriman_package_unhold_defaults_added=0
_shtab_ahriman_package_update_options=( _shtab_ahriman_package_update_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) version on duplicate (default\: True)]"
{-n,--now}"[run update function after (default\: False)]" {-n,--now}"[run update function after (default\: False)]"
{-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)" {-s,--source}"[explicitly specify the package source for this command (default\: auto)]:source:(auto archive aur directory local remote repository)"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
@@ -467,7 +472,7 @@ _shtab_ahriman_rebuild_options=(
"*--depends-on[only rebuild packages that depend on specified packages (default\: None)]:depends_on:" "*--depends-on[only rebuild packages that depend on specified packages (default\: None)]:depends_on:"
"--dry-run[just perform check for packages without rebuild process itself (default\: False)]" "--dry-run[just perform check for packages without rebuild process itself (default\: False)]"
"--from-database[read packages from database instead of filesystem. This feature in particular is required in case if you would like to restore repository from another repository instance. Note, however, that in order to restore packages you need to have original ahriman instance run with web service and have run repo-update at least once. (default\: False)]" "--from-database[read packages from database instead of filesystem. This feature in particular is required in case if you would like to restore repository from another repository instance. Note, however, that in order to restore packages you need to have original ahriman instance run with web service and have run repo-update at least once. (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{-s,--status}"[filter packages by status. Requires --from-database to be set (default\: None)]:status:(unknown pending building failed success)" {-s,--status}"[filter packages by status. Requires --from-database to be set (default\: None)]:status:(unknown pending building failed success)"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
@@ -502,10 +507,10 @@ _shtab_ahriman_repo_backup_defaults_added=0
_shtab_ahriman_repo_check_options=( _shtab_ahriman_repo_check_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
"(*)::filter check by package base (default\: None):" "(*)::filter check by package base (default\: None):"
) )
@@ -515,11 +520,11 @@ _shtab_ahriman_repo_check_defaults_added=0
_shtab_ahriman_repo_clean_options=( _shtab_ahriman_repo_clean_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--cache,--no-cache}"[clear directory with package caches (default\: False)]:cache:" {--cache,--no-cache}"[clear directory with package caches (default\: False)]"
{--chroot,--no-chroot}"[clear build chroot (default\: False)]:chroot:" {--chroot,--no-chroot}"[clear build chroot (default\: False)]"
{--manual,--no-manual}"[clear manually added packages queue (default\: False)]:manual:" {--manual,--no-manual}"[clear manually added packages queue (default\: False)]"
{--packages,--no-packages}"[clear directory with built packages (default\: False)]:packages:" {--packages,--no-packages}"[clear directory with built packages (default\: False)]"
{--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]:pacman:" {--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]"
) )
# guard to ensure default positional specs are added only once per session # guard to ensure default positional specs are added only once per session
@@ -527,8 +532,8 @@ _shtab_ahriman_repo_clean_defaults_added=0
_shtab_ahriman_repo_config_options=( _shtab_ahriman_repo_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]:info:" {--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]"
{--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]:secure:" {--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]"
":filter settings by section (default\: None):" ":filter settings by section (default\: None):"
":filter settings by key (default\: None):" ":filter settings by key (default\: None):"
) )
@@ -561,17 +566,17 @@ _shtab_ahriman_repo_create_mirrorlist_defaults_added=0
_shtab_ahriman_repo_daemon_options=( _shtab_ahriman_repo_daemon_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{-i,--interval}"[interval between runs in seconds (default\: 43200)]:interval:" {-i,--interval}"[interval between runs in seconds (default\: 43200)]:interval:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]:aur:" {--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
"--dry-run[just perform check for updates, same as check command (default\: False)]" "--dry-run[just perform check for updates, same as check command (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]:local:" {--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]"
{--manual,--no-manual}"[include or exclude manual updates (default\: True)]:manual:" {--manual,--no-manual}"[include or exclude manual updates (default\: True)]"
{--partitions,--no-partitions}"[instead of updating whole repository, split updates into chunks (default\: True)]:partitions:" {--partitions,--no-partitions}"[instead of updating whole repository, split updates into chunks (default\: True)]"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
) )
@@ -582,10 +587,10 @@ _shtab_ahriman_repo_init_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:" "--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:"
"--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:" "--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:"
{--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]:generate_salt:" {--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]:makeflags_jobs:" {--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]"
"--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:" "--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]:multilib:" {--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]"
"--packager[packager name and email]:packager:" "--packager[packager name and email]:packager:"
"--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:" "--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:"
"--sign-key[sign key id (default\: None)]:sign_key:" "--sign-key[sign key id (default\: None)]:sign_key:"
@@ -602,7 +607,7 @@ _shtab_ahriman_repo_rebuild_options=(
"*--depends-on[only rebuild packages that depend on specified packages (default\: None)]:depends_on:" "*--depends-on[only rebuild packages that depend on specified packages (default\: None)]:depends_on:"
"--dry-run[just perform check for packages without rebuild process itself (default\: False)]" "--dry-run[just perform check for packages without rebuild process itself (default\: False)]"
"--from-database[read packages from database instead of filesystem. This feature in particular is required in case if you would like to restore repository from another repository instance. Note, however, that in order to restore packages you need to have original ahriman instance run with web service and have run repo-update at least once. (default\: False)]" "--from-database[read packages from database instead of filesystem. This feature in particular is required in case if you would like to restore repository from another repository instance. Note, however, that in order to restore packages you need to have original ahriman instance run with web service and have run repo-update at least once. (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{-s,--status}"[filter packages by status. Requires --from-database to be set (default\: None)]:status:(unknown pending building failed success)" {-s,--status}"[filter packages by status. Requires --from-database to be set (default\: None)]:status:(unknown pending building failed success)"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
@@ -639,10 +644,10 @@ _shtab_ahriman_repo_setup_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:" "--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:"
"--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:" "--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:"
{--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]:generate_salt:" {--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]:makeflags_jobs:" {--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]"
"--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:" "--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]:multilib:" {--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]"
"--packager[packager name and email]:packager:" "--packager[packager name and email]:packager:"
"--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:" "--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:"
"--sign-key[sign key id (default\: None)]:sign_key:" "--sign-key[sign key id (default\: None)]:sign_key:"
@@ -709,17 +714,17 @@ _shtab_ahriman_repo_triggers_defaults_added=0
_shtab_ahriman_repo_update_options=( _shtab_ahriman_repo_update_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]:aur:" {--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
"--dry-run[just perform check for updates, same as check command (default\: False)]" "--dry-run[just perform check for updates, same as check command (default\: False)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]:local:" {--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]"
{--manual,--no-manual}"[include or exclude manual updates (default\: True)]:manual:" {--manual,--no-manual}"[include or exclude manual updates (default\: True)]"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
"(*)::filter check by package base (default\: None):" "(*)::filter check by package base (default\: None):"
) )
@@ -745,7 +750,7 @@ _shtab_ahriman_run_defaults_added=0
_shtab_ahriman_search_options=( _shtab_ahriman_search_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--info,--no-info}"[show additional package information (default\: False)]:info:" {--info,--no-info}"[show additional package information (default\: False)]"
"--sort-by[sort field by this field. In case if two packages have the same value of the specified field, they will be always sorted by name (default\: name)]:sort_by:(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)" "--sort-by[sort field by this field. In case if two packages have the same value of the specified field, they will be always sorted by name (default\: name)]:sort_by:(description first_submitted id last_modified maintainer name num_votes out_of_date package_base package_base_id popularity repository submitter url url_path version)"
"(*):search terms, can be specified multiple times, the result will match all terms:" "(*):search terms, can be specified multiple times, the result will match all terms:"
) )
@@ -755,11 +760,11 @@ _shtab_ahriman_search_defaults_added=0
_shtab_ahriman_service_clean_options=( _shtab_ahriman_service_clean_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--cache,--no-cache}"[clear directory with package caches (default\: False)]:cache:" {--cache,--no-cache}"[clear directory with package caches (default\: False)]"
{--chroot,--no-chroot}"[clear build chroot (default\: False)]:chroot:" {--chroot,--no-chroot}"[clear build chroot (default\: False)]"
{--manual,--no-manual}"[clear manually added packages queue (default\: False)]:manual:" {--manual,--no-manual}"[clear manually added packages queue (default\: False)]"
{--packages,--no-packages}"[clear directory with built packages (default\: False)]:packages:" {--packages,--no-packages}"[clear directory with built packages (default\: False)]"
{--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]:pacman:" {--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: False)]"
) )
# guard to ensure default positional specs are added only once per session # guard to ensure default positional specs are added only once per session
@@ -767,8 +772,8 @@ _shtab_ahriman_service_clean_defaults_added=0
_shtab_ahriman_service_config_options=( _shtab_ahriman_service_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]:info:" {--info,--no-info}"[show additional information, e.g. configuration files (default\: True)]"
{--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]:secure:" {--secure,--no-secure}"[hide passwords and secrets from output (default\: True)]"
":filter settings by section (default\: None):" ":filter settings by section (default\: None):"
":filter settings by key (default\: None):" ":filter settings by key (default\: None):"
) )
@@ -795,7 +800,7 @@ _shtab_ahriman_service_key_import_defaults_added=0
_shtab_ahriman_service_repositories_options=( _shtab_ahriman_service_repositories_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--id-only,--no-id-only}"[show machine readable identifier instead (default\: False)]:id_only:" {--id-only,--no-id-only}"[show machine readable identifier instead (default\: False)]"
) )
# guard to ensure default positional specs are added only once per session # guard to ensure default positional specs are added only once per session
@@ -813,10 +818,10 @@ _shtab_ahriman_service_setup_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:" "--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:"
"--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:" "--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:"
{--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]:generate_salt:" {--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]:makeflags_jobs:" {--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]"
"--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:" "--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]:multilib:" {--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]"
"--packager[packager name and email]:packager:" "--packager[packager name and email]:packager:"
"--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:" "--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:"
"--sign-key[sign key id (default\: None)]:sign_key:" "--sign-key[sign key id (default\: None)]:sign_key:"
@@ -848,10 +853,10 @@ _shtab_ahriman_setup_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:" "--build-as-user[force makepkg user to the specific one (default\: None)]:build_as_user:"
"--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:" "--from-configuration[path to default devtools pacman configuration (default\: \/usr\/share\/devtools\/pacman.conf.d\/extra.conf)]:from_configuration:"
{--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]:generate_salt:" {--generate-salt,--no-generate-salt}"[generate salt for user passwords (default\: False)]"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]:makeflags_jobs:" {--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: True)]"
"--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:" "--mirror[use the specified explicitly mirror instead of including mirrorlist (default\: None)]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]:multilib:" {--multilib,--no-multilib}"[add or do not multilib repository (default\: True)]"
"--packager[packager name and email]:packager:" "--packager[packager name and email]:packager:"
"--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:" "--server[server to be used for devtools. If none set, local files will be used (default\: None)]:server:"
"--sign-key[sign key id (default\: None)]:sign_key:" "--sign-key[sign key id (default\: None)]:sign_key:"
@@ -884,7 +889,7 @@ _shtab_ahriman_status_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
"--ahriman[get service status itself (default\: False)]" "--ahriman[get service status itself (default\: False)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--info,--no-info}"[show additional package information (default\: False)]:info:" {--info,--no-info}"[show additional package information (default\: False)]"
{-s,--status}"[filter packages by status (default\: None)]:status:(unknown pending building failed success)" {-s,--status}"[filter packages by status (default\: None)]:status:(unknown pending building failed success)"
"(*)::filter status by package base (default\: None):" "(*)::filter status by package base (default\: None):"
) )
@@ -910,17 +915,17 @@ _shtab_ahriman_sync_defaults_added=0
_shtab_ahriman_update_options=( _shtab_ahriman_update_options=(
"(- : *)"{-h,--help}"[show this help message and exit]" "(- : *)"{-h,--help}"[show this help message and exit]"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]:aur:" {--aur,--no-aur}"[enable or disable checking for AUR updates (default\: True)]"
{--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]:changes:" {--changes,--no-changes}"[calculate changes from the latest known commit if available. Only applicable in dry run mode (default\: True)]"
{--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]:check_files:" {--check-files,--no-check-files}"[enable or disable checking of broken dependencies (e.g. dynamically linked libraries or modules directories) (default\: True)]"
{--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]:dependencies:" {--dependencies,--no-dependencies}"[process missing package dependencies (default\: True)]"
"--dry-run[just perform check for updates, same as check command (default\: False)]" "--dry-run[just perform check for updates, same as check command (default\: False)]"
{-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]" {-e,--exit-code}"[return non-zero exit status if result is empty (default\: False)]"
{--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]:increment:" {--increment,--no-increment}"[increment package release (pkgrel) on duplicate (default\: True)]"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]:local:" {--local,--no-local}"[enable or disable checking of local packages for updates (default\: True)]"
{--manual,--no-manual}"[include or exclude manual updates (default\: True)]:manual:" {--manual,--no-manual}"[include or exclude manual updates (default\: True)]"
{-u,--username}"[build as user (default\: None)]:username:" {-u,--username}"[build as user (default\: None)]:username:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]:vcs:" {--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: True)]"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]" "*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date (default\: False)]"
"(*)::filter check by package base (default\: None):" "(*)::filter check by package base (default\: None):"
) )
@@ -981,7 +986,7 @@ _shtab_ahriman_web_reload_defaults_added=0
_shtab_ahriman() { _shtab_ahriman() {
local context state line curcontext="$curcontext" one_or_more='(*)' remainder='(-)*' default='*::: :->ahriman' local context state line curcontext="$curcontext" one_or_more='(*)' remainder='(-)*:' default='*::: :->ahriman'
# Add default positional/remainder specs only if none exist, and only once per session # Add default positional/remainder specs only if none exist, and only once per session
if (( ! _shtab_ahriman_defaults_added )); then if (( ! _shtab_ahriman_defaults_added )); then
+3
View File
@@ -12,6 +12,8 @@ dependencies = [
"inflection", "inflection",
"pyelftools", "pyelftools",
"requests", "requests",
"tree-sitter",
"tree-sitter-bash",
] ]
description = "ArcH linux ReposItory MANager, core package" description = "ArcH linux ReposItory MANager, core package"
dynamic = [ dynamic = [
@@ -57,6 +59,7 @@ packages = [
] ]
[tool.hatch.build.targets.wheel.shared-data] [tool.hatch.build.targets.wheel.shared-data]
"package/bin" = "bin"
"package/lib" = "lib" "package/lib" = "lib"
"package/share" = "share" "package/share" = "share"
+1 -1
View File
@@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
__version__ = "2.21.0" __version__ = "2.23.6"
+26
View File
@@ -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())
@@ -28,7 +28,6 @@ from ahriman import __version__
from ahriman.application.handlers.handler import Handler from ahriman.application.handlers.handler import Handler
from ahriman.application.help_formatter import _HelpFormatter from ahriman.application.help_formatter import _HelpFormatter
from ahriman.core.module_loader import implementations from ahriman.core.module_loader import implementations
from ahriman.core.utils import enum_values
from ahriman.models.log_handler import LogHandler from ahriman.models.log_handler import LogHandler
@@ -75,7 +74,7 @@ Start web service (requires additional configuration):
parser.add_argument("-l", "--lock", help="lock file", type=Path, default=Path("ahriman.pid")) parser.add_argument("-l", "--lock", help="lock file", type=Path, default=Path("ahriman.pid"))
parser.add_argument("--log-handler", help="explicit log handler specification. If none set, the handler will be " parser.add_argument("--log-handler", help="explicit log handler specification. If none set, the handler will be "
"guessed from environment", "guessed from environment",
type=LogHandler, choices=enum_values(LogHandler)) type=LogHandler, choices=tuple(LogHandler))
parser.add_argument("-q", "--quiet", help="force disable any logging", action="store_true") parser.add_argument("-q", "--quiet", help="force disable any logging", action="store_true")
parser.add_argument("--report", help="force enable or disable reporting to web service", parser.add_argument("--report", help="force enable or disable reporting to web service",
action=argparse.BooleanOptionalAction, default=True) action=argparse.BooleanOptionalAction, default=True)
@@ -22,7 +22,7 @@ from collections.abc import Callable, Iterable
from ahriman.application.application.application_packages import ApplicationPackages from ahriman.application.application.application_packages import ApplicationPackages
from ahriman.application.application.application_repository import ApplicationRepository from ahriman.application.application.application_repository import ApplicationRepository
from ahriman.core.formatters import UpdatePrinter 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.package import Package
from ahriman.models.result import Result from ahriman.models.result import Result
@@ -95,43 +95,39 @@ class Application(ApplicationPackages, ApplicationRepository):
""" """
self.repository.triggers.on_stop() 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: 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 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()} 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) def with_dependencies(self, plan: BuildPlan, *, process_dependencies: bool) -> BuildPlan:
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]:
""" """
add missing dependencies to list of packages. This will extract known packages, check dependencies of add missing dependencies to a build plan and record which packages require them
the supplied packages and add packages which are not presented in the list of known packages.
Args: 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 process_dependencies(bool): if set to ``False``, dependencies will not be processed
Returns: Returns:
list[Package]: updated packages list. Packager for dependencies will be copied from the original package BuildPlan: selected packages and their dependencies
Examples: Examples:
In the most cases, in order to avoid build failure, it is required to add missing packages, which can be In the most cases, in order to avoid build failure, it is required to add missing packages, which can be
done by calling:: done by calling::
>>> application = ... >>> application = ...
>>> packages = application.with_dependencies(packages, process_dependencies=True) >>> plan = application.with_dependencies(plan, process_dependencies=True)
>>> application.print_updates(packages, log_fn=print) >>> application.update(plan)
""" """
if not process_dependencies or not packages: if not process_dependencies or not plan:
return packages return plan
def missing_dependencies(sources: Iterable[Package]) -> dict[str, str | None]: def missing_dependencies(sources: Iterable[Package]) -> dict[str, str | None]:
# append list of known packages with packages which are in current sources # append list of known packages with packages which are in current sources
@@ -157,20 +153,30 @@ class Application(ApplicationPackages, ApplicationRepository):
leaf = Package.from_build(source_dir, self.repository.repository_id.architecture, packager) leaf = Package.from_build(source_dir, self.repository.repository_id.architecture, packager)
else: else:
leaf = Package.from_aur(package_name, packager, include_provides=True) 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 # register package in the database
self.reporter.set_unknown(leaf) self.reporter.set_unknown(leaf)
return portion return portion
known_packages = self._known_packages() known_packages = self._known_packages()
with_dependencies: dict[str, Package] = {} for package in plan:
for package in packages:
with self.in_package_context(package.base, package.version): # use the same context for the logger with self.in_package_context(package.base, package.version): # use the same context for the logger
try: try:
with_dependencies |= new_packages(package) packages = new_packages(package)
except Exception: except Exception:
self.logger.exception("could not process dependencies of %s, skip the package", package.base) self.logger.exception("could not process dependencies of %s, skip the package", package.base)
plan.remove(package.base)
self.reporter.set_failed(package.base)
continue
return list(with_dependencies.values()) # update existing package
plan.add(packages.pop(package.base))
# append dependencies
plan.update(packages.values(), BuildPlanReason.REQUIRED_BY, package.base)
return plan
@@ -38,14 +38,14 @@ class ApplicationProperties(LazyLogging):
""" """
def __init__(self, repository_id: RepositoryId, configuration: Configuration, *, report: bool, def __init__(self, repository_id: RepositoryId, configuration: Configuration, *, report: bool,
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) -> None: refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.DISABLED) -> None:
""" """
Args: Args:
repository_id(RepositoryId): repository unique identifier repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance configuration(Configuration): configuration instance
report(bool): force enable or disable reporting report(bool): force enable or disable reporting
refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level
(Default value = PacmanSynchronization.Disabled) (Default value = PacmanSynchronization.DISABLED)
""" """
self.configuration = configuration self.configuration = configuration
self.repository_id = repository_id self.repository_id = repository_id
@@ -23,6 +23,7 @@ from ahriman.application.application.application_properties import ApplicationPr
from ahriman.application.application.workers import Updater from ahriman.application.application.workers import Updater
from ahriman.core.build_tools.sources import Sources from ahriman.core.build_tools.sources import Sources
from ahriman.core.exceptions import UnknownPackageError from ahriman.core.exceptions import UnknownPackageError
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.packagers import Packagers from ahriman.models.packagers import Packagers
from ahriman.models.result import Result from ahriman.models.result import Result
@@ -158,6 +159,8 @@ class ApplicationRepository(ApplicationProperties):
# process already built packages if any # process already built packages if any
if built_packages := self.repository.packages_built(): # speedup a bit if built_packages := self.repository.packages_built(): # speedup a bit
build_result = self.repository.process_update(built_packages, packagers) build_result = self.repository.process_update(built_packages, packagers)
for package in build_result.success:
self.database.build_queue_clear(package.base)
self.on_result(build_result) self.on_result(build_result)
result.merge(build_result) result.merge(build_result)
@@ -172,13 +175,15 @@ class ApplicationRepository(ApplicationProperties):
for num, partition in enumerate(partitions): for num, partition in enumerate(partitions):
self.logger.info("processing chunk #%i %s", num, [package.base for package in partition]) self.logger.info("processing chunk #%i %s", num, [package.base for package in partition])
build_result = builder.update(partition, packagers, bump_pkgrel=bump_pkgrel) build_result = builder.update(partition, packagers, bump_pkgrel=bump_pkgrel)
for package in partition:
self.database.build_queue_clear(package.base)
self.on_result(build_result) self.on_result(build_result)
result.merge(build_result) result.merge(build_result)
return result return result
def updates(self, filter_packages: Iterable[str], *, 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 get list of packages to run update process
@@ -189,25 +194,24 @@ class ApplicationRepository(ApplicationProperties):
manual(bool): include or exclude manual updates manual(bool): include or exclude manual updates
vcs(bool): enable or disable checking of VCS packages vcs(bool): enable or disable checking of VCS packages
check_files(bool): check for broken dependencies check_files(bool): check for broken dependencies
Returns: 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 # always add already built packages, because they will be always added
updates.update({ plan.update(self.repository.load_archives(self.repository.packages_built()), BuildPlanReason.PRE_BUILT)
package.base: package
for package in self.repository.load_archives(self.repository.packages_built())
})
if aur:
updates.update({package.base: package for package in self.repository.updates_aur(filter_packages, vcs=vcs)})
if local:
updates.update({package.base: package for package in self.repository.updates_local(vcs=vcs)})
if manual: if manual:
updates.update({package.base: package for package in self.repository.updates_manual()}) plan.update(self.repository.updates_manual(), BuildPlanReason.MANUAL_REQUEST)
if aur:
plan.update(self.repository.updates_aur(filter_packages, vcs=vcs), BuildPlanReason.REGULAR_UPDATE)
if local:
plan.update(self.repository.updates_local(vcs=vcs), BuildPlanReason.LOCAL_SOURCE_UPDATE)
if check_files: 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.BROKEN_IMPLICIT_DEPENDENCY,
)
return [package for _, package in sorted(updates.items())] return plan
@@ -23,7 +23,7 @@ from ahriman.application.application import Application
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.application.handlers.update import Update from ahriman.application.handlers.update import Update
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.utils import enum_values, extract_user from ahriman.core.utils import extract_user
from ahriman.models.package_source import PackageSource from ahriman.models.package_source import PackageSource
from ahriman.models.pkgbuild_patch import PkgbuildPatch from ahriman.models.pkgbuild_patch import PkgbuildPatch
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -85,7 +85,7 @@ class Add(Handler):
action=argparse.BooleanOptionalAction, default=True) action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-n", "--now", help="run update function after", action="store_true") parser.add_argument("-n", "--now", help="run update function after", action="store_true")
parser.add_argument("-s", "--source", help="explicitly specify the package source for this command", parser.add_argument("-s", "--source", help="explicitly specify the package source for this command",
type=PackageSource, choices=enum_values(PackageSource), default=PackageSource.Auto) type=PackageSource, choices=tuple(PackageSource), default=PackageSource.AUTO)
parser.add_argument("-u", "--username", help="build as user", default=extract_user()) parser.add_argument("-u", "--username", help="build as user", default=extract_user())
parser.add_argument("-v", "--variable", help="apply specified makepkg variables to the next build", parser.add_argument("-v", "--variable", help="apply specified makepkg variables to the next build",
action="append") action="append")
@@ -50,10 +50,10 @@ class Archives(Handler):
application = Application(repository_id, configuration, report=True) application = Application(repository_id, configuration, report=True)
match args.action: match args.action:
case Action.List: case Action.LIST:
archives = application.repository.package_archives(args.package) archives = application.repository.package_archives(args.package)
for package in archives: for package in archives:
PackagePrinter(package, BuildStatus(BuildStatusEnum.Success))(verbose=args.info) PackagePrinter(package, BuildStatus(BuildStatusEnum.SUCCESS))(verbose=args.info)
Archives.check_status(args.exit_code, bool(archives)) Archives.check_status(args.exit_code, bool(archives))
@@ -75,7 +75,7 @@ class Archives(Handler):
action="store_true") action="store_true")
parser.add_argument("--info", help="show additional package information", parser.add_argument("--info", help="show additional package information",
action=argparse.BooleanOptionalAction, default=False) action=argparse.BooleanOptionalAction, default=False)
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
arguments = [_set_package_archives_parser] arguments = [_set_package_archives_parser]
@@ -50,11 +50,11 @@ class Change(Handler):
client = Application(repository_id, configuration, report=True).reporter client = Application(repository_id, configuration, report=True).reporter
match args.action: match args.action:
case Action.List: case Action.LIST:
changes = client.package_changes_get(args.package) changes = client.package_changes_get(args.package)
ChangesPrinter(changes)(verbose=True, separator="") ChangesPrinter(changes)(verbose=True, separator="")
Change.check_status(args.exit_code, changes.changes is not None) Change.check_status(args.exit_code, changes.changes is not None)
case Action.Remove: case Action.REMOVE:
client.package_changes_update(args.package, Changes()) client.package_changes_update(args.package, Changes())
@staticmethod @staticmethod
@@ -75,7 +75,7 @@ class Change(Handler):
parser.add_argument("package", help="package base") parser.add_argument("package", help="package base")
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
action="store_true") action="store_true")
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -92,7 +92,7 @@ class Change(Handler):
parser = root.add_parser("package-changes-remove", help="remove package changes", parser = root.add_parser("package-changes-remove", help="remove package changes",
description="remove the package changes stored remotely") description="remove the package changes stored remotely")
parser.add_argument("package", help="package base") parser.add_argument("package", help="package base")
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.REMOVE, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
arguments = [_set_package_changes_parser, _set_package_changes_remove_parser] arguments = [_set_package_changes_parser, _set_package_changes_remove_parser]
@@ -103,7 +103,7 @@ class Copy(Handler):
for source in package.packages.values() for source in package.packages.values()
if source.filename is not None if source.filename is not None
] ]
application.add(source_paths, PackageSource.Archive) application.add(source_paths, PackageSource.ARCHIVE)
# copy metadata # copy metadata
application.reporter.package_changes_update( application.reporter.package_changes_update(
@@ -112,6 +112,6 @@ class Copy(Handler):
application.reporter.package_dependencies_update( application.reporter.package_dependencies_update(
package.base, source_application.reporter.package_dependencies_get(package.base) package.base, source_application.reporter.package_dependencies_get(package.base)
) )
application.reporter.package_update(package, BuildStatusEnum.Pending) application.reporter.package_update(package, BuildStatusEnum.PENDING)
arguments = [_set_package_copy_parser] arguments = [_set_package_copy_parser]
@@ -46,10 +46,10 @@ class Hold(Handler):
client = Application(repository_id, configuration, report=True).reporter client = Application(repository_id, configuration, report=True).reporter
match args.action: match args.action:
case Action.Remove: case Action.REMOVE:
for package in args.package: for package in args.package:
client.package_hold_update(package, enabled=False) client.package_hold_update(package, enabled=False)
case Action.Update: case Action.UPDATE:
for package in args.package: for package in args.package:
client.package_hold_update(package, enabled=True) client.package_hold_update(package, enabled=True)
@@ -67,7 +67,7 @@ class Hold(Handler):
parser = root.add_parser("package-hold", help="hold package", parser = root.add_parser("package-hold", help="hold package",
description="hold package from automatic updates") description="hold package from automatic updates")
parser.add_argument("package", help="package base", nargs="+") parser.add_argument("package", help="package base", nargs="+")
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.UPDATE, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -84,7 +84,7 @@ class Hold(Handler):
parser = root.add_parser("package-unhold", help="unhold package", parser = root.add_parser("package-unhold", help="unhold package",
description="remove package hold, allowing automatic updates") description="remove package hold, allowing automatic updates")
parser.add_argument("package", help="package base", nargs="+") parser.add_argument("package", help="package base", nargs="+")
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.REMOVE, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
arguments = [ arguments = [
@@ -56,15 +56,15 @@ class Patch(Handler):
application.on_start() application.on_start()
match args.action: match args.action:
case Action.Update if args.variable is not None: case Action.UPDATE if args.variable is not None:
patch = Patch.patch_create_from_function(args.variable, args.patch) patch = Patch.patch_create_from_function(args.variable, args.patch)
Patch.patch_set_create(application, args.package, patch) Patch.patch_set_create(application, args.package, patch)
case Action.Update: case Action.UPDATE:
package_base, patch = Patch.patch_create_from_diff(args.package, repository_id.architecture, args.track) package_base, patch = Patch.patch_create_from_diff(args.package, repository_id.architecture, args.track)
Patch.patch_set_create(application, package_base, patch) Patch.patch_set_create(application, package_base, patch)
case Action.List: case Action.LIST:
Patch.patch_set_list(application, args.package, args.variable, args.exit_code) Patch.patch_set_list(application, args.package, args.variable, args.exit_code)
case Action.Remove: case Action.REMOVE:
Patch.patch_set_remove(application, args.package, args.variable) Patch.patch_set_remove(application, args.package, args.variable)
@staticmethod @staticmethod
@@ -89,7 +89,7 @@ class Patch(Handler):
"it must end with ()") "it must end with ()")
parser.add_argument("patch", help="path to file which contains function or variable value. If not set, " parser.add_argument("patch", help="path to file which contains function or variable value. If not set, "
"the value will be read from stdin", type=Path, nargs="?") "the value will be read from stdin", type=Path, nargs="?")
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False, parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, report=False,
repository="") repository="")
return parser return parser
@@ -111,7 +111,7 @@ class Patch(Handler):
action="store_true") action="store_true")
parser.add_argument("-v", "--variable", help="if set, show only patches for specified PKGBUILD variables", parser.add_argument("-v", "--variable", help="if set, show only patches for specified PKGBUILD variables",
action="append") action="append")
parser.set_defaults(action=Action.List, architecture="", lock=None, report=False, repository="", unsafe=True) parser.set_defaults(action=Action.LIST, architecture="", lock=None, report=False, repository="", unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -132,7 +132,7 @@ class Patch(Handler):
"to remove only specified PKGBUILD variables. In case if not set, " "to remove only specified PKGBUILD variables. In case if not set, "
"it will remove all patches related to the package", "it will remove all patches related to the package",
action="append") action="append")
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, report=False, parser.set_defaults(action=Action.REMOVE, architecture="", exit_code=False, lock=None, report=False,
repository="") repository="")
return parser return parser
@@ -157,7 +157,7 @@ class Patch(Handler):
parser.add_argument("package", help="path to directory with changed files for patch addition/update", type=Path) parser.add_argument("package", help="path to directory with changed files for patch addition/update", type=Path)
parser.add_argument("-t", "--track", help="files which has to be tracked", action="append", parser.add_argument("-t", "--track", help="files which has to be tracked", action="append",
default=["*.diff", "*.patch"]) default=["*.diff", "*.patch"])
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False, parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, report=False,
repository="", variable=None) repository="", variable=None)
return parser return parser
@@ -51,11 +51,11 @@ class Pkgbuild(Handler):
client = Application(repository_id, configuration, report=True).reporter client = Application(repository_id, configuration, report=True).reporter
match args.action: match args.action:
case Action.List: case Action.LIST:
changes = client.package_changes_get(args.package) changes = client.package_changes_get(args.package)
PkgbuildPrinter(changes)(verbose=True, separator="") PkgbuildPrinter(changes)(verbose=True, separator="")
Pkgbuild.check_status(args.exit_code, changes.pkgbuild is not None) Pkgbuild.check_status(args.exit_code, changes.pkgbuild is not None)
case Action.Remove: case Action.REMOVE:
changes = client.package_changes_get(args.package) changes = client.package_changes_get(args.package)
client.package_changes_update(args.package, replace(changes, pkgbuild=None)) client.package_changes_update(args.package, replace(changes, pkgbuild=None))
@@ -77,7 +77,7 @@ class Pkgbuild(Handler):
parser.add_argument("package", help="package base") parser.add_argument("package", help="package base")
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
action="store_true") action="store_true")
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -94,7 +94,7 @@ class Pkgbuild(Handler):
parser = root.add_parser("package-pkgbuild-remove", help="remove package pkgbuild", parser = root.add_parser("package-pkgbuild-remove", help="remove package pkgbuild",
description="remove the package PKGBUILD stored remotely") description="remove the package PKGBUILD stored remotely")
parser.add_argument("package", help="package base") parser.add_argument("package", help="package base")
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.REMOVE, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
arguments = [_set_package_pkgbuild_parser, _set_package_pkgbuild_remove_parser] arguments = [_set_package_pkgbuild_parser, _set_package_pkgbuild_remove_parser]
@@ -21,8 +21,10 @@ import argparse
from ahriman.application.application import Application from ahriman.application.application import Application
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.application.handlers.update import Update
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.utils import enum_values, extract_user 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.build_status import BuildStatusEnum
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.packagers import Packagers 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 = Rebuild.extract_packages(application, args.status, from_database=args.from_database)
packages = application.repository.packages_depend_on(packages, args.depends_on) 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: if args.dry_run:
application.print_updates(packages, log_fn=print) Rebuild.check_status(args.exit_code, plan)
return 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) Rebuild.check_status(args.exit_code, not result.is_empty)
@staticmethod @staticmethod
@@ -88,7 +92,7 @@ class Rebuild(Handler):
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
action="store_true") action="store_true")
parser.add_argument("-s", "--status", help="filter packages by status. Requires --from-database to be set", parser.add_argument("-s", "--status", help="filter packages by status. Requires --from-database to be set",
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum)) type=BuildStatusEnum, choices=tuple(BuildStatusEnum))
parser.add_argument("-u", "--username", help="build as user", default=extract_user()) parser.add_argument("-u", "--username", help="build as user", default=extract_user())
return parser return parser
@@ -82,7 +82,7 @@ class Rollback(Handler):
parser.add_argument("-u", "--username", help="build as user", default=extract_user()) parser.add_argument("-u", "--username", help="build as user", default=extract_user())
parser.set_defaults(aur=False, changes=False, check_files=False, dependencies=False, dry_run=False, parser.set_defaults(aur=False, changes=False, check_files=False, dependencies=False, dry_run=False,
exit_code=True, increment=False, now=True, local=False, manual=False, refresh=False, exit_code=True, increment=False, now=True, local=False, manual=False, refresh=False,
source=PackageSource.Archive, variable=None, vcs=False) source=PackageSource.ARCHIVE, variable=None, vcs=False)
return parser return parser
@staticmethod @staticmethod
@@ -23,6 +23,7 @@ from ahriman import __version__
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.formatters import UpdatePrinter from ahriman.core.formatters import UpdatePrinter
from ahriman.models.build_plan import BuildPlan, BuildPlanReason
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -56,7 +57,8 @@ class ServiceUpdates(Handler):
if same_version: if same_version:
return return
UpdatePrinter(remote, local_version)(verbose=True, separator=" -> ") plan = BuildPlan().update([remote], BuildPlanReason.REGULAR_UPDATE)
UpdatePrinter(plan, {remote.base: local_version})(verbose=True)
ServiceUpdates.check_status(args.exit_code, same_version) ServiceUpdates.check_status(args.exit_code, same_version)
@staticmethod @staticmethod
@@ -18,19 +18,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import argparse import argparse
import multiprocessing
import os
from pathlib import Path from pathlib import Path
from pwd import getpwuid
from typing import ClassVar from typing import ClassVar
from urllib.parse import quote_plus as url_encode from urllib.parse import quote_plus as url_encode
from ahriman.application.application import Application from ahriman.application.application import Application
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import MissingArchitectureError from ahriman.core.exceptions import InitializeError, MissingArchitectureError
from ahriman.core.utils import enum_values
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
from ahriman.models.repository_paths import RepositoryPaths
from ahriman.models.sign_settings import SignSettings from ahriman.models.sign_settings import SignSettings
from ahriman.models.user import User from ahriman.models.user import User
@@ -40,16 +39,12 @@ class Setup(Handler):
setup handler setup handler
Attributes: Attributes:
ARCHBUILD_COMMAND_PATH(Path): (class attribute) default devtools command
MIRRORLIST_PATH(Path): (class attribute) path to pacman default mirrorlist (used by multilib repository) MIRRORLIST_PATH(Path): (class attribute) path to pacman default mirrorlist (used by multilib repository)
SUDOERS_DIR_PATH(Path): (class attribute) path to sudoers.d includes directory
""" """
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
ARCHBUILD_COMMAND_PATH: ClassVar[Path] = Path("/") / "usr" / "bin" / "archbuild"
MIRRORLIST_PATH: ClassVar[Path] = Path("/") / "etc" / "pacman.d" / "mirrorlist" MIRRORLIST_PATH: ClassVar[Path] = Path("/") / "etc" / "pacman.d" / "mirrorlist"
SUDOERS_DIR_PATH: ClassVar[Path] = Path("/") / "etc" / "sudoers.d"
@classmethod @classmethod
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *, def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
@@ -67,21 +62,20 @@ class Setup(Handler):
if args.architecture is None or args.repository is None: if args.architecture is None or args.repository is None:
raise MissingArchitectureError(args.command) raise MissingArchitectureError(args.command)
Setup.configuration_create_ahriman(args, repository_id, configuration) target_directory = Setup.configuration_create_directory(configuration)
Setup.configuration_create_ahriman(args, repository_id, configuration, target_directory)
configuration.reload() configuration.reload()
application = Application(repository_id, configuration, report=report) application = Application(repository_id, configuration, report=report)
paths = application.repository.paths
# basically we create configuration here as root, but it is ok, because those files are only used for reading repository_server = f"file://{paths.repository}" if args.server is None else args.server
Setup.configuration_create_makepkg(args.packager, args.makeflags_jobs, application.repository.paths) target_directory = paths.ensure_exists(configuration.getpath("build", "devtools_configs"))
Setup.executable_create(application.repository.paths, repository_id) Setup.configuration_create_devtools(repository_id, args.from_configuration, target_directory, args.mirror,
repository_server = f"file://{application.repository.paths.repository}" if args.server is None else args.server args.multilib, repository_server)
Setup.configuration_create_devtools(
repository_id, args.from_configuration, args.mirror, args.multilib, repository_server)
Setup.configuration_create_sudo(application.repository.paths, repository_id)
# finish initialization # finish initialization
with application.repository.paths.preserve_owner(): with paths.preserve_owner():
application.repository.repo.init() application.repository.repo.init()
# lazy database sync # lazy database sync
application.repository.pacman.handle # pylint: disable=pointless-statement application.repository.pacman.handle # pylint: disable=pointless-statement
@@ -99,7 +93,7 @@ class Setup(Handler):
""" """
parser = root.add_parser("service-setup", aliases=["init", "repo-init", "repo-setup", "setup"], parser = root.add_parser("service-setup", aliases=["init", "repo-init", "repo-setup", "setup"],
help="initial service configuration", help="initial service configuration",
description="create initial service configuration, requires root", description="create initial service configuration as the repository owner",
epilog="Create minimal configuration for the service according to provided options.") epilog="Create minimal configuration for the service according to provided options.")
parser.add_argument("--build-as-user", help="force makepkg user to the specific one") parser.add_argument("--build-as-user", help="force makepkg user to the specific one")
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration", parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
@@ -117,30 +111,16 @@ class Setup(Handler):
parser.add_argument("--server", help="server to be used for devtools. If none set, local files will be used") parser.add_argument("--server", help="server to be used for devtools. If none set, local files will be used")
parser.add_argument("--sign-key", help="sign key id") parser.add_argument("--sign-key", help="sign key id")
parser.add_argument("--sign-target", help="sign options", action="append", parser.add_argument("--sign-target", help="sign options", action="append",
type=SignSettings.from_option, choices=enum_values(SignSettings)) type=SignSettings.from_option, choices=tuple(SignSettings))
parser.add_argument("--web-port", help="port of the web service", type=int) parser.add_argument("--web-port", help="port of the web service", type=int)
parser.add_argument("--web-unix-socket", help="path to unix socket used for interprocess communications", parser.add_argument("--web-unix-socket", help="path to unix socket used for interprocess communications",
type=Path) type=Path)
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(lock=None, quiet=True, report=False)
return parser return parser
@staticmethod
def build_command(root: Path, repository_id: RepositoryId) -> Path:
"""
generate build command name
Args:
root(Path): root directory for the build command (must be root of the repository)
repository_id(RepositoryId): repository unique identifier
Returns:
Path: valid devtools command name
"""
return root / f"{repository_id.name}-{repository_id.architecture}-build"
@staticmethod @staticmethod
def configuration_create_ahriman(args: argparse.Namespace, repository_id: RepositoryId, def configuration_create_ahriman(args: argparse.Namespace, repository_id: RepositoryId,
root: Configuration) -> None: root: Configuration, target_directory: Path) -> None:
""" """
create service specific configuration create service specific configuration
@@ -148,13 +128,16 @@ class Setup(Handler):
args(argparse.Namespace): command line args args(argparse.Namespace): command line args
repository_id(RepositoryId): repository unique identifier repository_id(RepositoryId): repository unique identifier
root(Configuration): root configuration instance root(Configuration): root configuration instance
target_directory(Path): path to directory where configuration files will be written
""" """
configuration = Configuration() configuration = Configuration()
section = Configuration.section_name("build", repository_id.name, repository_id.architecture)
build_command = Setup.build_command(root.repository_paths.root, repository_id)
configuration.set_option(section, "build_command", str(build_command))
configuration.set_option("repository", "name", repository_id.name) # backward compatibility for docker configuration.set_option("repository", "name", repository_id.name) # backward compatibility for docker
section = Configuration.section_name("build", repository_id.name, repository_id.architecture)
configuration.set_option(section, "packager", args.packager)
if args.makeflags_jobs:
configuration.set_option(section, "make_flags", f"-j{multiprocessing.cpu_count()}")
if args.build_as_user is not None: if args.build_as_user is not None:
configuration.set_option(section, "makechrootpkg_flags", f"-U {args.build_as_user}") configuration.set_option(section, "makechrootpkg_flags", f"-U {args.build_as_user}")
@@ -183,14 +166,13 @@ class Setup(Handler):
if args.generate_salt: if args.generate_salt:
configuration.set_option("auth", "salt", User.generate_password(20)) configuration.set_option("auth", "salt", User.generate_password(20))
(root.include / "00-setup-overrides.ini").unlink(missing_ok=True) # remove old-style configuration target = target_directory / f"00-setup-overrides-{repository_id.id}.ini"
target = root.include / f"00-setup-overrides-{repository_id.id}.ini"
with target.open("w", encoding="utf8") as ahriman_configuration: with target.open("w", encoding="utf8") as ahriman_configuration:
configuration.write(ahriman_configuration) configuration.write(ahriman_configuration)
@staticmethod @staticmethod
def configuration_create_devtools(repository_id: RepositoryId, source: Path, mirror: str | None, def configuration_create_devtools(repository_id: RepositoryId, source: Path, target_directory: Path,
multilib: bool, repository_server: str) -> None: mirror: str | None, multilib: bool, repository_server: str) -> None:
""" """
create configuration for devtools based on ``source`` configuration create configuration for devtools based on ``source`` configuration
@@ -200,6 +182,7 @@ class Setup(Handler):
Args: Args:
repository_id(RepositoryId): repository unique identifier repository_id(RepositoryId): repository unique identifier
source(Path): path to source configuration file source(Path): path to source configuration file
target_directory(Path): path to directory where configuration files will be written
mirror(str | None): link to package server mirror mirror(str | None): link to package server mirror
multilib(bool): add or do not multilib repository to the configuration multilib(bool): add or do not multilib repository to the configuration
repository_server(str): url of the repository repository_server(str): url of the repository
@@ -234,54 +217,32 @@ class Setup(Handler):
configuration.set_option(repository_id.name, "SigLevel", "Never") # we don't care configuration.set_option(repository_id.name, "SigLevel", "Never") # we don't care
configuration.set_option(repository_id.name, "Server", repository_server) configuration.set_option(repository_id.name, "Server", repository_server)
target = source.parent / f"{repository_id.name}-{repository_id.architecture}.conf" target = target_directory / f"{repository_id.name}-{repository_id.architecture}.conf"
with target.open("w", encoding="utf8") as devtools_configuration: with target.open("w", encoding="utf8") as devtools_configuration:
configuration.write(devtools_configuration) configuration.write(devtools_configuration)
@staticmethod @staticmethod
def configuration_create_makepkg(packager: str, makeflags_jobs: bool, paths: RepositoryPaths) -> None: def configuration_create_directory(root: Configuration) -> Path:
""" """
create configuration for makepkg create directory for includes
Args: Args:
packager(str): packager identifier (e.g. name, email) root(Configuration): root configuration instance
makeflags_jobs(bool): set MAKEFLAGS variable to number of cores
paths(RepositoryPaths): repository paths instance Returns:
Path: path to first writable directory
Raises:
InitializeError: if no writable directories have been found
""" """
for include_path in root.include:
try:
directory = root.repository_paths.ensure_exists(include_path)
if os.access(directory, os.W_OK | os.X_OK):
return directory
except OSError:
continue
content = f"PACKAGER='{packager}'\n" raise InitializeError("No writable include directory found")
if makeflags_jobs:
content += "MAKEFLAGS=\"-j$(nproc)\"\n"
uid, _ = paths.root_owner
home_dir = Path(getpwuid(uid).pw_dir)
(home_dir / ".makepkg.conf").write_text(content, encoding="utf8")
@staticmethod
def configuration_create_sudo(paths: RepositoryPaths, repository_id: RepositoryId) -> None:
"""
create configuration to run build command with sudo without password
Args:
paths(RepositoryPaths): repository paths instance
repository_id(RepositoryId): repository unique identifier
"""
command = Setup.build_command(paths.root, repository_id)
sudoers_file = Setup.build_command(Setup.SUDOERS_DIR_PATH, repository_id)
sudoers_file.write_text(f"ahriman ALL=(ALL) NOPASSWD:SETENV: {command} *\n", encoding="utf8")
sudoers_file.chmod(0o400) # security!
@staticmethod
def executable_create(paths: RepositoryPaths, repository_id: RepositoryId) -> None:
"""
create executable for the service
Args:
paths(RepositoryPaths): repository paths instance
repository_id(RepositoryId): repository unique identifier
"""
command = Setup.build_command(paths.root, repository_id)
command.unlink(missing_ok=True)
command.symlink_to(Setup.ARCHBUILD_COMMAND_PATH)
arguments = [_set_service_setup_parser] arguments = [_set_service_setup_parser]
@@ -28,7 +28,7 @@ from ahriman.application.application import Application
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.formatters import EventStatsPrinter, PackageStatsPrinter, RepositoryStatsPrinter from ahriman.core.formatters import EventStatsPrinter, PackageStatsPrinter, RepositoryStatsPrinter
from ahriman.core.utils import enum_values, pretty_datetime from ahriman.core.utils import pretty_datetime
from ahriman.models.event import Event, EventType from ahriman.models.event import Event, EventType
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -85,7 +85,7 @@ class Statistics(Handler):
parser.add_argument("package", help="fetch only events for the specified package", nargs="?") parser.add_argument("package", help="fetch only events for the specified package", nargs="?")
parser.add_argument("--chart", help="create updates chart and save it to the specified path", type=Path) parser.add_argument("--chart", help="create updates chart and save it to the specified path", type=Path)
parser.add_argument("-e", "--event", help="event type filter", parser.add_argument("-e", "--event", help="event type filter",
type=EventType, choices=enum_values(EventType), default=EventType.PackageUpdated) type=EventType, choices=tuple(EventType), default=EventType.PACKAGE_UPDATED)
parser.add_argument("--from-date", help="only fetch events which are newer than the date") parser.add_argument("--from-date", help="only fetch events which are newer than the date")
parser.add_argument("--limit", help="limit response by specified amount of events", type=int, default=-1) parser.add_argument("--limit", help="limit response by specified amount of events", type=int, default=-1)
parser.add_argument("--offset", help="skip specified amount of events", type=int, default=0) parser.add_argument("--offset", help="skip specified amount of events", type=int, default=0)
@@ -26,7 +26,6 @@ from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.formatters import PackagePrinter, StatusPrinter from ahriman.core.formatters import PackagePrinter, StatusPrinter
from ahriman.core.types import Comparable from ahriman.core.types import Comparable
from ahriman.core.utils import enum_values
from ahriman.models.build_status import BuildStatus, BuildStatusEnum from ahriman.models.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -93,7 +92,7 @@ class Status(Handler):
parser.add_argument("--info", help="show additional package information", parser.add_argument("--info", help="show additional package information",
action=argparse.BooleanOptionalAction, default=False) action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("-s", "--status", help="filter packages by status", parser.add_argument("-s", "--status", help="filter packages by status",
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum)) type=BuildStatusEnum, choices=tuple(BuildStatusEnum))
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@@ -22,7 +22,6 @@ import argparse
from ahriman.application.application import Application from ahriman.application.application import Application
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.utils import enum_values
from ahriman.models.action import Action from ahriman.models.action import Action
from ahriman.models.build_status import BuildStatusEnum from ahriman.models.build_status import BuildStatusEnum
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -50,14 +49,14 @@ class StatusUpdate(Handler):
client = Application(repository_id, configuration, report=True).reporter client = Application(repository_id, configuration, report=True).reporter
match args.action: match args.action:
case Action.Update if args.package: case Action.UPDATE if args.package:
# update packages statuses # update packages statuses
for package in args.package: for package in args.package:
client.package_status_update(package, args.status) client.package_status_update(package, args.status)
case Action.Update: case Action.UPDATE:
# update service status # update service status
client.status_update(args.status) client.status_update(args.status)
case Action.Remove: case Action.REMOVE:
for package in args.package: for package in args.package:
client.package_remove(package) client.package_remove(package)
@@ -77,7 +76,7 @@ class StatusUpdate(Handler):
epilog="Please note that this subcommand does not remove the package itself, it just " epilog="Please note that this subcommand does not remove the package itself, it just "
"clears the status page.") "clears the status page.")
parser.add_argument("package", help="remove specified packages from status page", nargs="+") parser.add_argument("package", help="remove specified packages from status page", nargs="+")
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.REMOVE, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -97,8 +96,8 @@ class StatusUpdate(Handler):
"If no packages supplied, service status will be updated", "If no packages supplied, service status will be updated",
nargs="*") nargs="*")
parser.add_argument("-s", "--status", help="new package build status", parser.add_argument("-s", "--status", help="new package build status",
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum), default=BuildStatusEnum.Success) type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.SUCCESS)
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.UPDATE, lock=None, quiet=True, report=False, unsafe=True)
return parser return parser
@staticmethod @staticmethod
@@ -115,8 +114,8 @@ class StatusUpdate(Handler):
parser = root.add_parser("repo-status-update", help="update repository status", parser = root.add_parser("repo-status-update", help="update repository status",
description="update repository status on the status page") description="update repository status on the status page")
parser.add_argument("-s", "--status", help="new status", parser.add_argument("-s", "--status", help="new status",
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum), default=BuildStatusEnum.Success) type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.SUCCESS)
parser.set_defaults(action=Action.Update, lock=None, package=[], quiet=True, report=False, unsafe=True) parser.set_defaults(action=Action.UPDATE, lock=None, package=[], quiet=True, report=False, unsafe=True)
return parser return parser
arguments = [ arguments = [
@@ -147,20 +147,19 @@ class Update(Handler):
application(Application): application instance application(Application): application instance
args(argparse.Namespace): command line args args(argparse.Namespace): command line args
""" """
packages = application.updates(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, plan = application.updates(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
check_files=args.check_files) check_files=args.check_files)
plan = application.with_dependencies(plan, process_dependencies=args.dependencies)
if args.changes: # generate changes if requested 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 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 return
packages = application.with_dependencies(packages, process_dependencies=args.dependencies) packagers = Packagers(args.username, {package.base: package.packager for package in plan})
packagers = Packagers(args.username, {package.base: package.packager for package in packages}) result = application.update(plan, packagers, bump_pkgrel=args.increment)
application.print_updates(packages, log_fn=application.logger.info)
result = application.update(packages, packagers, bump_pkgrel=args.increment)
Update.check_status(args.exit_code, not result.is_empty) Update.check_status(args.exit_code, not result.is_empty)
arguments = [ arguments = [
@@ -25,7 +25,6 @@ from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.core.exceptions import PasswordError from ahriman.core.exceptions import PasswordError
from ahriman.core.formatters import UserPrinter from ahriman.core.formatters import UserPrinter
from ahriman.core.utils import enum_values
from ahriman.models.action import Action from ahriman.models.action import Action
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
from ahriman.models.user import User from ahriman.models.user import User
@@ -54,17 +53,17 @@ class Users(Handler):
database = SQLite.load(configuration) database = SQLite.load(configuration)
match args.action: match args.action:
case Action.Update: case Action.UPDATE:
user = Users.user_create(args) user = Users.user_create(args)
# if password is left blank we are not going to require salt to be set # if password is left blank we are not going to require salt to be set
salt = configuration.get("auth", "salt", fallback="") if user.password else "" salt = configuration.get("auth", "salt", fallback="") if user.password else ""
database.user_update(user.hash_password(salt)) database.user_update(user.hash_password(salt))
case Action.List: case Action.LIST:
users = database.user_list(args.username, args.role) users = database.user_list(args.username, args.role)
for user in users: for user in users:
UserPrinter(user)(verbose=True) UserPrinter(user)(verbose=True)
Users.check_status(args.exit_code, users) Users.check_status(args.exit_code, users)
case Action.Remove: case Action.REMOVE:
database.user_remove(args.username) database.user_remove(args.username)
@staticmethod @staticmethod
@@ -89,8 +88,8 @@ class Users(Handler):
"-p", "--password", help="user password. Blank password will be treated as empty password, " "-p", "--password", help="user password. Blank password will be treated as empty password, "
"which is in particular must be used for OAuth2 authorization type.") "which is in particular must be used for OAuth2 authorization type.")
parser.add_argument("-R", "--role", help="user access level", parser.add_argument("-R", "--role", help="user access level",
type=UserAccess, choices=enum_values(UserAccess), default=UserAccess.Read) type=UserAccess, choices=tuple(UserAccess), default=UserAccess.READ)
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, quiet=True, parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, quiet=True,
report=False, repository="") report=False, repository="")
return parser return parser
@@ -110,9 +109,8 @@ class Users(Handler):
parser.add_argument("username", help="filter users by username", nargs="?") parser.add_argument("username", help="filter users by username", nargs="?")
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
action="store_true") action="store_true")
parser.add_argument("-R", "--role", help="filter users by role", type=UserAccess, parser.add_argument("-R", "--role", help="filter users by role", type=UserAccess, choices=tuple(UserAccess))
choices=enum_values(UserAccess)) parser.set_defaults(action=Action.LIST, architecture="", lock=None, quiet=True, report=False, repository="",
parser.set_defaults(action=Action.List, architecture="", lock=None, quiet=True, report=False, repository="",
unsafe=True) unsafe=True)
return parser return parser
@@ -130,7 +128,7 @@ class Users(Handler):
parser = root.add_parser("user-remove", help="remove user", parser = root.add_parser("user-remove", help="remove user",
description="remove user from the user mapping and update the configuration") description="remove user from the user mapping and update the configuration")
parser.add_argument("username", help="username for web service") parser.add_argument("username", help="username for web service")
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, quiet=True, parser.set_defaults(action=Action.REMOVE, architecture="", exit_code=False, lock=None, quiet=True,
report=False, repository="") report=False, repository="")
return parser return parser
@@ -23,7 +23,6 @@ import sys
from collections.abc import Iterator from collections.abc import Iterator
from importlib import metadata from importlib import metadata
from typing import ClassVar
from ahriman import __version__ from ahriman import __version__
from ahriman.application.handlers.handler import Handler, SubParserAction from ahriman.application.handlers.handler import Handler, SubParserAction
@@ -35,13 +34,10 @@ from ahriman.models.repository_id import RepositoryId
class Versions(Handler): class Versions(Handler):
""" """
version handler version handler
Attributes:
PEP423_PACKAGE_NAME(re.Pattern[str]): (class attribute) special regex for valid PEP423 package name
""" """
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
PEP423_PACKAGE_NAME: ClassVar[re.Pattern[str]] = re.compile(r"^[A-Za-z0-9._-]+") _PEP423_PACKAGE_NAME = re.compile(r"^[A-Za-z0-9._-]+")
@classmethod @classmethod
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *, def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
@@ -57,7 +53,7 @@ class Versions(Handler):
""" """
VersionPrinter(f"Module version {__version__}", VersionPrinter(f"Module version {__version__}",
{"Python": sys.version})(verbose=False, separator=" ") {"Python": sys.version})(verbose=False, separator=" ")
packages = Versions.package_dependencies("ahriman") packages = Versions.package_dependencies("ahriman-core", "ahriman-triggers", "ahriman-web")
VersionPrinter("Installed packages", dict(packages))(verbose=False, separator=" ") VersionPrinter("Installed packages", dict(packages))(verbose=False, separator=" ")
@staticmethod @staticmethod
@@ -77,15 +73,15 @@ class Versions(Handler):
return parser return parser
@staticmethod @staticmethod
def package_dependencies(root: str) -> Iterator[tuple[str, str]]: def package_dependencies(*roots: str) -> Iterator[tuple[str, str]]:
""" """
extract list of ahriman package dependencies installed into system with their versions extract installed root packages and their dependencies with their versions
Args: Args:
root(str): root package name *roots(str): root package names
Yields: Yields:
tuple[str, str]: map of installed dependency to its version tuple[str, str]: map of installed package to its version
""" """
def dependencies_by_key(key: str) -> Iterator[str]: def dependencies_by_key(key: str) -> Iterator[str]:
# in importlib it returns requires in the following format # in importlib it returns requires in the following format
@@ -95,10 +91,10 @@ class Versions(Handler):
except metadata.PackageNotFoundError: except metadata.PackageNotFoundError:
return return
for entry in requires or []: for entry in requires or []:
yield from Versions.PEP423_PACKAGE_NAME.findall(entry) yield from Versions._PEP423_PACKAGE_NAME.findall(entry)
keys: list[str] = [] keys: list[str] = []
portion = set(dependencies_by_key(root)) portion = set(roots)
while portion: while portion:
keys.extend(portion) keys.extend(portion)
portion = { portion = {
+2 -2
View File
@@ -209,7 +209,7 @@ class Lock(LazyLogging):
self.check_user() self.check_user()
self.check_version() self.check_version()
self.lock() self.lock()
self.reporter.status_update(BuildStatusEnum.Building) self.reporter.status_update(BuildStatusEnum.BUILDING)
return self return self
def __exit__(self, exc_type: type[Exception] | None, exc_val: Exception | None, def __exit__(self, exc_type: type[Exception] | None, exc_val: Exception | None,
@@ -226,6 +226,6 @@ class Lock(LazyLogging):
Literal[False]: always ``False`` (do not suppress any exception) Literal[False]: always ``False`` (do not suppress any exception)
""" """
self.clear() self.clear()
status = BuildStatusEnum.Success if exc_val is None else BuildStatusEnum.Failed status = BuildStatusEnum.SUCCESS if exc_val is None else BuildStatusEnum.FAILED
self.reporter.status_update(status) self.reporter.status_update(status)
return False return False
+1 -1
View File
@@ -96,7 +96,7 @@ class Pacman(LazyLogging):
self.database_init(handle, self.repository_id.name, self.repository_id.architecture) self.database_init(handle, self.repository_id.name, self.repository_id.architecture)
if use_ahriman_cache and refresh_database: if use_ahriman_cache and refresh_database:
self.database_sync(handle, force=refresh_database == PacmanSynchronization.Force) self.database_sync(handle, force=refresh_database == PacmanSynchronization.FORCE)
return handle return handle
@@ -17,355 +17,312 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import itertools
import re
import shlex import shlex
import tree_sitter_bash
from collections.abc import Iterator from collections.abc import Iterable, Iterator
from enum import StrEnum from enum import StrEnum
from typing import IO 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.core.exceptions import PkgbuildParserError
from ahriman.models.pkgbuild_patch import PkgbuildPatch from ahriman.models.pkgbuild_patch import PkgbuildPatch
class PkgbuildToken(StrEnum): class PkgbuildNodeType(StrEnum):
""" """
well-known tokens dictionary tree-sitter node types used by parser
Attributes: Attributes:
ArrayEnds(PkgbuildToken): array ends token APPEND(PkgbuildNodeType): append node
ArrayStarts(PkgbuildToken): array starts token ARRAY(PkgbuildNodeType): array node
Comma(PkgbuildToken): comma token COMMENT(PkgbuildNodeType): comment node
Comment(PkgbuildToken): comment token CONCATENATION(PkgbuildNodeType): concatenation node
FunctionDeclaration(PkgbuildToken): function declaration token ERROR(PkgbuildNodeType): syntax error node
FunctionEnds(PkgbuildToken): function ends token FUNCTION_DEFINITION(PkgbuildNodeType): function definition node
FunctionStarts(PkgbuildToken): function starts token NUMBER(PkgbuildNodeType): numeric word node
NewLine(PkgbuildToken): new line token RAW_STRING(PkgbuildNodeType): single-quoted string node
STRING(PkgbuildNodeType): double-quoted string node
STRING_CONTENT(PkgbuildNodeType): string content node
VARIABLE_ASSIGNMENT(PkgbuildNodeType): assignment node
WORD(PkgbuildNodeType): word node
""" """
ArrayStarts = "(" APPEND = "+="
ArrayEnds = ")" ARRAY = "array"
COMMENT = "comment"
Comma = "," CONCATENATION = "concatenation"
ERROR = "ERROR"
Comment = "#" FUNCTION_DEFINITION = "function_definition"
NUMBER = "number"
FunctionDeclaration = "()" RAW_STRING = "raw_string"
FunctionStarts = "{" STRING = "string"
FunctionEnds = "}" STRING_CONTENT = "string_content"
VARIABLE_ASSIGNMENT = "variable_assignment"
NewLine = "\n" WORD = "word"
class PkgbuildParser(shlex.shlex): class PkgbuildNodeField(StrEnum):
""" """
simple pkgbuild reader implementation in pure python, because others suck. tree-sitter node fields used by parser
What is it: Attributes:
BODY(PkgbuildNodeField): function body field
NAME(PkgbuildNodeField): variable or function name field
VALUE(PkgbuildNodeField): assignment value field
"""
#. Simple PKGBUILD parser written in python. BODY = "body"
#. No shell execution, so it is free from random shell attacks. NAME = "name"
#. Able to parse simple constructions (assignments, comments, functions, arrays). VALUE = "value"
class PkgbuildParser(Iterable[PkgbuildPatch]):
"""
PKGBUILD parser implementation in python
What it is:
#. A PKGBUILD parser based on tree-sitter's bash grammar.
#. A parser for assignments, arrays, and functions.
#. A parser which does not execute shell code.
What it is not: What it is not:
#. Fully functional shell parser. #. A shell executor.
#. Shell executor. #. A shell interpreter. Variable and command substitutions are returned as written.
#. No parameter expansion.
For more details what does it support, please, consult with the test cases. Simple comma-separated brace expressions in array elements are expanded. Function bodies are returned from the
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: Examples:
This class is heavily based on :mod:`shlex` parser, but instead of strings operates with the Parse package assignments::
:class:`ahriman.models.pkgbuild_patch.PkgbuildPatch` objects. The main way to use it is to call :func:`parse()`
function and collect parsed objects, e.g.::
>>> parser = PkgbuildParser(StringIO("input string")) >>> source = b"pkgname=example\\npkgver=1\\n"
>>> for patch in parser.parse(): >>> for patch in PkgbuildParser(BytesIO(source)):
>>> print(f"{patch.key} = {patch.value}") ... print(patch.key, patch.value)
It doesn't store the state of the fields (but operates with the :mod:`shlex` parser state), so no shell Function bodies are returned as function patches::
post-processing is performed (e.g. variable substitution).
>>> source = b"pkgver() { printf 1; }"
>>> for patch in PkgbuildParser(BytesIO(source)):
... print(patch.key, patch.value)
""" """
_ARRAY_ASSIGNMENT = re.compile(r"^(?P<key>\w+)=$") _ESCAPED_CHARACTERS = {
# in addition to usual assignment, functions can have dash "\\$": "$",
_FUNCTION_DECLARATION = re.compile(r"^(?P<key>[\w-]+)$") "\\`": "`",
_STRING_ASSIGNMENT = re.compile(r"^(?P<key>\w+)=(?P<value>.+)$") "\\\"": "\"",
"\\\n": "",
}
def __init__(self, stream: IO[str]) -> None: def __init__(self, stream: IO[bytes]) -> None:
""" """
Args: Args:
stream(IO[str]): input stream containing PKGBUILD content stream(IO[bytes]): input PKGBUILD stream
""" """
shlex.shlex.__init__(self, stream, posix=True, punctuation_chars=True) self._content = stream.read()
self._io = stream # direct access without type casting
# ignore substitution and extend bash symbols
self.wordchars += "${}#:+-@!"
# in case of default behavior, it will ignore, for example, segment part of url outside of quotes
self.commenters = ""
@staticmethod @staticmethod
def _expand_array(array: list[str]) -> list[str]: def text(node: Node) -> str:
""" """
bash array expansion simulator. It takes raw array and tries to expand constructions like read the original source text represented by a syntax tree node
``(first prefix-{mid1,mid2}-suffix last)`` into ``(first, prefix-mid1-suffix prefix-mid2-suffix last)``
Args: Args:
array(list[str]): input array node(Node): syntax tree node to read
Returns: Returns:
list[str]: either source array or expanded array if possible str: source text for the node
Raises:
PkgbuildParserError: if there are errors in parser
""" """
# we are using comma as marker for expansion (if any) return cast(bytes, node.text).decode("utf8", errors="backslashreplace")
if PkgbuildToken.Comma not in array:
return array
# again sanity check, for expansion there are at least 3 elements (first, last and comma)
if len(array) < 3:
return array
result = [] @staticmethod
buffer, prefix = [], None def unquote(value: str) -> str:
for index, (first, second) in enumerate(itertools.pairwise(array)):
match (first, second):
# in this case we check if expansion should be started
# this condition matches "prefix{first", ","
case (_, PkgbuildToken.Comma) if PkgbuildToken.FunctionStarts in first:
prefix, part = first.rsplit(PkgbuildToken.FunctionStarts, maxsplit=1)
buffer.append(f"{prefix}{part}")
# the last element case, it matches either ",", "last}" or ",", "last}suffix"
# in case if there is suffix, it must be appended to all list elements
case (PkgbuildToken.Comma, _) if prefix is not None and PkgbuildToken.FunctionEnds in second:
part, suffix = second.rsplit(PkgbuildToken.FunctionEnds, maxsplit=1)
buffer.append(f"{prefix}{part}")
result.extend([f"{part}{suffix}" for part in buffer])
# reset state
buffer, prefix = [], None
# we have already got prefix string, so we are in progress of expansion
# we always operate the last element, so this matches ",", "next"
case (PkgbuildToken.Comma, _) if prefix is not None:
buffer.append(f"{prefix}{second}")
# exactly first element of the list
case (_, _) if prefix is None and index == 0:
result.append(first)
# any next normal element
case (_, _) if prefix is None:
result.append(second)
# small sanity check
if prefix is not None:
raise PkgbuildParserError("error in array expansion", array)
return result
def _is_escaped(self) -> bool:
""" """
check if the last element was quoted. ``shlex.shlex`` parser doesn't provide information about was the token remove shell quotes and escapes from a single value
quoted or not, thus there is no difference between "'#'" (sharp in quotes) and "#" (sharp without quotes). This
method simply rolls back to the last non-space character and check if it is a quotation mark
Returns:
bool: ``True`` if the previous element of the stream is a quote or escaped and ``False`` otherwise
"""
current_position = self._io.tell()
last_char = penultimate_char = None
index = current_position - 1
while index > 0:
index, last_char = self._read_last(index)
if last_char.isspace():
index -= 1
continue
if index > 1:
_, penultimate_char = self._read_last(index - 1)
break
self._io.seek(current_position) # reset position of the stream
is_quoted = last_char is not None and last_char in self.quotes
is_escaped = penultimate_char is not None and penultimate_char in self.escape
return is_quoted or is_escaped
def _parse_array(self) -> list[str]:
"""
parse array from the PKGBUILD. This method will extract tokens from parser until it matches closing array,
modifying source parser state
Returns:
list[str]: extracted arrays elements
Raises:
PkgbuildParserError: if array is not closed
"""
def extract() -> Iterator[str]:
while token := self.get_token():
match token:
case _ if self._is_escaped():
pass
case PkgbuildToken.ArrayEnds:
break
case comment if comment.startswith(PkgbuildToken.Comment):
self._read_comment()
continue
yield token
if token != PkgbuildToken.ArrayEnds:
raise PkgbuildParserError("no closing array bracket found")
return self._expand_array(list(extract()))
def _parse_function(self) -> str:
"""
parse function from the PKGBUILD. This method will extract tokens from parser until it matches closing function,
modifying source parser state. Instead of trying to combine tokens together, it uses positions of the file
and reads content again in this range
Returns:
str: function body
Raises:
PkgbuildParserError: if function body wasn't found or parser input stream doesn't support position reading
"""
# find start and end positions
start_position = end_position = -1
counter = 0 # simple processing of the inner "{" and "}"
for token in self:
match token:
case _ if self._is_escaped():
continue
case PkgbuildToken.FunctionStarts:
if counter == 0:
start_position = self._io.tell() - 1
counter += 1
case PkgbuildToken.FunctionEnds:
end_position = self._io.tell()
if self.state != self.eof: # type: ignore[attr-defined]
end_position -= 1 # if we are not at the end of the file, position is _after_ the token
counter -= 1
if counter == 0:
break
case comment if comment.startswith(PkgbuildToken.Comment):
self._read_comment()
if not 0 < start_position < end_position:
raise PkgbuildParserError("function body wasn't found")
# read the specified interval from source stream
self._io.seek(start_position - 1) # start from the previous symbol
# we cannot use :func:`read()` here, because it reads characters, not bytes
content = ""
while self._io.tell() != end_position and (next_char := self._io.read(1)):
content += next_char
# special case of the end of file
if self.state == self.eof: # type: ignore[attr-defined]
content += self._io.read(1)
return content
def _parse_token(self, token: str) -> Iterator[PkgbuildPatch]:
"""
parse single token to the PKGBUILD field
Args: Args:
token(str): current token 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.STRING_CONTENT:
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.RAW_STRING | PkgbuildNodeType.WORD:
return PkgbuildParser.unquote(value)
case _:
return value
def _assignment(self, node: Node) -> PkgbuildPatch:
"""
convert an assignment node
Args:
node(Node): assignment node to convert
Returns:
PkgbuildPatch: parsed assignment
"""
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:
values = []
for element in filter(lambda child: child.type != PkgbuildNodeType.COMMENT, value.named_children):
values.extend(self._expand_array(element))
return PkgbuildPatch(key, values)
case _:
return PkgbuildPatch(key, self.value(value))
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: Yields:
PkgbuildPatch: extracted a PKGBUILD node PkgbuildPatch: parsed entries
""" """
# simple assignment rule match node.type:
if m := self._STRING_ASSIGNMENT.match(token): case PkgbuildNodeType.VARIABLE_ASSIGNMENT if any(child.type == PkgbuildNodeType.APPEND for child in node.children):
key = m.group("key") patch = self._assignment(node)
value = m.group("value") match values.get(patch.key), patch.value:
yield PkgbuildPatch(key, value) case PkgbuildPatch(value=str() as previous), str() as appended:
return 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
if token.startswith(PkgbuildToken.Comment): case PkgbuildNodeType.VARIABLE_ASSIGNMENT:
self._read_comment() patch = self._assignment(node)
return values[patch.key] = patch
yield patch
match self.get_token(): case PkgbuildNodeType.FUNCTION_DEFINITION:
# array processing. Arrays will be sent as "key=", "(", values, ")" name = cast(Node, node.child_by_field_name(PkgbuildNodeField.NAME))
case PkgbuildToken.ArrayStarts if m := self._ARRAY_ASSIGNMENT.match(token): body = cast(Node, node.child_by_field_name(PkgbuildNodeField.BODY))
key = m.group("key") yield PkgbuildPatch(f"{self.text(name)}()", self.text(body))
value = self._parse_array()
yield PkgbuildPatch(key, value)
# functions processing. Function will be sent as "name", "()", "{", body, "}" case _:
case PkgbuildToken.FunctionDeclaration if self._FUNCTION_DECLARATION.match(token): # descend into statements, but skip command arguments and values
key = f"{token}{PkgbuildToken.FunctionDeclaration}" for child in node.named_children:
value = self._parse_function() if child.type not in (
yield PkgbuildPatch(key, value) # this is not mistake, assign to token without () PkgbuildNodeType.ARRAY,
PkgbuildNodeType.COMMENT,
# special function case, where "(" and ")" are separated tokens, e.g. "pkgver ( )" PkgbuildNodeType.RAW_STRING,
case PkgbuildToken.ArrayStarts if self._FUNCTION_DECLARATION.match(token): PkgbuildNodeType.STRING,
next_token = self.get_token() PkgbuildNodeType.WORD,
if next_token == PkgbuildToken.ArrayEnds: # replace closing bracket with "()" ):
next_token = PkgbuildToken.FunctionDeclaration yield from self._read(child, values)
self.push_token(next_token) # type: ignore[arg-type]
yield from self._parse_token(token)
# some random token received without continuation, lets guess it is empty assignment (i.e. key=)
case other if other is not None:
yield from self._parse_token(other)
def _read_comment(self) -> None:
"""
read comment from the current position. This method doesn't check comment itself, just read the stream
until the comment line ends
"""
_, last_symbol = self._read_last()
if last_symbol != PkgbuildToken.NewLine:
self.instream.readline()
def _read_last(self, initial_index: int | None = None) -> tuple[int, str]:
"""
wrapper around read to read the last symbol from the input stream. This method is designed to process UTF-8
symbols correctly. This method does not reset current stream position
Args:
initial_index(int | None, optional): initial index to start reading from. If none set, the previous position
will be used (Default value = None)
Returns:
tuple[int, str]: last symbol and its position in the stream
Raises:
PkgbuildParserError: in case if stream reached starting position, but no valid symbols were found
"""
if initial_index is None:
initial_index = self._io.tell() - 1
if initial_index < 0:
raise PkgbuildParserError("stream is on starting position")
self._io.seek(initial_index)
while (position := self._io.tell()) > 0:
try:
return position, self._io.read(1)
except UnicodeDecodeError:
self._io.seek(position - 1)
raise PkgbuildParserError("reached starting position, no valid symbols found")
def parse(self) -> Iterator[PkgbuildPatch]: def parse(self) -> Iterator[PkgbuildPatch]:
""" """
parse source stream and yield parsed entries parse source and yield extracted entries
Yields: Yields:
PkgbuildPatch: extracted a PKGBUILD node PkgbuildPatch: parsed entries
Raises:
PkgbuildParserError: source contains invalid shell syntax
""" """
for token in self: def walk(node: Node) -> Iterator[Node]:
yield from self._parse_token(token) yield node
for child in node.children:
yield from walk(child)
parser = Parser(Language(tree_sitter_bash.language()))
tree = parser.parse(self._content)
if tree.root_node.has_error:
error = next((node for node in walk(tree.root_node) if node.is_error or node.is_missing), tree.root_node)
raise PkgbuildParserError(
f"syntax error at line {error.start_point.row + 1}, column {error.start_point.column + 1}"
)
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()
@@ -56,7 +56,7 @@ class PackageVersion(LazyLogging):
_, repository_id = configuration.check_loaded() _, repository_id = configuration.check_loaded()
paths = configuration.repository_paths paths = configuration.repository_paths
task = Task(self.package, configuration, repository_id.architecture, paths) task = Task(self.package, configuration, repository_id, paths)
try: try:
# create fresh chroot environment, fetch sources and - automagically - update PKGBUILD # create fresh chroot environment, fetch sources and - automagically - update PKGBUILD
@@ -165,7 +165,7 @@ class Sources(LazyLogging):
# extract local files... # extract local files...
files = ["PKGBUILD", ".SRCINFO"] + [str(path) for path in Pkgbuild.local_files(sources_dir)] files = ["PKGBUILD", ".SRCINFO"] + [str(path) for path in Pkgbuild.local_files(sources_dir)]
instance.add(sources_dir, *files) instance.add(sources_dir, *files, force=True)
# ...and commit them # ...and commit them
instance.commit(sources_dir) instance.commit(sources_dir)
@@ -232,7 +232,7 @@ class Sources(LazyLogging):
git_url, branch = remote.git_source() git_url, branch = remote.git_source()
check_output(*instance.git(), "push", "--quiet", git_url, branch, cwd=sources_dir, logger=instance.logger) check_output(*instance.git(), "push", "--quiet", git_url, branch, cwd=sources_dir, logger=instance.logger)
def add(self, sources_dir: Path, *pattern: str, intent_to_add: bool = False) -> None: def add(self, sources_dir: Path, *pattern: str, intent_to_add: bool = False, force: bool = False) -> None:
""" """
track found files via git track found files via git
@@ -241,6 +241,7 @@ class Sources(LazyLogging):
*pattern(str): glob patterns *pattern(str): glob patterns
intent_to_add(bool, optional): record only the fact that it will be added later, acts as intent_to_add(bool, optional): record only the fact that it will be added later, acts as
--intent-to-add git flag (Default value = False) --intent-to-add git flag (Default value = False)
force(bool, optional): allow adding ignored files (Default value = False)
""" """
# glob directory to find files which match the specified patterns # glob directory to find files which match the specified patterns
found_files: list[Path] = [] found_files: list[Path] = []
@@ -251,6 +252,8 @@ class Sources(LazyLogging):
self.logger.info("found matching files %s", found_files) self.logger.info("found matching files %s", found_files)
# add them to index # add them to index
args = ["--intent-to-add"] if intent_to_add else [] args = ["--intent-to-add"] if intent_to_add else []
if force:
args.append("--force")
check_output(*self.git(), "add", *args, *[str(fn.relative_to(sources_dir)) for fn in found_files], check_output(*self.git(), "add", *args, *[str(fn.relative_to(sources_dir)) for fn in found_files],
cwd=sources_dir, logger=self.logger) cwd=sources_dir, logger=self.logger)
@@ -27,6 +27,7 @@ from ahriman.core.log import LazyLogging
from ahriman.core.utils import check_output, package_like from ahriman.core.utils import check_output, package_like
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.pkgbuild_patch import PkgbuildPatch from ahriman.models.pkgbuild_patch import PkgbuildPatch
from ahriman.models.repository_id import RepositoryId
from ahriman.models.repository_paths import RepositoryPaths from ahriman.models.repository_paths import RepositoryPaths
@@ -36,33 +37,40 @@ class Task(LazyLogging):
Attributes: Attributes:
archbuild_flags(list[str]): command flags for archbuild command archbuild_flags(list[str]): command flags for archbuild command
architecture(str): repository architecture build_command(list[str]): build command
build_command(str): build command devtools_configs(Path): path to local directory with devtools configuration files
include_debug_packages(bool): whether to include debug packages or not include_debug_packages(bool): whether to include debug packages or not
make_flags(str): MAKEFLAGS variable for makepkg command
makechrootpkg_flags(list[str]): command flags for makechrootpkg command makechrootpkg_flags(list[str]): command flags for makechrootpkg command
makepkg_flags(list[str]): command flags for makepkg command makepkg_flags(list[str]): command flags for makepkg command
package(Package): package definitions package(Package): package definitions
paths(RepositoryPaths): repository paths instance paths(RepositoryPaths): repository paths instance
repository_id(RepositoryId): repository unique identifier
uid(int): uid of the repository owner user uid(int): uid of the repository owner user
""" """
def __init__(self, package: Package, configuration: Configuration, architecture: str, def __init__(self, package: Package, configuration: Configuration, repository_id: RepositoryId,
paths: RepositoryPaths) -> None: paths: RepositoryPaths) -> None:
""" """
Args: Args:
package(Package): package definitions package(Package): package definitions
configuration(Configuration): configuration instance configuration(Configuration): configuration instance
architecture(str): repository architecture repository_id(RepositoryId): repository unique identifier
paths(RepositoryPaths): repository paths instance paths(RepositoryPaths): repository paths instance
""" """
self.package = package self.package = package
self.paths = paths self.paths = paths
self.uid, _ = paths.root_owner self.uid, _ = paths.root_owner
self.architecture = architecture self.repository_id = repository_id
self.archbuild_flags = configuration.getlist("build", "archbuild_flags", fallback=[]) self.archbuild_flags = configuration.getlist("build", "archbuild_flags", fallback=[])
self.build_command = configuration.get("build", "build_command") self.build_command = configuration.getlist("build", "devtools_wrapper")
self.devtools_configs = configuration.getpath("build", "devtools_configs")
self._legacy_build_command = configuration.getlist("build", "build_command", fallback=[])
self.include_debug_packages = configuration.getboolean("build", "include_debug_packages", fallback=True) self.include_debug_packages = configuration.getboolean("build", "include_debug_packages", fallback=True)
# even though this option is declared as list, there is no need to read it as list,
# because it will be converted back to the string anyway
self.make_flags = configuration.get("build", "make_flags", fallback=None)
self.makepkg_flags = configuration.getlist("build", "makepkg_flags", fallback=[]) self.makepkg_flags = configuration.getlist("build", "makepkg_flags", fallback=[])
self.makechrootpkg_flags = configuration.getlist("build", "makechrootpkg_flags", fallback=[]) self.makechrootpkg_flags = configuration.getlist("build", "makechrootpkg_flags", fallback=[])
@@ -108,12 +116,21 @@ class Task(LazyLogging):
Returns: Returns:
list[Path]: paths of produced packages list[Path]: paths of produced packages
""" """
command = [self.build_command, "-r", str(self.paths.chroot)] command = self._legacy_build_command[:]
command.extend(self.archbuild_flags) if not command:
command.extend(["--", "-D", str(self.paths.archive)] + self.makechrootpkg_flags) command = self.build_command + [
command.extend(["--"] + self.makepkg_flags) "-r", self.repository_id.name,
"-a", self.repository_id.architecture,
"-c", str(self.devtools_configs),
"--",
]
command.extend(["-r", str(self.paths.chroot)] + self.archbuild_flags) # archbuild flags
command.extend(["--", "-D", str(self.paths.archive)] + self.makechrootpkg_flags) # makechrootpkg flags
command.extend(["--"] + self.makepkg_flags) # makepkg flags
if dry_run: if dry_run:
command.extend(["--nobuild"]) command.extend(["--nobuild"])
self.logger.info("using %s for %s", command, self.package.base) self.logger.info("using %s for %s", command, self.package.base)
environment: dict[str, str] = { environment: dict[str, str] = {
@@ -121,6 +138,8 @@ class Task(LazyLogging):
for key, value in kwargs.items() for key, value in kwargs.items()
if value is not None if value is not None
} }
if self.make_flags is not None:
environment["MAKEFLAGS"] = self.make_flags
self.logger.info("using environment variables %s", environment) self.logger.info("using environment variables %s", environment)
source_files = list(sources_dir.iterdir()) source_files = list(sources_dir.iterdir())
@@ -156,7 +175,7 @@ class Task(LazyLogging):
return last_commit_sha return last_commit_sha
# load fresh package # load fresh package
loaded_package = Package.from_build(sources_dir, self.architecture, None) loaded_package = Package.from_build(sources_dir, self.repository_id.architecture, None)
if (pkgrel := loaded_package.next_pkgrel(local_version)) is not None: if (pkgrel := loaded_package.next_pkgrel(local_version)) is not None:
self.logger.info("package %s is the same as in repo, bumping pkgrel to %s", self.package.base, pkgrel) self.logger.info("package %s is the same as in repo, bumping pkgrel to %s", self.package.base, pkgrel)
patch = PkgbuildPatch("pkgrel", pkgrel) patch = PkgbuildPatch("pkgrel", pkgrel)
@@ -109,14 +109,14 @@ class Configuration(configparser.RawConfigParser):
return repository_id.architecture return repository_id.architecture
@property @property
def include(self) -> Path: def include(self) -> list[Path]:
""" """
get full path to include directory get full path to include directory
Returns: Returns:
Path: path to directory with configuration includes list[Path]: paths to directories with configuration includes
""" """
return self.getpath("settings", "include") return self.getpathlist("settings", "include")
@property @property
def logging_path(self) -> Path: def logging_path(self) -> Path:
@@ -325,25 +325,26 @@ class Configuration(configparser.RawConfigParser):
section, key = name.rsplit(":", maxsplit=1) section, key = name.rsplit(":", maxsplit=1)
self.set_option(section, key, value) self.set_option(section, key, value)
def load_includes(self, path: Path | None = None) -> None: def load_includes(self) -> None:
""" """
load configuration includes from specified path load configuration includes from specified path
Args:
path(Path | None, optional): path to directory with include files. If none set, the default path will be
used (Default value = None)
""" """
self.includes = [] # reset state self.includes = [] # reset state
try: try:
path = path or self.include include_directories = self.include
except (configparser.NoOptionError, configparser.NoSectionError):
return
for path in include_directories: # pylint: disable=not-an-iterable
if not path.is_dir():
continue
for include in sorted(path.glob("*.ini")): for include in sorted(path.glob("*.ini")):
if include == self.logging_path: if include == self.logging_path:
continue # we don't want to load logging explicitly continue # we don't want to load logging explicitly
self.read(include) self.read(include)
self.includes.append(include) self.includes.append(include)
except (FileNotFoundError, configparser.NoOptionError, configparser.NoSectionError):
pass
def merge_sections(self, repository_id: RepositoryId) -> None: def merge_sections(self, repository_id: RepositoryId) -> None:
""" """
@@ -403,6 +404,7 @@ class Configuration(configparser.RawConfigParser):
# create another instance and copy values from there # create another instance and copy values from there
instance = self.from_path(path, repository_id) instance = self.from_path(path, repository_id)
self.copy_from(instance) self.copy_from(instance)
self.includes = instance.includes
def set_option(self, section: str, option: str, value: str) -> None: def set_option(self, section: str, option: str, value: str) -> None:
""" """
@@ -40,11 +40,14 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
"required": True, "required": True,
}, },
"include": { "include": {
"type": "list",
"coerce": "list",
"schema": {
"type": "path", "type": "path",
"coerce": "absolute_path", "coerce": "absolute_path",
"path_exists": True,
"path_type": "dir", "path_type": "dir",
}, },
},
"logging": { "logging": {
"type": "path", "type": "path",
"coerce": "absolute_path", "coerce": "absolute_path",
@@ -190,8 +193,27 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
}, },
}, },
"build_command": { "build_command": {
"type": "list",
"coerce": "list",
"schema": {
"type": "string", "type": "string",
"empty": False,
},
},
"devtools_configs": {
"type": "path",
"coerce": "absolute_path",
"required": True, "required": True,
"path_exists": True,
"path_type": "dir",
},
"devtools_wrapper": {
"type": "list",
"coerce": "list",
"schema": {
"type": "string",
"empty": False,
},
"empty": False, "empty": False,
}, },
"ignore_packages": { "ignore_packages": {
@@ -206,6 +228,14 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
"type": "boolean", "type": "boolean",
"coerce": "boolean", "coerce": "boolean",
}, },
"make_flags": {
"type": "list",
"coerce": "list",
"schema": {
"type": "string",
"empty": False,
},
},
"makechrootpkg_flags": { "makechrootpkg_flags": {
"type": "list", "type": "list",
"coerce": "list", "coerce": "list",
@@ -214,19 +244,23 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
"empty": False, "empty": False,
}, },
}, },
"makepkg_flags": {
"type": "list",
"coerce": "list",
"schema": {
"type": "string",
"empty": False,
},
},
"min_age": { "min_age": {
"type": "integer", "type": "integer",
"coerce": "integer", "coerce": "integer",
"min": 0, "min": 0,
}, },
"makepkg_flags": { "packager": {
"type": "list",
"coerce": "list",
"schema": {
"type": "string", "type": "string",
"empty": False, "empty": False,
}, },
},
"scan_paths": { "scan_paths": {
"type": "list", "type": "list",
"coerce": "list", "coerce": "list",
@@ -190,5 +190,5 @@ class Validator(RootValidator):
{"type": "string"} {"type": "string"}
""" """
fn = getattr(value, f"is_{constraint}") fn = getattr(value, f"is_{constraint}")
if not fn(): if value.exists() and not fn():
self._error(field, f"Path {value} must be type of {constraint}") self._error(field, f"Path {value} must be type of {constraint}")
+11 -6
View File
@@ -83,6 +83,15 @@ Process stderr:
{self.stderr}""" {self.stderr}"""
class DependencyResolutionError(RuntimeError):
"""
exception raised when package dependencies cannot be resolved
"""
def __init__(self, unprocessed: list[str]) -> None:
RuntimeError.__init__(self, f"Could not process dependencies. Unresolved packages: {unprocessed}")
class DuplicateRunError(RuntimeError): class DuplicateRunError(RuntimeError):
""" """
exception which will be raised if there is another application instance exception which will be raised if there is another application instance
@@ -229,16 +238,12 @@ class PkgbuildParserError(ValueError):
exception raises in case of PKGBUILD parser errors exception raises in case of PKGBUILD parser errors
""" """
def __init__(self, reason: str, source: Any = None) -> None: def __init__(self, reason: str) -> None:
""" """
Args: Args:
reason(str): parser error reason reason(str): parser error reason
source(Any, optional): source line if available (Default value = None)
""" """
message = f"Could not parse PKGBUILD: {reason}" ValueError.__init__(self, f"Could not parse PKGBUILD: {reason}")
if source is not None:
message += f", source: `{source}`"
ValueError.__init__(self, message)
class PasswordError(ValueError): class PasswordError(ValueError):
@@ -46,7 +46,7 @@ class Printer:
if not verbose and not prop.is_required: if not verbose and not prop.is_required:
continue continue
indent = "\t" * prop.indent 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]: def properties(self) -> list[Property]:
""" """
@@ -17,30 +17,38 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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.formatters.string_printer import StringPrinter
from ahriman.core.tree import Tree
from ahriman.core.utils import full_version, parse_version 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.package import Package
from ahriman.models.property import Property from ahriman.models.property import Property
class UpdatePrinter(StringPrinter): class UpdatePrinter(StringPrinter):
""" """
print content of the package update print content of the packages update
Attributes: Attributes:
package(Package): remote (new) package object plan(BuildPlan): plan to display
local_version(str | None): local version of the package if any 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: Args:
remote(Package): remote (new) package object plan(BuildPlan): plan to display
local_version(str | None): local version of the package if any 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) StringPrinter.__init__(self, "Build plan" if plan else "No packages selected")
self.package = remote self.plan = plan
self.local_version = local_version self.local_versions = local_versions
self.bump_pkgrel = bump_pkgrel
def properties(self) -> list[Property]: def properties(self) -> list[Property]:
""" """
@@ -49,9 +57,48 @@ class UpdatePrinter(StringPrinter):
Returns: Returns:
list[Property]: list of content properties list[Property]: list of content properties
""" """
if (pkgrel := self.package.next_pkgrel(self.local_version)) is not None: return [
epoch, pkgver, _ = parse_version(self.package.version) 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) effective_new_version = full_version(epoch, pkgver, pkgrel)
else: else:
effective_new_version = self.package.version effective_new_version = package.version
return [Property(self.local_version or "N/A", effective_new_version, is_required=True)]
return local_version or "N/A", effective_new_version
@@ -55,7 +55,7 @@ class RemotePull(LazyLogging):
web_url="", web_url="",
path=".", path=".",
branch=configuration.get(section, "pull_branch", fallback="master"), branch=configuration.get(section, "pull_branch", fallback="master"),
source=PackageSource.Local, source=PackageSource.LOCAL,
) )
self.architecture = repository_id.architecture self.architecture = repository_id.architecture
self.repository_paths = configuration.repository_paths self.repository_paths = configuration.repository_paths
@@ -62,7 +62,7 @@ class RemotePush(LazyLogging):
web_url="", web_url="",
path=".", path=".",
branch=configuration.get(section, "push_branch", fallback="master"), branch=configuration.get(section, "push_branch", fallback="master"),
source=PackageSource.Local, source=PackageSource.LOCAL,
) )
def package_update(self, package: Package, target_dir: Path) -> str: def package_update(self, package: Package, target_dir: Path) -> str:
@@ -87,7 +87,12 @@ class ArchiveRotationTrigger(Trigger):
if self.keep_built_packages == 0: if self.keep_built_packages == 0:
return return
to_remove = repository.package_archives(package.base) current = next(iter(repository.packages([package.base])), None)
to_remove = [
single
for single in repository.package_archives(package.base)
if current is None or single.version != current.version
]
for single in to_remove[:-self.keep_built_packages]: for single in to_remove[:-self.keep_built_packages]:
self.logger.info("removing version %s of package %s", single.version, single.base) self.logger.info("removing version %s of package %s", single.version, single.base)
@@ -21,6 +21,8 @@
from logging import NullHandler from logging import NullHandler
from typing import Any from typing import Any
from ahriman.core.module_loader import optional_module
__all__ = ["JournalHandler"] __all__ = ["JournalHandler"]
@@ -40,7 +42,5 @@ class _JournalHandler(NullHandler):
del args, kwargs del args, kwargs
try: systemd_journal = optional_module("systemd.journal")
from systemd.journal import JournalHandler # type: ignore[import-untyped] JournalHandler = systemd_journal.JournalHandler if systemd_journal else _JournalHandler
except ImportError:
JournalHandler = _JournalHandler
@@ -26,6 +26,7 @@ from typing import ClassVar, Literal
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.log.http_log_handler import HttpLogHandler from ahriman.core.log.http_log_handler import HttpLogHandler
from ahriman.core.log.log_context import LogContext from ahriman.core.log.log_context import LogContext
from ahriman.core.module_loader import optional_module
from ahriman.models.log_handler import LogHandler from ahriman.models.log_handler import LogHandler
from ahriman.models.repository_id import RepositoryId from ahriman.models.repository_id import RepositoryId
@@ -51,9 +52,9 @@ class LogLoader:
""" """
try to guess default log handler. In case if ``selected`` is set, it will return specified value with appended try to guess default log handler. In case if ``selected`` is set, it will return specified value with appended
_handler suffix. Otherwise, it will try to import journald handler and returns _handler suffix. Otherwise, it will try to import journald handler and returns
:attr:`ahriman.models.log_handler.LogHandler.Journald` if library is available. Otherwise, it will check if :attr:`ahriman.models.log_handler.LogHandler.JOURNALD` if library is available. Otherwise, it will check if
there is ``/dev/log`` device and returns :attr:`ahriman.models.log_handler.LogHandler.Syslog` in this there is ``/dev/log`` device and returns :attr:`ahriman.models.log_handler.LogHandler.SYSLOG` in this
case. And, finally, it will fall back to :attr:`ahriman.models.log_handler.LogHandler.Console` case. And, finally, it will fall back to :attr:`ahriman.models.log_handler.LogHandler.CONSOLE`
if none were found if none were found
Args: Args:
@@ -65,14 +66,11 @@ class LogLoader:
if selected is not None: if selected is not None:
return selected return selected
try: if optional_module("systemd.journal"):
from systemd.journal import JournalHandler # type: ignore[import-untyped] return LogHandler.JOURNALD # journald import was found
del JournalHandler
return LogHandler.Journald # journald import was found
except ImportError:
if LogLoader.DEFAULT_SYSLOG_DEVICE.exists(): if LogLoader.DEFAULT_SYSLOG_DEVICE.exists():
return LogHandler.Syslog return LogHandler.SYSLOG
return LogHandler.Console return LogHandler.CONSOLE
@staticmethod @staticmethod
def load(repository_id: RepositoryId, configuration: Configuration, handler: LogHandler, *, def load(repository_id: RepositoryId, configuration: Configuration, handler: LogHandler, *,
+17 -2
View File
@@ -26,8 +26,7 @@ from pkgutil import ModuleInfo, walk_packages
from types import ModuleType from types import ModuleType
from typing import Any, TypeGuard, TypeVar from typing import Any, TypeGuard, TypeVar
__all__ = ["implementations", "optional_module"]
__all__ = ["implementations"]
T = TypeVar("T") T = TypeVar("T")
@@ -74,3 +73,19 @@ def implementations(root_module: ModuleType, base_class: type[T]) -> Iterator[ty
for _, attribute in inspect.getmembers(module, is_base_class): for _, attribute in inspect.getmembers(module, is_base_class):
yield attribute yield attribute
def optional_module(module_name: str) -> ModuleType | None:
"""
import an optional module
Args:
module_name(str): fully qualified module name
Returns:
ModuleType | None: imported module or ``None`` when it cannot be imported
"""
try:
return import_module(module_name)
except ImportError:
return None
@@ -155,8 +155,8 @@ class JinjaTemplate:
homepage=self.homepage, homepage=self.homepage,
last_update=self.format_datetime(utcnow()), last_update=self.format_datetime(utcnow()),
link_path=self.link_path, link_path=self.link_path,
has_package_signed=SignSettings.Packages in self.sign_targets, has_package_signed=SignSettings.PACKAGES in self.sign_targets,
has_repo_signed=SignSettings.Repository in self.sign_targets, has_repo_signed=SignSettings.REPOSITORY in self.sign_targets,
packages=self.sort_content(content), packages=self.sort_content(content),
pgp_key=self.default_pgp_key, pgp_key=self.default_pgp_key,
repository=self.name, repository=self.name,
@@ -81,19 +81,19 @@ class Report(LazyLogging):
case ReportSettings.HTML: case ReportSettings.HTML:
from ahriman.core.report.html import HTML from ahriman.core.report.html import HTML
return HTML(repository_id, configuration, section) return HTML(repository_id, configuration, section)
case ReportSettings.Email: case ReportSettings.EMAIL:
from ahriman.core.report.email import Email from ahriman.core.report.email import Email
return Email(repository_id, configuration, section) return Email(repository_id, configuration, section)
case ReportSettings.Console: case ReportSettings.CONSOLE:
from ahriman.core.report.console import Console from ahriman.core.report.console import Console
return Console(repository_id, configuration, section) return Console(repository_id, configuration, section)
case ReportSettings.Telegram: case ReportSettings.TELEGRAM:
from ahriman.core.report.telegram import Telegram from ahriman.core.report.telegram import Telegram
return Telegram(repository_id, configuration, section) return Telegram(repository_id, configuration, section)
case ReportSettings.RSS: case ReportSettings.RSS:
from ahriman.core.report.rss import RSS from ahriman.core.report.rss import RSS
return RSS(repository_id, configuration, section) return RSS(repository_id, configuration, section)
case ReportSettings.RemoteCall: case ReportSettings.REMOTE_CALL:
from ahriman.core.report.remote_call import RemoteCall from ahriman.core.report.remote_call import RemoteCall
return RemoteCall(repository_id, configuration, section) return RemoteCall(repository_id, configuration, section)
case _: case _:
+1 -1
View File
@@ -103,7 +103,7 @@ class RSS(Report, JinjaTemplate):
""" """
ctx = context.get() ctx = context.get()
reporter = ctx.get(Client) reporter = ctx.get(Client)
events = reporter.event_get(EventType.PackageUpdated, None, limit=self.max_entries) events = reporter.event_get(EventType.PACKAGE_UPDATED, None, limit=self.max_entries)
known_packages = {package.base: package for package in packages} known_packages = {package.base: package for package in packages}
@@ -49,7 +49,7 @@ class EventLogger:
This method must be used as simple wrapper for :class:`ahriman.core.status.Client` methods, e.g.:: This method must be used as simple wrapper for :class:`ahriman.core.status.Client` methods, e.g.::
>>> do_something() >>> do_something()
>>> self.event(package_base, EventType.PackageUpdated) >>> self.event(package_base, EventType.PACKAGE_UPDATED)
""" """
self.reporter.event_add(Event(event, package_base, message)) self.reporter.event_add(Event(event, package_base, message))
@@ -68,7 +68,7 @@ class EventLogger:
Examples: Examples:
This method must be used to perform action in context with time measurement:: This method must be used to perform action in context with time measurement::
>>> with self.in_event(package_base, EventType.PackageUpdated): >>> with self.in_event(package_base, EventType.PACKAGE_UPDATED):
>>> do_something() >>> do_something()
Additional parameter ``failure`` can be set in order to emit an event on exception occurred. If none set Additional parameter ``failure`` can be set in order to emit an event on exception occurred. If none set
@@ -73,7 +73,8 @@ class Executor(PackageInfo, Cleaner):
""" """
self.reporter.set_building(package.base) self.reporter.set_building(package.base)
task = Task(package, self.configuration, self.repository_id.architecture, self.paths) default_packager = self.configuration.get("build", "packager", fallback=None)
task = Task(package, self.configuration, self.repository_id, self.paths)
patches = self.reporter.package_patches_get(package.base, None) patches = self.reporter.package_patches_get(package.base, None)
commit_sha = task.init(path, patches, local_version) commit_sha = task.init(path, patches, local_version)
@@ -86,7 +87,7 @@ class Executor(PackageInfo, Cleaner):
shutil.copy(artifact, path) shutil.copy(artifact, path)
built.append(path / artifact.name) built.append(path / artifact.name)
else: else:
built = task.build(path, PACKAGER=packager) built = task.build(path, PACKAGER=packager or default_packager)
package.with_packages(built) package.with_packages(built)
for src in built: for src in built:
@@ -116,7 +117,7 @@ class Executor(PackageInfo, Cleaner):
package_base(str): package base name package_base(str): package base name
""" """
try: try:
with self.in_event(package_base, EventType.PackageRemoved): with self.in_event(package_base, EventType.PACKAGE_REMOVED):
self.reporter.package_remove(package_base) self.reporter.package_remove(package_base)
except Exception: except Exception:
self.logger.exception("could not remove base %s", package_base) self.logger.exception("could not remove base %s", package_base)
@@ -168,7 +169,7 @@ class Executor(PackageInfo, Cleaner):
with self.in_package_context(single.base, local_versions.get(single.base)), \ with self.in_package_context(single.base, local_versions.get(single.base)), \
TemporaryDirectory(ignore_cleanup_errors=True) as dir_name: TemporaryDirectory(ignore_cleanup_errors=True) as dir_name:
try: try:
with self.in_event(single.base, EventType.PackageUpdated, failure=EventType.PackageUpdateFailed): with self.in_event(single.base, EventType.PACKAGE_UPDATED, failure=EventType.PACKAGE_UPDATE_FAILED):
packager = self.packager(packagers, single.base) packager = self.packager(packagers, single.base)
local_version = local_versions.get(single.base) if bump_pkgrel else None local_version = local_versions.get(single.base) if bump_pkgrel else None
commit_sha = self._package_build(single, Path(dir_name), packager.packager_id, local_version) commit_sha = self._package_build(single, Path(dir_name), packager.packager_id, local_version)
@@ -57,7 +57,7 @@ class Repository(Executor, UpdateHandler):
@classmethod @classmethod
def load(cls, repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, def load(cls, repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool,
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) -> Self: refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.DISABLED) -> Self:
""" """
load instance from argument list load instance from argument list
@@ -67,7 +67,7 @@ class Repository(Executor, UpdateHandler):
database(SQLite): database instance database(SQLite): database instance
report(bool): force enable or disable reporting report(bool): force enable or disable reporting
refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level
(Default value = PacmanSynchronization.Disabled) (Default value = PacmanSynchronization.DISABLED)
Returns: Returns:
Self: fully loaded repository class instance Self: fully loaded repository class instance
@@ -90,9 +90,9 @@ class RepositoryProperties(EventLogger, LazyLogging):
""" """
username = packagers.for_base(package_base) username = packagers.for_base(package_base)
if username is None: # none to search if username is None: # none to search
return User(username="", password="", access=UserAccess.Read, packager_id=None, key=None) # nosec return User(username="", password="", access=UserAccess.READ, packager_id=None, key=None) # nosec
if (user := self.database.user_get(username)) is not None: # found user if (user := self.database.user_get(username)) is not None: # found user
return user return user
# empty user with the username # empty user with the username
return User(username=username, password="", access=UserAccess.Read, packager_id=None, key=None) # nosec return User(username=username, password="", access=UserAccess.READ, packager_id=None, key=None) # nosec
@@ -36,6 +36,17 @@ class UpdateHandler(PackageInfo, Cleaner):
trait to get package update list trait to get package update list
""" """
def _updates_ignored(self) -> set[str]:
"""
collect package bases excluded from automatic updates
Returns:
set[str]: held and configured ignored package bases
"""
return set(self._ignore_list) | {
package.base for package, status in self.reporter.package_get(None) if status.is_held
}
def updates_aur(self, filter_packages: Iterable[str], *, vcs: bool) -> list[Package]: def updates_aur(self, filter_packages: Iterable[str], *, vcs: bool) -> list[Package]:
""" """
check AUR for updates check AUR for updates
@@ -51,16 +62,14 @@ class UpdateHandler(PackageInfo, Cleaner):
# try to load package from base and if none found try to load by separated packages # try to load package from base and if none found try to load by separated packages
for probe in [package.base] + sorted(package.packages.keys()): for probe in [package.base] + sorted(package.packages.keys()):
try: try:
if package.remote.source == PackageSource.Repository: if package.remote.source == PackageSource.REPOSITORY:
return Package.from_official(probe, self.pacman, None) return Package.from_official(probe, self.pacman, None)
return Package.from_aur(probe, None) return Package.from_aur(probe, None)
except UnknownPackageError: except UnknownPackageError:
continue continue
raise UnknownPackageError(package.base) raise UnknownPackageError(package.base)
ignore_list = self._ignore_list + [ ignore_list = self._updates_ignored()
package.base for package, status in self.reporter.package_get(None) if status.is_held
]
result: list[Package] = [] result: list[Package] = []
for local in self.packages(filter_packages): for local in self.packages(filter_packages):
@@ -76,10 +85,10 @@ class UpdateHandler(PackageInfo, Cleaner):
if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs): if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs):
self.reporter.set_pending(local.base) self.reporter.set_pending(local.base)
self.event(local.base, EventType.PackageOutdated, "Remote version is newer than local") self.event(local.base, EventType.PACKAGE_OUTDATED, "Remote version is newer than local")
result.append(remote) result.append(remote)
else: else:
self.reporter.package_status_update(local.base, BuildStatusEnum.Success) self.reporter.package_status_update(local.base, BuildStatusEnum.SUCCESS)
except Exception: except Exception:
self.reporter.set_failed(local.base) self.reporter.set_failed(local.base)
self.logger.exception("could not load remote package %s", local.base) self.logger.exception("could not load remote package %s", local.base)
@@ -106,8 +115,13 @@ class UpdateHandler(PackageInfo, Cleaner):
return files return files
ignore_list = self._updates_ignored()
result: list[Package] = [] result: list[Package] = []
for local in self.packages(filter_packages): for local in self.packages(filter_packages):
if local.base in ignore_list:
self.logger.info("package %s is held, skip update check", local.base)
continue
dependencies = self.reporter.package_dependencies_get(local.base) dependencies = self.reporter.package_dependencies_get(local.base)
if not dependencies.paths: if not dependencies.paths:
continue # skip check if no package dependencies found continue # skip check if no package dependencies found
@@ -122,7 +136,7 @@ class UpdateHandler(PackageInfo, Cleaner):
# there are no packages found in filesystem with the same paths # there are no packages found in filesystem with the same paths
self.reporter.set_pending(local.base) self.reporter.set_pending(local.base)
self.event(local.base, EventType.PackageOutdated, "Implicit dependencies are broken") self.event(local.base, EventType.PACKAGE_OUTDATED, "Implicit dependencies are broken")
result.append(local) result.append(local)
break break
@@ -141,13 +155,17 @@ class UpdateHandler(PackageInfo, Cleaner):
""" """
packages = {local.base: local for local in self.packages()} packages = {local.base: local for local in self.packages()}
local_versions = {package_base: package.version for package_base, package in packages.items()} local_versions = {package_base: package.version for package_base, package in packages.items()}
ignore_list = self._updates_ignored()
result: list[Package] = [] result: list[Package] = []
for cache_dir in self.paths.cache.iterdir(): for cache_dir in self.paths.cache.iterdir():
if cache_dir.name in ignore_list:
self.logger.info("package %s is held, skip update check", cache_dir.name)
continue
with self.in_package_context(cache_dir.name, local_versions.get(cache_dir.name)): with self.in_package_context(cache_dir.name, local_versions.get(cache_dir.name)):
try: try:
source = RemoteSource( source = RemoteSource(
source=PackageSource.Local, source=PackageSource.LOCAL,
git_url=cache_dir.absolute().as_uri(), git_url=cache_dir.absolute().as_uri(),
web_url="", web_url="",
path=".", path=".",
@@ -162,11 +180,15 @@ class UpdateHandler(PackageInfo, Cleaner):
continue # we don't add packages automatically continue # we don't add packages automatically
if local.remote.is_remote: if local.remote.is_remote:
continue # avoid checking AUR packages continue # avoid checking AUR packages
if local.base in ignore_list:
self.logger.info("package %s is held, skip update check", local.base)
continue
if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs): if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs):
self.reporter.set_pending(local.base) self.reporter.set_pending(local.base)
self.event(local.base, EventType.PackageOutdated, "Locally pulled sources are outdated") self.event(local.base, EventType.PACKAGE_OUTDATED, "Locally pulled sources are outdated")
result.append(remote) result.append(remote)
except Exception: except Exception:
self.logger.exception("could not process package at %s", cache_dir) self.logger.exception("could not process package at %s", cache_dir)
@@ -189,9 +211,8 @@ class UpdateHandler(PackageInfo, Cleaner):
self.reporter.set_unknown(local) self.reporter.set_unknown(local)
else: else:
self.reporter.set_pending(local.base) self.reporter.set_pending(local.base)
self.event(local.base, EventType.PackageOutdated, "Manual update is requested") self.event(local.base, EventType.PACKAGE_OUTDATED, "Manual update is requested")
self.clear_queue()
except Exception: except Exception:
self.logger.exception("could not load packages from database") self.logger.exception("could not load packages from database")
+4 -4
View File
@@ -53,7 +53,7 @@ class GPG(SyncHttpClient):
Returns: Returns:
list[str]: command line arguments for repo-add command to sign database list[str]: command line arguments for repo-add command to sign database
""" """
if SignSettings.Repository not in self.targets: if SignSettings.REPOSITORY not in self.targets:
return [] return []
if self.default_key is None: if self.default_key is None:
self.logger.error("no default key set, skip repository sign") self.logger.error("no default key set, skip repository sign")
@@ -88,7 +88,7 @@ class GPG(SyncHttpClient):
targets: set[SignSettings] = set() targets: set[SignSettings] = set()
for option in configuration.getlist("sign", "target", fallback=[]): for option in configuration.getlist("sign", "target", fallback=[]):
target = SignSettings.from_option(option) target = SignSettings.from_option(option)
if target == SignSettings.Disabled: if target == SignSettings.DISABLED:
continue continue
targets.add(target) targets.add(target)
default_key = configuration.get("sign", "key") if targets else None default_key = configuration.get("sign", "key") if targets else None
@@ -204,7 +204,7 @@ class GPG(SyncHttpClient):
# the file was already signed before, just use its signature # the file was already signed before, just use its signature
return [path, signature] return [path, signature]
if SignSettings.Packages not in self.targets: if SignSettings.PACKAGES not in self.targets:
return [path] return [path]
key = packager_key or self.default_key key = packager_key or self.default_key
@@ -226,7 +226,7 @@ class GPG(SyncHttpClient):
Returns: Returns:
list[Path]: list of generated files including original file list[Path]: list of generated files including original file
""" """
if SignSettings.Repository not in self.targets: if SignSettings.REPOSITORY not in self.targets:
return [path] return [path]
if self.default_key is None: if self.default_key is None:
self.logger.error("no default key set, skip repository sign") self.logger.error("no default key set, skip repository sign")
@@ -341,7 +341,7 @@ class Client:
Args: Args:
package_base(str): package base to update package_base(str): package base to update
""" """
self.package_status_update(package_base, BuildStatusEnum.Building) self.package_status_update(package_base, BuildStatusEnum.BUILDING)
def set_failed(self, package_base: str) -> None: def set_failed(self, package_base: str) -> None:
""" """
@@ -350,7 +350,7 @@ class Client:
Args: Args:
package_base(str): package base to update package_base(str): package base to update
""" """
self.package_status_update(package_base, BuildStatusEnum.Failed) self.package_status_update(package_base, BuildStatusEnum.FAILED)
def set_pending(self, package_base: str) -> None: def set_pending(self, package_base: str) -> None:
""" """
@@ -359,7 +359,7 @@ class Client:
Args: Args:
package_base(str): package base to update package_base(str): package base to update
""" """
self.package_status_update(package_base, BuildStatusEnum.Pending) self.package_status_update(package_base, BuildStatusEnum.PENDING)
def set_success(self, package: Package) -> None: def set_success(self, package: Package) -> None:
""" """
@@ -368,7 +368,7 @@ class Client:
Args: Args:
package(Package): current package properties package(Package): current package properties
""" """
self.package_update(package, BuildStatusEnum.Success) self.package_update(package, BuildStatusEnum.SUCCESS)
def set_unknown(self, package: Package) -> None: def set_unknown(self, package: Package) -> None:
""" """
@@ -380,7 +380,7 @@ class Client:
""" """
if self.package_get(package.base): if self.package_get(package.base):
return # skip update in case if package is already known return # skip update in case if package is already known
self.package_update(package, BuildStatusEnum.Unknown) self.package_update(package, BuildStatusEnum.UNKNOWN)
def statistics(self) -> RepositoryStats: def statistics(self) -> RepositoryStats:
""" """
@@ -197,7 +197,7 @@ class Watcher(LazyLogging):
self._known[package_base] = (package, replace(status, is_held=enabled)) self._known[package_base] = (package, replace(status, is_held=enabled))
self.client.package_hold_update(package_base, enabled=enabled) self.client.package_hold_update(package_base, enabled=enabled)
await self.event_bus.broadcast(EventType.PackageHeld, package_base, is_held=enabled) await self.event_bus.broadcast(EventType.PACKAGE_HELD, package_base, is_held=enabled)
async def package_logs_add(self, log_record: LogRecord) -> None: async def package_logs_add(self, log_record: LogRecord) -> None:
""" """
@@ -208,7 +208,7 @@ class Watcher(LazyLogging):
""" """
self.client.package_logs_add(log_record) self.client.package_logs_add(log_record)
await self.event_bus.broadcast(EventType.BuildLog, log_record.log_record_id.package_base, **log_record.view()) await self.event_bus.broadcast(EventType.BUILD_LOG, log_record.log_record_id.package_base, **log_record.view())
async def package_logs_get(self, package_base: str, version: str | None = None, process_id: str | None = None, async def package_logs_get(self, package_base: str, version: str | None = None, process_id: str | None = None,
limit: int = -1, offset: int = 0) -> list[LogRecord]: limit: int = -1, offset: int = 0) -> list[LogRecord]:
@@ -281,7 +281,7 @@ class Watcher(LazyLogging):
self._known.pop(package_base, None) self._known.pop(package_base, None)
self.client.package_remove(package_base) self.client.package_remove(package_base)
await self.event_bus.broadcast(EventType.PackageRemoved, package_base) await self.event_bus.broadcast(EventType.PACKAGE_REMOVED, package_base)
async def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None: async def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None:
""" """
@@ -296,7 +296,7 @@ class Watcher(LazyLogging):
self._known[package_base] = (package, BuildStatus(status, is_held=current_status.is_held)) self._known[package_base] = (package, BuildStatus(status, is_held=current_status.is_held))
self.client.package_status_update(package_base, status) self.client.package_status_update(package_base, status)
await self.event_bus.broadcast(EventType.PackageStatusChanged, package_base, status=status.value) await self.event_bus.broadcast(EventType.PACKAGE_STATUS_CHANGED, package_base, status=status.value)
async def package_update(self, package: Package, status: BuildStatusEnum) -> None: async def package_update(self, package: Package, status: BuildStatusEnum) -> None:
""" """
@@ -312,7 +312,7 @@ class Watcher(LazyLogging):
self.client.package_update(package, status) self.client.package_update(package, status)
await self.event_bus.broadcast( await self.event_bus.broadcast(
EventType.PackageUpdated, package.base, status=status.value, version=package.version, EventType.PACKAGE_UPDATED, package.base, status=status.value, version=package.version,
) )
async def packages(self) -> list[tuple[Package, BuildStatus]]: async def packages(self) -> list[tuple[Package, BuildStatus]]:
@@ -340,7 +340,7 @@ class Watcher(LazyLogging):
""" """
self.status = BuildStatus(status) self.status = BuildStatus(status)
await self.event_bus.broadcast(EventType.ServiceStatusChanged, None, status=status.value) await self.event_bus.broadcast(EventType.SERVICE_STATUS_CHANGED, None, status=status.value)
def __call__(self, package_base: str | None) -> Self: def __call__(self, package_base: str | None) -> Self:
""" """
+6 -1
View File
@@ -22,7 +22,7 @@ from __future__ import annotations
from collections.abc import Iterable from collections.abc import Iterable
from functools import partial from functools import partial
from ahriman.core.exceptions import PartitionError from ahriman.core.exceptions import DependencyResolutionError, PartitionError
from ahriman.core.utils import minmax, partition from ahriman.core.utils import minmax, partition
from ahriman.models.package import Package from ahriman.models.package import Package
@@ -226,6 +226,9 @@ class Tree:
Returns: Returns:
list[list[Package]]: sorted list of packages lists based on their dependencies list[list[Package]]: sorted list of packages lists based on their dependencies
Raises:
DependencyResolutionError: dependency cycle prevents ordering packages
""" """
unsorted: list[list[Leaf]] = [] unsorted: list[list[Leaf]] = []
@@ -235,6 +238,8 @@ class Tree:
# additional workaround with partial in order to hide cell-var-from-loop pylint warning # additional workaround with partial in order to hide cell-var-from-loop pylint warning
predicate = partial(Leaf.is_root, packages=unprocessed) predicate = partial(Leaf.is_root, packages=unprocessed)
new_level, unprocessed = partition(unprocessed, predicate) new_level, unprocessed = partition(unprocessed, predicate)
if not new_level:
raise DependencyResolutionError([leaf.package.base for leaf in unprocessed])
unsorted.append(new_level) unsorted.append(new_level)
# move leaves to the end if they are not required at the next level # move leaves to the end if they are not required at the next level
@@ -79,16 +79,16 @@ class Upload(LazyLogging):
""" """
section, provider_name = configuration.gettype(target, repository_id) section, provider_name = configuration.gettype(target, repository_id)
match UploadSettings.from_option(provider_name): match UploadSettings.from_option(provider_name):
case UploadSettings.Rsync: case UploadSettings.RSYNC:
from ahriman.core.upload.rsync import Rsync from ahriman.core.upload.rsync import Rsync
return Rsync(repository_id, configuration, section) return Rsync(repository_id, configuration, section)
case UploadSettings.S3: case UploadSettings.S3:
from ahriman.core.upload.s3 import S3 from ahriman.core.upload.s3 import S3
return S3(repository_id, configuration, section) return S3(repository_id, configuration, section)
case UploadSettings.GitHub: case UploadSettings.GITHUB:
from ahriman.core.upload.github import GitHub from ahriman.core.upload.github import GitHub
return GitHub(repository_id, configuration, section) return GitHub(repository_id, configuration, section)
case UploadSettings.RemoteService: case UploadSettings.REMOTE_SERVICE:
from ahriman.core.upload.remote_service import RemoteService from ahriman.core.upload.remote_service import RemoteService
return RemoteService(repository_id, configuration, section) return RemoteService(repository_id, configuration, section)
case _: case _:
-15
View File
@@ -31,7 +31,6 @@ import subprocess
from collections.abc import Callable, Iterable, Iterator, Mapping from collections.abc import Callable, Iterable, Iterator, Mapping
from dataclasses import asdict from dataclasses import asdict
from enum import Enum
from filelock import FileLock from filelock import FileLock
from pathlib import Path from pathlib import Path
from pwd import getpwuid from pwd import getpwuid
@@ -46,7 +45,6 @@ __all__ = [
"check_output", "check_output",
"check_user", "check_user",
"dataclass_view", "dataclass_view",
"enum_values",
"extract_user", "extract_user",
"filelock", "filelock",
"filter_json", "filter_json",
@@ -242,19 +240,6 @@ def dataclass_view(instance: Any) -> dict[str, Any]:
return asdict(instance, dict_factory=lambda fields: {key: value for key, value in fields if value is not None}) return asdict(instance, dict_factory=lambda fields: {key: value for key, value in fields if value is not None})
def enum_values(enum: type[Enum]) -> list[str]:
"""
generate list of enumeration values from the source
Args:
enum(type[Enum]): source enumeration class
Returns:
list[str]: available enumeration values as string
"""
return [str(key.value) for key in enum] # explicit str conversion for typing
def extract_user() -> str | None: def extract_user() -> str | None:
""" """
extract user from system environment extract user from system environment
+6 -6
View File
@@ -25,11 +25,11 @@ class Action(StrEnum):
base action enumeration base action enumeration
Attributes: Attributes:
List(Action): list available values LIST(Action): list available values
Remove(Action): remove everything from local storage REMOVE(Action): remove everything from local storage
Update(Action): update local storage or add to UPDATE(Action): update local storage or add to
""" """
List = "list" LIST = "list"
Remove = "remove" REMOVE = "remove"
Update = "update" UPDATE = "update"
@@ -27,15 +27,15 @@ class AuthSettings(StrEnum):
web authorization type web authorization type
Attributes: Attributes:
Disabled(AuthSettings): authorization is disabled DISABLED(AuthSettings): authorization is disabled
Configuration(AuthSettings): configuration based authorization CONFIGURATION(AuthSettings): configuration based authorization
OAuth(AuthSettings): OAuth based provider OAUTH(AuthSettings): OAuth based provider
PAM(AuthSettings): PAM based provider PAM(AuthSettings): PAM based provider
""" """
Disabled = "disabled" DISABLED = "disabled"
Configuration = "configuration" CONFIGURATION = "configuration"
OAuth = "oauth2" OAUTH = "oauth2"
PAM = "pam" PAM = "pam"
@property @property
@@ -46,7 +46,7 @@ class AuthSettings(StrEnum):
Returns: Returns:
bool: ``False`` in case if authorization is disabled and ``True`` otherwise bool: ``False`` in case if authorization is disabled and ``True`` otherwise
""" """
return self != AuthSettings.Disabled return self != AuthSettings.DISABLED
@staticmethod @staticmethod
def from_option(value: str) -> AuthSettings: def from_option(value: str) -> AuthSettings:
@@ -61,10 +61,10 @@ class AuthSettings(StrEnum):
""" """
match value.lower(): match value.lower():
case "configuration" | "mapping": case "configuration" | "mapping":
return AuthSettings.Configuration return AuthSettings.CONFIGURATION
case "oauth" | "oauth2": case "oauth" | "oauth2":
return AuthSettings.OAuth return AuthSettings.OAUTH
case "pam": case "pam":
return AuthSettings.PAM return AuthSettings.PAM
case _: case _:
return AuthSettings.Disabled return AuthSettings.DISABLED
@@ -0,0 +1,196 @@
#
# 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:
BROKEN_IMPLICIT_DEPENDENCY(BuildPlanReason): package has a broken implicit dependency
LOCAL_SOURCE_UPDATE(BuildPlanReason): locally sourced package has an update
MANUAL_REQUEST(BuildPlanReason): package was manually queued
PRE_BUILT(BuildPlanReason): package has already been built
REBUILD(BuildPlanReason): package was selected for rebuild
REGULAR_UPDATE(BuildPlanReason): package has an AUR update
REQUIRED_BY(BuildPlanReason): package is required by another selected package
"""
BROKEN_IMPLICIT_DEPENDENCY = "broken implicit dependency"
LOCAL_SOURCE_UPDATE = "local source update"
MANUAL_REQUEST = "manual request"
PRE_BUILT = "pre-built"
REBUILD = "rebuild"
REGULAR_UPDATE = "regular update"
REQUIRED_BY = "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 = BuildPlanReason.MANUAL_REQUEST,
requester: str | None = None) -> BuildPlanItem:
"""
add or update a package while preserving its first reason and requester
Args:
package(Package): package selected for the plan
reason(BuildPlanReason, optional): reason for selecting it (Default value = BuildPlanReason.MANUAL_REQUEST)
requester(str | None, optional): package requiring this dependency (Default value = None)
Returns:
BuildPlanItem: plan item for the package
"""
if (existing := self._items.get(package.base)) is not None:
reason, requester = existing.reason, existing.requester
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 remove(self, package_base: str) -> None:
"""
remove a package from the plan
Args:
package_base(str): package base to remove
"""
del self._items[package_base]
def update(self, packages: Iterable[Package], reason: BuildPlanReason = BuildPlanReason.MANUAL_REQUEST,
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, optional): reason for selecting it (Default value = BuildPlanReason.MANUAL_REQUEST)
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)
+11 -11
View File
@@ -29,18 +29,18 @@ class BuildStatusEnum(StrEnum):
build status enumeration build status enumeration
Attributes: Attributes:
Unknown(BuildStatusEnum): build status is unknown UNKNOWN(BuildStatusEnum): build status is unknown
Pending(BuildStatusEnum): package is out-of-dated and will be built soon PENDING(BuildStatusEnum): package is out-of-dated and will be built soon
Building(BuildStatusEnum): package is building right now BUILDING(BuildStatusEnum): package is building right now
Failed(BuildStatusEnum): package build failed FAILED(BuildStatusEnum): package build failed
Success(BuildStatusEnum): package has been built without errors SUCCESS(BuildStatusEnum): package has been built without errors
""" """
Unknown = "unknown" UNKNOWN = "unknown"
Pending = "pending" PENDING = "pending"
Building = "building" BUILDING = "building"
Failed = "failed" FAILED = "failed"
Success = "success" SUCCESS = "success"
@dataclass(frozen=True) @dataclass(frozen=True)
@@ -54,7 +54,7 @@ class BuildStatus:
is_held(bool | None): whether package held or not is_held(bool | None): whether package held or not
""" """
status: BuildStatusEnum = BuildStatusEnum.Unknown status: BuildStatusEnum = BuildStatusEnum.UNKNOWN
timestamp: int = field(default_factory=lambda: int(utcnow().timestamp())) timestamp: int = field(default_factory=lambda: int(utcnow().timestamp()))
is_held: bool | None = field(default=None, kw_only=True) is_held: bool | None = field(default=None, kw_only=True)
+17 -17
View File
@@ -28,24 +28,24 @@ class EventType(StrEnum):
predefined event types predefined event types
Attributes: Attributes:
BuildLog(EventType): new build log line BUILD_LOG(EventType): new build log line
PackageHeld(EventType): package hold status has been changed PACKAGE_HELD(EventType): package hold status has been changed
PackageOutdated(EventType): package has been marked as out-of-date PACKAGE_OUTDATED(EventType): package has been marked as out-of-date
PackageRemoved(EventType): package has been removed PACKAGE_REMOVED(EventType): package has been removed
PackageStatusChanged(EventType): package build status has been changed PACKAGE_STATUS_CHANGED(EventType): package build status has been changed
PackageUpdateFailed(EventType): package update has been failed PACKAGE_UPDATE_FAILED(EventType): package update has been failed
PackageUpdated(EventType): package has been updated PACKAGE_UPDATED(EventType): package has been updated
ServiceStatusChanged(EventType): service status has been changed SERVICE_STATUS_CHANGED(EventType): service status has been changed
""" """
BuildLog = "build-log" BUILD_LOG = "build-log"
PackageHeld = "package-held" PACKAGE_HELD = "package-held"
PackageOutdated = "package-outdated" PACKAGE_OUTDATED = "package-outdated"
PackageRemoved = "package-removed" PACKAGE_REMOVED = "package-removed"
PackageStatusChanged = "package-status-changed" PACKAGE_STATUS_CHANGED = "package-status-changed"
PackageUpdateFailed = "package-update-failed" PACKAGE_UPDATE_FAILED = "package-update-failed"
PackageUpdated = "package-updated" PACKAGE_UPDATED = "package-updated"
ServiceStatusChanged = "service-status-changed" SERVICE_STATUS_CHANGED = "service-status-changed"
class Event: class Event:
@@ -61,7 +61,7 @@ class Event:
""" """
def __init__(self, event: str | EventType, object_id: str, message: str | None = None, created: int | None = None, def __init__(self, event: str | EventType, object_id: str, message: str | None = None, created: int | None = None,
**kwargs: Any): **kwargs: Any) -> None:
""" """
Args: Args:
event(str | EventType): event type event(str | EventType): event type
@@ -25,11 +25,11 @@ class LogHandler(StrEnum):
log handler as described by default configuration log handler as described by default configuration
Attributes: Attributes:
Console(LogHandler): write logs to console CONSOLE(LogHandler): write logs to console
Syslog(LogHandler): write logs to syslog device /dev/null SYSLOG(LogHandler): write logs to syslog device /dev/null
Journald(LogHandler): write logs to journald directly JOURNALD(LogHandler): write logs to journald directly
""" """
Console = "console" CONSOLE = "console"
Syslog = "syslog" SYSLOG = "syslog"
Journald = "journald" JOURNALD = "journald"
@@ -50,13 +50,8 @@ class LogRecord:
Returns: Returns:
Self: log record object Self: log record object
""" """
if "process_id" in dump:
log_record_id = LogRecordId(package_base, dump["version"], dump["process_id"])
else:
log_record_id = LogRecordId(package_base, dump["version"])
return cls( return cls(
log_record_id=log_record_id, log_record_id=LogRecordId(package_base, dump["version"], dump.get("process_id", "")),
created=dump["created"], created=dump["created"],
message=dump["message"], message=dump["message"],
) )
+6 -6
View File
@@ -62,10 +62,10 @@ class Package(LazyLogging):
The specific class load method must be defined based on the source provided. The following methods (mostly) must The specific class load method must be defined based on the source provided. The following methods (mostly) must
be used: :func:`from_archive()`, :func:`from_aur()`, :func:`from_build()`, :func:`from_official()` for sources be used: :func:`from_archive()`, :func:`from_aur()`, :func:`from_build()`, :func:`from_official()` for sources
:attr:`ahriman.models.package_source.PackageSource.Archive`, :attr:`ahriman.models.package_source.PackageSource.ARCHIVE`,
:attr:`ahriman.models.package_source.PackageSource.AUR`, :attr:`ahriman.models.package_source.PackageSource.AUR`,
:attr:`ahriman.models.package_source.PackageSource.Local` and :attr:`ahriman.models.package_source.PackageSource.LOCAL` and
:attr:`ahriman.models.package_source.PackageSource.Repository` respectively: :attr:`ahriman.models.package_source.PackageSource.REPOSITORY` respectively:
>>> ahriman_package = Package.from_aur("ahriman") >>> ahriman_package = Package.from_aur("ahriman")
>>> pacman_package = Package.from_official("pacman", pacman) >>> pacman_package = Package.from_official("pacman", pacman)
@@ -192,7 +192,7 @@ class Package(LazyLogging):
return cls( return cls(
base=package.base or package.name, base=package.base or package.name,
version=package.version, version=package.version,
remote=RemoteSource(source=PackageSource.Archive), remote=RemoteSource(source=PackageSource.ARCHIVE),
packages={package.name: description}, packages={package.name: description},
packager=package.packager, packager=package.packager,
) )
@@ -255,7 +255,7 @@ class Package(LazyLogging):
version = full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"]) version = full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
remote = RemoteSource( remote = RemoteSource(
source=PackageSource.Local, source=PackageSource.LOCAL,
git_url=path.absolute().as_uri(), git_url=path.absolute().as_uri(),
web_url=None, web_url=None,
path=".", path=".",
@@ -315,7 +315,7 @@ class Package(LazyLogging):
package = impl.info(name, pacman=pacman, include_provides=include_provides) package = impl.info(name, pacman=pacman, include_provides=include_provides)
remote = RemoteSource( remote = RemoteSource(
source=PackageSource.Repository, source=PackageSource.REPOSITORY,
git_url=Official.remote_git_url(package.package_base, package.repository), git_url=Official.remote_git_url(package.package_base, package.repository),
web_url=Official.remote_web_url(package.package_base), web_url=Official.remote_web_url(package.package_base),
path=".", path=".",
@@ -32,31 +32,31 @@ class PackageSource(StrEnum):
package source for addition enumeration package source for addition enumeration
Attributes: Attributes:
Auto(PackageSource): automatically determine type of the source AUTO(PackageSource): automatically determine type of the source
Archive(PackageSource): source is a package archive ARCHIVE(PackageSource): source is a package archive
AUR(PackageSource): source is an AUR package for which it should search AUR(PackageSource): source is an AUR package for which it should search
Directory(PackageSource): source is a directory which contains packages DIRECTORY(PackageSource): source is a directory which contains packages
Local(PackageSource): source is locally stored PKGBUILD LOCAL(PackageSource): source is locally stored PKGBUILD
Remote(PackageSource): source is remote (http, ftp etc...) link REMOTE(PackageSource): source is remote (http, ftp etc...) link
Repository(PackageSource): source is official repository REPOSITORY(PackageSource): source is official repository
Examples: Examples:
In case if source is unknown the :func:`resolve()` and the source In case if source is unknown the :func:`resolve()` and the source
descriptor is available method must be used:: descriptor is available method must be used::
>>> real_source = PackageSource.Auto.resolve("ahriman", configuration.repository_paths) >>> real_source = PackageSource.AUTO.resolve("ahriman", configuration.repository_paths)
the code above will ensure that the presudo-source :attr:`Auto` the code above will ensure that the presudo-source :attr:`AUTO`
will not be processed later. will not be processed later.
""" """
Auto = "auto" AUTO = "auto"
Archive = "archive" ARCHIVE = "archive"
AUR = "aur" AUR = "aur"
Directory = "directory" DIRECTORY = "directory"
Local = "local" LOCAL = "local"
Remote = "remote" REMOTE = "remote"
Repository = "repository" REPOSITORY = "repository"
def resolve(self, source: str, paths: RepositoryPaths) -> PackageSource: def resolve(self, source: str, paths: RepositoryPaths) -> PackageSource:
""" """
@@ -69,21 +69,21 @@ class PackageSource(StrEnum):
Returns: Returns:
PackageSource: non-auto type of the package source PackageSource: non-auto type of the package source
""" """
if self != PackageSource.Auto: if self != PackageSource.AUTO:
return self return self
maybe_url = urlparse(source) # handle file:// like paths maybe_url = urlparse(source) # handle file:// like paths
maybe_path = Path(maybe_url.path) maybe_path = Path(maybe_url.path)
if maybe_url.scheme and maybe_url.scheme not in ("data", "file") and package_like(maybe_path): if maybe_url.scheme and maybe_url.scheme not in ("data", "file") and package_like(maybe_path):
return PackageSource.Remote return PackageSource.REMOTE
try: try:
if (maybe_path / "PKGBUILD").is_file() or paths.cache_for(source).is_dir(): if (maybe_path / "PKGBUILD").is_file() or paths.cache_for(source).is_dir():
return PackageSource.Local return PackageSource.LOCAL
if maybe_path.is_dir(): if maybe_path.is_dir():
return PackageSource.Directory return PackageSource.DIRECTORY
if maybe_path.is_file() and package_like(maybe_path): if maybe_path.is_file() and package_like(maybe_path):
return PackageSource.Archive return PackageSource.ARCHIVE
except PermissionError: except PermissionError:
# in some cases (e.g. if you run from your home directory with sudo) # in some cases (e.g. if you run from your home directory with sudo)
# it will try to read files to which it has no access. # it will try to read files to which it has no access.
@@ -25,11 +25,11 @@ class PacmanSynchronization(IntEnum):
pacman database synchronization flag pacman database synchronization flag
Attributes: Attributes:
Disabled(PacmanSynchronization): do not synchronize local database DISABLED(PacmanSynchronization): do not synchronize local database
Enabled(PacmanSynchronization): synchronize local database (same as pacman -Sy) ENABLED(PacmanSynchronization): synchronize local database (same as pacman -Sy)
Force(PacmanSynchronization): force synchronize local database (same as pacman -Syy) FORCE(PacmanSynchronization): force synchronize local database (same as pacman -Syy)
""" """
Disabled = 0 DISABLED = 0
Enabled = 1 ENABLED = 1
Force = 2 FORCE = 2
+12 -27
View File
@@ -19,12 +19,12 @@
# #
from collections.abc import Iterator, Mapping from collections.abc import Iterator, Mapping
from dataclasses import dataclass from dataclasses import dataclass
from io import StringIO from io import BytesIO
from pathlib import Path from pathlib import Path
from typing import Any, ClassVar, IO, Self from typing import Any, IO, Self
from urllib.parse import urlparse from urllib.parse import urlparse
from ahriman.core.alpm.pkgbuild_parser import PkgbuildParser, PkgbuildToken from ahriman.core.alpm.pkgbuild_parser import PkgbuildParser
from ahriman.core.utils import srcinfo_property_list from ahriman.core.utils import srcinfo_property_list
from ahriman.models.pkgbuild_patch import PkgbuildPatch from ahriman.models.pkgbuild_patch import PkgbuildPatch
@@ -35,14 +35,11 @@ class Pkgbuild(Mapping[str, Any]):
model and proxy for PKGBUILD properties model and proxy for PKGBUILD properties
Attributes: Attributes:
DEFAULT_ENCODINGS(str): (class attribute) default encoding to be applied on the file content
fields(dict[str, PkgbuildPatch]): PKGBUILD fields fields(dict[str, PkgbuildPatch]): PKGBUILD fields
""" """
fields: dict[str, PkgbuildPatch] fields: dict[str, PkgbuildPatch]
DEFAULT_ENCODINGS: ClassVar[str] = "utf8"
@property @property
def variables(self) -> dict[str, str]: def variables(self) -> dict[str, str]:
""" """
@@ -59,43 +56,31 @@ class Pkgbuild(Mapping[str, Any]):
} }
@classmethod @classmethod
def from_file(cls, path: Path, encoding: str | None = None) -> Self: def from_file(cls, path: Path) -> Self:
""" """
parse PKGBUILD from the file parse PKGBUILD from the file
Args: Args:
path(Path): path to the PKGBUILD file path(Path): path to the PKGBUILD file
encoding(str | None, optional): the encoding of the file (Default value = None)
Returns: Returns:
Self: constructed instance of self Self: constructed instance of self
Raises:
EncodeError: if encoding is unknown
""" """
# read raw bytes from file
with path.open("rb") as input_file: with path.open("rb") as input_file:
content = input_file.read() return cls.from_io(input_file)
# decode bytes content based on either
encoding = encoding or cls.DEFAULT_ENCODINGS
io = StringIO(content.decode(encoding, errors="backslashreplace"))
return cls.from_io(io)
@classmethod @classmethod
def from_io(cls, stream: IO[str]) -> Self: def from_io(cls, stream: IO[bytes]) -> Self:
""" """
parse PKGBUILD from input stream parse PKGBUILD from input stream
Args: Args:
stream(IO[str]): input stream containing PKGBUILD content stream(IO[bytes]): input stream containing PKGBUILD content
Returns: Returns:
Self: constructed instance of self Self: constructed instance of self
""" """
parser = PkgbuildParser(stream) fields = {patch.key: patch for patch in PkgbuildParser(stream)}
fields = {patch.key: patch for patch in parser.parse()}
# pkgbase is optional field, the pkgname must be used instead if not set # 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, # however, pkgname is not presented is "package()" functions which we are parsing here too,
@@ -162,10 +147,10 @@ class Pkgbuild(Mapping[str, Any]):
""" """
packages = [self["pkgname"]] if isinstance(self["pkgname"], str) else self["pkgname"] packages = [self["pkgname"]] if isinstance(self["pkgname"], str) else self["pkgname"]
def io(package_name: str) -> IO[str]: def io(package_name: str) -> IO[bytes]:
# try to read package specific function and fallback to default otherwise # try to read package specific function and fallback to default otherwise
content = self.get(f"package_{package_name}") or self.get("package") or "" content = self.get(f"package_{package_name}") or self.get("package") or ""
return StringIO(content) return BytesIO(content.encode("utf8"))
return {package: self.from_io(io(package)) for package in packages} return {package: self.from_io(io(package)) for package in packages}
@@ -185,8 +170,8 @@ class Pkgbuild(Mapping[str, Any]):
""" """
value = self.fields.get(item) value = self.fields.get(item)
# if the key wasn't found and user didn't ask for function explicitly, we can try to get by function name # if the key wasn't found and user didn't ask for function explicitly, we can try to get by function name
if value is None and not item.endswith(PkgbuildToken.FunctionDeclaration): if value is None and not item.endswith("()"):
value = self.fields.get(f"{item}{PkgbuildToken.FunctionDeclaration}") value = self.fields.get(f"{item}()")
# if we still didn't find anything, we can just raise the exception # if we still didn't find anything, we can just raise the exception
if value is None: if value is None:
@@ -20,9 +20,10 @@
import json import json
import shlex import shlex
from collections.abc import Iterator
from dataclasses import dataclass, fields from dataclasses import dataclass, fields
from pathlib import Path from pathlib import Path
from typing import Any, Iterator, Self from typing import Any, Self
from ahriman.core.configuration.shell_template import ShellTemplate from ahriman.core.configuration.shell_template import ShellTemplate
from ahriman.core.utils import dataclass_view, filter_json from ahriman.core.utils import dataclass_view, filter_json
@@ -31,9 +31,11 @@ class Property:
value(Any): property value value(Any): property value
is_required(bool): if set to ``True`` then this property is required is_required(bool): if set to ``True`` then this property is required
indent(int): property indentation level indent(int): property indentation level
separator(str | None): optional override for separator
""" """
name: str name: str
value: Any value: Any
is_required: bool = field(default=False, kw_only=True) is_required: bool = field(default=False, kw_only=True)
indent: int = 1 indent: int = 1
separator: str | None = None
@@ -59,7 +59,7 @@ class RemoteSource:
Returns: Returns:
bool: ``True`` in case if package is well-known remote source (e.g. AUR) and ``False`` otherwise bool: ``True`` in case if package is well-known remote source (e.g. AUR) and ``False`` otherwise
""" """
return self.source in (PackageSource.AUR, PackageSource.Repository) return self.source in (PackageSource.AUR, PackageSource.REPOSITORY)
@property @property
def pkgbuild_dir(self) -> Path | None: def pkgbuild_dir(self) -> Path | None:
@@ -27,22 +27,22 @@ class ReportSettings(StrEnum):
report targets enumeration report targets enumeration
Attributes: Attributes:
Disabled(ReportSettings): option which generates no report for testing purpose DISABLED(ReportSettings): option which generates no report for testing purpose
HTML(ReportSettings): HTML report generation HTML(ReportSettings): HTML report generation
Email(ReportSettings): email report generation EMAIL(ReportSettings): email report generation
Console(ReportSettings): print result to console CONSOLE(ReportSettings): print result to console
Telegram(ReportSettings): Markdown report to telegram channel TELEGRAM(ReportSettings): Markdown report to telegram channel
RSS(ReportSettings): RSS report generation RSS(ReportSettings): RSS report generation
RemoteCall(ReportSettings): remote ahriman server call REMOTE_CALL(ReportSettings): remote ahriman server call
""" """
Disabled = "disabled" # for testing purpose DISABLED = "disabled" # for testing purpose
HTML = "html" HTML = "html"
Email = "email" EMAIL = "email"
Console = "console" CONSOLE = "console"
Telegram = "telegram" TELEGRAM = "telegram"
RSS = "rss" RSS = "rss"
RemoteCall = "remote-call" REMOTE_CALL = "remote-call"
@staticmethod @staticmethod
def from_option(value: str) -> ReportSettings: # pylint: disable=too-many-return-statements def from_option(value: str) -> ReportSettings: # pylint: disable=too-many-return-statements
@@ -59,14 +59,14 @@ class ReportSettings(StrEnum):
case "html": case "html":
return ReportSettings.HTML return ReportSettings.HTML
case "email": case "email":
return ReportSettings.Email return ReportSettings.EMAIL
case "console": case "console":
return ReportSettings.Console return ReportSettings.CONSOLE
case "telegram": case "telegram":
return ReportSettings.Telegram return ReportSettings.TELEGRAM
case "rss": case "rss":
return ReportSettings.RSS return ReportSettings.RSS
case "ahriman" | "remote-call": case "ahriman" | "remote-call":
return ReportSettings.RemoteCall return ReportSettings.REMOTE_CALL
case _: case _:
return ReportSettings.Disabled return ReportSettings.DISABLED
@@ -103,7 +103,7 @@ class RepositoryPaths(LazyLogging):
Returns: Returns:
Path: path to directory in which build process is run Path: path to directory in which build process is run
""" """
uid, _ = owner(self.root) uid, _ = self.root_owner
return self.chroot / f"{self.repository_id.name}-{self.repository_id.architecture}" / getpwuid(uid).pw_name return self.chroot / f"{self.repository_id.name}-{self.repository_id.architecture}" / getpwuid(uid).pw_name
@property @property
@@ -127,6 +127,16 @@ class RepositoryPaths(LazyLogging):
# for the chroot directory devtools will create own tree, and we don't have to specify architecture here # for the chroot directory devtools will create own tree, and we don't have to specify architecture here
return self.root / "chroot" / self.repository_id.name return self.root / "chroot" / self.repository_id.name
@property
def configs(self) -> Path:
"""
get directory for local configuration files
Returns:
Path: full path to local configuration directory
"""
return self.root / ".config" / "ahriman"
@property @property
def packages(self) -> Path: def packages(self) -> Path:
""" """
@@ -323,6 +333,7 @@ class RepositoryPaths(LazyLogging):
self.archive, self.archive,
self.cache, self.cache,
self.chroot, self.chroot,
self.configs,
self.packages, self.packages,
self.pacman, self.pacman,
self.repository, self.repository,
@@ -27,14 +27,14 @@ class SignSettings(StrEnum):
sign targets enumeration sign targets enumeration
Attributes: Attributes:
Disabled(SignSettings): option which generates no report for testing purpose DISABLED(SignSettings): option which generates no report for testing purpose
Packages(SignSettings): sign each package PACKAGES(SignSettings): sign each package
Repository(SignSettings): sign repository database file REPOSITORY(SignSettings): sign repository database file
""" """
Disabled = "disabled" DISABLED = "disabled"
Packages = "packages" PACKAGES = "packages"
Repository = "repository" REPOSITORY = "repository"
@staticmethod @staticmethod
def from_option(value: str) -> SignSettings: def from_option(value: str) -> SignSettings:
@@ -49,8 +49,8 @@ class SignSettings(StrEnum):
""" """
match value.lower(): match value.lower():
case "package" | "packages" | "sign-package": case "package" | "packages" | "sign-package":
return SignSettings.Packages return SignSettings.PACKAGES
case "repository" | "sign-repository": case "repository" | "sign-repository":
return SignSettings.Repository return SignSettings.REPOSITORY
case _: case _:
return SignSettings.Disabled return SignSettings.DISABLED
@@ -27,12 +27,12 @@ class SmtpSSLSettings(StrEnum):
SMTP SSL mode enumeration SMTP SSL mode enumeration
Attributes: Attributes:
Disabled(SmtpSSLSettings): no SSL enabled DISABLED(SmtpSSLSettings): no SSL enabled
SSL(SmtpSSLSettings): use SMTP_SSL instead of normal SMTP client SSL(SmtpSSLSettings): use SMTP_SSL instead of normal SMTP client
STARTTLS(SmtpSSLSettings): use STARTTLS in normal SMTP client STARTTLS(SmtpSSLSettings): use STARTTLS in normal SMTP client
""" """
Disabled = "disabled" DISABLED = "disabled"
SSL = "ssl" SSL = "ssl"
STARTTLS = "starttls" STARTTLS = "starttls"
@@ -53,4 +53,4 @@ class SmtpSSLSettings(StrEnum):
case "starttls": case "starttls":
return SmtpSSLSettings.STARTTLS return SmtpSSLSettings.STARTTLS
case _: case _:
return SmtpSSLSettings.Disabled return SmtpSSLSettings.DISABLED
@@ -27,18 +27,18 @@ class UploadSettings(StrEnum):
remote synchronization targets enumeration remote synchronization targets enumeration
Attributes: Attributes:
Disabled(UploadSettings): no sync will be performed, required for testing purpose DISABLED(UploadSettings): no sync will be performed, required for testing purpose
Rsync(UploadSettings): sync via rsync RSYNC(UploadSettings): sync via rsync
S3(UploadSettings): sync to Amazon S3 S3(UploadSettings): sync to Amazon S3
GitHub(UploadSettings): sync to GitHub releases page GITHUB(UploadSettings): sync to GitHub releases page
RemoteService(UploadSettings): sync to another ahriman instance REMOTE_SERVICE(UploadSettings): sync to another ahriman instance
""" """
Disabled = "disabled" # for testing purpose DISABLED = "disabled" # for testing purpose
Rsync = "rsync" RSYNC = "rsync"
S3 = "s3" S3 = "s3"
GitHub = "github" GITHUB = "github"
RemoteService = "remote-service" REMOTE_SERVICE = "remote-service"
@staticmethod @staticmethod
def from_option(value: str) -> UploadSettings: def from_option(value: str) -> UploadSettings:
@@ -53,12 +53,12 @@ class UploadSettings(StrEnum):
""" """
match value.lower(): match value.lower():
case "rsync": case "rsync":
return UploadSettings.Rsync return UploadSettings.RSYNC
case "s3": case "s3":
return UploadSettings.S3 return UploadSettings.S3
case "github": case "github":
return UploadSettings.GitHub return UploadSettings.GITHUB
case "ahriman" | "remote-service": case "ahriman" | "remote-service":
return UploadSettings.RemoteService return UploadSettings.REMOTE_SERVICE
case _: case _:
return UploadSettings.Disabled return UploadSettings.DISABLED
+2 -2
View File
@@ -43,7 +43,7 @@ class User:
Simply create user from database data and perform required validation:: Simply create user from database data and perform required validation::
>>> password = User.generate_password(24) >>> password = User.generate_password(24)
>>> user = User(username="ahriman", password=password, access=UserAccess.Full) >>> user = User(username="ahriman", password=password, access=UserAccess.FULL)
Since the password supplied may be plain text, the :func:`hash_password()` method can be used to hash Since the password supplied may be plain text, the :func:`hash_password()` method can be used to hash
the password:: the password::
@@ -59,7 +59,7 @@ class User:
...and finally access can be verified:: ...and finally access can be verified::
>>> if user.verify_access(UserAccess.Read): >>> if user.verify_access(UserAccess.READ):
>>> print(f"user {user.username} has read access") >>> print(f"user {user.username} has read access")
""" """
@@ -27,17 +27,17 @@ class UserAccess(StrEnum):
web user access enumeration web user access enumeration
Attributes: Attributes:
Unauthorized(UserAccess): user can access specific resources which are marked as available UNAUTHORIZED(UserAccess): user can access specific resources which are marked as available
without authorization (e.g. login, logout, static) without authorization (e.g. login, logout, static)
Read(UserAccess): user can read the page READ(UserAccess): user can read the page
Reporter(UserAccess): user can read everything and is able to perform some modifications REPORTER(UserAccess): user can read everything and is able to perform some modifications
Full(UserAccess): user has full access FULL(UserAccess): user has full access
""" """
Unauthorized = "unauthorized" UNAUTHORIZED = "unauthorized"
Read = "read" READ = "read"
Reporter = "reporter" REPORTER = "reporter"
Full = "full" FULL = "full"
def permits(self, other: UserAccess) -> bool: def permits(self, other: UserAccess) -> bool:
""" """
@@ -4,8 +4,10 @@ from typing import Any
from unittest.mock import MagicMock, call as MockCall from unittest.mock import MagicMock, call as MockCall
from ahriman.application.application import Application 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 import Package
from ahriman.models.package_description import PackageDescription
from ahriman.models.result import Result from ahriman.models.result import Result
@@ -54,13 +56,11 @@ def test_print_updates(application: Application, package_ahriman: Package, mocke
""" """
must print updates must print updates
""" """
tree = Tree([Leaf(package_ahriman)])
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[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") print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application.print_updates([package_ahriman], log_fn=print) application.print_updates(BuildPlan().update([package_ahriman], BuildPlanReason.REGULAR_UPDATE), log_fn=print)
print_mock.assert_called_once_with(verbose=True, log_fn=print, separator=" -> ") 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, def test_with_dependencies(application: Application, package_ahriman: Package, package_python_schedule: Package,
@@ -68,14 +68,14 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
""" """
must append list of missing dependencies must append list of missing dependencies
""" """
def create_package_mock(package_base) -> MagicMock: def package(package_base: str) -> MagicMock:
mock = MagicMock() mock = MagicMock()
mock.base = package_base mock.base = package_base
mock.depends_build = [] mock.depends_build = []
mock.packages_full = [package_base] mock.packages_full = [package_base]
return mock return mock
def get_package(name: str | Path, *args: Any, **kwargs: Any) -> Package: def get_package(name: str | Path, *_args: Any, **_kwargs: Any) -> Package:
name = name if isinstance(name, str) else name.name name = name if isinstance(name, str) else name.name
return packages[name] return packages[name]
@@ -88,8 +88,8 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
packages = { packages = {
package_ahriman.base: package_ahriman, package_ahriman.base: package_ahriman,
package_python_schedule.base: package_python_schedule, package_python_schedule.base: package_python_schedule,
"python": create_package_mock("python"), "python": package("python"),
"python-installer": create_package_mock("python-installer"), "python-installer": package("python-installer"),
} }
mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p.name == "python") mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p.name == "python")
@@ -99,8 +99,11 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
return_value={"devtools", "python-build", "python-pytest"}) return_value={"devtools", "python-build", "python-pytest"})
status_client_mock = mocker.patch("ahriman.core.status.Client.set_unknown") 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.REGULAR_UPDATE)
result = application.with_dependencies(plan, process_dependencies=True)
assert {package.base: package for package in result} == packages 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([ package_aur_mock.assert_has_calls([
MockCall(package_python_schedule.base, package_ahriman.packager, include_provides=True), MockCall(package_python_schedule.base, package_ahriman.packager, include_provides=True),
MockCall("python-installer", package_ahriman.packager, include_provides=True), MockCall("python-installer", package_ahriman.packager, include_provides=True),
@@ -117,12 +120,48 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
], any_order=True) ], 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(package_base: str, package_name: str, dependencies: list[str]) -> Package:
return Package(
base=package_base,
version="1-1",
remote=package_ahriman.remote,
packages={package_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.MANUAL_REQUEST)
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.MANUAL_REQUEST
assert plan_item.requester is None
def test_with_dependencies_exception(application: Application, package_ahriman: Package, def test_with_dependencies_exception(application: Application, package_ahriman: Package,
package_python_schedule: Package, mocker: MockerFixture) -> None: package_python_schedule: Package, mocker: MockerFixture) -> None:
""" """
must skip packages if exception occurs must skip packages if exception occurs
""" """
def create_package_mock(package_base) -> MagicMock: def package(package_base: str) -> MagicMock:
mock = MagicMock() mock = MagicMock()
mock.base = package_base mock.base = package_base
mock.depends_build = [] mock.depends_build = []
@@ -132,23 +171,28 @@ def test_with_dependencies_exception(application: Application, package_ahriman:
package_python_schedule.packages = { package_python_schedule.packages = {
package_python_schedule.base: package_python_schedule.packages[package_python_schedule.base] package_python_schedule.base: package_python_schedule.packages[package_python_schedule.base]
} }
package_ahriman.packages[package_ahriman.base].depends = ["devtools", "python", package_python_schedule.base] package_ahriman.packages[package_ahriman.base].depends = ["devtools", package_python_schedule.base]
package_ahriman.packages[package_ahriman.base].make_depends = ["python-build", "python-installer"] package_ahriman.packages[package_ahriman.base].make_depends = ["python-build", "python-installer"]
package_python_installer = package("python-installer")
packages = { packages = {
package_ahriman.base: package_ahriman, package_ahriman.base: package_ahriman,
package_python_schedule.base: package_python_schedule, package_python_schedule.base: package_python_schedule,
"python": create_package_mock("python"), "python": package("python"),
"python-installer": create_package_mock("python-installer"), "python-installer": package_python_installer,
} }
mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p.name == "python") mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p.name == "python")
mocker.patch("ahriman.models.package.Package.from_aur", side_effect=lambda *args: packages[args[0]]) mocker.patch("ahriman.models.package.Package.from_aur", side_effect=lambda *args: packages[args[0]])
mocker.patch("ahriman.models.package.Package.from_build", side_effect=Exception) mocker.patch("ahriman.models.package.Package.from_build", side_effect=Exception)
mocker.patch("ahriman.application.application.Application._known_packages", mocker.patch("ahriman.application.application.Application._known_packages",
return_value={"devtools", "python-build", "python-pytest"}) return_value={"devtools", "python-build"})
failed_mock = mocker.patch("ahriman.core.status.Client.set_failed")
assert not application.with_dependencies([package_ahriman], process_dependencies=True) plan = BuildPlan().update([package_ahriman, package_python_installer], BuildPlanReason.REGULAR_UPDATE)
application.with_dependencies(plan, process_dependencies=True)
assert plan.packages == [package_python_installer]
failed_mock.assert_called_once_with(package_ahriman.base)
def test_with_dependencies_skip(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None: def test_with_dependencies_skip(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
@@ -157,8 +201,9 @@ def test_with_dependencies_skip(application: Application, package_ahriman: Packa
""" """
packages_mock = mocker.patch("ahriman.application.application.Application._known_packages") 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.REGULAR_UPDATE)
assert application.with_dependencies(plan, process_dependencies=False).packages == [package_ahriman]
packages_mock.assert_not_called() 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() packages_mock.assert_not_called()
@@ -167,7 +167,7 @@ def test_add_add_archive(application_packages: ApplicationPackages, package_ahri
""" """
add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_archive") add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_archive")
application_packages.add([package_ahriman.base], PackageSource.Archive, "packager") application_packages.add([package_ahriman.base], PackageSource.ARCHIVE, "packager")
add_mock.assert_called_once_with(package_ahriman.base, "packager") add_mock.assert_called_once_with(package_ahriman.base, "packager")
@@ -189,7 +189,7 @@ def test_add_add_directory(application_packages: ApplicationPackages, package_ah
""" """
add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_directory") add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_directory")
application_packages.add([package_ahriman.base], PackageSource.Directory, "packager") application_packages.add([package_ahriman.base], PackageSource.DIRECTORY, "packager")
add_mock.assert_called_once_with(package_ahriman.base, "packager") add_mock.assert_called_once_with(package_ahriman.base, "packager")
@@ -200,7 +200,7 @@ def test_add_add_local(application_packages: ApplicationPackages, package_ahrima
""" """
add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_local") add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_local")
application_packages.add([package_ahriman.base], PackageSource.Local, "packager") application_packages.add([package_ahriman.base], PackageSource.LOCAL, "packager")
add_mock.assert_called_once_with(package_ahriman.base, "packager") add_mock.assert_called_once_with(package_ahriman.base, "packager")
@@ -212,7 +212,7 @@ def test_add_add_remote(application_packages: ApplicationPackages, package_descr
add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_remote") add_mock = mocker.patch("ahriman.application.application.application_packages.ApplicationPackages._add_remote")
url = f"https://host/{package_description_ahriman.filename}" url = f"https://host/{package_description_ahriman.filename}"
application_packages.add([url], PackageSource.Remote, "packager") application_packages.add([url], PackageSource.REMOTE, "packager")
add_mock.assert_called_once_with(url, "packager") add_mock.assert_called_once_with(url, "packager")
@@ -188,6 +188,7 @@ def test_update(application_repository: ApplicationRepository, package_ahriman:
""" """
must process package updates must process package updates
""" """
application_repository.database.build_queue_insert(package_ahriman)
paths = [package.filepath for package in package_ahriman.packages.values()] paths = [package.filepath for package in package_ahriman.packages.values()]
tree = Tree([Leaf(package_ahriman)]) tree = Tree([Leaf(package_ahriman)])
prebuilt_result = Result() prebuilt_result = Result()
@@ -207,12 +208,15 @@ def test_update(application_repository: ApplicationRepository, package_ahriman:
update_mock.assert_called_once_with(paths, Packagers("username")) update_mock.assert_called_once_with(paths, Packagers("username"))
on_result_mock.assert_has_calls([MockCall(prebuilt_result), MockCall(result)]) on_result_mock.assert_has_calls([MockCall(prebuilt_result), MockCall(result)])
assert application_repository.database.build_queue_get() == []
def test_update_prebuilt_filter(application_repository: ApplicationRepository, package_ahriman: Package, result: Result, def test_update_prebuilt_filter(application_repository: ApplicationRepository, package_ahriman: Package, result: Result,
mocker: MockerFixture) -> None: mocker: MockerFixture) -> None:
""" """
must filter out packages which were successfully prebuilt must filter out packages which were successfully prebuilt
""" """
application_repository.database.build_queue_insert(package_ahriman)
paths = [package.filepath for package in package_ahriman.packages.values()] paths = [package.filepath for package in package_ahriman.packages.values()]
resolve_mock = mocker.patch("ahriman.application.application.workers.local_updater.LocalUpdater.partition", resolve_mock = mocker.patch("ahriman.application.application.workers.local_updater.LocalUpdater.partition",
@@ -224,6 +228,8 @@ def test_update_prebuilt_filter(application_repository: ApplicationRepository, p
application_repository.update([package_ahriman], Packagers("username"), bump_pkgrel=True) application_repository.update([package_ahriman], Packagers("username"), bump_pkgrel=True)
resolve_mock.assert_called_once_with([]) resolve_mock.assert_called_once_with([])
assert application_repository.database.build_queue_get() == []
def test_update_empty(application_repository: ApplicationRepository, package_ahriman: Package, result: Result, def test_update_empty(application_repository: ApplicationRepository, package_ahriman: Package, result: Result,
mocker: MockerFixture) -> None: mocker: MockerFixture) -> None:
@@ -16,7 +16,7 @@ def test_call(args: argparse.Namespace, configuration: Configuration, mocker: Mo
must call inside lock must call inside lock
""" """
args.configuration = Path("") args.configuration = Path("")
args.log_handler = LogHandler.Console args.log_handler = LogHandler.CONSOLE
args.quiet = False args.quiet = False
args.report = False args.report = False
mocker.patch("ahriman.application.handlers.handler.Handler.run") mocker.patch("ahriman.application.handlers.handler.Handler.run")
@@ -24,7 +24,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
args.package = ["ahriman"] args.package = ["ahriman"]
args.now = False args.now = False
args.refresh = 0 args.refresh = 0
args.source = PackageSource.Auto args.source = PackageSource.AUTO
args.username = "username" args.username = "username"
args.variable = None args.variable = None
return args return args
@@ -21,7 +21,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
Returns: Returns:
argparse.Namespace: generated arguments for these test cases argparse.Namespace: generated arguments for these test cases
""" """
args.action = Action.List args.action = Action.LIST
args.exit_code = False args.exit_code = False
args.info = False args.info = False
args.package = "package" args.package = "package"
@@ -21,7 +21,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
Returns: Returns:
argparse.Namespace: generated arguments for these test cases argparse.Namespace: generated arguments for these test cases
""" """
args.action = Action.List args.action = Action.LIST
args.exit_code = False args.exit_code = False
args.package = "package" args.package = "package"
return args return args
@@ -68,7 +68,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
must remove package changes must remove package changes
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Remove args.action = Action.REMOVE
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update") update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update")
@@ -102,9 +102,9 @@ def test_copy_package(package_ahriman: Package, application: Application, mocker
path = application.repository.paths.repository / package_ahriman.packages[package_ahriman.base].filename path = application.repository.paths.repository / package_ahriman.packages[package_ahriman.base].filename
Copy.copy_package(package_ahriman, application, application) Copy.copy_package(package_ahriman, application, application)
add_mock.assert_called_once_with([str(path)], PackageSource.Archive) add_mock.assert_called_once_with([str(path)], PackageSource.ARCHIVE)
changes_get_mock.assert_called_once_with(package_ahriman.base) changes_get_mock.assert_called_once_with(package_ahriman.base)
changes_update_mock.assert_called_once_with(package_ahriman.base, changes_get_mock.return_value) changes_update_mock.assert_called_once_with(package_ahriman.base, changes_get_mock.return_value)
deps_get_mock.assert_called_once_with(package_ahriman.base) deps_get_mock.assert_called_once_with(package_ahriman.base)
deps_update_mock.assert_called_once_with(package_ahriman.base, deps_get_mock.return_value) deps_update_mock.assert_called_once_with(package_ahriman.base, deps_get_mock.return_value)
package_update_mock.assert_called_once_with(package_ahriman, BuildStatusEnum.Pending) package_update_mock.assert_called_once_with(package_ahriman, BuildStatusEnum.PENDING)
@@ -1,5 +1,4 @@
import argparse import argparse
import pytest
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
@@ -29,7 +28,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
must run command must run command
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Update args.action = Action.UPDATE
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update") hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
@@ -44,7 +43,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
must remove held status must remove held status
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Remove args.action = Action.REMOVE
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update") hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
@@ -38,7 +38,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
must run command must run command
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Update args.action = Action.UPDATE
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
patch_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_create_from_diff", patch_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_create_from_diff",
return_value=(args.package, PkgbuildPatch(None, "patch"))) return_value=(args.package, PkgbuildPatch(None, "patch")))
@@ -56,7 +56,7 @@ def test_run_function(args: argparse.Namespace, configuration: Configuration, re
must run command with patch function flag must run command with patch function flag
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Update args.action = Action.UPDATE
args.patch = "patch" args.patch = "patch"
args.variable = "version" args.variable = "version"
patch = PkgbuildPatch(args.variable, args.patch) patch = PkgbuildPatch(args.variable, args.patch)
@@ -77,7 +77,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, reposi
must run command with list flag must run command with list flag
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.List args.action = Action.LIST
args.variable = ["version"] args.variable = ["version"]
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list") application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list")
@@ -93,7 +93,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
must run command with remove flag must run command with remove flag
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Remove args.action = Action.REMOVE
args.variable = ["version"] args.variable = ["version"]
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove") application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
@@ -169,7 +169,7 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None
Patch.patch_set_list(application, "ahriman", ["version"], False) Patch.patch_set_list(application, "ahriman", ["version"], False)
get_mock.assert_called_once_with("ahriman", None) get_mock.assert_called_once_with("ahriman", None)
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ") print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ")
check_mock.assert_called_once_with(False, [PkgbuildPatch(key='version', value='value')]) check_mock.assert_called_once_with(False, [PkgbuildPatch(key="version", value="value")])
def test_patch_set_list_all(application: Application, mocker: MockerFixture) -> None: def test_patch_set_list_all(application: Application, mocker: MockerFixture) -> None:
@@ -184,7 +184,7 @@ def test_patch_set_list_all(application: Application, mocker: MockerFixture) ->
Patch.patch_set_list(application, "ahriman", None, False) Patch.patch_set_list(application, "ahriman", None, False)
get_mock.assert_called_once_with("ahriman", None) get_mock.assert_called_once_with("ahriman", None)
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ") print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ")
check_mock.assert_called_once_with(False, [PkgbuildPatch(key=None, value='patch')]) check_mock.assert_called_once_with(False, [PkgbuildPatch(key=None, value="patch")])
def test_patch_set_list_empty_exception(application: Application, mocker: MockerFixture) -> None: def test_patch_set_list_empty_exception(application: Application, mocker: MockerFixture) -> None:
@@ -21,7 +21,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
Returns: Returns:
argparse.Namespace: generated arguments for these test cases argparse.Namespace: generated arguments for these test cases
""" """
args.action = Action.List args.action = Action.LIST
args.exit_code = False args.exit_code = False
args.package = "package" args.package = "package"
return args return args
@@ -68,7 +68,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
must remove package pkgbuild must remove package pkgbuild
""" """
args = _default_args(args) args = _default_args(args)
args.action = Action.Remove args.action = Action.REMOVE
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository) mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
changes = Changes("sha", "change", "pkgbuild content") changes = Changes("sha", "change", "pkgbuild content")
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=changes) mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=changes)
@@ -2,12 +2,12 @@ import argparse
import pytest import pytest
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from unittest.mock import call as MockCall
from ahriman.application.application import Application from ahriman.application.application import Application
from ahriman.application.handlers.rebuild import Rebuild from ahriman.application.handlers.rebuild import Rebuild
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.repository import Repository 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.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.package import Package from ahriman.models.package import Package
from ahriman.models.packagers import Packagers 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", application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on",
return_value=[package_ahriman]) return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result) 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") check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start") on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
_, repository_id = configuration.check_loaded() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) 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) 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_packages_mock.assert_called_once_with([package_ahriman], None)
application_mock.assert_called_once_with([package_ahriman], Packagers(args.username), bump_pkgrel=args.increment) print_mock.assert_called_once_with(plan, pytest.helpers.anyvar(int), bump_pkgrel=args.increment)
check_mock.assert_has_calls([MockCall(False, [package_ahriman]), MockCall(False, True)]) 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() 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() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) Rebuild.run(args, repository_id, configuration, report=False)
application_mock.assert_not_called() application_mock.assert_not_called()
check_mock.assert_called_once_with(False, [package_ahriman]) plan = BuildPlan().update([package_ahriman], BuildPlanReason.REBUILD)
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int)) 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, 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.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[]) mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on") 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() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) 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.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[]) mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on") 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() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) 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() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) 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, 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.application.handlers.rebuild.Rebuild.extract_packages")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[package_ahriman]) 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.update", return_value=Result())
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status") check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
_, repository_id = configuration.check_loaded() _, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False) 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: def test_extract_packages(application: Application, mocker: MockerFixture) -> None:
@@ -182,10 +189,10 @@ def test_extract_packages_by_status(application: Application, mocker: MockerFixt
must extract packages from database and filter them by status must extract packages from database and filter them by status
""" """
packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get", return_value=[ packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get", return_value=[
("package1", BuildStatus(BuildStatusEnum.Success)), ("package1", BuildStatus(BuildStatusEnum.SUCCESS)),
("package2", BuildStatus(BuildStatusEnum.Failed)), ("package2", BuildStatus(BuildStatusEnum.FAILED)),
]) ])
assert Rebuild.extract_packages(application, BuildStatusEnum.Failed, from_database=True) == ["package2"] assert Rebuild.extract_packages(application, BuildStatusEnum.FAILED, from_database=True) == ["package2"]
packages_mock.assert_called_once_with(application.repository_id) packages_mock.assert_called_once_with(application.repository_id)
@@ -39,7 +39,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
_, repository_id = configuration.check_loaded() _, repository_id = configuration.check_loaded()
ServiceUpdates.run(args, repository_id, configuration, report=False) ServiceUpdates.run(args, repository_id, configuration, report=False)
package_mock.assert_called_once_with(package_ahriman.base, None) 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) check_mock.assert_called_once_with(args.exit_code, False)
Loaded 100 of 333 files, more files were not shown because too many files have changed in this diff. Show more