Skip to content

Commit

Permalink
Merge pull request #45 from yast/vendor_change
Browse files Browse the repository at this point in the history
Added "allowVendorChange" option to Pkg.SetSolverFlags() (FATE#319138)
  • Loading branch information
lslezak committed Jul 3, 2015
2 parents ae02644 + fb3270f commit 6119573
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings-devel-doc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-pkg-bindings-devel-doc
Version: 3.1.25
Version: 3.1.26
Release: 0
License: GPL-2.0
Group: Documentation/HTML
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-pkg-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jul 2 18:21:06 UTC 2015 - lslezak@suse.cz

- added "allowVendorChange" option to Pkg.SetSolverFlags() to
allow configuring the vendor change flag (FATE#319138)
- 3.1.26

-------------------------------------------------------------------
Fri Jun 19 09:23:22 UTC 2015 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-pkg-bindings
Version: 3.1.25
Version: 3.1.26
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
36 changes: 33 additions & 3 deletions src/Package.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,8 @@ void SaveProblemList(const zypp::ResolverProblemList &problems, const std::strin
@builtin SetSolverFlags
@short Set solver flags (options)
@param map params solver options, currently accepted options are:
"allowVendorChange" : boolean or nil, (allow (true) or forbid (false)
vendor change, nil = set the default value from zypp.conf file)
"ignoreAlreadyRecommended" : boolean, (do not select recommended packages for already installed packages)
"onlyRequires" : boolean, (do not select recommended packages, recommended language packages, modalias packages...)
"reset" : boolean - if set to true then the solver is reset (all added extra requires/conflicts added by user are removed, fixsystem mode is disabled, additional data about solver run are cleared)
Expand All @@ -1793,8 +1795,35 @@ void SaveProblemList(const zypp::ResolverProblemList &problems, const std::strin

YCPValue PkgFunctions::SetSolverFlags(const YCPMap& params)
{
if (params.isNull())
{
return YCPBoolean(true);
}

const YCPString vendor_key("allowVendorChange");
if (!params->value(vendor_key).isNull())
{
// check for nil value
if (params->value(vendor_key)->isVoid())
{
y2milestone("Resetting the vendor change flag to the default value");
// reset to default
zypp_ptr()->resolver()->setDefaultAllowVendorChange();

bool allowed = zypp_ptr()->resolver()->allowVendorChange();
y2milestone("Vendor change is now %s", allowed ? "enabled" : "disabled");
}
else if (params->value(vendor_key)->isBoolean())
{
bool allow_change = params->value(vendor_key)->asBoolean()->value();

y2milestone("Vendor change set to %s", allow_change ? "enabled" : "disabled");
zypp_ptr()->resolver()->setAllowVendorChange(allow_change);
}
}

const YCPString reset_key("reset");
if (!params.isNull() && !params->value(reset_key).isNull() && params->value(reset_key)->isBoolean())
if (!params->value(reset_key).isNull() && params->value(reset_key)->isBoolean())
{
bool reset = params->value(reset_key)->asBoolean()->value();

Expand All @@ -1808,15 +1837,15 @@ YCPValue PkgFunctions::SetSolverFlags(const YCPMap& params)
}

const YCPString ignore_key("ignoreAlreadyRecommended");
if (!params.isNull() && !params->value(ignore_key).isNull() && params->value(ignore_key)->isBoolean())
if (!params->value(ignore_key).isNull() && params->value(ignore_key)->isBoolean())
{
bool ignoreAlreadyRecommended = params->value(ignore_key)->asBoolean()->value();
y2milestone("Setting solver flag ignoreAlreadyRecommended: %d", ignoreAlreadyRecommended);
zypp_ptr()->resolver()->setIgnoreAlreadyRecommended(ignoreAlreadyRecommended);
}

const YCPString requires_key("onlyRequires");
if (!params.isNull() && !params->value(requires_key).isNull() && params->value(requires_key)->isBoolean())
if (!params->value(requires_key).isNull() && params->value(requires_key)->isBoolean())
{
bool onlyRequires = params->value(requires_key)->asBoolean()->value();
y2milestone("Setting solver flag onlyRequires: %d", onlyRequires);
Expand All @@ -1837,6 +1866,7 @@ YCPValue PkgFunctions::GetSolverFlags()

ret->add(YCPString("onlyRequires"), YCPBoolean(zypp_ptr()->resolver()->onlyRequires()));
ret->add(YCPString("ignoreAlreadyRecommended"), YCPBoolean(zypp_ptr()->resolver()->ignoreAlreadyRecommended()));
ret->add(YCPString("allowVendorChange"), YCPBoolean(zypp_ptr()->resolver()->allowVendorChange()));

return ret;
}
Expand Down

0 comments on commit 6119573

Please sign in to comment.