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

master3.4
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 .build_storage import Build
from calculate.update.update import Update
from calculate.install.distr import Distributive
from calculate.install.distr import Distributive, IsoDistributive
from functools import partial
import os
from os import path
from .datavars import BuilderError
from .emerge_fetch import EmergeFetcher, EmergeFetcherError
from calculate.install.distr import SquashDistributive
from calculate.builder.variables.action import Actions
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, _)
@ -927,6 +928,7 @@ class Builder(Update):
:param exclude_files:
:return:
"""
builder_path = builder_path.encode('utf-8')
all_count = countFiles(builder_path)
exclude_sum = sum(countFiles(path.join(builder_path, x))
for x in exclude_files)
@ -967,3 +969,26 @@ class Builder(Update):
raise BuilderError(_("Builder action for %s is already running. "
"Try to run later.")%build_id)
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 calculate.lib.utils.portage import GitError
from calculate.install.distr import DistributiveError, IsoDistributive
from calculate.builder.variables.action import Actions
setLocalTranslate('cl_builder3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
@ -81,6 +82,10 @@ class ClBuilderImageAction(Action):
'method': 'Builder.remove_video_drivers(cl_builder_path)',
'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',
'group': __("Creating live image"),
'tasks': [
@ -99,7 +104,7 @@ class ClBuilderImageAction(Action):
IsoDistributive)
},
{'name': 'squash_action',
'method': 'Builder.set_builder_action("squash")',
'method': 'Builder.set_builder_action("%s")'%Actions.ImageSquash,
},
{'name': 'count_files',
'method': 'Builder.recount_files(cl_builder_path,'
@ -110,12 +115,14 @@ class ClBuilderImageAction(Action):
},
{'name': 'apply_template',
'message': __("Configuring squash filesystem image"),
# наложить шаблоны в развернутый дистрибутив
'method': 'Builder.applyTemplates(cl_builder_target,'
'False,False,None)',
},
{'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
{'name':'remove_list_digest',
@ -145,10 +152,14 @@ class ClBuilderImageAction(Action):
'method': 'Builder.mount_target(cl_builder_target)',
'condition': lambda Get: Get('cl_builder_build')
},
{'name': 'update_menu',
'message': "Rescratch",
{'name': 'image_menu',
'method': 'Builder.set_builder_action("%s")' % Actions.ImageMenu,
'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',

@ -19,7 +19,9 @@ from os import path
import os
import re
from calculate.install.variables.kernel import KernelConfig
from calculate.lib.utils.dracut import Dracut
from calculate.lib.utils.portage import getSquashList
from calculate.lib.variables.system import VariableOsRootType, RootType
from .action import Actions
from calculate.install import distr
from calculate.lib.utils.device import getUdevDeviceInfo, humanreadableSize
@ -701,8 +703,6 @@ class VariableClBuilderImageFilename(Variable):
metavalue = "IMAGE"
untrusted = True
flash_base_dn = '/run/initramfs/live/iso'
flash_iso_base_dn = '/run/initramfs/isoscan/iso'
default_base_dn = '/var/calculate/linux'
def init(self):
@ -724,10 +724,8 @@ class VariableClBuilderImageFilename(Variable):
build_id = self.Get('cl_builder_id')
base_dn = self.default_base_dn
if self.Get('os_root_type') == 'livecd':
if self.Get('cl_flash_set') == 'on':
base_dn = self.flash_base_dn
# TODO: для iso-scan из flash
if self.Get('os_root_type_ext') in RootType.RebuildAvailable:
base_dn = self.Get('cl_builder_flash_repository')
if build_id:
imagename = self._isoname()
return path.join(base_dn, imagename)
@ -1215,10 +1213,44 @@ class VariableClBuilderRescratchSet(ReadonlyVariable):
type = "bool"
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')
var = VariableClBuilderImageFilename
if (isoimage.startswith(var.flash_base_dn) or
isoimage.startswith(var.flash_iso_base_dn)):
flash_rep = self.Get('cl_builder_flash_repository')
isoimage_dir = path.dirname(isoimage)
if isoimage_dir == flash_rep:
return "on"
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
raise VariableError(_("Failed to generate kernel name"))
def generator(self):
isopath = self.Get('cl_builder_image_path')
def generator(self, isopath):
n = 1
for iso_image in [x for x in listDirectory(isopath, fullPath=True)
if x.endswith('.iso')]:
@ -159,9 +158,10 @@ class VariableClBuilderImageData(ReadonlyTableVariable):
pass
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 list(self.generator())
return list(self.generator(isopath))
class VariableClBuilderImageId(FieldValue, ReadonlyVariable):

@ -276,6 +276,13 @@ class Wsdl(WsdlBase):
hide=('cl_templates_locate',
'cl_verbose_set',
'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=(
# Включить проприетарные видео драйвера

Loading…
Cancel
Save