def run(self, InstallProgress): import libbricks.engine as engine from libbricks.features import features atleastone = False for feature, choice in self.moduleclass.modules_settings["bricks"]["features"].items(): status, packages, allpackages = engine.status(feature) dic = features[feature] if not choice: # remove! atleastone = True engine.remove(packages) # We should really, really, really ensure that no # dependency remains. We do this by marking too the # meta-package's dependencies as to be removed. pkgs = [] for typ in dic["enable_selection"]: dps = engine.dependencies_loop_simplified(dic[typ]) for dep in dps: if dep.name.startswith("meta-") or dep.name in pkgs: continue pkgs.append(dep.name) engine.remove(pkgs, auto=False) # Commit if atleastone: engine.cache.commit(install_progress=InstallProgress)
def run(self): """ Apply the changes! """ atleastone = False # hack to not commit if not needed try: # Get the status of each switch, then change cache accordingly for feature, objs in self.parent._objects.items(): status, packages, allpackages = engine.status(feature) # Get things to purge, if any to_purge = () if "purge" in features[feature]: to_purge = features[feature]["purge"] change = objs["switch"].get_active() if change and change == status: # We shouldn't touch this feature. continue elif not change: # We need to check every checkbox to see if we need # to change something toinstall = [] toremove = [] allfalse = True # should check if there is at least one True item for dep, checkbox in self.parent.checkboxes[feature].items(): value = checkbox.get_active() if value and not engine.is_installed(dep): # Package needs to be installed. toinstall.append(dep) allfalse = False elif value: allfalse = False elif not value and engine.is_installed(dep): # Package is installed and needs removal toremove.append(dep) if allfalse: # Every checkbox is false, we can mark for removal # the entire "packages" atleastone = True engine.remove(packages, purge=to_purge) else: # the user customized the feature. # We need to be sure that the meta package is # being processed as well. # First, we need to loop through the customizable # metapackages for meta in features[feature]["enable_selection"]: meta = features[feature][meta] # Now that we got the package name, we need to # get its dependencies... deps = engine.dependencies_loop_simplified(meta, asString=True) # ...and see if one of ours is there for pkg in toremove: if pkg in deps: # Yeah! Just add meta to toremove toremove.append(meta) break print "Packages to install:", toinstall print "Packages to remove:", toremove if toinstall: atleastone = True engine.install(toinstall) if toremove: atleastone = True engine.remove(toremove, auto=False, purge=to_purge) else: atleastone = True # Should mark for installation! engine.install(allpackages) #self.parent.progress_set_quota(100) #for lol in range(100): # self.parent.progress_set_text(str(lol)) # self.parent.progress_set_percentage(lol) # #self.parent.update_progress(str(lol), lol) # time.sleep(0.3) # Commit if atleastone: engine.cache.commit(AcquireProgress(self.parent), InstallProgress(self.parent)) except: excp = sys.exc_info() error = "".join(traceback.format_exception(excp[0],excp[1],excp[2])) print(error) GObject.idle_add( self.parent.error_window.format_secondary_markup, # _("Press Close to exit from the application.") + "\n\n<i>" + error + "</i>") "<i>%s</i>\n\n" % excp[1] + _("Press Close to exit from the application.")) GObject.idle_add(self.parent.error_window.show) else: self.parent.really_quit()