Compare commits

...

14 Commits

Author SHA1 Message Date
5bbb9d269b Release 2.6.1 2023-01-25 15:28:27 +02:00
17466d8d37 make oauth client trully optional (#84)
Same old song, after migraiton to packages some optional modules are
being imported globally which lead to making hard dependency
2023-01-25 15:25:42 +02:00
9e4e3b701b enable lock for web service 2023-01-18 01:39:55 +02:00
c6555cf2c7 Release 2.6.0 2023-01-16 01:35:12 +02:00
85baad6a41 add notes about non-x86_64 architecture setup 2023-01-15 18:16:29 +02:00
616a1950ae add ability to override pacman mirror in devtools configuration
This commit also extends configuration of the multilib option, adding
the ability to exlcude multilib repository from repositories list

Note, that in order to support repository list and mirror correctly,
alpm configuration section is now architectture specific
2023-01-15 18:05:15 +02:00
30b9bcb45a add note about other authroization options to gitremote triggers 2023-01-13 17:27:19 +02:00
d7356926c4 consider vcs flag and vcs_allowed_age during local packages update 2023-01-12 15:37:05 +02:00
43a7d09cab add ability to check for service updates 2023-01-12 15:37:05 +02:00
77954b988b subcommand review
Some commands have been moved to another group and thus having another
default name (old subcommands are still available...for now):

* daemon -> repo-daemon
* key-import -> service-key-import
* repo-clean -> service-clean
* repo-config -> service-config
* repo-config-validate -> service-config-validate
* repo-setup -> service-setup
* repo-shell -> service-shell
* version -> help-version
2023-01-12 15:37:05 +02:00
0239fb50b6 expose trigger configuration schema
Note that this commit contains the following breaking changes:

* remote pull and remote push triggers are now enabled by default (with
  empty target list)
* remote pull and remote push triggers now require target option to be
  set (old behaviour had fallback on `gitremote`)
* validation is now considered to be stable, so it is enabled by default
  in docker image (can be disabled however)
2023-01-10 03:33:52 +02:00
d942a70272 add config validator subcommand (#80)
* add config validator subcommand

* add --exit-code flag

* docs & faq update
2023-01-09 18:22:29 +03:00
1f07a89316 sort unsafe commands response 2023-01-04 18:00:10 +02:00
014007ade3 review unsafe commands access
Some commands were made unsafe in old versions, but nowadays they can be
run without having special privileges.

There was also a bug in which status commands were not available if you
are not ahriman user and unix socket is used. It has been fixed by
switching to manual socket creation (see also
https://github.com/aio-libs/aiohttp/issues/4155)
2023-01-04 17:45:44 +02:00
89 changed files with 6847 additions and 4328 deletions

View File

@ -10,7 +10,7 @@ echo -e '[arcanisrepo]\nServer = http://repo.arcanis.me/$arch\nSigLevel = Never'
# refresh the image
pacman --noconfirm -Syu
# main dependencies
pacman --noconfirm -Sy base-devel devtools git pyalpm python-aur python-passlib python-setuptools python-srcinfo sudo
pacman --noconfirm -Sy base-devel devtools git pyalpm python-cerberus python-inflection python-passlib python-requests python-setuptools python-srcinfo sudo
# make dependencies
pacman --noconfirm -Sy python-build python-installer python-wheel
# optional dependencies
@ -38,7 +38,9 @@ systemd-machine-id-setup
sed -i "s/handlers = syslog_handler/handlers = console_handler/g" /etc/ahriman.ini.d/logging.ini
# initial setup command as root
[[ -z $MINIMAL_INSTALL ]] && WEB_ARGS=("--web-port" "8080")
ahriman -a x86_64 repo-setup --packager "ahriman bot <ahriman@example.com>" --repository "github" "${WEB_ARGS[@]}"
ahriman -a x86_64 service-setup --packager "ahriman bot <ahriman@example.com>" --repository "github" "${WEB_ARGS[@]}"
# validate configuration
ahriman -a x86_64 service-config-validate --exit-code
# enable services
systemctl enable ahriman-web@x86_64
systemctl enable ahriman@x86_64.timer

View File

@ -31,13 +31,15 @@ Again, the most checks can be performed by `make check` command, though some add
```python
def foo(argument: str, *, flag: bool = False) -> int:
"""
do foo
do foo. With very very very long
docstring
Note:
Very important note about this function
Args:
argument(str): an argument
argument(str): an argument. This argument has
long description also
flag(bool, optional): a flag (Default value = False)
Returns:
@ -77,9 +79,13 @@ Again, the most checks can be performed by `make check` command, though some add
CLAZZ_ATTRIBUTE = 42
def __init__(self) -> None:
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
default constructor
Args:
*args(Any): positional arguments
**kwargs(Any): keyword arguments
"""
self.instance_attribute = ""
```

View File

@ -5,13 +5,16 @@ ENV AHRIMAN_ARCHITECTURE="x86_64"
ENV AHRIMAN_DEBUG=""
ENV AHRIMAN_FORCE_ROOT=""
ENV AHRIMAN_HOST="0.0.0.0"
ENV AHRIMAN_MULTILIB="yes"
ENV AHRIMAN_OUTPUT="syslog"
ENV AHRIMAN_PACKAGER="ahriman bot <ahriman@example.com>"
ENV AHRIMAN_PACMAN_MIRROR=""
ENV AHRIMAN_PORT=""
ENV AHRIMAN_REPOSITORY="aur-clone"
ENV AHRIMAN_REPOSITORY_ROOT="/var/lib/ahriman/ahriman"
ENV AHRIMAN_UNIX_SOCKET=""
ENV AHRIMAN_USER="ahriman"
ENV AHRIMAN_VALIDATE_CONFIGURATION="yes"
# install environment
## update pacman.conf with multilib
@ -25,7 +28,7 @@ RUN useradd -m -d "/home/build" -s "/usr/bin/nologin" build && \
COPY "docker/install-aur-package.sh" "/usr/local/bin/install-aur-package"
## install package dependencies
## darcs is not installed by reasons, because it requires a lot haskell packages which dramatically increase image size
RUN pacman --noconfirm -Sy devtools git pyalpm python-inflection python-passlib python-requests python-setuptools python-srcinfo && \
RUN pacman --noconfirm -Sy devtools git pyalpm python-cerberus python-inflection python-passlib python-requests python-setuptools python-srcinfo && \
pacman --noconfirm -Sy python-build python-installer python-wheel && \
pacman --noconfirm -Sy breezy mercurial python-aiohttp python-boto3 python-cryptography python-jinja python-requests-unixsocket rsync subversion && \
runuser -u build -- install-aur-package python-aioauth-client python-aiohttp-jinja2 python-aiohttp-debugtoolbar \

View File

@ -39,13 +39,22 @@ chown "$AHRIMAN_USER":"$AHRIMAN_USER" "$AHRIMAN_GNUPG_HOME"
AHRIMAN_SETUP_ARGS=("--build-as-user" "$AHRIMAN_USER")
AHRIMAN_SETUP_ARGS+=("--packager" "$AHRIMAN_PACKAGER")
AHRIMAN_SETUP_ARGS+=("--repository" "$AHRIMAN_REPOSITORY")
if [ -z "$AHRIMAN_MULTILIB" ]; then
AHRIMAN_SETUP_ARGS+=("--no-multilib")
fi
if [ -n "$AHRIMAN_PACMAN_MIRROR" ]; then
AHRIMAN_SETUP_ARGS+=("--mirror" "$AHRIMAN_PACMAN_MIRROR")
fi
if [ -n "$AHRIMAN_PORT" ]; then
AHRIMAN_SETUP_ARGS+=("--web-port" "$AHRIMAN_PORT")
fi
if [ -n "$AHRIMAN_UNIX_SOCKET" ]; then
AHRIMAN_SETUP_ARGS+=("--web-unix-socket" "$AHRIMAN_UNIX_SOCKET")
fi
ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" repo-setup "${AHRIMAN_SETUP_ARGS[@]}"
ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" service-setup "${AHRIMAN_SETUP_ARGS[@]}"
# validate configuration if set
[ -n "$AHRIMAN_VALIDATE_CONFIGURATION" ] && ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" service-config-validate --exit-code
# create machine-id which is required by build tools
systemd-machine-id-setup &> /dev/null

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 641 KiB

After

Width:  |  Height:  |  Size: 673 KiB

View File

@ -1,9 +1,9 @@
.TH AHRIMAN "1" "2023\-01\-03" "ahriman" "Generated Python Manual"
.TH AHRIMAN "1" "2023\-01\-25" "ahriman" "Generated Python Manual"
.SH NAME
ahriman
.SH SYNOPSIS
.B ahriman
[-h] [-a ARCHITECTURE] [-c CONFIGURATION] [--force] [-l LOCK] [--report | --no-report] [-q] [--unsafe] [-V] {aur-search,search,daemon,help,help-commands-unsafe,key-import,package-add,add,package-update,package-remove,remove,package-status,status,package-status-remove,package-status-update,status-update,patch-add,patch-list,patch-remove,patch-set-add,repo-backup,repo-check,check,repo-clean,clean,repo-config,config,repo-rebuild,rebuild,repo-remove-unknown,remove-unknown,repo-report,report,repo-restore,repo-setup,init,repo-init,setup,repo-sign,sign,repo-status-update,repo-sync,sync,repo-tree,repo-triggers,repo-update,update,shell,user-add,user-list,user-remove,version,web} ...
[-h] [-a ARCHITECTURE] [-c CONFIGURATION] [--force] [-l LOCK] [--report | --no-report] [-q] [--unsafe] [-V] {aur-search,search,help,help-commands-unsafe,help-updates,help-version,version,package-add,add,package-update,package-remove,remove,package-status,status,package-status-remove,package-status-update,status-update,patch-add,patch-list,patch-remove,patch-set-add,repo-backup,repo-check,check,repo-daemon,daemon,repo-rebuild,rebuild,repo-remove-unknown,remove-unknown,repo-report,report,repo-restore,repo-sign,sign,repo-status-update,repo-sync,sync,repo-tree,repo-triggers,repo-update,update,service-clean,clean,repo-clean,service-config,config,repo-config,service-config-validate,config-validate,repo-config-validate,service-key-import,key-import,service-setup,init,repo-init,repo-setup,setup,service-shell,shell,user-add,user-list,user-remove,web} ...
.SH DESCRIPTION
ArcH linux ReposItory MANager
@ -46,17 +46,17 @@ COMMAND
\fBahriman\fR \fI\,aur\-search\/\fR
search for package
.TP
\fBahriman\fR \fI\,daemon\/\fR
run application as daemon
.TP
\fBahriman\fR \fI\,help\/\fR
show help message
.TP
\fBahriman\fR \fI\,help\-commands\-unsafe\/\fR
list unsafe commands
.TP
\fBahriman\fR \fI\,key\-import\/\fR
import PGP key
\fBahriman\fR \fI\,help\-updates\/\fR
check for service updates
.TP
\fBahriman\fR \fI\,help\-version\/\fR
application version
.TP
\fBahriman\fR \fI\,package\-add\/\fR
add package
@ -91,11 +91,8 @@ backup repository data
\fBahriman\fR \fI\,repo\-check\/\fR
check for updates
.TP
\fBahriman\fR \fI\,repo\-clean\/\fR
clean local caches
.TP
\fBahriman\fR \fI\,repo\-config\/\fR
dump configuration
\fBahriman\fR \fI\,repo\-daemon\/\fR
run application as daemon
.TP
\fBahriman\fR \fI\,repo\-rebuild\/\fR
rebuild repository
@ -109,9 +106,6 @@ generate report
\fBahriman\fR \fI\,repo\-restore\/\fR
restore repository data
.TP
\fBahriman\fR \fI\,repo\-setup\/\fR
initial service configuration
.TP
\fBahriman\fR \fI\,repo\-sign\/\fR
sign packages
.TP
@ -130,7 +124,22 @@ run triggers
\fBahriman\fR \fI\,repo\-update\/\fR
update packages
.TP
\fBahriman\fR \fI\,shell\/\fR
\fBahriman\fR \fI\,service\-clean\/\fR
clean local caches
.TP
\fBahriman\fR \fI\,service\-config\/\fR
dump configuration
.TP
\fBahriman\fR \fI\,service\-config\-validate\/\fR
validate system configuration
.TP
\fBahriman\fR \fI\,service\-key\-import\/\fR
import PGP key
.TP
\fBahriman\fR \fI\,service\-setup\/\fR
initial service configuration
.TP
\fBahriman\fR \fI\,service\-shell\/\fR
invoke python shell
.TP
\fBahriman\fR \fI\,user\-add\/\fR
@ -142,9 +151,6 @@ user known users and their access
\fBahriman\fR \fI\,user\-remove\/\fR
remove user
.TP
\fBahriman\fR \fI\,version\/\fR
application version
.TP
\fBahriman\fR \fI\,web\/\fR
web server
@ -173,37 +179,6 @@ show additional package information (default: False)
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
.SH COMMAND \fI\,'ahriman daemon'\/\fR
usage: ahriman daemon [\-h] [\-i INTERVAL] [\-\-aur | \-\-no\-aur] [\-\-local | \-\-no\-local] [\-\-manual | \-\-no\-manual]
[\-\-vcs | \-\-no\-vcs] [\-y]
start process which periodically will run update process
.SH OPTIONS \fI\,'ahriman daemon'\/\fR
.TP
\fB\-i\fR \fI\,INTERVAL\/\fR, \fB\-\-interval\fR \fI\,INTERVAL\/\fR
interval between runs in seconds
.TP
\fB\-\-aur\fR, \fB\-\-no\-aur\fR
enable or disable checking for AUR updates. Implies \-\-no\-vcs (default: True)
.TP
\fB\-\-local\fR, \fB\-\-no\-local\fR
enable or disable checking of local packages for updates (default: True)
.TP
\fB\-\-manual\fR, \fB\-\-no\-manual\fR
include or exclude manual updates (default: True)
.TP
\fB\-\-vcs\fR, \fB\-\-no\-vcs\fR
enable or disable checking of VCS packages (default: True)
.TP
\fB\-y\fR, \fB\-\-refresh\fR
download fresh package databases from the mirror before actions, \-yy to force refresh even if up to date
.SH COMMAND \fI\,'ahriman help'\/\fR
usage: ahriman help [\-h] [command]
@ -224,19 +199,20 @@ list unsafe commands as defined in default args
instead of showing commands, just test command line for unsafe subcommand and return 0 in case if command is safe and 1
otherwise
.SH COMMAND \fI\,'ahriman key\-import'\/\fR
usage: ahriman key\-import [\-h] [\-\-key\-server KEY_SERVER] key
.SH COMMAND \fI\,'ahriman help\-updates'\/\fR
usage: ahriman help\-updates [\-h] [\-e]
import PGP key from public sources to the repository user
request AUR for current version and compare with current service version
.SH OPTIONS \fI\,'ahriman help\-updates'\/\fR
.TP
\fBkey\fR
PGP key to import from public server
\fB\-e\fR, \fB\-\-exit\-code\fR
return non\-zero exit code if updates available
.SH OPTIONS \fI\,'ahriman key\-import'\/\fR
.TP
\fB\-\-key\-server\fR \fI\,KEY_SERVER\/\fR
key server for key import
.SH COMMAND \fI\,'ahriman help\-version'\/\fR
usage: ahriman help\-version [\-h]
print application and its dependencies versions
.SH COMMAND \fI\,'ahriman package\-add'\/\fR
usage: ahriman package\-add [\-h] [\-e] [\-n] [\-y] [\-s {auto,archive,aur,directory,local,remote,repository}]
@ -418,43 +394,42 @@ return non\-zero exit status if result is empty
.TP
\fB\-\-vcs\fR, \fB\-\-no\-vcs\fR
enable or disable checking of VCS packages (default: True)
fetch actual version of VCS packages (default: True)
.TP
\fB\-y\fR, \fB\-\-refresh\fR
download fresh package databases from the mirror before actions, \-yy to force refresh even if up to date
.SH COMMAND \fI\,'ahriman repo\-clean'\/\fR
usage: ahriman repo\-clean [\-h] [\-\-cache | \-\-no\-cache] [\-\-chroot | \-\-no\-chroot] [\-\-manual | \-\-no\-manual]
[\-\-packages | \-\-no\-packages] [\-\-pacman | \-\-no\-pacman]
.SH COMMAND \fI\,'ahriman repo\-daemon'\/\fR
usage: ahriman repo\-daemon [\-h] [\-i INTERVAL] [\-\-aur | \-\-no\-aur] [\-\-local | \-\-no\-local] [\-\-manual | \-\-no\-manual]
[\-\-vcs | \-\-no\-vcs] [\-y]
remove local caches
start process which periodically will run update process
.SH OPTIONS \fI\,'ahriman repo\-clean'\/\fR
.SH OPTIONS \fI\,'ahriman repo\-daemon'\/\fR
.TP
\fB\-\-cache\fR, \fB\-\-no\-cache\fR
clear directory with package caches (default: False)
\fB\-i\fR \fI\,INTERVAL\/\fR, \fB\-\-interval\fR \fI\,INTERVAL\/\fR
interval between runs in seconds
.TP
\fB\-\-chroot\fR, \fB\-\-no\-chroot\fR
clear build chroot (default: False)
\fB\-\-aur\fR, \fB\-\-no\-aur\fR
enable or disable checking for AUR updates (default: True)
.TP
\fB\-\-local\fR, \fB\-\-no\-local\fR
enable or disable checking of local packages for updates (default: True)
.TP
\fB\-\-manual\fR, \fB\-\-no\-manual\fR
clear manually added packages queue (default: False)
include or exclude manual updates (default: True)
.TP
\fB\-\-packages\fR, \fB\-\-no\-packages\fR
clear directory with built packages (default: False)
\fB\-\-vcs\fR, \fB\-\-no\-vcs\fR
fetch actual version of VCS packages (default: True)
.TP
\fB\-\-pacman\fR, \fB\-\-no\-pacman\fR
clear directory with pacman local database cache (default: False)
.SH COMMAND \fI\,'ahriman repo\-config'\/\fR
usage: ahriman repo\-config [\-h]
dump configuration for the specified architecture
\fB\-y\fR, \fB\-\-refresh\fR
download fresh package databases from the mirror before actions, \-yy to force refresh even if up to date
.SH COMMAND \fI\,'ahriman repo\-rebuild'\/\fR
usage: ahriman repo\-rebuild [\-h] [\-\-depends\-on DEPENDS_ON] [\-\-dry\-run] [\-\-from\-database] [\-e]
@ -509,60 +484,6 @@ path of the input archive
\fB\-o\fR \fI\,OUTPUT\/\fR, \fB\-\-output\fR \fI\,OUTPUT\/\fR
root path of the extracted files
.SH COMMAND \fI\,'ahriman repo\-setup'\/\fR
usage: ahriman repo\-setup [\-h] [\-\-build\-as\-user BUILD_AS_USER] [\-\-build\-command BUILD_COMMAND]
[\-\-from\-configuration FROM_CONFIGURATION] [\-\-makeflags\-jobs | \-\-no\-makeflags\-jobs]
[\-\-multilib | \-\-no\-multilib] \-\-packager PACKAGER \-\-repository REPOSITORY [\-\-sign\-key SIGN_KEY]
[\-\-sign\-target {disabled,packages,repository}] [\-\-web\-port WEB_PORT]
[\-\-web\-unix\-socket WEB_UNIX_SOCKET]
create initial service configuration, requires root
.SH OPTIONS \fI\,'ahriman repo\-setup'\/\fR
.TP
\fB\-\-build\-as\-user\fR \fI\,BUILD_AS_USER\/\fR
force makepkg user to the specific one
.TP
\fB\-\-build\-command\fR \fI\,BUILD_COMMAND\/\fR
build command prefix
.TP
\fB\-\-from\-configuration\fR \fI\,FROM_CONFIGURATION\/\fR
path to default devtools pacman configuration
.TP
\fB\-\-makeflags\-jobs\fR, \fB\-\-no\-makeflags\-jobs\fR
append MAKEFLAGS variable with parallelism set to number of cores (default: True)
.TP
\fB\-\-multilib\fR, \fB\-\-no\-multilib\fR
add or do not multilib repository (default: True)
.TP
\fB\-\-packager\fR \fI\,PACKAGER\/\fR
packager name and email
.TP
\fB\-\-repository\fR \fI\,REPOSITORY\/\fR
repository name
.TP
\fB\-\-sign\-key\fR \fI\,SIGN_KEY\/\fR
sign key id
.TP
\fB\-\-sign\-target\fR \fI\,{disabled,packages,repository}\/\fR
sign options
.TP
\fB\-\-web\-port\fR \fI\,WEB_PORT\/\fR
port of the web service
.TP
\fB\-\-web\-unix\-socket\fR \fI\,WEB_UNIX_SOCKET\/\fR
path to unix socket used for interprocess communications
.SH COMMAND \fI\,'ahriman repo\-sign'\/\fR
usage: ahriman repo\-sign [\-h] [package ...]
@ -623,7 +544,7 @@ return non\-zero exit status if result is empty
.TP
\fB\-\-aur\fR, \fB\-\-no\-aur\fR
enable or disable checking for AUR updates. Implies \-\-no\-vcs (default: True)
enable or disable checking for AUR updates (default: True)
.TP
\fB\-\-local\fR, \fB\-\-no\-local\fR
@ -635,14 +556,128 @@ include or exclude manual updates (default: True)
.TP
\fB\-\-vcs\fR, \fB\-\-no\-vcs\fR
enable or disable checking of VCS packages (default: True)
fetch actual version of VCS packages (default: True)
.TP
\fB\-y\fR, \fB\-\-refresh\fR
download fresh package databases from the mirror before actions, \-yy to force refresh even if up to date
.SH COMMAND \fI\,'ahriman shell'\/\fR
usage: ahriman shell [\-h] [code]
.SH COMMAND \fI\,'ahriman service\-clean'\/\fR
usage: ahriman service\-clean [\-h] [\-\-cache | \-\-no\-cache] [\-\-chroot | \-\-no\-chroot] [\-\-manual | \-\-no\-manual]
[\-\-packages | \-\-no\-packages] [\-\-pacman | \-\-no\-pacman]
remove local caches
.SH OPTIONS \fI\,'ahriman service\-clean'\/\fR
.TP
\fB\-\-cache\fR, \fB\-\-no\-cache\fR
clear directory with package caches (default: False)
.TP
\fB\-\-chroot\fR, \fB\-\-no\-chroot\fR
clear build chroot (default: False)
.TP
\fB\-\-manual\fR, \fB\-\-no\-manual\fR
clear manually added packages queue (default: False)
.TP
\fB\-\-packages\fR, \fB\-\-no\-packages\fR
clear directory with built packages (default: False)
.TP
\fB\-\-pacman\fR, \fB\-\-no\-pacman\fR
clear directory with pacman local database cache (default: False)
.SH COMMAND \fI\,'ahriman service\-config'\/\fR
usage: ahriman service\-config [\-h]
dump configuration for the specified architecture
.SH COMMAND \fI\,'ahriman service\-config\-validate'\/\fR
usage: ahriman service\-config\-validate [\-h] [\-e]
validate configuration and print found errors
.SH OPTIONS \fI\,'ahriman service\-config\-validate'\/\fR
.TP
\fB\-e\fR, \fB\-\-exit\-code\fR
return non\-zero exit status if configuration is invalid
.SH COMMAND \fI\,'ahriman service\-key\-import'\/\fR
usage: ahriman service\-key\-import [\-h] [\-\-key\-server KEY_SERVER] key
import PGP key from public sources to the repository user
.TP
\fBkey\fR
PGP key to import from public server
.SH OPTIONS \fI\,'ahriman service\-key\-import'\/\fR
.TP
\fB\-\-key\-server\fR \fI\,KEY_SERVER\/\fR
key server for key import
.SH COMMAND \fI\,'ahriman service\-setup'\/\fR
usage: ahriman service\-setup [\-h] [\-\-build\-as\-user BUILD_AS_USER] [\-\-build\-command BUILD_COMMAND]
[\-\-from\-configuration FROM_CONFIGURATION] [\-\-makeflags\-jobs | \-\-no\-makeflags\-jobs]
[\-\-mirror MIRROR] [\-\-multilib | \-\-no\-multilib] \-\-packager PACKAGER \-\-repository REPOSITORY
[\-\-sign\-key SIGN_KEY] [\-\-sign\-target {disabled,packages,repository}] [\-\-web\-port WEB_PORT]
[\-\-web\-unix\-socket WEB_UNIX_SOCKET]
create initial service configuration, requires root
.SH OPTIONS \fI\,'ahriman service\-setup'\/\fR
.TP
\fB\-\-build\-as\-user\fR \fI\,BUILD_AS_USER\/\fR
force makepkg user to the specific one
.TP
\fB\-\-build\-command\fR \fI\,BUILD_COMMAND\/\fR
build command prefix
.TP
\fB\-\-from\-configuration\fR \fI\,FROM_CONFIGURATION\/\fR
path to default devtools pacman configuration
.TP
\fB\-\-makeflags\-jobs\fR, \fB\-\-no\-makeflags\-jobs\fR
append MAKEFLAGS variable with parallelism set to number of cores (default: True)
.TP
\fB\-\-mirror\fR \fI\,MIRROR\/\fR
use the specified explicitly mirror instead of including mirrorlist
.TP
\fB\-\-multilib\fR, \fB\-\-no\-multilib\fR
add or do not multilib repository (default: True)
.TP
\fB\-\-packager\fR \fI\,PACKAGER\/\fR
packager name and email
.TP
\fB\-\-repository\fR \fI\,REPOSITORY\/\fR
repository name
.TP
\fB\-\-sign\-key\fR \fI\,SIGN_KEY\/\fR
sign key id
.TP
\fB\-\-sign\-target\fR \fI\,{disabled,packages,repository}\/\fR
sign options
.TP
\fB\-\-web\-port\fR \fI\,WEB_PORT\/\fR
port of the web service
.TP
\fB\-\-web\-unix\-socket\fR \fI\,WEB_UNIX_SOCKET\/\fR
path to unix socket used for interprocess communications
.SH COMMAND \fI\,'ahriman service\-shell'\/\fR
usage: ahriman service\-shell [\-h] [code]
drop into python shell while having created application
@ -700,11 +735,6 @@ remove user from the user mapping and update the configuration
\fBusername\fR
username for web service
.SH COMMAND \fI\,'ahriman version'\/\fR
usage: ahriman version [\-h]
print application and its dependencies versions
.SH COMMAND \fI\,'ahriman web'\/\fR
usage: ahriman web [\-h]

View File

@ -116,6 +116,14 @@ ahriman.application.handlers.search module
:no-undoc-members:
:show-inheritance:
ahriman.application.handlers.service\_updates module
----------------------------------------------------
.. automodule:: ahriman.application.handlers.service_updates
:members:
:no-undoc-members:
:show-inheritance:
ahriman.application.handlers.setup module
-----------------------------------------
@ -196,6 +204,14 @@ ahriman.application.handlers.users module
:no-undoc-members:
:show-inheritance:
ahriman.application.handlers.validate module
--------------------------------------------
.. automodule:: ahriman.application.handlers.validate
:members:
:no-undoc-members:
:show-inheritance:
ahriman.application.handlers.versions module
--------------------------------------------

View File

@ -0,0 +1,37 @@
ahriman.core.configuration package
==================================
Submodules
----------
ahriman.core.configuration.configuration module
-----------------------------------------------
.. automodule:: ahriman.core.configuration.configuration
:members:
:no-undoc-members:
:show-inheritance:
ahriman.core.configuration.schema module
----------------------------------------
.. automodule:: ahriman.core.configuration.schema
:members:
:no-undoc-members:
:show-inheritance:
ahriman.core.configuration.validator module
-------------------------------------------
.. automodule:: ahriman.core.configuration.validator
:members:
:no-undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: ahriman.core.configuration
:members:
:no-undoc-members:
:show-inheritance:

View File

@ -92,6 +92,14 @@ ahriman.core.formatters.user\_printer module
:no-undoc-members:
:show-inheritance:
ahriman.core.formatters.validation\_printer module
--------------------------------------------------
.. automodule:: ahriman.core.formatters.validation_printer
:members:
:no-undoc-members:
:show-inheritance:
ahriman.core.formatters.version\_printer module
-----------------------------------------------

View File

@ -10,6 +10,7 @@ Subpackages
ahriman.core.alpm
ahriman.core.auth
ahriman.core.build_tools
ahriman.core.configuration
ahriman.core.database
ahriman.core.formatters
ahriman.core.gitremote
@ -24,14 +25,6 @@ Subpackages
Submodules
----------
ahriman.core.configuration module
---------------------------------
.. automodule:: ahriman.core.configuration
:members:
:no-undoc-members:
:show-inheritance:
ahriman.core.exceptions module
------------------------------

View File

@ -81,6 +81,22 @@ In the most cases handlers spawn god class ``ahriman.application.application.App
Application is designed to run from ``systemd`` services and provides parametrized by architecture timer and service file for that.
Subcommand design
^^^^^^^^^^^^^^^^^
All subcommands are divided into several groups depending on the role they are doing:
* ``aur`` (``aur-search``) group is for AUR operations.
* ``help`` (e.g. ``help``) are system commands.
* ``package`` subcommands (e.g. ``package-add``) allow to perform single package actions.
* ``patch`` subcommands (e.g. ``pacth-list``) are the special case of ``package`` subcommands introduced in order to control patches for packages.
* ``repo`` subcommands (e.g. ``repo-check``) usually perform actions on whole repository.
* ``service`` subcommands (e.g. ``service-setup``) perform actions which are related to whole service managing: create repository, show configuration.
* ``user`` subcommands (``user-add``) are intended for user management.
* ``web`` subcommands are related to web service management.
For historical reasons and in order to keep backward compatibility some subcommands have aliases to their shorter forms or even other groups, but the service doesn't guarantee that they will remain unchanged.
Database
--------

View File

@ -1,14 +1,15 @@
# AUTOMATICALLY GENERATED by `shtab`
_shtab_ahriman_subparsers=('aur-search' 'search' 'daemon' 'help' 'help-commands-unsafe' 'key-import' 'package-add' 'add' 'package-update' 'package-remove' 'remove' 'package-status' 'status' 'package-status-remove' 'package-status-update' 'status-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'repo-backup' 'repo-check' 'check' 'repo-clean' 'clean' 'repo-config' 'config' 'repo-rebuild' 'rebuild' 'repo-remove-unknown' 'remove-unknown' 'repo-report' 'report' 'repo-restore' 'repo-setup' 'init' 'repo-init' 'setup' 'repo-sign' 'sign' 'repo-status-update' 'repo-sync' 'sync' 'repo-tree' 'repo-triggers' 'repo-update' 'update' 'shell' 'user-add' 'user-list' 'user-remove' 'version' 'web')
_shtab_ahriman_subparsers=('aur-search' 'search' 'help' 'help-commands-unsafe' 'help-updates' 'help-version' 'version' 'package-add' 'add' 'package-update' 'package-remove' 'remove' 'package-status' 'status' 'package-status-remove' 'package-status-update' 'status-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'repo-backup' 'repo-check' 'check' 'repo-daemon' 'daemon' 'repo-rebuild' 'rebuild' 'repo-remove-unknown' 'remove-unknown' 'repo-report' 'report' 'repo-restore' 'repo-sign' 'sign' 'repo-status-update' 'repo-sync' 'sync' 'repo-tree' 'repo-triggers' 'repo-update' 'update' 'service-clean' 'clean' 'repo-clean' 'service-config' 'config' 'repo-config' 'service-config-validate' 'config-validate' 'repo-config-validate' 'service-key-import' 'key-import' 'service-setup' 'init' 'repo-init' 'repo-setup' 'setup' 'service-shell' 'shell' 'user-add' 'user-list' 'user-remove' 'web')
_shtab_ahriman_option_strings=('-h' '--help' '-a' '--architecture' '-c' '--configuration' '--force' '-l' '--lock' '--report' '--no-report' '-q' '--quiet' '--unsafe' '-V' '--version')
_shtab_ahriman_aur_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_daemon_option_strings=('-h' '--help' '-i' '--interval' '--aur' '--no-aur' '--local' '--no-local' '--manual' '--no-manual' '--vcs' '--no-vcs' '-y' '--refresh')
_shtab_ahriman_help_option_strings=('-h' '--help')
_shtab_ahriman_help_commands_unsafe_option_strings=('-h' '--help' '--command')
_shtab_ahriman_key_import_option_strings=('-h' '--help' '--key-server')
_shtab_ahriman_help_updates_option_strings=('-h' '--help' '-e' '--exit-code')
_shtab_ahriman_help_version_option_strings=('-h' '--help')
_shtab_ahriman_version_option_strings=('-h' '--help')
_shtab_ahriman_package_add_option_strings=('-h' '--help' '-e' '--exit-code' '-n' '--now' '-y' '--refresh' '-s' '--source' '--without-dependencies')
_shtab_ahriman_add_option_strings=('-h' '--help' '-e' '--exit-code' '-n' '--now' '-y' '--refresh' '-s' '--source' '--without-dependencies')
_shtab_ahriman_package_update_option_strings=('-h' '--help' '-e' '--exit-code' '-n' '--now' '-y' '--refresh' '-s' '--source' '--without-dependencies')
@ -26,10 +27,8 @@ _shtab_ahriman_patch_set_add_option_strings=('-h' '--help' '-t' '--track')
_shtab_ahriman_repo_backup_option_strings=('-h' '--help')
_shtab_ahriman_repo_check_option_strings=('-h' '--help' '-e' '--exit-code' '--vcs' '--no-vcs' '-y' '--refresh')
_shtab_ahriman_check_option_strings=('-h' '--help' '-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_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')
_shtab_ahriman_config_option_strings=('-h' '--help')
_shtab_ahriman_repo_daemon_option_strings=('-h' '--help' '-i' '--interval' '--aur' '--no-aur' '--local' '--no-local' '--manual' '--no-manual' '--vcs' '--no-vcs' '-y' '--refresh')
_shtab_ahriman_daemon_option_strings=('-h' '--help' '-i' '--interval' '--aur' '--no-aur' '--local' '--no-local' '--manual' '--no-manual' '--vcs' '--no-vcs' '-y' '--refresh')
_shtab_ahriman_repo_rebuild_option_strings=('-h' '--help' '--depends-on' '--dry-run' '--from-database' '-e' '--exit-code')
_shtab_ahriman_rebuild_option_strings=('-h' '--help' '--depends-on' '--dry-run' '--from-database' '-e' '--exit-code')
_shtab_ahriman_repo_remove_unknown_option_strings=('-h' '--help' '--dry-run')
@ -37,10 +36,6 @@ _shtab_ahriman_remove_unknown_option_strings=('-h' '--help' '--dry-run')
_shtab_ahriman_repo_report_option_strings=('-h' '--help')
_shtab_ahriman_report_option_strings=('-h' '--help')
_shtab_ahriman_repo_restore_option_strings=('-h' '--help' '-o' '--output')
_shtab_ahriman_repo_setup_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_init_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_repo_init_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_setup_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_repo_sign_option_strings=('-h' '--help')
_shtab_ahriman_sign_option_strings=('-h' '--help')
_shtab_ahriman_repo_status_update_option_strings=('-h' '--help' '-s' '--status')
@ -50,16 +45,32 @@ _shtab_ahriman_repo_tree_option_strings=('-h' '--help')
_shtab_ahriman_repo_triggers_option_strings=('-h' '--help')
_shtab_ahriman_repo_update_option_strings=('-h' '--help' '--dry-run' '-e' '--exit-code' '--aur' '--no-aur' '--local' '--no-local' '--manual' '--no-manual' '--vcs' '--no-vcs' '-y' '--refresh')
_shtab_ahriman_update_option_strings=('-h' '--help' '--dry-run' '-e' '--exit-code' '--aur' '--no-aur' '--local' '--no-local' '--manual' '--no-manual' '--vcs' '--no-vcs' '-y' '--refresh')
_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_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_service_config_option_strings=('-h' '--help')
_shtab_ahriman_config_option_strings=('-h' '--help')
_shtab_ahriman_repo_config_option_strings=('-h' '--help')
_shtab_ahriman_service_config_validate_option_strings=('-h' '--help' '-e' '--exit-code')
_shtab_ahriman_config_validate_option_strings=('-h' '--help' '-e' '--exit-code')
_shtab_ahriman_repo_config_validate_option_strings=('-h' '--help' '-e' '--exit-code')
_shtab_ahriman_service_key_import_option_strings=('-h' '--help' '--key-server')
_shtab_ahriman_key_import_option_strings=('-h' '--help' '--key-server')
_shtab_ahriman_service_setup_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_init_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_repo_init_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_repo_setup_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_setup_option_strings=('-h' '--help' '--build-as-user' '--build-command' '--from-configuration' '--makeflags-jobs' '--no-makeflags-jobs' '--mirror' '--multilib' '--no-multilib' '--packager' '--repository' '--sign-key' '--sign-target' '--web-port' '--web-unix-socket')
_shtab_ahriman_service_shell_option_strings=('-h' '--help')
_shtab_ahriman_shell_option_strings=('-h' '--help')
_shtab_ahriman_user_add_option_strings=('-h' '--help' '-p' '--password' '-r' '--role' '-s' '--secure')
_shtab_ahriman_user_list_option_strings=('-h' '--help' '-e' '--exit-code' '-r' '--role')
_shtab_ahriman_user_remove_option_strings=('-h' '--help')
_shtab_ahriman_version_option_strings=('-h' '--help')
_shtab_ahriman_web_option_strings=('-h' '--help')
_shtab_ahriman_pos_0_choices=('aur-search' 'search' 'daemon' 'help' 'help-commands-unsafe' 'key-import' 'package-add' 'add' 'package-update' 'package-remove' 'remove' 'package-status' 'status' 'package-status-remove' 'package-status-update' 'status-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'repo-backup' 'repo-check' 'check' 'repo-clean' 'clean' 'repo-config' 'config' 'repo-rebuild' 'rebuild' 'repo-remove-unknown' 'remove-unknown' 'repo-report' 'report' 'repo-restore' 'repo-setup' 'init' 'repo-init' 'setup' 'repo-sign' 'sign' 'repo-status-update' 'repo-sync' 'sync' 'repo-tree' 'repo-triggers' 'repo-update' 'update' 'shell' 'user-add' 'user-list' 'user-remove' 'version' 'web')
_shtab_ahriman_pos_0_choices=('aur-search' 'search' 'help' 'help-commands-unsafe' 'help-updates' 'help-version' 'version' 'package-add' 'add' 'package-update' 'package-remove' 'remove' 'package-status' 'status' 'package-status-remove' 'package-status-update' 'status-update' 'patch-add' 'patch-list' 'patch-remove' 'patch-set-add' 'repo-backup' 'repo-check' 'check' 'repo-daemon' 'daemon' 'repo-rebuild' 'rebuild' 'repo-remove-unknown' 'remove-unknown' 'repo-report' 'report' 'repo-restore' 'repo-sign' 'sign' 'repo-status-update' 'repo-sync' 'sync' 'repo-tree' 'repo-triggers' 'repo-update' 'update' 'service-clean' 'clean' 'repo-clean' 'service-config' 'config' 'repo-config' 'service-config-validate' 'config-validate' 'repo-config-validate' 'service-key-import' 'key-import' 'service-setup' 'init' 'repo-init' 'repo-setup' 'setup' 'service-shell' 'shell' 'user-add' 'user-list' 'user-remove' 'web')
_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' 'url' 'url_path' 'version')
_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' 'url' 'url_path' 'version')
_shtab_ahriman_package_add__s_choices=('auto' 'archive' 'aur' 'directory' 'local' 'remote' 'repository')
@ -76,12 +87,13 @@ _shtab_ahriman_package_status_update__s_choices=('unknown' 'pending' 'building'
_shtab_ahriman_package_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success')
_shtab_ahriman_status_update__s_choices=('unknown' 'pending' 'building' 'failed' 'success')
_shtab_ahriman_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success')
_shtab_ahriman_repo_setup___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_init___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_repo_init___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_setup___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_repo_status_update__s_choices=('unknown' 'pending' 'building' 'failed' 'success')
_shtab_ahriman_repo_status_update___status_choices=('unknown' 'pending' 'building' 'failed' 'success')
_shtab_ahriman_service_setup___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_init___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_repo_init___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_repo_setup___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_setup___sign_target_choices=('disabled' 'packages' 'repository')
_shtab_ahriman_user_add__r_choices=('unauthorized' 'read' 'reporter' 'full')
_shtab_ahriman_user_add___role_choices=('unauthorized' 'read' 'reporter' 'full')
_shtab_ahriman_user_list__r_choices=('unauthorized' 'read' 'reporter' 'full')
@ -112,24 +124,18 @@ _shtab_ahriman_search__e_nargs=0
_shtab_ahriman_search___exit_code_nargs=0
_shtab_ahriman_search___info_nargs=0
_shtab_ahriman_search___no_info_nargs=0
_shtab_ahriman_daemon__h_nargs=0
_shtab_ahriman_daemon___help_nargs=0
_shtab_ahriman_daemon___aur_nargs=0
_shtab_ahriman_daemon___no_aur_nargs=0
_shtab_ahriman_daemon___local_nargs=0
_shtab_ahriman_daemon___no_local_nargs=0
_shtab_ahriman_daemon___manual_nargs=0
_shtab_ahriman_daemon___no_manual_nargs=0
_shtab_ahriman_daemon___vcs_nargs=0
_shtab_ahriman_daemon___no_vcs_nargs=0
_shtab_ahriman_daemon__y_nargs=0
_shtab_ahriman_daemon___refresh_nargs=0
_shtab_ahriman_help__h_nargs=0
_shtab_ahriman_help___help_nargs=0
_shtab_ahriman_help_commands_unsafe__h_nargs=0
_shtab_ahriman_help_commands_unsafe___help_nargs=0
_shtab_ahriman_key_import__h_nargs=0
_shtab_ahriman_key_import___help_nargs=0
_shtab_ahriman_help_updates__h_nargs=0
_shtab_ahriman_help_updates___help_nargs=0
_shtab_ahriman_help_updates__e_nargs=0
_shtab_ahriman_help_updates___exit_code_nargs=0
_shtab_ahriman_help_version__h_nargs=0
_shtab_ahriman_help_version___help_nargs=0
_shtab_ahriman_version__h_nargs=0
_shtab_ahriman_version___help_nargs=0
_shtab_ahriman_package_add_pos_0_nargs=+
_shtab_ahriman_package_add__h_nargs=0
_shtab_ahriman_package_add___help_nargs=0
@ -221,34 +227,30 @@ _shtab_ahriman_check___vcs_nargs=0
_shtab_ahriman_check___no_vcs_nargs=0
_shtab_ahriman_check__y_nargs=0
_shtab_ahriman_check___refresh_nargs=0
_shtab_ahriman_repo_clean__h_nargs=0
_shtab_ahriman_repo_clean___help_nargs=0
_shtab_ahriman_repo_clean___cache_nargs=0
_shtab_ahriman_repo_clean___no_cache_nargs=0
_shtab_ahriman_repo_clean___chroot_nargs=0
_shtab_ahriman_repo_clean___no_chroot_nargs=0
_shtab_ahriman_repo_clean___manual_nargs=0
_shtab_ahriman_repo_clean___no_manual_nargs=0
_shtab_ahriman_repo_clean___packages_nargs=0
_shtab_ahriman_repo_clean___no_packages_nargs=0
_shtab_ahriman_repo_clean___pacman_nargs=0
_shtab_ahriman_repo_clean___no_pacman_nargs=0
_shtab_ahriman_clean__h_nargs=0
_shtab_ahriman_clean___help_nargs=0
_shtab_ahriman_clean___cache_nargs=0
_shtab_ahriman_clean___no_cache_nargs=0
_shtab_ahriman_clean___chroot_nargs=0
_shtab_ahriman_clean___no_chroot_nargs=0
_shtab_ahriman_clean___manual_nargs=0
_shtab_ahriman_clean___no_manual_nargs=0
_shtab_ahriman_clean___packages_nargs=0
_shtab_ahriman_clean___no_packages_nargs=0
_shtab_ahriman_clean___pacman_nargs=0
_shtab_ahriman_clean___no_pacman_nargs=0
_shtab_ahriman_repo_config__h_nargs=0
_shtab_ahriman_repo_config___help_nargs=0
_shtab_ahriman_config__h_nargs=0
_shtab_ahriman_config___help_nargs=0
_shtab_ahriman_repo_daemon__h_nargs=0
_shtab_ahriman_repo_daemon___help_nargs=0
_shtab_ahriman_repo_daemon___aur_nargs=0
_shtab_ahriman_repo_daemon___no_aur_nargs=0
_shtab_ahriman_repo_daemon___local_nargs=0
_shtab_ahriman_repo_daemon___no_local_nargs=0
_shtab_ahriman_repo_daemon___manual_nargs=0
_shtab_ahriman_repo_daemon___no_manual_nargs=0
_shtab_ahriman_repo_daemon___vcs_nargs=0
_shtab_ahriman_repo_daemon___no_vcs_nargs=0
_shtab_ahriman_repo_daemon__y_nargs=0
_shtab_ahriman_repo_daemon___refresh_nargs=0
_shtab_ahriman_daemon__h_nargs=0
_shtab_ahriman_daemon___help_nargs=0
_shtab_ahriman_daemon___aur_nargs=0
_shtab_ahriman_daemon___no_aur_nargs=0
_shtab_ahriman_daemon___local_nargs=0
_shtab_ahriman_daemon___no_local_nargs=0
_shtab_ahriman_daemon___manual_nargs=0
_shtab_ahriman_daemon___no_manual_nargs=0
_shtab_ahriman_daemon___vcs_nargs=0
_shtab_ahriman_daemon___no_vcs_nargs=0
_shtab_ahriman_daemon__y_nargs=0
_shtab_ahriman_daemon___refresh_nargs=0
_shtab_ahriman_repo_rebuild__h_nargs=0
_shtab_ahriman_repo_rebuild___help_nargs=0
_shtab_ahriman_repo_rebuild___dry_run_nargs=0
@ -273,30 +275,6 @@ _shtab_ahriman_report__h_nargs=0
_shtab_ahriman_report___help_nargs=0
_shtab_ahriman_repo_restore__h_nargs=0
_shtab_ahriman_repo_restore___help_nargs=0
_shtab_ahriman_repo_setup__h_nargs=0
_shtab_ahriman_repo_setup___help_nargs=0
_shtab_ahriman_repo_setup___makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___multilib_nargs=0
_shtab_ahriman_repo_setup___no_multilib_nargs=0
_shtab_ahriman_init__h_nargs=0
_shtab_ahriman_init___help_nargs=0
_shtab_ahriman_init___makeflags_jobs_nargs=0
_shtab_ahriman_init___no_makeflags_jobs_nargs=0
_shtab_ahriman_init___multilib_nargs=0
_shtab_ahriman_init___no_multilib_nargs=0
_shtab_ahriman_repo_init__h_nargs=0
_shtab_ahriman_repo_init___help_nargs=0
_shtab_ahriman_repo_init___makeflags_jobs_nargs=0
_shtab_ahriman_repo_init___no_makeflags_jobs_nargs=0
_shtab_ahriman_repo_init___multilib_nargs=0
_shtab_ahriman_repo_init___no_multilib_nargs=0
_shtab_ahriman_setup__h_nargs=0
_shtab_ahriman_setup___help_nargs=0
_shtab_ahriman_setup___makeflags_jobs_nargs=0
_shtab_ahriman_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_setup___multilib_nargs=0
_shtab_ahriman_setup___no_multilib_nargs=0
_shtab_ahriman_repo_sign_pos_0_nargs=*
_shtab_ahriman_repo_sign__h_nargs=0
_shtab_ahriman_repo_sign___help_nargs=0
@ -346,6 +324,98 @@ _shtab_ahriman_update___vcs_nargs=0
_shtab_ahriman_update___no_vcs_nargs=0
_shtab_ahriman_update__y_nargs=0
_shtab_ahriman_update___refresh_nargs=0
_shtab_ahriman_service_clean__h_nargs=0
_shtab_ahriman_service_clean___help_nargs=0
_shtab_ahriman_service_clean___cache_nargs=0
_shtab_ahriman_service_clean___no_cache_nargs=0
_shtab_ahriman_service_clean___chroot_nargs=0
_shtab_ahriman_service_clean___no_chroot_nargs=0
_shtab_ahriman_service_clean___manual_nargs=0
_shtab_ahriman_service_clean___no_manual_nargs=0
_shtab_ahriman_service_clean___packages_nargs=0
_shtab_ahriman_service_clean___no_packages_nargs=0
_shtab_ahriman_service_clean___pacman_nargs=0
_shtab_ahriman_service_clean___no_pacman_nargs=0
_shtab_ahriman_clean__h_nargs=0
_shtab_ahriman_clean___help_nargs=0
_shtab_ahriman_clean___cache_nargs=0
_shtab_ahriman_clean___no_cache_nargs=0
_shtab_ahriman_clean___chroot_nargs=0
_shtab_ahriman_clean___no_chroot_nargs=0
_shtab_ahriman_clean___manual_nargs=0
_shtab_ahriman_clean___no_manual_nargs=0
_shtab_ahriman_clean___packages_nargs=0
_shtab_ahriman_clean___no_packages_nargs=0
_shtab_ahriman_clean___pacman_nargs=0
_shtab_ahriman_clean___no_pacman_nargs=0
_shtab_ahriman_repo_clean__h_nargs=0
_shtab_ahriman_repo_clean___help_nargs=0
_shtab_ahriman_repo_clean___cache_nargs=0
_shtab_ahriman_repo_clean___no_cache_nargs=0
_shtab_ahriman_repo_clean___chroot_nargs=0
_shtab_ahriman_repo_clean___no_chroot_nargs=0
_shtab_ahriman_repo_clean___manual_nargs=0
_shtab_ahriman_repo_clean___no_manual_nargs=0
_shtab_ahriman_repo_clean___packages_nargs=0
_shtab_ahriman_repo_clean___no_packages_nargs=0
_shtab_ahriman_repo_clean___pacman_nargs=0
_shtab_ahriman_repo_clean___no_pacman_nargs=0
_shtab_ahriman_service_config__h_nargs=0
_shtab_ahriman_service_config___help_nargs=0
_shtab_ahriman_config__h_nargs=0
_shtab_ahriman_config___help_nargs=0
_shtab_ahriman_repo_config__h_nargs=0
_shtab_ahriman_repo_config___help_nargs=0
_shtab_ahriman_service_config_validate__h_nargs=0
_shtab_ahriman_service_config_validate___help_nargs=0
_shtab_ahriman_service_config_validate__e_nargs=0
_shtab_ahriman_service_config_validate___exit_code_nargs=0
_shtab_ahriman_config_validate__h_nargs=0
_shtab_ahriman_config_validate___help_nargs=0
_shtab_ahriman_config_validate__e_nargs=0
_shtab_ahriman_config_validate___exit_code_nargs=0
_shtab_ahriman_repo_config_validate__h_nargs=0
_shtab_ahriman_repo_config_validate___help_nargs=0
_shtab_ahriman_repo_config_validate__e_nargs=0
_shtab_ahriman_repo_config_validate___exit_code_nargs=0
_shtab_ahriman_service_key_import__h_nargs=0
_shtab_ahriman_service_key_import___help_nargs=0
_shtab_ahriman_key_import__h_nargs=0
_shtab_ahriman_key_import___help_nargs=0
_shtab_ahriman_service_setup__h_nargs=0
_shtab_ahriman_service_setup___help_nargs=0
_shtab_ahriman_service_setup___makeflags_jobs_nargs=0
_shtab_ahriman_service_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_service_setup___multilib_nargs=0
_shtab_ahriman_service_setup___no_multilib_nargs=0
_shtab_ahriman_init__h_nargs=0
_shtab_ahriman_init___help_nargs=0
_shtab_ahriman_init___makeflags_jobs_nargs=0
_shtab_ahriman_init___no_makeflags_jobs_nargs=0
_shtab_ahriman_init___multilib_nargs=0
_shtab_ahriman_init___no_multilib_nargs=0
_shtab_ahriman_repo_init__h_nargs=0
_shtab_ahriman_repo_init___help_nargs=0
_shtab_ahriman_repo_init___makeflags_jobs_nargs=0
_shtab_ahriman_repo_init___no_makeflags_jobs_nargs=0
_shtab_ahriman_repo_init___multilib_nargs=0
_shtab_ahriman_repo_init___no_multilib_nargs=0
_shtab_ahriman_repo_setup__h_nargs=0
_shtab_ahriman_repo_setup___help_nargs=0
_shtab_ahriman_repo_setup___makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_repo_setup___multilib_nargs=0
_shtab_ahriman_repo_setup___no_multilib_nargs=0
_shtab_ahriman_setup__h_nargs=0
_shtab_ahriman_setup___help_nargs=0
_shtab_ahriman_setup___makeflags_jobs_nargs=0
_shtab_ahriman_setup___no_makeflags_jobs_nargs=0
_shtab_ahriman_setup___multilib_nargs=0
_shtab_ahriman_setup___no_multilib_nargs=0
_shtab_ahriman_service_shell__h_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_shell__h_nargs=0
_shtab_ahriman_shell___help_nargs=0
_shtab_ahriman_shell__v_nargs=0
@ -360,8 +430,6 @@ _shtab_ahriman_user_list__e_nargs=0
_shtab_ahriman_user_list___exit_code_nargs=0
_shtab_ahriman_user_remove__h_nargs=0
_shtab_ahriman_user_remove___help_nargs=0
_shtab_ahriman_version__h_nargs=0
_shtab_ahriman_version___help_nargs=0
_shtab_ahriman_web__h_nargs=0
_shtab_ahriman_web___help_nargs=0

View File

@ -10,9 +10,12 @@ _shtab_ahriman_commands() {
"check:check for packages updates. Same as repo-update --dry-run --no-manual"
"clean:remove local caches"
"config:dump configuration for the specified architecture"
"config-validate:validate configuration and print found errors"
"daemon:start process which periodically will run update process"
"help:show help message for application or command and exit"
"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-version:print application and its dependencies versions"
"init:create initial service configuration, requires root"
"key-import:import PGP key from public sources to the repository user"
"package-add:add existing or new package to the build queue"
@ -32,6 +35,8 @@ _shtab_ahriman_commands() {
"repo-check:check for packages updates. Same as repo-update --dry-run --no-manual"
"repo-clean:remove local caches"
"repo-config:dump configuration for the specified architecture"
"repo-config-validate:validate configuration and print found errors"
"repo-daemon:start process which periodically will run update process"
"repo-init:create initial service configuration, requires root"
"repo-rebuild:force rebuild whole repository"
"repo-remove-unknown:remove packages which are missing in AUR and do not have local PKGBUILDs"
@ -46,6 +51,12 @@ _shtab_ahriman_commands() {
"repo-update:check for packages updates and run build process if requested"
"report:generate repository report according to current settings"
"search:search for package in AUR using API"
"service-clean:remove local caches"
"service-config:dump configuration for the specified architecture"
"service-config-validate:validate configuration and print found errors"
"service-key-import:import PGP key from public sources to the repository user"
"service-setup:create initial service configuration, requires root"
"service-shell:drop into python shell while having created application"
"setup:create initial service configuration, requires root"
"shell:drop into python shell while having created application"
"sign:(re-)sign packages and repository database according to current settings"
@ -95,7 +106,7 @@ _shtab_ahriman_aur_search_options=(
_shtab_ahriman_check_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if result is empty]"
{--vcs,--no-vcs}"[enable or disable checking of VCS packages (default\: \%(default)s)]:vcs:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
"(*)::filter check by package base:"
)
@ -113,13 +124,18 @@ _shtab_ahriman_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
)
_shtab_ahriman_config_validate_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if configuration is invalid]"
)
_shtab_ahriman_daemon_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-i,--interval}"[interval between runs in seconds]:interval:"
{--aur,--no-aur}"[enable or disable checking for AUR updates. Implies --no-vcs (default\: \%(default)s)]:aur:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: \%(default)s)]:aur:"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: \%(default)s)]:local:"
{--manual,--no-manual}"[include or exclude manual updates (default\: \%(default)s)]:manual:"
{--vcs,--no-vcs}"[enable or disable checking of VCS packages (default\: \%(default)s)]:vcs:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
)
@ -133,12 +149,22 @@ _shtab_ahriman_help_commands_unsafe_options=(
"--command[instead of showing commands, just test command line for unsafe subcommand and return 0 in case if command is safe and 1 otherwise]:command:"
)
_shtab_ahriman_help_updates_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit code if updates available]"
)
_shtab_ahriman_help_version_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
)
_shtab_ahriman_init_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one]:build_as_user:"
"--build-command[build command prefix]:build_command:"
"--from-configuration[path to default devtools pacman configuration]:from_configuration:"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: \%(default)s)]:makeflags_jobs:"
"--mirror[use the specified explicitly mirror instead of including mirrorlist]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: \%(default)s)]:multilib:"
"--packager[packager name and email]:packager:"
"--repository[repository name]:repository:"
@ -251,7 +277,7 @@ _shtab_ahriman_repo_backup_options=(
_shtab_ahriman_repo_check_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if result is empty]"
{--vcs,--no-vcs}"[enable or disable checking of VCS packages (default\: \%(default)s)]:vcs:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
"(*)::filter check by package base:"
)
@ -269,12 +295,28 @@ _shtab_ahriman_repo_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
)
_shtab_ahriman_repo_config_validate_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if configuration is invalid]"
)
_shtab_ahriman_repo_daemon_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-i,--interval}"[interval between runs in seconds]:interval:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: \%(default)s)]:aur:"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: \%(default)s)]:local:"
{--manual,--no-manual}"[include or exclude manual updates (default\: \%(default)s)]:manual:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
)
_shtab_ahriman_repo_init_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one]:build_as_user:"
"--build-command[build command prefix]:build_command:"
"--from-configuration[path to default devtools pacman configuration]:from_configuration:"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: \%(default)s)]:makeflags_jobs:"
"--mirror[use the specified explicitly mirror instead of including mirrorlist]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: \%(default)s)]:multilib:"
"--packager[packager name and email]:packager:"
"--repository[repository name]:repository:"
@ -313,6 +355,7 @@ _shtab_ahriman_repo_setup_options=(
"--build-command[build command prefix]:build_command:"
"--from-configuration[path to default devtools pacman configuration]:from_configuration:"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: \%(default)s)]:makeflags_jobs:"
"--mirror[use the specified explicitly mirror instead of including mirrorlist]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: \%(default)s)]:multilib:"
"--packager[packager name and email]:packager:"
"--repository[repository name]:repository:"
@ -349,10 +392,10 @@ _shtab_ahriman_repo_update_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--dry-run[just perform check for updates, same as check command]"
{-e,--exit-code}"[return non-zero exit status if result is empty]"
{--aur,--no-aur}"[enable or disable checking for AUR updates. Implies --no-vcs (default\: \%(default)s)]:aur:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: \%(default)s)]:aur:"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: \%(default)s)]:local:"
{--manual,--no-manual}"[include or exclude manual updates (default\: \%(default)s)]:manual:"
{--vcs,--no-vcs}"[enable or disable checking of VCS packages (default\: \%(default)s)]:vcs:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
"(*)::filter check by package base:"
)
@ -369,12 +412,58 @@ _shtab_ahriman_search_options=(
"(*):search terms, can be specified multiple times, the result will match all terms:"
)
_shtab_ahriman_service_clean_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{--cache,--no-cache}"[clear directory with package caches (default\: \%(default)s)]:cache:"
{--chroot,--no-chroot}"[clear build chroot (default\: \%(default)s)]:chroot:"
{--manual,--no-manual}"[clear manually added packages queue (default\: \%(default)s)]:manual:"
{--packages,--no-packages}"[clear directory with built packages (default\: \%(default)s)]:packages:"
{--pacman,--no-pacman}"[clear directory with pacman local database cache (default\: \%(default)s)]:pacman:"
)
_shtab_ahriman_service_config_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
)
_shtab_ahriman_service_config_validate_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
{-e,--exit-code}"[return non-zero exit status if configuration is invalid]"
)
_shtab_ahriman_service_key_import_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--key-server[key server for key import]:key_server:"
":PGP key to import from public server:"
)
_shtab_ahriman_service_setup_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one]:build_as_user:"
"--build-command[build command prefix]:build_command:"
"--from-configuration[path to default devtools pacman configuration]:from_configuration:"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: \%(default)s)]:makeflags_jobs:"
"--mirror[use the specified explicitly mirror instead of including mirrorlist]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: \%(default)s)]:multilib:"
"--packager[packager name and email]:packager:"
"--repository[repository name]:repository:"
"--sign-key[sign key id]:sign_key:"
"*--sign-target[sign options]:sign_target:(disabled packages repository)"
"--web-port[port of the web service]:web_port:"
"--web-unix-socket[path to unix socket used for interprocess communications]:web_unix_socket:"
)
_shtab_ahriman_service_shell_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
":instead of dropping into shell, just execute the specified code:"
)
_shtab_ahriman_setup_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--build-as-user[force makepkg user to the specific one]:build_as_user:"
"--build-command[build command prefix]:build_command:"
"--from-configuration[path to default devtools pacman configuration]:from_configuration:"
{--makeflags-jobs,--no-makeflags-jobs}"[append MAKEFLAGS variable with parallelism set to number of cores (default\: \%(default)s)]:makeflags_jobs:"
"--mirror[use the specified explicitly mirror instead of including mirrorlist]:mirror:"
{--multilib,--no-multilib}"[add or do not multilib repository (default\: \%(default)s)]:multilib:"
"--packager[packager name and email]:packager:"
"--repository[repository name]:repository:"
@ -417,10 +506,10 @@ _shtab_ahriman_update_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--dry-run[just perform check for updates, same as check command]"
{-e,--exit-code}"[return non-zero exit status if result is empty]"
{--aur,--no-aur}"[enable or disable checking for AUR updates. Implies --no-vcs (default\: \%(default)s)]:aur:"
{--aur,--no-aur}"[enable or disable checking for AUR updates (default\: \%(default)s)]:aur:"
{--local,--no-local}"[enable or disable checking of local packages for updates (default\: \%(default)s)]:local:"
{--manual,--no-manual}"[include or exclude manual updates (default\: \%(default)s)]:manual:"
{--vcs,--no-vcs}"[enable or disable checking of VCS packages (default\: \%(default)s)]:vcs:"
{--vcs,--no-vcs}"[fetch actual version of VCS packages (default\: \%(default)s)]:vcs:"
"*"{-y,--refresh}"[download fresh package databases from the mirror before actions, -yy to force refresh even if up to date]"
"(*)::filter check by package base:"
)
@ -473,9 +562,12 @@ _shtab_ahriman() {
check) _arguments -C $_shtab_ahriman_check_options ;;
clean) _arguments -C $_shtab_ahriman_clean_options ;;
config) _arguments -C $_shtab_ahriman_config_options ;;
config-validate) _arguments -C $_shtab_ahriman_config_validate_options ;;
daemon) _arguments -C $_shtab_ahriman_daemon_options ;;
help) _arguments -C $_shtab_ahriman_help_options ;;
help-commands-unsafe) _arguments -C $_shtab_ahriman_help_commands_unsafe_options ;;
help-updates) _arguments -C $_shtab_ahriman_help_updates_options ;;
help-version) _arguments -C $_shtab_ahriman_help_version_options ;;
init) _arguments -C $_shtab_ahriman_init_options ;;
key-import) _arguments -C $_shtab_ahriman_key_import_options ;;
package-add) _arguments -C $_shtab_ahriman_package_add_options ;;
@ -495,6 +587,8 @@ _shtab_ahriman() {
repo-check) _arguments -C $_shtab_ahriman_repo_check_options ;;
repo-clean) _arguments -C $_shtab_ahriman_repo_clean_options ;;
repo-config) _arguments -C $_shtab_ahriman_repo_config_options ;;
repo-config-validate) _arguments -C $_shtab_ahriman_repo_config_validate_options ;;
repo-daemon) _arguments -C $_shtab_ahriman_repo_daemon_options ;;
repo-init) _arguments -C $_shtab_ahriman_repo_init_options ;;
repo-rebuild) _arguments -C $_shtab_ahriman_repo_rebuild_options ;;
repo-remove-unknown) _arguments -C $_shtab_ahriman_repo_remove_unknown_options ;;
@ -509,6 +603,12 @@ _shtab_ahriman() {
repo-update) _arguments -C $_shtab_ahriman_repo_update_options ;;
report) _arguments -C $_shtab_ahriman_report_options ;;
search) _arguments -C $_shtab_ahriman_search_options ;;
service-clean) _arguments -C $_shtab_ahriman_service_clean_options ;;
service-config) _arguments -C $_shtab_ahriman_service_config_options ;;
service-config-validate) _arguments -C $_shtab_ahriman_service_config_validate_options ;;
service-key-import) _arguments -C $_shtab_ahriman_service_key_import_options ;;
service-setup) _arguments -C $_shtab_ahriman_service_setup_options ;;
service-shell) _arguments -C $_shtab_ahriman_service_shell_options ;;
setup) _arguments -C $_shtab_ahriman_setup_options ;;
shell) _arguments -C $_shtab_ahriman_shell_options ;;
sign) _arguments -C $_shtab_ahriman_sign_options ;;

View File

@ -12,6 +12,14 @@ There are two variable types which have been added to default ones, they are pat
Path values, except for casting to ``pathlib.Path`` type, will be also expanded to absolute paths relative to the configuration path. E.g. if path is set to ``ahriman.ini.d/logging.ini`` and root configuration path is ``/etc/ahriman.ini``, the value will be expanded to ``/etc/ahriman.ini.d/logging.ini``. In order to disable path expand, use the full path, e.g. ``/etc/ahriman.ini.d/logging.ini``.
There is also additional subcommand which will allow to validate configuration and print found errors. In order to do so, run ``service-config-validate`` subcommand, e.g.:
.. code-block:: shell
ahriman -a x86_64 service-config-validate
It will check current settings on common errors and compare configuration with known schema.
``settings`` group
------------------
@ -24,7 +32,7 @@ Base configuration settings.
``alpm`` group
--------------
libalpm and AUR related configuration.
libalpm and AUR related configuration. Group name can refer to architecture, e.g. ``alpm:x86_64`` can be used for x86_64 architecture specific settings.
* ``database`` - path to pacman system database cache, string, required.
* ``mirror`` - package database mirror used by pacman for syncronization, string, required. This option supports standard pacman substitutions with ``$arch`` and ``$repo``. Note that the mentioned mirror should contain all repositories which are set by ``alpm.repositories`` option.
@ -78,12 +86,36 @@ Settings for signing packages or repository. Group name can refer to architectur
* ``key`` - default PGP key, string, required. This key will also be used for database signing if enabled.
* ``key_*`` settings - PGP key which will be used for specific packages, string, optional. For example, if there is ``key_yay`` option the specified key will be used for yay package and default key for others.
``web:*`` groups
----------------
Web server settings. If any of ``host``/``port`` is not set, web integration will be disabled. Group name can refer to architecture, e.g. ``web:x86_64`` can be used for x86_64 architecture specific settings. This feature requires ``aiohttp`` libraries to be installed.
* ``address`` - optional address in form ``proto://host:port`` (``port`` can be omitted in case of default ``proto`` ports), will be used instead of ``http://{host}:{port}`` in case if set, string, optional. This option is required in case if ``OAuth`` provider is used.
* ``debug`` - enable debug toolbar, boolean, optional, default ``no``.
* ``debug_check_host`` - check hosts to access debug toolbar, boolean, optional, default ``no``.
* ``debug_allowed_hosts`` - allowed hosts to get access to debug toolbar, space separated list of string, optional.
* ``host`` - host to bind, string, optional.
* ``index_url`` - full url of the repository index page, string, optional.
* ``password`` - password to authorize in web service in order to update service status, string, required in case if authorization enabled.
* ``port`` - port to bind, int, optional.
* ``static_path`` - path to directory with static files, string, required.
* ``templates`` - path to templates directory, string, required.
* ``unix_socket`` - path to the listening unix socket, string, optional. If set, server will create the socket on the specified address which can (and will) be used by application. Note, that unlike usual host/port configuration, unix socket allows to perform requests without authorization.
* ``unix_socket_unsafe`` - set unsafe (o+w) permissions to unix socket, boolean, optional, default ``yes``. This option is enabled by default, because it is supposed that unix socket is created in safe environment (only web service is supposed to be used in unsafe), but it can be disabled by configuration.
* ``username`` - username to authorize in web service in order to update service status, string, required in case if authorization enabled.
``remote-pull`` group
---------------------
Remote git source synchronization settings. Unlike ``Upload`` triggers those triggers are used for PKGBUILD synchronization - fetch from remote repository PKGBUILDs before updating process.
It supports authorization; to do so you'd need to prefix the url with authorization part, e.g. ``https://key:token@github.com/arcan1s/ahriman.git``. It is highly recommended to use application tokens instead of your user authorization details.
It supports authorization; to do so you'd need to prefix the url with authorization part, e.g. ``https://key:token@github.com/arcan1s/ahriman.git``. It is highly recommended to use application tokens instead of your user authorization details. Alternatively, you can use any other option supported by git, e.g.:
* by SSH key: generate SSH key as ``ahriman`` user and put public part of it to the repository keys.
* by git credentials helper: consult with the `related man page <https://git-scm.com/docs/gitcredentials>`_.
Available options are:
* ``target`` - list of remote pull triggers to be used, space separated list of strings, optional, defaults to ``gitremote``. It must point to valid section (or to section with architecture), e.g. ``gitremote`` must point to either ``gitremote`` or ``gitremote:x86_64`` (the one with architecture has higher priority).
@ -98,7 +130,12 @@ Remote pull trigger
Remote git source synchronization settings. Same as remote pull triggers those triggers are used for PKGBUILD synchronization - push updated PKGBUILDs to the remote repository after build process.
It supports authorization; to do so you'd need to prefix the url with authorization part, e.g. ``https://key:token@github.com/arcan1s/ahriman.git``. It is highly recommended to use application tokens instead of your user authorization details.
It supports authorization; to do so you'd need to prefix the url with authorization part, e.g. ``https://key:token@github.com/arcan1s/ahriman.git``. It is highly recommended to use application tokens instead of your user authorization details. Alternatively, you can use any other option supported by git, e.g.:
* by SSH key: generate SSH key as ``ahriman`` user and put public part of it to the repository keys.
* by git credentials helper: consult with the `related man page <https://git-scm.com/docs/gitcredentials>`_.
Available options are:
* ``target`` - list of remote push triggers to be used, space separated list of strings, optional, defaults to ``gitremote``. It must point to valid section (or to section with architecture), e.g. ``gitremote`` must point to either ``gitremote`` or ``gitremote:x86_64`` (the one with architecture has higher priority).
@ -224,22 +261,4 @@ Requires ``boto3`` library to be installed. Section name must be either ``s3`` (
* ``bucket`` - bucket name (e.g. ``bucket``), string, required.
* ``chunk_size`` - chunk size for calculating entity tags, int, optional, default 8 * 1024 * 1024.
* ``region`` - bucket region (e.g. ``eu-central-1``), string, required.
* ``secret_key`` - AWS secret access key, string, required.
``web:*`` groups
----------------
Web server settings. If any of ``host``/``port`` is not set, web integration will be disabled. Group name can refer to architecture, e.g. ``web:x86_64`` can be used for x86_64 architecture specific settings. This feature requires ``aiohttp`` libraries to be installed.
* ``address`` - optional address in form ``proto://host:port`` (``port`` can be omitted in case of default ``proto`` ports), will be used instead of ``http://{host}:{port}`` in case if set, string, optional. This option is required in case if ``OAuth`` provider is used.
* ``debug`` - enable debug toolbar, boolean, optional, default ``no``.
* ``debug_check_host`` - check hosts to access debug toolbar, boolean, optional, default ``no``.
* ``debug_allowed_hosts`` - allowed hosts to get access to debug toolbar, space separated list of string, optional.
* ``host`` - host to bind, string, optional.
* ``index_url`` - full url of the repository index page, string, optional.
* ``password`` - password to authorize in web service in order to update service status, string, required in case if authorization enabled.
* ``port`` - port to bind, int, optional.
* ``static_path`` - path to directory with static files, string, required.
* ``templates`` - path to templates directory, string, required.
* ``unix_socket`` - path to the listening unix socket, string, optional. If set, server will create the socket on the specified address which can (and will) be used by application. Note, that unlike usual host/port configuration, unix socket allows to perform requests without authorization.
* ``username`` - username to authorize in web service in order to update service status, string, required in case if authorization enabled.
* ``secret_key`` - AWS secret access key, string, required.

View File

@ -18,7 +18,7 @@ TL;DR
.. code-block:: shell
yay -S ahriman
sudo ahriman -a x86_64 repo-setup --packager "ahriman bot <ahriman@example.com>" --repository "repository"
ahriman -a x86_64 service-setup --packager "ahriman bot <ahriman@example.com>" --repository "repository"
systemctl enable --now ahriman@x86_64.timer
Long answer
@ -26,6 +26,33 @@ Long answer
The idea is to install the package as usual, create working directory tree, create configuration for ``sudo`` and ``devtools``. Detailed description of the setup instruction can be found :doc:`here <setup>`.
How to validate settings
^^^^^^^^^^^^^^^^^^^^^^^^
There is special command which can be used in order to validate current configuration:
.. code-block:: shell
ahriman -a x86_64 service-config-validate --exit-code
This command will print found errors, based on `cerberus <https://docs.python-cerberus.org/>`_, e.g.:
.. code-block:: shell
auth
ssalt: unknown field
target: none or more than one rule validate
oneof definition 0: unallowed value mapping
oneof definition 1: field 'salt' is required
oneof definition 2: unallowed value mapping
oneof definition 2: field 'salt' is required
oneof definition 2: field 'client_id' is required
oneof definition 2: field 'client_secret' is required
gitremote
pull_url: unknown field
If an additional flag ``--exit-code`` is supplied, the application will return non-zero exit code, which can be used partially in scripts.
What does "architecture specific" mean / How to configure for different architectures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -117,52 +144,30 @@ Before using this command you will need to create local directory, put ``PKGBUIL
How to fetch PKGBUILDs from remote repository
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For that purpose you could use ``RemotePullTrigger`` trigger. To do so you will need:
For that purpose you could use ``RemotePullTrigger`` trigger. To do so you will need to configure trigger as following:
#.
Append ``triggers`` option in ``build`` section with the following line:
.. code-block:: ini
.. code-block:: ini
[remote-pull]
target = gitremote
[build]
triggers = ahriman.core.gitremote.RemotePullTrigger
#.
Configure trigger as following:
.. code-block:: ini
[remote-pull]
target = gitremote
[gitremote]
pull_url = https://github.com/username/repository
[gitremote]
pull_url = https://github.com/username/repository
During the next application run it will fetch repository from the specified url and will try to find packages there which can be used as local sources.
How to push updated PKGBUILDs to remote repository
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For that purpose you'd need to use another trigger called ``RemotePushTrigger``. Configure it as following:
For that purpose you'd need to use another trigger called ``RemotePushTrigger``. Configure trigger as following:
#.
Append ``triggers`` option in ``build`` section with the trigger name:
.. code-block:: ini
.. code-block:: ini
[remote-push]
target = gitremote
[build]
triggers = ahriman.core.gitremote.RemotePushTrigger
#.
Configure trigger as following:
.. code-block:: ini
[remote-push]
target = gitremote
[gitremote]
push_url = https://github.com/username/repository
[gitremote]
push_url = https://github.com/username/repository
Unlike ``RemotePullTrigger`` trigger, the ``RemotePushTrigger`` more likely will require authorization. It is highly recommended to use application tokens for that instead of using your password (e.g. for Github you can generate tokens `here <https://github.com/settings/tokens>`_ with scope ``public_repo``). Authorization can be supplied by using authorization part of the url, e.g. ``https://key:token@github.com/username/repository``.
@ -214,7 +219,7 @@ TL;DR
.. code-block:: shell
sudo -u ahriman ahriman key-import ...
sudo -u ahriman ahriman service-key-import ...
How to update VCS packages
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -386,13 +391,16 @@ The following environment variables are supported:
* ``AHRIMAN_DEBUG`` - if set all commands will be logged to console.
* ``AHRIMAN_FORCE_ROOT`` - force run ahriman as root instead of guessing by subcommand.
* ``AHRIMAN_HOST`` - host for the web interface, default is ``0.0.0.0``.
* ``AHRIMAN_MULTILIB`` - if set (default) multilib repository will be used, disabled otherwise.
* ``AHRIMAN_OUTPUT`` - controls logging handler, e.g. ``syslog``, ``console``. The name must be found in logging configuration. Note that if ``syslog`` (the default) handler is used you will need to mount ``/dev/log`` inside container because it is not available there.
* ``AHRIMAN_PACKAGER`` - packager name from which packages will be built, default is ``ahriman bot <ahriman@example.com>``.
* ``AHRIMAN_PACMAN_MIRROR`` - override pacman mirror server if set.
* ``AHRIMAN_PORT`` - HTTP server port if any, default is empty.
* ``AHRIMAN_REPOSITORY`` - repository name, default is ``aur-clone``.
* ``AHRIMAN_REPOSITORY_ROOT`` - repository root. Because of filesystem rights it is required to override default repository root. By default, it uses ``ahriman`` directory inside ahriman's home, which can be passed as mount volume.
* ``AHRIMAN_UNIX_SOCKET`` - full path to unix socket which is used by web server, default is empty. Note that more likely you would like to put it inside ``AHRIMAN_REPOSITORY_ROOT`` directory (e.g. ``/var/lib/ahriman/ahriman/ahriman-web.sock``) or to ``/tmp``.
* ``AHRIMAN_USER`` - ahriman user, usually must not be overwritten, default is ``ahriman``.
* ``AHRIMAN_USER`` - ahriman user, usually must not be overwritten, default is ``ahriman``.
* ``AHRIMAN_VALIDATE_CONFIGURATION`` - if set validate service configuration
You can pass any of these variables by using ``-e`` argument, e.g.:
@ -403,11 +411,11 @@ You can pass any of these variables by using ``-e`` argument, e.g.:
Daemon service
^^^^^^^^^^^^^^
There is special ``daemon`` subcommand which emulates systemd timer and will perform repository update periodically:
There is special ``repo-daemon`` subcommand which emulates systemd timer and will perform repository update periodically:
.. code-block:: shell
docker run --privileged -v /path/to/local/repo:/var/lib/ahriman arcan1s/ahriman:latest daemon
docker run --privileged -v /path/to/local/repo:/var/lib/ahriman arcan1s/ahriman:latest repo-daemon
This command uses same rules as ``repo-update``, thus, e.g. requires ``--privileged`` flag.
@ -436,6 +444,102 @@ Otherwise, you would need to pass ``AHRIMAN_PORT`` and mount container network t
docker run --privileged --net=host -e AHRIMAN_PORT=8080 -v /path/to/local/repo:/var/lib/ahriman arcan1s/ahriman:latest
Non-x86_64 architecture setup
-----------------------------
The following section describes how to setup ahriman with architecture different from x86_64, as example i686. For most cases you have base repository available, e.g. archlinux32 repositories for i686 architecture; in case if base repository is not available, steps are a bit different, however, idea remains the same.
Physical server setup
^^^^^^^^^^^^^^^^^^^^^
In this example we are going to use files and packages which are provided by official repositories of the used architecture. Note, that versions might be different, thus you need to find correct versions on the distribution web site, e.g. `archlinux32 packages <https://www.archlinux32.org/packages/>`_.
#.
First, considering having base Arch Linux system, we need to install keyring for the specified repositories:
.. code-block:: shell
wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20220927-1.0-any.pkg.tar.zst
pacman -U archlinux32-keyring-20220927-1.0-any.pkg.tar.zst
#.
In order to run ``devtools`` scripts for custom architecture they also need specific ``makepkg`` configuration, it can be retrieved by installing the ``devtools`` package of the distribution:
.. code-block:: shell
wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.0-any.pkg.tar.zst
pacman -U devtools-20221208-1.0-any.pkg.tar.zst
Alternatively, you can create your own ``makepkg`` configuration and save it as ``/usr/share/devtools/makepkg-i686.conf``.
#.
Setup repository as usual:
.. code-block:: shell
ahriman -a i686 service-setup --mirror 'http://de.mirror.archlinux32.org/$arch/$repo'--no-multilib ...
In addition to usual options, you need to specify the following options:
* ``--mirror`` - link to the mirrors which will be used instead of official repositories.
* ``--no-multilib`` - in the example we are using i686 architecture for which multilib repository doesn't exist.
Docker container setup
^^^^^^^^^^^^^^^^^^^^^^
There are two possible ways to achieve same setup, by using docker container. The first one is just mount required files inside container and run it as usual (with specific environment variables). Another one is to create own container based on official one:
#.
Clone official container as base:
.. code-block:: dockerfile
FROM arcan1s/ahriman:latest
#.
Init pacman keys. This command is required in order to populate distribution keys:
.. code-block:: dockerfile
RUN pacman-key --init
#.
Install packages as it was described above:
.. code-block:: dockerfile
RUN pacman --noconfirm -Sy wget
RUN wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.0-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.0-any.pkg.tar.zst
RUN wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20220927-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20220927-1.0-any.pkg.tar.zst
#.
At that point you should have full ``Dockerfile`` like:
.. code-block:: dockerfile
FROM arcan1s/ahriman:latest
RUN pacman-key --init
RUN pacman --noconfirm -Sy wget
RUN wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.0-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.0-any.pkg.tar.zst
RUN wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20220927-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20220927-1.0-any.pkg.tar.zst
#.
After that you can build you own container, e.g.:
.. code-block:: shell
docker build --tag ahriman-i686:latest
#.
Now you can run locally built container as usual with passing environment variables for setup command:
.. code-block:: shell
docker run --privileged -p 8080:8080 -e AHRIMAN_ARCHITECTURE=i686 -e AHRIMAN_PACMAN_MIRROR='http://de.mirror.archlinux32.org/$arch/$repo' -e AHRIMAN_MULTILIB= ahriman-i686:latest
Remote synchronization
----------------------
@ -784,7 +888,7 @@ The service provides several commands aim to do easy repository backup and resto
.. code-block:: shell
sudo ahriman repo-backup /tmp/repo.tar.gz
ahriman repo-backup /tmp/repo.tar.gz
This command will pack all configuration files together with database file into the archive specified as command line argument (i.e. ``/tmp/repo.tar.gz``). In addition it will also archive ``cache`` directory (the one which contains local clones used by e.g. local packages) and ``.gnupg`` of the ``ahriman`` user.
@ -799,7 +903,7 @@ The service provides several commands aim to do easy repository backup and resto
.. code-block:: shell
sudo ahriman repo-restore /tmp/repo.tar.gz
ahriman repo-restore /tmp/repo.tar.gz
An additional argument ``-o``/``--output`` can be used to specify extraction root (``/`` by default).

View File

@ -10,9 +10,9 @@ Initial setup
.. code-block:: shell
sudo ahriman -a x86_64 repo-setup ...
sudo ahriman -a x86_64 service-setup ...
``repo-setup`` literally does the following steps:
``service-setup`` literally does the following steps:
#.
Create ``/var/lib/ahriman/.makepkg.conf`` with ``makepkg.conf`` overrides if required (at least you might want to set ``PACKAGER``):

View File

@ -125,3 +125,8 @@ Setup the trigger
First, put the trigger in any path it can be exported, e.g. by packing the resource into python package (which will lead to import path as ``package.slack_reporter.SlackReporter``) or just put file somewhere it can be accessed by application (e.g. ``/usr/local/lib/slack_reporter.py.SlackReporter``).
After that run application as usual and receive notification in your slack channel.
Trigger configuration schema
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Triggers can expose their configuration schema. It can be achieved by implementing ``CONFIGURATION_SCHEMA`` class variable according to `cerberus <https://docs.python-cerberus.org/>`_ documentation. For more details and examples, please refer to built-in triggers implementations.

View File

@ -1,13 +1,13 @@
# Maintainer: Evgeniy Alekseev
pkgname='ahriman'
pkgver=2.5.4
pkgver=2.6.1
pkgrel=1
pkgdesc="ArcH linux ReposItory MANager"
arch=('any')
url="https://github.com/arcan1s/ahriman"
license=('GPL3')
depends=('devtools' 'git' 'pyalpm' 'python-inflection' 'python-passlib' 'python-requests' 'python-setuptools' 'python-srcinfo')
depends=('devtools' 'git' 'pyalpm' 'python-cerberus' 'python-inflection' 'python-passlib' 'python-requests' 'python-setuptools' 'python-srcinfo')
makedepends=('python-build' 'python-installer' 'python-wheel')
optdepends=('breezy: -bzr packages support'
'darcs: -darcs packages support'

View File

@ -9,4 +9,4 @@ User=ahriman
Group=ahriman
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

View File

@ -23,7 +23,7 @@ build_command = extra-x86_64-build
ignore_packages =
makechrootpkg_flags =
makepkg_flags = --nocolor --ignorearch
triggers = ahriman.core.report.ReportTrigger ahriman.core.upload.UploadTrigger
triggers = ahriman.core.gitremote.RemotePullTrigger ahriman.core.report.ReportTrigger ahriman.core.upload.UploadTrigger ahriman.core.gitremote.RemotePushTrigger
vcs_allowed_age = 604800
[repository]
@ -33,6 +33,12 @@ root = /var/lib/ahriman
[sign]
target =
[remote-pull]
target =
[remote-push]
target =
[report]
target = console
@ -65,4 +71,5 @@ debug_check_host = no
debug_allowed_hosts =
host = 127.0.0.1
static_path = /usr/share/ahriman/templates/static
templates = /usr/share/ahriman/templates
templates = /usr/share/ahriman/templates
unix_socket_unsafe = yes

View File

@ -29,6 +29,7 @@ setup(
dependency_links=[
],
install_requires=[
"cerberus",
"inflection",
"passlib",
"requests",

View File

@ -84,10 +84,10 @@ def _parser() -> argparse.ArgumentParser:
subparsers = parser.add_subparsers(title="command", help="command to run", dest="command", required=True)
_set_aur_search_parser(subparsers)
_set_daemon_parser(subparsers)
_set_help_parser(subparsers)
_set_help_commands_unsafe_parser(subparsers)
_set_key_import_parser(subparsers)
_set_help_updates_parser(subparsers)
_set_help_version_parser(subparsers)
_set_package_add_parser(subparsers)
_set_package_remove_parser(subparsers)
_set_package_status_parser(subparsers)
@ -99,24 +99,26 @@ def _parser() -> argparse.ArgumentParser:
_set_patch_set_add_parser(subparsers)
_set_repo_backup_parser(subparsers)
_set_repo_check_parser(subparsers)
_set_repo_clean_parser(subparsers)
_set_repo_config_parser(subparsers)
_set_repo_daemon_parser(subparsers)
_set_repo_rebuild_parser(subparsers)
_set_repo_remove_unknown_parser(subparsers)
_set_repo_report_parser(subparsers)
_set_repo_restore_parser(subparsers)
_set_repo_setup_parser(subparsers)
_set_repo_sign_parser(subparsers)
_set_repo_status_update_parser(subparsers)
_set_repo_sync_parser(subparsers)
_set_repo_tree_parser(subparsers)
_set_repo_triggers_parser(subparsers)
_set_repo_update_parser(subparsers)
_set_shell_parser(subparsers)
_set_service_clean_parser(subparsers)
_set_service_config_parser(subparsers)
_set_service_config_validate_parser(subparsers)
_set_service_key_import_parser(subparsers)
_set_service_setup_parser(subparsers)
_set_service_shell_parser(subparsers)
_set_user_add_parser(subparsers)
_set_user_list_parser(subparsers)
_set_user_remove_parser(subparsers)
_set_version_parser(subparsers)
_set_web_parser(subparsers)
return parser
@ -146,35 +148,6 @@ def _set_aur_search_parser(root: SubParserAction) -> argparse.ArgumentParser:
return parser
def _set_daemon_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for daemon subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("daemon", help="run application as daemon",
description="start process which periodically will run update process",
formatter_class=_formatter)
parser.add_argument("-i", "--interval", help="interval between runs in seconds", type=int, default=60 * 60 * 12)
parser.add_argument("--aur", help="enable or disable checking for AUR updates. Implies --no-vcs",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--local", help="enable or disable checking of local packages for updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--manual", help="include or exclude manual updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--vcs", help="enable or disable checking of VCS packages",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
"-yy to force refresh even if up to date",
action="count", default=False)
parser.set_defaults(handler=handlers.Daemon, dry_run=False, exit_code=False, package=[])
return parser
def _set_help_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for listing help subcommand
@ -189,8 +162,8 @@ def _set_help_parser(root: SubParserAction) -> argparse.ArgumentParser:
description="show help message for application or command and exit",
formatter_class=_formatter)
parser.add_argument("command", help="show help message for specific command", nargs="?")
parser.set_defaults(handler=handlers.Help, architecture=[""], lock=None, report=False, quiet=True,
unsafe=True, parser=_parser)
parser.set_defaults(handler=handlers.Help, architecture=[""], lock=None, report=False, quiet=True, unsafe=True,
parser=_parser)
return parser
@ -213,9 +186,9 @@ def _set_help_commands_unsafe_parser(root: SubParserAction) -> argparse.Argument
return parser
def _set_key_import_parser(root: SubParserAction) -> argparse.ArgumentParser:
def _set_help_updates_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for key import subcommand
add parser for service update check subcommand
Args:
root(SubParserAction): subparsers for the commands
@ -223,16 +196,28 @@ def _set_key_import_parser(root: SubParserAction) -> argparse.ArgumentParser:
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("key-import", help="import PGP key",
description="import PGP key from public sources to the repository user",
epilog="By default ahriman runs build process with package sources validation "
"(in case if signature and keys are available in PKGBUILD). This process will "
"fail in case if key is not known for build user. This subcommand can be used "
"in order to import the PGP key to user keychain.",
parser = root.add_parser("help-updates", help="check for service updates",
description="request AUR for current version and compare with current service version",
formatter_class=_formatter)
parser.add_argument("--key-server", help="key server for key import", default="keyserver.ubuntu.com")
parser.add_argument("key", help="PGP key to import from public server")
parser.set_defaults(handler=handlers.KeyImport, architecture=[""], lock=None, report=False)
parser.add_argument("-e", "--exit-code", help="return non-zero exit code if updates available", action="store_true")
parser.set_defaults(handler=handlers.ServiceUpdates, architecture=[""], lock=None, report=False, quiet=True,
unsafe=True)
return parser
def _set_help_version_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for version subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("help-version", aliases=["version"], help="application version",
description="print application and its dependencies versions", formatter_class=_formatter)
parser.set_defaults(handler=handlers.Versions, architecture=[""], lock=None, report=False, quiet=True, unsafe=True)
return parser
@ -399,7 +384,8 @@ def _set_patch_list_parser(root: SubParserAction) -> argparse.ArgumentParser:
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", action="store_true")
parser.add_argument("-v", "--variable", help="if set, show only patches for specified PKGBUILD variables",
action="append")
parser.set_defaults(handler=handlers.Patch, action=Action.List, architecture=[""], lock=None, report=False)
parser.set_defaults(handler=handlers.Patch, action=Action.List, architecture=[""], lock=None, report=False,
unsafe=True)
return parser
@ -481,7 +467,7 @@ def _set_repo_check_parser(root: SubParserAction) -> argparse.ArgumentParser:
formatter_class=_formatter)
parser.add_argument("package", help="filter check by package base", nargs="*")
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", action="store_true")
parser.add_argument("--vcs", help="enable or disable checking of VCS packages",
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
"-yy to force refresh even if up to date",
@ -490,9 +476,9 @@ def _set_repo_check_parser(root: SubParserAction) -> argparse.ArgumentParser:
return parser
def _set_repo_clean_parser(root: SubParserAction) -> argparse.ArgumentParser:
def _set_repo_daemon_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for repository clean subcommand
add parser for daemon subcommand
Args:
root(SubParserAction): subparsers for the commands
@ -500,39 +486,22 @@ def _set_repo_clean_parser(root: SubParserAction) -> argparse.ArgumentParser:
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-clean", aliases=["clean"], help="clean local caches",
description="remove local caches",
epilog="The subcommand clears every temporary directories (builds, caches etc). Normally "
"you should not run this command manually. Also in case if you are going to clear "
"the chroot directories you will need root privileges.",
parser = root.add_parser("repo-daemon", aliases=["daemon"], help="run application as daemon",
description="start process which periodically will run update process",
formatter_class=_formatter)
parser.add_argument("--cache", help="clear directory with package caches",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--chroot", help="clear build chroot", action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--manual", help="clear manually added packages queue",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--packages", help="clear directory with built packages",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--pacman", help="clear directory with pacman local database cache",
action=argparse.BooleanOptionalAction, default=False)
parser.set_defaults(handler=handlers.Clean, quiet=True, unsafe=True)
return parser
def _set_repo_config_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for config subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-config", aliases=["config"], help="dump configuration",
description="dump configuration for the specified architecture",
formatter_class=_formatter)
parser.set_defaults(handler=handlers.Dump, lock=None, report=False, quiet=True, unsafe=True)
parser.add_argument("-i", "--interval", help="interval between runs in seconds", type=int, default=60 * 60 * 12)
parser.add_argument("--aur", help="enable or disable checking for AUR updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--local", help="enable or disable checking of local packages for updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--manual", help="include or exclude manual updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
"-yy to force refresh even if up to date",
action="count", default=False)
parser.set_defaults(handler=handlers.Daemon, dry_run=False, exit_code=False, package=[])
return parser
@ -616,39 +585,6 @@ def _set_repo_restore_parser(root: SubParserAction) -> argparse.ArgumentParser:
return parser
def _set_repo_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for setup subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-setup", aliases=["init", "repo-init", "setup"], help="initial service configuration",
description="create initial service configuration, requires root",
epilog="Create _minimal_ configuration for the service according to provided options.",
formatter_class=_formatter)
parser.add_argument("--build-as-user", help="force makepkg user to the specific one")
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
type=Path, default=Path("/usr/share/devtools/pacman-extra.conf"))
parser.add_argument("--makeflags-jobs", help="append MAKEFLAGS variable with parallelism set to number of cores",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--multilib", help="add or do not multilib repository",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--packager", help="packager name and email", required=True)
parser.add_argument("--repository", help="repository name", required=True)
parser.add_argument("--sign-key", help="sign key id")
parser.add_argument("--sign-target", help="sign options", action="append",
type=SignSettings.from_option, choices=enum_values(SignSettings))
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", type=Path)
parser.set_defaults(handler=handlers.Setup, lock=None, report=False, quiet=True, unsafe=True)
return parser
def _set_repo_sign_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for sign subcommand
@ -718,7 +654,7 @@ def _set_repo_tree_parser(root: SubParserAction) -> argparse.ArgumentParser:
parser = root.add_parser("repo-tree", help="dump repository tree",
description="dump repository tree based on packages dependencies",
formatter_class=_formatter)
parser.set_defaults(handler=handlers.Structure, lock=None, report=False, quiet=True)
parser.set_defaults(handler=handlers.Structure, lock=None, report=False, quiet=True, unsafe=True)
return parser
@ -757,13 +693,13 @@ def _set_repo_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
parser.add_argument("package", help="filter check by package base", nargs="*")
parser.add_argument("--dry-run", help="just perform check for updates, same as check command", action="store_true")
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty", action="store_true")
parser.add_argument("--aur", help="enable or disable checking for AUR updates. Implies --no-vcs",
parser.add_argument("--aur", help="enable or disable checking for AUR updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--local", help="enable or disable checking of local packages for updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--manual", help="include or exclude manual updates",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--vcs", help="enable or disable checking of VCS packages",
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
"-yy to force refresh even if up to date",
@ -772,7 +708,131 @@ def _set_repo_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
return parser
def _set_shell_parser(root: SubParserAction) -> argparse.ArgumentParser:
def _set_service_clean_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for repository clean subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("service-clean", aliases=["clean", "repo-clean"], help="clean local caches",
description="remove local caches",
epilog="The subcommand clears every temporary directories (builds, caches etc). Normally "
"you should not run this command manually. Also in case if you are going to clear "
"the chroot directories you will need root privileges.",
formatter_class=_formatter)
parser.add_argument("--cache", help="clear directory with package caches",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--chroot", help="clear build chroot", action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--manual", help="clear manually added packages queue",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--packages", help="clear directory with built packages",
action=argparse.BooleanOptionalAction, default=False)
parser.add_argument("--pacman", help="clear directory with pacman local database cache",
action=argparse.BooleanOptionalAction, default=False)
parser.set_defaults(handler=handlers.Clean, quiet=True, unsafe=True)
return parser
def _set_service_config_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for config subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("service-config", aliases=["config", "repo-config"], help="dump configuration",
description="dump configuration for the specified architecture",
formatter_class=_formatter)
parser.set_defaults(handler=handlers.Dump, lock=None, report=False, quiet=True, unsafe=True)
return parser
def _set_service_config_validate_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for config validation subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("service-config-validate", aliases=["config-validate", "repo-config-validate"],
help="validate system configuration",
description="validate configuration and print found errors",
formatter_class=_formatter)
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if configuration is invalid",
action="store_true")
parser.set_defaults(handler=handlers.Validate, lock=None, report=False, quiet=True, unsafe=True)
return parser
def _set_service_key_import_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for key import subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("service-key-import", aliases=["key-import"], help="import PGP key",
description="import PGP key from public sources to the repository user",
epilog="By default ahriman runs build process with package sources validation "
"(in case if signature and keys are available in PKGBUILD). This process will "
"fail in case if key is not known for build user. This subcommand can be used "
"in order to import the PGP key to user keychain.",
formatter_class=_formatter)
parser.add_argument("--key-server", help="key server for key import", default="keyserver.ubuntu.com")
parser.add_argument("key", help="PGP key to import from public server")
parser.set_defaults(handler=handlers.KeyImport, architecture=[""], lock=None, report=False)
return parser
def _set_service_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for setup subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("service-setup", aliases=["init", "repo-init", "repo-setup", "setup"],
help="initial service configuration",
description="create initial service configuration, requires root",
epilog="Create _minimal_ configuration for the service according to provided options.",
formatter_class=_formatter)
parser.add_argument("--build-as-user", help="force makepkg user to the specific one")
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
type=Path, default=Path("/usr/share/devtools/pacman-extra.conf"))
parser.add_argument("--makeflags-jobs", help="append MAKEFLAGS variable with parallelism set to number of cores",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--mirror", help="use the specified explicitly mirror instead of including mirrorlist")
parser.add_argument("--multilib", help="add or do not multilib repository",
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--packager", help="packager name and email", required=True)
parser.add_argument("--repository", help="repository name", required=True)
parser.add_argument("--sign-key", help="sign key id")
parser.add_argument("--sign-target", help="sign options", action="append",
type=SignSettings.from_option, choices=enum_values(SignSettings))
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", type=Path)
parser.set_defaults(handler=handlers.Setup, lock=None, report=False, quiet=True, unsafe=True)
return parser
def _set_service_shell_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for shell subcommand
@ -782,7 +842,7 @@ def _set_shell_parser(root: SubParserAction) -> argparse.ArgumentParser:
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("shell", help="invoke python shell",
parser = root.add_parser("service-shell", aliases=["shell"], help="invoke python shell",
description="drop into python shell while having created application",
formatter_class=_formatter)
parser.add_argument("code", help="instead of dropping into shell, just execute the specified code", nargs="?")
@ -814,7 +874,7 @@ def _set_user_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
type=UserAccess, choices=enum_values(UserAccess), default=UserAccess.Read)
parser.add_argument("-s", "--secure", help="set file permissions to user-only", action="store_true")
parser.set_defaults(handler=handlers.Users, action=Action.Update, architecture=[""], lock=None, report=False,
quiet=True, unsafe=True)
quiet=True)
return parser
@ -854,24 +914,7 @@ def _set_user_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
formatter_class=_formatter)
parser.add_argument("username", help="username for web service")
parser.set_defaults(handler=handlers.Users, action=Action.Remove, architecture=[""], lock=None, report=False, # nosec
password="", quiet=True, unsafe=True)
return parser
def _set_version_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for version subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("version", help="application version",
description="print application and its dependencies versions", formatter_class=_formatter)
parser.set_defaults(handler=handlers.Versions, architecture=[""], lock=None, report=False, quiet=True,
unsafe=True)
password="", quiet=True)
return parser
@ -886,7 +929,8 @@ def _set_web_parser(root: SubParserAction) -> argparse.ArgumentParser:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("web", help="web server", description="start web server", formatter_class=_formatter)
parser.set_defaults(handler=handlers.Web, lock=None, report=False, parser=_parser)
parser.set_defaults(handler=handlers.Web, lock=Path(tempfile.gettempdir()) / "ahriman-web.lock", report=False,
parser=_parser)
return parser

View File

@ -175,7 +175,7 @@ class ApplicationRepository(ApplicationProperties):
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()})
updates.update({package.base: package for package in self.repository.updates_local(vcs=vcs)})
if manual:
updates.update({package.base: package for package in self.repository.updates_manual()})

View File

@ -32,6 +32,7 @@ from ahriman.application.handlers.remove import Remove
from ahriman.application.handlers.remove_unknown import RemoveUnknown
from ahriman.application.handlers.restore import Restore
from ahriman.application.handlers.search import Search
from ahriman.application.handlers.service_updates import ServiceUpdates
from ahriman.application.handlers.setup import Setup
from ahriman.application.handlers.shell import Shell
from ahriman.application.handlers.sign import Sign
@ -42,5 +43,6 @@ from ahriman.application.handlers.triggers import Triggers
from ahriman.application.handlers.unsafe_commands import UnsafeCommands
from ahriman.application.handlers.update import Update
from ahriman.application.handlers.users import Users
from ahriman.application.handlers.validate import Validate
from ahriman.application.handlers.versions import Versions
from ahriman.application.handlers.web import Web

View File

@ -0,0 +1,65 @@
#
# Copyright (c) 2021-2023 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 argparse
from typing import Type
from ahriman import version
from ahriman.application.application import Application
from ahriman.application.handlers import Handler
from ahriman.core.configuration import Configuration
from ahriman.core.formatters import UpdatePrinter
from ahriman.models.package import Package
class ServiceUpdates(Handler):
"""
service updates handler
"""
ALLOW_AUTO_ARCHITECTURE_RUN = False # it should be called only as "no-architecture"
@classmethod
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration, *,
report: bool, unsafe: bool) -> None:
"""
callback for command line
Args:
args(argparse.Namespace): command line args
architecture(str): repository architecture
configuration(Configuration): configuration instance
report(bool): force enable or disable reporting
unsafe(bool): if set no user check will be performed before path creation
"""
application = Application(architecture, configuration, report=report, unsafe=unsafe)
remote = Package.from_aur("ahriman", application.repository.pacman)
release = remote.version.rsplit("-", 1)[-1] # we don't store pkgrel locally, so we just append it
local_version = f"{version.__version__}-{release}"
# technically we would like to compare versions, but it is fine to raise an exception in case if locally
# installed package is newer than in AUR
same_version = remote.version == local_version
if same_version:
return
UpdatePrinter(remote, local_version).print(verbose=True, separator=" -> ")
ServiceUpdates.check_if_empty(args.exit_code, not same_version)

View File

@ -21,7 +21,7 @@ import argparse
from pathlib import Path
from pwd import getpwuid
from typing import Type
from typing import Optional, Type
from ahriman.application.application import Application
from ahriman.application.handlers import Handler
@ -58,15 +58,14 @@ class Setup(Handler):
report(bool): force enable or disable reporting
unsafe(bool): if set no user check will be performed before path creation
"""
Setup.configuration_create_ahriman(args, architecture, args.repository, configuration.include,
configuration.repository_paths)
Setup.configuration_create_ahriman(args, architecture, args.repository, configuration)
configuration.reload()
application = Application(architecture, configuration, report=report, unsafe=unsafe)
Setup.configuration_create_makepkg(args.packager, args.makeflags_jobs, application.repository.paths)
Setup.executable_create(application.repository.paths, args.build_command, architecture)
Setup.configuration_create_devtools(args.build_command, architecture, args.from_configuration,
Setup.configuration_create_devtools(args.build_command, architecture, args.from_configuration, args.mirror,
args.multilib, args.repository, application.repository.paths)
Setup.configuration_create_sudo(application.repository.paths, args.build_command, architecture)
@ -91,7 +90,7 @@ class Setup(Handler):
@staticmethod
def configuration_create_ahriman(args: argparse.Namespace, architecture: str, repository: str,
include_path: Path, paths: RepositoryPaths) -> None:
root: Configuration) -> None:
"""
create service specific configuration
@ -99,37 +98,41 @@ class Setup(Handler):
args(argparse.Namespace): command line args
architecture(str): repository architecture
repository(str): repository name
include_path(Path): path to directory with configuration includes
paths(RepositoryPaths): repository paths instance
root(Configuration): root configuration instance
"""
configuration = Configuration()
section = Configuration.section_name("build", architecture)
build_command = Setup.build_command(paths.root, args.build_command, architecture)
build_command = Setup.build_command(root.repository_paths.root, args.build_command, architecture)
configuration.set_option(section, "build_command", str(build_command))
configuration.set_option("repository", "name", repository)
if args.build_as_user is not None:
configuration.set_option(section, "makechrootpkg_flags", f"-U {args.build_as_user}")
section = Configuration.section_name("alpm", architecture)
if args.mirror is not None:
configuration.set_option(section, "mirror", args.mirror)
if not args.multilib:
repositories = filter(lambda r: r != "multilib", root.getlist("alpm", "repositories"))
configuration.set_option(section, "repositories", " ".join(repositories))
section = Configuration.section_name("sign", architecture)
if args.sign_key is not None:
section = Configuration.section_name("sign", architecture)
configuration.set_option(section, "target", " ".join([target.name.lower() for target in args.sign_target]))
configuration.set_option(section, "key", args.sign_key)
section = Configuration.section_name("web", architecture)
if args.web_port is not None:
section = Configuration.section_name("web", architecture)
configuration.set_option(section, "port", str(args.web_port))
if args.web_unix_socket is not None:
section = Configuration.section_name("web", architecture)
configuration.set_option(section, "unix_socket", str(args.web_unix_socket))
target = include_path / "00-setup-overrides.ini"
target = root.include / "00-setup-overrides.ini"
with target.open("w") as ahriman_configuration:
configuration.write(ahriman_configuration)
@staticmethod
def configuration_create_devtools(prefix: str, architecture: str, source: Path,
def configuration_create_devtools(prefix: str, architecture: str, source: Path, mirror: Optional[str],
multilib: bool, repository: str, paths: RepositoryPaths) -> None:
"""
create configuration for devtools based on ``source`` configuration
@ -141,6 +144,7 @@ class Setup(Handler):
prefix(str): command prefix in {prefix}-{architecture}-build
architecture(str): repository architecture
source(Path): path to source configuration file
mirror(Optional[str]): link to package server mirror
multilib(bool): add or do not multilib repository to the configuration
repository(str): repository name
paths(RepositoryPaths): repository paths instance
@ -163,6 +167,14 @@ class Setup(Handler):
if multilib:
configuration.set_option("multilib", "Include", str(Setup.MIRRORLIST_PATH))
# override Include option to Server in case if mirror option set
if mirror is not None:
for section in filter(lambda s: s != "options", configuration.sections()):
if configuration.get(section, "Include", fallback=None) != str(Setup.MIRRORLIST_PATH):
continue
configuration.remove_option(section, "Include")
configuration.set_option(section, "Server", mirror)
# add repository itself
configuration.set_option(repository, "SigLevel", "Optional TrustAll") # we don't care
configuration.set_option(repository, "Server", f"file://{paths.repository}")

View File

@ -48,6 +48,6 @@ class Triggers(Handler):
application = Application(architecture, configuration, report=report, unsafe=unsafe)
if args.trigger:
loader = application.repository.triggers
loader.triggers = [loader.load_trigger(trigger) for trigger in args.trigger]
loader.triggers = [loader.load_trigger(trigger, architecture, configuration) for trigger in args.trigger]
application.on_start()
application.on_result(Result())

View File

@ -82,4 +82,4 @@ class UnsafeCommands(Handler):
# should never fail
# pylint: disable=protected-access
subparser = next(action for action in parser._actions if isinstance(action, argparse._SubParsersAction))
return [action_name for action_name, action in subparser.choices.items() if action.get_default("unsafe")]
return sorted(action_name for action_name, action in subparser.choices.items() if action.get_default("unsafe"))

View File

@ -0,0 +1,135 @@
#
# Copyright (c) 2021-2023 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 argparse
import copy
from typing import Any, Dict, Type
from ahriman.application.handlers import Handler
from ahriman.core.configuration import Configuration
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA, ConfigurationSchema
from ahriman.core.configuration.validator import Validator
from ahriman.core.exceptions import ExtensionError
from ahriman.core.formatters import ValidationPrinter
from ahriman.core.triggers import TriggerLoader
class Validate(Handler):
"""
configuration validator handler
"""
ALLOW_AUTO_ARCHITECTURE_RUN = False
@classmethod
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration, *,
report: bool, unsafe: bool) -> None:
"""
callback for command line
Args:
args(argparse.Namespace): command line args
architecture(str): repository architecture
configuration(Configuration): configuration instance
report(bool): force enable or disable reporting
unsafe(bool): if set no user check will be performed before path creation
"""
schema = Validate.schema(architecture, configuration)
validator = Validator(instance=configuration, schema=schema)
if validator.validate(configuration.dump()):
return # no errors found
for node, errors in validator.errors.items():
ValidationPrinter(node, errors).print(verbose=True)
# as we reach this part it means that we always have errors
Validate.check_if_empty(args.exit_code, True)
@staticmethod
def schema(architecture: str, configuration: Configuration) -> ConfigurationSchema:
"""
get schema with triggers
Args:
architecture(str): repository architecture
configuration(Configuration): configuration instance
Returns:
ConfigurationSchema: configuration validation schema
"""
root = copy.deepcopy(CONFIGURATION_SCHEMA)
# create trigger loader instance
loader = TriggerLoader()
for trigger in loader.selected_triggers(configuration):
try:
trigger_class = loader.load_trigger_class(trigger)
except ExtensionError:
continue
# default settings if any
for schema_name, schema in trigger_class.configuration_schema(architecture, None).items():
erased = Validate.schema_erase_required(copy.deepcopy(schema))
root[schema_name] = Validate.schema_merge(root.get(schema_name, {}), erased)
# settings according to enabled triggers
for schema_name, schema in trigger_class.configuration_schema(architecture, configuration).items():
root[schema_name] = Validate.schema_merge(root.get(schema_name, {}), copy.deepcopy(schema))
return root
@staticmethod
def schema_erase_required(schema: ConfigurationSchema) -> ConfigurationSchema:
"""
recursively remove required field from supplied cerberus schema
Args:
schema(ConfigurationSchema): source schema from which required field must be removed
Returns:
ConfigurationSchema: schema without required fields. Note, that source schema will be modified in-place
"""
schema.pop("required", None)
for value in filter(lambda v: isinstance(v, dict), schema.values()):
Validate.schema_erase_required(value)
return schema
@staticmethod
def schema_merge(source: Dict[str, Any], schema: Dict[str, Any]) -> Dict[str, Any]:
"""
merge child schema into source. In case if source already contains values, new keys will be added
(possibly with overrides - in case if such key already set also)
Args:
source(Dict[str, Any]): source (current) schema into which will be merged
schema(Dict[str, Any]): new schema to be merged
Returns:
Dict[str, Any]: schema with added elements from source schema if they were set before and not presented
in the new one. Note, that schema will be modified in-place
"""
for key, value in source.items():
if key not in schema:
schema[key] = value # new key found, just add it as is
elif isinstance(value, dict):
# value is dictionary, so we need to go deeper
Validate.schema_merge(value, schema[key])
return schema

View File

@ -21,7 +21,6 @@ from __future__ import annotations
import argparse
from pathlib import Path
from types import TracebackType
from typing import Literal, Optional, Type
@ -68,7 +67,8 @@ class Lock(LazyLogging):
architecture(str): repository architecture
configuration(Configuration): configuration instance
"""
self.path = Path(f"{args.lock}_{architecture}") if args.lock is not None else None
self.path = args.lock.with_stem(f"{args.lock.stem}_{architecture}") if args.lock is not None else None
print(self.path)
self.force = args.force
self.unsafe = args.unsafe

View File

@ -45,8 +45,8 @@ class Pacman(LazyLogging):
Args:
architecture(str): repository architecture
configuration(Configuration): configuration instance
refresh_database(int): synchronize local cache to remote. If set to ``0``, no syncronization will be
enabled, if set to ``1`` - normal syncronization, if set to ``2`` - force syncronization
refresh_database(int): synchronize local cache to remote. If set to ``0``, no synchronization will be
enabled, if set to ``1`` - normal synchronization, if set to ``2`` - force synchronization
"""
self.__create_handle_fn: Callable[[], Handle] = lambda: self.__create_handle(
architecture, configuration, refresh_database=refresh_database)
@ -58,8 +58,8 @@ class Pacman(LazyLogging):
Args:
architecture(str): repository architecture
configuration(Configuration): configuration instance
refresh_database(int): synchronize local cache to remote. If set to ``0``, no syncronization will be
enabled, if set to ``1`` - normal syncronization, if set to ``2`` - force syncronization
refresh_database(int): synchronize local cache to remote. If set to ``0``, no synchronization will be
enabled, if set to ``1`` - normal synchronization, if set to ``2`` - force synchronization
Returns:
Handle: fully initialized pacman handle
@ -126,7 +126,7 @@ class Pacman(LazyLogging):
Returns:
DB: loaded pacman database instance
"""
self.logger.info("loading pacman databases")
self.logger.info("loading pacman database %s", repository)
database: DB = handle.register_syncdb(repository, SIG_PACKAGE)
# replace variables in mirror address
database.servers = [mirror.replace("$repo", repository).replace("$arch", architecture)]
@ -138,7 +138,7 @@ class Pacman(LazyLogging):
Args:
handle(Handle): pacman handle which will be used for database sync
force(bool): force database syncronization (same as ``pacman -Syy``)
force(bool): force database synchronization (same as ``pacman -Syy``)
"""
self.logger.info("refresh ahriman's home pacman database (force refresh %s)", force)
transaction = handle.init_transaction()

View File

@ -18,6 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from ahriman.core.auth.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth

View File

@ -78,10 +78,10 @@ class Auth(LazyLogging):
"""
provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled"))
if provider == AuthSettings.Configuration:
from ahriman.core.auth import Mapping
from ahriman.core.auth.mapping import Mapping
return Mapping(configuration, database)
if provider == AuthSettings.OAuth:
from ahriman.core.auth import OAuth
from ahriman.core.auth.oauth import OAuth
return OAuth(configuration, database)
return cls(configuration)

View File

@ -21,7 +21,7 @@ import aioauth_client
from typing import Optional, Type
from ahriman.core.auth import Mapping
from ahriman.core.auth.mapping import Mapping
from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite
from ahriman.core.exceptions import OptionError

View File

@ -0,0 +1,20 @@
#
# Copyright (c) 2021-2023 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 ahriman.core.configuration.configuration import Configuration

View File

@ -24,7 +24,7 @@ import shlex
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Type
from typing import Any, Callable, Dict, List, Optional, Tuple, Type
from ahriman.core.exceptions import InitializeError
from ahriman.models.repository_paths import RepositoryPaths
@ -61,8 +61,9 @@ class Configuration(configparser.RawConfigParser):
>>> path, architecture = configuration.check_loaded()
"""
ARCHITECTURE_SPECIFIC_SECTIONS = ["build", "sign", "web"]
ARCHITECTURE_SPECIFIC_SECTIONS = ["alpm", "build", "sign", "web"]
SYSTEM_CONFIGURATION_PATH = Path(sys.prefix) / "share" / "ahriman" / "settings" / "ahriman.ini"
converters: Dict[str, Callable[[str], Any]] # typing guard
def __init__(self, allow_no_value: bool = False) -> None:
"""
@ -74,7 +75,7 @@ class Configuration(configparser.RawConfigParser):
"""
configparser.RawConfigParser.__init__(self, allow_no_value=allow_no_value, converters={
"list": shlex.split,
"path": self.__convert_path,
"path": self._convert_path,
})
self.architecture: Optional[str] = None
self.path: Optional[Path] = None
@ -141,7 +142,7 @@ class Configuration(configparser.RawConfigParser):
"""
return f"{section}:{suffix}"
def __convert_path(self, value: str) -> Path:
def _convert_path(self, value: str) -> Path:
"""
convert string value to path object
@ -188,7 +189,7 @@ class Configuration(configparser.RawConfigParser):
def getpath(self, *args: Any, **kwargs: Any) -> Path: ... # type: ignore
def gettype(self, section: str, architecture: str) -> Tuple[str, str]:
def gettype(self, section: str, architecture: str, *, fallback: Optional[str] = None) -> Tuple[str, str]:
"""
get type variable with fallback to old logic. Despite the fact that it has same semantics as other get* methods,
but it has different argument list
@ -196,6 +197,8 @@ class Configuration(configparser.RawConfigParser):
Args:
section(str): section name
architecture(str): repository architecture
fallback(Optional[str], optional): optional fallback type if any. If set, second element of the tuple will
be always set to this value (Default value = None)
Returns:
Tuple[str, str]: section name and found type name
@ -203,9 +206,8 @@ class Configuration(configparser.RawConfigParser):
Raises:
configparser.NoSectionError: in case if no section found
"""
group_type = self.get(section, "type", fallback=None) # new-style logic
if group_type is not None:
return section, group_type
if (group_type := self.get(section, "type", fallback=fallback)) is not None:
return section, group_type # new-style logic
# okay lets check for the section with architecture name
full_section = self.section_name(section, architecture)
if self.has_section(full_section):
@ -273,14 +275,14 @@ class Configuration(configparser.RawConfigParser):
self.load(path)
self.merge_sections(architecture)
def set_option(self, section: str, option: str, value: Optional[str]) -> None:
def set_option(self, section: str, option: str, value: str) -> None:
"""
set option. Unlike default ``configparser.RawConfigParser.set`` it also creates section if it does not exist
Args:
section(str): section name
option(str): option name
value(Optional[str]): option value as string in parsable format
value(str): option value as string in parsable format
"""
if not self.has_section(section):
self.add_section(section)

View File

@ -0,0 +1,294 @@
#
# Copyright (c) 2021-2023 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 typing import Any, Dict
__all__ = ["CONFIGURATION_SCHEMA", "ConfigurationSchema"]
ConfigurationSchema = Dict[str, Dict[str, Any]]
CONFIGURATION_SCHEMA: ConfigurationSchema = {
"settings": {
"type": "dict",
"schema": {
"include": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"database": {
"type": "path",
"coerce": "absolute_path",
"required": True,
},
"logging": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
},
},
"alpm": {
"type": "dict",
"schema": {
"database": {
"type": "path",
"coerce": "absolute_path",
"required": True,
},
"mirror": {
"type": "string",
"required": True,
},
"repositories": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
"required": True,
"empty": False,
},
"root": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"use_ahriman_cache": {
"type": "boolean",
"coerce": "boolean",
"required": True,
},
},
},
"auth": {
"type": "dict",
"schema": {
"target": {
"type": "string",
"oneof": [
{"allowed": ["disabled"]},
{"allowed": ["configuration", "mapping"], "dependencies": ["salt"]},
{"allowed": ["oauth"], "dependencies": [
"client_id", "client_secret", "oauth_provider", "oauth_scopes", "salt"
]},
],
},
"allow_read_only": {
"type": "boolean",
"coerce": "boolean",
"required": True,
},
"client_id": {
"type": "string",
},
"client_secret": {
"type": "string",
},
"max_age": {
"type": "integer",
"coerce": "integer",
},
"oauth_provider": {
"type": "string",
},
"oauth_scopes": {
"type": "string",
},
"salt": {
"type": "string",
},
},
},
"build": {
"type": "dict",
"schema": {
"archbuild_flags": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"build_command": {
"type": "string",
"required": True,
},
"ignore_packages": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"makepkg_flags": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"makechrootpkg_flags": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"triggers": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"vcs_allowed_age": {
"type": "integer",
"coerce": "integer",
},
},
},
"repository": {
"type": "dict",
"schema": {
"name": {
"type": "string",
"required": True,
},
"root": {
"type": "string",
"required": True,
},
},
},
"sign": {
"type": "dict",
"allow_unknown": True,
"keysrules": {
"type": "string",
"anyof_regex": ["^target$", "^key$", "^key_.*"],
},
"schema": {
"target": {
"type": "list",
"coerce": "list",
"oneof": [
{"allowed": []},
{"allowed": ["package", "repository"], "dependencies": ["key"]},
],
},
"key": {
"type": "string",
},
},
},
"web": {
"type": "dict",
"schema": {
"address": {
"type": "string",
},
"debug": {
"type": "boolean",
"coerce": "boolean",
},
"debug_check_host": {
"type": "boolean",
"coerce": "boolean",
},
"debug_allowed_hosts": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
"host": {
"type": "string",
},
"index_url": {
"type": "string",
},
"password": {
"type": "string",
},
"port": {
"type": "integer",
"coerce": "integer",
"min": 0,
"max": 65535,
},
"static_path": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"templates": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"unix_socket": {
"type": "path",
"coerce": "absolute_path",
},
"unix_socket_unsafe": {
"type": "boolean",
"coerce": "boolean",
},
"username": {
"type": "string",
},
},
},
"remote-pull": {
"type": "dict",
"schema": {
"target": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
},
},
"remote-push": {
"type": "dict",
"schema": {
"target": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
},
},
"report": {
"type": "dict",
"schema": {
"target": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
},
},
"upload": {
"type": "dict",
"schema": {
"target": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
},
},
},
}

View File

@ -0,0 +1,117 @@
#
# Copyright (c) 2021-2023 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 cerberus import TypeDefinition, Validator as RootValidator # type: ignore
from pathlib import Path
from typing import Any, List
from ahriman.core.configuration import Configuration
class Validator(RootValidator): # type: ignore
"""
class which defines custom validation methods for the service configuration
Attributes:
instance(Configuration): configuration instance
"""
types_mapping = RootValidator.types_mapping.copy()
types_mapping["path"] = TypeDefinition("path", (Path,), ())
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
default constructor
Args:
instance(Configuration): configuration instance used for extraction
*args(Any): positional arguments to be passed to base validator
**kwargs(): keyword arguments to be passed to base validator
"""
RootValidator.__init__(self, *args, **kwargs)
self.instance: Configuration = kwargs["instance"]
def _normalize_coerce_absolute_path(self, value: str) -> Path:
"""
extract path from string value
Args:
value(str): converting value
Returns:
Path: value converted to path instance according to configuration rules
"""
converted: Path = self.instance.converters["path"](value)
return converted
def _normalize_coerce_boolean(self, value: str) -> bool:
"""
extract boolean from string value
Args:
value(str): converting value
Returns:
bool: value converted to boolean according to configuration rules
"""
# pylint: disable=protected-access
converted: bool = self.instance._convert_to_boolean(value) # type: ignore
return converted
def _normalize_coerce_integer(self, value: str) -> int:
"""
extract integer from string value
Args:
value(str): converting value
Returns:
int: value converted to int according to configuration rules
"""
del self
return int(value)
def _normalize_coerce_list(self, value: str) -> List[str]:
"""
extract string list from string value
Args:
value(str): converting value
Returns:
List[str]: value converted to string list instance according to configuration rules
"""
converted: List[str] = self.instance.converters["list"](value)
return converted
def _validate_path_exists(self, constraint: bool, field: str, value: Path) -> None:
"""
check if paths exists
Args:
constraint(bool): True in case if path must exist and False otherwise
field(str): field name to be checked
value(Path): value to be checked
Examples:
The rule's arguments are validated against this schema:
{"type": "boolean"}
"""
if constraint and not value.exists():
self._error(field, f"Path {value} must exist")

View File

@ -27,6 +27,7 @@ from ahriman.core.formatters.package_printer import PackagePrinter
from ahriman.core.formatters.patch_printer import PatchPrinter
from ahriman.core.formatters.status_printer import StatusPrinter
from ahriman.core.formatters.tree_printer import TreePrinter
from ahriman.core.formatters.validation_printer import ValidationPrinter
from ahriman.core.formatters.update_printer import UpdatePrinter
from ahriman.core.formatters.user_printer import UserPrinter
from ahriman.core.formatters.version_printer import VersionPrinter

View File

@ -41,7 +41,8 @@ class Printer:
for prop in self.properties():
if not verbose and not prop.is_required:
continue
log_fn(f"\t{prop.name}{separator}{prop.value}")
indent = "\t" * prop.indent
log_fn(f"{indent}{prop.name}{separator}{prop.value}")
def properties(self) -> List[Property]:
"""

View File

@ -0,0 +1,77 @@
#
# Copyright (c) 2021-2023 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 typing import Any, Dict, Generator, List, Union
from ahriman.core.formatters import StringPrinter
from ahriman.models.property import Property
class ValidationPrinter(StringPrinter):
"""
print content of the validation errors
Attributes:
node(str): root level name
errors(List[Union[str, Dict[str, Any]]]): validation errors
"""
def __init__(self, node: str, errors: List[Union[str, Dict[str, Any]]]) -> None:
"""
default constructor
Args:
node(str): root level name
errors(List[Union[str, Dict[str, Any]]]): validation errors
"""
StringPrinter.__init__(self, node)
self.node = node
self.errors = errors
@staticmethod
def get_error_messages(node: str, errors: List[Union[str, Dict[str, Any]]],
current_level: int = 1) -> Generator[Property, None, None]:
"""
extract default error message from cerberus class
Args:
node(str): current node level name
errors(List[Union[str, Dict[str, Any]]]): current node validation errors
current_level(int, optional): current level number (Default value = 1)
Yields:
Property: error messages from error tree
"""
for error in errors:
if not isinstance(error, str): # child nodes errors
for child_node, child_errors in error.items():
# increase indentation instead of nodes concatenations
# sometimes it is not only nodes, but rules themselves
yield from ValidationPrinter.get_error_messages(child_node, child_errors, current_level + 1)
else: # current node errors
yield Property(node, error, is_required=True, indent=current_level)
def properties(self) -> List[Property]:
"""
convert content into printable data
Returns:
List[Property]: list of content properties
"""
return list(self.get_error_messages(self.node, self.errors))

View File

@ -17,6 +17,8 @@
# 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 typing import List, Type
from ahriman.core.configuration import Configuration
from ahriman.core.gitremote.remote_pull import RemotePull
from ahriman.core.triggers import Trigger
@ -30,6 +32,22 @@ class RemotePullTrigger(Trigger):
targets(List[str]): git remote target list
"""
CONFIGURATION_SCHEMA = {
"gitremote": {
"type": "dict",
"schema": {
"pull_url": {
"type": "string",
"required": True,
},
"pull_branch": {
"type": "string",
},
},
},
}
CONFIGURATION_SCHEMA_FALLBACK = "gitremote"
def __init__(self, architecture: str, configuration: Configuration) -> None:
"""
default constructor
@ -39,13 +57,27 @@ class RemotePullTrigger(Trigger):
configuration(Configuration): configuration instance
"""
Trigger.__init__(self, architecture, configuration)
self.targets = configuration.getlist("remote-pull", "target", fallback=["gitremote"])
self.targets = self.configuration_sections(configuration)
@classmethod
def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
"""
extract configuration sections from configuration
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: read configuration sections belong to this trigger
"""
return configuration.getlist("remote-pull", "target", fallback=[])
def on_start(self) -> None:
"""
trigger action which will be called at the start of the application
"""
for target in self.targets:
section, _ = self.configuration.gettype(target, self.architecture)
section, _ = self.configuration.gettype(
target, self.architecture, fallback=self.CONFIGURATION_SCHEMA_FALLBACK)
runner = RemotePull(self.configuration, section)
runner.run()

View File

@ -17,7 +17,7 @@
# 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 typing import Iterable
from typing import Iterable, List, Type
from ahriman.core import context
from ahriman.core.configuration import Configuration
@ -37,6 +37,25 @@ class RemotePushTrigger(Trigger):
targets(List[str]): git remote target list
"""
CONFIGURATION_SCHEMA = {
"gitremote": {
"type": "dict",
"schema": {
"commit_author": {
"type": "string",
},
"push_url": {
"type": "string",
"required": True,
},
"push_branch": {
"type": "string",
},
},
},
}
CONFIGURATION_SCHEMA_FALLBACK = "gitremote"
def __init__(self, architecture: str, configuration: Configuration) -> None:
"""
default constructor
@ -46,7 +65,20 @@ class RemotePushTrigger(Trigger):
configuration(Configuration): configuration instance
"""
Trigger.__init__(self, architecture, configuration)
self.targets = configuration.getlist("remote-push", "target", fallback=["gitremote"])
self.targets = self.configuration_sections(configuration)
@classmethod
def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
"""
extract configuration sections from configuration
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: read configuration sections belong to this trigger
"""
return configuration.getlist("remote-push", "target", fallback=[])
def on_result(self, result: Result, packages: Iterable[Package]) -> None:
"""
@ -63,6 +95,7 @@ class RemotePushTrigger(Trigger):
database = ctx.get(ContextKey("database", SQLite))
for target in self.targets:
section, _ = self.configuration.gettype(target, self.architecture)
section, _ = self.configuration.gettype(
target, self.architecture, fallback=self.CONFIGURATION_SCHEMA_FALLBACK)
runner = RemotePush(self.configuration, database, section)
runner.run(result)

View File

@ -17,7 +17,7 @@
# 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 typing import Iterable
from typing import Iterable, List, Type
from ahriman.core.configuration import Configuration
from ahriman.core.triggers import Trigger
@ -34,6 +34,148 @@ class ReportTrigger(Trigger):
targets(List[str]): report target list
"""
CONFIGURATION_SCHEMA = {
"console": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["console"],
},
"use_utf": {
"type": "boolean",
"coerce": "boolean",
},
},
},
"email": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["email"],
},
"full_template_path": {
"type": "path",
"coerce": "absolute_path",
"path_exists": True,
},
"homepage": {
"type": "string",
},
"host": {
"type": "string",
"required": True,
},
"link_path": {
"type": "string",
"required": True,
},
"no_empty_report": {
"type": "boolean",
"coerce": "boolean",
},
"password": {
"type": "string",
},
"port": {
"type": "integer",
"coerce": "integer",
"required": True,
},
"receivers": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
"required": True,
"empty": False,
},
"sender": {
"type": "string",
"required": True,
},
"ssl": {
"type": "string",
"allowed": ["ssl", "starttls", "disabled"],
},
"template_path": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"user": {
"type": "string",
},
},
},
"html": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["html"],
},
"homepage": {
"type": "string",
},
"link_path": {
"type": "string",
"required": True,
},
"path": {
"type": "path",
"coerce": "absolute_path",
"required": True,
},
"template_path": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
},
},
"telegram": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["telegram"],
},
"api_key": {
"type": "string",
"required": True,
},
"chat_id": {
"type": "string",
"required": True,
},
"homepage": {
"type": "string",
},
"link_path": {
"type": "string",
"required": True,
},
"template_path": {
"type": "path",
"coerce": "absolute_path",
"required": True,
"path_exists": True,
},
"template_type": {
"type": "string",
"allowed": ["MarkdownV2", "HTML", "Markdown"],
},
"timeout": {
"type": "integer",
"coerce": "integer",
},
},
},
}
def __init__(self, architecture: str, configuration: Configuration) -> None:
"""
default constructor
@ -43,7 +185,20 @@ class ReportTrigger(Trigger):
configuration(Configuration): configuration instance
"""
Trigger.__init__(self, architecture, configuration)
self.targets = configuration.getlist("report", "target", fallback=[])
self.targets = self.configuration_sections(configuration)
@classmethod
def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
"""
extract configuration sections from configuration
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: read configuration sections belong to this trigger
"""
return configuration.getlist("report", "target", fallback=[])
def on_result(self, result: Result, packages: Iterable[Package]) -> None:
"""

View File

@ -80,4 +80,4 @@ class RepositoryProperties(LazyLogging):
self.sign = GPG(architecture, configuration)
self.repo = Repo(self.name, self.paths, self.sign.repository_sign_args)
self.reporter = Client.load(configuration, report=report)
self.triggers = TriggerLoader(architecture, configuration)
self.triggers = TriggerLoader.load(architecture, configuration)

View File

@ -21,7 +21,6 @@ from typing import Iterable, List
from ahriman.core.build_tools.sources import Sources
from ahriman.core.repository.cleaner import Cleaner
from ahriman.core.util import utcnow
from ahriman.models.package import Package
from ahriman.models.package_source import PackageSource
@ -54,10 +53,6 @@ class UpdateHandler(Cleaner):
Returns:
List[Package]: list of packages which are out-of-dated
"""
# don't think there are packages older then 1970
now = utcnow()
min_vcs_build_date = (now.timestamp() - self.vcs_allowed_age) if vcs else now.timestamp()
result: List[Package] = []
for local in self.packages():
@ -74,8 +69,10 @@ class UpdateHandler(Cleaner):
else:
remote = Package.from_aur(local.base, self.pacman)
calculate_version = not local.is_newer_than(min_vcs_build_date)
if local.is_outdated(remote, self.paths, calculate_version=calculate_version):
if local.is_outdated(
remote, self.paths,
vcs_allowed_age=self.vcs_allowed_age,
calculate_version=vcs):
self.reporter.set_pending(local.base)
result.append(remote)
except Exception:
@ -84,10 +81,13 @@ class UpdateHandler(Cleaner):
return result
def updates_local(self) -> List[Package]:
def updates_local(self, *, vcs: bool) -> List[Package]:
"""
check local packages for updates
Args:
vcs(bool): enable or disable checking of VCS packages
Returns:
List[Package]: list of local packages which are out-of-dated
"""
@ -104,7 +104,9 @@ class UpdateHandler(Cleaner):
if local is None:
self.reporter.set_unknown(remote)
result.append(remote)
elif local.is_outdated(remote, self.paths, calculate_version=True):
elif local.is_outdated(remote, self.paths,
vcs_allowed_age=self.vcs_allowed_age,
calculate_version=vcs):
self.reporter.set_pending(local.base)
result.append(remote)
except Exception:

View File

@ -87,7 +87,7 @@ class Spawn(Thread, LazyLogging):
server(str): PGP key server
"""
kwargs = {} if server is None else {"key-server": server}
self.spawn_process("key-import", key, **kwargs)
self.spawn_process("service-key-import", key, **kwargs)
def packages_add(self, packages: Iterable[str], *, now: bool) -> None:
"""

View File

@ -160,7 +160,9 @@ class WebClient(Client, LazyLogging):
Returns:
str: full url of web service for specific package base
"""
return f"{self.address}/api/v1/packages/{package_base}"
# in case if unix socket is used we need to normalize url
suffix = f"/{package_base}" if package_base else ""
return f"{self.address}/api/v1/packages{suffix}"
def add(self, package: Package, status: BuildStatusEnum) -> None:
"""

View File

@ -17,9 +17,12 @@
# 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 typing import Iterable
from __future__ import annotations
from typing import Iterable, List, Optional, Type
from ahriman.core.configuration import Configuration
from ahriman.core.configuration.schema import ConfigurationSchema
from ahriman.core.log import LazyLogging
from ahriman.models.package import Package
from ahriman.models.result import Result
@ -30,6 +33,9 @@ class Trigger(LazyLogging):
trigger base class
Attributes:
CONFIGURATION_SCHEMA(ConfigurationSchema): (class attribute) configuration schema template
CONFIGURATION_SCHEMA_FALLBACK(Optional[str]): (class attribute) optional fallback option for defining
configuration schema type used
architecture(str): repository architecture
configuration(Configuration): configuration instance
@ -47,10 +53,13 @@ class Trigger(LazyLogging):
>>> configuration = Configuration()
>>> configuration.set_option("build", "triggers", "my.awesome.package.CustomTrigger")
>>>
>>> loader = TriggerLoader("x86_64", configuration)
>>> loader = TriggerLoader.load("x86_64", configuration)
>>> loader.on_result(Result(), [])
"""
CONFIGURATION_SCHEMA: ConfigurationSchema = {}
CONFIGURATION_SCHEMA_FALLBACK: Optional[str] = None
def __init__(self, architecture: str, configuration: Configuration) -> None:
"""
default constructor
@ -62,6 +71,60 @@ class Trigger(LazyLogging):
self.architecture = architecture
self.configuration = configuration
@classmethod
def configuration_schema(cls: Type[Trigger], architecture: str,
configuration: Optional[Configuration]) -> ConfigurationSchema:
"""
configuration schema based on supplied service configuration
Notes:
Schema must be in cerberus format, for details and examples you can check built-in triggers.
Args:
architecture(str): repository architecture
configuration(Optional[Configuration]): configuration instance. If set to None, the default schema
should be returned
Returns:
ConfigurationSchema: configuration schema in cerberus format
"""
if configuration is None:
return cls.CONFIGURATION_SCHEMA
result: ConfigurationSchema = {}
for target in cls.configuration_sections(configuration):
if not configuration.has_section(target):
continue
section, schema_name = configuration.gettype(
target, architecture, fallback=cls.CONFIGURATION_SCHEMA_FALLBACK)
if schema_name not in cls.CONFIGURATION_SCHEMA:
continue
result[section] = cls.CONFIGURATION_SCHEMA[schema_name]
return result
@classmethod
def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
"""
extract configuration sections from configuration
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: read configuration sections belong to this trigger
Examples:
This method can be used in order to extract specific configuration sections which are set by user, e.g.
from sources::
>>> @staticmethod
>>> def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
>>> return configuration.getlist("report", "target", fallback=[])
"""
del configuration
return []
def on_result(self, result: Result, packages: Iterable[Package]) -> None:
"""
trigger action which will be called after build process with process result

View File

@ -17,13 +17,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import annotations
import contextlib
import importlib
import os
from pathlib import Path
from types import ModuleType
from typing import Generator, Iterable
from typing import Generator, Iterable, List, Type
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import ExtensionError
@ -38,8 +40,6 @@ class TriggerLoader(LazyLogging):
trigger loader class
Attributes:
architecture(str): repository architecture
configuration(Configuration): configuration instance
triggers(List[Trigger]): list of loaded triggers according to the configuration
Examples:
@ -50,7 +50,7 @@ class TriggerLoader(LazyLogging):
Having such configuration you can create instance of the loader::
>>> loader = TriggerLoader("x86_64", configuration)
>>> loader = TriggerLoader.load("x86_64", configuration)
>>> print(loader.triggers)
After that you are free to run triggers::
@ -58,23 +58,46 @@ class TriggerLoader(LazyLogging):
>>> loader.on_result(Result(), [])
"""
def __init__(self, architecture: str, configuration: Configuration) -> None:
def __init__(self) -> None:
"""
default constructor
"""
self._on_stop_requested = False
self.triggers: List[Trigger] = []
@classmethod
def load(cls: Type[TriggerLoader], architecture: str, configuration: Configuration) -> TriggerLoader:
"""
create instance from configuration
Args:
architecture(str): repository architecture
configuration(Configuration): configuration instance
"""
self.architecture = architecture
self.configuration = configuration
self._on_stop_requested = False
self.triggers = [
self.load_trigger(trigger)
for trigger in configuration.getlist("build", "triggers")
Returns:
TriggerLoader: fully loaded trigger instance
"""
instance = cls()
instance.triggers = [
instance.load_trigger(trigger, architecture, configuration)
for trigger in instance.selected_triggers(configuration)
]
return instance
@staticmethod
def selected_triggers(configuration: Configuration) -> List[str]:
"""
read configuration and return triggers which are set by settings
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: list of triggers according to configuration
"""
return configuration.getlist("build", "triggers", fallback=[])
@contextlib.contextmanager
def __execute_trigger(self, trigger: Trigger) -> Generator[None, None, None]:
"""
@ -130,16 +153,39 @@ class TriggerLoader(LazyLogging):
except ModuleNotFoundError:
raise ExtensionError(f"Module {package} not found")
def load_trigger(self, module_path: str) -> Trigger:
def load_trigger(self, module_path: str, architecture: str, configuration: Configuration) -> Trigger:
"""
load trigger by module path
Args:
module_path(str): module import path to load
architecture(str): repository architecture
configuration(Configuration): configuration instance
Returns:
Trigger: loaded trigger based on settings
Raises:
InvalidExtension: in case if trigger could not be instantiated
"""
trigger_type = self.load_trigger_class(module_path)
try:
trigger = trigger_type(architecture, configuration)
except Exception:
raise ExtensionError(f"Could not load instance of trigger from {trigger_type} loaded from {module_path}")
return trigger
def load_trigger_class(self, module_path: str) -> Type[Trigger]:
"""
load trigger class by module path
Args:
module_path(str): module import path to load
Returns:
Type[Trigger]: loaded trigger type by module path
Raises:
InvalidExtension: in case if module cannot be loaded from the specified module path or is not a trigger
"""
@ -156,16 +202,11 @@ class TriggerLoader(LazyLogging):
trigger_type = getattr(module, class_name, None)
if not isinstance(trigger_type, type):
raise ExtensionError(f"{class_name} of {package_or_path} is not a type")
if not issubclass(trigger_type, Trigger):
raise ExtensionError(f"Class {class_name} of {package_or_path} is not a Trigger subclass")
self.logger.info("loaded type %s of package %s", class_name, package_or_path)
try:
trigger = trigger_type(self.architecture, self.configuration)
except Exception:
raise ExtensionError(f"Could not load instance of trigger from {class_name} of {package_or_path}")
if not isinstance(trigger, Trigger):
raise ExtensionError(f"Class {class_name} of {package_or_path} is not a Trigger")
return trigger
return trigger_type
def on_result(self, result: Result, packages: Iterable[Package]) -> None:
"""

View File

@ -17,7 +17,7 @@
# 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 typing import Iterable
from typing import Iterable, List, Type
from ahriman.core.configuration import Configuration
from ahriman.core.triggers import Trigger
@ -34,6 +34,86 @@ class UploadTrigger(Trigger):
targets(List[str]): upload target list
"""
CONFIGURATION_SCHEMA = {
"github": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["github"],
},
"owner": {
"type": "string",
"required": True,
},
"password": {
"type": "string",
"required": True,
},
"repository": {
"type": "string",
"required": True,
},
"timeout": {
"type": "integer",
"coerce": "integer",
},
"username": {
"type": "string",
},
},
},
"rsync": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["rsync"],
},
"command": {
"type": "list",
"coerce": "list",
"schema": {"type": "string"},
"required": True,
"empty": False,
},
"remote": {
"type": "string",
"required": True,
},
},
},
"s3": {
"type": "dict",
"schema": {
"type": {
"type": "string",
"allowed": ["s3"],
},
"access_key": {
"type": "string",
"required": True,
},
"bucket": {
"type": "string",
"required": True,
},
"chunk_size": {
"type": "integer",
"coerce": "integer",
},
"region": {
"type": "string",
"required": True,
},
"secret_key": {
"type": "string",
"required": True,
},
},
},
}
def __init__(self, architecture: str, configuration: Configuration) -> None:
"""
default constructor
@ -43,7 +123,20 @@ class UploadTrigger(Trigger):
configuration(Configuration): configuration instance
"""
Trigger.__init__(self, architecture, configuration)
self.targets = configuration.getlist("upload", "target", fallback=[])
self.targets = self.configuration_sections(configuration)
@classmethod
def configuration_sections(cls: Type[Trigger], configuration: Configuration) -> List[str]:
"""
extract configuration sections from configuration
Args:
configuration(Configuration): configuration instance
Returns:
List[str]: read configuration sections belong to this trigger
"""
return configuration.getlist("upload", "target", fallback=[])
def on_result(self, result: Result, packages: Iterable[Package]) -> None:
"""

View File

@ -32,7 +32,7 @@ from ahriman.core.alpm.pacman import Pacman
from ahriman.core.alpm.remote import AUR, Official, OfficialSyncdb
from ahriman.core.exceptions import PackageInfoError
from ahriman.core.log import LazyLogging
from ahriman.core.util import check_output, full_version
from ahriman.core.util import check_output, full_version, utcnow
from ahriman.models.package_description import PackageDescription
from ahriman.models.package_source import PackageSource
from ahriman.models.remote_source import RemoteSource
@ -376,20 +376,29 @@ class Package(LazyLogging):
if package.build_date is not None
)
def is_outdated(self, remote: Package, paths: RepositoryPaths, *, calculate_version: bool) -> bool:
def is_outdated(self, remote: Package, paths: RepositoryPaths, *,
vcs_allowed_age: Union[float, int] = 0,
calculate_version: bool = True) -> bool:
"""
check if package is out-of-dated
Args:
remote(Package): package properties from remote source
paths(RepositoryPaths): repository paths instance. Required for VCS packages cache
vcs_allowed_age(Union[float, int], optional): max age of the built packages before they will be
forced to calculate actual version (Default value = 0)
calculate_version(bool, optional): expand version to actual value (by calculating git versions)
(Default value = True)
Returns:
bool: True if the package is out-of-dated and False otherwise
"""
remote_version = remote.actual_version(paths) if calculate_version else remote.version
min_vcs_build_date = utcnow().timestamp() - vcs_allowed_age
if calculate_version and not self.is_newer_than(min_vcs_build_date):
remote_version = remote.actual_version(paths)
else:
remote_version = remote.version
result: int = vercmp(self.version, remote_version)
return result < 0

View File

@ -30,8 +30,10 @@ class Property:
name(str): name of the property
value(Any): property value
is_required(bool): if set to True then this property is required
indent(int): property indentation level
"""
name: str
value: Any
is_required: bool = field(default=False, kw_only=True)
indent: int = 1

View File

@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__version__ = "2.5.4"
__version__ = "2.6.1"

View File

@ -53,7 +53,7 @@ class LoginView(BaseView):
Examples:
This request must not be used directly.
"""
from ahriman.core.auth import OAuth
from ahriman.core.auth.oauth import OAuth
oauth_provider = self.validator
if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway

View File

@ -20,8 +20,10 @@
import aiohttp_jinja2
import jinja2
import logging
import socket
from aiohttp import web
from typing import Optional
from ahriman.core.auth import Auth
from ahriman.core.configuration import Configuration
@ -34,7 +36,40 @@ from ahriman.web.middlewares.exception_handler import exception_handler
from ahriman.web.routes import setup_routes
__all__ = ["on_shutdown", "on_startup", "run_server", "setup_service"]
__all__ = ["create_socket", "on_shutdown", "on_startup", "run_server", "setup_service"]
def create_socket(configuration: Configuration, application: web.Application) -> Optional[socket.socket]:
"""
create unix socket based on configuration option
Args:
configuration(Configuration): configuration instance
application(web.Application): web application instance
Returns:
Optional[socket.socket]: unix socket object if set by option
"""
unix_socket = configuration.getpath("web", "unix_socket", fallback=None)
if unix_socket is None:
return None # no option set
# create unix socket and bind it
unix_socket.unlink(missing_ok=True) # remove socket file if it wasn't removed somehow before
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(str(unix_socket))
# allow everyone to write to the socket, otherwise API methods are not allowed by non-ahriman user
# by default sockets are created with same rights as directory is, but it seems that x bit is not really required
# see also https://github.com/aio-libs/aiohttp/issues/4155
if configuration.getboolean("web", "unix_socket_unsafe", fallback=True):
unix_socket.chmod(0o666) # for the glory of satan of course
# register socket removal
async def remove_socket(_: web.Application) -> None:
unix_socket.unlink(missing_ok=True)
application.on_shutdown.append(remove_socket)
return sock
async def on_shutdown(application: web.Application) -> None:
@ -78,9 +113,9 @@ def run_server(application: web.Application) -> None:
configuration: Configuration = application["configuration"]
host = configuration.get("web", "host")
port = configuration.getint("web", "port")
unix_socket = configuration.get("web", "unix_socket", fallback=None)
unix_socket = create_socket(configuration, application)
web.run_app(application, host=host, port=port, path=unix_socket, handle_signals=False,
web.run_app(application, host=host, port=port, sock=unix_socket, handle_signals=False,
access_log=logging.getLogger("http"), access_log_class=FilteredAccessLogger)

View File

@ -208,7 +208,7 @@ def test_updates_all(application_repository: ApplicationRepository, package_ahri
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, log_fn=print)
updates_aur_mock.assert_called_once_with([], vcs=True)
updates_local_mock.assert_called_once_with()
updates_local_mock.assert_called_once_with(vcs=True)
updates_manual_mock.assert_called_once_with()
@ -238,7 +238,7 @@ def test_updates_no_aur(application_repository: ApplicationRepository, mocker: M
application_repository.updates([], aur=False, local=True, manual=True, vcs=True, log_fn=print)
updates_aur_mock.assert_not_called()
updates_local_mock.assert_called_once_with()
updates_local_mock.assert_called_once_with(vcs=True)
updates_manual_mock.assert_called_once_with()
@ -268,7 +268,7 @@ def test_updates_no_manual(application_repository: ApplicationRepository, mocker
application_repository.updates([], aur=True, local=True, manual=False, vcs=True, log_fn=print)
updates_aur_mock.assert_called_once_with([], vcs=True)
updates_local_mock.assert_called_once_with()
updates_local_mock.assert_called_once_with(vcs=True)
updates_manual_mock.assert_not_called()
@ -283,7 +283,7 @@ def test_updates_no_vcs(application_repository: ApplicationRepository, mocker: M
application_repository.updates([], aur=True, local=True, manual=True, vcs=False, log_fn=print)
updates_aur_mock.assert_called_once_with([], vcs=False)
updates_local_mock.assert_called_once_with()
updates_local_mock.assert_called_once_with(vcs=False)
updates_manual_mock.assert_called_once_with()
@ -298,5 +298,5 @@ def test_updates_with_filter(application_repository: ApplicationRepository, mock
application_repository.updates(["filter"], aur=True, local=True, manual=True, vcs=True, log_fn=print)
updates_aur_mock.assert_called_once_with(["filter"], vcs=True)
updates_local_mock.assert_called_once_with()
updates_local_mock.assert_called_once_with(vcs=True)
updates_manual_mock.assert_called_once_with()

View File

@ -4,15 +4,12 @@ from pytest_mock import MockerFixture
from ahriman.application.handlers import Dump
from ahriman.core.configuration import Configuration
from ahriman.core.repository import Repository
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
mocker: MockerFixture) -> None:
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run command
"""
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump",
return_value=configuration.dump())

View File

@ -0,0 +1,58 @@
import argparse
from pytest_mock import MockerFixture
from ahriman import version
from ahriman.application.handlers import ServiceUpdates
from ahriman.core.configuration import Configuration
from ahriman.core.repository import Repository
from ahriman.models.package import Package
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
"""
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
"""
args.exit_code = False
return args
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
package_ahriman: Package, mocker: MockerFixture) -> None:
"""
must run command
"""
package_ahriman.version = "0.0.0"
args = _default_args(args)
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
package_mock = mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
ServiceUpdates.run(args, "x86_64", configuration, report=False, unsafe=False)
package_mock.assert_called_once_with(package_ahriman.base, repository.pacman)
application_mock.assert_called_once_with(verbose=True, separator=" -> ")
check_mock.assert_called_once_with(args.exit_code, True)
def test_run_skip(args: argparse.Namespace, configuration: Configuration, repository: Repository,
package_ahriman: Package, mocker: MockerFixture) -> None:
"""
must do not perform any actions if package is up-to-date
"""
package_ahriman.version = f"{version.__version__}-1"
args = _default_args(args)
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
ServiceUpdates.run(args, "x86_64", configuration, report=False, unsafe=False)
application_mock.assert_not_called()
check_mock.assert_not_called()

View File

@ -27,6 +27,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
args.build_command = "ahriman"
args.from_configuration = Path("/usr/share/devtools/pacman-extra.conf")
args.makeflags_jobs = True
args.mirror = "mirror"
args.multilib = True
args.packager = "John Doe <john@doe.com>"
args.repository = "aur-clone"
@ -52,10 +53,10 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
Setup.run(args, "x86_64", configuration, report=False, unsafe=False)
ahriman_configuration_mock.assert_called_once_with(
args, "x86_64", args.repository, configuration.include, repository_paths)
ahriman_configuration_mock.assert_called_once_with(args, "x86_64", args.repository, configuration)
devtools_configuration_mock.assert_called_once_with(
args.build_command, "x86_64", args.from_configuration, args.multilib, args.repository, repository_paths)
args.build_command, "x86_64", args.from_configuration, args.mirror, args.multilib, args.repository,
repository_paths)
makepkg_configuration_mock.assert_called_once_with(args.packager, args.makeflags_jobs, repository_paths)
sudo_configuration_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
executable_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
@ -85,11 +86,12 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
command = Setup.build_command(repository_paths.root, args.build_command, "x86_64")
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration.include, repository_paths)
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration)
set_option_mock.assert_has_calls([
MockCall(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
MockCall("repository", "name", args.repository),
MockCall(Configuration.section_name("build", "x86_64"), "makechrootpkg_flags", f"-U {args.build_as_user}"),
MockCall(Configuration.section_name("alpm", "x86_64"), "mirror", args.mirror),
MockCall(Configuration.section_name("sign", "x86_64"), "target",
" ".join([target.name.lower() for target in args.sign_target])),
MockCall(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
@ -99,6 +101,23 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
def test_configuration_create_ahriman_no_multilib(args: argparse.Namespace, configuration: Configuration,
repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
"""
must create configuration for the service without multilib repository
"""
args = _default_args(args)
args.multilib = False
mocker.patch("pathlib.Path.open")
mocker.patch("ahriman.core.configuration.Configuration.write")
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration)
set_option_mock.assert_has_calls([
MockCall(Configuration.section_name("alpm", "x86_64"), "mirror", args.mirror),
]) # non-strict check called intentionally
def test_configuration_create_devtools(args: argparse.Namespace, repository_paths: RepositoryPaths,
mocker: MockerFixture) -> None:
"""
@ -111,11 +130,38 @@ def test_configuration_create_devtools(args: argparse.Namespace, repository_path
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
args.multilib, args.repository, repository_paths)
None, args.multilib, args.repository, repository_paths)
add_section_mock.assert_has_calls([MockCall("multilib"), MockCall(args.repository)])
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
def test_configuration_create_devtools_mirror(args: argparse.Namespace, repository_paths: RepositoryPaths,
mocker: MockerFixture) -> None:
"""
must create configuration for the devtools with mirror set explicitly
"""
def get(section: str, key: str, *args: Any, **kwargs: Any) -> Any:
del args
if section == "core" and key == "Include":
return str(Setup.MIRRORLIST_PATH)
return kwargs["fallback"]
args = _default_args(args)
mocker.patch("pathlib.Path.open")
mocker.patch("ahriman.core.configuration.Configuration.set")
mocker.patch("ahriman.core.configuration.Configuration.write")
mocker.patch("ahriman.core.configuration.Configuration.sections", return_value=["core", "extra"])
get_mock = mocker.patch("ahriman.core.configuration.Configuration.get", side_effect=get)
remove_option_mock = mocker.patch("ahriman.core.configuration.Configuration.remove_option")
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
args.mirror, False, args.repository, repository_paths)
get_mock.assert_has_calls([MockCall("core", "Include", fallback=None), MockCall("extra", "Include", fallback=None)])
remove_option_mock.assert_called_once_with("core", "Include")
set_option_mock.assert_has_calls([MockCall("core", "Server", args.mirror)]) # non-strict check called intentionally
def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, repository_paths: RepositoryPaths,
mocker: MockerFixture) -> None:
"""
@ -127,7 +173,7 @@ def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, rep
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
False, args.repository, repository_paths)
None, False, args.repository, repository_paths)
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))

View File

@ -57,7 +57,7 @@ def test_check_unsafe(mocker: MockerFixture) -> None:
must check if command is unsafe
"""
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
UnsafeCommands.check_unsafe("repo-clean", ["repo-clean"], _parser())
UnsafeCommands.check_unsafe("service-clean", ["service-clean"], _parser())
check_mock.assert_called_once_with(True, True)
@ -66,7 +66,7 @@ def test_check_unsafe_safe(mocker: MockerFixture) -> None:
must check if command is safe
"""
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
UnsafeCommands.check_unsafe("package-status", ["repo-clean"], _parser())
UnsafeCommands.check_unsafe("package-status", ["service-clean"], _parser())
check_mock.assert_called_once_with(True, False)

View File

@ -0,0 +1,106 @@
import argparse
import json
from pytest_mock import MockerFixture
from ahriman.application.handlers import Validate
from ahriman.core.configuration import Configuration
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA
from ahriman.core.configuration.validator import Validator
from ahriman.core.gitremote import RemotePullTrigger, RemotePushTrigger
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
"""
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
"""
args.exit_code = False
return args
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run command
"""
args = _default_args(args)
mocker.patch.object(Validator, "errors", {"node": ["error"]})
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=False)
Validate.run(args, "x86_64", configuration, report=False, unsafe=False)
application_mock.assert_called_once_with(configuration.dump())
print_mock.assert_called_once_with(verbose=True)
def test_run_skip(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
"""
must skip print if no errors found
"""
args = _default_args(args)
mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=True)
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Validate.run(args, "x86_64", configuration, report=False, unsafe=False)
print_mock.assert_not_called()
def test_schema(configuration: Configuration) -> None:
"""
must generate full schema correctly
"""
schema = Validate.schema("x86_64", configuration)
# defaults
assert schema.pop("console")
assert schema.pop("email")
assert schema.pop("github")
assert schema.pop("html")
assert schema.pop("rsync")
assert schema.pop("s3")
assert schema.pop("telegram")
assert schema == CONFIGURATION_SCHEMA
def test_schema_invalid_trigger(configuration: Configuration) -> None:
"""
must skip trigger if it caused exception on load
"""
configuration.set_option("build", "triggers", "some.invalid.trigger.path.Trigger")
assert Validate.schema("x86_64", configuration) == CONFIGURATION_SCHEMA
def test_schema_erase_required() -> None:
"""
must remove required field from dictionaries recursively
"""
# the easiest way is to just dump to string and check
assert "required" not in json.dumps(Validate.schema_erase_required(CONFIGURATION_SCHEMA))
def test_schema_merge() -> None:
"""
must merge schemas correctly
"""
erased = Validate.schema_erase_required(CONFIGURATION_SCHEMA)
assert Validate.schema_merge(erased, CONFIGURATION_SCHEMA) == CONFIGURATION_SCHEMA
merged = Validate.schema_merge(RemotePullTrigger.CONFIGURATION_SCHEMA, RemotePushTrigger.CONFIGURATION_SCHEMA)
for key in RemotePullTrigger.CONFIGURATION_SCHEMA["gitremote"]["schema"]:
assert key in merged["gitremote"]["schema"]
for key in RemotePushTrigger.CONFIGURATION_SCHEMA["gitremote"]["schema"]:
assert key in merged["gitremote"]["schema"]
def test_disallow_auto_architecture_run() -> None:
"""
must not allow multi architecture run
"""
assert not Validate.ALLOW_AUTO_ARCHITECTURE_RUN

View File

@ -14,16 +14,16 @@ def test_parser(parser: argparse.ArgumentParser) -> None:
"""
must parse valid command line
"""
parser.parse_args(["-a", "x86_64", "repo-config"])
parser.parse_args(["-a", "x86_64", "service-config"])
def test_parser_option_configuration(parser: argparse.ArgumentParser) -> None:
"""
must convert configuration option to Path instance
"""
args = parser.parse_args(["-a", "x86_64", "repo-config"])
args = parser.parse_args(["-a", "x86_64", "service-config"])
assert isinstance(args.configuration, Path)
args = parser.parse_args(["-a", "x86_64", "-c", "ahriman.ini", "repo-config"])
args = parser.parse_args(["-a", "x86_64", "-c", "ahriman.ini", "service-config"])
assert isinstance(args.configuration, Path)
@ -41,7 +41,7 @@ def test_multiple_architectures(parser: argparse.ArgumentParser) -> None:
"""
must accept multiple architectures
"""
args = parser.parse_args(["-a", "x86_64", "-a", "i686", "repo-config"])
args = parser.parse_args(["-a", "x86_64", "-a", "i686", "service-config"])
assert args.architecture == ["x86_64", "i686"]
@ -65,38 +65,6 @@ def test_subparsers_aur_search_architecture(parser: argparse.ArgumentParser) ->
assert args.architecture == [""]
def test_subparsers_daemon(parser: argparse.ArgumentParser) -> None:
"""
daemon command must imply dry run, exit code and package
"""
args = parser.parse_args(["daemon"])
assert not args.dry_run
assert not args.exit_code
assert args.package == []
def test_subparsers_daemon_option_refresh(parser: argparse.ArgumentParser) -> None:
"""
daemon command must count refresh options
"""
args = parser.parse_args(["daemon"])
assert args.refresh == 0
args = parser.parse_args(["daemon", "-y"])
assert args.refresh == 1
args = parser.parse_args(["daemon", "-yy"])
assert args.refresh == 2
def test_subparsers_daemon_option_interval(parser: argparse.ArgumentParser) -> None:
"""
daemon command must convert interval option to int instance
"""
args = parser.parse_args(["daemon"])
assert isinstance(args.interval, int)
args = parser.parse_args(["daemon", "--interval", "10"])
assert isinstance(args.interval, int)
def test_subparsers_help(parser: argparse.ArgumentParser) -> None:
"""
help command must imply architecture list, lock, report, quiet, unsafe and parser
@ -139,21 +107,43 @@ def test_subparsers_help_commands_unsafe_architecture(parser: argparse.ArgumentP
assert args.architecture == [""]
def test_subparsers_key_import(parser: argparse.ArgumentParser) -> None:
def test_subparsers_help_updates(parser: argparse.ArgumentParser) -> None:
"""
key-import command must imply architecture list, lock and report
help-updates command must imply architecture list, lock, report, quiet and unsafe
"""
args = parser.parse_args(["key-import", "key"])
args = parser.parse_args(["help-updates"])
assert args.architecture == [""]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_key_import_architecture(parser: argparse.ArgumentParser) -> None:
def test_subparsers_help_updates_architecture(parser: argparse.ArgumentParser) -> None:
"""
key-import command must correctly parse architecture list
help-updates command must correctly parse architecture list
"""
args = parser.parse_args(["-a", "x86_64", "key-import", "key"])
args = parser.parse_args(["-a", "x86_64", "help-updates"])
assert args.architecture == [""]
def test_subparsers_help_version(parser: argparse.ArgumentParser) -> None:
"""
help-version command must imply architecture, lock, report, quiet and unsafe
"""
args = parser.parse_args(["help-version"])
assert args.architecture == [""]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_help_version_architecture(parser: argparse.ArgumentParser) -> None:
"""
help-version command must correctly parse architecture list
"""
args = parser.parse_args(["-a", "x86_64", "help-version"])
assert args.architecture == [""]
@ -258,13 +248,14 @@ def test_subparsers_patch_add_architecture(parser: argparse.ArgumentParser) -> N
def test_subparsers_patch_list(parser: argparse.ArgumentParser) -> None:
"""
patch-list command must imply action, architecture list, lock and report
patch-list command must imply action, architecture list, lock, report and unsafe
"""
args = parser.parse_args(["patch-list", "ahriman"])
assert args.action == Action.List
assert args.architecture == [""]
assert args.lock is None
assert not args.report
assert args.unsafe
def test_subparsers_patch_list_architecture(parser: argparse.ArgumentParser) -> None:
@ -381,35 +372,36 @@ def test_subparsers_repo_check_option_refresh(parser: argparse.ArgumentParser) -
assert args.refresh == 2
def test_subparsers_repo_clean(parser: argparse.ArgumentParser) -> None:
def test_subparsers_repo_daemon(parser: argparse.ArgumentParser) -> None:
"""
repo-clean command must imply quiet and unsafe
repo-daemon command must imply dry run, exit code and package
"""
args = parser.parse_args(["repo-clean"])
assert args.quiet
assert args.unsafe
args = parser.parse_args(["repo-daemon"])
assert not args.dry_run
assert not args.exit_code
assert args.package == []
def test_subparsers_repo_clean_architecture(parser: argparse.ArgumentParser) -> None:
def test_subparsers_repo_daemon_option_refresh(parser: argparse.ArgumentParser) -> None:
"""
repo-clean command must correctly parse architecture list
repo-daemon command must count refresh options
"""
args = parser.parse_args(["repo-clean"])
assert args.architecture is None
args = parser.parse_args(["-a", "x86_64", "repo-clean"])
assert args.architecture == ["x86_64"]
args = parser.parse_args(["repo-daemon"])
assert args.refresh == 0
args = parser.parse_args(["repo-daemon", "-y"])
assert args.refresh == 1
args = parser.parse_args(["repo-daemon", "-yy"])
assert args.refresh == 2
def test_subparsers_repo_config(parser: argparse.ArgumentParser) -> None:
def test_subparsers_repo_daemon_option_interval(parser: argparse.ArgumentParser) -> None:
"""
repo-config command must imply lock, report, quiet and unsafe
repo-daemon command must convert interval option to int instance
"""
args = parser.parse_args(["-a", "x86_64", "repo-config"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
args = parser.parse_args(["repo-daemon"])
assert isinstance(args.interval, int)
args = parser.parse_args(["repo-daemon", "--interval", "10"])
assert isinstance(args.interval, int)
def test_subparsers_repo_rebuild_architecture(parser: argparse.ArgumentParser) -> None:
@ -469,41 +461,6 @@ def test_subparsers_repo_restore_architecture(parser: argparse.ArgumentParser) -
assert args.architecture == [""]
def test_subparsers_repo_setup(parser: argparse.ArgumentParser) -> None:
"""
repo-setup command must imply lock, report, quiet and unsafe
"""
args = parser.parse_args(["-a", "x86_64", "repo-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_repo_setup_option_from_configuration(parser: argparse.ArgumentParser) -> None:
"""
repo-setup command must convert from-configuration option to path instance
"""
args = parser.parse_args(["-a", "x86_64", "repo-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone"])
assert isinstance(args.from_configuration, Path)
args = parser.parse_args(["-a", "x86_64", "repo-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone", "--from-configuration", "path"])
assert isinstance(args.from_configuration, Path)
def test_subparsers_repo_setup_option_sign_target(parser: argparse.ArgumentParser) -> None:
"""
repo-setup command must convert sign-target option to signsettings instance
"""
args = parser.parse_args(["-a", "x86_64", "repo-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone", "--sign-target", "packages"])
assert args.sign_target
assert all(isinstance(target, SignSettings) for target in args.sign_target)
def test_subparsers_repo_sign_architecture(parser: argparse.ArgumentParser) -> None:
"""
repo-sign command must correctly parse architecture list
@ -558,12 +515,13 @@ def test_subparsers_repo_sync_architecture(parser: argparse.ArgumentParser) -> N
def test_subparsers_repo_tree(parser: argparse.ArgumentParser) -> None:
"""
repo-tree command must imply lock, report and quiet
repo-tree command must imply lock, report, quiet and unsafe
"""
args = parser.parse_args(["repo-tree"])
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_repo_tree_architecture(parser: argparse.ArgumentParser) -> None:
@ -608,18 +566,114 @@ def test_subparsers_repo_update_option_refresh(parser: argparse.ArgumentParser)
assert args.refresh == 2
def test_subparsers_shell(parser: argparse.ArgumentParser) -> None:
def test_subparsers_service_clean(parser: argparse.ArgumentParser) -> None:
"""
shell command must imply lock and report
service-clean command must imply quiet and unsafe
"""
args = parser.parse_args(["shell"])
args = parser.parse_args(["service-clean"])
assert args.quiet
assert args.unsafe
def test_subparsers_service_clean_architecture(parser: argparse.ArgumentParser) -> None:
"""
service-clean command must correctly parse architecture list
"""
args = parser.parse_args(["service-clean"])
assert args.architecture is None
args = parser.parse_args(["-a", "x86_64", "service-clean"])
assert args.architecture == ["x86_64"]
def test_subparsers_service_config(parser: argparse.ArgumentParser) -> None:
"""
service-config command must imply lock, report, quiet and unsafe
"""
args = parser.parse_args(["-a", "x86_64", "service-config"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_service_config_validate(parser: argparse.ArgumentParser) -> None:
"""
service-config-validate command must imply lock, report, quiet and unsafe
"""
args = parser.parse_args(["-a", "x86_64", "service-config-validate"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_service_key_import(parser: argparse.ArgumentParser) -> None:
"""
service-key-import command must imply architecture list, lock and report
"""
args = parser.parse_args(["service-key-import", "key"])
assert args.architecture == [""]
assert args.lock is None
assert not args.report
def test_subparsers_service_key_import_architecture(parser: argparse.ArgumentParser) -> None:
"""
service-key-import command must correctly parse architecture list
"""
args = parser.parse_args(["-a", "x86_64", "service-key-import", "key"])
assert args.architecture == [""]
def test_subparsers_service_setup(parser: argparse.ArgumentParser) -> None:
"""
service-setup command must imply lock, report, quiet and unsafe
"""
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_service_setup_option_from_configuration(parser: argparse.ArgumentParser) -> None:
"""
service-setup command must convert from-configuration option to path instance
"""
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone"])
assert isinstance(args.from_configuration, Path)
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone", "--from-configuration", "path"])
assert isinstance(args.from_configuration, Path)
def test_subparsers_service_setup_option_sign_target(parser: argparse.ArgumentParser) -> None:
"""
service-setup command must convert sign-target option to signsettings instance
"""
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
"--repository", "aur-clone", "--sign-target", "packages"])
assert args.sign_target
assert all(isinstance(target, SignSettings) for target in args.sign_target)
def test_subparsers_service_shell(parser: argparse.ArgumentParser) -> None:
"""
service-shell command must imply lock and report
"""
args = parser.parse_args(["service-shell"])
assert args.lock is None
assert not args.report
def test_subparsers_user_add(parser: argparse.ArgumentParser) -> None:
"""
user-add command must imply action, architecture, lock, report, quiet and unsafe
user-add command must imply action, architecture, lock, report and quiet
"""
args = parser.parse_args(["user-add", "username"])
assert args.action == Action.Update
@ -627,7 +681,6 @@ def test_subparsers_user_add(parser: argparse.ArgumentParser) -> None:
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_user_add_architecture(parser: argparse.ArgumentParser) -> None:
@ -680,7 +733,7 @@ def test_subparsers_user_list_option_role(parser: argparse.ArgumentParser) -> No
def test_subparsers_user_remove(parser: argparse.ArgumentParser) -> None:
"""
user-remove command must imply action, architecture, lock, report, password, quiet, role and unsafe
user-remove command must imply action, architecture, lock, report, password and quiet
"""
args = parser.parse_args(["user-remove", "username"])
assert args.action == Action.Remove
@ -689,7 +742,6 @@ def test_subparsers_user_remove(parser: argparse.ArgumentParser) -> None:
assert not args.report
assert args.password is not None
assert args.quiet
assert args.unsafe
def test_subparsers_user_remove_architecture(parser: argparse.ArgumentParser) -> None:
@ -700,33 +752,12 @@ def test_subparsers_user_remove_architecture(parser: argparse.ArgumentParser) ->
assert args.architecture == [""]
def test_subparsers_version(parser: argparse.ArgumentParser) -> None:
"""
version command must imply architecture, lock, report, quiet and unsafe
"""
args = parser.parse_args(["version"])
assert args.architecture == [""]
assert args.lock is None
assert not args.report
assert args.quiet
assert args.unsafe
def test_subparsers_version_architecture(parser: argparse.ArgumentParser) -> None:
"""
version command must correctly parse architecture list
"""
args = parser.parse_args(["-a", "x86_64", "version"])
assert args.architecture == [""]
def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
"""
web command must imply lock, report and parser
web command must imply report and parser
"""
args = parser.parse_args(["-a", "x86_64", "web"])
assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report
assert args.parser is not None and args.parser()

View File

@ -1,3 +1,4 @@
import argparse
import pytest
import tempfile
@ -7,11 +8,26 @@ from unittest.mock import call as MockCall
from ahriman import version
from ahriman.application.lock import Lock
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.internal_status import InternalStatus
def test_path(args: argparse.Namespace, configuration: Configuration) -> None:
"""
must create path variable correctly
"""
assert Lock(args, "x86_64", configuration).path is None
args.lock = Path("/run/ahriman.lock")
assert Lock(args, "x86_64", configuration).path == Path("/run/ahriman_x86_64.lock")
with pytest.raises(ValueError):
args.lock = Path("/")
Lock(args, "x86_64", configuration).path # special case
def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
"""
must check version correctly

View File

@ -1,6 +1,7 @@
import pytest
from ahriman.core.auth import Mapping, OAuth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite

View File

@ -1,4 +1,6 @@
from ahriman.core.auth import Auth, Mapping, OAuth
from ahriman.core.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite
from ahriman.models.user import User

View File

@ -1,6 +1,6 @@
from pytest_mock import MockerFixture
from ahriman.core.auth import Mapping
from ahriman.core.auth.mapping import Mapping
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.auth import OAuth
from ahriman.core.auth.oauth import OAuth
from ahriman.core.exceptions import OptionError

View File

@ -0,0 +1,19 @@
import pytest
from ahriman.core.configuration import Configuration
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA
from ahriman.core.configuration.validator import Validator
@pytest.fixture
def validator(configuration: Configuration) -> Validator:
"""
fixture for validator
Args:
configuration(Configuration): configuration fixture
Returns:
Validator: validator test instance
"""
return Validator(instance=configuration, schema=CONFIGURATION_SCHEMA)

View File

@ -207,6 +207,15 @@ def test_gettype(configuration: Configuration) -> None:
assert provider == "s3"
def test_gettype_with_fallback(configuration: Configuration) -> None:
"""
must return same provider name as in fallback
"""
section, provider = configuration.gettype("rsync", "x86_64", fallback="abracadabra")
assert section == "rsync"
assert provider == "abracadabra"
def test_gettype_from_section(configuration: Configuration) -> None:
"""
must extract type from section name

View File

@ -0,0 +1,70 @@
from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.configuration.validator import Validator
def test_types_mapping() -> None:
"""
must set custom types
"""
assert "path" in Validator.types_mapping
assert Path in Validator.types_mapping["path"].included_types
def test_normalize_coerce_absolute_path(validator: Validator) -> None:
"""
must convert string value to path by using configuration converters
"""
convert_mock = MagicMock()
validator.instance.converters["path"] = convert_mock
validator._normalize_coerce_absolute_path("value")
convert_mock.assert_called_once_with("value")
def test_normalize_coerce_boolean(validator: Validator, mocker: MockerFixture) -> None:
"""
must convert string value to boolean by using configuration converters
"""
convert_mock = mocker.patch("ahriman.core.configuration.Configuration._convert_to_boolean")
validator._normalize_coerce_boolean("1")
convert_mock.assert_called_once_with("1")
def test_normalize_coerce_integer(validator: Validator) -> None:
"""
must convert string value to integer by using configuration converters
"""
assert validator._normalize_coerce_integer("1") == 1
assert validator._normalize_coerce_integer("42") == 42
def test_normalize_coerce_list(validator: Validator) -> None:
"""
must convert string value to list by using configuration converters
"""
convert_mock = MagicMock()
validator.instance.converters["list"] = convert_mock
validator._normalize_coerce_list("value")
convert_mock.assert_called_once_with("value")
def test_validate_path_exists(validator: Validator, mocker: MockerFixture) -> None:
"""
must validate that paths exists
"""
error_mock = mocker.patch("ahriman.core.configuration.validator.Validator._error")
mocker.patch("pathlib.Path.exists", return_value=False)
validator._validate_path_exists(False, "field", Path("1"))
mocker.patch("pathlib.Path.exists", return_value=False)
validator._validate_path_exists(True, "field", Path("2"))
mocker.patch("pathlib.Path.exists", return_value=True)
validator._validate_path_exists(True, "field", Path("3"))
error_mock.assert_called_once_with("field", "Path 2 must exist")

View File

@ -1,7 +1,7 @@
import pytest
from ahriman.core.formatters import AurPrinter, ConfigurationPrinter, PackagePrinter, PatchPrinter, StatusPrinter, \
StringPrinter, TreePrinter, UpdatePrinter, UserPrinter, VersionPrinter
StringPrinter, TreePrinter, UpdatePrinter, UserPrinter, ValidationPrinter, VersionPrinter
from ahriman.models.aur_package import AURPackage
from ahriman.models.build_status import BuildStatus
from ahriman.models.package import Package
@ -126,6 +126,29 @@ def user_printer(user: User) -> UserPrinter:
return UserPrinter(user)
@pytest.fixture
def validation_printer() -> ValidationPrinter:
"""
fixture for validation printer
Returns:
ValidationPrinter: validation printer test instance
"""
return ValidationPrinter("root", [
"root error",
{
"child": [
"child error",
{
"grandchild": [
"grandchild error",
],
},
],
},
])
@pytest.fixture
def version_printer(package_ahriman: Package) -> VersionPrinter:
"""

View File

@ -1,7 +1,9 @@
from unittest.mock import MagicMock
from pytest_mock import MockerFixture
from unittest.mock import MagicMock, call as MockCall
from ahriman.core.formatters import PackagePrinter
from ahriman.core.formatters import Printer
from ahriman.models.property import Property
def test_print(package_ahriman_printer: PackagePrinter) -> None:
@ -31,6 +33,24 @@ def test_print_verbose(package_ahriman_printer: PackagePrinter) -> None:
log_mock.assert_called()
def test_print_indent(mocker: MockerFixture) -> None:
"""
must correctly use indentation
"""
log_mock = MagicMock()
mocker.patch("ahriman.core.formatters.Printer.properties", return_value=[Property("key", "value", indent=0)])
Printer().print(verbose=True, log_fn=log_mock)
mocker.patch("ahriman.core.formatters.Printer.properties", return_value=[Property("key", "value", indent=1)])
Printer().print(verbose=True, log_fn=log_mock)
mocker.patch("ahriman.core.formatters.Printer.properties", return_value=[Property("key", "value", indent=2)])
Printer().print(verbose=True, log_fn=log_mock)
log_mock.assert_has_calls([MockCall("key: value"), MockCall("\tkey: value"), MockCall("\t\tkey: value")])
def test_properties() -> None:
"""
must return empty properties list

View File

@ -0,0 +1,28 @@
from ahriman.core.formatters import ValidationPrinter
from ahriman.models.property import Property
def test_properties(validation_printer: ValidationPrinter) -> None:
"""
must return non-empty properties list
"""
assert validation_printer.properties()
def test_title(validation_printer: ValidationPrinter) -> None:
"""
must return non-empty title
"""
assert validation_printer.title() is not None
def test_get_error_messages(validation_printer: ValidationPrinter) -> None:
"""
must get error messages from plain list
"""
result = ValidationPrinter.get_error_messages(validation_printer.node, validation_printer.errors)
assert list(result) == [
Property("root", "root error", is_required=True, indent=1),
Property("child", "child error", is_required=True, indent=2),
Property("grandchild", "grandchild error", is_required=True, indent=3),
]

View File

@ -4,6 +4,17 @@ from ahriman.core.configuration import Configuration
from ahriman.core.gitremote import RemotePullTrigger
def test_configuration_sections(configuration: Configuration) -> None:
"""
must correctly parse target list
"""
configuration.set_option("remote-pull", "target", "a b c")
assert RemotePullTrigger.configuration_sections(configuration) == ["a", "b", "c"]
configuration.remove_option("remote-pull", "target")
assert RemotePullTrigger.configuration_sections(configuration) == []
def test_on_start(configuration: Configuration, mocker: MockerFixture) -> None:
"""
must clone repo on start

View File

@ -8,6 +8,17 @@ from ahriman.models.package import Package
from ahriman.models.result import Result
def test_configuration_sections(configuration: Configuration) -> None:
"""
must correctly parse target list
"""
configuration.set_option("remote-push", "target", "a b c")
assert RemotePushTrigger.configuration_sections(configuration) == ["a", "b", "c"]
configuration.remove_option("remote-push", "target")
assert RemotePushTrigger.configuration_sections(configuration) == []
def test_on_result(configuration: Configuration, result: Result, package_ahriman: Package,
database: SQLite, mocker: MockerFixture) -> None:
"""

View File

@ -5,6 +5,17 @@ from ahriman.core.report import ReportTrigger
from ahriman.models.result import Result
def test_configuration_sections(configuration: Configuration) -> None:
"""
must correctly parse target list
"""
configuration.set_option("report", "target", "a b c")
assert ReportTrigger.configuration_sections(configuration) == ["a", "b", "c"]
configuration.remove_option("report", "target")
assert ReportTrigger.configuration_sections(configuration) == []
def test_on_result(configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run report for specified targets

View File

@ -4,7 +4,6 @@ from pathlib import Path
from pytest_mock import MockerFixture
from ahriman.core.repository.update_handler import UpdateHandler
from ahriman.core.util import utcnow
from ahriman.models.package import Package
from ahriman.models.package_source import PackageSource
from ahriman.models.remote_source import RemoteSource
@ -24,12 +23,16 @@ def test_updates_aur(update_handler: UpdateHandler, package_ahriman: Package,
must provide updates with status updates
"""
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
package_is_outdated_mock = mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
assert update_handler.updates_aur([], vcs=True) == [package_ahriman]
status_client_mock.assert_called_once_with(package_ahriman.base)
package_is_outdated_mock.assert_called_once_with(
package_ahriman, update_handler.paths,
vcs_allowed_age=update_handler.vcs_allowed_age,
calculate_version=True)
def test_updates_aur_official(update_handler: UpdateHandler, package_ahriman: Package,
@ -95,14 +98,13 @@ def test_updates_aur_ignore_vcs(update_handler: UpdateHandler, package_ahriman:
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
mocker.patch("ahriman.models.package.Package.is_vcs", return_value=True)
package_is_newer_than_mock = mocker.patch("ahriman.models.package.Package.is_newer_than", return_value=True)
package_is_outdated_mock = mocker.patch("ahriman.models.package.Package.is_outdated", return_value=False)
ts1 = utcnow().timestamp()
assert not update_handler.updates_aur([], vcs=False)
package_is_newer_than_mock.assert_called_once_with(pytest.helpers.anyvar(float, strict=True))
assert ts1 < package_is_newer_than_mock.call_args[0][0] < utcnow().timestamp()
package_is_outdated_mock.assert_called_once_with(package_ahriman, update_handler.paths, calculate_version=False)
package_is_outdated_mock.assert_called_once_with(
package_ahriman, update_handler.paths,
vcs_allowed_age=update_handler.vcs_allowed_age,
calculate_version=False)
def test_updates_local(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None:
@ -111,15 +113,37 @@ def test_updates_local(update_handler: UpdateHandler, package_ahriman: Package,
"""
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
fetch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
package_load_mock = mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
package_is_outdated_mock = mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
assert update_handler.updates_local() == [package_ahriman]
assert update_handler.updates_local(vcs=True) == [package_ahriman]
fetch_mock.assert_called_once_with(Path(package_ahriman.base), remote=None)
package_load_mock.assert_called_once_with(Path(package_ahriman.base))
status_client_mock.assert_called_once_with(package_ahriman.base)
package_is_outdated_mock.assert_called_once_with(
package_ahriman, update_handler.paths,
vcs_allowed_age=update_handler.vcs_allowed_age,
calculate_version=True)
def test_updates_local_ignore_vcs(update_handler: UpdateHandler, package_ahriman: Package,
mocker: MockerFixture) -> None:
"""
must skip VCS packages check if requested for locally stored packages
"""
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
package_is_outdated_mock = mocker.patch("ahriman.models.package.Package.is_outdated", return_value=False)
assert not update_handler.updates_local(vcs=False)
package_is_outdated_mock.assert_called_once_with(
package_ahriman, update_handler.paths,
vcs_allowed_age=update_handler.vcs_allowed_age,
calculate_version=False)
def test_updates_local_unknown(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None:
@ -133,7 +157,7 @@ def test_updates_local_unknown(update_handler: UpdateHandler, package_ahriman: P
mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_unknown")
assert update_handler.updates_local() == [package_ahriman]
assert update_handler.updates_local(vcs=True) == [package_ahriman]
status_client_mock.assert_called_once_with(package_ahriman)
@ -146,7 +170,7 @@ def test_updates_local_with_failures(update_handler: UpdateHandler, package_ahri
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception())
assert not update_handler.updates_local()
assert not update_handler.updates_local(vcs=True)
def test_updates_manual_clear(update_handler: UpdateHandler, mocker: MockerFixture) -> None:

View File

@ -123,6 +123,9 @@ def test_package_url(web_client: WebClient, package_ahriman: Package) -> None:
"""
must generate package status url correctly
"""
assert web_client._package_url("").startswith(web_client.address)
assert web_client._package_url("").endswith(f"/api/v1/packages")
assert web_client._package_url(package_ahriman.base).startswith(web_client.address)
assert web_client._package_url(package_ahriman.base).endswith(f"/api/v1/packages/{package_ahriman.base}")

View File

@ -42,7 +42,7 @@ def test_key_import(spawner: Spawn, mocker: MockerFixture) -> None:
"""
spawn_mock = mocker.patch("ahriman.core.spawn.Spawn.spawn_process")
spawner.key_import("0xdeadbeaf", None)
spawn_mock.assert_called_once_with("key-import", "0xdeadbeaf")
spawn_mock.assert_called_once_with("service-key-import", "0xdeadbeaf")
def test_key_import_with_server(spawner: Spawn, mocker: MockerFixture) -> None:
@ -51,7 +51,7 @@ def test_key_import_with_server(spawner: Spawn, mocker: MockerFixture) -> None:
"""
spawn_mock = mocker.patch("ahriman.core.spawn.Spawn.spawn_process")
spawner.key_import("0xdeadbeaf", "keyserver.ubuntu.com")
spawn_mock.assert_called_once_with("key-import", "0xdeadbeaf", **{"key-server": "keyserver.ubuntu.com"})
spawn_mock.assert_called_once_with("service-key-import", "0xdeadbeaf", **{"key-server": "keyserver.ubuntu.com"})
def test_packages_add(spawner: Spawn, mocker: MockerFixture) -> None:

View File

@ -28,4 +28,4 @@ def trigger_loader(configuration: Configuration) -> TriggerLoader:
Returns:
TriggerLoader: trigger loader test instance
"""
return TriggerLoader("x86_64", configuration)
return TriggerLoader.load("x86_64", configuration)

View File

@ -1,9 +1,64 @@
from unittest.mock import MagicMock
from ahriman.core.configuration import Configuration
from ahriman.core.report import ReportTrigger
from ahriman.core.triggers import Trigger
from ahriman.models.result import Result
def test_configuration_schema(configuration: Configuration) -> None:
"""
must return used configuration schema
"""
section = "console"
configuration.set_option("report", "target", section)
expected = {section: ReportTrigger.CONFIGURATION_SCHEMA[section]}
assert ReportTrigger.configuration_schema("x86_64", configuration) == expected
def test_configuration_schema_no_section(configuration: Configuration) -> None:
"""
must return nothing in case if section doesn't exist
"""
section = "abracadabra"
configuration.set_option("report", "target", section)
assert ReportTrigger.configuration_schema("x86_64", configuration) == {}
def test_configuration_schema_no_schema(configuration: Configuration) -> None:
"""
must return nothing in case if schema doesn't exist
"""
section = "abracadabra"
configuration.set_option("report", "target", section)
configuration.set_option(section, "key", "value")
assert ReportTrigger.configuration_schema("x86_64", configuration) == {}
def test_configuration_schema_empty() -> None:
"""
must return default schema if no configuration set
"""
assert ReportTrigger.configuration_schema("x86_64", None) == ReportTrigger.CONFIGURATION_SCHEMA
def test_configuration_schema_variables(configuration: Configuration) -> None:
"""
must return empty schema
"""
assert Trigger.CONFIGURATION_SCHEMA == {}
assert Trigger.CONFIGURATION_SCHEMA_FALLBACK is None
def test_configuration_sections(configuration: Configuration) -> None:
"""
must return empty section list
"""
assert Trigger.configuration_sections(configuration) == []
def test_on_result(trigger: Trigger) -> None:
"""
must pass execution nto run method

View File

@ -5,75 +5,97 @@ from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import ExtensionError
from ahriman.core.report import ReportTrigger
from ahriman.core.triggers import TriggerLoader
from ahriman.models.package import Package
from ahriman.models.result import Result
def test_load_trigger_package(trigger_loader: TriggerLoader) -> None:
def test_selected_triggers(configuration: Configuration) -> None:
"""
must load trigger from package
must return used triggers
"""
assert trigger_loader.load_trigger("ahriman.core.report.ReportTrigger")
configuration.set_option("build", "triggers", "a b c")
assert TriggerLoader.selected_triggers(configuration) == ["a", "b", "c"]
configuration.remove_option("build", "triggers")
assert TriggerLoader.selected_triggers(configuration) == []
def test_load_trigger_package_invalid_import(trigger_loader: TriggerLoader, mocker: MockerFixture) -> None:
def test_load_trigger(trigger_loader: TriggerLoader, configuration: Configuration) -> None:
"""
must raise InvalidExtension on invalid import
must load trigger
"""
mocker.patch("ahriman.core.triggers.trigger_loader.importlib.import_module", side_effect=ModuleNotFoundError())
with pytest.raises(ExtensionError):
trigger_loader.load_trigger("random.module")
loaded = trigger_loader.load_trigger("ahriman.core.report.ReportTrigger", "x86_64", configuration)
assert loaded
assert isinstance(loaded, ReportTrigger)
def test_load_trigger_package_not_trigger(trigger_loader: TriggerLoader) -> None:
"""
must raise InvalidExtension if imported module is not a type
"""
with pytest.raises(ExtensionError):
trigger_loader.load_trigger("ahriman.core.util.check_output")
def test_load_trigger_package_error_on_creation(trigger_loader: TriggerLoader, mocker: MockerFixture) -> None:
def test_load_trigger_package_error_on_creation(trigger_loader: TriggerLoader, configuration: Configuration,
mocker: MockerFixture) -> None:
"""
must raise InvalidException on trigger initialization if any exception is thrown
"""
mocker.patch("ahriman.core.triggers.trigger.Trigger.__init__", side_effect=Exception())
with pytest.raises(ExtensionError):
trigger_loader.load_trigger("ahriman.core.report.ReportTrigger")
trigger_loader.load_trigger("ahriman.core.report.ReportTrigger", "x86_64", configuration)
def test_load_trigger_package_is_not_trigger(trigger_loader: TriggerLoader) -> None:
def test_load_trigger_class_package(trigger_loader: TriggerLoader) -> None:
"""
must load trigger class from package
"""
assert trigger_loader.load_trigger_class("ahriman.core.report.ReportTrigger") == ReportTrigger
def test_load_trigger_class_package_invalid_import(trigger_loader: TriggerLoader, mocker: MockerFixture) -> None:
"""
must raise InvalidExtension on invalid import
"""
mocker.patch("ahriman.core.triggers.trigger_loader.importlib.import_module", side_effect=ModuleNotFoundError())
with pytest.raises(ExtensionError):
trigger_loader.load_trigger_class("random.module")
def test_load_trigger_class_package_not_trigger(trigger_loader: TriggerLoader) -> None:
"""
must raise InvalidExtension if imported module is not a type
"""
with pytest.raises(ExtensionError):
trigger_loader.load_trigger_class("ahriman.core.util.check_output")
def test_load_trigger_class_package_is_not_trigger(trigger_loader: TriggerLoader) -> None:
"""
must raise InvalidExtension if loaded class is not a trigger
"""
with pytest.raises(ExtensionError):
trigger_loader.load_trigger("ahriman.core.sign.gpg.GPG")
trigger_loader.load_trigger_class("ahriman.core.sign.gpg.GPG")
def test_load_trigger_path(trigger_loader: TriggerLoader, resource_path_root: Path) -> None:
def test_load_trigger_class_path(trigger_loader: TriggerLoader, resource_path_root: Path) -> None:
"""
must load trigger from path
must load trigger class from path
"""
path = resource_path_root.parent.parent / "src" / "ahriman" / "core" / "report" / "report_trigger.py"
assert trigger_loader.load_trigger(f"{path}.ReportTrigger")
path = resource_path_root.parent.parent / "src" / "ahriman" / "core" / "report" / "__init__.py"
assert trigger_loader.load_trigger_class(f"{path}.ReportTrigger") == ReportTrigger
def test_load_trigger_path_directory(trigger_loader: TriggerLoader, resource_path_root: Path) -> None:
def test_load_trigger_class_path_directory(trigger_loader: TriggerLoader, resource_path_root: Path) -> None:
"""
must raise InvalidExtension if provided import path is directory
"""
path = resource_path_root.parent.parent / "src" / "ahriman" / "core" / "report"
with pytest.raises(ExtensionError):
trigger_loader.load_trigger(f"{path}.ReportTrigger")
trigger_loader.load_trigger_class(f"{path}.ReportTrigger")
def test_load_trigger_path_not_found(trigger_loader: TriggerLoader) -> None:
def test_load_trigger_class_path_not_found(trigger_loader: TriggerLoader) -> None:
"""
must raise InvalidExtension if file cannot be found
"""
with pytest.raises(ExtensionError):
trigger_loader.load_trigger("/some/random/path.py.SomeRandomModule")
trigger_loader.load_trigger_class("/some/random/path.py.SomeRandomModule")
def test_on_result(trigger_loader: TriggerLoader, package_ahriman: Package, mocker: MockerFixture) -> None:
@ -119,9 +141,11 @@ def test_on_stop_with_on_start(configuration: Configuration, mocker: MockerFixtu
"""
must call on_stop on exit if on_start was called
"""
mocker.patch("ahriman.core.upload.UploadTrigger.on_start")
mocker.patch("ahriman.core.report.ReportTrigger.on_start")
on_stop_mock = mocker.patch("ahriman.core.triggers.trigger_loader.TriggerLoader.on_stop")
trigger_loader = TriggerLoader("x86_64", configuration)
trigger_loader = TriggerLoader.load("x86_64", configuration)
trigger_loader.on_start()
del trigger_loader
on_stop_mock.assert_called_once_with()
@ -133,7 +157,7 @@ def test_on_stop_without_on_start(configuration: Configuration, mocker: MockerFi
"""
on_stop_mock = mocker.patch("ahriman.core.triggers.trigger_loader.TriggerLoader.on_stop")
trigger_loader = TriggerLoader("x86_64", configuration)
trigger_loader = TriggerLoader.load("x86_64", configuration)
del trigger_loader
on_stop_mock.assert_not_called()

View File

@ -5,6 +5,17 @@ from ahriman.core.upload import UploadTrigger
from ahriman.models.result import Result
def test_configuration_sections(configuration: Configuration) -> None:
"""
must correctly parse target list
"""
configuration.set_option("upload", "target", "a b c")
assert UploadTrigger.configuration_sections(configuration) == ["a", "b", "c"]
configuration.remove_option("upload", "target")
assert UploadTrigger.configuration_sections(configuration) == []
def test_on_result(configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run report for specified targets

View File

@ -6,6 +6,7 @@ from unittest.mock import MagicMock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.exceptions import PackageInfoError
from ahriman.core.util import utcnow
from ahriman.models.aur_package import AURPackage
from ahriman.models.package import Package
from ahriman.models.repository_paths import RepositoryPaths
@ -285,21 +286,46 @@ def test_is_newer_than(package_ahriman: Package, package_python_schedule: Packag
assert not package_python_schedule.is_newer_than(min_date)
def test_is_outdated_false(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
def test_is_outdated_false(package_ahriman: Package, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
"""
must be not outdated for the same package
"""
assert not package_ahriman.is_outdated(package_ahriman, repository_paths, calculate_version=True)
actual_version_mock = mocker.patch("ahriman.models.package.Package.actual_version",
return_value=package_ahriman.version)
assert not package_ahriman.is_outdated(package_ahriman, repository_paths)
actual_version_mock.assert_called_once_with(repository_paths)
def test_is_outdated_true(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
def test_is_outdated_true(package_ahriman: Package, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
"""
must be outdated for the new version
"""
other = Package.from_json(package_ahriman.view())
other.version = other.version.replace("-1", "-2")
actual_version_mock = mocker.patch("ahriman.models.package.Package.actual_version", return_value=other.version)
assert package_ahriman.is_outdated(other, repository_paths, calculate_version=True)
assert package_ahriman.is_outdated(other, repository_paths)
actual_version_mock.assert_called_once_with(repository_paths)
def test_is_outdated_no_version_calculation(package_ahriman: Package, repository_paths: RepositoryPaths,
mocker: MockerFixture) -> None:
"""
must not call actual version if calculation is disabled
"""
actual_version_mock = mocker.patch("ahriman.models.package.Package.actual_version")
assert not package_ahriman.is_outdated(package_ahriman, repository_paths, calculate_version=False)
actual_version_mock.assert_not_called()
def test_is_outdated_fresh_package(package_ahriman: Package, repository_paths: RepositoryPaths,
mocker: MockerFixture) -> None:
"""
must not call actual version if package is never than specified time
"""
actual_version_mock = mocker.patch("ahriman.models.package.Package.actual_version")
assert not package_ahriman.is_outdated(package_ahriman, repository_paths, vcs_allowed_age=utcnow().timestamp())
actual_version_mock.assert_not_called()
def test_build_status_pretty_print(package_ahriman: Package) -> None:

View File

@ -9,7 +9,7 @@ from unittest.mock import MagicMock
import ahriman.core.auth.helpers
from ahriman.core.auth import OAuth
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite
from ahriman.core.repository import Repository

View File

@ -1,12 +1,62 @@
import pytest
import socket
from aiohttp import web
from pytest_mock import MockerFixture
from unittest.mock import call as MockCall
from ahriman.core.exceptions import InitializeError
from ahriman.core.log.filtered_access_logger import FilteredAccessLogger
from ahriman.core.status.watcher import Watcher
from ahriman.web.web import on_shutdown, on_startup, run_server
from ahriman.web.web import create_socket, on_shutdown, on_startup, run_server
async def test_create_socket(application: web.Application, mocker: MockerFixture) -> None:
"""
must create socket
"""
path = "/run/ahriman.sock"
application["configuration"].set_option("web", "unix_socket", str(path))
current_on_shutdown = len(application.on_shutdown)
bind_mock = mocker.patch("socket.socket.bind")
chmod_mock = mocker.patch("pathlib.Path.chmod")
unlink_mock = mocker.patch("pathlib.Path.unlink")
sock = create_socket(application["configuration"], application)
assert sock.family == socket.AF_UNIX
assert sock.type == socket.SOCK_STREAM
bind_mock.assert_called_once_with(str(path))
chmod_mock.assert_called_once_with(0o666)
assert len(application.on_shutdown) == current_on_shutdown + 1
# provoke socket removal
await application.on_shutdown[-1](application)
unlink_mock.assert_has_calls([MockCall(missing_ok=True), MockCall(missing_ok=True)])
def test_create_socket_empty(application: web.Application) -> None:
"""
must skip socket creation if not set by configuration
"""
assert create_socket(application["configuration"], application) is None
def test_create_socket_safe(application: web.Application, mocker: MockerFixture) -> None:
"""
must create socket with default permission set
"""
path = "/run/ahriman.sock"
application["configuration"].set_option("web", "unix_socket", str(path))
application["configuration"].set_option("web", "unix_socket_unsafe", "no")
mocker.patch("socket.socket.bind")
mocker.patch("pathlib.Path.unlink")
chmod_mock = mocker.patch("pathlib.Path.chmod")
sock = create_socket(application["configuration"], application)
assert sock is not None
chmod_mock.assert_not_called()
async def test_on_shutdown(application: web.Application, mocker: MockerFixture) -> None:
@ -50,7 +100,7 @@ def test_run(application: web.Application, mocker: MockerFixture) -> None:
run_server(application)
run_application_mock.assert_called_once_with(
application, host="127.0.0.1", port=port, path=None, handle_signals=False,
application, host="127.0.0.1", port=port, sock=None, handle_signals=False,
access_log=pytest.helpers.anyvar(int), access_log_class=FilteredAccessLogger
)
@ -65,7 +115,7 @@ def test_run_with_auth(application_with_auth: web.Application, mocker: MockerFix
run_server(application_with_auth)
run_application_mock.assert_called_once_with(
application_with_auth, host="127.0.0.1", port=port, path=None, handle_signals=False,
application_with_auth, host="127.0.0.1", port=port, sock=None, handle_signals=False,
access_log=pytest.helpers.anyvar(int), access_log_class=FilteredAccessLogger
)
@ -80,7 +130,7 @@ def test_run_with_debug(application_with_debug: web.Application, mocker: MockerF
run_server(application_with_debug)
run_application_mock.assert_called_once_with(
application_with_debug, host="127.0.0.1", port=port, path=None, handle_signals=False,
application_with_debug, host="127.0.0.1", port=port, sock=None, handle_signals=False,
access_log=pytest.helpers.anyvar(int), access_log_class=FilteredAccessLogger
)
@ -90,13 +140,13 @@ def test_run_with_socket(application: web.Application, mocker: MockerFixture) ->
must run application
"""
port = 8080
socket = "/run/ahriman.sock"
application["configuration"].set_option("web", "port", str(port))
application["configuration"].set_option("web", "unix_socket", socket)
socket_mock = mocker.patch("ahriman.web.web.create_socket", return_value=42)
run_application_mock = mocker.patch("aiohttp.web.run_app")
run_server(application)
socket_mock.assert_called_once_with(application["configuration"], application)
run_application_mock.assert_called_once_with(
application, host="127.0.0.1", port=port, path=socket, handle_signals=False,
application, host="127.0.0.1", port=port, sock=42, handle_signals=False,
access_log=pytest.helpers.anyvar(int), access_log_class=FilteredAccessLogger
)

View File

@ -45,7 +45,7 @@ push_url = https://github.com/arcan1s/repository.git
pull_url = https://github.com/arcan1s/repository.git
[report]
target =
target = console
[email]
host = 127.0.0.1