Browse Source

Множественные изменения calculate-update.

Изменен порядок выполнения шаблонов, добавлено выполнение шаблонов при
смене профиля, добавлена перенастройка пакетов.
master3.3
Mike Khiretskiy 7 years ago
parent
commit
40e42184ad
  1. 2
      data/cl-git-wrapper
  2. 49
      update/update.py
  3. 9
      update/utils/cl_update.py
  4. 16
      update/utils/cl_update_profile.py
  5. 79
      update/variables/update.py
  6. 23
      update/wsdl_update.py

2
data/cl-git-wrapper

@ -22,7 +22,7 @@ native_reps=,$(/usr/sbin/cl-core --method core_variables_show \
if echo $native_reps | grep -q ,${repo_name},
then
# отбновить репозиторий через утилиты Calculate
/usr/sbin/cl-core --method update --rep $repo_name --sync-only on --skip-update-metadata --skip-eix-update --update-rev=off
/usr/sbin/cl-core --method update --rep $repo_name --sync-only on --skip-update-metadata --skip-eix-update -T none
else
# выполнить обновление через git
/usr/bin/git $*

49
update/update.py

@ -28,6 +28,7 @@ from calculate.lib.utils.tools import AddonError
from calculate.lib.utils.colortext.palette import TextState
from calculate.lib.utils.colortext import get_color_print
from calculate.update.emerge_parser import RevdepPercentBlock
from calculate.update.datavars import DataVarsUpdate
import re
from collections import MutableSet
@ -621,7 +622,7 @@ class Update:
"""
# подробный список пакетов
_print = self.color_print
if self.clVars.Get('cl_verbose_set') == 'on':
if self.clVars.Get('cl_update_emergelist_set') == 'on':
self.printPre(str(emerge.install_packages))
else:
pkglist = emerge.install_packages.list
@ -648,7 +649,7 @@ class Update:
Отобразить список удаляемых пакетов
"""
# подробный список пакетов
if self.clVars.Get('cl_verbose_set') == 'on':
if self.clVars.Get('cl_update_emergelist_set') == 'on':
self.printPre(self._emerge_translate(
emerge.uninstall_packages.verbose_result))
else:
@ -922,3 +923,47 @@ class Update:
except (OSError,IOError) as e:
raise UpdateError(_("Failed to set the profile: %s")%str(e))
return True
def applyProfileTemplates(self,useClt=None,cltFilter=False,useDispatch=True):
"""
Наложить шаблоны из профиля
"""
from calculate.lib.cl_template import (Template,TemplatesError,
ProgressTemplate)
dv = DataVarsUpdate()
try:
dv.importUpdate()
dv.flIniFile()
dv.Set('cl_action','merge',force=True)
dv.Set('cl_templates_locate', self.clVars.Get('cl_update_templates_locate'))
dv.Set("cl_chroot_path",'/', True)
dv.Set("cl_root_path",'/', True)
for copyvar in ("cl_dispatch_conf", "cl_verbose_set"):
dv.Set(copyvar,self.clVars.Get(copyvar),True)
# определение каталогов содержащих шаблоны
dirs_list, files_list = ([],[])
useClt = useClt in ("on",True)
self.addProgress()
nullProgress = lambda *args,**kw:None
dispatch = self.dispatchConf if useDispatch else None
clTempl = ProgressTemplate(nullProgress,dv,
cltObj=useClt,
cltFilter=cltFilter,
printSUCCESS=self.printSUCCESS,
printWARNING=self.printWARNING,
askConfirm=self.askConfirm,
dispatchConf=dispatch,
printERROR=self.printERROR)
try:
dirsFiles = clTempl.applyTemplates()
if clTempl.hasError():
if clTempl.getError():
raise TemplatesError(clTempl.getError())
finally:
if clTempl:
if clTempl.cltObj:
clTempl.cltObj.closeFiles()
clTempl.closeFiles()
finally:
dv.close()
return True

9
update/utils/cl_update.py

@ -186,8 +186,7 @@ class ClUpdateAction(Action):
{'name': 'update_other:dispatch_conf_end',
'message': __("Updating configuration files"),
'method':'Update.dispatchConf()',
'condition': lambda Get: ((Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on') and
'condition': lambda Get: (Get('cl_dispatch_conf') != 'skip' and
Get('cl_update_pretend_set') == 'off')
},
]
@ -269,14 +268,12 @@ class ClUpdateAction(Action):
'message': __("Fixing the settings"),
'method': 'Update.applyTemplates(install.cl_source,'
'cl_template_clt_set,True,None,False)',
'condition': lambda Get: (Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on')
'condition': lambda Get: Get('cl_templates_locate')
},
{'name': 'dispatch_conf',
'message': __("Updating configuration files"),
'method':'Update.dispatchConf()',
'condition': lambda Get: ((Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on') and
'condition': lambda Get: (Get('cl_dispatch_conf') != 'skip' and
Get('cl_update_pretend_set') == 'off')
},
]

16
update/utils/cl_update_profile.py

@ -103,6 +103,22 @@ class ClUpdateProfileAction(Action):
'message': __("Switching to profile {cl_update_profile_system}"),
'method': 'Update.setProfile()'
},
{'name': 'revision',
'message': __("Fixing the settings"),
'method': 'Update.applyTemplates(install.cl_source,'
'cl_template_clt_set,True,None,False)',
'condition': lambda Get: Get('cl_templates_locate')
},
{'name': 'reconfigure',
'message': __("The system is being configured"),
'method': 'Update.applyProfileTemplates(cl_template_clt_set,True,False)',
'condition': lambda Get: Get('cl_update_templates_locate')
},
{'name': 'dispatch_conf',
'message': __("Updating configuration files"),
'method':'Update.dispatchConf()',
'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
},
]
}
]

79
update/variables/update.py

@ -32,6 +32,7 @@ from calculate.update.profile import RepositoryStorageSet, DEFAULT_BRANCH
from calculate.lib.variables.linux import VariableOsLinuxName, \
VariableOsLinuxSubname, VariableOsLinuxVer, VariableOsLinuxShortname
from calculate.lib.variables.env import VariableClTemplateLocation
setLocalTranslate('cl_update3', sys.modules[__name__])
@ -49,11 +50,23 @@ class VariableAcUpdateSync(ReadonlyVariable):
return ""
class VariableClUpdateWorld(Variable):
def get(self):
if self.Get('cl_rebuild_world_set') == "on":
return "rebuild"
else:
return ""
type = "choice"
value = "update"
opt = ["--world"]
syntax = "--{choice}-world"
metavalue = "MODE"
def init(self):
self.help = ("'rebuild' - " + _("rebuild package list") +
",\n'merge' - " + _("append profile package list") +
",\n'update' - " + _("update package list"))
self.label = _("Package list")
def choice(self):
return [("rebuild", _("Rebuild")),
("merge", _("Merge")),
("update", _("Update"))]
class VariableClRebuildWorldSet(Variable):
"""
@ -527,6 +540,40 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
setValue = Variable.setValue
class VariableClUpdateTemplatesLocate(Variable):
"""
Выбранные типы хранилищ шаблонов
"""
type = "choice-list"
element = "selecttable"
opt = ["-T","--templates"]
metavalue = "TEMPLATES"
untrusted = True
check_after = ['cl_update_profile_system']
descriptionMap = {'overlay': _('Overlay templates'),
'local': _('Local templates'),
'calculate': _("Calculate overlay templates"),
'distros': _('Distribution templates'),
'distro': _('Distribution templates'),
'remote': _('Remote templates'),
'clt': _('clt templates')}
def init(self):
self.label = _("Templates location")
self.help = _("select location for templates %s") \
%",".join(self.get())
def get(self):
dv = self.Get('update.cl_update_profile_datavars')
if dv:
return self.Get('cl_templates_locate')
return dv.Get('cl_template_location') + ['clt']
def choice(self):
return map(lambda x:(x,self.descriptionMap.get(x,_("%s overlay templates")%x)),
self.get())
class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
type = "list"
source_variable = "cl_update_profile_depend_data"
@ -596,7 +643,7 @@ class VariableClUpdateProfileRep(Variable):
Текущий репозиторий
"""
untrusted = True
check_after = "cl_update_profile_branch"
check_after = ["cl_update_profile_branch"]
opt = ["--url"]
@ -871,6 +918,7 @@ class DataVarsUpdateProfile(SimpleDataVars):
VariableOsLinuxShortname(),
VariableOsLinuxSubname(),
VariableOsLinuxVer(),
VariableClTemplateLocation(),
VariableClUpdateRepData(section="update"),
VariableClUpdateRepPath(section="update"),
VariableClUpdateRepRev(section="update"),
@ -888,15 +936,15 @@ class DataVarsUpdateProfile(SimpleDataVars):
class VariableClUpdateProfileSyncSet(Variable):
"""
Не выполнять установку/обновление пакетов при обновлении
Синхронизировать репозиторий перед сменой профиля
"""
type = "bool"
value = "off"
opt = ["-s", "--sync"]
def init(self):
self.label = _("Repositories to be synchronized")
self.help = _("repositories to be synchronized")
self.label = _("Synchronize the repository")
self.help = _("Synchronize the repository")
class VariableClUpdateAutocheckSet(Variable):
@ -943,6 +991,18 @@ class VariableClUpdateAutocheckScheduleSet(Variable):
self.label = _("Consider the autocheck schedule")
self.help = _("consider the autocheck schedule")
class VariableClUpdateEmergelistSet(Variable):
"""
Вывести список пакетов в формате emerge
"""
type = "bool"
value = "off"
opt = ["-e","--emergelist"]
def init(self):
self.label = _("Emerge like package list")
self.help = _("display package list in emerge format")
class VariableClUpdateKernelVersion(ReadonlyVariable):
"""
Текущая версия ядра
@ -972,3 +1032,4 @@ class VariableClUpdateKernelPkg(ReadonlyVariable):
else:
return ""

23
update/wsdl_update.py

@ -65,13 +65,15 @@ class Wsdl(WsdlBase):
lambda group: group(_("Update the system"),
normal=(),
expert=(
'cl_rebuild_world_set', 'cl_update_rev_set',
'cl_update_sync_rep', 'cl_update_branch',
'cl_update_egencache_force',
'cl_update_sync_only_set',
'cl_update_other_set',
'cl_update_pretend_set',
'cl_update_sync_rep',
'cl_update_emergelist_set',
'cl_update_world',
'cl_update_branch',
'cl_update_egencache_force',
'cl_update_eixupdate_force',
'cl_update_sync_only_set',
'cl_update_wait_another_set',
'cl_update_autocheck_schedule_set',
'cl_templates_locate',
@ -112,10 +114,17 @@ class Wsdl(WsdlBase):
hide=('cl_update_profile_rep',
'cl_update_profile_sync_set'),
normal=('cl_update_profile_rep',),
expert=('cl_update_profile_branch',
'cl_update_profile_sync_set')),
expert=('cl_update_profile_sync_set',
'cl_update_profile_branch')),
lambda group: group(_("Profile"),
normal=('cl_update_profile_system',),
normal=('cl_update_profile_system',
'cl_update_world'),
expert=('cl_update_templates_locate',
'cl_verbose_set',
'cl_dispatch_conf'),
hide=('cl_update_templates_locate',
'cl_verbose_set',
'cl_dispatch_conf'),
brief=('cl_update_profile_system',
'cl_update_profile_linux_fullname',
'cl_update_profile_depend_data')

Loading…
Cancel
Save