diff --git a/i18n/cl_install_ru.mo b/i18n/cl_install_ru.mo index 9fe439a..260767d 100644 Binary files a/i18n/cl_install_ru.mo and b/i18n/cl_install_ru.mo differ diff --git a/pym/cl_distr.py b/pym/cl_distr.py index 27586b5..7a47383 100644 --- a/pym/cl_distr.py +++ b/pym/cl_distr.py @@ -135,7 +135,10 @@ class DistributiveRepository: # may be directory is isodir (directory which contains iso image) extname = "isodir" try: - distr = IsoDistributive(filename) + if filename.startswith('/dev'): + distr = PartitionDistributive(filename) + else: + distr = IsoDistributive(filename) filename = distr.convertToDirectory().directory except Exception,e: extname = "dir" diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 5697526..ec9dd8e 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -1291,14 +1291,19 @@ class fillVars(object, glob_attr): self.Get('cl_image_path'), self.Get('os_install_arch_machine'), 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: + d = DistributiveRepository()._getfromcontent(imagename) + if d and "build" in d: + build = d['build'] + return build res = DistributiveRepository.reDistName.search(imagename) if res: build = res.groupdict()['ver'] if re.match('^\d{8}$',build): return build - if imagename in ('/mnt/flash', '/mnt/squash', '/mnt/livecd', '/mnt/cdrom'): - return self.Get('os_linux_build') return "" def get_os_device_partition(self): diff --git a/pym/cl_install.py b/pym/cl_install.py index 5b7d52c..f90f180 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -25,7 +25,8 @@ from os import path from cl_utils import runOsCommand,appendProgramToEnvFile, \ removeProgramToEnvFile,pathJoin, \ scanDirectory,process,getTupleVersion, \ - detectDeviceForPartition,listDirectory + detectDeviceForPartition,listDirectory, \ + cmpVersion from cl_kernel_utils import KernelConfig,InitRamFs @@ -801,7 +802,35 @@ class cl_install(color_print, SignalInterrupt): else: 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.defaultPrint("%s\n"%_("System information")) self.printSUCCESS(_("Computer name")+": %s"% @@ -871,13 +900,18 @@ class cl_install(color_print, SignalInterrupt): if 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.clVars.Get('os_install_linux_name'), self.clVars.Get('os_install_linux_ver'), subname,build)) 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): """Prepare system for boot""" @@ -1834,7 +1868,7 @@ class cl_install(color_print, SignalInterrupt): self.printByResult(True) 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""" sourceDistr = None targetDistr = None @@ -1851,7 +1885,7 @@ class cl_install(color_print, SignalInterrupt): rootPartIsFormat=rootPartCmdDict['isFormat'] rootPartSystemId=rootPartCmdDict['systemId'] - self.printInfo() + self.printInfo(update=update) targetDistr = self.getTargetDistributive(rootPartdev, buildermode=builder, @@ -1869,7 +1903,7 @@ class cl_install(color_print, SignalInterrupt): _("Installation is supported for system not less version" " %s")%minver) distName = "" - if distName: + if distName and (not update or self.cmpInstallVersion()>0): # print info sourceDistr = distRep.getDistributiveByFile(distName) if not force: diff --git a/pym/cl_install_cmd.py b/pym/cl_install_cmd.py index a667ced..99f5d1c 100644 --- a/pym/cl_install_cmd.py +++ b/pym/cl_install_cmd.py @@ -102,6 +102,9 @@ CMD_OPTIONS = [{'shortOption':"d", 'help':_("do not use UUID") }, {'longOption':'set'}, + {'shortOption':"U", + 'longOption':"update", + 'help':_("install only newer images")}, {'shortOption':"f", 'longOption':"force", 'help':_("no questions during the install process") @@ -139,7 +142,7 @@ class install_cmd(share_cmd): self.logicObj = cl_install() # names incompatible options with --live self.optionsLiveIncompatible = ["type","d", "b", "mbr", - "w", "f", "s","install","uninstall","build","u"] + "w", "f","U", "s","install","uninstall","build","u"] def _getNamesAllSetOptions(self): """Get list set options""" @@ -388,11 +391,12 @@ class install_cmd(share_cmd): return False 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""" if self.logicObj.installSystem(force=force, bootDisk=bootDisk, stdinReadPwd=stdinReadPwd, builder=builder, - flagSpinner=flagSpinner): + flagSpinner=flagSpinner,update=update): self.defaultPrint("\n") self.defaultPrint(_("To apply changes you have to reboot")+".\n") return True diff --git a/scripts/cl-install b/scripts/cl-install index ed78cd2..e123fc6 100644 --- a/scripts/cl-install +++ b/scripts/cl-install @@ -74,7 +74,7 @@ if __name__ == "__main__": flagSpinner = not options.nospinner if not install.installSystem(force=forceOpions, bootDisk=options.mbr, stdinReadPwd=options.P,builder=options.build, - flagSpinner=flagSpinner): + flagSpinner=flagSpinner,update=options.U): sys.exit(1) #if not install.writeVars(options): # sys.exit(1)