daemon/deploy: Warn on immediately inactive requests
This has been a huge point of confusion for users with the new declarative way of specifying package requests (see #1216, #1287). Essentially, doing `rpm-ostree install glibc` will work, but it's not very useful because we don't really expect glibc to ever go away. As a heuristic, let's work towards forbidding package requests that would immediately become inactive. For now, we just print a warning. Note that this still leaves the door open for layered pkgs that e.g. become inactive during a rebase to a tree which has it baked in, and then active again when rebasing back; supporting this was the major advantage of switching to a declarative approach. Closes: #1378 Approved by: cgwalters
This commit is contained in:
parent
315406d8cd
commit
3c12a58b25
@ -879,6 +879,31 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
|
||||
|
||||
if (self->install_pkgs)
|
||||
{
|
||||
/* we run a special check here; let's just not allow trying to install a pkg that will
|
||||
* right away become inactive because it's already installed */
|
||||
const char *base = rpmostree_sysroot_upgrader_get_base (upgrader);
|
||||
g_autoptr(RpmOstreeRefSack) rsack =
|
||||
rpmostree_get_refsack_for_commit (repo, base, cancellable, error);
|
||||
if (rsack == NULL)
|
||||
return FALSE;
|
||||
|
||||
for (char **it = self->install_pkgs; it && *it; it++)
|
||||
{
|
||||
const char *pkg = *it;
|
||||
g_autoptr(GPtrArray) pkgs = rpmostree_get_matching_packages (rsack->sack, pkg);
|
||||
if (pkgs->len > 0)
|
||||
{
|
||||
g_autoptr(GString) pkgnames = g_string_new ("");
|
||||
for (guint i = 0; i < pkgs->len; i++)
|
||||
{
|
||||
DnfPackage *p = pkgs->pdata[i];
|
||||
g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p));
|
||||
}
|
||||
rpmostree_output_message ("warning: Package \"%s\" is already provided by:%s",
|
||||
pkg, pkgnames->str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!rpmostree_origin_add_packages (origin, self->install_pkgs, FALSE, error))
|
||||
return FALSE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user