Add update option.

netsetup
Mike Hiretsky 13 years ago
parent 9a9de3cad3
commit 01fbd54eb9

Binary file not shown.

@ -135,7 +135,10 @@ class DistributiveRepository:
# may be directory is isodir (directory which contains iso image) # may be directory is isodir (directory which contains iso image)
extname = "isodir" extname = "isodir"
try: try:
distr = IsoDistributive(filename) if filename.startswith('/dev'):
distr = PartitionDistributive(filename)
else:
distr = IsoDistributive(filename)
filename = distr.convertToDirectory().directory filename = distr.convertToDirectory().directory
except Exception,e: except Exception,e:
extname = "dir" extname = "dir"

@ -1291,14 +1291,19 @@ class fillVars(object, glob_attr):
self.Get('cl_image_path'), self.Get('cl_image_path'),
self.Get('os_install_arch_machine'), self.Get('os_install_arch_machine'),
self.Get('os_install_linux_shortname')) self.Get('os_install_linux_shortname'))
if imagename in ('/mnt/flash', '/mnt/squash',
'/mnt/livecd', '/mnt/cdrom'):
return self.Get('os_linux_build')
if imagename: if imagename:
d = DistributiveRepository()._getfromcontent(imagename)
if d and "build" in d:
build = d['build']
return build
res = DistributiveRepository.reDistName.search(imagename) res = DistributiveRepository.reDistName.search(imagename)
if res: if res:
build = res.groupdict()['ver'] build = res.groupdict()['ver']
if re.match('^\d{8}$',build): if re.match('^\d{8}$',build):
return build return build
if imagename in ('/mnt/flash', '/mnt/squash', '/mnt/livecd', '/mnt/cdrom'):
return self.Get('os_linux_build')
return "" return ""
def get_os_device_partition(self): def get_os_device_partition(self):

@ -25,7 +25,8 @@ from os import path
from cl_utils import runOsCommand,appendProgramToEnvFile, \ from cl_utils import runOsCommand,appendProgramToEnvFile, \
removeProgramToEnvFile,pathJoin, \ removeProgramToEnvFile,pathJoin, \
scanDirectory,process,getTupleVersion, \ scanDirectory,process,getTupleVersion, \
detectDeviceForPartition,listDirectory detectDeviceForPartition,listDirectory, \
cmpVersion
from cl_kernel_utils import KernelConfig,InitRamFs from cl_kernel_utils import KernelConfig,InitRamFs
@ -801,7 +802,35 @@ class cl_install(color_print, SignalInterrupt):
else: else:
return dirsFiles return dirsFiles
def printInfo(self): def cmpInstallVersion(self):
"""Compare current and install version(build)
Return:
1 - new version above current and installed
0 - new version equal current or installed
-1 - new version less current or installed
-2 - installed versin above current and new
"""
rootdev = self.clVars.Get('os_install_root_dev')
d = DistributiveRepository()._getfromcontent(rootdev)
curver = self.clVars.Get('os_linux_ver')
curbuild = self.clVars.Get('os_linux_build')
curver = (getTupleVersion(curver),curbuild)
nextver = self.clVars.Get('os_install_linux_ver')
nextbuild = self.clVars.Get('os_install_linux_build')
nextver = (getTupleVersion(nextver),nextbuild)
curnextres = cmp(nextver,curver)
if d and "ver" in d:
installedver = (getTupleVersion(d["ver"]),
d["build"])
if installedver > curver:
instnextres = cmp(nextver,installedver)
if instnextres <= 0 and curnextres == 1:
return -2
return instnextres
return curnextres
def printInfo(self,update=False):
self.printSUCCESS(_("Installation") + " Calculate Linux") self.printSUCCESS(_("Installation") + " Calculate Linux")
self.defaultPrint("%s\n"%_("System information")) self.defaultPrint("%s\n"%_("System information"))
self.printSUCCESS(_("Computer name")+": %s"% self.printSUCCESS(_("Computer name")+": %s"%
@ -871,13 +900,18 @@ class cl_install(color_print, SignalInterrupt):
if buildvar: if buildvar:
build = " (build %s)"%buildvar build = " (build %s)"%buildvar
if self.clVars.Get('cl_image'): if update:
cmpres = self.cmpInstallVersion()
if self.clVars.Get('cl_image') and ( not update or cmpres > 0):
self.printSUCCESS(_("Found update")+": %s %s%s%s\n"% self.printSUCCESS(_("Found update")+": %s %s%s%s\n"%
(self.clVars.Get('os_install_linux_name'), (self.clVars.Get('os_install_linux_name'),
self.clVars.Get('os_install_linux_ver'), self.clVars.Get('os_install_linux_ver'),
subname,build)) subname,build))
else: else:
self.printWARNING(_("No update available.")) if update and cmpres == -2:
self.printWARNING(_("Update already has installed."))
else:
self.printWARNING(_("No update available."))
def prepareBoot(self,targetDistr): def prepareBoot(self,targetDistr):
"""Prepare system for boot""" """Prepare system for boot"""
@ -1834,7 +1868,7 @@ class cl_install(color_print, SignalInterrupt):
self.printByResult(True) self.printByResult(True)
def installSystem(self, force=False, bootDisk=None, stdinReadPwd=False, def installSystem(self, force=False, bootDisk=None, stdinReadPwd=False,
builder=False, flagSpinner=True): builder=False, flagSpinner=True, update=False):
"""install System by current variable enviroment""" """install System by current variable enviroment"""
sourceDistr = None sourceDistr = None
targetDistr = None targetDistr = None
@ -1851,7 +1885,7 @@ class cl_install(color_print, SignalInterrupt):
rootPartIsFormat=rootPartCmdDict['isFormat'] rootPartIsFormat=rootPartCmdDict['isFormat']
rootPartSystemId=rootPartCmdDict['systemId'] rootPartSystemId=rootPartCmdDict['systemId']
self.printInfo() self.printInfo(update=update)
targetDistr = self.getTargetDistributive(rootPartdev, targetDistr = self.getTargetDistributive(rootPartdev,
buildermode=builder, buildermode=builder,
@ -1869,7 +1903,7 @@ class cl_install(color_print, SignalInterrupt):
_("Installation is supported for system not less version" _("Installation is supported for system not less version"
" %s")%minver) " %s")%minver)
distName = "" distName = ""
if distName: if distName and (not update or self.cmpInstallVersion()>0):
# print info # print info
sourceDistr = distRep.getDistributiveByFile(distName) sourceDistr = distRep.getDistributiveByFile(distName)
if not force: if not force:

@ -102,6 +102,9 @@ CMD_OPTIONS = [{'shortOption':"d",
'help':_("do not use UUID") 'help':_("do not use UUID")
}, },
{'longOption':'set'}, {'longOption':'set'},
{'shortOption':"U",
'longOption':"update",
'help':_("install only newer images")},
{'shortOption':"f", {'shortOption':"f",
'longOption':"force", 'longOption':"force",
'help':_("no questions during the install process") 'help':_("no questions during the install process")
@ -139,7 +142,7 @@ class install_cmd(share_cmd):
self.logicObj = cl_install() self.logicObj = cl_install()
# names incompatible options with --live # names incompatible options with --live
self.optionsLiveIncompatible = ["type","d", "b", "mbr", self.optionsLiveIncompatible = ["type","d", "b", "mbr",
"w", "f", "s","install","uninstall","build","u"] "w", "f","U", "s","install","uninstall","build","u"]
def _getNamesAllSetOptions(self): def _getNamesAllSetOptions(self):
"""Get list set options""" """Get list set options"""
@ -388,11 +391,12 @@ class install_cmd(share_cmd):
return False return False
def installSystem(self, force=False, bootDisk=None, users=[], def installSystem(self, force=False, bootDisk=None, users=[],
stdinReadPwd=False, builder=False, flagSpinner=True): stdinReadPwd=False, builder=False, flagSpinner=True,
update=False):
"""Run install system""" """Run install system"""
if self.logicObj.installSystem(force=force, bootDisk=bootDisk, if self.logicObj.installSystem(force=force, bootDisk=bootDisk,
stdinReadPwd=stdinReadPwd, builder=builder, stdinReadPwd=stdinReadPwd, builder=builder,
flagSpinner=flagSpinner): flagSpinner=flagSpinner,update=update):
self.defaultPrint("\n") self.defaultPrint("\n")
self.defaultPrint(_("To apply changes you have to reboot")+".\n") self.defaultPrint(_("To apply changes you have to reboot")+".\n")
return True return True

@ -74,7 +74,7 @@ if __name__ == "__main__":
flagSpinner = not options.nospinner flagSpinner = not options.nospinner
if not install.installSystem(force=forceOpions, bootDisk=options.mbr, if not install.installSystem(force=forceOpions, bootDisk=options.mbr,
stdinReadPwd=options.P,builder=options.build, stdinReadPwd=options.P,builder=options.build,
flagSpinner=flagSpinner): flagSpinner=flagSpinner,update=options.U):
sys.exit(1) sys.exit(1)
#if not install.writeVars(options): #if not install.writeVars(options):
# sys.exit(1) # sys.exit(1)

Loading…
Cancel
Save