diff --git a/pym/update/utils/cl_update.py b/pym/update/utils/cl_update.py index a51d7df..077978c 100644 --- a/pym/update/utils/cl_update.py +++ b/pym/update/utils/cl_update.py @@ -280,7 +280,7 @@ class ClUpdateAction(Action): "eix_update")), } ] - }, + }, {'name': 'reps_synchronization', 'group': __("System configuration"), 'tasks': [ @@ -292,7 +292,7 @@ class ClUpdateAction(Action): (Get('cl_update_outdate_set') == 'on' or Get('cl_update_force_fix_set') == 'on')) - }, + }, {'name': 'dispatch_conf', 'message': __("Updating configuration files"), 'method': 'Update.dispatchConf()', @@ -300,12 +300,12 @@ class ClUpdateAction(Action): Get('cl_update_pretend_set') == 'off' and (Get('cl_update_outdate_set') == 'on' or Get('cl_update_force_fix_set') == 'on')) - }, + }, {'name': 'binhost_changed', 'method': 'Update.message_binhost_changed()' - }, + }, ] - } + } ] + emerge_tasks + [ {'name': 'failed', 'error': __("Update failed"), diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 8b060ce..31b1cbe 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -25,7 +25,7 @@ from calculate.lib.datavars import (Variable, VariableError, TableVariable, FieldValue, HumanReadable, CriticalError, SimpleDataVars, DataVarsError) -from calculate.lib.utils.binhosts import Binhosts +from calculate.lib.utils.binhosts import Binhosts, PackagesIndex, HOURS from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin from calculate.lib.configparser import ConfigParser @@ -1706,9 +1706,22 @@ class VariableClUpdatePackageCache(ReadonlyVariable): host, parsed_url.path.lstrip("/"), "Packages") + class VariableClUpdatePackageCacheSet(Variable): """ Необходимость обновить Packages """ type = "bool" - value = "off" + + def get(self): + packages_fn = self.Get('cl_update_package_cache') + if not path.exists(packages_fn): + return "on" + pi = PackagesIndex(readFile(packages_fn)) + try: + ttl = int(pi.get("TTL", "0")) + if ttl > HOURS: + return "off" + except ValueError: + return "on" + return "on"