Skip to content

Commit

Permalink
display number of locked packages in the proposal (fate#318257)
Browse files Browse the repository at this point in the history
- 2.17.25
  • Loading branch information
lslezak committed Jan 16, 2015
1 parent e96e207 commit 25a6ad3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.17.24
2.17.25
7 changes: 7 additions & 0 deletions package/yast2-update.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 16 13:47:52 UTC 2015 - lslezak@suse.cz

- display number of locked ("protected" and "taboo") packages in
the package proposal summary (fate#318257)
- 2.17.25

-------------------------------------------------------------------
Mon Feb 25 12:36:15 CET 2013 - jsuchome@suse.cz

Expand Down
51 changes: 51 additions & 0 deletions src/clients/packages_proposal.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,43 @@
return ret;
}

// count locked packages
define map<symbol, integer> locked_packages()
{
list<string> protected = [];
list<string> taboo = [];

list<map> packages = Pkg::ResolvableProperties("", `package, "");

// Pkg::ResolvableProperties returns all package instances (all versions),
// we have to ensure that a package is either in "taboo" or "protected"
// list (but never in both) and each package is counted only once
foreach(map package, packages, {
if (package["locked"]:false)
{
string name = package["name"]:"";

if (package["status"]:nil == `available && !contains(taboo, name) &&
!contains(protected, name))
{
taboo = add(taboo, name);
}

if (package["status"]:nil == `installed && !contains(protected, name))
{
protected = add(protected, name);

// remove from taboo if a different version is there
taboo = filter(string taboo_name, taboo, { return taboo_name != name; });
}
}
});

y2milestone("Protected packages: %1", protected);
y2milestone("Taboo packages: %1", taboo);

return $[ `protected : size(protected), `taboo : size(taboo) ];
}

if ( func == "MakeProposal" )
{
Expand Down Expand Up @@ -107,6 +144,20 @@
// proposal for packages during update, %1 is count of packages
tmp = add (tmp, sformat (_("New Packages to Install: %1"),
Update::packages_to_install));

map<symbol, integer> locked = locked_packages();
if (locked[`protected]:0 > 0)
{
// summary text, %1 is a number of protected packages,
// (kept in the current version, disabled for upgrade)
tmp = add(tmp, HTML::Colorize(sformat(_("Protected Packages: %1"), locked[`protected]:0), "red"));
}
if (locked[`taboo]:0 > 0)
{
// summary text, %1 is a number of taboo packages (forbidden to install)
tmp = add(tmp, HTML::Colorize(sformat(_("Taboo Packages: %1"), locked[`taboo]:0), "red"));
}

// proposal for packages during update, %1 is count of packages
tmp = add (tmp, sformat (_("Packages to Remove: %1"),
Update::packages_to_remove));
Expand Down

0 comments on commit 25a6ad3

Please sign in to comment.