support of new schema in systemd units

This commit is contained in:
2023-09-01 03:07:06 +03:00
committed by Evgenii Alekseev
parent 18763d16cf
commit 5693b84c21
14 changed files with 101 additions and 60 deletions

View File

@ -83,6 +83,9 @@ def _parser() -> argparse.ArgumentParser:
action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-r", "--repository", help="target repository. For several subcommands it can be used "
"multiple times", action="append")
# special secret argument for systemd unit. The issue is that systemd doesn't allow multiple arguments to template
# name. This parameter accepts [[arch]-repo] in order to keep backward compatibility
parser.add_argument("--repository-id", help=argparse.SUPPRESS)
parser.add_argument("-q", "--quiet", help="force disable any logging", action="store_true")
parser.add_argument("--unsafe", help="allow to run ahriman as non-ahriman user. Some actions might be unavailable",
action="store_true")

View File

@ -124,6 +124,15 @@ class Handler:
# pylint, wtf???
root = configuration.getpath("repository", "root") # pylint: disable=assignment-from-no-return
# preparse systemd repository-id argument
# we are using unescaped values, so / is not allowed here, because it is impossible to separate if from dashes
if args.repository_id is not None:
# repository parts is optional for backward compatibility
architecture, *repository_parts = args.repository_id.split("/")
args.architecture = [architecture]
if repository_parts:
args.repository = ["-".join(repository_parts)] # replace slash with dash
# extract repository names first
names = args.repository
if names is None: # try to read file system first