On Fri, Jul 06, 2007 at 09:39:20AM +1200, Ian McDonald <[EMAIL PROTECTED]> was heard to say: > When I do "sudo aptitude -PV upgrade" and it cannot get all the files I > get this: > > W: Could not lock the cache file. Opening in read-only mode; any > changes you make to the states of packages will NOT be preserved! > > immediately prior is this:
(...) > Reading task descriptions... Done > Building tag database... Done You're saying the error appears here, right? > I have checked and the lock file (/var/lock/aptitude) IS removed if > aptitude is successful. That would be surprising, since there is no code in aptitude to delete it. aptitude uses fcntl locks, so once the program has exited the lock will always be released by the kernel. However, there have been multiple bugs that caused aptitude to claim it had failed to lock the file when there was some other problem, and this looks like another one to me. The code in question first tries to open without a lock, then (if that fails or produces an error) tries to open with a lock. If it succeeds the second time, it assumes that it failed because of a lock the first time (apt doesn't actually return this information, so I get to play a game of reverse engineering what happened). Unfortunately, it doesn't clear the global error state before doing this, so any errors that happen before it tries to lock the cache will cause a spurious "lock failure". This patch should fix your problem. If you can rebuild aptitude with it applied and check whether it helps, that would be great. Daniel
diff -r 84cd0521e303 src/generic/apt/apt.cc --- a/src/generic/apt/apt.cc Tue Jul 03 07:06:43 2007 -0700 +++ b/src/generic/apt/apt.cc Thu Jul 05 20:54:36 2007 -0700 @@ -288,6 +288,9 @@ void apt_load_cache(OpProgress *progress apt_source_list->ReadMainList(); bool simulate = aptcfg->FindB(PACKAGE "::Simulate", false); + + // Clear the error stack so that we don't get confused by old errors. + consume_errors(); bool open_failed=!new_file->Open(*progress_bar, do_initselections, (getuid() == 0) && !simulate,

