From 09ba73272ff246084b49766e759d9e19f5d44001 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 28 Feb 2010 14:11:50 +0000 Subject: [PATCH] Merged from trunk -r15477:15489 | 15486 | Add a --quiet-unmerge-warn option to disable the warning | | zmedico | message that's shown prior to --unmerge actions. Thanks to | | | Thomas Sachau for the suggestion. | | 15487 | Make _global_updates ensure that the binarytree is only | | zmedico | populated with local packages (getbinpkgs=0), and fix | | | binarytree.populate() to behave properly when called more | | | than once. | | 15488 | Make bindbapi override cpv_inject and cpv_remove, for | | zmedico | deleting stale values from self._aux_cache. Also, add a | | | comment about stale cache handling inside aux_update. | | 15489 | Fix vardbapi.move_ent and aux_update to clear relevant | | zmedico | caches. | svn path=/main/branches/prefix/; revision=15498 --- man/emerge.1 | 6 ++++++ pym/_emerge/actions.py | 4 +++- pym/_emerge/help.py | 8 ++++++++ pym/_emerge/main.py | 1 + pym/portage/_global_updates.py | 4 ++++ pym/portage/dbapi/bintree.py | 22 +++++++++++++++++----- pym/portage/dbapi/vartree.py | 3 +++ 7 files changed, 42 insertions(+), 6 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index bebae95f8..c16bfac1c 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -477,6 +477,12 @@ output from portage's displays. Redirect all build output to logs alone, and do not display it on stdout. .TP +.BR \-\-quiet\-unmerge\-warn +Disable the warning message that's shown prior to +\fB\-\-unmerge\fR actions. This option is intended +to be set in the \fBmake.conf\fR(5) +\fBEMERGE_DEFAULT_OPTS\fR variable. +.TP .BR "\-\-rebuilt\-binaries[=n]" Replace installed packages with binary packages that have been rebuilt. Rebuilds are detected by comparison of diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index aff3ce7b1..6655dea43 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2330,7 +2330,9 @@ def action_uninstall(settings, trees, ldpath_mtimes, if files and not valid_atoms: return 1 - if action == 'unmerge' and '--quiet' not in opts: + if action == 'unmerge' and \ + '--quiet' not in opts and \ + '--quiet-unmerge-warn' not in opts: msg = "This action can remove important packages! " + \ "In order to be safer, use " + \ "`emerge -pv --depclean ` to check for " + \ diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index 867902a6c..1dfb63a47 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -506,6 +506,14 @@ def help(myopts, havecolor=1): for line in wrap(desc, desc_width): print(desc_indent + line) print() + print(" "+green("--quiet-unmerge-warn")) + desc = "Disable the warning message that's shown prior to " + \ + "--unmerge actions. This option is intended " + \ + "to be set in the make.conf(5) " + \ + "EMERGE_DEFAULT_OPTS variable." + for line in wrap(desc, desc_width): + print(desc_indent + line) + print() print(" "+green("--rebuilt-binaries") + "[=%s]" % turquoise("n")) desc = "Replace installed packages with binary packages that have " + \ "been rebuilt. Rebuilds are detected by comparison of " + \ diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 48a799423..28fe40ebd 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -70,6 +70,7 @@ options=[ "--onlydeps", "--pretend", "--quiet", "--quiet-build", +"--quiet-unmerge-warn", "--resume", "--searchdesc", "--skipfirst", diff --git a/pym/portage/_global_updates.py b/pym/portage/_global_updates.py index acb548ba5..4310c892a 100644 --- a/pym/portage/_global_updates.py +++ b/pym/portage/_global_updates.py @@ -94,6 +94,10 @@ def _global_updates(trees, prev_mtimes): bindb = trees["/"]["bintree"].dbapi if not os.access(bindb.bintree.pkgdir, os.W_OK): bindb = None + else: + # Call binarytree.populate(), since we want to make sure it's + # only populated with local packages here (getbinpkgs=0). + bindb.bintree.populate() for update_cmd in myupd: if update_cmd[0] == "move": moves = vardb.move_ent(update_cmd) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 13a5e4f37..6a5a4f862 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -67,6 +67,14 @@ class bindbapi(fakedbapi): self.bintree.populate() return fakedbapi.match(self, *pargs, **kwargs) + def cpv_inject(self, cpv, **kwargs): + self._aux_cache.pop(cpv, None) + fakedbapi.cpv_inject(cpv, **kwargs) + + def cpv_remove(self, cpv): + self._aux_cache.pop(cpv, None) + fakedbapi.cpv_remove(cpv) + def aux_get(self, mycpv, wants): if self.bintree and not self.bintree.populated: self.bintree.populate() @@ -137,6 +145,7 @@ class bindbapi(fakedbapi): if not v: del mydata[k] mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata)) + # inject will clear stale caches via cpv_inject. self.bintree.inject(cpv) def cp_list(self, *pargs, **kwargs): @@ -485,6 +494,13 @@ class binarytree(object): if (not os.path.isdir(self.pkgdir) and not getbinpkgs): return 0 + # Clear all caches in case populate is called multiple times + # as may be the case when _global_updates calls populate() + # prior to performing package moves since it only wants to + # operate on local packages (getbinpkgs=0). + self._remotepkgs = None + self.dbapi._clear_cache() + self.dbapi._aux_cache.clear() if True: pkg_paths = {} self._pkg_paths = pkg_paths @@ -696,10 +712,7 @@ class binarytree(object): writemsg(_("!!! PORTAGE_BINHOST unset, but use is requested.\n"), noiselevel=-1) - if getbinpkgs and \ - "PORTAGE_BINHOST" in self.settings and \ - not self._remotepkgs: - + if getbinpkgs and 'PORTAGE_BINHOST' in self.settings: base_url = self.settings["PORTAGE_BINHOST"] from portage.const import CACHE_PATH try: @@ -916,7 +929,6 @@ class binarytree(object): return slot = slot.strip() self.dbapi.cpv_inject(cpv) - self.dbapi._aux_cache.pop(cpv, None) # Reread the Packages index (in case it's been changed by another # process) and then updated it, all while holding a lock. diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index c04caf940..618f8be44 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1940,6 +1940,8 @@ class vardbapi(dbapi): #dest already exists; keep this puppy where it is. continue _movefile(origpath, newpath, mysettings=self.settings) + self._clear_pkg_cache(self._dblink(mycpv)) + self._clear_pkg_cache(self._dblink(mynewcpv)) # We need to rename the ebuild now. old_pf = catsplit(mycpv)[1] @@ -2336,6 +2338,7 @@ class vardbapi(dbapi): treetype="vartree", vartree=self.vartree) if not mylink.exists(): raise KeyError(cpv) + self._clear_pkg_cache(mylink) for k, v in values.items(): if v: mylink.setfile(k, v) -- 2.26.2