app/override: allow removing and replacing atomically
This is an essential functionality rather than a nicety. Some replacements can *only* be done without conflicts if we can remove packages at the same time. I do like that this has to be done explicitly, though OTOH, I can definitely see folks wanting an `--allow-removals` type of switch in the future. Closes: #1255 Closes: #1257 Approved by: cgwalters
This commit is contained in:
parent
5879b96a64
commit
ff9c19acd3
@ -29,6 +29,8 @@ static char *opt_osname;
|
|||||||
static gboolean opt_reboot;
|
static gboolean opt_reboot;
|
||||||
static gboolean opt_dry_run;
|
static gboolean opt_dry_run;
|
||||||
static gboolean opt_reset_all;
|
static gboolean opt_reset_all;
|
||||||
|
static const char *const *opt_remove_pkgs;
|
||||||
|
static const char *const *opt_replace_pkgs;
|
||||||
static const char *const *install_pkgs;
|
static const char *const *install_pkgs;
|
||||||
static const char *const *uninstall_pkgs;
|
static const char *const *uninstall_pkgs;
|
||||||
|
|
||||||
@ -44,6 +46,16 @@ static GOptionEntry reset_option_entries[] = {
|
|||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GOptionEntry replace_option_entries[] = {
|
||||||
|
{ "remove", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_remove_pkgs, "Remove a package", "PKG" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static GOptionEntry remove_option_entries[] = {
|
||||||
|
{ "replace", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_replace_pkgs, "Replace a package", "RPM" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_override (RPMOSTreeSysroot *sysroot_proxy,
|
handle_override (RPMOSTreeSysroot *sysroot_proxy,
|
||||||
const char *const *override_remove,
|
const char *const *override_remove,
|
||||||
@ -124,6 +136,8 @@ rpmostree_override_builtin_replace (int argc, char **argv,
|
|||||||
|
|
||||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||||
|
|
||||||
|
g_option_context_add_main_entries (context, replace_option_entries, NULL);
|
||||||
|
|
||||||
if (!rpmostree_option_context_parse (context,
|
if (!rpmostree_option_context_parse (context,
|
||||||
option_entries,
|
option_entries,
|
||||||
&argc, &argv,
|
&argc, &argv,
|
||||||
@ -149,7 +163,7 @@ rpmostree_override_builtin_replace (int argc, char **argv,
|
|||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
||||||
return handle_override (sysroot_proxy,
|
return handle_override (sysroot_proxy,
|
||||||
NULL, (const char *const*)argv, NULL,
|
opt_remove_pkgs, (const char *const*)argv, NULL,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +179,8 @@ rpmostree_override_builtin_remove (int argc, char **argv,
|
|||||||
|
|
||||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||||
|
|
||||||
|
g_option_context_add_main_entries (context, remove_option_entries, NULL);
|
||||||
|
|
||||||
if (!rpmostree_option_context_parse (context,
|
if (!rpmostree_option_context_parse (context,
|
||||||
option_entries,
|
option_entries,
|
||||||
&argc, &argv,
|
&argc, &argv,
|
||||||
@ -190,7 +206,7 @@ rpmostree_override_builtin_remove (int argc, char **argv,
|
|||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
||||||
return handle_override (sysroot_proxy,
|
return handle_override (sysroot_proxy,
|
||||||
(const char *const*)argv, NULL, NULL,
|
(const char *const*)argv, opt_replace_pkgs, NULL,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,17 +164,22 @@ echo "ok active -> inactive -> active override replace"
|
|||||||
|
|
||||||
vm_rpmostree cleanup -p
|
vm_rpmostree cleanup -p
|
||||||
|
|
||||||
# try both local package layering and local replacements to
|
# try both local package layering and local replacements to make sure fd sending
|
||||||
# make sure fd sending doesn't get mixed up
|
# doesn't get mixed up; and also remove a package at the same time
|
||||||
vm_build_rpm baz
|
vm_build_rpm baz
|
||||||
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo_and_bar
|
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo_and_bar
|
||||||
vm_rpmostree upgrade
|
vm_rpmostree upgrade
|
||||||
vm_rpmostree override replace $YUMREPO/bar-0.9-1.x86_64.rpm \
|
vm_rpmostree override replace $YUMREPO/bar-0.9-1.x86_64.rpm \
|
||||||
--install $YUMREPO/baz-1.0-1.x86_64.rpm
|
--install $YUMREPO/baz-1.0-1.x86_64.rpm \
|
||||||
|
--remove foo --remove fooext
|
||||||
vm_assert_status_jq \
|
vm_assert_status_jq \
|
||||||
'.deployments[0]["base-local-replacements"]|length == 1' \
|
'.deployments[0]["base-local-replacements"]|length == 1' \
|
||||||
'.deployments[0]["requested-base-local-replacements"]|length == 1' \
|
'.deployments[0]["requested-base-local-replacements"]|length == 1' \
|
||||||
'.deployments[0]["requested-local-packages"]|length == 1' \
|
'.deployments[0]["requested-local-packages"]|length == 1' \
|
||||||
'.deployments[0]["requested-local-packages"]|index("baz-1.0-1.x86_64") >= 0'
|
'.deployments[0]["requested-local-packages"]|index("baz-1.0-1.x86_64") >= 0' \
|
||||||
|
'.deployments[0]["base-removals"]|length == 2' \
|
||||||
|
'[.deployments[0]["base-removals"][][.0]]|index("foo-1.0-1.x86_64") >= 0' \
|
||||||
|
'.deployments[0]["requested-base-removals"]|length == 2' \
|
||||||
|
'.deployments[0]["requested-base-removals"]|index("foo") >= 0'
|
||||||
assert_replaced_local_pkg bar-1.0-1.x86_64 bar-0.9-1.x86_64
|
assert_replaced_local_pkg bar-1.0-1.x86_64 bar-0.9-1.x86_64
|
||||||
echo "ok local replace and local layering"
|
echo "ok local replace and local layering"
|
||||||
|
Loading…
Reference in New Issue
Block a user