parent
22703407d2
commit
08bbdc6142
@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Calculate Ltd. http://www.calculate-linux.org
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import re
|
||||
import sys
|
||||
from calculate.update.emerge_parser import EmergeInformationBlock
|
||||
from calculate.lib.utils.portage import EmergePackage
|
||||
|
||||
|
||||
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, _)
|
||||
setLocalTranslate('cl_builder3', sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
class EmergePackageFetch(EmergePackage):
|
||||
files = []
|
||||
|
||||
class EmergeFetcherError(Exception):
|
||||
pass
|
||||
|
||||
class EmergeFetcher(object):
|
||||
_color_block = EmergeInformationBlock._color_block
|
||||
_new_line = EmergeInformationBlock._new_line
|
||||
re_fetching = re.compile(
|
||||
">>> Fetching \({c}\d+{c} of {c}\d+{c}\) {c}(.*?){c}{nl}(.*?)"
|
||||
"(?=>>> Fetching|$)".format(c=_color_block, nl=_new_line), re.S)
|
||||
|
||||
re_filename = re.compile("^{c} [*] {c}(\S+).*;-\)".format(c=_color_block),
|
||||
re.M)
|
||||
|
||||
def __init__(self, emerge_command):
|
||||
"""
|
||||
:param package_list: список пакетов типа (EmergeUpdateInfo)
|
||||
:return:
|
||||
"""
|
||||
self.emerge_command = emerge_command
|
||||
|
||||
def parse(self, data):
|
||||
if "is already locked by another fetcher" in data:
|
||||
raise EmergeFetcherError(
|
||||
_("File is already locked by another fetcher."))
|
||||
for package, block in self.re_fetching.findall(data):
|
||||
ep = EmergePackageFetch(package)
|
||||
ep.files = [x for x in self.re_filename.findall(block)]
|
||||
yield ep
|
||||
|
||||
def __iter__(self):
|
||||
child = self.emerge_command.execute()
|
||||
for i in self.parse(child.read()):
|
||||
yield i
|
@ -0,0 +1,146 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Calculate Ltd. http://www.calculate-linux.org
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
from calculate.core.server.func import Action, Tasks
|
||||
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
||||
from calculate.lib.utils.files import FilesError, isMount
|
||||
from calculate.update.update import UpdateError
|
||||
from ..datavars import BuilderError
|
||||
from calculate.lib.utils.portage import GitError, isPkgInstalled
|
||||
from calculate.install.distr import DistributiveError
|
||||
|
||||
setLocalTranslate('cl_builder3', sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
|
||||
class ClBuilderProfileAction(Action):
|
||||
"""
|
||||
Действие обновление конфигурационных файлов
|
||||
"""
|
||||
# ошибки, которые отображаются без подробностей
|
||||
native_error = (DistributiveError, FilesError, UpdateError,
|
||||
BuilderError, GitError)
|
||||
|
||||
successMessage = __("The profile was successfully updated")
|
||||
failedMessage = __("Failed to update the profile")
|
||||
interruptMessage = __("Profile update manually interrupted")
|
||||
|
||||
# список задач для действия
|
||||
tasks = [
|
||||
{'name': 'migrate_repository',
|
||||
'method': 'Builder.migrateCacheRepository('
|
||||
'cl_builder_profile_url,cl_builder_profile_branch,'
|
||||
'cl_builder_profile_storage)',
|
||||
'message': __("Repository transfer"),
|
||||
'condition': lambda Get: not (
|
||||
Get('cl_builder_profile_storage').is_local(
|
||||
Get('cl_builder_profile_url'),
|
||||
Get('cl_builder_profile_branch')))
|
||||
},
|
||||
{'name': 'reconfigure_vars1',
|
||||
'method': 'Builder.invalidateVariables("cl_builder_profile_storage")',
|
||||
'depend': Tasks.has('migrate_repository')
|
||||
},
|
||||
{'name': 'reconfigure_vars',
|
||||
'method': 'Builder.reconfigureProfileVars(cl_builder_profile_datavars,'
|
||||
'cl_builder_path)'
|
||||
},
|
||||
{'name': 'remove_old_reps',
|
||||
'foreach': 'cl_builder_remove_rep',
|
||||
'message': __("Remove the {eachvar:capitalize} repository"),
|
||||
'method': 'Builder.remove_repositories(eachvar)'
|
||||
},
|
||||
{'name': 'reps_synchronization',
|
||||
'group': __("Repositories synchronization"),
|
||||
'tasks': [
|
||||
{'name': 'sync_reps',
|
||||
'foreach': 'cl_builder_profile_sync_rep',
|
||||
'message': __("Syncing the {eachvar:capitalize} repository"),
|
||||
'method': 'Builder.syncRepositories(eachvar)',
|
||||
#'condition': lambda Get: Get('cl_update_profile_sync_rep')
|
||||
},
|
||||
{'name': 'regen_cache',
|
||||
'foreach': 'cl_builder_sync_overlay_rep',
|
||||
'message': __("Updating the {eachvar:capitalize} repository cache"),
|
||||
'essential': False,
|
||||
'method': 'Builder.regenCache(eachvar)',
|
||||
#'condition': (
|
||||
# lambda Get: (Get('cl_update_outdate_set') == 'on' and
|
||||
# Get('cl_update_metadata_force') != 'skip' or
|
||||
# Get('cl_update_metadata_force') == 'force'))
|
||||
},
|
||||
{'name': 'eix_update',
|
||||
'message': __("Updating the eix cache"),
|
||||
'method': 'Builder.eixUpdate(cl_builder_repository_name)',
|
||||
#'condition': (
|
||||
# lambda Get: (Get('cl_update_outdate_set') == 'on' and
|
||||
# Get('cl_update_eixupdate_force') != 'skip' or
|
||||
# Get('cl_update_eixupdate_force') == 'force'))
|
||||
},
|
||||
# save
|
||||
{'name': 'save',
|
||||
'method': 'Builder.save_build(cl_builder_build,'
|
||||
'cl_builder_profile_datavars)',
|
||||
},
|
||||
# сообщение удачного завершения при обновлении репозиториев
|
||||
{'name': 'success_syncrep',
|
||||
'message': __("Synchronization finished"),
|
||||
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
|
||||
"sync_other_reps",
|
||||
"emerge_metadata",
|
||||
"eix_update")),
|
||||
}
|
||||
]
|
||||
},
|
||||
{'name': 'reps_synchronization',
|
||||
'group': __("Setting up the profile"),
|
||||
'tasks': [
|
||||
{'name': 'set_profile',
|
||||
'message': __("Switching to profile "
|
||||
"{cl_builder_profile_system_shortname}"),
|
||||
'method': 'Builder.set_profile('
|
||||
'cl_builder_profile_system_shortname,cl_builder_path)'
|
||||
},
|
||||
{'name': 'merge_utils',
|
||||
'message': __("Calculating dependencies"),
|
||||
'method': 'Builder.emerge("-console -pxe","-1","sys-apps/calculate-utils")',
|
||||
# TODO: возможно добавить параметр необходимости установки
|
||||
'condition': lambda Get: not isPkgInstalled(
|
||||
'sys-apps/calculate-utils', Get('cl_builder_path'))
|
||||
},
|
||||
{'name': 'reconfigure',
|
||||
'message': __("Reconfigure the settings"),
|
||||
'method': 'Builder.apply_templates(cl_builder_path,'
|
||||
'cl_template_clt_set,True,None,False,"merge",'
|
||||
'cl_builder_profile_datavars)',
|
||||
'condition': lambda Get: Get('cl_templates_locate')
|
||||
},
|
||||
{'name': 'fix_settings',
|
||||
'message': __("Fixing the settings"),
|
||||
'method': 'Builder.apply_templates(cl_builder_path,'
|
||||
'cl_template_clt_set,True,None,False,"sync",'
|
||||
'cl_builder_profile_datavars)',
|
||||
'condition': lambda Get: Get('cl_templates_locate')
|
||||
},
|
||||
{'name': 'dispatch_conf',
|
||||
'message': __("Updating configuration files"),
|
||||
'method':'Builder.dispatchConf(None,cl_builder_path)',
|
||||
'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
@ -0,0 +1,247 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Calculate Ltd. http://www.calculate-linux.org
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
from calculate.core.server.func import Action, Tasks
|
||||
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
||||
from calculate.lib.utils.files import FilesError, isMount
|
||||
from calculate.update.emerge_parser import EmergeError
|
||||
from calculate.update.update import UpdateError
|
||||
from ..datavars import BuilderError
|
||||
from calculate.lib.utils.portage import GitError, isPkgInstalled, \
|
||||
EmergeLogNamedTask, PackageList, EmergeLog
|
||||
from calculate.install.distr import DistributiveError
|
||||
from os import path
|
||||
from calculate.update.update_tasks import EmergeMark
|
||||
|
||||
setLocalTranslate('cl_builder3', sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
|
||||
class ClBuilderUpdateAction(Action):
|
||||
"""
|
||||
Действие обновление конфигурационных файлов
|
||||
"""
|
||||
# ошибки, которые отображаются без подробностей
|
||||
native_error = (DistributiveError, FilesError, UpdateError,
|
||||
BuilderError, GitError, EmergeError)
|
||||
|
||||
successMessage = __("The system was successfully updated")
|
||||
failedMessage = __("Failed to update the system")
|
||||
interruptMessage = __("System update manually interrupted")
|
||||
|
||||
def was_installed(pkg, task_name):
|
||||
def func(Get):
|
||||
task = EmergeLog(EmergeLogNamedTask(task_name),
|
||||
prefix=Get('cl_builder_path'))
|
||||
return bool(PackageList(task.list)[pkg])
|
||||
|
||||
return func
|
||||
|
||||
def need_depclean(pkg, task_name):
|
||||
def func(Get):
|
||||
task = EmergeLog(EmergeLogNamedTask(task_name),
|
||||
prefix=Get('cl_builder_path'))
|
||||
return bool(PackageList(task.list)[pkg])
|
||||
|
||||
return func
|
||||
|
||||
# список задач для действия
|
||||
tasks = [
|
||||
{'name': 'clear_log',
|
||||
'method': 'Builder.clear_log(cl_builder_id)',
|
||||
},
|
||||
{'name': 'apply_template',
|
||||
'message': __("Configuring build"),
|
||||
'method': 'Builder.applyTemplates(cl_builder_target,False,False,None)',
|
||||
},
|
||||
{'name': 'invalidate_vars',
|
||||
'method': 'Builder.invalidateVariables("cl_builder_linux_datavars")'
|
||||
},
|
||||
{'name': 'reconfigure_vars',
|
||||
'method': 'Builder.reconfigureProfileVars(cl_builder_linux_datavars,'
|
||||
'cl_builder_path)'
|
||||
},
|
||||
{'name': 'reps_synchronization',
|
||||
'group': __("Repositories synchronization"),
|
||||
'tasks': [
|
||||
{'name': 'sync_reps',
|
||||
'foreach': 'cl_builder_profile_sync_rep',
|
||||
'message': __("Syncing the {eachvar:capitalize} repository"),
|
||||
'method': 'Builder.syncRepositories(eachvar)',
|
||||
},
|
||||
{'name': 'regen_cache',
|
||||
'foreach': 'cl_builder_sync_overlay_rep',
|
||||
'message': __("Updating the {eachvar:capitalize} repository cache"),
|
||||
'essential': False,
|
||||
'method': 'Builder.regenCache(eachvar)',
|
||||
},
|
||||
{'name': 'eix_update',
|
||||
'message': __("Updating the eix cache"),
|
||||
'method': 'Builder.eixUpdate(cl_builder_repository_name)',
|
||||
},
|
||||
# сообщение удачного завершения при обновлении репозиториев
|
||||
{'name': 'success_syncrep',
|
||||
'message': __("Synchronization finished"),
|
||||
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
|
||||
"sync_other_reps",
|
||||
"emerge_metadata",
|
||||
"eix_update")),
|
||||
}
|
||||
]
|
||||
},
|
||||
{'name': 'reps_synchronization',
|
||||
'group': __("System configuration"),
|
||||
'tasks': [
|
||||
{'name': 'revision',
|
||||
'message': __("Fixing the settings"),
|
||||
'method': 'Builder.apply_templates(cl_builder_path,'
|
||||
'cl_template_clt_set,True,None,False,"sync",'
|
||||
'cl_builder_linux_datavars)',
|
||||
'condition': lambda Get: Get('cl_templates_locate')
|
||||
},
|
||||
{'name': 'dispatch_conf',
|
||||
'message': __("Updating configuration files"),
|
||||
'method': 'Builder.dispatchConf(None,cl_builder_path)',
|
||||
'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'emerge_update_world',
|
||||
'group': __("Updating packages"),
|
||||
'tasks': [
|
||||
{'name': 'update_world',
|
||||
'message': __("Calculating dependencies"),
|
||||
'method': 'Builder.emerge_ask("-uDN", "--changed-deps",'
|
||||
'"--with-bdeps=y", "@world")'
|
||||
}
|
||||
]
|
||||
},
|
||||
{'name': 'group_changed_packages',
|
||||
'group': __("Rebuild modified packages"),
|
||||
'tasks': [
|
||||
{'name': 'changed_packages',
|
||||
'message': __("Calculating dependencies"),
|
||||
'method': 'Builder.rebuild_changed_packages(cl_builder_path,'
|
||||
'cl_builder_repository_data)'
|
||||
}
|
||||
]
|
||||
},
|
||||
{'name': 'update_python',
|
||||
'group': __("Updating Python"),
|
||||
'tasks': [
|
||||
{'name': 'python_updater',
|
||||
'message': __('Find & rebuild packages broken due '
|
||||
'to a Python upgrade'),
|
||||
'method': 'Builder.emergelike(cl_builder_path,"python-updater")',
|
||||
'condition': was_installed('dev-lang/python$',
|
||||
EmergeMark.PythonUpdater),
|
||||
'decoration': 'Builder.update_task("%s")' %
|
||||
EmergeMark.PythonUpdater
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'update_perl',
|
||||
'group': __("Updating Perl"),
|
||||
'tasks': [
|
||||
{'name': 'perl_cleaner',
|
||||
'message': __('Find & rebuild packages and Perl header files '
|
||||
'broken due to a perl upgrade'),
|
||||
'method': 'Builder.emergelike(cl_builder_path,"perl-cleaner",'
|
||||
'"all")',
|
||||
'condition': was_installed('dev-lang/perl$',
|
||||
EmergeMark.PerlCleaner),
|
||||
'decoration': 'Builder.update_task("%s")' % EmergeMark.PerlCleaner
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'depclean',
|
||||
'group': __("Cleaning the system from needless packages"),
|
||||
'tasks': [
|
||||
{'name': 'update_depclean',
|
||||
'message': __("Calculating dependencies"),
|
||||
'method': 'Builder.depclean()',
|
||||
'condition': need_depclean('.*', EmergeMark.Depclean),
|
||||
'decoration': 'Builder.update_task("%s")' % EmergeMark.Depclean
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'update_world:update_modules',
|
||||
'group': __("Rebuilding dependent modules"),
|
||||
'tasks': [
|
||||
{'name': 'update_world:module_rebuild',
|
||||
'message': __('Updating Kernel modules'),
|
||||
'method': 'Builder.emerge("","@module-rebuild")',
|
||||
'condition': was_installed('sys-kernel/.*source',
|
||||
EmergeMark.KernelModules),
|
||||
'decoration': 'Builder.update_task("%s")' %
|
||||
EmergeMark.KernelModules
|
||||
},
|
||||
{'name': 'update_world:x11_module_rebuild',
|
||||
'message': __('Updating X.Org server modules'),
|
||||
'method': 'Builder.emerge("","@x11-module-rebuild")',
|
||||
'condition': was_installed('x11-base/xorg-server',
|
||||
EmergeMark.XorgModules),
|
||||
'decoration': 'Builder.update_task("%s")' % EmergeMark.XorgModules
|
||||
},
|
||||
{'name': 'update_world:preserved_rebuild',
|
||||
'message': __('Updating preserved libraries'),
|
||||
'method': 'Builder.emerge("","@preserved-rebuild")',
|
||||
'condition': was_installed('.*', EmergeMark.PreservedLibs),
|
||||
'decoration': 'Builder.update_task("%s")' %
|
||||
EmergeMark.PreservedLibs
|
||||
},
|
||||
{'name': 'update_world:dispatch_conf_end',
|
||||
'message': __("Updating configuration files"),
|
||||
'method':'Builder.dispatchConf()',
|
||||
'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'prelink',
|
||||
'message': __("Executing prelink"),
|
||||
'method': 'Builder.chroot_command(cl_builder_path,"prelink",'
|
||||
'"-afmR")',
|
||||
'condition': was_installed('.*', EmergeMark.Prelink),
|
||||
'decoration': 'Builder.update_task("%s")' % EmergeMark.Prelink
|
||||
},
|
||||
{'name': 'fetch_video_drivers',
|
||||
'group': __("Fetching video drivers"),
|
||||
'tasks': [
|
||||
{'name': 'fetch_drivers',
|
||||
'method': 'Builder.fetch_drivers(cl_builder_path,'
|
||||
'cl_builder_linux_distdir,cl_builder_linux_pkgdir)',
|
||||
'condition': lambda Get: Get('cl_builder_videodrv_set') == 'on'
|
||||
},
|
||||
{'name': 'create_video_data',
|
||||
'message': __("Creating install video driver data"),
|
||||
'method': 'Builder.create_video_data(cl_builder_path,'
|
||||
'cl_builder_repository_data)',
|
||||
'condition': lambda Get: Get('cl_builder_videodrv_set') == 'on'
|
||||
},
|
||||
]
|
||||
},
|
||||
{'name': 'remove_video_drivers',
|
||||
'method': 'Builder.remove_video_drivers(cl_builder_path)',
|
||||
'condition': lambda Get: Get('cl_builder_videodrv_set') == 'off'
|
||||
},
|
||||
{'name': 'reading_news',
|
||||
'method': 'Builder.reading_news(cl_builder_path)'
|
||||
},
|
||||
{'name': 'check_obsolete',
|
||||
'method': 'Builder.check_obsolete(cl_builder_path)'
|
||||
}
|
||||
]
|
Loading…
Reference in new issue