diff options
author | Daniel Burrows <dburrows@debian.org> | 2011-05-14 13:52:02 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2011-05-14 13:55:49 -0700 |
commit | ec9d6281a021d0c3708520c5fd9a8e08ef3b686f (patch) | |
tree | d63f0807748b9a703af2c446e91406d221c876d9 | |
parent | 1bdbe67a6d055902d26bf002731b907777d05810 (diff) | |
download | aptitude-ec9d6281a021d0c3708520c5fd9a8e08ef3b686f.tar.gz |
Save and restore the auto flag of a package around MarkInstall(). (Closes: #622719)
For some reason, MarkInstall likes to clear the auto flag of packages
that the user upgraded manually. This will only affect the "head"
package, so recursive installs still turn packages to automatic mode.
-rw-r--r-- | src/generic/apt/aptcache.cc | 14 | ||||
-rw-r--r-- | src/generic/apt/aptcache.h | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/generic/apt/aptcache.cc b/src/generic/apt/aptcache.cc index 913084dd..cba35e27 100644 --- a/src/generic/apt/aptcache.cc +++ b/src/generic/apt/aptcache.cc @@ -1,6 +1,6 @@ // aptcache.cc // -// Copyright 1999-2009 Daniel Burrows +// Copyright 1999-2009, 2011 Daniel Burrows // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -640,7 +640,7 @@ void aptitudeDepCache::mark_all_upgradable(bool with_autoinst, pre_package_state_changed(); dirty = true; - MarkInstall(*it, do_autoinstall); + internal_mark_install(*it, do_autoinstall, false); } } } @@ -1108,6 +1108,10 @@ void aptitudeDepCache::internal_mark_install(const PkgIterator &Pkg, MarkAuto(Pkg, false); + // MarkInstall and friends like to modify the auto flag, so save it + // here and restore it afterwards: + bool previously_auto = ((*this)[Pkg].Flags & Flag::Auto) != 0; + if(!ReInstall) { pkgDepCache::MarkInstall(Pkg, AutoInst); @@ -1117,6 +1121,8 @@ void aptitudeDepCache::internal_mark_install(const PkgIterator &Pkg, pkgDepCache::SetReInstall(Pkg, ReInstall); + MarkAuto(Pkg, previously_auto); + get_ext_state(Pkg).selection_state=pkgCache::State::Install; get_ext_state(Pkg).reinstall=ReInstall; get_ext_state(Pkg).forbidver=""; @@ -1334,7 +1340,7 @@ void aptitudeDepCache::mark_single_install(const PkgIterator &Pkg, undo_group *u if(set_to_manual) MarkAuto(Pkg, false); - pkgDepCache::MarkInstall(Pkg, true); + internal_mark_install(Pkg, true, false); } void aptitudeDepCache::mark_auto_installed(const PkgIterator &Pkg, @@ -1539,7 +1545,7 @@ bool aptitudeDepCache::try_fix_broken(undo_group *undo) { pkgDepCache::StateCache &state=(*this)[i]; if(state.InstBroken() || state.NowBroken()) - MarkInstall(i,true); + internal_mark_install(i, true, false); else if(state.Delete()) fixer.Remove(i); } diff --git a/src/generic/apt/aptcache.h b/src/generic/apt/aptcache.h index 20bcba56..3cbca962 100644 --- a/src/generic/apt/aptcache.h +++ b/src/generic/apt/aptcache.h @@ -1,6 +1,6 @@ // aptcache.h -*-c++-*- // -// Copyright 1999-2005, 2007-2009 Daniel Burrows +// Copyright 1999-2005, 2007-2009, 2011 Daniel Burrows // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -320,6 +320,11 @@ private: // The following methods just perform the core part of the named // action, without creating a new action group or running // mark&sweep. + + /** + * Use this instead of pkgDepCache::MarkInstall; it ensures that the + * package's auto flag is set properly. + */ void internal_mark_install(const PkgIterator &Pkg, bool AutoInst, bool ReInstall); void internal_mark_delete(const PkgIterator &Pkg, bool Purge, bool unused_delete); void internal_mark_keep(const PkgIterator &Pkg, bool Automatic, bool SetHold); |