repo: Fix location of remote configs for system repos
Need to respect the repo's system root directory instead of assuming the compile-time $(sysconfdir).
This commit is contained in:
parent
74fb777edb
commit
708d923125
|
|
@ -17,9 +17,12 @@
|
||||||
|
|
||||||
include Makefile-decls.am
|
include Makefile-decls.am
|
||||||
|
|
||||||
|
shortened_sysconfdir = $$(echo "$(sysconfdir)" | sed -e 's|^$(prefix)||' -e 's|^/||')
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||||
AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
|
AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
|
||||||
-DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \
|
-DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||||
|
-DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \
|
||||||
-DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \
|
-DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \
|
||||||
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 \
|
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 \
|
||||||
-DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48
|
-DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ G_DEFINE_TYPE (OstreeRepo, ostree_repo, G_TYPE_OBJECT)
|
||||||
GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, local_keyfile_unref, g_key_file_unref)
|
GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, local_keyfile_unref, g_key_file_unref)
|
||||||
#define local_cleanup_keyfile __attribute__ ((cleanup(local_keyfile_unref)))
|
#define local_cleanup_keyfile __attribute__ ((cleanup(local_keyfile_unref)))
|
||||||
|
|
||||||
|
#define SYSCONF_REMOTES SHORTENED_SYSCONFDIR "/ostree/remotes.d"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
volatile int ref_count;
|
volatile int ref_count;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
@ -927,6 +929,7 @@ impl_repo_remote_add (OstreeRepo *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
local_cleanup_remote OstreeRemote *remote = NULL;
|
local_cleanup_remote OstreeRemote *remote = NULL;
|
||||||
|
gboolean different_sysroot = FALSE;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (name != NULL, FALSE);
|
g_return_val_if_fail (name != NULL, FALSE);
|
||||||
|
|
@ -968,16 +971,39 @@ impl_repo_remote_add (OstreeRepo *self,
|
||||||
remote->group = g_strdup_printf ("remote \"%s\"", name);
|
remote->group = g_strdup_printf ("remote \"%s\"", name);
|
||||||
remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", name);
|
remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", name);
|
||||||
|
|
||||||
if (sysroot != NULL || ostree_repo_is_system (self))
|
/* The OstreeRepo maintains its own internal system root path,
|
||||||
|
* so we need to not only check if a "sysroot" argument was given
|
||||||
|
* but also whether it's actually different from OstreeRepo's.
|
||||||
|
*
|
||||||
|
* XXX Having API regret about the "sysroot" argument now.
|
||||||
|
*/
|
||||||
|
if (sysroot != NULL)
|
||||||
|
different_sysroot = !g_file_equal (sysroot, self->sysroot_dir);
|
||||||
|
|
||||||
|
if (different_sysroot || ostree_repo_is_system (self))
|
||||||
{
|
{
|
||||||
const char *sysconf_remotes = SYSCONFDIR "/ostree/remotes.d";
|
|
||||||
g_autofree char *basename = g_strconcat (name, ".conf", NULL);
|
g_autofree char *basename = g_strconcat (name, ".conf", NULL);
|
||||||
g_autoptr(GFile) etc_ostree_remotes_d = NULL;
|
g_autoptr(GFile) etc_ostree_remotes_d = NULL;
|
||||||
|
GError *local_error = NULL;
|
||||||
|
|
||||||
if (sysroot == NULL)
|
if (sysroot == NULL)
|
||||||
etc_ostree_remotes_d = g_file_new_for_path (sysconf_remotes);
|
sysroot = self->sysroot_dir;
|
||||||
|
|
||||||
|
etc_ostree_remotes_d = g_file_resolve_relative_path (sysroot, SYSCONF_REMOTES);
|
||||||
|
|
||||||
|
if (!g_file_make_directory_with_parents (etc_ostree_remotes_d,
|
||||||
|
cancellable, &local_error))
|
||||||
|
{
|
||||||
|
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
|
||||||
|
{
|
||||||
|
g_clear_error (&local_error);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
etc_ostree_remotes_d = g_file_resolve_relative_path (sysroot, sysconf_remotes + 1);
|
{
|
||||||
|
g_propagate_error (error, local_error);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
remote->file = g_file_get_child (etc_ostree_remotes_d, basename);
|
remote->file = g_file_get_child (etc_ostree_remotes_d, basename);
|
||||||
}
|
}
|
||||||
|
|
@ -2179,7 +2205,8 @@ append_remotes_d (OstreeRepo *self,
|
||||||
g_autoptr(GFile) etc_ostree_remotes_d = NULL;
|
g_autoptr(GFile) etc_ostree_remotes_d = NULL;
|
||||||
g_autoptr(GFileEnumerator) direnum = NULL;
|
g_autoptr(GFileEnumerator) direnum = NULL;
|
||||||
|
|
||||||
etc_ostree_remotes_d = g_file_new_for_path (SYSCONFDIR "/ostree/remotes.d");
|
etc_ostree_remotes_d = g_file_resolve_relative_path (self->sysroot_dir, SYSCONF_REMOTES);
|
||||||
|
|
||||||
if (!enumerate_directory_allow_noent (etc_ostree_remotes_d, OSTREE_GIO_FAST_QUERYINFO, 0,
|
if (!enumerate_directory_allow_noent (etc_ostree_remotes_d, OSTREE_GIO_FAST_QUERYINFO, 0,
|
||||||
&direnum,
|
&direnum,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue