Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 16, 2015
1 parent e96e207 commit 634a6e4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/clients/packages_proposal.ycp
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, "");

// counting packages is little bit tricky, Pkg::ResolvableProperties
// returns all package instances (all versions), we have to ensure
// that a package is either is "taboo" or "protected" list (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,9 +144,24 @@
// 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 locked 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));

// part of summary, %1 is size of packages (in MB or GB)
tmp = add (tmp, sformat (_("Total Size of Packages to Update: %1"),
Packages::CountSizeToBeInstalled ()));
Expand Down

0 comments on commit 634a6e4

Please sign in to comment.