Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: add 'makecache' command #1035

Closed
wants to merge 12 commits into from
Closed
1 change: 1 addition & 0 deletions Makefile-rpm-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rpm_ostree_SOURCES = src/app/main.c \
src/app/rpmostree-builtin-initramfs.c \
src/app/rpmostree-builtin-livefs.c \
src/app/rpmostree-builtin-override.c \
src/app/rpmostree-builtin-refresh-md.c \
src/app/rpmostree-pkg-builtins.c \
src/app/rpmostree-builtin-status.c \
src/app/rpmostree-builtin-ex.c \
Expand Down
11 changes: 11 additions & 0 deletions man/rpm-ostree.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ Boston, MA 02111-1307, USA.
</listitem>
</varlistentry>

<varlistentry>
<term><command>refresh-md</command></term>

<listitem>
<para>
Download the latest rpm repo metadata if necessary and generate the
cache.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><command>cleanup</command></term>

Expand Down
5 changes: 5 additions & 0 deletions src/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ static RpmOstreeCommand commands[] = {
{ "uninstall", 0,
"Remove one or more overlay packages",
rpmostree_builtin_uninstall },
{ "refresh-md", 0,
"Generate rpm repo metadata",
rpmostree_builtin_refresh_md },
/* Legacy aliases */
{ "pkg-add", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_install },
Expand All @@ -82,6 +85,8 @@ static RpmOstreeCommand commands[] = {
{ "rpm", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_db },
{ "makecache", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_refresh_md },
/* Hidden */
{ "ex", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
Expand Down
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
97 changes: 97 additions & 0 deletions src/app/rpmostree-builtin-refresh-md.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* Copyright (C) 2017 Jonathan Lebon <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the licence or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

#include "config.h"

#include <string.h>
#include <glib-unix.h>

#include "rpmostree-builtins.h"
#include "rpmostree-util.h"
#include "rpmostree-libbuiltin.h"
#include "rpmostree-dbus-helpers.h"

#include <libglnx.h>

static char *opt_osname;
static char *opt_force;

static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
{ "force", 'f', 0, G_OPTION_ARG_NONE, &opt_force, "Expire current cache", NULL },
{ NULL }
};

static GVariant *
get_args_variant (void)
{
GVariantDict dict;
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert (&dict, "force", "b", opt_force);
return g_variant_dict_end (&dict);
}

int
rpmostree_builtin_refresh_md (int argc,
char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GOptionContext) context = g_option_context_new ("");
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
g_autofree char *transaction_address = NULL;
_cleanup_peer_ GPid peer_pid = 0;

if (!rpmostree_option_context_parse (context,
option_entries,
&argc, &argv,
invocation,
cancellable,
NULL, NULL,
&sysroot_proxy,
&peer_pid,
error))
return EXIT_FAILURE;

if (argc < 1 || argc > 2)
{
rpmostree_usage_error (context, "Too few or too many arguments", error);
return EXIT_FAILURE;
}

if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname,
cancellable, &os_proxy, error))
return EXIT_FAILURE;

if (!rpmostree_os_call_refresh_md_sync (os_proxy,
get_args_variant (),
&transaction_address,
cancellable,
error))
return EXIT_FAILURE;

if (!rpmostree_transaction_get_response_sync (sysroot_proxy,
transaction_address,
cancellable,
error))
return EXIT_FAILURE;

return EXIT_SUCCESS;
}
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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah...but what about the ostree side? The option makes sense there too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I was mostly going off of the --cache-only naming from the compose side. I suppose we'll have to have a new switch there too for unified core re. ostree caching? Would be nice to keep it consistent across those commands.

{ "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
1 change: 1 addition & 0 deletions src/app/rpmostree-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ BUILTINPROTO(cleanup);
BUILTINPROTO(rollback);
BUILTINPROTO(initramfs);
BUILTINPROTO(status);
BUILTINPROTO(refresh_md);
BUILTINPROTO(db);
BUILTINPROTO(internals);
BUILTINPROTO(container);
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
7 changes: 7 additions & 0 deletions src/daemon/org.projectatomic.rpmostree1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
<arg type="s" name="transaction_address" direction="out"/>
</method>

<method name="RefreshMd">
<arg type="a{sv}" name="options" direction="in"/>
<arg type="s" name="transaction_address" direction="out"/>
</method>

<!-- Available modifiers:
"set-refspec" (type 's')
"set-revision" (type 's')
Expand Down Expand Up @@ -255,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
Loading