Перегенрация меню

Mike Khiretskiy 9 years ago
parent ef5035ef42
commit 162471ef7b

@ -37,12 +37,13 @@ from calculate.update.emerge_parser import EmergeParser, \
from calculate.lib.cl_log import log from calculate.lib.cl_log import log
from .build_storage import Build from .build_storage import Build
from calculate.update.update import Update from calculate.update.update import Update
from calculate.install.distr import Distributive from calculate.install.distr import Distributive, IsoDistributive
from functools import partial from functools import partial
import os import os
from os import path from os import path
from .datavars import BuilderError from .datavars import BuilderError
from .emerge_fetch import EmergeFetcher, EmergeFetcherError from .emerge_fetch import EmergeFetcher, EmergeFetcherError
from calculate.install.distr import SquashDistributive
from calculate.builder.variables.action import Actions from calculate.builder.variables.action import Actions
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, _) from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, _)
@ -927,6 +928,7 @@ class Builder(Update):
:param exclude_files: :param exclude_files:
:return: :return:
""" """
builder_path = builder_path.encode('utf-8')
all_count = countFiles(builder_path) all_count = countFiles(builder_path)
exclude_sum = sum(countFiles(path.join(builder_path, x)) exclude_sum = sum(countFiles(path.join(builder_path, x))
for x in exclude_files) for x in exclude_files)
@ -967,3 +969,26 @@ class Builder(Update):
raise BuilderError(_("Builder action for %s is already running. " raise BuilderError(_("Builder action for %s is already running. "
"Try to run later.")%build_id) "Try to run later.")%build_id)
return True return True
def update_menu(self, dn):
with IsoDistributive(dn) as iso:
d = iso.getDirectory()
root_path = path.relpath(dn, d)
self.clVars.Set('cl_builder_iso_path', dn, force=True)
self.clVars.Set('cl_builder_target', iso, force=True)
self.applyTemplates(d, False, False, root_path)
return True
def remount_rw(self, dn):
"""
Перемонтировать каталог для чтения/записи (используется для flash)
:param dn: каталог
:return:
"""
if not dn:
raise BuilderError(_("Failed to remount Flash drive"))
p = process('/bin/mount', '-o', 'remount,rw', dn, stderr=STDOUT)
if p.failed():
self.printERROR(p.read())
return False
return True

@ -21,6 +21,7 @@ from calculate.lib.utils.files import FilesError
from ..datavars import BuilderError from ..datavars import BuilderError
from calculate.lib.utils.portage import GitError from calculate.lib.utils.portage import GitError
from calculate.install.distr import DistributiveError, IsoDistributive from calculate.install.distr import DistributiveError, IsoDistributive
from calculate.builder.variables.action import Actions
setLocalTranslate('cl_builder3', sys.modules[__name__]) setLocalTranslate('cl_builder3', sys.modules[__name__])
__ = getLazyLocalTranslate(_) __ = getLazyLocalTranslate(_)
@ -81,6 +82,10 @@ class ClBuilderImageAction(Action):
'method': 'Builder.remove_video_drivers(cl_builder_path)', 'method': 'Builder.remove_video_drivers(cl_builder_path)',
'condition': lambda Get: Get('cl_builder_videodrv_set') == 'off' 'condition': lambda Get: Get('cl_builder_videodrv_set') == 'off'
}, },
{'name': 'remount_flash',
'method': 'Builder.remount_rw(cl_builder_flash_path)',
'condition': lambda Get: Get('cl_builder_rescratch_set') == 'on'
},
{'name': 'creating_live_image', {'name': 'creating_live_image',
'group': __("Creating live image"), 'group': __("Creating live image"),
'tasks': [ 'tasks': [
@ -99,7 +104,7 @@ class ClBuilderImageAction(Action):
IsoDistributive) IsoDistributive)
}, },
{'name': 'squash_action', {'name': 'squash_action',
'method': 'Builder.set_builder_action("squash")', 'method': 'Builder.set_builder_action("%s")'%Actions.ImageSquash,
}, },
{'name': 'count_files', {'name': 'count_files',
'method': 'Builder.recount_files(cl_builder_path,' 'method': 'Builder.recount_files(cl_builder_path,'
@ -110,12 +115,14 @@ class ClBuilderImageAction(Action):
}, },
{'name': 'apply_template', {'name': 'apply_template',
'message': __("Configuring squash filesystem image"), 'message': __("Configuring squash filesystem image"),
# наложить шаблоны в развернутый дистрибутив
'method': 'Builder.applyTemplates(cl_builder_target,' 'method': 'Builder.applyTemplates(cl_builder_target,'
'False,False,None)', 'False,False,None)',
}, },
{'name': 'squash_action', {'name': 'squash_action',
'method': 'Builder.set_builder_action("iso")', 'method': 'Builder.set_builder_action("%s")'%Actions.ImageIso,
},
{'name': 'protect_off',
'method': 'Builder.setVariable("cl_protect_use_set","off",True)'
}, },
# сборка iso # сборка iso
{'name':'remove_list_digest', {'name':'remove_list_digest',
@ -145,10 +152,14 @@ class ClBuilderImageAction(Action):
'method': 'Builder.mount_target(cl_builder_target)', 'method': 'Builder.mount_target(cl_builder_target)',
'condition': lambda Get: Get('cl_builder_build') 'condition': lambda Get: Get('cl_builder_build')
}, },
{'name': 'update_menu', {'name': 'image_menu',
'message': "Rescratch", 'method': 'Builder.set_builder_action("%s")' % Actions.ImageMenu,
'condition': lambda Get: Get('cl_builder_rescratch_set') == 'on' 'condition': lambda Get: Get('cl_builder_rescratch_set') == 'on'
} },
{'name': 'image_menu:update_menu',
'message': "Templates",
'method': 'Builder.update_menu(cl_builder_flash_path)',
},
] ]
}, },
{'name': 'failed', {'name': 'failed',

@ -19,7 +19,9 @@ from os import path
import os import os
import re import re
from calculate.install.variables.kernel import KernelConfig from calculate.install.variables.kernel import KernelConfig
from calculate.lib.utils.dracut import Dracut
from calculate.lib.utils.portage import getSquashList from calculate.lib.utils.portage import getSquashList
from calculate.lib.variables.system import VariableOsRootType, RootType
from .action import Actions from .action import Actions
from calculate.install import distr from calculate.install import distr
from calculate.lib.utils.device import getUdevDeviceInfo, humanreadableSize from calculate.lib.utils.device import getUdevDeviceInfo, humanreadableSize
@ -701,8 +703,6 @@ class VariableClBuilderImageFilename(Variable):
metavalue = "IMAGE" metavalue = "IMAGE"
untrusted = True untrusted = True
flash_base_dn = '/run/initramfs/live/iso'
flash_iso_base_dn = '/run/initramfs/isoscan/iso'
default_base_dn = '/var/calculate/linux' default_base_dn = '/var/calculate/linux'
def init(self): def init(self):
@ -724,10 +724,8 @@ class VariableClBuilderImageFilename(Variable):
build_id = self.Get('cl_builder_id') build_id = self.Get('cl_builder_id')
base_dn = self.default_base_dn base_dn = self.default_base_dn
if self.Get('os_root_type') == 'livecd': if self.Get('os_root_type_ext') in RootType.RebuildAvailable:
if self.Get('cl_flash_set') == 'on': base_dn = self.Get('cl_builder_flash_repository')
base_dn = self.flash_base_dn
# TODO: для iso-scan из flash
if build_id: if build_id:
imagename = self._isoname() imagename = self._isoname()
return path.join(base_dn, imagename) return path.join(base_dn, imagename)
@ -1215,10 +1213,44 @@ class VariableClBuilderRescratchSet(ReadonlyVariable):
type = "bool" type = "bool"
def get(self): def get(self):
if self.Get('cl_flash_set') == 'on': if self.Get('os_root_type_ext') in RootType.RebuildAvailable:
isoimage = self.Get('cl_builder_image_filename') isoimage = self.Get('cl_builder_image_filename')
var = VariableClBuilderImageFilename flash_rep = self.Get('cl_builder_flash_repository')
if (isoimage.startswith(var.flash_base_dn) or isoimage_dir = path.dirname(isoimage)
isoimage.startswith(var.flash_iso_base_dn)): if isoimage_dir == flash_rep:
return "on" return "on"
return "off" return "off"
class VariableClBuilderFlashRepository(ReadonlyVariable):
"""
Хранилище по умолчанию для iso образов на flash
"""
suffix = "iso"
def get(self):
return path.join(self.Get('cl_builder_flash_path'), "iso")
class VariableClBuilderFlashPath(ReadonlyVariable):
"""
Путь, куда подключена flash (загрузка либо с флешки, либо с iso)
"""
def get(self):
root_type_ext = self.Get('os_root_type_ext')
if root_type_ext == RootType.LiveFlash:
return Dracut.IsoLive
if root_type_ext == RootType.IsoScan:
return Dracut.IsoScanPath
return ""
class VariableClBuilderFlashUuid(ReadonlyVariable):
"""
UUID flash, используется для перестроения меню
"""
def get(self):
flash_path = self.Get('cl_builder_flash_path')
dev = isMount(flash_path)
if dev:
return self.select(
'install.os_disk_uuid',
install_os_disk_dev=dev, limit=1)
return ""

@ -130,8 +130,7 @@ class VariableClBuilderImageData(ReadonlyTableVariable):
return newname return newname
raise VariableError(_("Failed to generate kernel name")) raise VariableError(_("Failed to generate kernel name"))
def generator(self): def generator(self, isopath):
isopath = self.Get('cl_builder_image_path')
n = 1 n = 1
for iso_image in [x for x in listDirectory(isopath, fullPath=True) for iso_image in [x for x in listDirectory(isopath, fullPath=True)
if x.endswith('.iso')]: if x.endswith('.iso')]:
@ -159,9 +158,10 @@ class VariableClBuilderImageData(ReadonlyTableVariable):
pass pass
def get(self, hr=False): def get(self, hr=False):
if self.Get('cl_builder_action') != Actions.ImageMenu: isopath = self.Get('cl_builder_flash_repository')
if self.Get('cl_builder_action') != Actions.ImageMenu or not isopath:
return [[]] return [[]]
return list(self.generator()) return list(self.generator(isopath))
class VariableClBuilderImageId(FieldValue, ReadonlyVariable): class VariableClBuilderImageId(FieldValue, ReadonlyVariable):

@ -276,6 +276,13 @@ class Wsdl(WsdlBase):
hide=('cl_templates_locate', hide=('cl_templates_locate',
'cl_verbose_set', 'cl_verbose_set',
'cl_dispatch_conf' 'cl_dispatch_conf'
'cl_builder_prepared_id',
'cl_builder_image_filename',
'cl_builder_videodrv_set',
'cl_builder_compress',
'cl_builder_keep_tree_set',
'cl_builder_isohybrid_set',
'cl_builder_prelink_set',
), ),
expert=( expert=(
# Включить проприетарные видео драйвера # Включить проприетарные видео драйвера

Loading…
Cancel
Save