mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-24 15:48:18 -05:00
utils: Move OstreeRepo configuration accessors to a new translation unit
This is a step towards removing the libostree dependency from flatpak-utils, which should be one of the lowest-level components. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
485f6bc5c5
commit
c98a7c024f
@@ -30,6 +30,7 @@
|
||||
#include "libglnx.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-repo-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
#include "flatpak-prune-private.h"
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "libglnx.h"
|
||||
|
||||
#include <ostree.h>
|
||||
|
||||
/**
|
||||
* FLATPAK_SUMMARY_INDEX_GVARIANT_FORMAT:
|
||||
*
|
||||
@@ -75,3 +77,53 @@
|
||||
#define FLATPAK_SPARSE_CACHE_KEY_ENDOFLINE_REBASE "eolr"
|
||||
#define FLATPAK_SPARSE_CACHE_KEY_TOKEN_TYPE "tokt"
|
||||
#define FLATPAK_SPARSE_CACHE_KEY_EXTRA_DATA_SIZE "eds"
|
||||
|
||||
#define FLATPAK_SUMMARY_HISTORY_LENGTH_DEFAULT 16
|
||||
|
||||
gboolean flatpak_repo_set_title (OstreeRepo *repo,
|
||||
const char *title,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_comment (OstreeRepo *repo,
|
||||
const char *comment,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_description (OstreeRepo *repo,
|
||||
const char *description,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_icon (OstreeRepo *repo,
|
||||
const char *icon,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_homepage (OstreeRepo *repo,
|
||||
const char *homepage,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_redirect_url (OstreeRepo *repo,
|
||||
const char *redirect_url,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_name (OstreeRepo *repo,
|
||||
const char *authenticator_name,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_install (OstreeRepo *repo,
|
||||
gboolean authenticator_install,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_option (OstreeRepo *repo,
|
||||
const char *key,
|
||||
const char *value,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_default_branch (OstreeRepo *repo,
|
||||
const char *branch,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_collection_id (OstreeRepo *repo,
|
||||
const char *collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_summary_history_length (OstreeRepo *repo,
|
||||
guint length,
|
||||
GError **error);
|
||||
guint flatpak_repo_get_summary_history_length (OstreeRepo *repo);
|
||||
gboolean flatpak_repo_set_gpg_keys (OstreeRepo *repo,
|
||||
GBytes *bytes,
|
||||
GError **error);
|
||||
|
||||
318
common/flatpak-repo-utils.c
Normal file
318
common/flatpak-repo-utils.c
Normal file
@@ -0,0 +1,318 @@
|
||||
/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s:
|
||||
* Copyright © 1995-1998 Free Software Foundation, Inc.
|
||||
* Copyright © 2014-2019 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.1 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander Larsson <alexl@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "flatpak-repo-utils-private.h"
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_title (OstreeRepo *repo,
|
||||
const char *title,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (title)
|
||||
g_key_file_set_string (config, "flatpak", "title", title);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "title", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_comment (OstreeRepo *repo,
|
||||
const char *comment,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (comment)
|
||||
g_key_file_set_string (config, "flatpak", "comment", comment);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "comment", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_description (OstreeRepo *repo,
|
||||
const char *description,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (description)
|
||||
g_key_file_set_string (config, "flatpak", "description", description);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "description", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_icon (OstreeRepo *repo,
|
||||
const char *icon,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (icon)
|
||||
g_key_file_set_string (config, "flatpak", "icon", icon);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "icon", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_homepage (OstreeRepo *repo,
|
||||
const char *homepage,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (homepage)
|
||||
g_key_file_set_string (config, "flatpak", "homepage", homepage);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "homepage", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_redirect_url (OstreeRepo *repo,
|
||||
const char *redirect_url,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (redirect_url)
|
||||
g_key_file_set_string (config, "flatpak", "redirect-url", redirect_url);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "redirect-url", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_name (OstreeRepo *repo,
|
||||
const char *authenticator_name,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (authenticator_name)
|
||||
g_key_file_set_string (config, "flatpak", "authenticator-name", authenticator_name);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "authenticator-name", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_install (OstreeRepo *repo,
|
||||
gboolean authenticator_install,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
g_key_file_set_boolean (config, "flatpak", "authenticator-install", authenticator_install);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_option (OstreeRepo *repo,
|
||||
const char *key,
|
||||
const char *value,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
g_autofree char *full_key = g_strdup_printf ("authenticator-options.%s", key);
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (value)
|
||||
g_key_file_set_string (config, "flatpak", full_key, value);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", full_key, NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
g_key_file_set_boolean (config, "flatpak", "deploy-collection-id", deploy_collection_id);
|
||||
return ostree_repo_write_config (repo, config, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
g_key_file_set_boolean (config, "flatpak", "deploy-sideload-collection-id", deploy_collection_id);
|
||||
return ostree_repo_write_config (repo, config, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_gpg_keys (OstreeRepo *repo,
|
||||
GBytes *bytes,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
g_autofree char *value_base64 = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
value_base64 = g_base64_encode (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
|
||||
|
||||
g_key_file_set_string (config, "flatpak", "gpg-keys", value_base64);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_default_branch (OstreeRepo *repo,
|
||||
const char *branch,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (branch)
|
||||
g_key_file_set_string (config, "flatpak", "default-branch", branch);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "default-branch", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_collection_id (OstreeRepo *repo,
|
||||
const char *collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
if (!ostree_repo_set_collection_id (repo, collection_id, error))
|
||||
return FALSE;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_summary_history_length (OstreeRepo *repo,
|
||||
guint length,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (length)
|
||||
g_key_file_set_integer (config, "flatpak", "summary-history-length", length);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "summary-history-length", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
guint
|
||||
flatpak_repo_get_summary_history_length (OstreeRepo *repo)
|
||||
{
|
||||
GKeyFile *config = ostree_repo_get_config (repo);
|
||||
int length;
|
||||
|
||||
length = g_key_file_get_integer (config, "flatpak", "sumary-history-length", NULL);
|
||||
|
||||
if (length <= 0)
|
||||
return FLATPAK_SUMMARY_HISTORY_LENGTH_DEFAULT;
|
||||
|
||||
return length;
|
||||
}
|
||||
@@ -49,8 +49,6 @@
|
||||
|
||||
#define FLATPAK_SUMMARY_DIFF_HEADER "xadf"
|
||||
|
||||
#define FLATPAK_SUMMARY_HISTORY_LENGTH_DEFAULT 16
|
||||
|
||||
/* https://bugzilla.gnome.org/show_bug.cgi?id=766370 */
|
||||
#if !GLIB_CHECK_VERSION (2, 49, 3)
|
||||
#define FLATPAK_VARIANT_BUILDER_INITIALIZER {{0, }}
|
||||
@@ -194,54 +192,6 @@ GKeyFile * flatpak_parse_repofile (const char *remote_name,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean flatpak_repo_set_title (OstreeRepo *repo,
|
||||
const char *title,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_comment (OstreeRepo *repo,
|
||||
const char *comment,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_description (OstreeRepo *repo,
|
||||
const char *description,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_icon (OstreeRepo *repo,
|
||||
const char *icon,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_homepage (OstreeRepo *repo,
|
||||
const char *homepage,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_redirect_url (OstreeRepo *repo,
|
||||
const char *redirect_url,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_name (OstreeRepo *repo,
|
||||
const char *authenticator_name,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_install (OstreeRepo *repo,
|
||||
gboolean authenticator_install,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_authenticator_option (OstreeRepo *repo,
|
||||
const char *key,
|
||||
const char *value,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_default_branch (OstreeRepo *repo,
|
||||
const char *branch,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_collection_id (OstreeRepo *repo,
|
||||
const char *collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error);
|
||||
gboolean flatpak_repo_set_summary_history_length (OstreeRepo *repo,
|
||||
guint length,
|
||||
GError **error);
|
||||
guint flatpak_repo_get_summary_history_length (OstreeRepo *repo);
|
||||
gboolean flatpak_repo_set_gpg_keys (OstreeRepo *repo,
|
||||
GBytes *bytes,
|
||||
GError **error);
|
||||
|
||||
GBytes *flatpak_zlib_compress_bytes (GBytes *bytes,
|
||||
int level,
|
||||
GError **error);
|
||||
|
||||
@@ -1978,301 +1978,6 @@ flatpak_parse_repofile (const char *remote_name,
|
||||
return g_steal_pointer (&config);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_title (OstreeRepo *repo,
|
||||
const char *title,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (title)
|
||||
g_key_file_set_string (config, "flatpak", "title", title);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "title", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_comment (OstreeRepo *repo,
|
||||
const char *comment,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (comment)
|
||||
g_key_file_set_string (config, "flatpak", "comment", comment);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "comment", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_description (OstreeRepo *repo,
|
||||
const char *description,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (description)
|
||||
g_key_file_set_string (config, "flatpak", "description", description);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "description", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_icon (OstreeRepo *repo,
|
||||
const char *icon,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (icon)
|
||||
g_key_file_set_string (config, "flatpak", "icon", icon);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "icon", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_homepage (OstreeRepo *repo,
|
||||
const char *homepage,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (homepage)
|
||||
g_key_file_set_string (config, "flatpak", "homepage", homepage);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "homepage", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_redirect_url (OstreeRepo *repo,
|
||||
const char *redirect_url,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (redirect_url)
|
||||
g_key_file_set_string (config, "flatpak", "redirect-url", redirect_url);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "redirect-url", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_name (OstreeRepo *repo,
|
||||
const char *authenticator_name,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (authenticator_name)
|
||||
g_key_file_set_string (config, "flatpak", "authenticator-name", authenticator_name);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "authenticator-name", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_install (OstreeRepo *repo,
|
||||
gboolean authenticator_install,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
g_key_file_set_boolean (config, "flatpak", "authenticator-install", authenticator_install);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_authenticator_option (OstreeRepo *repo,
|
||||
const char *key,
|
||||
const char *value,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
g_autofree char *full_key = g_strdup_printf ("authenticator-options.%s", key);
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (value)
|
||||
g_key_file_set_string (config, "flatpak", full_key, value);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", full_key, NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
g_key_file_set_boolean (config, "flatpak", "deploy-collection-id", deploy_collection_id);
|
||||
return ostree_repo_write_config (repo, config, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
|
||||
gboolean deploy_collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
g_key_file_set_boolean (config, "flatpak", "deploy-sideload-collection-id", deploy_collection_id);
|
||||
return ostree_repo_write_config (repo, config, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_gpg_keys (OstreeRepo *repo,
|
||||
GBytes *bytes,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
g_autofree char *value_base64 = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
value_base64 = g_base64_encode (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
|
||||
|
||||
g_key_file_set_string (config, "flatpak", "gpg-keys", value_base64);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_default_branch (OstreeRepo *repo,
|
||||
const char *branch,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (branch)
|
||||
g_key_file_set_string (config, "flatpak", "default-branch", branch);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "default-branch", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_collection_id (OstreeRepo *repo,
|
||||
const char *collection_id,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
if (!ostree_repo_set_collection_id (repo, collection_id, error))
|
||||
return FALSE;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_repo_set_summary_history_length (OstreeRepo *repo,
|
||||
guint length,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (length)
|
||||
g_key_file_set_integer (config, "flatpak", "summary-history-length", length);
|
||||
else
|
||||
g_key_file_remove_key (config, "flatpak", "summary-history-length", NULL);
|
||||
|
||||
if (!ostree_repo_write_config (repo, config, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
guint
|
||||
flatpak_repo_get_summary_history_length (OstreeRepo *repo)
|
||||
{
|
||||
GKeyFile *config = ostree_repo_get_config (repo);
|
||||
int length;
|
||||
|
||||
length = g_key_file_get_integer (config, "flatpak", "sumary-history-length", NULL);
|
||||
|
||||
if (length <= 0)
|
||||
return FLATPAK_SUMMARY_HISTORY_LENGTH_DEFAULT;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
GVariant *
|
||||
flatpak_commit_get_extra_data_sources (GVariant *commitv,
|
||||
GError **error)
|
||||
|
||||
@@ -187,6 +187,7 @@ sources = [
|
||||
'flatpak-related-ref.c',
|
||||
'flatpak-remote-ref.c',
|
||||
'flatpak-remote.c',
|
||||
'flatpak-repo-utils.c',
|
||||
'flatpak-run.c',
|
||||
'flatpak-run-cups.c',
|
||||
'flatpak-run-dbus.c',
|
||||
|
||||
Reference in New Issue
Block a user