summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2008-01-13 12:57:34 -0800
committerDaniel Burrows <dburrows@debian.org>2008-01-13 12:57:34 -0800
commit1d3021d78fd68bf4c05b2d1fe78718dafe71f21c (patch)
treec0e0f340a39471fa4d074fbb27f793f46694e577
parent5b990f5c1311aad1216d5b37517dc906425f5501 (diff)
downloadaptitude-1d3021d78fd68bf4c05b2d1fe78718dafe71f21c.tar.gz
Switch to using Apt::Install-Recommends instead of Aptitude::Recommends-Important. (Closes: #458189, #448561)
After thinking this over for a while, I concluded that it was simply not possible to come up with a satisfactory solution to this problem without doing a wholesale conversion to the new option. aptitude will now attempt to migrate the user's settings automatically on start-up, and will warn you if there's an old configuration option at the system level that it can't change. The upshot of this is that --without-recommends works again.
-rw-r--r--src/apt_options.cc4
-rw-r--r--src/generic/apt/apt.cc42
-rw-r--r--src/generic/apt/aptcache.cc6
-rw-r--r--src/generic/apt/aptitudepolicy.cc8
-rw-r--r--src/generic/apt/infer_reason.cc2
-rw-r--r--src/generic/apt/resolver_manager.cc4
-rw-r--r--src/main.cc6
7 files changed, 51 insertions, 21 deletions
diff --git a/src/apt_options.cc b/src/apt_options.cc
index 09dc7f1e..ad11973a 100644
--- a/src/apt_options.cc
+++ b/src/apt_options.cc
@@ -1,6 +1,6 @@
// apt_options.cc
//
-// Copyright (C) 2000, 2007 Daniel Burrows
+// Copyright (C) 2000, 2007-2008 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
@@ -361,7 +361,7 @@ option_item dependency_options[]={
"packages automatically\" is enabled, packages "
"that are recommended by an installed package "
"will not be automatically removed."),
- PACKAGE "::Recommends-Important", true),
+ "Apt::Install-Recommends", true),
option_item(N_("Remove unused packages automatically"),
N_("If this option is enabled, packages that are "
"automatically installed and that no manually "
diff --git a/src/generic/apt/apt.cc b/src/generic/apt/apt.cc
index 2253b5d7..fdaea824 100644
--- a/src/generic/apt/apt.cc
+++ b/src/generic/apt/apt.cc
@@ -1,6 +1,6 @@
// apt.cc
//
-// Copyright 1999-2007 Daniel Burrows
+// Copyright 1999-2008 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
@@ -121,6 +121,11 @@ bool get_apt_knows_about_rootdir()
void apt_preinit()
{
+ // The old name for the recommends-should-be-automatically-installed
+ // setting and the new one.
+ const char * const aptitudeRecommendsImportant = PACKAGE "::Recommends-Important";
+ const char * const aptInstallRecommends = "APT::Install-Recommends";
+
signal(SIGPIPE, SIG_IGN);
// Probe apt to see if it has RootDir support.
@@ -153,6 +158,22 @@ void apt_preinit()
pkgInitConfig(*_config);
pkgInitSystem(*_config, _system);
+ // Obviously this must come before we read user settings.
+ //
+ // Warn if things look shady, but let the user tell use they really
+ // know what they're doing. (e.g., consider configuration systems
+ // that share settings between machines with different versions)
+ //
+ // Q: Is it better or worse to give the system config file name?
+ // Most of the time this message will indicate a problem there, but
+ // apt also sources /etc/apt/apt.conf.d/* on startup. If the
+ // problem is in some other file and aptitude calls out
+ // /etc/apt/apt.conf, that would be rather confusing.
+ if(_config->Exists(aptitudeRecommendsImportant) &&
+ !_config->FindB(PACKAGE "::Dont-Warn-About-Recommends-Important", false))
+ _error->Warning(_("The system configuration file (%s) contains a setting for the obsolete option 'Aptitude::Recommends-Important'; consider setting 'APT::Install-Recommends' instead or removing this setting."),
+ _config->FindFile("Dir::Etc::main").c_str());
+
// Allow a user-specific customization file.
const char *HOME = getenv("HOME");
@@ -176,7 +197,22 @@ void apt_preinit()
aptcfg=new signalling_config(user_config, _config, theme_config);
- aptcfg->connect(PACKAGE "::Recommends-Important",
+ // Remove any old Recommends-Important setting by setting it to ""
+ // in ~/.aptitude/config.
+ if(aptcfg->Exists(aptitudeRecommendsImportant))
+ {
+ // If it was overridden to "false" and the system setting for
+ // APT::Install-Recommends is "true", set the latter to "false"
+ // to preserve aptitude's behavior.
+ if(!aptcfg->FindB(aptitudeRecommendsImportant, true) &&
+ aptcfg->FindB(aptInstallRecommends, true))
+ aptcfg->Set(aptInstallRecommends, "false");
+ aptcfg->Set(aptitudeRecommendsImportant, "");
+
+ apt_dumpcfg(PACKAGE);
+ }
+
+ aptcfg->connect("APT::Install-Recommends",
sigc::ptr_fun(&reset_interesting_dep_memoization));
cache_closed.connect(sigc::ptr_fun(&reset_interesting_dep_memoization));
@@ -816,7 +852,7 @@ static bool internal_is_interesting_dep(const pkgCache::DepIterator &d,
else if(const_cast<pkgCache::DepIterator &>(d).IsCritical())
return true;
else if(d->Type != pkgCache::Dep::Recommends ||
- !aptcfg->FindB(PACKAGE "::Recommends-Important", true))
+ !aptcfg->FindB("Apt::Install-Recommends", true))
return false;
else
{
diff --git a/src/generic/apt/aptcache.cc b/src/generic/apt/aptcache.cc
index e199fbb7..13a1f803 100644
--- a/src/generic/apt/aptcache.cc
+++ b/src/generic/apt/aptcache.cc
@@ -1,6 +1,6 @@
// aptcache.cc
//
-// Copyright 1999-2007 Daniel Burrows
+// Copyright 1999-2008 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
@@ -189,7 +189,7 @@ aptitudeDepCache::aptitudeDepCache(pkgCache *Cache, Policy *Plcy)
{
// When the "install recommended packages" flag changes, collect garbage.
#if 0
- aptcfg->connect(PACKAGE "::Recommends-Important",
+ aptcfg->connect("Apt::Install-Recommends",
sigc::bind(sigc::mem_fun(*this,
&pkgDepCache::MarkAndSweep),
(undo_group *) NULL));
@@ -1588,7 +1588,7 @@ bool aptitudeDepCache::is_held(const PkgIterator &pkg)
bool aptitudeDepCache::MarkFollowsRecommends()
{
return pkgDepCache::MarkFollowsRecommends() ||
- aptcfg->FindB(PACKAGE "::Recommends-Important", true) ||
+ aptcfg->FindB("Apt::Install-Recommends", true) ||
aptcfg->FindB(PACKAGE "::Keep-Recommends", false);
}
diff --git a/src/generic/apt/aptitudepolicy.cc b/src/generic/apt/aptitudepolicy.cc
index 40ef6fd4..5c81b4ae 100644
--- a/src/generic/apt/aptitudepolicy.cc
+++ b/src/generic/apt/aptitudepolicy.cc
@@ -21,11 +21,5 @@
bool aptitudePolicy::IsImportantDep(pkgCache::DepIterator dep)
{
- if(pkgPolicy::IsImportantDep(dep))
- return true;
-
- if(dep->Type==pkgCache::Dep::Recommends)
- return aptcfg->FindB(PACKAGE "::Recommends-Important", true);
- else
- return false;
+ return pkgPolicy::IsImportantDep(dep);
}
diff --git a/src/generic/apt/infer_reason.cc b/src/generic/apt/infer_reason.cc
index 90d1a191..b2587882 100644
--- a/src/generic/apt/infer_reason.cc
+++ b/src/generic/apt/infer_reason.cc
@@ -208,7 +208,7 @@ void infer_reason(pkgCache::PkgIterator pkg, set<reason> &reasons)
((*apt_cache_file)[d.ParentPkg()].Delete() ||
(*apt_cache_file)[d.ParentPkg()].InstVerIter(*apt_cache_file)!=d.ParentVer()) &&
(d->Type==pkgCache::Dep::Depends ||
- (aptcfg->FindB(PACKAGE "::Recommends-Important", true) &&
+ (aptcfg->FindB("Apt::Install-Recommends", true) &&
d->Type==pkgCache::Dep::Recommends)))
reasons.insert(reason(d.ParentPkg(), d));
}
diff --git a/src/generic/apt/resolver_manager.cc b/src/generic/apt/resolver_manager.cc
index 21834200..8a717ad9 100644
--- a/src/generic/apt/resolver_manager.cc
+++ b/src/generic/apt/resolver_manager.cc
@@ -1,6 +1,6 @@
// resolver_manager.cc
//
-// Copyright (C) 2005, 2007 Daniel Burrows
+// Copyright (C) 2005, 2007-2008 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
@@ -171,7 +171,7 @@ resolver_manager::resolver_manager(aptitudeDepCache *_cache)
cache->pre_package_state_changed.connect(sigc::mem_fun(this, &resolver_manager::discard_resolver));
cache->package_state_changed.connect(sigc::mem_fun(this, &resolver_manager::maybe_create_resolver));
- aptcfg->connect(PACKAGE "::Recommends-Important",
+ aptcfg->connect("Apt::Install-Recommends",
sigc::mem_fun(this,
&resolver_manager::discard_resolver));
diff --git a/src/main.cc b/src/main.cc
index cfceb3c5..92727b3b 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,6 +1,6 @@
// main.cc (ne้ testscr.cc)
//
-// Copyright 1999-2007 Daniel Burrows
+// Copyright 1999-2008 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
@@ -333,10 +333,10 @@ int main(int argc, char *argv[])
seen_quiet = true;
break;
case 'r':
- aptcfg->SetNoUser(PACKAGE "::Recommends-Important", "true");
+ aptcfg->SetNoUser("Apt::Install-Recommends", "true");
break;
case 'R':
- aptcfg->SetNoUser(PACKAGE "::Recommends-Important", "false");
+ aptcfg->SetNoUser("Apt::Install-Recommends", "false");
aptcfg->SetNoUser(PACKAGE "::Keep-Recommends", "true");
break;
case 't':