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/builder.py

90 lines
2.7 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 .build_storage import Build
from calculate.install.distr import Distributive
from os import path
from .datavars import BuilderError
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, _)
setLocalTranslate('cl_builder3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
class Builder(object):
"""Основной объект для выполнения действий связанных со сборкой системы
"""
def init(self):
pass
def mount_target(self, target):
dir_distro = target.convertToDirectory()
dir_distro.mountSystemDirectories()
return True
def umount_system(self, target):
dir_distro = target.convertToDirectory()
dir_distro.umountSystemDirectories()
return True
def detach_target(self, target):
"""
@type target: Distributive
"""
if target:
target.reserve()
return True
def close_build(self, build, clear=False):
"""
@type build:Build
"""
if build:
build.remove()
build.close_distributive()
if clear:
build.distributive.post_clear()
return True
def restore_build(self, build):
if build:
build.restore()
return True
def save_build(self, build):
build.pkgdir = self.clVars.Get('cl_builder_pkgdir')
build.save()
return True
def set_builder_action(self, action_name):
self.clVars.Set('cl_builder_action', action_name, force=True)
return True
def prepare_iso(self, dn):
self.endTask()
self.startTask(_("Prepare iso data"))
root_path = path.relpath(dn, self.clVars.Get('cl_builder_path'))
self.applyTemplates(self.clVars.Get('cl_builder_target'),
False, False, root_path)
self.endTask()
self.startTask(_("Pack iso image"))
self.addProgress()
def prepare_image(self, image):
image.eventPrepareIso.connect(self.prepare_iso)
return True