From 01fbd54eb9a361079985472279c0bbd18cb5f2be Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Thu, 10 Mar 2011 17:59:51 +0300 Subject: [PATCH] Add update option. --- i18n/cl_install_ru.mo | Bin 23985 -> 24200 bytes pym/cl_distr.py | 5 ++++- pym/cl_fill_install.py | 9 ++++++-- pym/cl_install.py | 48 +++++++++++++++++++++++++++++++++++------ pym/cl_install_cmd.py | 10 ++++++--- scripts/cl-install | 2 +- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/i18n/cl_install_ru.mo b/i18n/cl_install_ru.mo index 9fe439a5aa32ed49b9a6a88da895cc891a47c644..260767de570f6bc4242329060bc4f9e347182671 100644 GIT binary patch delta 4494 zcmZA3dsLNG9>(!~Kpn>ma!>?BcIw7N3Nk7 z_#QPw_pu{(X2)tz^g#VS9JPe`sD@@EZJR1g$MvX&&!X=Ct~c|qO?Hn0RUE(;ACBRu zshfaW!zFh44je-MThyitV_2Hnk*E=lh)I+~3d`2^I!-SbFj zs+MAVd>fezvjKJEL1ebg8H~Z3sLdD1@HEmG)N##0?U99cc_pfz^{9sSAsgPDLM_Q< zq+YkVLqa18W=m>qVo?=mpdOrx49b*aJFG*EWDSnR4^i)pA5k;VlMSH`4@K2mfNHQ5 zRj(V>kxiJU^S_@&90fn2MjXMyYRZ$5B9o5EI1@FZwWyicZRguioAzfrAKTCBU=GqJ zQ-tb3C8`5&qn2bZj-Y*Wf`mqN5A{G-hNGS*p+=OADxZb^xB}IY)pmX>>eX70E^Ng@ z{4Z*$a_Oy>xER%NCAx4mx>Zn5LOncU-_VNcz;&cg<~C|(`ovnV&J@&AjY4(22zB1) zpz3=SwFGNW_3T6!9!GWLs-3?Z%lzwyaCVRy$UxdM1=tQNQM-E?cEZ=u57(g@`aNof zw%hp@OeNojTH^qwMN{4%b()?;b+iE0!TAH3f35LK3S77YH4|qr5x+w<7&6G(jJ;4J zkHa*~LUnv8>Uh3|I+k1UWe2++H3RYS))Hl*j{AJn%x-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GZ}Ab#<7ZUQZ${URVtwXxe}r0*7d-c&26`U9k3Gk_E42jsa(@uD zHJ_n!!pEpmFodNz7InNM7|~w8Mu9)O$YngHl#-b^7x^u*FFZStA2}PqLw=luORy5@ z%Nno}|BKbCpWr5GBkKFSGB-DtVk!4d8SAeRHdDb#v47)23{7TK z2gh(^aPx`^HN~CD5X|I0f_m;%R0m(9o^QkLm@?HpC2t`4Ymrt8oH)y$ z=FVg>a)N9N>ctaCKH4puk0I8Lw(J?~k4>oTZo}o+gK00o^{95PBVSqH8SY9h#mBjS z3FpzjML+D$@KMhl$oASPEWns@H>pNpnERcm0iE*hyUuh^O(Bk>el4}#9J^r3 zEVCbA0JVir;!8UJ`zdtpVTC)86&U1!J;)&KW7J9nXl)3NN6q{RjKdvXeJ$#_3#hH@ zz+6nFSLIY0Do1{Z1MykRqd}JLbIG zJImMXTXc#-=zh{ME6LZAIkuh?+t9HlYD8R7*(>-$?`0g*^(T4$X_vB^VkP}1iW zVlmM`oF=M>KEyjjGNIh-Nqp+;i7iR|iqZx`pJl{q;<(cuoBi+wRq;9D(s@-r>Qh8~ zNu&@T5>FAoBCZgH1R2x$PdId@*ePsrmc?b={~Jn5w)coHi1P%iXrB@HK3Ba0zfpFS zxJ=Y~b-$O+rMQfOkG-0g@iF2fVy9R4F8-28CwdUSb3*ZD@t;uAX9A&va>;o*KBLzW zN?V9g#6IV>_-tRJ^J#o?ulKnpe>yYIoYwfT?`_|E_U 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)