From 34c3d5a02a03575430dd43477fcc1e9875017c3d Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 1 Jun 2018 12:26:56 -0400 Subject: [PATCH] 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 --- man/rpm-ostree.xml | 19 +++++++++++++++++++ src/app/rpmostree-pkg-builtins.c | 3 +++ src/daemon/org.projectatomic.rpmostree1.xml | 3 +++ src/daemon/rpmostreed-os.c | 2 ++ src/daemon/rpmostreed-transaction-types.c | 13 +++++++++++-- src/daemon/rpmostreed-transaction-types.h | 1 + tests/vmcheck/test-layering-basic-2.sh | 6 ++++++ 7 files changed, 45 insertions(+), 2 deletions(-) diff --git a/man/rpm-ostree.xml b/man/rpm-ostree.xml index 70a87597..462195d8 100644 --- a/man/rpm-ostree.xml +++ b/man/rpm-ostree.xml @@ -225,6 +225,20 @@ Boston, MA 02111-1307, USA. local package that resides on the host. + + 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. + + + + Note that currently, you may specify a package that is + already in the base layer, though you should use the + --allow-inactive option to avoid a + warning. This option will become mandatory in the future. + + --reboot or -r 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. + + to allow requests for + packages that are already in the base layer. + + or -C to perform the operation without trying to download the latest diff --git a/src/app/rpmostree-pkg-builtins.c b/src/app/rpmostree-pkg-builtins.c index baf1bb85..12881b9f 100644 --- a/src/app/rpmostree-pkg-builtins.c +++ b/src/app/rpmostree-pkg-builtins.c @@ -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; diff --git a/src/daemon/org.projectatomic.rpmostree1.xml b/src/daemon/org.projectatomic.rpmostree1.xml index 949afb7b..385ef73c 100644 --- a/src/daemon/org.projectatomic.rpmostree1.xml +++ b/src/daemon/org.projectatomic.rpmostree1.xml @@ -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. --> diff --git a/src/daemon/rpmostreed-os.c b/src/daemon/rpmostreed-os.c index e922cfb2..54165012 100644 --- a/src/daemon/rpmostreed-os.c +++ b/src/daemon/rpmostreed-os.c @@ -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; } diff --git a/src/daemon/rpmostreed-transaction-types.c b/src/daemon/rpmostreed-transaction-types.c index dd45710e..ddc944d5 100644 --- a/src/daemon/rpmostreed-transaction-types.c +++ b/src/daemon/rpmostreed-transaction-types.c @@ -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); + } } } diff --git a/src/daemon/rpmostreed-transaction-types.h b/src/daemon/rpmostreed-transaction-types.h index 4dfaafa8..0afb241d 100644 --- a/src/daemon/rpmostreed-transaction-types.h +++ b/src/daemon/rpmostreed-transaction-types.h @@ -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; diff --git a/tests/vmcheck/test-layering-basic-2.sh b/tests/vmcheck/test-layering-basic-2.sh index 3301e5d7..ef4f42aa 100755 --- a/tests/vmcheck/test-layering-basic-2.sh +++ b/tests/vmcheck/test-layering-basic-2.sh @@ -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:"