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 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
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] for pmclass in pmpkgs: pmcs = ChangeSet(self._cache) for pkg in pmpkgs[pmclass]: if pkg in cs: pmcs[pkg] = cs[pkg] if sysconf.get("commit", True): self.writeCommitLog(pmcs) pmclass().commit(pmcs, pkgpaths) 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