From aac3ccfc30e6190b08534f45030af61c6218b4d0 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Mon, 8 May 2023 18:01:13 +0300 Subject: [PATCH] migration to pkgctl --- .github/workflows/setup.sh | 6 +- Dockerfile | 2 +- docker/entrypoint.sh | 1 - docs/configuration.rst | 4 +- docs/setup.rst | 35 +++-------- package/archlinux/PKGBUILD | 2 +- package/share/ahriman/settings/ahriman.ini | 6 +- src/ahriman/application/ahriman.py | 10 +-- src/ahriman/application/handlers/setup.py | 61 ++++--------------- src/ahriman/core/build_tools/task.py | 20 +++--- src/ahriman/core/configuration/schema.py | 12 +--- .../handlers/test_handler_setup.py | 57 ++++------------- tests/testresources/core/ahriman.ini | 5 +- 13 files changed, 60 insertions(+), 161 deletions(-) diff --git a/.github/workflows/setup.sh b/.github/workflows/setup.sh index 5f5aebaa..f4db480d 100755 --- a/.github/workflows/setup.sh +++ b/.github/workflows/setup.sh @@ -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-cerberus python-inflection python-passlib python-requests python-srcinfo sudo +pacman --noconfirm -Sy base-devel devtools-git-poc git pyalpm python-cerberus python-inflection python-passlib python-requests python-srcinfo sudo # make dependencies pacman --noconfirm -Sy python-build python-installer python-wheel # optional dependencies @@ -52,9 +52,9 @@ if [[ -z $MINIMAL_INSTALL ]]; then fi # add the first package # the build itself does not really work in the container -sudo -u ahriman -- ahriman package-add --now yay +sudo -u ahriman -- ahriman package-add --now ahriman # check if package was actually installed -test -n "$(find "/var/lib/ahriman/repository/x86_64" -name "yay*pkg*")" +test -n "$(find "/var/lib/ahriman/repository/x86_64" -name "ahriman*pkg*")" # run package check sudo -u ahriman -- ahriman repo-update # stop web service lol diff --git a/Dockerfile b/Dockerfile index 96b5ae8d..e6ada93a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,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-cerberus python-inflection python-passlib python-requests python-srcinfo && \ +RUN pacman --noconfirm -Sy devtools-git-poc git pyalpm python-cerberus python-inflection python-passlib python-requests python-srcinfo && \ pacman --noconfirm -Sy python-build python-installer python-wheel && \ pacman --noconfirm -Sy breezy mercurial python-aiohttp python-aiohttp-cors python-boto3 python-cryptography python-jinja python-requests-unixsocket rsync subversion && \ runuser -u build -- install-aur-package python-aioauth-client python-aiohttp-apispec-git python-aiohttp-jinja2 \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 69bc91cf..547b1ba6 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -36,7 +36,6 @@ AHRIMAN_GNUPG_HOME="$(getent passwd "$AHRIMAN_USER" | cut -d : -f 6)/.gnupg" chown "$AHRIMAN_USER":"$AHRIMAN_USER" "$AHRIMAN_GNUPG_HOME" # run built-in setup command -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 diff --git a/docs/configuration.rst b/docs/configuration.rst index 4568ce60..cb348019 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -63,11 +63,9 @@ Authorized users are stored inside internal database, if any of external provide Build related configuration. Group name can refer to architecture, e.g. ``build:x86_64`` can be used for x86_64 architecture specific settings. -* ``archbuild_flags`` - additional flags passed to ``archbuild`` command, space separated list of strings, optional. * ``build_command`` - default build command, string, required. +* ``build_flags`` - additional ``pkgctl`` flags, space separated list of strings, optional. * ``ignore_packages`` - list packages to ignore during a regular update (manual update will still work), space separated list of strings, optional. -* ``makepkg_flags`` - additional flags passed to ``makepkg`` command, space separated list of strings, optional. -* ``makechrootpkg_flags`` - additional flags passed to ``makechrootpkg`` command, space separated list of strings, optional. * ``triggers`` - list of ``ahriman.core.triggers.Trigger`` class implementation (e.g. ``ahriman.core.report.ReportTrigger ahriman.core.upload.UploadTrigger``) which will be loaded and run at the end of processing, space separated list of strings, optional. You can also specify triggers by their paths, e.g. ``/usr/lib/python3.10/site-packages/ahriman/core/report/report.py.ReportTrigger``. Triggers are run in the order of mention. * ``vcs_allowed_age`` - maximal age in seconds of the VCS packages before their version will be updated with its remote source, int, optional, default ``604800``. diff --git a/docs/setup.rst b/docs/setup.rst index 3c930c45..31f954af 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -24,46 +24,31 @@ Initial setup #. Configure build tools (it is required for correct dependency management system): - #. - Create build command (you can choose any name for command, basically it should be ``{name}-{arch}-build``): + #. + Create configuration file ``{repository}.conf``: .. code-block:: shell - ln -s /usr/bin/archbuild /usr/local/bin/ahriman-x86_64-build - - #. - Create configuration file (same as previous ``pacman-{name}.conf``): - - .. code-block:: shell - - cp /usr/share/devtools/pacman-{extra,ahriman}.conf + cp /usr/local/share/devtools-git-poc/pacman.conf.d/{extra,aur-clone}.conf #. Change configuration file, add your own repository, add multilib repository etc: .. code-block:: shell - echo '[multilib]' | tee -a /usr/share/devtools/pacman-ahriman.conf - echo 'Include = /etc/pacman.d/mirrorlist' | tee -a /usr/share/devtools/pacman-ahriman.conf + echo '[multilib]' | tee -a /usr/local/share/devtools-git-poc/pacman.conf.d/aur-clone.conf + echo 'Include = /etc/pacman.d/mirrorlist' | tee -a /usr/local/share/devtools-git-poc/pacman.conf.d/aur-clone.conf - echo '[aur-clone]' | tee -a /usr/share/devtools/pacman-ahriman.conf - echo 'SigLevel = Optional TrustAll' | tee -a /usr/share/devtools/pacman-ahriman.conf - echo 'Server = file:///var/lib/ahriman/repository/$arch' | tee -a /usr/share/devtools/pacman-ahriman.conf - - #. - Set ``build_command`` option to point to your command: - - .. code-block:: shell - - echo '[build]' | tee -a /etc/ahriman.ini.d/build.ini - echo 'build_command = ahriman-x86_64-build' | tee -a /etc/ahriman.ini.d/build.ini + echo '[aur-clone]' | tee -a /usr/local/share/devtools-git-poc/pacman.conf.d/aur-clone.conf + echo 'SigLevel = Optional TrustAll' | tee -a /usr/local/share/devtools-git-poc/pacman.conf.d/aur-clone.conf + echo 'Server = file:///var/lib/ahriman/repository/$arch' | tee -a /usr/local/share/devtools-git-poc/pacman.conf.d/aur-clone.conf #. - Configure ``/etc/sudoers.d/ahriman`` to allow running command without a password: + Configure ``/etc/sudoers.d/ahriman`` to allow running devtools command without a password: .. code-block:: shell - echo 'Cmnd_Alias CARCHBUILD_CMD = /usr/local/bin/ahriman-x86_64-build *' | tee -a /etc/sudoers.d/ahriman + echo 'Cmnd_Alias CARCHBUILD_CMD = /usr/bin/pkgctl build *' | tee -a /etc/sudoers.d/ahriman echo 'ahriman ALL=(ALL) NOPASSWD: CARCHBUILD_CMD' | tee -a /etc/sudoers.d/ahriman chmod 400 /etc/sudoers.d/ahriman diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index 44c33b11..83ca2337 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -7,7 +7,7 @@ pkgdesc="ArcH linux ReposItory MANager" arch=('any') url="https://github.com/arcan1s/ahriman" license=('GPL3') -depends=('devtools' 'git' 'pyalpm' 'python-cerberus' 'python-inflection' 'python-passlib' 'python-requests' 'python-srcinfo') +depends=('devtools-git-poc' 'git' 'pyalpm' 'python-cerberus' 'python-inflection' 'python-passlib' 'python-requests' 'python-srcinfo') makedepends=('python-build' 'python-installer' 'python-wheel') optdepends=('breezy: -bzr packages support' 'darcs: -darcs packages support' diff --git a/package/share/ahriman/settings/ahriman.ini b/package/share/ahriman/settings/ahriman.ini index 9008c57d..e127589a 100644 --- a/package/share/ahriman/settings/ahriman.ini +++ b/package/share/ahriman/settings/ahriman.ini @@ -19,11 +19,9 @@ oauth_scopes = https://www.googleapis.com/auth/userinfo.email allow_read_only = yes [build] -archbuild_flags = -build_command = extra-x86_64-build +build_command = pkgctl ignore_packages = -makechrootpkg_flags = -makepkg_flags = --nocolor --ignorearch +pkgctl_flags = triggers = ahriman.core.gitremote.RemotePullTrigger ahriman.core.report.ReportTrigger ahriman.core.upload.UploadTrigger ahriman.core.gitremote.RemotePushTrigger vcs_allowed_age = 604800 diff --git a/src/ahriman/application/ahriman.py b/src/ahriman/application/ahriman.py index 61234551..263f6464 100644 --- a/src/ahriman/application/ahriman.py +++ b/src/ahriman/application/ahriman.py @@ -70,7 +70,8 @@ def _parser() -> argparse.ArgumentParser: fromfile_prefix_chars="@", formatter_class=_formatter) parser.add_argument("-a", "--architecture", help="target architectures. For several subcommands it can be used " "multiple times", action="append") - parser.add_argument("-c", "--configuration", help="configuration path", type=Path, default=Path("/etc/ahriman.ini")) + parser.add_argument("-c", "--configuration", help="configuration path", type=Path, + default=Path("/etc") / "ahriman.ini") parser.add_argument("--force", help="force run, remove file lock", action="store_true") parser.add_argument("-l", "--lock", help="lock file", type=Path, default=Path(tempfile.gettempdir()) / "ahriman.lock") @@ -819,10 +820,9 @@ def _set_service_setup_parser(root: SubParserAction) -> argparse.ArgumentParser: 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("--build-command", help="path to build command", default=Path("/usr") / "bin" / "pkgctl") + parser.add_argument("--from-configuration", help="path to default devtools pacman configuration", type=Path, + default=Path("/usr") / "local" / "share" / "devtools-git-poc" / "pacman.conf.d" / "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") diff --git a/src/ahriman/application/handlers/setup.py b/src/ahriman/application/handlers/setup.py index d3ffe97d..0d2b74f8 100644 --- a/src/ahriman/application/handlers/setup.py +++ b/src/ahriman/application/handlers/setup.py @@ -33,14 +33,12 @@ class Setup(Handler): setup handler Attributes: - ARCHBUILD_COMMAND_PATH(Path): (class attribute) default devtools command MIRRORLIST_PATH(Path): (class attribute) path to pacman default mirrorlist (used by multilib repository) SUDOERS_DIR_PATH(Path): (class attribute) path to sudoers.d includes directory """ ALLOW_AUTO_ARCHITECTURE_RUN = False - ARCHBUILD_COMMAND_PATH = Path("/usr/bin/archbuild") MIRRORLIST_PATH = Path("/etc/pacman.d/mirrorlist") SUDOERS_DIR_PATH = Path("/etc/sudoers.d") @@ -63,30 +61,14 @@ class Setup(Handler): 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, args.mirror, + Setup.configuration_create_devtools(architecture, args.from_configuration, args.mirror, args.multilib, args.repository, application.repository.paths) - Setup.configuration_create_sudo(application.repository.paths, args.build_command, architecture) + Setup.configuration_create_sudo(args.build_command) application.repository.repo.init() # lazy database sync application.repository.pacman.handle # pylint: disable=pointless-statement - @staticmethod - def build_command(root: Path, prefix: str, architecture: str) -> Path: - """ - generate build command name - - Args: - root(Path): root directory for the build command (must be root of the repository) - prefix(str): command prefix in {prefix}-{architecture}-build - architecture(str): repository architecture - - Returns: - Path: valid devtools command name - """ - return root / f"{prefix}-{architecture}-build" - @staticmethod def configuration_create_ahriman(args: argparse.Namespace, architecture: str, repository: str, root: Configuration) -> None: @@ -101,12 +83,10 @@ class Setup(Handler): """ configuration = Configuration() - section = Configuration.section_name("build", 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("build", architecture) + configuration.set_option(section, "build_command", str(args.build_command)) section = Configuration.section_name("alpm", architecture) if args.mirror is not None: @@ -131,7 +111,7 @@ class Setup(Handler): configuration.write(ahriman_configuration) @staticmethod - def configuration_create_devtools(prefix: str, architecture: str, source: Path, mirror: str | None, + def configuration_create_devtools(architecture: str, source: Path, mirror: str | None, multilib: bool, repository: str, paths: RepositoryPaths) -> None: """ create configuration for devtools based on ``source`` configuration @@ -140,7 +120,6 @@ class Setup(Handler): devtools does not allow to specify the pacman configuration, thus we still have to use configuration in /usr Args: - prefix(str): command prefix in {prefix}-{architecture}-build architecture(str): repository architecture source(Path): path to source configuration file mirror(str | None): link to package server mirror @@ -178,7 +157,7 @@ class Setup(Handler): configuration.set_option(repository, "SigLevel", "Optional TrustAll") # we don't care configuration.set_option(repository, "Server", f"file://{paths.repository}") - target = source.parent / f"pacman-{prefix}-{architecture}.conf" + target = source.parent / f"{repository}.conf" with target.open("w") as devtools_configuration: configuration.write(devtools_configuration) @@ -202,31 +181,13 @@ class Setup(Handler): (home_dir / ".makepkg.conf").write_text(content, encoding="utf8") @staticmethod - def configuration_create_sudo(paths: RepositoryPaths, prefix: str, architecture: str) -> None: + def configuration_create_sudo(build_command: Path) -> None: """ create configuration to run build command with sudo without password Args: - paths(RepositoryPaths): repository paths instance - prefix(str): command prefix in {prefix}-{architecture}-build - architecture(str): repository architecture + build_command(Path): path to build command """ - command = Setup.build_command(paths.root, prefix, architecture) - sudoers_file = Setup.build_command(Setup.SUDOERS_DIR_PATH, prefix, architecture) - sudoers_file.write_text(f"ahriman ALL=(ALL) NOPASSWD: {command} *\n", encoding="utf8") + sudoers_file = Setup.SUDOERS_DIR_PATH / f"ahriman-{build_command.name}" + sudoers_file.write_text(f"ahriman ALL=(ALL) NOPASSWD: {build_command} build *\n", encoding="utf8") sudoers_file.chmod(0o400) # security! - - @staticmethod - def executable_create(paths: RepositoryPaths, prefix: str, architecture: str) -> None: - """ - create executable for the service - - Args: - paths(RepositoryPaths): repository paths instance - prefix(str): command prefix in {prefix}-{architecture}-build - architecture(str): repository architecture - """ - command = Setup.build_command(paths.root, prefix, architecture) - command.unlink(missing_ok=True) - command.symlink_to(Setup.ARCHBUILD_COMMAND_PATH) - paths.chown(command) # we would like to keep owner inside ahriman's home diff --git a/src/ahriman/core/build_tools/task.py b/src/ahriman/core/build_tools/task.py index 84255f34..ba3ea770 100644 --- a/src/ahriman/core/build_tools/task.py +++ b/src/ahriman/core/build_tools/task.py @@ -34,6 +34,10 @@ class Task(LazyLogging): base package build task Attributes: + architecture(str): repository architecture + build_command(str): build command + build_flags(list[str]): list of additional flags to pkgctl + name(str): repository name package(Package): package definitions paths(RepositoryPaths): repository paths instance uid(int): uid of the repository owner user @@ -52,12 +56,13 @@ class Task(LazyLogging): """ self.package = package self.paths = paths - self.uid, _ = paths.root_owner - self.archbuild_flags = configuration.getlist("build", "archbuild_flags", fallback=[]) + _, self.architecture = configuration.check_loaded() + self.uid, _ = paths.root_owner + self.name = configuration.get("repository", "name") + self.build_command = configuration.get("build", "build_command") - self.makepkg_flags = configuration.getlist("build", "makepkg_flags", fallback=[]) - self.makechrootpkg_flags = configuration.getlist("build", "makechrootpkg_flags", fallback=[]) + self.build_flags = configuration.getlist("build", "pkgctl_flags", fallback=[]) def build(self, sources_dir: Path) -> list[Path]: """ @@ -69,10 +74,9 @@ class Task(LazyLogging): Returns: list[Path]: paths of produced packages """ - command = [self.build_command, "-r", str(self.paths.chroot)] - command.extend(self.archbuild_flags) - command.extend(["--"] + self.makechrootpkg_flags) - command.extend(["--"] + self.makepkg_flags) + command = [self.build_command, "build"] + self.build_flags + command.extend(["--arch", self.architecture]) + command.extend(["--repo", self.name]) self.logger.info("using %s for %s", command, self.package.base) Task._check_output( diff --git a/src/ahriman/core/configuration/schema.py b/src/ahriman/core/configuration/schema.py index e490d459..c2c2e765 100644 --- a/src/ahriman/core/configuration/schema.py +++ b/src/ahriman/core/configuration/schema.py @@ -134,11 +134,6 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = { "build": { "type": "dict", "schema": { - "archbuild_flags": { - "type": "list", - "coerce": "list", - "schema": {"type": "string"}, - }, "build_command": { "type": "string", "required": True, @@ -148,12 +143,7 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = { "coerce": "list", "schema": {"type": "string"}, }, - "makepkg_flags": { - "type": "list", - "coerce": "list", - "schema": {"type": "string"}, - }, - "makechrootpkg_flags": { + "pkgctl_flags": { "type": "list", "coerce": "list", "schema": {"type": "string"}, diff --git a/tests/ahriman/application/handlers/test_handler_setup.py b/tests/ahriman/application/handlers/test_handler_setup.py index 90024ded..51fc4321 100644 --- a/tests/ahriman/application/handlers/test_handler_setup.py +++ b/tests/ahriman/application/handlers/test_handler_setup.py @@ -23,9 +23,8 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace: Returns: argparse.Namespace: generated arguments for these test cases """ - args.build_as_user = "ahriman" - args.build_command = "ahriman" - args.from_configuration = Path("/usr/share/devtools/pacman-extra.conf") + args.build_command = Path("/usr") / "bin" / "pkgctl" + args.from_configuration = Path("/usr") / "local" / "share" / "devtools-git-poc" / "pacman.conf.d" / "extra.conf" args.makeflags_jobs = True args.mirror = "mirror" args.multilib = True @@ -49,32 +48,17 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository: devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools") makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_makepkg") sudo_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo") - executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create") 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) devtools_configuration_mock.assert_called_once_with( - args.build_command, "x86_64", args.from_configuration, args.mirror, args.multilib, args.repository, - repository_paths) + "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") + sudo_configuration_mock.assert_called_once_with(args.build_command) init_mock.assert_called_once_with() -def test_build_command(args: argparse.Namespace) -> None: - """ - must generate correct build command name - """ - args = _default_args(args) - path = Path("local") - - build_command = Setup.build_command(path, args.build_command, "x86_64") - assert build_command.name == f"{args.build_command}-x86_64-build" - assert build_command.parent == path - - def test_configuration_create_ahriman(args: argparse.Namespace, configuration: Configuration, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None: """ @@ -84,13 +68,11 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C mocker.patch("pathlib.Path.open") set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option") 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) 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("build", "x86_64"), "build_command", str(args.build_command)), 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])), @@ -129,8 +111,8 @@ def test_configuration_create_devtools(args: argparse.Namespace, repository_path add_section_mock = mocker.patch("ahriman.core.configuration.Configuration.add_section") write_mock = mocker.patch("ahriman.core.configuration.Configuration.write") - Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration, - None, args.multilib, args.repository, repository_paths) + Setup.configuration_create_devtools("x86_64", args.from_configuration, 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)) @@ -154,8 +136,8 @@ def test_configuration_create_devtools_mirror(args: argparse.Namespace, reposito 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) + Setup.configuration_create_devtools("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 @@ -171,8 +153,8 @@ def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, rep mocker.patch("ahriman.core.configuration.Configuration.set") write_mock = mocker.patch("ahriman.core.configuration.Configuration.write") - Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration, - None, False, args.repository, repository_paths) + Setup.configuration_create_devtools("x86_64", args.from_configuration, None, + False, args.repository, repository_paths) write_mock.assert_called_once_with(pytest.helpers.anyvar(int)) @@ -199,26 +181,11 @@ def test_configuration_create_sudo(args: argparse.Namespace, repository_paths: R chmod_text_mock = mocker.patch("pathlib.Path.chmod") write_text_mock = mocker.patch("pathlib.Path.write_text") - Setup.configuration_create_sudo(repository_paths, args.build_command, "x86_64") + Setup.configuration_create_sudo(args.build_command) chmod_text_mock.assert_called_once_with(0o400) write_text_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), encoding="utf8") -def test_executable_create(args: argparse.Namespace, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None: - """ - must create executable - """ - args = _default_args(args) - chown_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.chown") - symlink_mock = mocker.patch("pathlib.Path.symlink_to") - unlink_mock = mocker.patch("pathlib.Path.unlink") - - Setup.executable_create(repository_paths, args.build_command, "x86_64") - chown_mock.assert_called_once_with(Setup.build_command(repository_paths.root, args.build_command, "x86_64")) - symlink_mock.assert_called_once_with(Setup.ARCHBUILD_COMMAND_PATH) - unlink_mock.assert_called_once_with(missing_ok=True) - - def test_disallow_auto_architecture_run() -> None: """ must not allow multi architecture run diff --git a/tests/testresources/core/ahriman.ini b/tests/testresources/core/ahriman.ini index bc7b5a85..18d0b889 100644 --- a/tests/testresources/core/ahriman.ini +++ b/tests/testresources/core/ahriman.ini @@ -19,11 +19,8 @@ salt = salt allow_read_only = no [build] -archbuild_flags = -build_command = extra-x86_64-build +build_command = pkgctl ignore_packages = -makechrootpkg_flags = -makepkg_flags = --skippgpcheck triggers = ahriman.core.report.ReportTrigger ahriman.core.upload.UploadTrigger [repository]