mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
refactor: add ability to pass anything as environment variable to build task
This commit is contained in:
parent
ad901067d8
commit
4b6feb9ae6
@ -68,13 +68,13 @@ class Task(LazyLogging):
|
|||||||
self.makepkg_flags = configuration.getlist("build", "makepkg_flags", fallback=[])
|
self.makepkg_flags = configuration.getlist("build", "makepkg_flags", fallback=[])
|
||||||
self.makechrootpkg_flags = configuration.getlist("build", "makechrootpkg_flags", fallback=[])
|
self.makechrootpkg_flags = configuration.getlist("build", "makechrootpkg_flags", fallback=[])
|
||||||
|
|
||||||
def build(self, sources_dir: Path, packager: str | None = None) -> list[Path]:
|
def build(self, sources_dir: Path, **kwargs: str | None) -> list[Path]:
|
||||||
"""
|
"""
|
||||||
run package build
|
run package build
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sources_dir(Path): path to where sources are
|
sources_dir(Path): path to where sources are
|
||||||
packager(str | None, optional): optional packager override (Default value = None)
|
**kwargs(str | None): environment variables to be passed to build processes
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[Path]: paths of produced packages
|
list[Path]: paths of produced packages
|
||||||
@ -85,9 +85,11 @@ class Task(LazyLogging):
|
|||||||
command.extend(["--"] + self.makepkg_flags)
|
command.extend(["--"] + self.makepkg_flags)
|
||||||
self.logger.info("using %s for %s", command, self.package.base)
|
self.logger.info("using %s for %s", command, self.package.base)
|
||||||
|
|
||||||
environment: dict[str, str] = {}
|
environment: dict[str, str] = {
|
||||||
if packager is not None:
|
key: value
|
||||||
environment["PACKAGER"] = packager
|
for key, value in kwargs.items()
|
||||||
|
if value is not None
|
||||||
|
}
|
||||||
self.logger.info("using environment variables %s", environment)
|
self.logger.info("using environment variables %s", environment)
|
||||||
|
|
||||||
Task._check_output(
|
Task._check_output(
|
||||||
|
@ -83,7 +83,7 @@ class Executor(Cleaner):
|
|||||||
task = Task(package, self.configuration, self.architecture, self.paths)
|
task = Task(package, self.configuration, self.architecture, self.paths)
|
||||||
local_version = local_versions.get(package.base) if bump_pkgrel else None
|
local_version = local_versions.get(package.base) if bump_pkgrel else None
|
||||||
task.init(local_path, self.database, local_version)
|
task.init(local_path, self.database, local_version)
|
||||||
built = task.build(local_path, packager_id)
|
built = task.build(local_path, PACKAGER=packager_id)
|
||||||
for src in built:
|
for src in built:
|
||||||
dst = self.paths.packages / src.name
|
dst = self.paths.packages / src.name
|
||||||
shutil.move(src, dst)
|
shutil.move(src, dst)
|
||||||
|
@ -10,7 +10,7 @@ def test_build(task_ahriman: Task, mocker: MockerFixture) -> None:
|
|||||||
must build package
|
must build package
|
||||||
"""
|
"""
|
||||||
check_output_mock = mocker.patch("ahriman.core.build_tools.task.Task._check_output")
|
check_output_mock = mocker.patch("ahriman.core.build_tools.task.Task._check_output")
|
||||||
task_ahriman.build(Path("ahriman"), "packager")
|
task_ahriman.build(Path("ahriman"))
|
||||||
check_output_mock.assert_called()
|
check_output_mock.assert_called()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user