From: Zac Medico Date: Sat, 28 Jun 2008 09:08:24 +0000 (-0000) Subject: Split out a PackageUninstall class. X-Git-Tag: v2.2_rc2~292 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bcf69af38179859dcc5dd4ebd591933f24f464ad;p=portage.git Split out a PackageUninstall class. svn path=/main/trunk/; revision=10833 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 3e10d71e9..edbabdd99 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1536,6 +1536,25 @@ class EbuildMerge(Task): blockers=self.find_blockers) return retval +class PackageUninstall(Task): + + __slots__ = ("ldpath_mtimes", "opts", "pkg", "settings") + + def _get_hash_key(self): + hash_key = getattr(self, "_hash_key", None) + if hash_key is None: + self._hash_key = ("PackageUninstall", self.pkg._get_hash_key()) + return self._hash_key + + def execute(self): + try: + unmerge(self.pkg.root_config, self.opts, "unmerge", + [self.pkg.cpv], self.ldpath_mtimes, clean_world=0, + raise_on_error=1) + except UninstallFailure, e: + return e.status + return os.EX_OK + class BinpkgFetcher(Task): __slots__ = ("use_locks", "pkg", "pretend", @@ -6413,12 +6432,11 @@ class MergeTask(object): metadata = pkg.metadata if pkg.installed: if not (buildpkgonly or fetchonly or pretend): - try: - unmerge(root_config, self.myopts, "unmerge", - [pkg.cpv], mtimedb["ldpath"], clean_world=0, - raise_on_error=1) - except UninstallFailure, e: - raise self._pkg_failure(e.status) + uninstall = PackageUninstall(ldpath_mtimes=ldpath_mtimes, + opts=self.myopts, pkg=pkg, settings=pkgsettings) + retval = uninstall.execute() + if retval != os.EX_OK: + raise self._pkg_failure(retval) return if x[0]=="blocks":