pmb.build.is_necessary: replace version_{new,old} (MR 2295)

Give more meaningful names to the variables:
* version_new -> version_pmaports
* version_old -> version_binary

This makes the code less confusing for the case where version_binary is
actually newer than version_pmaports. This is a relict from the time
before there was a binary package repository, in that case the version
from pmaports would always be the newer one, built from source, compared
to the local binary package that was probably built before.
This commit is contained in:
Oliver Smith 2024-04-12 01:34:18 +02:00
parent 105b5ec0bf
commit d55bc245d1
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -54,7 +54,7 @@ def is_necessary(args, arch, apkbuild, indexes=None):
"""
# Get package name, version, define start of debug message
package = apkbuild["pkgname"]
version_new = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
version_pmaports = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
msg = "Build is necessary for package '" + package + "': "
# Get old version from APKINDEX
@ -72,20 +72,20 @@ def is_necessary(args, arch, apkbuild, indexes=None):
return False
# a) Binary repo has a newer version
version_old = index_data["version"]
if pmb.parse.version.compare(version_old, version_new) == 1:
version_binary = index_data["version"]
if pmb.parse.version.compare(version_binary, version_pmaports) == 1:
logging.warning("WARNING: package {}: aport version {} is lower than"
" {} from the binary repository. {} will be used when"
" installing {}. See also:"
" <https://postmarketos.org/warning-repo2>"
"".format(package, version_new, version_old,
version_old, package))
"".format(package, version_pmaports, version_binary,
version_binary, package))
return False
# b) Aports folder has a newer version
if version_new != version_old:
if version_pmaports != version_binary:
logging.debug(f"{msg}Binary package out of date (binary: "
f"{version_old}, aport: {version_new})")
f"{version_binary}, aport: {version_pmaports})")
return True
# Aports and binary repo have the same version.