libpriv: add new rpmostree-types.h
There are types that we want to share between the daemon and the client for deduplication. Those are, as expected, related to D-Bus things like formats and enums. Let's create a new file for it rather than shove it in `rpmostree-util.h`. As mentioned in the file, some of these probably belong better directly in the public API. Closes: #1147 Approved by: cgwalters
This commit is contained in:
parent
51fb641305
commit
553a68c32a
@ -24,6 +24,7 @@ librpmostreepriv_la_SOURCES = \
|
|||||||
src/libpriv/rpmostree-json-parsing.h \
|
src/libpriv/rpmostree-json-parsing.h \
|
||||||
src/libpriv/rpmostree-util.c \
|
src/libpriv/rpmostree-util.c \
|
||||||
src/libpriv/rpmostree-util.h \
|
src/libpriv/rpmostree-util.h \
|
||||||
|
src/libpriv/rpmostree-types.h \
|
||||||
src/libpriv/rpmostree-passwd-util.c \
|
src/libpriv/rpmostree-passwd-util.c \
|
||||||
src/libpriv/rpmostree-passwd-util.h \
|
src/libpriv/rpmostree-passwd-util.h \
|
||||||
src/libpriv/rpmostree-refts.h \
|
src/libpriv/rpmostree-refts.h \
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
#include <libglnx.h>
|
#include <libglnx.h>
|
||||||
|
|
||||||
|
#include "rpmostree-types.h"
|
||||||
#include "rpmostree-dbus-helpers.h"
|
#include "rpmostree-dbus-helpers.h"
|
||||||
#include "rpmostree-builtins.h"
|
#include "rpmostree-builtins.h"
|
||||||
#include "rpmostree-libbuiltin.h"
|
#include "rpmostree-libbuiltin.h"
|
||||||
@ -1236,25 +1237,29 @@ rpmostree_print_cached_update (GVariant *cached_update,
|
|||||||
|
|
||||||
g_autoptr(GVariant) upgraded =
|
g_autoptr(GVariant) upgraded =
|
||||||
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "upgraded",
|
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "upgraded",
|
||||||
G_VARIANT_TYPE ("a(us(ss)(ss))"), error);
|
RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT,
|
||||||
|
error);
|
||||||
if (!upgraded)
|
if (!upgraded)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_autoptr(GVariant) downgraded =
|
g_autoptr(GVariant) downgraded =
|
||||||
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "downgraded",
|
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "downgraded",
|
||||||
G_VARIANT_TYPE ("a(us(ss)(ss))"), error);
|
RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT,
|
||||||
|
error);
|
||||||
if (!downgraded)
|
if (!downgraded)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_autoptr(GVariant) removed =
|
g_autoptr(GVariant) removed =
|
||||||
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "removed",
|
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "removed",
|
||||||
G_VARIANT_TYPE ("a(usss)"), error);
|
RPMOSTREE_DIFF_SINGLE_GVARIANT_FORMAT,
|
||||||
|
error);
|
||||||
if (!removed)
|
if (!removed)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_autoptr(GVariant) added =
|
g_autoptr(GVariant) added =
|
||||||
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "added",
|
_rpmostree_vardict_lookup_value_required (&rpm_diff_dict, "added",
|
||||||
G_VARIANT_TYPE ("a(usss)"), error);
|
RPMOSTREE_DIFF_SINGLE_GVARIANT_FORMAT,
|
||||||
|
error);
|
||||||
if (!added)
|
if (!added)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <systemd/sd-journal.h>
|
#include <systemd/sd-journal.h>
|
||||||
#include <libglnx.h>
|
#include <libglnx.h>
|
||||||
|
|
||||||
|
#include "rpmostree-types.h"
|
||||||
#include "rpmostreed-deployment-utils.h"
|
#include "rpmostreed-deployment-utils.h"
|
||||||
#include "rpmostree-origin.h"
|
#include "rpmostree-origin.h"
|
||||||
#include "rpmostree-util.h"
|
#include "rpmostree-util.h"
|
||||||
@ -570,6 +571,7 @@ sort_pkgvariant_by_name (gconstpointer pkga_pp,
|
|||||||
|
|
||||||
return strcmp (pkgname_a, pkgname_b);
|
return strcmp (pkgname_a, pkgname_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GVariant*
|
static GVariant*
|
||||||
array_to_variant_new (const char *format, GPtrArray *array)
|
array_to_variant_new (const char *format, GPtrArray *array)
|
||||||
{
|
{
|
||||||
@ -592,14 +594,14 @@ rpm_diff_variant_new (RpmDiff *diff)
|
|||||||
g_assert (diff->initialized);
|
g_assert (diff->initialized);
|
||||||
g_auto(GVariantDict) dict;
|
g_auto(GVariantDict) dict;
|
||||||
g_variant_dict_init (&dict, NULL);
|
g_variant_dict_init (&dict, NULL);
|
||||||
g_variant_dict_insert_value (&dict, "upgraded",
|
g_variant_dict_insert_value (&dict, "upgraded", array_to_variant_new (
|
||||||
array_to_variant_new ("a(us(ss)(ss))", diff->upgraded));
|
RPMOSTREE_DIFF_MODIFIED_GVARIANT_STRING, diff->upgraded));
|
||||||
g_variant_dict_insert_value (&dict, "downgraded",
|
g_variant_dict_insert_value (&dict, "downgraded", array_to_variant_new (
|
||||||
array_to_variant_new ("a(us(ss)(ss))", diff->downgraded));
|
RPMOSTREE_DIFF_MODIFIED_GVARIANT_STRING, diff->downgraded));
|
||||||
g_variant_dict_insert_value (&dict, "removed",
|
g_variant_dict_insert_value (&dict, "removed", array_to_variant_new (
|
||||||
array_to_variant_new ("a(usss)", diff->removed));
|
RPMOSTREE_DIFF_SINGLE_GVARIANT_STRING, diff->removed));
|
||||||
g_variant_dict_insert_value (&dict, "added",
|
g_variant_dict_insert_value (&dict, "added", array_to_variant_new (
|
||||||
array_to_variant_new ("a(usss)", diff->added));
|
RPMOSTREE_DIFF_SINGLE_GVARIANT_STRING, diff->added));
|
||||||
return g_variant_dict_end (&dict);
|
return g_variant_dict_end (&dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
src/libpriv/rpmostree-types.h
Normal file
54
src/libpriv/rpmostree-types.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* Copyright (C) 2018 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* These types are used by both the daemon and the client. Some of them should probably be
|
||||||
|
* added to the public API eventually. */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RPM_OSTREE_PKG_TYPE_BASE,
|
||||||
|
RPM_OSTREE_PKG_TYPE_LAYER,
|
||||||
|
} RpmOstreePkgTypes;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RPMOSTREED_AUTOMATIC_UPDATE_POLICY_NONE,
|
||||||
|
RPMOSTREED_AUTOMATIC_UPDATE_POLICY_CHECK,
|
||||||
|
} RpmostreedAutomaticUpdatePolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RPMOSTREE_DIFF_SINGLE_GVARIANT_FORMAT:
|
||||||
|
*
|
||||||
|
* - u - type (RpmOstreePkgTypes)
|
||||||
|
* - s - name
|
||||||
|
* - s - evr
|
||||||
|
* - s - arch
|
||||||
|
*/
|
||||||
|
#define RPMOSTREE_DIFF_SINGLE_GVARIANT_STRING "a(usss)"
|
||||||
|
#define RPMOSTREE_DIFF_SINGLE_GVARIANT_FORMAT G_VARIANT_TYPE (RPMOSTREE_DIFF_SINGLE_GVARIANT_STRING)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT:
|
||||||
|
*
|
||||||
|
* - u - type (RpmOstreePkgTypes)
|
||||||
|
* - s - name
|
||||||
|
* - (ss) - evr & arch of previous package
|
||||||
|
* - (ss) - evr & arch of new package
|
||||||
|
*/
|
||||||
|
#define RPMOSTREE_DIFF_MODIFIED_GVARIANT_STRING "a(us(ss)(ss))"
|
||||||
|
#define RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT G_VARIANT_TYPE (RPMOSTREE_DIFF_MODIFIED_GVARIANT_STRING)
|
@ -27,6 +27,7 @@
|
|||||||
#include <libdnf/libdnf.h>
|
#include <libdnf/libdnf.h>
|
||||||
#include "libglnx.h"
|
#include "libglnx.h"
|
||||||
#include "rpmostree.h"
|
#include "rpmostree.h"
|
||||||
|
#include "rpmostree-types.h"
|
||||||
|
|
||||||
#define _N(single, plural, n) ( (n) == 1 ? (single) : (plural) )
|
#define _N(single, plural, n) ( (n) == 1 ? (single) : (plural) )
|
||||||
#define _NS(n) _N("", "s", n)
|
#define _NS(n) _N("", "s", n)
|
||||||
@ -200,13 +201,6 @@ rpmostree_variant_bsearch_str (GVariant *array,
|
|||||||
const char *str,
|
const char *str,
|
||||||
int *out_pos);
|
int *out_pos);
|
||||||
|
|
||||||
/* these are kept here for easier sharing with the client */
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RPMOSTREED_AUTOMATIC_UPDATE_POLICY_NONE,
|
|
||||||
RPMOSTREED_AUTOMATIC_UPDATE_POLICY_CHECK,
|
|
||||||
} RpmostreedAutomaticUpdatePolicy;
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
rpmostree_auto_update_policy_to_str (RpmostreedAutomaticUpdatePolicy policy,
|
rpmostree_auto_update_policy_to_str (RpmostreedAutomaticUpdatePolicy policy,
|
||||||
GError **error);
|
GError **error);
|
||||||
@ -215,8 +209,3 @@ gboolean
|
|||||||
rpmostree_str_to_auto_update_policy (const char *str,
|
rpmostree_str_to_auto_update_policy (const char *str,
|
||||||
RpmostreedAutomaticUpdatePolicy *out_policy,
|
RpmostreedAutomaticUpdatePolicy *out_policy,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RPM_OSTREE_PKG_TYPE_BASE,
|
|
||||||
RPM_OSTREE_PKG_TYPE_LAYER,
|
|
||||||
} RpmOstreePkgTypes;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user