You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-3-update/pym/builder/utils/cl_builder_image.py

78 lines
3.1 KiB

# -*- 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
from ..datavars import BuilderError
from calculate.lib.utils.portage import GitError
from calculate.install.distr import DistributiveError, IsoDistributive
setLocalTranslate('cl_builder3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
class ClBuilderImageAction(Action):
"""
Действие обновление конфигурационных файлов
"""
# ошибки, которые отображаются без подробностей
native_error = (DistributiveError, FilesError, BuilderError, GitError)
successMessage = __("Image created successfully")
failedMessage = __("Creating the image is failed")
interruptMessage = __("Image creating manually interrupted")
# список задач для действия
tasks = [
# закрепить подключенные данные
{'name': 'detach',
'message': __("Detach target"),
'method': 'Builder.detach_target(cl_builder_target)',
},
{'name': 'umount_system',
'message': __("Umount build system resources"),
'method': 'Builder.umount_system(cl_builder_target)',
'condition': lambda Get: Get('cl_builder_build')
},
{'name': 'prepare_image',
'method': 'Builder.prepare_image(cl_builder_image)',
'condition': lambda Get: isinstance(Get('cl_builder_image'),
IsoDistributive)
},
{'name': 'squash_action',
'method': 'Builder.set_builder_action("squash")',
},
{'name': 'apply_template',
'message': __("Configuring squash"),
# наложить шаблоны в развернутый дистрибутив
'method': 'Builder.applyTemplates(cl_builder_target,False,False,None)',
},
{'name': 'squash_action',
'method': 'Builder.set_builder_action("iso")',
},
# распаковка дистрибутива
{'name': 'unpack',
'message': __("Pack squash"),
'method': 'Install.unpack(cl_builder_target, cl_builder_image, "0")',
},
{'name': 'umount_system!:mount_system',
'warning': _("Restore build system resources"),
'method': 'Builder.mount_target(cl_builder_target)',
'condition': lambda Get: Get('cl_builder_build')
}]