mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
more verbose variables
This commit is contained in:
parent
eb02e1e62b
commit
4ca2348f0d
@ -40,7 +40,7 @@ def _parser() -> argparse.ArgumentParser:
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument("-a", "--architecture", help="target architectures (can be used multiple times)",
|
||||
action="append", required=True)
|
||||
parser.add_argument("-c", "--config", help="configuration path", default="/etc/ahriman.ini")
|
||||
parser.add_argument("-c", "--configuration", help="configuration path", default="/etc/ahriman.ini")
|
||||
parser.add_argument("--force", help="force run, remove file lock", action="store_true")
|
||||
parser.add_argument("--lock", help="lock file", default="/tmp/ahriman.lock")
|
||||
parser.add_argument("--no-log", help="redirect all log messages to stderr", action="store_true")
|
||||
@ -175,7 +175,7 @@ def _set_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
description="create initial service configuration, requires root",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
|
||||
parser.add_argument("--from-config", help="path to default devtools pacman configuration",
|
||||
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
|
||||
default="/usr/share/devtools/pacman-extra.conf")
|
||||
parser.add_argument("--no-multilib", help="do not add multilib repository", action="store_true")
|
||||
parser.add_argument("--packager", help="packager name and email", required=True)
|
||||
|
@ -35,21 +35,21 @@ class Application:
|
||||
"""
|
||||
base application class
|
||||
:ivar architecture: repository architecture
|
||||
:ivar config: configuration instance
|
||||
:ivar configuration: configuration instance
|
||||
:ivar logger: application logger
|
||||
:ivar repository: repository instance
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("root")
|
||||
self.config = config
|
||||
self.configuration = configuration
|
||||
self.architecture = architecture
|
||||
self.repository = Repository(architecture, config)
|
||||
self.repository = Repository(architecture, configuration)
|
||||
|
||||
def _known_packages(self) -> Set[str]:
|
||||
"""
|
||||
@ -106,7 +106,7 @@ class Application:
|
||||
add_archive(full_path)
|
||||
|
||||
def add_manual(src: str) -> Path:
|
||||
package = Package.load(src, self.repository.pacman, self.config.get("alpm", "aur_url"))
|
||||
package = Package.load(src, self.repository.pacman, self.configuration.get("alpm", "aur_url"))
|
||||
path = self.repository.paths.manual / package.base
|
||||
Task.fetch(path, package.git_url)
|
||||
return path
|
||||
|
@ -32,11 +32,11 @@ class Add(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).add(args.package, args.without_dependencies)
|
||||
Application(architecture, configuration).add(args.package, args.without_dependencies)
|
||||
|
@ -32,12 +32,12 @@ class Clean(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).clean(args.no_build, args.no_cache, args.no_chroot,
|
||||
Application(architecture, configuration).clean(args.no_build, args.no_cache, args.no_chroot,
|
||||
args.no_manual, args.no_packages)
|
||||
|
@ -27,21 +27,21 @@ from ahriman.core.configuration import Configuration
|
||||
|
||||
class Dump(Handler):
|
||||
"""
|
||||
dump config handler
|
||||
dump configuration handler
|
||||
"""
|
||||
|
||||
_print = print
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
config_dump = config.dump(architecture)
|
||||
for section, values in sorted(config_dump.items()):
|
||||
dump = configuration.dump(architecture)
|
||||
for section, values in sorted(dump.items()):
|
||||
Dump._print(f"[{section}]")
|
||||
for key, value in sorted(values.items()):
|
||||
Dump._print(f"{key} = {value}")
|
||||
|
@ -35,17 +35,17 @@ class Handler:
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def _call(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> bool:
|
||||
def _call(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> bool:
|
||||
"""
|
||||
additional function to wrap all calls for multiprocessing library
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:return: True on success, False otherwise
|
||||
"""
|
||||
try:
|
||||
with Lock(args, architecture, config):
|
||||
cls.run(args, architecture, config)
|
||||
with Lock(args, architecture, configuration):
|
||||
cls.run(args, architecture, configuration)
|
||||
return True
|
||||
except Exception:
|
||||
logging.getLogger("root").exception("process exception")
|
||||
@ -58,18 +58,18 @@ class Handler:
|
||||
:param args: command line args
|
||||
:return: 0 on success, 1 otherwise
|
||||
"""
|
||||
configuration = Configuration.from_path(args.config, not args.no_log)
|
||||
configuration = Configuration.from_path(args.configuration, not args.no_log)
|
||||
with Pool(len(args.architecture)) as pool:
|
||||
result = pool.starmap(
|
||||
cls._call, [(args, architecture, configuration) for architecture in args.architecture])
|
||||
return 0 if all(result) else 1
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
@ -32,13 +32,13 @@ class Rebuild(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
application = Application(architecture, config)
|
||||
application = Application(architecture, configuration)
|
||||
packages = application.repository.packages()
|
||||
application.update(packages)
|
||||
|
@ -32,11 +32,11 @@ class Remove(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).remove(args.package)
|
||||
Application(architecture, configuration).remove(args.package)
|
||||
|
@ -32,11 +32,11 @@ class Report(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).report(args.target)
|
||||
Application(architecture, configuration).report(args.target)
|
||||
|
@ -44,19 +44,19 @@ class Setup(Handler):
|
||||
SUDOERS_PATH = Path("/etc/sudoers.d/ahriman")
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
application = Application(architecture, config)
|
||||
application = Application(architecture, configuration)
|
||||
Setup.create_makepkg_configuration(args.packager, application.repository.paths)
|
||||
Setup.create_executable(args.build_command, architecture)
|
||||
Setup.create_devtools_configuration(args.build_command, architecture, Path(args.from_config), args.no_multilib,
|
||||
args.repository, application.repository.paths)
|
||||
Setup.create_ahriman_configuration(args.build_command, architecture, args.repository, config.include)
|
||||
Setup.create_devtools_configuration(args.build_command, architecture, Path(args.from_configuration),
|
||||
args.no_multilib, args.repository, application.repository.paths)
|
||||
Setup.create_ahriman_configuration(args.build_command, architecture, args.repository, configuration.include)
|
||||
Setup.create_sudo_configuration(args.build_command, architecture)
|
||||
|
||||
@staticmethod
|
||||
@ -78,17 +78,17 @@ class Setup(Handler):
|
||||
:param repository: repository name
|
||||
:param include_path: path to directory with configuration includes
|
||||
"""
|
||||
config = configparser.ConfigParser()
|
||||
configuration = configparser.ConfigParser()
|
||||
|
||||
config.add_section("build")
|
||||
config.set("build", "build_command", str(Setup.build_command(prefix, architecture)))
|
||||
configuration.add_section("build")
|
||||
configuration.set("build", "build_command", str(Setup.build_command(prefix, architecture)))
|
||||
|
||||
config.add_section("repository")
|
||||
config.set("repository", "name", repository)
|
||||
configuration.add_section("repository")
|
||||
configuration.set("repository", "name", repository)
|
||||
|
||||
target = include_path / "build-overrides.ini"
|
||||
with target.open("w") as ahriman_config:
|
||||
config.write(ahriman_config)
|
||||
with target.open("w") as ahriman_configuration:
|
||||
configuration.write(ahriman_configuration)
|
||||
|
||||
@staticmethod
|
||||
def create_devtools_configuration(prefix: str, architecture: str, source: Path,
|
||||
@ -102,31 +102,31 @@ class Setup(Handler):
|
||||
:param repository: repository name
|
||||
:param paths: repository paths instance
|
||||
"""
|
||||
config = configparser.ConfigParser()
|
||||
configuration = configparser.ConfigParser()
|
||||
# preserve case
|
||||
# stupid mypy thinks that it is impossible
|
||||
config.optionxform = lambda key: key # type: ignore
|
||||
configuration.optionxform = lambda key: key # type: ignore
|
||||
|
||||
# load default configuration first
|
||||
# we cannot use Include here because it will be copied to new chroot, thus no includes there
|
||||
config.read(source)
|
||||
configuration.read(source)
|
||||
|
||||
# set our architecture now
|
||||
config.set("options", "Architecture", architecture)
|
||||
configuration.set("options", "Architecture", architecture)
|
||||
|
||||
# add multilib
|
||||
if not no_multilib:
|
||||
config.add_section("multilib")
|
||||
config.set("multilib", "Include", str(Setup.MIRRORLIST_PATH))
|
||||
configuration.add_section("multilib")
|
||||
configuration.set("multilib", "Include", str(Setup.MIRRORLIST_PATH))
|
||||
|
||||
# add repository itself
|
||||
config.add_section(repository)
|
||||
config.set(repository, "SigLevel", "Optional TrustAll") # we don't care
|
||||
config.set(repository, "Server", f"file://{paths.repository}")
|
||||
configuration.add_section(repository)
|
||||
configuration.set(repository, "SigLevel", "Optional TrustAll") # we don't care
|
||||
configuration.set(repository, "Server", f"file://{paths.repository}")
|
||||
|
||||
target = source.parent / f"pacman-{prefix}-{architecture}.conf"
|
||||
with target.open("w") as devtools_config:
|
||||
config.write(devtools_config)
|
||||
with target.open("w") as devtools_configuration:
|
||||
configuration.write(devtools_configuration)
|
||||
|
||||
@staticmethod
|
||||
def create_makepkg_configuration(packager: str, paths: RepositoryPaths) -> None:
|
||||
|
@ -32,11 +32,11 @@ class Sign(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).sign(args.package)
|
||||
Application(architecture, configuration).sign(args.package)
|
||||
|
@ -34,14 +34,14 @@ class Status(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
application = Application(architecture, config)
|
||||
application = Application(architecture, configuration)
|
||||
if args.ahriman:
|
||||
ahriman = application.repository.reporter.get_self()
|
||||
print(ahriman.pretty_print())
|
||||
|
@ -33,14 +33,14 @@ class StatusUpdate(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
client = Application(architecture, config).repository.reporter
|
||||
client = Application(architecture, configuration).repository.reporter
|
||||
status = BuildStatusEnum(args.status)
|
||||
if args.package:
|
||||
# update packages statuses
|
||||
|
@ -32,11 +32,11 @@ class Sync(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Application(architecture, config).sync(args.target)
|
||||
Application(architecture, configuration).sync(args.target)
|
||||
|
@ -32,18 +32,18 @@ class Update(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
# typing workaround
|
||||
def log_fn(line: str) -> None:
|
||||
return print(line) if args.dry_run else application.logger.info(line)
|
||||
|
||||
application = Application(architecture, config)
|
||||
application = Application(architecture, configuration)
|
||||
packages = application.get_updates(args.package, args.no_aur, args.no_manual, args.no_vcs, log_fn)
|
||||
if args.dry_run:
|
||||
return
|
||||
|
@ -31,13 +31,13 @@ class Web(Handler):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
from ahriman.web.web import run_server, setup_service
|
||||
application = setup_service(architecture, config)
|
||||
application = setup_service(architecture, configuration)
|
||||
run_server(application)
|
||||
|
@ -42,19 +42,19 @@ class Lock:
|
||||
:ivar unsafe: skip user check
|
||||
"""
|
||||
|
||||
def __init__(self, args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, args: argparse.Namespace, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.path = Path(f"{args.lock}_{architecture}") if args.lock is not None else None
|
||||
self.force = args.force
|
||||
self.unsafe = args.unsafe
|
||||
|
||||
self.root = Path(config.get("repository", "root"))
|
||||
self.reporter = Client() if args.no_report else Client.load(architecture, config)
|
||||
self.root = Path(configuration.get("repository", "root"))
|
||||
self.reporter = Client() if args.no_report else Client.load(architecture, configuration)
|
||||
|
||||
def __enter__(self) -> Lock:
|
||||
"""
|
||||
|
@ -29,15 +29,15 @@ class Pacman:
|
||||
:ivar handle: pyalpm root `Handle`
|
||||
"""
|
||||
|
||||
def __init__(self, config: Configuration) -> None:
|
||||
def __init__(self, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
root = config.get("alpm", "root")
|
||||
pacman_root = config.getpath("alpm", "database")
|
||||
root = configuration.get("alpm", "root")
|
||||
pacman_root = configuration.getpath("alpm", "database")
|
||||
self.handle = Handle(root, str(pacman_root))
|
||||
for repository in config.getlist("alpm", "repositories"):
|
||||
for repository in configuration.getlist("alpm", "repositories"):
|
||||
self.handle.register_syncdb(repository, 0) # 0 is pgp_level
|
||||
|
||||
def all_packages(self) -> List[str]:
|
||||
|
@ -41,12 +41,13 @@ class Task:
|
||||
|
||||
_check_output = check_output
|
||||
|
||||
def __init__(self, package: Package, architecture: str, config: Configuration, paths: RepositoryPaths) -> None:
|
||||
def __init__(self, package: Package, architecture: str, configuration: Configuration,
|
||||
paths: RepositoryPaths) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param package: package definitions
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:param paths: repository paths instance
|
||||
"""
|
||||
self.logger = logging.getLogger("builder")
|
||||
@ -54,10 +55,11 @@ class Task:
|
||||
self.package = package
|
||||
self.paths = paths
|
||||
|
||||
self.archbuild_flags = config.wrap("build", architecture, "archbuild_flags", config.getlist)
|
||||
self.build_command = config.wrap("build", architecture, "build_command", config.get)
|
||||
self.makepkg_flags = config.wrap("build", architecture, "makepkg_flags", config.getlist)
|
||||
self.makechrootpkg_flags = config.wrap("build", architecture, "makechrootpkg_flags", config.getlist)
|
||||
self.archbuild_flags = configuration.wrap("build", architecture, "archbuild_flags", configuration.getlist)
|
||||
self.build_command = configuration.wrap("build", architecture, "build_command", configuration.get)
|
||||
self.makepkg_flags = configuration.wrap("build", architecture, "makepkg_flags", configuration.getlist)
|
||||
self.makechrootpkg_flags = configuration.wrap("build", architecture, "makechrootpkg_flags",
|
||||
configuration.getlist)
|
||||
|
||||
@property
|
||||
def cache_path(self) -> Path:
|
||||
@ -96,14 +98,14 @@ class Task:
|
||||
run package build
|
||||
:return: paths of produced packages
|
||||
"""
|
||||
cmd = [self.build_command, "-r", str(self.paths.chroot)]
|
||||
cmd.extend(self.archbuild_flags)
|
||||
cmd.extend(["--"] + self.makechrootpkg_flags)
|
||||
cmd.extend(["--"] + self.makepkg_flags)
|
||||
self.logger.info(f"using {cmd} for {self.package.base}")
|
||||
command = [self.build_command, "-r", str(self.paths.chroot)]
|
||||
command.extend(self.archbuild_flags)
|
||||
command.extend(["--"] + self.makechrootpkg_flags)
|
||||
command.extend(["--"] + self.makepkg_flags)
|
||||
self.logger.info(f"using {command} for {self.package.base}")
|
||||
|
||||
Task._check_output(
|
||||
*cmd,
|
||||
*command,
|
||||
exception=BuildFailed(self.package.base),
|
||||
cwd=self.git_path,
|
||||
logger=self.build_logger)
|
||||
|
@ -157,8 +157,8 @@ class Configuration(configparser.RawConfigParser):
|
||||
"""
|
||||
def file_logger() -> None:
|
||||
try:
|
||||
config_path = self.getpath("settings", "logging")
|
||||
fileConfig(config_path)
|
||||
path = self.getpath("settings", "logging")
|
||||
fileConfig(path)
|
||||
except (FileNotFoundError, PermissionError):
|
||||
console_logger()
|
||||
logging.exception("could not create logfile, fallback to stderr")
|
||||
|
@ -63,22 +63,22 @@ class HTML(Report):
|
||||
:ivar template_path: path to directory with jinja templates
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Report.__init__(self, architecture, config)
|
||||
self.report_path = config.wrap("html", architecture, "path", config.getpath)
|
||||
self.link_path = config.wrap("html", architecture, "link_path", config.get)
|
||||
self.template_path = config.wrap("html", architecture, "template_path", config.getpath)
|
||||
Report.__init__(self, architecture, configuration)
|
||||
self.report_path = configuration.wrap("html", architecture, "path", configuration.getpath)
|
||||
self.link_path = configuration.wrap("html", architecture, "link_path", configuration.get)
|
||||
self.template_path = configuration.wrap("html", architecture, "template_path", configuration.getpath)
|
||||
|
||||
# base template vars
|
||||
self.homepage = config.wrap("html", architecture, "homepage", config.get, fallback=None)
|
||||
self.name = config.get("repository", "name")
|
||||
self.homepage = configuration.wrap("html", architecture, "homepage", configuration.get, fallback=None)
|
||||
self.name = configuration.get("repository", "name")
|
||||
|
||||
self.sign_targets, self.default_pgp_key = GPG.sign_options(architecture, config)
|
||||
self.sign_targets, self.default_pgp_key = GPG.sign_options(architecture, configuration)
|
||||
|
||||
def generate(self, packages: Iterable[Package]) -> None:
|
||||
"""
|
||||
|
@ -31,35 +31,35 @@ class Report:
|
||||
"""
|
||||
base report generator
|
||||
:ivar architecture: repository architecture
|
||||
:ivar config: configuration instance
|
||||
:ivar configuration: configuration instance
|
||||
:ivar logger: class logger
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("builder")
|
||||
self.architecture = architecture
|
||||
self.config = config
|
||||
self.configuration = configuration
|
||||
|
||||
@staticmethod
|
||||
def run(architecture: str, config: Configuration, target: str, packages: Iterable[Package]) -> None:
|
||||
def run(architecture: str, configuration: Configuration, target: str, packages: Iterable[Package]) -> None:
|
||||
"""
|
||||
run report generation
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:param target: target to generate report (e.g. html)
|
||||
:param packages: list of packages to generate report
|
||||
"""
|
||||
provider = ReportSettings.from_option(target)
|
||||
if provider == ReportSettings.HTML:
|
||||
from ahriman.core.report.html import HTML
|
||||
report: Report = HTML(architecture, config)
|
||||
report: Report = HTML(architecture, configuration)
|
||||
else:
|
||||
report = Report(architecture, config)
|
||||
report = Report(architecture, configuration)
|
||||
|
||||
try:
|
||||
report.generate(packages)
|
||||
|
@ -49,7 +49,7 @@ class Executor(Cleaner):
|
||||
"""
|
||||
def build_single(package: Package) -> None:
|
||||
self.reporter.set_building(package.base)
|
||||
task = Task(package, self.architecture, self.config, self.paths)
|
||||
task = Task(package, self.architecture, self.configuration, self.paths)
|
||||
task.init()
|
||||
built = task.build()
|
||||
for src in built:
|
||||
@ -106,9 +106,9 @@ class Executor(Cleaner):
|
||||
:param targets: list of targets to generate reports. Configuration option will be used if it is not set
|
||||
"""
|
||||
if targets is None:
|
||||
targets = self.config.getlist("report", "target")
|
||||
targets = self.configuration.getlist("report", "target")
|
||||
for target in targets:
|
||||
Report.run(self.architecture, self.config, target, self.packages())
|
||||
Report.run(self.architecture, self.configuration, target, self.packages())
|
||||
|
||||
def process_sync(self, targets: Optional[Iterable[str]]) -> None:
|
||||
"""
|
||||
@ -116,9 +116,9 @@ class Executor(Cleaner):
|
||||
:param targets: list of targets to sync. Configuration option will be used if it is not set
|
||||
"""
|
||||
if targets is None:
|
||||
targets = self.config.getlist("upload", "target")
|
||||
targets = self.configuration.getlist("upload", "target")
|
||||
for target in targets:
|
||||
Upload.run(self.architecture, self.config, target, self.paths.repository)
|
||||
Upload.run(self.architecture, self.configuration, target, self.paths.repository)
|
||||
|
||||
def process_update(self, packages: Iterable[Path]) -> Path:
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ class Properties:
|
||||
repository internal objects holder
|
||||
:ivar architecture: repository architecture
|
||||
:ivar aur_url: base AUR url
|
||||
:ivar config: configuration instance
|
||||
:ivar configuration: configuration instance
|
||||
:ivar logger: class logger
|
||||
:ivar name: repository name
|
||||
:ivar pacman: alpm wrapper instance
|
||||
@ -42,18 +42,18 @@ class Properties:
|
||||
:ivar sign: GPG wrapper instance
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
self.logger = logging.getLogger("builder")
|
||||
self.architecture = architecture
|
||||
self.config = config
|
||||
self.configuration = configuration
|
||||
|
||||
self.aur_url = config.get("alpm", "aur_url")
|
||||
self.name = config.get("repository", "name")
|
||||
self.aur_url = configuration.get("alpm", "aur_url")
|
||||
self.name = configuration.get("repository", "name")
|
||||
|
||||
self.paths = RepositoryPaths(config.getpath("repository", "root"), architecture)
|
||||
self.paths = RepositoryPaths(configuration.getpath("repository", "root"), architecture)
|
||||
self.paths.create_tree()
|
||||
|
||||
self.pacman = Pacman(config)
|
||||
self.sign = GPG(architecture, config)
|
||||
self.pacman = Pacman(configuration)
|
||||
self.sign = GPG(architecture, configuration)
|
||||
self.repo = Repo(self.name, self.paths, self.sign.repository_sign_args)
|
||||
self.reporter = Client.load(architecture, config)
|
||||
self.reporter = Client.load(architecture, configuration)
|
||||
|
@ -44,7 +44,7 @@ class UpdateHandler(Cleaner):
|
||||
"""
|
||||
result: List[Package] = []
|
||||
|
||||
ignore_list = self.config.wrap("build", self.architecture, "ignore_packages", self.config.getlist)
|
||||
ignore_list = self.configuration.wrap("build", self.architecture, "ignore_packages", self.configuration.getlist)
|
||||
|
||||
for local in self.packages():
|
||||
if local.base in ignore_list:
|
||||
|
@ -32,7 +32,7 @@ class GPG:
|
||||
"""
|
||||
gnupg wrapper
|
||||
:ivar architecture: repository architecture
|
||||
:ivar config: configuration instance
|
||||
:ivar configuration: configuration instance
|
||||
:ivar default_key: default PGP key ID to use
|
||||
:ivar logger: class logger
|
||||
:ivar targets: list of targets to sign (repository, package etc)
|
||||
@ -40,16 +40,16 @@ class GPG:
|
||||
|
||||
_check_output = check_output
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("build_details")
|
||||
self.architecture = architecture
|
||||
self.config = config
|
||||
self.targets, self.default_key = self.sign_options(architecture, config)
|
||||
self.configuration = configuration
|
||||
self.targets, self.default_key = self.sign_options(architecture, configuration)
|
||||
|
||||
@property
|
||||
def repository_sign_args(self) -> List[str]:
|
||||
@ -74,18 +74,18 @@ class GPG:
|
||||
return ["gpg", "-u", key, "-b", str(path)]
|
||||
|
||||
@staticmethod
|
||||
def sign_options(architecture: str, config: Configuration) -> Tuple[Set[SignSettings], Optional[str]]:
|
||||
def sign_options(architecture: str, configuration: Configuration) -> Tuple[Set[SignSettings], Optional[str]]:
|
||||
"""
|
||||
extract default sign options from configuration
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:return: tuple of sign targets and default PGP key
|
||||
"""
|
||||
targets = {
|
||||
SignSettings.from_option(option)
|
||||
for option in config.wrap("sign", architecture, "targets", config.getlist)
|
||||
for option in configuration.wrap("sign", architecture, "targets", configuration.getlist)
|
||||
}
|
||||
default_key = config.wrap("sign", architecture, "key", config.get) if targets else None
|
||||
default_key = configuration.wrap("sign", architecture, "key", configuration.get) if targets else None
|
||||
return targets, default_key
|
||||
|
||||
def process(self, path: Path, key: str) -> List[Path]:
|
||||
@ -110,8 +110,8 @@ class GPG:
|
||||
"""
|
||||
if SignSettings.SignPackages not in self.targets:
|
||||
return [path]
|
||||
key = self.config.wrap("sign", self.architecture, f"key_{base}",
|
||||
self.config.get, fallback=self.default_key)
|
||||
key = self.configuration.wrap("sign", self.architecture, f"key_{base}",
|
||||
self.configuration.get, fallback=self.default_key)
|
||||
if key is None:
|
||||
self.logger.error(f"no default key set, skip package {path} sign")
|
||||
return [path]
|
||||
|
@ -111,15 +111,15 @@ class Client:
|
||||
return self.add(package, BuildStatusEnum.Unknown)
|
||||
|
||||
@staticmethod
|
||||
def load(architecture: str, config: Configuration) -> Client:
|
||||
def load(architecture: str, configuration: Configuration) -> Client:
|
||||
"""
|
||||
load client from settings
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:return: client according to current settings
|
||||
"""
|
||||
host = config.wrap("web", architecture, "host", config.get, fallback=None)
|
||||
port = config.wrap("web", architecture, "port", config.getint, fallback=None)
|
||||
host = configuration.wrap("web", architecture, "host", configuration.get, fallback=None)
|
||||
port = configuration.wrap("web", architecture, "port", configuration.getint, fallback=None)
|
||||
if host is None or port is None:
|
||||
return Client()
|
||||
|
||||
|
@ -40,16 +40,16 @@ class Watcher:
|
||||
:ivar status: daemon status
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("http")
|
||||
|
||||
self.architecture = architecture
|
||||
self.repository = Repository(architecture, config)
|
||||
self.repository = Repository(architecture, configuration)
|
||||
|
||||
self.known: Dict[str, Tuple[Package, BuildStatus]] = {}
|
||||
self.status = BuildStatus()
|
||||
|
@ -27,20 +27,21 @@ from ahriman.core.util import check_output
|
||||
class Rsync(Upload):
|
||||
"""
|
||||
rsync wrapper
|
||||
:ivar command: command arguments for sync
|
||||
:ivar remote: remote address to sync
|
||||
"""
|
||||
|
||||
_check_output = check_output
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Upload.__init__(self, architecture, config)
|
||||
self.command = config.wrap("rsync", architecture, "command", config.getlist)
|
||||
self.remote = config.wrap("rsync", architecture, "remote", config.get)
|
||||
Upload.__init__(self, architecture, configuration)
|
||||
self.command = configuration.wrap("rsync", architecture, "command", configuration.getlist)
|
||||
self.remote = configuration.wrap("rsync", architecture, "remote", configuration.get)
|
||||
|
||||
def sync(self, path: Path) -> None:
|
||||
"""
|
||||
|
@ -28,19 +28,20 @@ class S3(Upload):
|
||||
"""
|
||||
aws-cli wrapper
|
||||
:ivar bucket: full bucket name
|
||||
:ivar command: command arguments for sync
|
||||
"""
|
||||
|
||||
_check_output = check_output
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
Upload.__init__(self, architecture, config)
|
||||
self.bucket = config.wrap("s3", architecture, "bucket", config.get)
|
||||
self.command = config.wrap("s3", architecture, "command", config.getlist)
|
||||
Upload.__init__(self, architecture, configuration)
|
||||
self.bucket = configuration.wrap("s3", architecture, "bucket", configuration.get)
|
||||
self.command = configuration.wrap("s3", architecture, "command", configuration.getlist)
|
||||
|
||||
def sync(self, path: Path) -> None:
|
||||
"""
|
||||
|
@ -30,38 +30,38 @@ class Upload:
|
||||
"""
|
||||
base remote sync class
|
||||
:ivar architecture: repository architecture
|
||||
:ivar config: configuration instance
|
||||
:ivar configuration: configuration instance
|
||||
:ivar logger: application logger
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
def __init__(self, architecture: str, configuration: Configuration) -> None:
|
||||
"""
|
||||
default constructor
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("builder")
|
||||
self.architecture = architecture
|
||||
self.config = config
|
||||
self.config = configuration
|
||||
|
||||
@staticmethod
|
||||
def run(architecture: str, config: Configuration, target: str, path: Path) -> None:
|
||||
def run(architecture: str, configuration: Configuration, target: str, path: Path) -> None:
|
||||
"""
|
||||
run remote sync
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:param target: target to run sync (e.g. s3)
|
||||
:param path: local path to sync
|
||||
"""
|
||||
provider = UploadSettings.from_option(target)
|
||||
if provider == UploadSettings.Rsync:
|
||||
from ahriman.core.upload.rsync import Rsync
|
||||
upload: Upload = Rsync(architecture, config)
|
||||
upload: Upload = Rsync(architecture, configuration)
|
||||
elif provider == UploadSettings.S3:
|
||||
from ahriman.core.upload.s3 import S3
|
||||
upload = S3(architecture, config)
|
||||
upload = S3(architecture, configuration)
|
||||
else:
|
||||
upload = Upload(architecture, config)
|
||||
upload = Upload(architecture, configuration)
|
||||
|
||||
try:
|
||||
upload.sync(path)
|
||||
|
@ -59,19 +59,19 @@ def run_server(application: web.Application) -> None:
|
||||
application.logger.info("start server")
|
||||
|
||||
architecture: str = application["architecture"]
|
||||
config: Configuration = application["config"]
|
||||
host = config.wrap("web", architecture, "host", config.get)
|
||||
port = config.wrap("web", architecture, "port", config.getint)
|
||||
configuration: Configuration = application["configuration"]
|
||||
host = configuration.wrap("web", architecture, "host", configuration.get)
|
||||
port = configuration.wrap("web", architecture, "port", configuration.getint)
|
||||
|
||||
web.run_app(application, host=host, port=port, handle_signals=False,
|
||||
access_log=logging.getLogger("http"))
|
||||
|
||||
|
||||
def setup_service(architecture: str, config: Configuration) -> web.Application:
|
||||
def setup_service(architecture: str, configuration: Configuration) -> web.Application:
|
||||
"""
|
||||
create web application
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
:param configuration: configuration instance
|
||||
:return: web application instance
|
||||
"""
|
||||
application = web.Application(logger=logging.getLogger("http"))
|
||||
@ -85,13 +85,13 @@ def setup_service(architecture: str, config: Configuration) -> web.Application:
|
||||
setup_routes(application)
|
||||
|
||||
application.logger.info("setup templates")
|
||||
aiohttp_jinja2.setup(application, loader=jinja2.FileSystemLoader(config.getpath("web", "templates")))
|
||||
aiohttp_jinja2.setup(application, loader=jinja2.FileSystemLoader(configuration.getpath("web", "templates")))
|
||||
|
||||
application.logger.info("setup configuration")
|
||||
application["config"] = config
|
||||
application["configuration"] = configuration
|
||||
application["architecture"] = architecture
|
||||
|
||||
application.logger.info("setup watcher")
|
||||
application["watcher"] = Watcher(architecture, config)
|
||||
application["watcher"] = Watcher(architecture, configuration)
|
||||
|
||||
return application
|
||||
|
@ -11,7 +11,7 @@ from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.build_command = "ahriman"
|
||||
args.from_config = "/usr/share/devtools/pacman-extra.conf"
|
||||
args.from_configuration = "/usr/share/devtools/pacman-extra.conf"
|
||||
args.no_multilib = False
|
||||
args.packager = "John Doe <john@doe.com>"
|
||||
args.repository = "aur-clone"
|
||||
@ -81,8 +81,8 @@ def test_create_devtools_configuration(args: argparse.Namespace, repository_path
|
||||
add_section_mock = mocker.patch("configparser.RawConfigParser.add_section")
|
||||
write_mock = mocker.patch("configparser.RawConfigParser.write")
|
||||
|
||||
Setup.create_devtools_configuration(args.build_command, "x86_64", Path(args.from_config), args.no_multilib,
|
||||
args.repository, repository_paths)
|
||||
Setup.create_devtools_configuration(args.build_command, "x86_64", Path(args.from_configuration),
|
||||
args.no_multilib, args.repository, repository_paths)
|
||||
add_section_mock.assert_has_calls([
|
||||
mock.call("multilib"),
|
||||
mock.call(args.repository)
|
||||
@ -101,8 +101,8 @@ def test_create_devtools_configuration_no_multilib(args: argparse.Namespace, rep
|
||||
add_section_mock = mocker.patch("configparser.RawConfigParser.add_section")
|
||||
write_mock = mocker.patch("configparser.RawConfigParser.write")
|
||||
|
||||
Setup.create_devtools_configuration(args.build_command, "x86_64", Path(args.from_config), True,
|
||||
args.repository, repository_paths)
|
||||
Setup.create_devtools_configuration(args.build_command, "x86_64", Path(args.from_configuration),
|
||||
True, args.repository, repository_paths)
|
||||
add_section_mock.assert_called_once()
|
||||
write_mock.assert_called_once()
|
||||
|
||||
|
@ -107,20 +107,20 @@ def test_process_report_auto(executor: Executor, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process report in auto mode if no targets supplied
|
||||
"""
|
||||
config_getlist_mock = mocker.patch("ahriman.core.configuration.Configuration.getlist")
|
||||
configuration_getlist_mock = mocker.patch("ahriman.core.configuration.Configuration.getlist")
|
||||
|
||||
executor.process_report(None)
|
||||
config_getlist_mock.assert_called_once()
|
||||
configuration_getlist_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_process_sync_auto(executor: Executor, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process sync in auto mode if no targets supplied
|
||||
"""
|
||||
config_getlist_mock = mocker.patch("ahriman.core.configuration.Configuration.getlist")
|
||||
configuration_getlist_mock = mocker.patch("ahriman.core.configuration.Configuration.getlist")
|
||||
|
||||
executor.process_sync(None)
|
||||
config_getlist_mock.assert_called_once()
|
||||
configuration_getlist_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_process_update(executor: Executor, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
|
@ -36,10 +36,10 @@ def test_run(application: web.Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
host = "localhost"
|
||||
port = 8080
|
||||
application["config"].set("web", "host", host)
|
||||
application["config"].set("web", "port", str(port))
|
||||
run_app_mock = mocker.patch("aiohttp.web.run_app")
|
||||
application["configuration"].set("web", "host", host)
|
||||
application["configuration"].set("web", "port", str(port))
|
||||
run_application_mock = mocker.patch("aiohttp.web.run_app")
|
||||
|
||||
run_server(application)
|
||||
run_app_mock.assert_called_with(application, host=host, port=port,
|
||||
run_application_mock.assert_called_with(application, host=host, port=port,
|
||||
handle_signals=False, access_log=pytest.helpers.anyvar(int))
|
||||
|
Loading…
Reference in New Issue
Block a user