libpriv/kargs: Copy libostree patch to support KEYWORD kargs
This is essentially a copy of https://github.com/ostreedev/ostree/pull/1785 to our private copy of the kargs API. Should really dedupe those... The really confusing part though was that that patch was intended to fix the `rpm-ostree kargs --append EMPTYKEY=` case (#1706), yet the `rpmostree kargs --append KEYWORD` case (#1779) wasn't also fixed, even though that same ostree patch clearly fixes and tests for that too. To make a long story short, we were passing buggy kargs to ostree, which before that patch, had itself buggy kargs parsing which conveniently fixed back the kargs we passed for the `KEYWORD` case. Closes: #1779 Closes: #1796 Approved by: cgwalters
This commit is contained in:
parent
28c3a4cd07
commit
247214c27e
@ -17,6 +17,9 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* XXX: This file is lifted from src/libostree/ostree-kernel-args.c, though there are some
|
||||
* new APIs. Should upstream those and dedupe. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "rpmostree-kargs-process.h"
|
||||
@ -35,21 +38,12 @@ split_keyeq (char *arg)
|
||||
char *eq;
|
||||
|
||||
eq = strchr (arg, '=');
|
||||
if (eq)
|
||||
{
|
||||
/* Note key/val are in one malloc block,
|
||||
* so we don't free val...
|
||||
*/
|
||||
*eq = '\0';
|
||||
return eq+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ...and this allows us to insert a constant
|
||||
* string.
|
||||
*/
|
||||
return "";
|
||||
}
|
||||
if (eq == NULL)
|
||||
return NULL;
|
||||
|
||||
// Note: key/val are in a single allocation block, so we don't free val.
|
||||
*eq = '\0';
|
||||
return eq+1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -573,7 +567,10 @@ _ostree_kernel_args_to_strv (OstreeKernelArgs *kargs)
|
||||
{
|
||||
const char *value = values->pdata[j];
|
||||
|
||||
g_ptr_array_add (strv, g_strconcat (key, "=", value, NULL));
|
||||
if (value == NULL)
|
||||
g_ptr_array_add (strv, g_strconcat (key, NULL));
|
||||
else
|
||||
g_ptr_array_add (strv, g_strconcat (key, "=", value, NULL));
|
||||
}
|
||||
}
|
||||
g_ptr_array_add (strv, NULL);
|
||||
@ -605,14 +602,12 @@ _ostree_kernel_args_to_string (OstreeKernelArgs *kargs)
|
||||
else
|
||||
g_string_append_c (buf, ' ');
|
||||
|
||||
if (value && *value)
|
||||
g_string_append (buf, key);
|
||||
if (value != NULL)
|
||||
{
|
||||
g_string_append (buf, key);
|
||||
g_string_append_c (buf, '=');
|
||||
g_string_append (buf, value);
|
||||
}
|
||||
else
|
||||
g_string_append (buf, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user