Skip to content

Commit

Permalink
app: add -C flag to always use cached metadata
Browse files Browse the repository at this point in the history
This is the equivalent version of `yum/dnf -C`. It goes together with
the new `makecache` command to allow completely asynchronous cache
update and usage.

Closes: #1035
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Oct 6, 2017
1 parent d0b69b4 commit b7efe6c
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/app/rpmostree-builtin-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
static char *opt_osname;
static gboolean opt_reboot;
static gboolean opt_preview;
static gboolean opt_cache_only;

static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
Expand All @@ -39,6 +40,7 @@ static GOptionEntry option_entries[] = {
* A --preview option would work for both commands if we wanted to
* deprecate --check-diff. */
{ "preview", 0, 0, G_OPTION_ARG_NONE, &opt_preview, "Just preview package differences", NULL },
{ "cache-only", 'C', 0, G_OPTION_ARG_NONE, &opt_cache_only, "Do not update repo metadata cache", NULL },
{ NULL }
};

Expand Down Expand Up @@ -109,6 +111,7 @@ rpmostree_builtin_deploy (int argc,
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
TRUE, /* allow-downgrade */
opt_cache_only,
FALSE, /* skip-purge */
FALSE, /* no-pull-base */
FALSE, /* dry-run */
Expand Down
3 changes: 3 additions & 0 deletions src/app/rpmostree-builtin-rebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ static gboolean opt_reboot;
static gboolean opt_skip_purge;
static char * opt_branch;
static char * opt_remote;
static gboolean opt_cache_only;

static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &opt_branch, "Rebase to branch BRANCH; use --remote to change remote as well", "BRANCH" },
{ "remote", 'm', 0, G_OPTION_ARG_STRING, &opt_remote, "Rebase to current branch name using REMOTE; may also be combined with --branch", "REMOTE" },
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after rebase is finished", NULL },
{ "skip-purge", 0, 0, G_OPTION_ARG_NONE, &opt_skip_purge, "Keep previous refspec after rebase", NULL },
{ "cache-only", 'C', 0, G_OPTION_ARG_NONE, &opt_cache_only, "Do not update repo metadata cache", NULL },
{ NULL }
};

Expand Down Expand Up @@ -114,6 +116,7 @@ rpmostree_builtin_rebase (int argc,
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
TRUE, /* allow-downgrade */
opt_cache_only,
opt_skip_purge,
FALSE, /* no-pull-base */
FALSE, /* dry-run */
Expand Down
5 changes: 3 additions & 2 deletions src/app/rpmostree-builtin-rollback.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ rpmostree_builtin_rollback (int argc,
g_autoptr(GVariant) previous_deployment = rpmostree_os_dup_default_deployment (os_proxy);
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
FALSE, /* allow-downgrade */
FALSE,
FALSE, /* allow-downgrade */
FALSE, /* cache-only */
FALSE, /* skip-purge */
FALSE, /* no-pull-base */
FALSE, /* dry-run */
FALSE); /* no-overrides */
Expand Down
3 changes: 3 additions & 0 deletions src/app/rpmostree-builtin-upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static gboolean opt_allow_downgrade;
static gboolean opt_preview;
static gboolean opt_check;
static gboolean opt_upgrade_unchanged_exit_77;
static gboolean opt_cache_only;

/* "check-diff" is deprecated, replaced by "preview" */
static GOptionEntry option_entries[] = {
Expand All @@ -46,6 +47,7 @@ static GOptionEntry option_entries[] = {
{ "check-diff", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_preview, "Check for upgrades and print package diff only", NULL },
{ "preview", 0, 0, G_OPTION_ARG_NONE, &opt_preview, "Just preview package differences", NULL },
{ "check", 0, 0, G_OPTION_ARG_NONE, &opt_check, "Just check if an upgrade is available", NULL },
{ "cache-only", 'C', 0, G_OPTION_ARG_NONE, &opt_cache_only, "Do not update repo metadata cache", NULL },
{ "upgrade-unchanged-exit-77", 0, 0, G_OPTION_ARG_NONE, &opt_upgrade_unchanged_exit_77, "If no upgrade is available, exit 77", NULL },
{ NULL }
};
Expand Down Expand Up @@ -121,6 +123,7 @@ rpmostree_builtin_upgrade (int argc,
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
opt_allow_downgrade,
opt_cache_only,
FALSE, /* skip-purge */
FALSE, /* no-pull-base */
FALSE, /* dry-run */
Expand Down
2 changes: 2 additions & 0 deletions src/app/rpmostree-dbus-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ get_modifiers_variant (const char *set_refspec,
GVariant*
rpmostree_get_options_variant (gboolean reboot,
gboolean allow_downgrade,
gboolean cache_only,
gboolean skip_purge,
gboolean no_pull_base,
gboolean dry_run,
Expand All @@ -1074,6 +1075,7 @@ rpmostree_get_options_variant (gboolean reboot,
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert (&dict, "reboot", "b", reboot);
g_variant_dict_insert (&dict, "allow-downgrade", "b", allow_downgrade);
g_variant_dict_insert (&dict, "rpmmd-cache-only", "b", cache_only);
g_variant_dict_insert (&dict, "skip-purge", "b", skip_purge);
g_variant_dict_insert (&dict, "no-pull-base", "b", no_pull_base);
g_variant_dict_insert (&dict, "dry-run", "b", dry_run);
Expand Down
1 change: 1 addition & 0 deletions src/app/rpmostree-dbus-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ rpmostree_sort_pkgs_strv (const char *const* pkgs,
GVariant*
rpmostree_get_options_variant (gboolean reboot,
gboolean allow_downgrade,
gboolean cache_only,
gboolean skip_purge,
gboolean no_pull_base,
gboolean dry_run,
Expand Down
1 change: 1 addition & 0 deletions src/app/rpmostree-override-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ handle_override (RPMOSTreeSysroot *sysroot_proxy,
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
FALSE, /* allow-downgrade */
FALSE, /* cache-only */
FALSE, /* skip-purge */
TRUE, /* no-pull-base */
opt_dry_run,
Expand Down
3 changes: 3 additions & 0 deletions src/app/rpmostree-pkg-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ static gboolean opt_reboot;
static gboolean opt_dry_run;
static gchar **opt_install;
static gchar **opt_uninstall;
static gboolean opt_cache_only;

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 },
{ "cache-only", 'C', 0, G_OPTION_ARG_NONE, &opt_cache_only, "Do not update repo metadata cache", NULL },
{ NULL }
};

Expand Down Expand Up @@ -75,6 +77,7 @@ pkg_change (RPMOSTreeSysroot *sysroot_proxy,
g_autoptr(GVariant) options =
rpmostree_get_options_variant (opt_reboot,
FALSE, /* allow-downgrade */
opt_cache_only,
FALSE, /* skip-purge */
TRUE, /* no-pull-base */
opt_dry_run,
Expand Down
2 changes: 2 additions & 0 deletions src/daemon/org.projectatomic.rpmostree1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@
"no-overrides" (type 'b')
Remove all active overrides. Not valid if any override
modifiers are specified.
"rpmmd-cache-only" (type 'b')
Do not update rpmmd repo metadata cache.
-->
<method name="UpdateDeployment">
<arg type="a{sv}" name="modifiers" direction="in"/>
Expand Down
6 changes: 6 additions & 0 deletions src/daemon/rpmostree-sysroot-upgrader.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,12 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self,
cancellable, error))
return FALSE;

if (self->flags & RPMOSTREE_SYSROOT_UPGRADER_FLAGS_RPMMD_CACHE_ONLY)
{
DnfContext *hifctx = rpmostree_context_get_hif (self->ctx);
dnf_context_set_cache_age (hifctx, G_MAXUINT);
}

g_autoptr(OstreeRepo) pkgcache_repo = NULL;
if (!rpmostree_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
return FALSE;
Expand Down
4 changes: 3 additions & 1 deletion src/daemon/rpmostree-sysroot-upgrader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (RpmOstreeSysrootUpgrader, g_object_unref)
* @RPMOSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED: Do not error if the origin has an unconfigured-state key
* @RPMOSTREE_SYSROOT_UPGRADER_FLAGS_ALLOW_OLDER: Do not error if the new deployment was composed earlier than the current deployment
* @RPMOSTREE_SYSROOT_UPGRADER_FLAGS_DRY_RUN: Don't deploy new base. If layering packages, only print the transaction
* @RPMOSTREE_SYSROOT_UPGRADER_FLAGS_DRY_RUN: Don't update rpmmd cache.
*
* Flags controlling operation of an #RpmOstreeSysrootUpgrader.
*/
typedef enum {
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_NONE = (1 << 0),
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED = (1 << 1),
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_ALLOW_OLDER = (1 << 2),
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_DRY_RUN = (1 << 3)
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_DRY_RUN = (1 << 3),
RPMOSTREE_SYSROOT_UPGRADER_FLAGS_RPMMD_CACHE_ONLY = (1 << 4)
} RpmOstreeSysrootUpgraderFlags;

/* _NONE means we're doing pure ostree, no client-side computation.
Expand Down
2 changes: 2 additions & 0 deletions src/daemon/rpmostreed-os.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ deploy_flags_from_options (GVariant *options,
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DRY_RUN;
if (vardict_lookup_bool (&dict, "no-overrides", FALSE))
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_NO_OVERRIDES;
if (vardict_lookup_bool (&dict, "rpmmd-cache-only", FALSE))
ret |= RPMOSTREE_TRANSACTION_DEPLOY_FLAG_RPMMD_CACHE_ONLY;
return ret;
}

Expand Down
4 changes: 3 additions & 1 deletion src/daemon/rpmostreed-transaction-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
upgrader_flags |= RPMOSTREE_SYSROOT_UPGRADER_FLAGS_ALLOW_OLDER;
if (self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DRY_RUN)
upgrader_flags |= RPMOSTREE_SYSROOT_UPGRADER_FLAGS_DRY_RUN;
gboolean no_overrides =
if (self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_RPMMD_CACHE_ONLY)
upgrader_flags |= RPMOSTREE_SYSROOT_UPGRADER_FLAGS_RPMMD_CACHE_ONLY;
const gboolean no_overrides =
((self->flags & RPMOSTREE_TRANSACTION_DEPLOY_FLAG_NO_OVERRIDES) > 0);

/* this should have been checked already */
Expand Down
3 changes: 2 additions & 1 deletion src/daemon/rpmostreed-transaction-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ typedef enum {
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_ALLOW_DOWNGRADE = (1 << 2),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_NO_PULL_BASE = (1 << 4),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_DRY_RUN = (1 << 5),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_NO_OVERRIDES = (1 << 6)
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_NO_OVERRIDES = (1 << 6),
RPMOSTREE_TRANSACTION_DEPLOY_FLAG_RPMMD_CACHE_ONLY = (1 << 7),
} RpmOstreeTransactionDeployFlags;


Expand Down

0 comments on commit b7efe6c

Please sign in to comment.