|
|
|
@ -124,6 +124,22 @@ CMD_OPTIONS = [{'shortOption':"d",
|
|
|
|
|
'optVal':"NTP",
|
|
|
|
|
'help':_("set ntp server for system")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"video",
|
|
|
|
|
'optVal':"VIDEODRV",
|
|
|
|
|
'help':_("set video driver")
|
|
|
|
|
},
|
|
|
|
|
{'shortOption':"X",
|
|
|
|
|
'optVal':"<width>x<height>",
|
|
|
|
|
'help':_("set Xorg resolution")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"fb",
|
|
|
|
|
'optVal':"<width>x<height>",
|
|
|
|
|
'help':_("set frame buffer resolution")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"timezone",
|
|
|
|
|
'optVal':"TIMEZONE",
|
|
|
|
|
'help':_("set timezone")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"nouuid",
|
|
|
|
|
'help':_("do not use UUID")
|
|
|
|
|
},
|
|
|
|
@ -177,6 +193,9 @@ class install_cmd(share_cmd):
|
|
|
|
|
self.optionsStartupIncompatible = ["type","d", "b", "mbr",
|
|
|
|
|
"w", "f","U", "s","install","uninstall","build","u"]
|
|
|
|
|
self.optionsDhcpIncompatible = ["ip","gateway","dns"]
|
|
|
|
|
self.errorWithExample = \
|
|
|
|
|
_("option {optname}: {errormess}:"
|
|
|
|
|
" '{value}' (example: '{example}')")
|
|
|
|
|
|
|
|
|
|
def _getNamesAllSetOptions(self):
|
|
|
|
|
"""Get list set options"""
|
|
|
|
@ -214,6 +233,17 @@ class install_cmd(share_cmd):
|
|
|
|
|
self.optobj.error(_("incompatible options")+":"+" %s"\
|
|
|
|
|
%self.getStringIncompatibleOptions(opts))
|
|
|
|
|
|
|
|
|
|
def __checkByReg(self,reg="",value="",valueopt="",valuename="",example=""):
|
|
|
|
|
"""Check option specifed by value"""
|
|
|
|
|
if value:
|
|
|
|
|
if not re.match(reg,value):
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname=valueopt,
|
|
|
|
|
errormess=_("%s specifing error")%valuename,
|
|
|
|
|
value=value,
|
|
|
|
|
example=example))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkOpts(self, values, args):
|
|
|
|
|
"""Check values all specified options."""
|
|
|
|
|
if len(args) > 0:
|
|
|
|
@ -233,28 +263,36 @@ class install_cmd(share_cmd):
|
|
|
|
|
errMsg = _("incorrect option") + ":" + " %s" %"--xml" +\
|
|
|
|
|
": " + _("use with option '-v'")
|
|
|
|
|
self.optobj.error(errMsg)
|
|
|
|
|
self.__checkByReg(reg="^\d+x\d+$",value=values.X,valueopt="-X",
|
|
|
|
|
valuename=_("X resolution"),example="1024x768")
|
|
|
|
|
self.__checkByReg(reg="^\d+x\d+$",value=values.fb,valueopt="--fb",
|
|
|
|
|
valuename=_("frame buffer resolution"),
|
|
|
|
|
example="1024x768")
|
|
|
|
|
if values.ip:
|
|
|
|
|
for ipaddr in values.ip:
|
|
|
|
|
if not re.match("^(\w+:)?%s$"%iputils.IP_ADDR_NET,ipaddr):
|
|
|
|
|
self.optobj.error(_("option %s:") %"--ip" +\
|
|
|
|
|
" " + _("ip specifing error: '{ip}' "
|
|
|
|
|
"(example: '{example}')").format(\
|
|
|
|
|
ip=ipaddr,example="eth0:192.168.0.21/16"))
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname="--ip",
|
|
|
|
|
errormess=_("%s specifing error")%"ip",
|
|
|
|
|
value=ipaddr,
|
|
|
|
|
example="eth0:192.168.0.21/16"))
|
|
|
|
|
if not values.dns is None:
|
|
|
|
|
if not re.match("(^{0}(,{0})*|)$".format(iputils.IP_ADDR),values.dns):
|
|
|
|
|
self.optobj.error(_("option %s:") %"--dns" +\
|
|
|
|
|
" " + _("dns specifing error: '%s'") %\
|
|
|
|
|
values.dns)
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname="--dns",
|
|
|
|
|
errormess=_("%s specifing error")%"dns",
|
|
|
|
|
value=values.dns,
|
|
|
|
|
example="8.8.8.8"))
|
|
|
|
|
if values.route:
|
|
|
|
|
for route in values.route:
|
|
|
|
|
if not re.match("^({net}|default):(({ipaddr})?"
|
|
|
|
|
"(:\w+(:{ipaddr})?)?)?$".format(
|
|
|
|
|
net=iputils.IP_ADDR_NET,ipaddr=iputils.IP_ADDR),route):
|
|
|
|
|
self.optobj.error(_("option %s:") %"--route" +\
|
|
|
|
|
" " + _("route specifing error: '{route}'"
|
|
|
|
|
"(example: '{example}'").format(
|
|
|
|
|
route=route,
|
|
|
|
|
example="default:192.168.1.1"))
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname="--route",
|
|
|
|
|
errormess=_("%s specifing error")%_("route"),
|
|
|
|
|
value=route,
|
|
|
|
|
example="default:192.168.1.1"))
|
|
|
|
|
if not (values.install or values.uninstall or values.startup):
|
|
|
|
|
if values.v is False and \
|
|
|
|
|
not values.p and \
|
|
|
|
@ -266,17 +304,21 @@ class install_cmd(share_cmd):
|
|
|
|
|
reTrueDisk = re.compile("^[^:]+(:[^:]*){0,3}$")
|
|
|
|
|
wrongValue = filter(lambda x: not reTrueDisk.match(x),values.d)
|
|
|
|
|
if wrongValue:
|
|
|
|
|
self.optobj.error(_("option %s:") %"d" +\
|
|
|
|
|
" " + _("disk specifing error: '%s'")\
|
|
|
|
|
%", ".join(wrongValue))
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname="-d",
|
|
|
|
|
errormess=_("%s specifing error")%_("disk"),
|
|
|
|
|
value=", ".join(wrongValue),
|
|
|
|
|
example="/dev/sda2:/:ext4"))
|
|
|
|
|
# check syntax SWAP_DISK
|
|
|
|
|
if values.w:
|
|
|
|
|
reTrueBind = re.compile("^[^:]+$")
|
|
|
|
|
wrongValue = filter(lambda x: not reTrueBind.match(x),values.w)
|
|
|
|
|
if wrongValue:
|
|
|
|
|
self.optobj.error(_("option %s:") %"w" +\
|
|
|
|
|
" " + _("mount bind specifing error: '%s'")\
|
|
|
|
|
%", ".join(wrongValue))
|
|
|
|
|
self.optobj.error(self.errorWithExample.format(
|
|
|
|
|
optname="-w",
|
|
|
|
|
errormess=_("%s specifing error")%_("disk"),
|
|
|
|
|
value=", ".join(wrongValue),
|
|
|
|
|
example="/dev/sda1"))
|
|
|
|
|
#check boot device
|
|
|
|
|
if values.mbr:
|
|
|
|
|
bootDisk = values.mbr
|
|
|
|
@ -340,6 +382,23 @@ class install_cmd(share_cmd):
|
|
|
|
|
|
|
|
|
|
def setVars(self,options):
|
|
|
|
|
"""Process setting values for variables"""
|
|
|
|
|
values = self.optobj.values
|
|
|
|
|
if values.video:
|
|
|
|
|
if not self.logicObj.setVideo(values.video,
|
|
|
|
|
startup=values.startup):
|
|
|
|
|
return False
|
|
|
|
|
if values.X:
|
|
|
|
|
if not self.clVars.Set('os_install_x11_resolution', values.X,
|
|
|
|
|
force=True):
|
|
|
|
|
return False
|
|
|
|
|
if values.fb:
|
|
|
|
|
if not self.clVars.Set('os_install_fb_resolution',
|
|
|
|
|
"%s-32"%values.fb,
|
|
|
|
|
force=True):
|
|
|
|
|
return False
|
|
|
|
|
if values.timezone:
|
|
|
|
|
if not self.logicObj.setTimezone(values.timezone):
|
|
|
|
|
return False
|
|
|
|
|
if options.set:
|
|
|
|
|
for vals in options.set:
|
|
|
|
|
for val in vals.split(','):
|
|
|
|
|