parent
f533d90139
commit
5b81189ab1
@ -0,0 +1,74 @@
|
||||
#-*- 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_builder import cl_builder, __app__, __version__
|
||||
from cl_opt import opt
|
||||
from cl_share_cmd import share_cmd
|
||||
import os
|
||||
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 image builder")
|
||||
CMD_OPTIONS = []
|
||||
USAGE = _("%prog [options] iso|squash")
|
||||
|
||||
class image_cmd(share_cmd):
|
||||
"""Class for work with cl_builder by console"""
|
||||
def __init__(self):
|
||||
self.optobj = opt(package=__app__,
|
||||
version=__version__,
|
||||
description=DESCRIPTION,
|
||||
usage=USAGE,
|
||||
option_list= CMD_OPTIONS + opt.variable_control +
|
||||
opt.color_control,
|
||||
check_values=self.checkOpts)
|
||||
self.logicObj = cl_builder()
|
||||
self.commands = ["iso","squash"]
|
||||
#self.optionsInitrdIncompatible = ["o","no_clean","m","mdadm","lvm",
|
||||
# "k", "e","dmraid","c","ebuild",
|
||||
# "symlink"]
|
||||
|
||||
def checkOpts(self, values, args):
|
||||
"""Check values all specified options."""
|
||||
if len(args) > 1:
|
||||
self.optobj.error(_("unrecognized option") + ": %s"% "".join(args))
|
||||
if len(args) < 1 and not values.v:
|
||||
self.optobj.error(_("missing command argument"))
|
||||
if args and not args[0] in self.commands:
|
||||
self.optobj.error(_("invalid command: '%s' (choose from %s)")%
|
||||
(args[0],", ".join(map(lambda x:"'%s'"%x,self.commands))))
|
||||
self.logicObj.clVars.Set('cl_action',args[0],True)
|
||||
|
||||
self.optobj.checkVarSyntax(values)
|
||||
return (values, args)
|
||||
|
||||
def performActionByCommand(self,options,args):
|
||||
action = {'iso':self.makeIso,
|
||||
'squash':self.makeSquash}
|
||||
action[args[0]](options)
|
||||
|
||||
def makeIso(self,options):
|
||||
"""Set specified kernel to default"""
|
||||
return True
|
||||
|
||||
def makeSquash(self,options):
|
||||
"""Set specified kernel to default"""
|
||||
return True
|
@ -0,0 +1,54 @@
|
||||
#!/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_image_cmd import image_cmd
|
||||
|
||||
from cl_lang import lang
|
||||
tr = lang()
|
||||
tr.setGlobalDomain('cl_builder')
|
||||
tr.setLanguage(sys.modules[__name__])
|
||||
|
||||
if __name__ == "__main__":
|
||||
image = image_cmd()
|
||||
image.logicObj.initVars()
|
||||
# set lang
|
||||
ret = image.optobj.parse_args()
|
||||
if ret is False:
|
||||
sys.exit(1)
|
||||
options, args = ret
|
||||
# set color/nocolor for display messages
|
||||
image.setPrintNoColor(options)
|
||||
# set values to variables
|
||||
if not image.setVars(options):
|
||||
sys.exit(1)
|
||||
# print variables
|
||||
if options.v or options.filter or options.xml:
|
||||
image.printVars(options)
|
||||
sys.exit(0)
|
||||
# check root
|
||||
if not image.isRoot():
|
||||
sys.exit(1)
|
||||
if not image.performActionByCommand(options,args):
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
Loading…
Reference in new issue