mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-07-22 18:31:14 +00:00
feat: add cooldown for aur packages
This commit is contained in:
@@ -42,6 +42,8 @@ retry_backoff = 1.0
|
||||
;include_debug_packages = yes
|
||||
; List of additional flags passed to makechrootpkg command.
|
||||
;makechrootpkg_flags =
|
||||
; Minimal age in seconds since the latest AUR package modification before automatic updates are allowed.
|
||||
;min_age = 0
|
||||
; List of additional flags passed to makepkg command.
|
||||
makepkg_flags = --nocolor --ignorearch
|
||||
; List of paths to be used for implicit dependency scan. Regular expressions are supported.
|
||||
|
||||
@@ -22,6 +22,7 @@ from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.log import LazyLogging
|
||||
from ahriman.core.utils import full_version, utcnow
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.pkgbuild import Pkgbuild
|
||||
|
||||
|
||||
@@ -64,7 +65,7 @@ class PackageVersion(LazyLogging):
|
||||
|
||||
return full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
|
||||
except Exception:
|
||||
self.logger.exception("cannot determine version of VCS package")
|
||||
self.logger.exception("cannot determine version of VCS package %s", self.package.base)
|
||||
finally:
|
||||
# clear log files generated by devtools
|
||||
for log_file in paths.cache_for(self.package.base).glob("*.log"):
|
||||
@@ -103,9 +104,14 @@ class PackageVersion(LazyLogging):
|
||||
Returns:
|
||||
bool: ``True`` if the package is out-of-dated and ``False`` otherwise
|
||||
"""
|
||||
min_allowed_age = configuration.getint("build", "min_age", fallback=0)
|
||||
min_build_date = utcnow().timestamp() - min_allowed_age
|
||||
if remote.remote.source == PackageSource.AUR and PackageVersion(remote).is_newer_than(min_build_date):
|
||||
self.logger.info("package %s was modified too recently, skip update", remote.base)
|
||||
return False
|
||||
|
||||
vcs_allowed_age = configuration.getint("build", "vcs_allowed_age", fallback=0)
|
||||
min_vcs_build_date = utcnow().timestamp() - vcs_allowed_age
|
||||
|
||||
if calculate_version and not self.is_newer_than(min_vcs_build_date):
|
||||
remote_version = PackageVersion(remote).actual_version(configuration)
|
||||
else:
|
||||
|
||||
@@ -206,7 +206,7 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
|
||||
"type": "boolean",
|
||||
"coerce": "boolean",
|
||||
},
|
||||
"makepkg_flags": {
|
||||
"makechrootpkg_flags": {
|
||||
"type": "list",
|
||||
"coerce": "list",
|
||||
"schema": {
|
||||
@@ -214,7 +214,12 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
|
||||
"empty": False,
|
||||
},
|
||||
},
|
||||
"makechrootpkg_flags": {
|
||||
"min_age": {
|
||||
"type": "integer",
|
||||
"coerce": "integer",
|
||||
"min": 0,
|
||||
},
|
||||
"makepkg_flags": {
|
||||
"type": "list",
|
||||
"coerce": "list",
|
||||
"schema": {
|
||||
|
||||
@@ -113,6 +113,7 @@ class PackageDescription:
|
||||
Self: package properties based on source AUR package
|
||||
"""
|
||||
return cls(
|
||||
build_date=int(package.last_modified.timestamp()),
|
||||
depends=package.depends,
|
||||
make_depends=package.make_depends,
|
||||
opt_depends=package.opt_depends,
|
||||
|
||||
@@ -90,6 +90,19 @@ def test_is_outdated_true(package_ahriman: Package, configuration: Configuration
|
||||
actual_version_mock.assert_called_once_with(configuration)
|
||||
|
||||
|
||||
def test_is_outdated_aur_cooldown(package_ahriman: Package, configuration: Configuration) -> None:
|
||||
"""
|
||||
must be not outdated if AUR package is modified too recently
|
||||
"""
|
||||
other = Package.from_json(package_ahriman.view())
|
||||
other.version = other.version.replace("-1", "-2")
|
||||
for description in other.packages.values():
|
||||
description.build_date = int(utcnow().timestamp())
|
||||
configuration.set_option("build", "min_age", "3600")
|
||||
|
||||
assert not PackageVersion(package_ahriman).is_outdated(other, configuration)
|
||||
|
||||
|
||||
def test_is_outdated_no_version_calculation(package_ahriman: Package, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user