repo: Fix non-system remotes-config-dir usage

Before commit e0346c1, a non-system repo could specify
remotes-config-dir and have remotes read from there. However, adding
remotes would only be done in the config dir for a system repo. Restore
that by respecting remotes-config-dir when no sysroot is found and
adding back the ostree_repo_is_system() check when adding remotes.

Closes: #1133

Closes: #1151
Approved by: cgwalters
This commit is contained in:
Dan Nicholson authored and Atomic Bot committed 2017-09-08 13:54:30 +00:00
1 parent 2a7fdfdbc5
commit 43c78c9006
3 files changed
+89 -8

No files matched your search

+15 -8
View File
@@ -1010,8 +1010,11 @@ impl_repo_remote_add (OstreeRepo *self,
remote = ostree_remote_new (name);
/* Only add repos in remotes.d for system repos since that was the
* legacy behavior and non-system repos would not expect it.
*/
g_autoptr(GFile) etc_ostree_remotes_d = get_remotes_d_dir (self, sysroot);
if (etc_ostree_remotes_d)
if (etc_ostree_remotes_d && ostree_repo_is_system (self))
{
g_autoptr(GError) local_error = NULL;
@@ -2040,10 +2043,6 @@ static GFile *
get_remotes_d_dir (OstreeRepo *self,
GFile *sysroot)
{
/* Support explicit override */
if (self->sysroot_dir != NULL && self->remotes_config_dir != NULL)
return g_file_resolve_relative_path (self->sysroot_dir, self->remotes_config_dir);
g_autoptr(GFile) sysroot_owned = NULL;
/* Very complicated sysroot logic; this bit breaks the otherwise mostly clean
* layering between OstreeRepo and OstreeSysroot. First, If a sysroot was
@@ -2079,10 +2078,18 @@ get_remotes_d_dir (OstreeRepo *self,
if (sysroot == NULL && sysroot_ref == NULL)
sysroot = self->sysroot_dir;
/* Did we find a sysroot? If not, NULL means use the repo config, otherwise
* return the path in /etc.
/* Was the config directory specified? If so, use that with the
* optional sysroot prepended. If not, return the path in /etc if the
* sysroot was found and NULL otherwise to use the repo config.
*/
if (sysroot == NULL)
if (self->remotes_config_dir != NULL)
{
if (sysroot == NULL)
return g_file_new_for_path (self->remotes_config_dir);
else
return g_file_resolve_relative_path (sysroot, self->remotes_config_dir);
}
else if (sysroot == NULL)
return NULL;
else
return g_file_resolve_relative_path (sysroot, SYSCONF_REMOTES);