mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
fix: force dry run build on task initialization for VCS packages
Previously if package is VCS and version in PKGBUILD doesn't match to AUR one, then makepkg will update pkgbuild ignoring all previous pkgrel patches With this change during task init dry ryn process is always run for vcs packages
This commit is contained in:
parent
22ac5e8b43
commit
c6cb4a4abd
@ -149,8 +149,11 @@ class Task(LazyLogging):
|
||||
str | None: current commit sha if available
|
||||
"""
|
||||
last_commit_sha = Sources.load(sources_dir, self.package, patches, self.paths)
|
||||
if local_version is None:
|
||||
return last_commit_sha # there is no local package or pkgrel increment is disabled
|
||||
if self.package.is_vcs: # if package is VCS, then make sure to update PKGBUILD to the latest version
|
||||
self.build(sources_dir, dry_run=True)
|
||||
|
||||
if local_version is None: # there is no local package or pkgrel increment is disabled
|
||||
return last_commit_sha
|
||||
|
||||
# load fresh package
|
||||
loaded_package = Package.from_build(sources_dir, self.architecture, None)
|
||||
|
@ -432,8 +432,6 @@ class Package(LazyLogging):
|
||||
with self.suppress_logging():
|
||||
# create fresh chroot environment, fetch sources and - automagically - update PKGBUILD
|
||||
task.init(paths.cache_for(self.base), [], None)
|
||||
task.build(paths.cache_for(self.base), dry_run=True)
|
||||
|
||||
pkgbuild = Pkgbuild.from_file(paths.cache_for(self.base) / "PKGBUILD")
|
||||
|
||||
return full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
|
||||
|
@ -117,6 +117,21 @@ def test_init(task_ahriman: Task, mocker: MockerFixture) -> None:
|
||||
load_mock.assert_called_once_with(Path("ahriman"), task_ahriman.package, patches, task_ahriman.paths)
|
||||
|
||||
|
||||
def test_init_vcs(task_ahriman: Task, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must copy tree instead of fetch
|
||||
"""
|
||||
task_ahriman.package.base += "-git"
|
||||
mocker.patch("ahriman.models.package.Package.from_build", return_value=task_ahriman.package)
|
||||
load_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.load", return_value="sha")
|
||||
build_mock = mocker.patch("ahriman.core.build_tools.task.Task.build")
|
||||
|
||||
local = Path("ahriman")
|
||||
assert task_ahriman.init(local, [], None) == "sha"
|
||||
load_mock.assert_called_once_with(local, task_ahriman.package, [], task_ahriman.paths)
|
||||
build_mock.assert_called_once_with(local, dry_run=True)
|
||||
|
||||
|
||||
def test_init_bump_pkgrel(task_ahriman: Task, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must bump pkgrel if it is same as provided
|
||||
|
@ -359,13 +359,10 @@ def test_actual_version_vcs(package_tpacpi_bat_git: Package, configuration: Conf
|
||||
mocker.patch("ahriman.models.pkgbuild.Pkgbuild.from_file", return_value=Pkgbuild.from_file(pkgbuild))
|
||||
mocker.patch("pathlib.Path.glob", return_value=[Path("local")])
|
||||
init_mock = mocker.patch("ahriman.core.build_tools.task.Task.init")
|
||||
build_mock = mocker.patch("ahriman.core.build_tools.task.Task.build")
|
||||
unlink_mock = mocker.patch("pathlib.Path.unlink")
|
||||
|
||||
assert package_tpacpi_bat_git.actual_version(configuration) == "3.1.r13.g4959b52-1"
|
||||
init_mock.assert_called_once_with(configuration.repository_paths.cache_for(package_tpacpi_bat_git.base), [], None)
|
||||
build_mock.assert_called_once_with(configuration.repository_paths.cache_for(package_tpacpi_bat_git.base),
|
||||
dry_run=True)
|
||||
unlink_mock.assert_called_once_with()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user