cl-update: Feature: добавлено сохранение хэша для пакета world. При
несовпадении с предыдущим значением - запускаестя удаление устаревших
пакетов
master 3.7.2.63
root 1 year ago
parent 017fc09c31
commit ac4cf20de9

@ -2040,6 +2040,21 @@ class Update(MethodsInterface):
ini.delVar('system', 'portage_hash')
return True
def save_world_state_hash(self):
ini = SystemIni(self.clVars)
ps = PortageState()
ps.paths = ['/var/lib/portage/world']
new_world_state_hash = ps.get_state()
ini.setVar('system', {'world_hash': new_world_state_hash})
def drop_world_state_hash(self):
"""
Сбросить состояние
"""
ini = SystemIni(self.clVars)
ini.delVar('system', 'world_hash')
return True
def drop_packages_cache(self):
packages_fn = self.clVars.Get('update.cl_update_package_cache')
packages_sign_fn = self.clVars.Get('update.cl_update_package_cache_sign')

@ -272,7 +272,8 @@ class UpdateConditions():
task = EmergeLog(EmergeLogNamedTask(task_name))
return (bool(PackageList(task.list)[pkg])
or Get('cl_update_force_depclean_set') == 'on'
or Get('cl_update_outdated_kernel_set') == 'on')
or Get('cl_update_outdated_kernel_set') == 'on'
or Get('cl_update_world_hash_set') == 'on')
return func
@staticmethod
@ -501,6 +502,9 @@ class ClUpdateAction(Action):
'method': 'Update.drop_portage_state_hash()',
'depend': Tasks.failed()
},
{'name': 'drop_world_hash',
'method': 'Update.drop_world_state_hash()',
'depend': Tasks.failed()},
{'name': 'update:set_current_level',
'method': 'Update.update_increment_current_level()',
'depend': (Tasks.success() & Tasks.hasnot("interrupt") &
@ -521,6 +525,10 @@ class ClUpdateAction(Action):
'method': 'Update.save_portage_state_hash()',
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off'
},
{'name': 'update:save_world_hash',
'method': 'Update.save_world_state_hash()',
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off'
},
{'name': 'clear_migration_host',
'method': 'Update.delete_binhost()',
'depend': (Tasks.hasnot("check_schedule")),

@ -2091,3 +2091,22 @@ class VariableClUpdateSavedTag(Variable):
class VariableClUpdateSaveCurBinhost(Variable):
value = " "
class VariableClUpdateWorldHashSet(Variable):
"""
Хэш world для проверки изменений
"""
type = Variable.Types.Boolean
value = ""
def get(self):
if self.value:
return self.value
ini = SystemIni(self.parent)
old_world_state_hash = ini.getVar('system', 'world_hash') or ""
#меняем путь сборки хэша на world файл
ps = PortageState()
ps.paths = ['/var/lib/portage/world']
new_world_state_hash = ps.get_state()
return "on" if new_world_state_hash != old_world_state_hash else "off"

@ -18,7 +18,7 @@
# limitations under the License.
__app__ = "calculate-update"
__version__ = "3.2.2" #TODO bump version
__version__ = "3.7.3" #TODO bump version
import os
from glob import glob

Loading…
Cancel
Save