ref: refs/heads/master
commit edcbcec26000a9c4e72ba72812e257b82078e6ec
Author: Ján Kupec <jkupec(a)suse.cz>
Date: Thu Apr 2 19:38:15 2009 +0200
zypper.conf: installRecommends handling added.
- --recommends option added to override zypper.conf
- affected help texts reformatted to fit 80 columns (bnc #423007)
- fixed unwanted overriding of zypp.conf onlyRequires option
- fixes bnc #478144
---
src/Config.cc | 20 +++++++-
src/Config.h | 5 ++
src/Zypper.cc | 130 ++++++++++++++++++++++++++++++--------------------
src/solve-commit.cc | 11 +++-
4 files changed, 108 insertions(+), 58 deletions(-)
diff --git a/src/Config.cc b/src/Config.cc
index b834bc2..91ecf1e 100644
--- a/src/Config.cc
+++ b/src/Config.cc
@@ -16,6 +16,7 @@ extern "C"
#include "zypp/base/Measure.h"
#include "zypp/base/String.h"
#include "zypp/base/Exception.h"
+#include "zypp/ZConfig.h"
#include "utils/Augeas.h"
#include "Config.h"
@@ -31,7 +32,7 @@ using namespace zypp;
static map<string, ConfigOption::Option> _table;
static map<ConfigOption::Option, string> _table_str;
-
+const ConfigOption ConfigOption::SOLVER_INSTALL_RECOMMENDS(ConfigOption::SOLVER_INSTALL_RECOMMENDS_e);
const ConfigOption ConfigOption::COLOR_USE_COLORS(ConfigOption::COLOR_USE_COLORS_e);
const ConfigOption ConfigOption::COLOR_BACKGROUND(ConfigOption::COLOR_BACKGROUND_e);
const ConfigOption ConfigOption::COLOR_RESULT(ConfigOption::COLOR_RESULT_e);
@@ -52,6 +53,7 @@ ConfigOption::Option ConfigOption::parse(const std::string & strval_r)
if (_table.empty())
{
// initialize it
+ _table["solver/installRecommends"] = ConfigOption::SOLVER_INSTALL_RECOMMENDS_e;
_table["color/useColors"] = ConfigOption::COLOR_USE_COLORS_e;
_table["color/background"] = ConfigOption::COLOR_BACKGROUND_e;
_table["color/result"] = ConfigOption::COLOR_RESULT_e;
@@ -77,6 +79,7 @@ const string ConfigOption::asString() const
if (_table.empty())
{
// initialize it
+ _table_str[SOLVER_INSTALL_RECOMMENDS_e] = string("solver/installRecommends");
_table_str[COLOR_USE_COLORS_e] = string("color/useColors");
_table_str[COLOR_BACKGROUND_e] = "color/background";
_table_str[COLOR_RESULT_e] = "color/result";
@@ -95,7 +98,8 @@ const string ConfigOption::asString() const
Config::Config()
- : do_colors (false)
+ : solver_installRecommends(true)
+ , do_colors (false)
, color_useColors ("never")
, color_background (false) // dark background
, color_result ("white") // default colors for dark background
@@ -115,10 +119,21 @@ void Config::read()
m.elapsed();
+ string s;
+
// ---------------[ main ]--------------------------------------------------
// TODO
+ // ---------------[ main ]--------------------------------------------------
+
+ s = augeas.getOption(ConfigOption::SOLVER_INSTALL_RECOMMENDS.asString());
+ if (s.empty())
+ solver_installRecommends = ZConfig::instance().solver_onlyRequires();
+ else
+ solver_installRecommends = str::strToBool(s, true);
+
+
// ---------------[ colors ]------------------------------------------------
color_useColors = augeas.getOption(ConfigOption::COLOR_USE_COLORS.asString());
@@ -128,7 +143,6 @@ void Config::read()
////// color/background //////
- string s;
s = augeas.getOption(ConfigOption::COLOR_BACKGROUND.asString());
if (s == "light")
color_background = true;
diff --git a/src/Config.h b/src/Config.h
index 3330b8d..5871e2b 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -15,6 +15,8 @@
class ConfigOption
{
public:
+ static const ConfigOption SOLVER_INSTALL_RECOMMENDS;
+
static const ConfigOption COLOR_USE_COLORS;
static const ConfigOption COLOR_BACKGROUND;
static const ConfigOption COLOR_RESULT;
@@ -28,6 +30,8 @@ public:
enum Option
{
+ SOLVER_INSTALL_RECOMMENDS_e,
+
COLOR_USE_COLORS_e,
COLOR_BACKGROUND_e,
COLOR_RESULT_e,
@@ -67,6 +71,7 @@ struct Config
void read();
+ bool solver_installRecommends;
/**
* Whether to colorize the output. This is evaluated according to
diff --git a/src/Zypper.cc b/src/Zypper.cc
index bd1476c..6fd8072 100644
--- a/src/Zypper.cc
+++ b/src/Zypper.cc
@@ -869,14 +869,15 @@ void Zypper::processCommandOptions()
{"no-confirm", no_argument, 0, 'y'},
{"auto-agree-with-licenses", no_argument, 0, 'l'},
// rug compatibility, we have --auto-agree-with-licenses
- {"agree-to-third-party-licenses", no_argument, 0, 0},
- {"debug-solver", no_argument, 0, 0},
+ {"agree-to-third-party-licenses", no_argument, 0, 0 },
+ {"debug-solver", no_argument, 0, 0 },
{"no-force-resolution", no_argument, 0, 'R'},
{"force-resolution", no_argument, 0, 0 },
{"dry-run", no_argument, 0, 'D'},
// rug uses -N shorthand
{"dry-run", no_argument, 0, 'N'},
{"no-recommends", no_argument, 0, 0 },
+ {"recommends", no_argument, 0, 0 },
// rug compatibility - will mark all packages for installation (like 'in *')
{"entire-catalog", required_argument, 0, 0 },
{"help", no_argument, 0, 'h'},
@@ -893,22 +894,28 @@ void Zypper::processCommandOptions()
"of <, <=, =, >=, >.\n"
"\n"
" Command options:\n"
- "-r, --repo <alias|#|URI> Install packages only from the specified repository.\n"
- "-t, --type <type> Type of package (%s).\n"
- " Default: %s.\n"
- "-n, --name Select packages by plain name, not by capability.\n"
- "-C, --capability Select packages by capability.\n"
- "-f, --force Install even if the item is already installed (reinstall).\n"
- "-l, --auto-agree-with-licenses Automatically say 'yes' to third party license confirmation prompt.\n"
- " See 'man zypper' for more details.\n"
- " --debug-solver Create solver test case for debugging.\n"
- " --no-recommends Do not install recommended packages, only required.\n"
- "-R, --no-force-resolution Do not force the solver to find solution, let it ask.\n"
- " --force-resolution Force the solver to find a solution (even an agressive).\n"
- "-D, --dry-run Test the installation, do not actually install.\n"
- ), "package, patch, pattern, product", "package") + string(_(
- // translators: this option belongs to 'install' command
- " --from <alias|#|URI> Select packages only from specified repository.\n"));
+ " --from <alias|#|URI> Select packages from the specified repository.\n"
+ "-r, --repo <alias|#|URI> Load only the specified repository.\n"
+ "-t, --type <type> Type of package (%s).\n"
+ " Default: %s.\n"
+ "-n, --name Select packages by plain name, not by capability.\n"
+ "-C, --capability Select packages by capability.\n"
+ "-f, --force Reinstall the package if the exact version is\n"
+ " available in repositories.\n"
+ "-l, --auto-agree-with-licenses\n"
+ " Automatically say 'yes' to third party license\n"
+ " confirmation prompt.\n"
+ " See 'man zypper' for more details.\n"
+ " --debug-solver Create solver test case for debugging.\n"
+ " --no-recommends Do not install recommended packages, only required.\n"
+ " --recommends Install also recommended packages in addition\n"
+ " to the required.\n"
+ " --no-force-resolution Do not force the solver to find solution,\n"
+ " let it ask.\n"
+ "-R, --force-resolution Force the solver to find a solution (even\n"
+ " an agressive).\n"
+ "-D, --dry-run Test the installation, do not actually install.\n"
+ ), "package, patch, pattern, product", "package");
break;
}
@@ -1002,9 +1009,12 @@ void Zypper::processCommandOptions()
" and repair eventual dependency problems.\n"
"\n"
" Command options:\n"
- " --no-recommends Do not install recommended packages, only required.\n"
- "-D, --dry-run Test the repair, do not actually do anything to the system.\n"
- "-r, --repo <alias|#|URI> Use only specified repositories to install missing packages.\n"
+ "-r, --repo <alias|#|URI> Load only the specified repository.\n"
+ " --no-recommends Do not install recommended packages, only required.\n"
+ " --recommends Install also recommended packages in addition\n"
+ " to the required.\n"
+ "-D, --dry-run Test the repair, do not actually do anything to\n"
+ " the system.\n"
);
break;
}
@@ -1479,6 +1489,7 @@ void Zypper::processCommandOptions()
{"no-force-resolution", no_argument, 0, 'R'},
{"force-resolution", no_argument, 0, 0 },
{"no-recommends", no_argument, 0, 0 },
+ {"recommends", no_argument, 0, 0 },
{"dry-run", no_argument, 0, 'D'},
// rug uses -N shorthand
{"dry-run", no_argument, 0, 'N'},
@@ -1499,21 +1510,26 @@ void Zypper::processCommandOptions()
"\n"
" Command options:\n"
"\n"
- "-t, --type <type> Type of package (%s).\n"
- " Default: %s.\n"
- "-r, --repo <alias|#|URI> Limit updates to the specified repository.\n"
- " --skip-interactive Skip interactive updates.\n"
- "-l, --auto-agree-with-licenses Automatically say 'yes' to third party license\n"
- " confirmation prompt.\n"
- " See man zypper for more details.\n"
- " --best-effort Do a 'best effort' approach to update. Updates\n"
- " to a lower than the latest version are\n"
- " also acceptable.\n"
- " --debug-solver Create solver test case for debugging.\n"
- " --no-recommends Do not install recommended packages, only required.\n"
- "-R, --no-force-resolution Do not force the solver to find solution, let it ask.\n"
- " --force-resolution Force the solver to find a solution (even an agressive).\n"
- "-D, --dry-run Test the update, do not actually update.\n"
+ "-t, --type <type> Type of package (%s).\n"
+ " Default: %s.\n"
+ "-r, --repo <alias|#|URI> Load only the specified repository.\n"
+ " --skip-interactive Skip interactive updates.\n"
+ "-l, --auto-agree-with-licenses\n"
+ " Automatically say 'yes' to third party license\n"
+ " confirmation prompt.\n"
+ " See man zypper for more details.\n"
+ " --best-effort Do a 'best effort' approach to update. Updates\n"
+ " to a lower than the latest version are\n"
+ " also acceptable.\n"
+ " --debug-solver Create solver test case for debugging.\n"
+ " --no-recommends Do not install recommended packages, only required.\n"
+ " --recommends Install also recommended packages in addition\n"
+ " to the required.\n"
+ "-R, --no-force-resolution Do not force the solver to find solution,\n"
+ " let it ask.\n"
+ " --force-resolution Force the solver to find a solution (even\n"
+ " an agressive).\n"
+ "-D, --dry-run Test the update, do not actually update.\n"
), "package, patch, pattern, product", "package");
break;
}
@@ -1522,10 +1538,11 @@ void Zypper::processCommandOptions()
{
static struct option update_options[] = {
{"repo", required_argument, 0, 'r'},
- {"skip-interactive", no_argument, 0, 0},
+ {"skip-interactive", no_argument, 0, 0 },
{"auto-agree-with-licenses", no_argument, 0, 'l'},
- {"debug-solver", no_argument, 0, 0},
+ {"debug-solver", no_argument, 0, 0 },
{"no-recommends", no_argument, 0, 0 },
+ {"recommends", no_argument, 0, 0 },
{"dry-run", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
@@ -1538,13 +1555,17 @@ void Zypper::processCommandOptions()
"\n"
" Command options:\n"
"\n"
- "-r, --repo <alias|#|URI> Work only with specified repository.\n"
- " --skip-interactive Skip interactive patches.\n"
- "-l, --auto-agree-with-licenses Automatically say 'yes' to third party license\n"
- " confirmation prompt.\n"
- " See man zypper for more details.\n"
- " --debug-solver Create solver test case for debugging.\n"
- "-D, --dry-run Test the update, do not actually update.\n"
+ "-r, --repo <alias|#|URI> Load only the specified repository.\n"
+ " --skip-interactive Skip interactive patches.\n"
+ "-l, --auto-agree-with-licenses\n"
+ " Automatically say 'yes' to third party license\n"
+ " confirmation prompt.\n"
+ " See man zypper for more details.\n"
+ " --debug-solver Create solver test case for debugging.\n"
+ " --no-recommends Do not install recommended packages, only required.\n"
+ " --recommends Install also recommended packages in addition\n"
+ " to the required.\n"
+ "-D, --dry-run Test the update, do not actually update.\n"
);
break;
}
@@ -1573,8 +1594,9 @@ void Zypper::processCommandOptions()
static struct option dupdate_options[] = {
{"repo", required_argument, 0, 'r'},
{"no-recommends", no_argument, 0, 0 },
+ {"recommends", no_argument, 0, 0 },
{"auto-agree-with-licenses", no_argument, 0, 'l'},
- {"debug-solver", no_argument, 0, 0},
+ {"debug-solver", no_argument, 0, 0 },
{"dry-run", no_argument, 0, 'D'},
// rug uses -N shorthand
{"dry-run", no_argument, 0, 'N'},
@@ -1589,12 +1611,16 @@ void Zypper::processCommandOptions()
"\n"
" Command options:\n"
"\n"
- "-r, --repo <alias|#|URI> Limit the upgrade to the specified repository.\n"
- " --no-recommends Do not install recommended packages, only required.\n"
- "-l, --auto-agree-with-licenses Automatically say 'yes' to third party license confirmation prompt.\n"
- " See man zypper for more details.\n"
- " --debug-solver Create solver test case for debugging\n"
- "-D, --dry-run Test the upgrade, do not actually upgrade\n"
+ "-r, --repo <alias|#|URI> Load only the specified repository.\n"
+ "-l, --auto-agree-with-licenses\n"
+ " Automatically say 'yes' to third party license\n"
+ " confirmation prompt.\n"
+ " See man zypper for more details.\n"
+ " --debug-solver Create solver test case for debugging\n"
+ " --no-recommends Do not install recommended packages, only required.\n"
+ " --recommends Install also recommended packages in addition\n"
+ " to the required.\n"
+ "-D, --dry-run Test the upgrade, do not actually upgrade\n"
);
break;
}
diff --git a/src/solve-commit.cc b/src/solve-commit.cc
index b6738b9..5237ca8 100755
--- a/src/solve-commit.cc
+++ b/src/solve-commit.cc
@@ -261,13 +261,18 @@ static void set_force_resolution(Zypper & zypper)
static void set_no_recommends(Zypper & zypper)
{
- bool no_recommends = false;
+ bool no_recommends = !zypper.config().solver_installRecommends;
+
+ // override zypper.conf in these cases:
if (zypper.command() == ZypperCommand::REMOVE)
// never install recommends when removing packages
no_recommends = true;
- else
+ else if (zypper.cOpts().count("no-recommends"))
// install also recommended packages unless --no-recommends is specified
- no_recommends = zypper.cOpts().count("no-recommends");
+ no_recommends = true;
+ else if (zypper.cOpts().count("recommends"))
+ no_recommends = false;
+
DBG << "no recommends (only requires): " << no_recommends << endl;
God->resolver()->setOnlyRequires(no_recommends);
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org