On Sat, Oct 08, 2005 at 03:25:17AM +0200, "Steinar H. Gunderson" <[EMAIL PROTECTED]> was heard to say: > aptitude has a bit of an odd tendency to do its initialization twice: > > baby:~> LANG=C sudo aptitude install nonexistant-package > Reading package lists... Done > Building dependency tree... Done > Reading extended state information > Initializing package states... Done > Reading task descriptions... Done > Building tag database... Done > Couldn't find any package whose name or description matched > "nonexistant-package" > The following packages have been kept back: > abiword-common abiword-gnome ndiswrapper-utils > 0 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded. > Need to get 0B of archives. After unpacking 0B will be used. > > [and here the second initialization:] > Reading package lists... Done > Building dependency tree... Done > Reading extended state information > Initializing package states... Done > Reading task descriptions... Done > Building tag database... Done > > This is rather slow and a bit annoying -- I have no idea why it insists > on doing the last part, and can see no bad effects if I Ctrl-C it.
The attached patch should fix this bug. Daniel
Fri Oct 7 18:50:39 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]>
* Don't reload the cache more than is absolutely necessary after an install
operation. (Closes: #332708)
Fri Oct 7 18:48:14 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]>
* Also don't reload the cache after an update except to the extent that it's
required.
Fri Oct 7 18:44:17 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]>
* Always ensure that the cache gets loaded after a download process if the
process closed it.
This is the first stage of the fix for #332708; it will allow download
processes to not
reopen the cache themselves (instead depending on their caller to do it).
diff -rN -udp old-head/src/generic/apt/download_install_manager.cc
new-head/src/generic/apt/download_install_manager.cc
--- old-head/src/generic/apt/download_install_manager.cc 2005-10-07
18:51:37.377884848 -0700
+++ new-head/src/generic/apt/download_install_manager.cc 2005-10-07
18:49:36.000000000 -0700
@@ -185,17 +185,21 @@ download_manager::result download_instal
{
result run_res = execute_install_run(res, progress);
+ apt_close_cache();
+
if(run_res != do_again)
{
if(log != NULL)
log->Complete();
- apt_reload_cache(&progress, true);
- if(apt_cache_file != NULL &&
- aptcfg->FindB(PACKAGE "::Forget-New-On-Install", false))
+ if(aptcfg->FindB(PACKAGE "::Forget-New-On-Install", false))
{
- (*apt_cache_file)->forget_new(NULL);
- post_forget_new_hook();
+ apt_load_cache(&progress, true);
+ if(apt_cache_file != NULL)
+ {
+ (*apt_cache_file)->forget_new(NULL);
+ post_forget_new_hook();
+ }
}
}
diff -rN -udp old-head/src/generic/apt/download_update_manager.cc
new-head/src/generic/apt/download_update_manager.cc
--- old-head/src/generic/apt/download_update_manager.cc 2005-10-07
18:51:37.387883328 -0700
+++ new-head/src/generic/apt/download_update_manager.cc 2005-10-07
18:36:42.000000000 -0700
@@ -23,6 +23,7 @@
#include "config_signal.h"
#include "download_signal_log.h"
+#include <apt-pkg/cachefile.h>
#include <apt-pkg/clean.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sourcelist.h>
@@ -100,11 +101,10 @@ download_update_manager::finish(pkgAcqui
if(log != NULL)
log->Complete();
+ apt_close_cache();
+
if(res != pkgAcquire::Continue)
- {
- apt_reload_cache(&progress, true);
- return failure;
- }
+ return failure;
// Clean old stuff out
if(fetcher->Clean(aptcfg->FindDir("Dir::State::lists")) == false ||
@@ -114,17 +114,35 @@ download_update_manager::finish(pkgAcqui
return failure;
}
- apt_reload_cache(&progress, true);
+ // Rebuild the apt caches as done in apt-get. cachefile is scoped
+ // so it dies before we possibly-reload the cache. This will do a
+ // little redundant work in visual mode, but avoids lots of
+ // redundant work at the command-line.
+ {
+ pkgCacheFile cachefile;
+ if(!cachefile.BuildCaches(progress, true))
+ {
+ _error->Error(_("Couldn't rebuild package cache"));
+ return failure;
+ }
+ }
- if(apt_cache_file != NULL &&
- aptcfg->FindB(PACKAGE "::Forget-New-On-Update", false))
+ bool need_forget_new =
+ aptcfg->FindB(PACKAGE "::Forget-New-On-Update", false);
+
+ bool need_autoclean =
+ aptcfg->FindB(PACKAGE "::AutoClean-After-Update", false);
+
+ if(need_forget_new || need_autoclean)
+ apt_load_cache(&progress, true);
+
+ if(apt_cache_file != NULL && need_forget_new)
{
(*apt_cache_file)->forget_new(NULL);
post_forget_new_hook();
}
- if(apt_cache_file != NULL &&
- aptcfg->FindB(PACKAGE "::AutoClean-After-Update", false))
+ if(apt_cache_file != NULL && need_autoclean)
{
pre_autoclean_hook();
diff -rN -udp old-head/src/ui_download_manager.cc
new-head/src/ui_download_manager.cc
--- old-head/src/ui_download_manager.cc 2005-10-07 18:51:37.389883024 -0700
+++ new-head/src/ui_download_manager.cc 2005-10-07 18:31:39.000000000 -0700
@@ -73,6 +73,8 @@ void ui_download_manager::done(download_
download_manager::result run_res = manager->finish(res, *p.unsafe_get_ref());
+ apt_load_cache(p.unsafe_get_ref(), true);
+
p->destroy();
delete t;
signature.asc
Description: Digital signature

