Change copyrights. Add install.

netsetup
Mike Hiretsky 14 years ago
parent c36921e467
commit 45206a50e5

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

@ -1,5 +1,19 @@
#-*- 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 os.path import exists as pathexists
from os.path import dirname as pathdirname
from os.path import join as pathjoin

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.
@ -36,8 +36,7 @@ class fillVars(object, glob_attr):
def get_cl_install_merge_action(self):
"""Need perform templates for install:merge or install:unmerge"""
actionsMap = {'merge':'up',
'system':'up',
'unmerge':'down'}
'system':'up'}
cl_action = self.Get('cl_action')
return actionsMap[cl_action] if cl_action in actionsMap else ""
@ -876,3 +875,4 @@ class fillVars(object, glob_attr):
def get_os_install_initrd_install(self):
return self.getInitrd(suffix="install")

@ -22,7 +22,8 @@ import re
import sys
import traceback
from os.path import exists as pathexists,join as pathjoin
from cl_utils import runOsCommand
from cl_utils import runOsCommand,appendProgramToEnvFile, \
removeProgramToEnvFile
import cl_overriding
@ -580,7 +581,6 @@ class convertDictOpt:
class cl_install(color_print):
"""Primary class for templates appling and system installation"""
def __init__(self):
self.clVars = None
@ -1161,16 +1161,19 @@ class cl_install(color_print):
self.printRight(self.lenString(message)+5,4)
self.startMessage = True
def printByResult(self,result):
def printByResult(self,result,failMessage=None):
if result:
self.printLine((('blueBr','['),
('greenBr',' ok '),
('blueBr',']')),[],printBR=False)
self.defaultPrint("")
else:
self.printLine((('blueBr','['),
('redBr',' !! '),
('blueBr',']')),[],printBR=False)
self.defaultPrint("")
self.defaultPrint("")
if failMessage:
self.printERROR(failMessage)
self.startMessage = False
def setupOpenGL(self):
@ -1459,3 +1462,80 @@ the system") + " (yes/no)"
self.clVars.Set('os_install_locale_xkb',
locale.getFieldByLang('xkblayout',lang), True)
return True
def installOverlay(self):
return True
#res,mes = runOsCommand('layman -l -N')
#notempty = lambda x:x
#if res == 0:
#
# map(lambda x:x[0],
# filter(lambda x:x,
# map(lambda x:filter(lambda x:x,x.split())[1:2],
# mes)))
# return True
#else:
# raise InstallError(_("Cann't get list layman overlays"))
def installPackage(self):
"""Install this package. Convert Gentoo system to Calculate"""
error = None
self.printSUCCESS(_('Package installation'))
try:
self.printMessageForTest(
_("Link calculate-install to package configuration"))
self.printByResult(appendProgramToEnvFile(__app__, self.clVars),
failMessage=
_("Can not save '%s' to %s")%(__app__,
self.clVars.Get("cl_env_path")[0]))
except (InstallError,DistributiveError),e:
error = e
except (Exception),e:
error = ""
for i in apply(traceback.format_exception, sys.exc_info()):
error += i
except KeyboardInterrupt,e:
if self.startMessage:
self.printByResult(False)
self.defaultPrint("\n")
error = _("Package installation manually interrupt")
if self.startMessage:
self.printByResult(False)
if error:
for line in filter(lambda x: x,str(error).split('\n')):
self.printERROR(line)
self.printERROR(_("Package installation failed"))
return False
return True
def uninstallPackage(self):
"""Uninstall this package. Convert Calculate system to Gentoo"""
error = None
self.printSUCCESS(_('Package uninstallation'))
try:
self.printMessageForTest(
_("Unlink calculate-install from package configuration"))
self.printByResult(removeProgramToEnvFile(__app__, self.clVars),
failMessage=
_("Can not remove '%s' to %s")%(__app__,
self.clVars.Get("cl_env_path")[0]))
except (InstallError,DistributiveError),e:
error = e
except (Exception),e:
error = ""
for i in apply(traceback.format_exception, sys.exc_info()):
error += i
except KeyboardInterrupt,e:
if self.startMessage:
self.printByResult(False)
self.defaultPrint("\n")
error = _("Package uninstallation manually interrupt")
if self.startMessage:
self.printByResult(False)
if error:
for line in filter(lambda x: x,str(error).split('\n')):
self.printERROR(line)
self.printERROR(_("Package uninstallation failed"))
return False
return True

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.
@ -78,6 +78,12 @@ CMD_OPTIONS = [{'shortOption':"d",
{'longOption':"ntp",
'optVal':"NTP",
'help':_("set ntp server for system")
},
{'longOption':"install",
'help':_("convert Gentoo system to Calculate")
},
{'longOption':"uninstall",
'help':_("convert Calculate system to Gentoo")
}
]
#{'shortOption':"b",
@ -99,32 +105,41 @@ class install_cmd(cl_install,share_cmd):
self.optionsLiveIncompatible = ["d", "b", "mbr", "w", "f", "s"]
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)),
[])
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 checkIncompatibeLive(self):
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 checkIncompatibleInstallUninstall(self):
"""Check incompatible options for options --install and --uninstall"""
opts = self._getNamesAllSetOptions()
if len(opts)>2:
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(opts))
def checkOpts(self, values, args):
"""Check values all specified options."""
if len(args) > 0:
self.optobj.error(_("unrecognized option") + ": %s"% "".join(args))
if values.live:
self.checkIncompatibeLive()
self.checkIncompatibleLive()
elif values.install or values.uninstall:
self.checkIncompatibleInstallUninstall()
else:
if values.v is False and \
values.d is None and not self.detectPreviousSystem():

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.
@ -31,9 +31,6 @@ class Data:
# program version
cl_ver = {'value':__version__}
# work action
cl_action = {'value':'merge'}
# need perform templates for install:merge or install:unmerge
cl_install_merge_action = {}

@ -1,7 +1,7 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.
@ -59,13 +59,19 @@ if __name__ == "__main__":
#if not install.applyTemplatesForSystem():
#sys.exit(1)
#else:
if not options.live:
if not install.installSystem(force=options.f, bootDisk=options.mbr,
users=options.u):
if options.live:
if not install.configureSystem():
sys.exit(1)
elif options.install:
if not install.installPackage():
sys.exit(1)
elif options.uninstall:
if not install.uninstallPackage():
sys.exit(1)
else:
if not install.configureSystem():
if not install.installSystem(force=options.f, bootDisk=options.mbr,
users=options.u):
sys.exit(1)
if not install.writeVars(options):
sys.exit(1)
#if not install.writeVars(options):
# sys.exit(1)
sys.exit(0)

@ -1,7 +1,7 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

@ -3,7 +3,7 @@
# setup.py --- Setup script for calculate-install
# Copyright 2010 Mir Calculate Ltd. http://www.calculate-linux.org
# 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.

Loading…
Cancel
Save