app/install: Add --allow-inactive switch

For now all this switch does is turn off the scary warning. We also
tweak the warning to make it clear that this will be required in a
future release.

Closes: #1378
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-06-01 12:26:56 -04:00 committed by Atomic Bot
parent 625c17f9b0
commit 34c3d5a02a
7 changed files with 45 additions and 2 deletions

View File

@ -225,6 +225,20 @@ Boston, MA 02111-1307, USA.
local package that resides on the host.
</para>
<para>
rpm-ostree remembers these requests even if a later host
update includes those packages already: if the packages are
subsequently dropped out again, rpm-ostree will go back to
layering them.
</para>
<para>
Note that currently, you may specify a package that is
already in the base layer, though you should use the
<command>--allow-inactive</command> option to avoid a
warning. This option will become mandatory in the future.
</para>
<para>
<command>--reboot</command> or <command>-r</command> to
initiate a reboot after the deployment is prepared.
@ -236,6 +250,11 @@ Boston, MA 02111-1307, USA.
the packages and creating a new deployment.
</para>
<para>
<option>--allow-inactive</option> to allow requests for
packages that are already in the base layer.
</para>
<para>
<option>--cache-only</option> or <command>-C</command> to
perform the operation without trying to download the latest

View File

@ -36,11 +36,13 @@ static gchar **opt_install;
static gchar **opt_uninstall;
static gboolean opt_cache_only;
static gboolean opt_download_only;
static gboolean opt_allow_inactive;
static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after upgrade is prepared", NULL },
{ "dry-run", 'n', 0, G_OPTION_ARG_NONE, &opt_dry_run, "Exit after printing the transaction", NULL },
{ "allow-inactive", 0, 0, G_OPTION_ARG_NONE, &opt_allow_inactive, "Allow inactive package requests", NULL },
{ NULL }
};
@ -85,6 +87,7 @@ pkg_change (RpmOstreeCommandInvocation *invocation,
g_variant_dict_insert (&dict, "download-only", "b", opt_download_only);
g_variant_dict_insert (&dict, "no-pull-base", "b", TRUE);
g_variant_dict_insert (&dict, "dry-run", "b", opt_dry_run);
g_variant_dict_insert (&dict, "allow-inactive", "b", opt_allow_inactive);
g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_dict_end (&dict));
gboolean met_local_pkg = FALSE;

View File

@ -320,6 +320,9 @@
perform any deployments. This is like "dry-run" except that
the latter does not download and import packages. Not valid
if "cache-only" or "dry-run" is specified.
"allow-inactive-requests" (type 'b')
When installing packages, allow package requests which would
not immediately be active.
-->
<method name="UpdateDeployment">
<arg type="a{sv}" name="modifiers" direction="in"/>

View File

@ -579,6 +579,8 @@ deploy_flags_from_options (GVariant *options,
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_CACHE_ONLY;
if (vardict_lookup_bool (&dict, "download-only", FALSE))
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DOWNLOAD_ONLY;
if (vardict_lookup_bool (&dict, "allow-inactive", FALSE))
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_ALLOW_INACTIVE;
return ret;
}

View File

@ -739,6 +739,8 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
* amount of metadata only to check if there's an upgrade */
const gboolean download_metadata_only =
((self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DOWNLOAD_METADATA_ONLY) > 0);
const gboolean allow_inactive =
((self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_ALLOW_INACTIVE) > 0);
RpmOstreeSysrootUpgraderFlags upgrader_flags = 0;
if (self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_ALLOW_DOWNGRADE)
@ -906,8 +908,15 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
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 (!allow_inactive)
{
/* XXX: awkward CLI mention here */
rpmostree_output_message (
"warning: deprecated: \"%s\" is already provided by:%s. Use "
"--allow-inactive to squash this warning. A future release will make "
"this a requirement. See rpm-ostree(1) for details.",
pkg, pkgnames->str);
}
}
}

View File

@ -59,6 +59,7 @@ typedef enum {
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DOWNLOAD_ONLY = (1 << 8),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DOWNLOAD_METADATA_ONLY = (1 << 9),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_STAGE = (1 << 10),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_ALLOW_INACTIVE = (1 << 11),
} RpmOstreeTransactionDeployFlags;

View File

@ -88,3 +88,9 @@ vm_cmd ostree show --print-metadata-key rpmostree.rpmdb.pkglist \
$(vm_get_deployment_info 0 checksum) > pkglist.txt
assert_file_has_content pkglist.txt 'test-pkgcache-migrate-pkg'
echo "ok layered pkglist"
vm_rpmostree install glibc &>out.txt
assert_file_has_content out.txt "warning: .* Use --allow-inactive to squash this warning."
vm_rpmostree cleanup -p
vm_rpmostree install glibc --allow-inactive &>out.txt
assert_not_file_has_content out.txt "warning:"