app: Lift kargs out of experimental

It's been in experimental for a while now, and we've had good feedback
that it's working. With #1392 fixed, it seems in a good position to
declare stable and commit to that API. This also helps empty out `ex` a
bit.

Closes: #1428
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-06-26 10:38:45 -04:00 committed by Atomic Bot
parent 77e2e19c1f
commit c84b8b81db
8 changed files with 56 additions and 30 deletions

View File

@ -511,6 +511,29 @@ Boston, MA 02111-1307, USA.
</listitem>
</varlistentry>
<varlistentry>
<term><command>kargs</command></term>
<listitem>
<para>
Without options, display current default kernel arguments. Modify
arguments using <option>--append</option>,
<option>--replace</option>, <option>--delete</option>, or
<option>--editor</option>. This will create a new deployment with
the modified kernel arguments. Previous deployments are never
changed.
</para>
<para>
By default, modifications are applied to the kernel arguments of the
default deployment to get the final arguments. Use
<option>--deploy-index</option> or
<option>--import-proc-cmdline</option> to instead base them off of a
specific deployment or the current boot.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>cleanup</command></term>

View File

@ -89,6 +89,9 @@ static RpmOstreeCommand commands[] = {
{ "refresh-md", 0,
"Generate rpm repo metadata",
rpmostree_builtin_refresh_md },
{ "kargs", 0,
"Query or modify kernel arguments",
rpmostree_builtin_kargs },
/* Legacy aliases */
{ "pkg-add", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_install },

View File

@ -28,12 +28,13 @@ static RpmOstreeCommand ex_subcommands[] = {
rpmostree_ex_builtin_livefs },
{ "container", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Assemble local unprivileged containers", rpmostree_builtin_container },
{ "kargs", 0,
"Query or Modify the kernel arguments", rpmostree_ex_builtin_kargs },
{ "commit2rojig", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Convert an OSTree commit into an rpm-ostree rojig", rpmostree_ex_builtin_commit2rojig },
{ "rojig2commit", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Convert an rpm-ostree rojig into an OSTree commit", rpmostree_ex_builtin_rojig2commit },
/* temporary aliases; nuke in next version */
{ "kargs", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_kargs },
{ NULL, 0, NULL, NULL }
};

View File

@ -39,7 +39,7 @@ static char *opt_deploy_index;
static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operation on provided OSNAME", "OSNAME" },
{ "deploy-index", 0, 0, G_OPTION_ARG_STRING, &opt_deploy_index, "Modify the kernel args from a specific deployment based on index. Index is in the form of a number (e.g 0 means the first deployment in the list)", "INDEX"},
{ "deploy-index", 0, 0, G_OPTION_ARG_STRING, &opt_deploy_index, "Modify the kernel args from a specific deployment based on index. Index is in the form of a number (e.g. 0 means the first deployment in the list)", "INDEX"},
{ "reboot", 0, 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after operation is complete", NULL},
{ "append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_append_strings, "Append kernel argument; useful with e.g. console= that can be used multiple times. empty value for an argument is allowed", "KEY=VALUE" },
{ "replace", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_replace_strings, "Replace existing kernel argument, the user is also able to replace an argument with KEY=VALUE if only one value exist for that argument ", "KEY=VALUE=NEWVALUE" },
@ -169,11 +169,11 @@ kernel_arg_handle_editor (const char *input_kernel_arg,
gboolean
rpmostree_ex_builtin_kargs (int argc,
char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
rpmostree_builtin_kargs (int argc,
char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
_cleanup_peer_ GPid peer_pid = 0;
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
@ -217,7 +217,7 @@ rpmostree_ex_builtin_kargs (int argc,
if (opt_import_proc_cmdline && opt_deploy_index)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Cannot specify both --import-from-proc-cmdline and --deployid");
"Cannot specify both --import-from-proc-cmdline and --deploy-index");
return FALSE;
}
if (opt_import_proc_cmdline && opt_osname)

View File

@ -48,6 +48,7 @@ BUILTINPROTO(container);
BUILTINPROTO(install);
BUILTINPROTO(uninstall);
BUILTINPROTO(override);
BUILTINPROTO(kargs);
BUILTINPROTO(start_daemon);
BUILTINPROTO(ex);

View File

@ -32,8 +32,6 @@ G_BEGIN_DECLS
BUILTINPROTO(unpack);
BUILTINPROTO(livefs);
BUILTINPROTO(override);
BUILTINPROTO(kargs);
BUILTINPROTO(commit2rojig);
BUILTINPROTO(rojig2commit);

View File

@ -1139,7 +1139,7 @@ os_handle_get_deployment_boot_config (RPMOSTreeOS *interface,
}
else
{
/* If the deploy_index is speicified, we ignore the pending option */
/* If the deploy_index is specified, we ignore the pending option */
target_deployment = rpmostreed_deployment_get_for_index (ot_sysroot, arg_deploy_index,
&local_error);
if (target_deployment == NULL)

View File

@ -26,59 +26,59 @@ set -x
osname=$(vm_get_booted_deployment_info osname)
vm_rpmostree ex kargs > kargs.txt
vm_rpmostree kargs > kargs.txt
conf_content=$(vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf | sed -e 's,options ,,')
assert_file_has_content_literal kargs.txt "$conf_content"
echo "ok kargs display matches options"
vm_rpmostree ex kargs --append=FOO=BAR --append=APPENDARG=VALAPPEND --append=APPENDARG=2NDAPPEND
vm_rpmostree kargs --append=FOO=BAR --append=APPENDARG=VALAPPEND --append=APPENDARG=2NDAPPEND
# read the conf file into a txt for future comparison
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > tmp_conf.txt
assert_file_has_content_literal tmp_conf.txt 'FOO=BAR'
assert_file_has_content_literal tmp_conf.txt 'APPENDARG=VALAPPEND APPENDARG=2NDAPPEND'
# Ensure the result flows through with rpm-ostree ex kargs
vm_rpmostree ex kargs > kargs.txt
# Ensure the result flows through with rpm-ostree kargs
vm_rpmostree kargs > kargs.txt
assert_file_has_content_literal kargs.txt 'FOO=BAR'
assert_file_has_content_literal kargs.txt 'APPENDARG=VALAPPEND APPENDARG=2NDAPPEND'
echo "ok kargs append"
# Test for rpm-ostree ex kargs delete
vm_rpmostree ex kargs --delete FOO
# Test for rpm-ostree kargs delete
vm_rpmostree kargs --delete FOO
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > tmp_conf.txt
assert_not_file_has_content tmp_conf.txt 'FOO=BAR'
echo "ok delete a single key/value pair"
if vm_rpmostree ex kargs --delete APPENDARG 2>err.txt; then
if vm_rpmostree kargs --delete APPENDARG 2>err.txt; then
assert_not_reached "Delete A key with multiple values unexpectedly succeeded"
fi
assert_file_has_content err.txt "Unable to delete argument 'APPENDARG' with multiple values"
echo "ok failed to delete key with multiple values"
vm_rpmostree ex kargs --delete APPENDARG=VALAPPEND
vm_rpmostree kargs --delete APPENDARG=VALAPPEND
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > tmp_conf.txt
assert_not_file_has_content tmp_conf.txt 'APPENDARG=VALAPPEND'
assert_file_has_content tmp_conf.txt 'APPENDARG=2NDAPPEND'
echo "ok delete a single key/value pair from multi valued key pairs"
# Test for rpm-ostree ex kargs replace
vm_rpmostree ex kargs --append=REPLACE_TEST=TEST --append=REPLACE_MULTI_TEST=TEST --append=REPLACE_MULTI_TEST=NUMBERTWO
# Test for rpm-ostree kargs replace
vm_rpmostree kargs --append=REPLACE_TEST=TEST --append=REPLACE_MULTI_TEST=TEST --append=REPLACE_MULTI_TEST=NUMBERTWO
# Test for replacing key/value pair with only one value
vm_rpmostree ex kargs --replace=REPLACE_TEST=HELLO
vm_rpmostree kargs --replace=REPLACE_TEST=HELLO
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > tmp_conf.txt
assert_file_has_content_literal tmp_conf.txt 'REPLACE_TEST=HELLO'
echo "ok replacing one key/value pair"
# Test for replacing key/value pair with multi vars
if vm_rpmostree ex kargs --replace=REPLACE_MULTI_TEST=ERR 2>err.txt; then
if vm_rpmostree kargs --replace=REPLACE_MULTI_TEST=ERR 2>err.txt; then
assert_not_reached "Replace a key with multiple values unexpectedly succeeded"
fi
assert_file_has_content err.txt "Unable to replace argument 'REPLACE_MULTI_TEST' with multiple values"
echo "ok failed to replace key with multiple values"
# Test for replacing one of the values for multi value keys
vm_rpmostree ex kargs --replace=REPLACE_MULTI_TEST=TEST=NEWTEST
vm_rpmostree kargs --replace=REPLACE_MULTI_TEST=TEST=NEWTEST
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > tmp_conf.txt
assert_file_has_content tmp_conf.txt "REPLACE_MULTI_TEST=NEWTEST"
assert_not_file_has_content tmp_conf.txt "REPLACE_MULTI_TEST=TEST"
@ -104,7 +104,7 @@ echo "ok rollback will revert the changes to conf file"
# in the list should be the booted deployment.
# Also Note: we need to remove the first line of output because
# the kargs output is in the form of 'The kernel args are: \n xxxx'
for arg in $(vm_rpmostree ex kargs --deploy-index=0 | tail -n +2); do
for arg in $(vm_rpmostree kargs --deploy-index=0 | tail -n +2); do
case "$arg" in
ostree=*) # Skip ostree arg
;;
@ -115,14 +115,14 @@ done
# Now the changed deployment should be the second in the list
# since we just did a rollback
vm_rpmostree ex kargs --deploy-index=1 > kargs.txt
vm_rpmostree kargs --deploy-index=1 > kargs.txt
assert_file_has_content kargs.txt 'REPLACE_MULTI_TEST=NUMBERTWO'
assert_file_has_content kargs.txt 'APPENDARG=2NDAPPEND'
echo "ok kargs correctly displayed for specific deployment indices"
# Test if the proc-cmdline option produces the same result as /proc/cmdline
vm_cmd cat /proc/cmdline > cmdlinekargs.txt
for arg in $(vm_rpmostree ex kargs --import-proc-cmdline | tail -n +2); do
for arg in $(vm_rpmostree kargs --import-proc-cmdline | tail -n +2); do
case "$arg" in
ostree=*) # Skip the ostree arg due to potential boot version difference
;;
@ -133,13 +133,13 @@ done
echo "ok import kargs from current deployment"
# Test for https://github.com/projectatomic/rpm-ostree/issues/1392
vm_rpmostree ex kargs --append=PACKAGE=TEST
vm_rpmostree kargs --append=PACKAGE=TEST
vm_build_rpm foo
vm_rpmostree install foo
vm_cmd grep ^options /boot/loader/entries/ostree-$osname-0.conf > kargs.txt
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
echo "ok kargs with multiple operations"
vm_rpmostree ex kargs > kargs.txt
vm_rpmostree kargs > kargs.txt
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
echo "ok kargs display with multiple operations"