diff --git a/i18n/cl_builder_ru.mo b/i18n/cl_builder_ru.mo deleted file mode 100644 index 9b4e74b..0000000 Binary files a/i18n/cl_builder_ru.mo and /dev/null differ diff --git a/pym/__init__.py b/pym/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pym/builder/__init__.py b/pym/builder/__init__.py new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/pym/builder/__init__.py @@ -0,0 +1 @@ + diff --git a/pym/builder/builder.py b/pym/builder/builder.py new file mode 100644 index 0000000..5ebceb2 --- /dev/null +++ b/pym/builder/builder.py @@ -0,0 +1,35 @@ +#-*- 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 random +import sys +import os +from os import path + +from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate, + RegexpLocalization, _) +setLocalTranslate('cl_builder3', sys.modules[__name__]) +__ = getLazyLocalTranslate(_) + + +class BuilderError(AddonError): + """Builder Error""" + +class Builder(object): + """Основной объект для выполнения действий связанных со сборкой системы + + """ + def init(self): + pass diff --git a/pym/builder/datavars.py b/pym/builder/datavars.py new file mode 100644 index 0000000..a2c5278 --- /dev/null +++ b/pym/builder/datavars.py @@ -0,0 +1,33 @@ +#-*- 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. +from version import __app__, __version__ + +import os +import sys +from calculate.lib.datavars import DataVars + +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_builder3',sys.modules[__name__]) + +class DataVarsBuilder(DataVars): + """Variable class for desktop package""" + var_module = "update" + + def importBuilder(self, **args): + """Import desktop variables""" + self.importVariables() + self.importVariables('calculate.%s.variables'%self.var_module) + self.defaultModule = self.var_module diff --git a/pym/builder/utils/cl_builder_create.py b/pym/builder/utils/cl_builder_create.py new file mode 100644 index 0000000..79d59f7 --- /dev/null +++ b/pym/builder/utils/cl_builder_create.py @@ -0,0 +1,41 @@ +#-*- 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 calculate.builder.builder import BuilderError +from calculate.lib.utils.portage import GitError + +setLocalTranslate('cl_builder3', sys.modules[__name__]) +__ = getLazyLocalTranslate(_) + + +class ClBuilderCreateAction(Action): + """ + Действие обновление конфигурационных файлов + """ + # ошибки, которые отображаются без подробностей + native_error = (FilesError, BuilderError, GitError) + + successMessage = __("The profile was successfully updated") + failedMessage = __("Failed to update the profile") + interruptMessage = __("Profile update manually interrupted") + + # список задач для дейсвия + tasks = [ + ] diff --git a/pym/builder/variables/__init__.py b/pym/builder/variables/__init__.py new file mode 100644 index 0000000..0dc3dbf --- /dev/null +++ b/pym/builder/variables/__init__.py @@ -0,0 +1,19 @@ +#-*- coding: utf-8 -*- + +# Copyright 2008-2013 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 action + +section = "builder" diff --git a/pym/builder/variables/action.py b/pym/builder/variables/action.py new file mode 100644 index 0000000..2887765 --- /dev/null +++ b/pym/builder/variables/action.py @@ -0,0 +1,45 @@ +#-*- coding: utf-8 -*- + +# Copyright 2008-2013 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 os +import sys +from os import path +from calculate.lib.datavars import Variable,VariableError,ReadonlyVariable + +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_builder3',sys.modules[__name__]) + +class VariableAcBuilderSquash(ReadonlyVariable): + """ + Action variable which has value "on" for package install and + install this package + """ + def get(self): + action = self.Get("cl_action") + if action in ("squash",): + return "on" + return "off" + +class VariableAcBuilderIso(ReadonlyVariable): + """ + Action variable which has value "on" for package install and + install this package + """ + def get(self): + action = self.Get("cl_action") + if action in ("iso",): + return "on" + return "off" diff --git a/pym/builder/version.py b/pym/builder/version.py new file mode 100644 index 0000000..93f92cc --- /dev/null +++ b/pym/builder/version.py @@ -0,0 +1,17 @@ +#-*- coding: utf-8 -*- + +# Copyright 15 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. +__app__ = 'calculate-builder' +__version__ = '3.4.0_alpha1' diff --git a/pym/builder/wsdl_builder.py b/pym/builder/wsdl_builder.py new file mode 100644 index 0000000..81f1268 --- /dev/null +++ b/pym/builder/wsdl_builder.py @@ -0,0 +1,70 @@ +#-*- coding: utf-8 -*- + +# Copyright 2010-2013 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.lib.datavars import VariableError,DataVarsError,DataVars + +from calculate.core.server.func import WsdlBase +from calculate.install.install import InstallError +from calculate.builder.builder import BuilderError +from calculate.lib.utils.portage import GitError +from utils.cl_builder_create import ClBuilderCreateAction +from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate +setLocalTranslate('cl_update3',sys.modules[__name__]) +__ = getLazyLocalTranslate(_) + + +class Wsdl(WsdlBase): + methods = [ + # + # Подготовить систему для сборки + # + { + # идентификатор метода + 'method_name': "builder_create", + # категория метода + 'category': __('Builder'), + # заголовок метода + 'title': __("Create the system"), + # иконка для графической консоли + 'image': 'calculate-update', + # метод присутствует в графической консоли + 'gui': True, + # консольная команда + 'command': 'cl-builder-create', + # права для запуска метода + 'rights': ['build'], + # объект содержащий модули для действия + 'logic': {'Builder': Builder}, + # описание действия + 'action': ClBuilderCreateAction, + # объект переменных + 'datavars': "builder", + 'native_error': (VariableError, DataVarsError, + InstallError, BuilderError, GitError), + # значения по умолчанию для переменных этого метода + 'setvars': {'cl_action!': 'create'}, + # описание груп (список лямбда функций) + 'groups': [ + lambda group: group(_("Create the system"), + normal=(), + expert=( + 'cl_templates_locate', + 'cl_verbose_set', 'cl_dispatch_conf'), + next_label=_("Perform"))] + }, + ] diff --git a/pym/cl_fill_builder.py b/pym/cl_fill_builder.py deleted file mode 100644 index f641d6c..0000000 --- a/pym/cl_fill_builder.py +++ /dev/null @@ -1,64 +0,0 @@ -#-*- coding: utf-8 -*- - -# Copyright 2010 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 os -import re -import cl_overriding -from cl_datavars import glob_attr -from cl_kernel import cl_kernel -from os import access, R_OK -from os import path - -class fillVars(object, glob_attr): - - def get_cl_kernel_directory(self): - defaultKernelPath = '/usr/src' - if not access(defaultKernelPath,R_OK): - return "" - kernel = cl_kernel() - kernelDirs = filter(kernel._testKernelDirectory,os.listdir('/usr/src')) - if kernelDirs: - if "linux" in kernelDirs: - return path.join(defaultKernelPath,"linux") - else: - return path.join(defaultKernelPath,kernelDirs[0]) - return "" - - def get_cl_kernel_version(self): - kernelMakefile = path.join(self.Get('cl_kernel_directory'),'Makefile') - reVerPart = re.compile("^(?:VERSION|^PATCHLEVEL|^SUBLEVEL)\s*=",re.I) - if access(kernelMakefile,R_OK): - try: - return "%(VERSION)s.%(PATCHLEVEL)s.%(SUBLEVEL)s"% \ - dict(map(lambda x:(x[0].strip(),x[2].strip()), - map(lambda x:x.partition('='), - filter(reVerPart.search, - open(kernelMakefile,'r'))))) - except: - pass - return "" - - def get_cl_kernel_config(self): - kernelDirs = self.Get('cl_kernel_config_path') - if not access(kernelDirs,R_OK): - return "" - configName = "config-%(system)s-%(march)s-%(ver)s" % \ - {'system':self.Get('os_linux_system'), - 'march':self.Get('os_arch_machine'), - 'ver':self.Get('cl_kernel_version')} - if path.exists(configName): - return path.join(kernelDirs,configName) - return "" diff --git a/pym/cl_kernel.py b/pym/cl_kernel.py deleted file mode 100644 index 755d81b..0000000 --- a/pym/cl_kernel.py +++ /dev/null @@ -1,73 +0,0 @@ -#-*- coding: utf-8 -*- - -# Copyright 2010 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. - -__version__ = "2.2.0.0" -__app__ = "calculate-builder" - -import os -import re -import sys -import traceback -from os import path -from cl_utils import process -from cl_print import color_print -from cl_datavars import DataVars - -from cl_kernel_utils import KernelConfig,InitRamFs - -from cl_lang import lang - -class printNoColor: - def colorPrint(self,attr,fg,bg,string): - sys.stdout.write(string) - -class DataVarsBuilder(DataVars): - """Variable class for installation""" - - def importBuilder(self, **args): - '''Get variables for builder''' - # section name in calculate.env - envSection = "builder" - # import builder variables - self.importData(envSection, ('cl_vars_builder','cl_fill_builder')) - -class cl_kernel(color_print): - """Primary class for kernel manipulation""" - - def __init__(self): - self.clVars = None - self.startMessage = "" - - def _testKernelDirectory(self,dirpath): - """Test directory for kernel sources""" - makefilepath = path.join(dirpath,'Makefile') - kbuildpath = path.join(dirpath,'Kbuild') - if not path.exists(makefilepath) \ - or not path.exists(kbuildpath) \ - or not "Kbuild for top-level directory of the kernel" in \ - open(kbuildpath,'r').read(): - return False - return True - - def setNoColor(self): - self.color = False - - def initVars(self): - """Primary initialization of variables""" - self.clVars = DataVarsBuilder() - self.clVars.importBuilder() - self.clVars.flIniFile() - diff --git a/pym/cl_kernel_cmd.py b/pym/cl_kernel_cmd.py deleted file mode 100644 index 0896be6..0000000 --- a/pym/cl_kernel_cmd.py +++ /dev/null @@ -1,129 +0,0 @@ -#-*- coding: utf-8 -*- - -# Copyright 2010 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. - -from cl_kernel import cl_kernel, __app__, __version__ -from cl_opt import opt -from cl_share_cmd import share_cmd -from os import path -from os import access,R_OK -import re -import sys - -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) - -DESCRIPTION = _("The Calculate Linux kernel builder") -CMD_OPTIONS = [{'shortOption':"c", - 'longOption':"kernel-config", - 'optVal':"FILE", - 'help':_("Kernel configuration file to use for compilation") - }, - {'longOption':"dmraid", - 'help':_("Include DMRAID support") - }, - {'shortOption':"e", - 'longOption':"extraversion", - 'optVal':"VER", - 'help':_("Specify extraversion for kernel") - }, - {'shortOption':"k", - 'longOption':"kerneldir", - 'optVal':"DIR", - 'help':_("Location of the kernel sources") - }, - {'longOption':"lvm", - 'help':_("Include LVM support") - }, - { 'longOption':"mdadm", - 'help':_("Copy /etc/mdadm.conf to initramfs") - }, - {'shortOption':"m", - 'longOption':"menuconfig", - 'help':_("Run menuconfig after oldconfig") - }, - {'longOption':"no-clean", - 'help':_("Do not run make clean before compilation") - }, - {'shortOption':"o", - 'longOption':"use-own-config", - 'help':_("Use config from kernel directory") - }, - {'shortOption':"q", - 'help':_("Do not display kernel compilation process") - }] - - -class kernel_cmd(share_cmd): - """Class for work with cl_install by console""" - def __init__(self): - self.optobj = opt(package=__app__, - version=__version__, - description=DESCRIPTION, - option_list= CMD_OPTIONS + opt.variable_control + - opt.color_control, - check_values=self.checkOpts) - self.logicObj = cl_kernel() - - def _getNamesAllSetOptions(self): - """Get list set options""" - setOptDict = self.optobj.values.__dict__.items() - defaultOptDict = self.optobj.get_default_values().__dict__.items() - return reduce(lambda x,y: x+[y[0][0]], - filter(lambda x:x[0][1] != x[1][1], - zip(setOptDict,defaultOptDict)), []) - - def getStringIncompatibleOptions(self,listOpt): - """Форматированная строка несовместимых опций разделенных ','""" - return ", ".join(map(lambda x: len(x) == 1 and "'-%s'"%x or "'--%s'"%x, - listOpt)) - - def checkIncompatibleLive(self): - """Check incompatible options for option --live""" - incompatible = list(set(self._getNamesAllSetOptions()) & - set(self.optionsLiveIncompatible)) - if incompatible: - self.optobj.error(_("incompatible options")+":"+" %s"\ - %self.getStringIncompatibleOptions(incompatible+["live"])) - - def checkOpts(self, values, args): - """Check values all specified options.""" - if values.k: - if not self.logicObj._testKernelDirectory(values.k): - self.optobj.error("%s:'%s'"% - (_("Wrong kernel source directory"),values.k)) - else: - self.logic.clVars.Set('os_kernel_directory',values.k,True) - if values.c and values.o: - self.optobj.error(self.getStringIncompatibleOptions(["c","o"])) - if values.c: - if not path.exists(values.c): - self.optobj.error(_("Kernel config '%s' not found")%values.c) - else: - self.logic.clVars.Set('os_kernel_config',values.c,True) - elif values.o: - if not path.exists( - path.join(self.logic.clVars.Get('os_kernel_directory'), - ".config")): - self.optobj.error(_("Kernel directory has not config")) - else: - self.logic.clVars.Set('os_kernel_config', - path.join(self.logic.clVars.Get('os_kernel_directory'), - ".config.bak"),True) - - return (values, args) - - def makeKernel(self): - return self.logicObj.makeKernel() diff --git a/pym/cl_share_cmd.py b/pym/cl_share_cmd.py deleted file mode 100644 index 0fbfdf3..0000000 --- a/pym/cl_share_cmd.py +++ /dev/null @@ -1,87 +0,0 @@ -#-*- coding: utf-8 -*- - -# Copyright 2010 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 -import os - -from cl_print import color_print -from cl_utils import _error - -# Перевод сообщений для программы -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) - -class share_cmd(color_print, _error): - """Класс общих методов обработки опций командной строки""" - def isRoot(self, printError=True): - """Detect root user""" - if os.getuid() == 0 and os.getgid() == 0: - return True - else: - if printError: - self.printERROR(_("The user is not root")) - return False - - def printVars(self, optObj): - """Process displaying variables""" - if optObj.v: - varsFilter = None - varsNames = [] - format = "default" - # Фильтрование переменных - if "filter" in optObj.__dict__.keys() and optObj.filter: - optCmd = optObj.filter - if ',' in optCmd: - varsNames = optCmd.split(",") - elif '*' in optCmd: - varsFilter = optCmd.replace("*", ".*") - else: - varsNames.append(optCmd) - if "xml" in optObj.__dict__.keys() and optObj.xml: - format = "xml" - self.logicObj.clVars.printVars(varsFilter, varsNames, - outFormat=format) - - def setVars(self, optObj): - """Установка переменных""" - if optObj.set: - for vals in optObj.set: - for val in vals.split(','): - k,o,v = val.partition('=') - if self.logicObj.clVars.exists(k): - if not self.logicObj.clVars.SetWriteVar(k,v): - return False - else: - self.printERROR(_('variable %s not found')%k) - return False - return True - - def writeVars(self, optObj): - """Запись переменных""" - if not self.logicObj.clVars.WriteVars(header="install"): - errMsg = self.getError() - if errMsg: - self.printERROR(errMsg.strip()) - self.printERROR(_('Can not write template variables')) - return False - return True - - def setPrintNoColor(self, optObj): - """Установка печати сообщений без цвета""" - if optObj.color and optObj.color=="never": - color_print.colorPrint = lambda *arg : sys.stdout.write(arg[-1]) or\ - sys.stdout.flush() - diff --git a/pym/cl_vars_builder.py b/pym/cl_vars_builder.py deleted file mode 100644 index 99cf77b..0000000 --- a/pym/cl_vars_builder.py +++ /dev/null @@ -1,41 +0,0 @@ -#-*- coding: utf-8 -*- - -# Copyright 2010 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. - -#Допустимые ключи значений -# mode - read only or writeable variable -# value - default variable value -# select - list of posible values for variable -# official - flag, if it is True, then the variable is not printable -# printval - print value of variable -from cl_install import __version__, __app__ - -class Data: - # relative path for apply templates on files of system - cl_root_path = {} - - # program name - cl_name = {'value':__app__} - - # program version - cl_ver = {'value':__version__} - - cl_kernel_directory = {} - - cl_kernel_config = {} - - cl_kernel_config_path = {'mode':'w', - 'value':'/var/lib/layman/calculate/profiles/kernel'} - - cl_kernel_version = {} diff --git a/scripts/cl-builder b/scripts/cl-builder deleted file mode 100755 index eed6b36..0000000 --- a/scripts/cl-builder +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------ -# cl-builder -# Copyright ©2009 Mir Calculate Ltd. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------ - -# выбор строки перемонтирования разделов в зависимости от используемого модуля -BUILDER=/mnt/builder -if [[ -n `mount | grep " / type aufs"` ]]; -then - REMOUNT="mount -t aufs -o remount,br:/ none /" - REMOUNTBUILDER="mount -t aufs -o remount,br:/ none $BUILDER" -else - REMOUNT="mount -t unionfs -o remount,dirs=/ unionfs /" - REMOUNTBUILDER=":" -fi -TIMERUN=`date +%s` -EMERGELOG=${BUILDER}/var/log/emerge.log -TAILEMERGELOG="tail -f ${EMERGELOG}" - -#------------------------------------------------------------------------------ -# Обновление Unionfs в течение сборки пакетов -#------------------------------------------------------------------------------ -watching() { - $TAILEMERGELOG | - while read line; - do - if [ `echo "$line" | awk -F: '{print $1;}'` -ge $TIMERUN ] && - [ "`echo "$line" | grep -e "unemerge success" -e "completed emerge"`" ] - then - $REMOUNT &>/dev/null - fi - done -} - -#------------------------------------------------------------------------------ -# Монтируем ресурсы -#------------------------------------------------------------------------------ -mountres() { - mount -o bind /var/calculate/remote ${BUILDER}/var/calculate/remote - mount -o bind /usr/calculate/share ${BUILDER}/usr/calculate/share - mount -t proc none ${BUILDER}/proc && mount -o bind /dev ${BUILDER}/dev && - mount -t sysfs none ${BUILDER}/sys && - mount -o bind /dev/pts ${BUILDER}/dev/pts && return 0 - return 1 -} - -#------------------------------------------------------------------------------ -# Выполним emerge -#------------------------------------------------------------------------------ -runchroot() { - touch $EMERGELOG - watching & 2>/dev/null - chroot $BUILDER /bin/bash --rcfile /usr/calculate/install/config/chroot.rc - WATCHINGPID=`ps axo pid,cmd | sed -nr "s|^\s*([0-9]+)\s+${TAILEMERGELOG}.*|\1|p"` - [ "${WATCHINGPID}" ] && kill -9 $WATCHINGPID &>/dev/null - $REMOUNT &>/dev/null -} - -#------------------------------------------------------------------------------ -# Отмонтируем ресурсы -#------------------------------------------------------------------------------ -umountres() { - # перебираем строку в обратном порядке - MOUNTDIRS=`mount | grep -Po "${BUILDER}/[^ ]+" | sed "{N;s/\n/ /}"` - for MOUNTDIR in $( echo $MOUNTDIRS | rev ) - do - umount $(echo $MOUNTDIR | rev) || exit - done -} - - -#------------------------------------------------------------------------------ -# Выполним проверки -#------------------------------------------------------------------------------ -checkrun() { - if [[ `/usr/bin/id -u` -ne 0 ]] - then - echo "Only root can perform system building." - exit; - fi - #не запустим если загрузка не в Scrach режиме - if ! mount | grep /mnt/scratch &>/dev/null - then - echo "This program only works in the system, installed by Calculate with the option '--build'." - exit; - fi - - #не запустим второй раз - if mount | grep "/dev/pts on /mnt/builder/dev/pts " &>/dev/null - then - if [ `ps ax | grep -v grep | grep -c "/bin/bash /usr/bin/cl-builder"` -gt 3 ]; - then - echo "This program is already run." - exit; - else - umountres - fi - fi - - #не запустим из chroot - if [ `mount | grep -c "devpts on /dev/pts "` -ne 1 ]; - then - echo "This program can't be run from Scratch layer." - exit; - fi -} - -#------------------------------------------------------------------------------ -# Выполним предварительные настройки -#------------------------------------------------------------------------------ -configure() { - # Перенесем resolv.conf - if [ -f /etc/resolv.conf ] - then - mkdir -p ${BUILDER}/etc - cp /etc/resolv.conf ${BUILDER}/etc/ - fi -} - -checkrun -configure -$REMOUNTBUILDER &>/dev/null -mountres && runchroot -umountres - -ROOTDIR=/ -UPDATE_DIRS="/boot /lib/modules /lib/firmware" -#------------------------------------------------------------------------------ -# Ask: whether to replace the old file -#------------------------------------------------------------------------------ -ask_replace() { - [[ $REPLACE_ANSWER == "yes" ]] && return 0 - [[ $REPLACE_ANSWER == "no" ]] && return 1 - local destfile=$1 - echo "File '$destfile' in builder is newer than in workspace" - local line - while true - do - echo -n "Do you want replace old file (Yes/No/All/None):" - read line <&1 - case $line in - All|all) REPLACE_ANSWER=yes;return 0;; - None|none) REPLACE_ANSWER=no;return 1;; - Y*|y*) return 0 ;; - N*|n*) return 1 ;; - esac - done -} - -#------------------------------------------------------------------------------ -# Compare modify time of the first and second file -#------------------------------------------------------------------------------ -test_newer() { - # [[ file1 -nt file2 ]] not correct work with symbolic link, because - # get modify time of target file - if [[ -L $1 || -L $2 ]] - then - [[ `stat -c %Y $1` -gt `stat -c %Y $2` ]] - else - [[ $1 -nt $2 ]] - fi -} - -#------------------------------------------------------------------------------ -# Compare modify time, ask user for update and update file -#------------------------------------------------------------------------------ -try_update_file() { - [[ -e $2 || -L $2 ]] && test_newer $1 $2 && - ask_replace $2 && cp -P $1 $2 -} - -#------------------------------------------------------------------------------ -# Find in first directory files and symbolic links with modify time great than -# same files in the second directory -#------------------------------------------------------------------------------ -update_from_builder() { - basesrc=${1%/} - basedest=${2%/} - shift 2 - for place in $* - do - src=$basesrc/${place#/} - dest=$basedest/${place#/} - find $src -type f -o -type l | - while read srcfile; - do - dstfile=${dest}/${srcfile#${src}/} - try_update_file $srcfile $dstfile - done - done -} - -update_from_builder $BUILDER $ROOTDIR $UPDATE_DIRS diff --git a/scripts/cl-kernel b/scripts/cl-kernel deleted file mode 100644 index 427edbc..0000000 --- a/scripts/cl-kernel +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -#-*- coding: utf-8 -*- - -# Copyright 2010 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 -import os -from os import path -sys.path.insert(0, path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym')) -sys.path.insert(0, path.abspath('/usr/lib/calculate-2.2/calculate-install/pym')) -sys.path.insert(0, path.abspath('/usr/lib/calculate-2.2/calculate-builder/pym')) - -from cl_kernel_cmd import kernel_cmd - -from cl_lang import lang -tr = lang() -tr.setGlobalDomain('cl_builder') -tr.setLanguage(sys.modules[__name__]) - -if __name__ == "__main__": - kernel = kernel_cmd() - kernel.logicObj.initVars() - # set lang - ret = kernel.optobj.parse_args() - if ret is False: - sys.exit(1) - options, args = ret - # set color/nocolor for display messages - kernel.setPrintNoColor(options) - # set values to variables - if not kernel.setVars(options): - sys.exit(1) - # print variables - if options.v or options.filter or options.xml: - kernel.printVars(options) - sys.exit(0) - # check root - if not kernel.isRoot(): - sys.exit(1) - - if not kernel.makeKernel(): - sys.exit(1) - - sys.exit(0) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5f5b0f1..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[install] -install-scripts=/usr/bin -install-purelib=/usr/lib/calculate-2.2 -install-platlib=/usr/lib/calculate-2.2 -#install-data=/usr/lib/calculate-2.2/calculate-builder diff --git a/setup.py b/setup.py index 271b59e..e537cd9 100755 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # -*- coding: utf-8 -*- # setup.py --- Setup script for calculate-builder -# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org +# 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. @@ -17,63 +17,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import stat -from distutils.core import setup, Extension -from distutils.command.install_data import install_data +__app__ = "calculate-builder" +__version__ = "3.4.0_alpha1" -data_files = [] - -var_data_files = [] - -share_calculate_dir = "/usr/share/calculate" -data_dirs_share = ['i18n'] - - -def __scanDir(scanDir, prefix, replace_dirname, dirData, flagDir=False): - """Scan directory""" - files = [] - dirs = [] - if flagDir or stat.S_ISDIR(os.stat(scanDir)[stat.ST_MODE]): - for fileOrDir in os.listdir(scanDir): - absPath = os.path.join(scanDir,fileOrDir) - statInfo = os.stat(absPath)[stat.ST_MODE] - if stat.S_ISREG(statInfo): - files.append(absPath) - elif stat.S_ISDIR(statInfo): - dirs.append(absPath) - if replace_dirname: - listDirs = list(scanDir.partition("/"))[1:] - listDirs.insert(0,replace_dirname) - scanDir = "".join(listDirs) - if prefix: - scanDir = os.path.join(prefix,scanDir) - dirData.append((scanDir, files)) - for sDir in dirs: - __scanDir(sDir, prefix, replace_dirname,dirData, True) - return dirData - -def create_data_files(data_dirs, prefix="", replace_dirname=""): - """Create data_files""" - data_files = [] - for data_dir in data_dirs: - data = [] - data_files += __scanDir(data_dir, prefix, replace_dirname, data) - return data_files - -data_files += create_data_files (data_dirs_share, share_calculate_dir) +from distutils.core import setup setup( - name = 'calculate-builder', - version = "2.2.0", - description = "Calculate Linux builder", - author = "Calculate Ltd.", - author_email = "support@calculate.ru", - url = "http://calculate-linux.org", - license = "http://www.apache.org/licenses/LICENSE-2.0", - package_dir = {'calculate-builder': "."}, - packages = ['calculate-builder.pym'], - data_files = data_files, - scripts=["./scripts/cl-kernel", - "./scripts/cl-builder"] -) + name=__app__, + version=__version__, + description="Update system utilities", + author="Calculate Ltd.", + author_email="support@calculate.ru", + url="http://calculate-linux.org", + license="http://www.apache.org/licenses/LICENSE-2.0", + package_dir={'calculate.builder': "builder"}, + packages=['calculate.builder', 'calculate.builder.utils', + 'calculate.builder.variables'])