def commitChangeSetStepped(self, changeset, caching=OPTIONAL, confirm=True): if confirm and not iface.confirmChangeSet(changeset): return False # Order by number of required packages inside the transaction. pkglst = [] for pkg in changeset: n = 0 for req in pkg.requires: for prv in req.providedby: for prvpkg in prv.packages: if changeset.get(prvpkg) is INSTALL: n += 1 pkglst.append((n, pkg)) pkglst.sort() splitter = ChangeSetSplitter(changeset) unioncs = ChangeSet(self._cache) for n, pkg in pkglst: if pkg in unioncs: continue cs = ChangeSet(self._cache, unioncs) splitter.include(unioncs, pkg) cs = unioncs.difference(cs) self.commitChangeSet(cs, confirm=confirm) return True
def markAndSweep(self, changeset=None): if changeset == None: changeset = {} # Mark ... all = self._cache.getPackages() auto = pkgconf.filterByFlag("auto", all) marked = {} for pkg in all: if (pkg.installed and pkg not in auto and changeset.get(pkg) != REMOVE): marked[pkg] = True queue = marked.keys() while queue: pkg = queue.pop(0) for req in pkg.requires: for prv in req.providedby: for prvpkg in prv.packages: if (prvpkg.installed and prvpkg not in marked and prvpkg not in changeset): marked[prvpkg] = True queue.append(prvpkg) # see what is not marked suggestions = ChangeSet(self._cache) for pkg in all: if pkg.installed and pkg not in marked: suggestions[pkg] = REMOVE # FIXME: we should probably check here is those suggestions # would break the relations in the cache and bail out # if that happens #if suggestions: # accepted = iface.suggestChanges(suggestions) # if accepted: # changeset.update(accepted) return suggestions
def run(self, command=None, argv=None): self.setCatchExceptions(True) self._window.set_icon(getPixbuf("smart")) self._window.show() self._ctrl.reloadChannels() self._changeset = ChangeSet(self._ctrl.getCache()) self._pi.setChangeSet(self._changeset) self._progress.hide() self.refreshPackages() gtk.main() self.setCatchExceptions(False)
def run(self, command=None, argv=None): self.setCatchExceptions(True) self.loadState() self._window.setIcon(getPixmap("smart")) self._window.show() self._ctrl.reloadChannels() self._changeset = ChangeSet(self._ctrl.getCache()) self._pi.setChangeSet(self._changeset) self._progress.hide() self.refreshPackages() app.exec_loop() self.saveState() self.setCatchExceptions(False)
def commitChangeSet(self, changeset, caching=OPTIONAL, confirm=True): if confirm and not iface.confirmChangeSet(changeset): return False if not confirm: iface.showChangeSet(changeset) if sysconf.get("dry-run"): return True setCloseOnExecAll() pmpkgs = {} for pkg in changeset: pmclass = pkg.packagemanager if pmclass not in pmpkgs: pmpkgs[pmclass] = [pkg] else: pmpkgs[pmclass].append(pkg) channels = getChannelsWithPackages( [x for x in changeset if changeset[x] is INSTALL]) datadir = sysconf.get("data-dir") splitter = ChangeSetSplitter(changeset) donecs = ChangeSet(self._cache) copypkgpaths = {} while True: if not self.askForRemovableChannels(channels): return False self._achanset.setChannels(channels) splitter.resetLocked() splitter.setLockedSet(dict.fromkeys(donecs, True)) cs = changeset.copy() for channel in channels: if not self._achanset.isAvailable(channel): for pkg in channels[channel]: if pkg not in donecs and pkg not in copypkgpaths: splitter.exclude(cs, pkg) cs = cs.difference(donecs) donecs.update(cs) if cs: pkgpaths = self.fetchPackages([ pkg for pkg in cs if pkg not in copypkgpaths and cs[pkg] is INSTALL ], caching) for pkg in cs: if pkg in copypkgpaths: pkgpaths[pkg] = copypkgpaths[pkg] del copypkgpaths[pkg] hooks.call("pre-commit") for pmclass in pmpkgs: pmcs = ChangeSet(self._cache) for pkg in pmpkgs[pmclass]: if pkg in cs: pmcs[pkg] = cs[pkg] pmcs.setRequested(pkg, cs.getRequested(pkg)) if sysconf.get("commit", True): pmcs.markPackagesAutoInstalled() self.writeCommitLog(pmcs) pmclass().commit(pmcs, pkgpaths) hooks.call("post-commit") if sysconf.get("remove-packages", True): for pkg in pkgpaths: for path in pkgpaths[pkg]: if path.startswith( os.path.join(datadir, "packages")): os.unlink(path) if donecs == changeset: break copypkgs = [] for channel in channels.keys(): if self._achanset.isAvailable(channel): pkgs = [pkg for pkg in channels[channel] if pkg not in cs] if not pkgs: del channels[channel] elif channel.isRemovable(): copypkgs.extend(pkgs) del channels[channel] else: channels[channel] = pkgs self._fetcher.setForceCopy(True) copypkgpaths.update(self.fetchPackages(copypkgs, caching)) self._fetcher.setForceCopy(False) self._mediaset.restoreState() return True