Changeset 3411
- Timestamp:
- Jan 25, 2017, 6:34:23 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-up/trunk/fuentes/lliurex-up-cli/usr/sbin/lliurex-upgrade
r3405 r3411 11 11 class LliurexUpCli: 12 12 def __init__(self): 13 13 14 self.lliurexcore = lliurex.lliurexup.LliurexUpCore() 14 15 15 self.checkInitialFlavour() 16 17 def checkInitialFlavour(self): 18 19 self.targetMetapackage=None 20 21 try: 22 self.targetMetapackage=self.lliurexcore.checkFlavour() 23 24 #if self.targetMetapackage !=None: 25 self.metapackageRef=self.lliurexcore.metapackageRef 26 if len(self.metapackageRef)==0: 27 self.lliurexcore.getTargetMetapackage() 28 self.metapackageRef=sorted(self.metapackageRef) 29 30 self.previousFlavours=self.lliurexcore.previuosFlavours 31 if len(self.previousFlavours)==0: 32 self.lliurexcore.getPreviuosFlavours() 33 34 log_msg="Get initial flavours: " + str(self.previousFlavours) 35 self.log(log_msg) 36 37 except Exception as e: 38 print e 39 16 40 def initActionsScript(self): 41 17 42 command=self.lliurexcore.initActionsScript() 18 43 try: … … 59 84 def checkingInitialFlavourToInstall(self): 60 85 61 print ("Checking flavour") 62 63 def getPackagesToUpdate(self): 64 self.packages=self.lliurexcore.getPackagesToUpdate() 65 86 if self.targetMetapackage == None: 87 self.flavourToInstall=self.requiresInstallFlavour() 88 if self.flavourToInstall != None: 89 print " [Lliurex-up]: Installation of flavour is required: " +str(self.flavourToInstall) 90 is_flavour_installed=self.lliurexcore.installInitialFlavour(self.flavourToInstall) 91 returncode=is_flavour_installed['returncode'] 92 error=is_flavour_installed['stderrs'] 93 print " [Lliurex-up]: Flavour is now installed: " + str(returncode) + " Error: " + str(error) 94 else: 95 print " [Lliurex-up]: Installation of flavour is not required" 96 else: 97 print " [Lliurex-up]: Installation of flavour is required: " + str(self.targetMetapackage) 98 is_flavour_installed=self.lliurexcore.installInitialFlavour(self.targetMetapackage) 99 returncode=is_flavour_installed['returncode'] 100 error=is_flavour_installed['stderrs'] 101 print " [Lliurex-up]: Flavour is now installed: " + str(returncode) + " Error: " + str(error) 102 103 def requiresInstallFlavour(self): 104 105 flavourToInstall=None 106 107 self.flavours=self.lliurexcore.flavours 108 if not 'None' in self.previousFlavours: 109 if self.previousFlavours !=self.flavours: 110 flavourToInstall=self.parseFlavourToInstall(self.previousFlavours) 111 112 else: 113 if self.metapackageRef != self.flavours: 114 flavourToInstall=self.parseFlavourToInstall(self.metapackageRef) 115 116 return flavourToInstall 117 118 #def requiresInstallFlavour 119 120 def parseFlavourToInstall(self,flavours): 121 122 parse_flavour="" 123 124 for item in flavours: 125 if item != "edu": 126 parse_flavour=parse_flavour + " " + "lliurex-meta-" + item 127 128 return parse_flavour 129 130 def checkingIncorrectFlavours(self): 131 132 count=0 133 ref_flavour=["lliurex-meta-server","lliurex-meta-client", "lliurex-meta-desktop", "lliurex-meta-music", "lliurex-meta-pyme", "lliurex-meta-infantil"] 134 self.incorrect_flavours=[] 135 136 for item in self.packages: 137 if item in ref_flavour: 138 self.incorrect_flavours.append(item) 139 140 if len(self.incorrect_flavours)>0: 141 for item in self.incorrect_flavours: 142 if self.targetMetapackage != None: 143 if item != self.targetMetapackage: 144 count=count+1 145 else: 146 meta=item.split("-")[2] 147 if 'None' in self.previousFlavours: 148 if not meta in self.metapackageRef: 149 count=count+1 150 else: 151 if not meta in self.previousFlavours: 152 count=count+1 153 154 if count>0: 155 return True 156 else: 157 return False 66 158 67 159 def preActionsScript(self): 160 68 161 command=self.lliurexcore.preActionsScript() 69 162 try: … … 74 167 75 168 def distUpgrade(self): 169 76 170 command=self.lliurexcore.distUpgradeProcess() 77 171 try: … … 81 175 82 176 def postActionsScript(self): 177 83 178 command=self.lliurexcore.postActionsScript() 84 179 try: … … 86 181 except Exception as e: 87 182 print e 88 89 90 183 91 184 def main(self): … … 103 196 104 197 print(" [Lliurex-up]: Checking if installation of flavour is required") 105 self.checkingInitialFlavourToInstall() :198 self.checkingInitialFlavourToInstall() 106 199 107 200 print(" [Lliurex-up]: Checking for new updates") 108 self. getPackagesToUpdate()201 self.packages=self.lliurexcore.getPackagesToUpdate() 109 202 110 203 if len(self.packages)>0: 111 print(" [Lliurex-up]:List of packages to update") 112 for item in self.packages: 113 print item + ": " + packages[item]["candidate"] 114 115 response=raw_input(' [LLiurex-up]: Do you want to udpate the system(yes/no)): ').lower() 116 if response.startswith('y'): 117 print(" [Lliurex-up]: Preparin system to update") 118 self.preActionsScript() 119 print(" [Lliurex-up]: Downloading and installing packages") 120 self.distUpgrade() 121 print(" [Lliurex-up]: Ending the update") 122 self.postActionsScript() 123 print(" [Lliurex-up]: The system is now update") 124 204 205 if not self.checkingIncorrectFlavours(): 206 print(" [Lliurex-up]:List of packages to update") 207 for item in self.packages: 208 print item + ": " + self.packages[item]["candidate"] 209 210 response=raw_input(' [LLiurex-up]: Do you want to udpate the system(yes/no)): ').lower() 211 if response.startswith('y'): 212 print(" [Lliurex-up]: Preparin system to update") 213 self.preActionsScript() 214 print(" [Lliurex-up]: Downloading and installing packages") 215 self.distUpgrade() 216 print(" [Lliurex-up]: Ending the update") 217 self.postActionsScript() 218 print(" [Lliurex-up]: The system is now update") 219 self.lliurexcore.cleanEnvironment() 220 221 else: 222 print(" [Lliurex-up]: Cancel the update") 223 self.lliurexcore.cleanEnvironment() 224 return 0 125 225 else: 126 return 0 127 226 print("[Lliurex-up]: Updated abort for incorrect flavours detected in new update") 128 227 else: 129 228 print(" [Lliurex-up]: Your systems is updated. Nothing to do")
Note: See TracChangeset
for help on using the changeset viewer.