status: Use more concise GPGSignature without --verbose
Since it takes up a lot of room and should be something that's just always working. Closes: https://github.com/projectatomic/rpm-ostree/issues/842 Closes: #848 Approved by: jlebon
This commit is contained in:
parent
4d72f8d787
commit
c7c89e8735
@ -53,15 +53,24 @@ printpad (char c, guint n)
|
||||
}
|
||||
|
||||
static void
|
||||
print_kv (const char *key,
|
||||
guint maxkeylen,
|
||||
const char *value)
|
||||
print_kv_no_newline (const char *key,
|
||||
guint maxkeylen,
|
||||
const char *value)
|
||||
{
|
||||
int pad = maxkeylen - strlen (key);
|
||||
g_assert (pad >= 0);
|
||||
/* +2 for initial leading spaces */
|
||||
printpad (' ', pad + 2);
|
||||
printf ("%s: %s\n", key, value);
|
||||
printf ("%s: %s", key, value);
|
||||
}
|
||||
|
||||
static void
|
||||
print_kv (const char *key,
|
||||
guint maxkeylen,
|
||||
const char *value)
|
||||
{
|
||||
print_kv_no_newline (key, maxkeylen, value);
|
||||
putc ('\n', stdout);
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
@ -403,16 +412,22 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy,
|
||||
{
|
||||
if (signatures)
|
||||
{
|
||||
guint n_sigs = g_variant_n_children (signatures);
|
||||
g_autofree char *gpgheader = g_strdup_printf ("%u signature%s", n_sigs,
|
||||
n_sigs == 1 ? "" : "s");
|
||||
const guint gpgpad = max_key_len+4;
|
||||
char gpgspaces[gpgpad+1];
|
||||
memset (gpgspaces, ' ', gpgpad);
|
||||
gpgspaces[gpgpad] = '\0';
|
||||
|
||||
print_kv ("GPGSignature", max_key_len, gpgheader);
|
||||
rpmostree_print_signatures (signatures, gpgspaces);
|
||||
if (opt_verbose)
|
||||
{
|
||||
const guint n_sigs = g_variant_n_children (signatures);
|
||||
g_autofree char *gpgheader =
|
||||
g_strdup_printf ("%u signature%s", n_sigs,
|
||||
n_sigs == 1 ? "" : "s");
|
||||
print_kv ("GPGSignature", max_key_len, gpgheader);
|
||||
}
|
||||
else
|
||||
print_kv_no_newline ("GPGSignature", max_key_len, "");
|
||||
rpmostree_print_signatures (signatures, gpgspaces, opt_verbose);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -662,25 +662,35 @@ out:
|
||||
|
||||
void
|
||||
rpmostree_print_signatures (GVariant *variant,
|
||||
const gchar *sep)
|
||||
const gchar *sep,
|
||||
gboolean verbose)
|
||||
{
|
||||
GString *sigs_buffer;
|
||||
guint i;
|
||||
guint n_sigs = g_variant_n_children (variant);
|
||||
sigs_buffer = g_string_sized_new (256);
|
||||
const guint n_sigs = g_variant_n_children (variant);
|
||||
g_autoptr(GString) sigs_buffer = g_string_sized_new (256);
|
||||
|
||||
for (i = 0; i < n_sigs; i++)
|
||||
for (guint i = 0; i < n_sigs; i++)
|
||||
{
|
||||
g_autoptr(GVariant) v = NULL;
|
||||
if (i != 0)
|
||||
g_string_append_c (sigs_buffer, '\n');
|
||||
g_variant_get_child (variant, i, "v", &v);
|
||||
ostree_gpg_verify_result_describe_variant (v, sigs_buffer, sep,
|
||||
OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
|
||||
if (verbose)
|
||||
ostree_gpg_verify_result_describe_variant (v, sigs_buffer, sep,
|
||||
OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
|
||||
else
|
||||
{
|
||||
gboolean valid;
|
||||
g_variant_get_child (v, OSTREE_GPG_SIGNATURE_ATTR_VALID, "b", &valid);
|
||||
const char *fingerprint;
|
||||
g_variant_get_child (v, OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT, "&s", &fingerprint);
|
||||
if (i != 0)
|
||||
g_string_append (sigs_buffer, sep);
|
||||
g_string_append_printf (sigs_buffer, "%s signature by %s\n", valid ? "Valid" : "Invalid",
|
||||
fingerprint);
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("%s", sigs_buffer->str);
|
||||
g_string_free (sigs_buffer, TRUE);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -70,7 +70,8 @@ rpmostree_transaction_get_response_sync (RPMOSTreeSysroot *sysroot_proxy,
|
||||
|
||||
void
|
||||
rpmostree_print_signatures (GVariant *variant,
|
||||
const gchar *sep);
|
||||
const gchar *sep,
|
||||
gboolean verbose);
|
||||
|
||||
void
|
||||
rpmostree_print_package_diffs (GVariant *variant);
|
||||
|
Loading…
Reference in New Issue
Block a user