After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 751188 - remote ADD_IF_NOT_EXISTS with sysroot doesn't use sysroot
remote ADD_IF_NOT_EXISTS with sysroot doesn't use sysroot
Status: RESOLVED FIXED
Product: ostree
Classification: Infrastructure
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: OSTree maintainer(s)
OSTree maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-06-19 01:32 UTC by Colin Walters
Modified: 2015-07-16 16:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Colin Walters 2015-06-19 01:32:26 UTC
In https://github.com/rhinstaller/anaconda/commit/438e19b8fe0f9f8d87a1a003f634d455973c87e1
I tried to support trees containing remotes.

Except it doesn't work because while the sysroot API to add a remote takes a sysroot argument, we don't actually use it to read the remote configs - we always read from /etc.
Comment 1 Matthew Barnes 2015-06-23 21:55:37 UTC
Could this be addressed with something like

   OstreeRepo * ostree_repo_new_for_sysroot (GFile *repo_path,
                                             GFile *sysroot_path)

And then have ostree_repo_is_system() take sysroot_path into account?
Comment 2 Matthew Barnes 2015-07-10 01:29:31 UTC
I messed around with this a little today and I think I have the libostree changes correct, but I got hamstrung by a bunch of CLI tests that broke.

The problem is the "ostree remote add" command only takes a --repo argument and therefore has to assume the sysroot is always "/".

Would you agree this command needs its own --sysroot option so it can figure out if it's dealing with a system repo?
Comment 3 Colin Walters 2015-07-12 00:29:07 UTC
Adding a sysroot to that command makes sense to me indeed.
Comment 4 Matthew Barnes 2015-07-13 00:03:55 UTC
This is getting a little messier than I'd hoped, but I think it might still be worth correcting.

There's a couple places in ostree-repo.c where we construct the system-wide remote config path like so:

    SYSCONFDIR "/ostree/remotes.d"

I think this is wrong.  It's constructing the path according to OSTree's install prefix at compile time, not according to a runtime-specified system root.

We need to be constructing the path more like:

    SYSTEM_ROOT "/" RELATIVE_SYSCONFDIR "/ostree/remotes.d"

Where RELATIVE_SYSCONFDIR is a relative path set at compile time, like "etc".

I don't think this can be reliably derived from the autoconf $(sysconfdir) variable though; I think we actually need a separate configure switch that defaults to "etc".  --with-relative-sysconfdir or some better name.

Does this seem sane or can you think of another way?
Comment 5 Colin Walters 2015-07-13 14:34:42 UTC
We can prepend the sysroot to the absolute path, no?  I don't mind calling it RELATIVE_ internally but the end result seems to be the same - we'd have to add an intermediate '/'.

In the end I think the real assumption we're making here is that the ostree inside the *target* is using --sysconfdir=/etc and not something like GoboLinux paths.  And I'm fine with that assumption, things like GoboLinux aren't valuable enough to support.
Comment 6 Matthew Barnes 2015-07-13 15:15:33 UTC
In my case I'm building ostree to a prefix like /home/mbarnes/local for testing, with sysconfdir ending up /home/mbarnes/local/etc.

If I run a test script from, say, /home/mbarnes/tmp, then prepending sysroot to sysconfdir produces some crazy path like

  /home/mbarnes/tmp/sysroot/home/mbarnes/local/etc/ostree/remotes.d/

I thought maybe we could get a relative $sysconfdir by slicing off $prefix if it matches, or maybe this is too much of a corner case to worry about?
Comment 7 Colin Walters 2015-07-13 17:01:57 UTC
Ah, I hadn't considered the developer case for prefix.  Yeah, just slicing off $prefix makes sense to me then.
Comment 8 Matthew Barnes 2015-07-14 01:54:49 UTC
(In reply to Colin Walters from comment #3)
> Adding a sysroot to that command makes sense to me indeed.

Instead of piling on more command-line options for rare use cases, what do you think about supporting an OSTREE_SYSROOT environment variable?

I can't think of any other use for the option beyond our installed tests at the moment, and the environment variable could be a nice little cleanup for some of the tests so we're not repeating --sysroot=sysroot ad nauseum.
Comment 9 Colin Walters 2015-07-14 15:04:01 UTC
No strong opinion, I'm OK with environment if you prefer.  As a general rule it'd be nice if the commandline exposed most of what the API does, but for this specifc case, no strong opinion.

To avoid duplication in the tests though I've been using bash functions in some places.
Comment 10 Matthew Barnes 2015-07-14 17:49:51 UTC
Got a solution that I think is fairly clean.

https://github.com/GNOME/ostree/pull/125

Chose to go with the OSTREE_SYSROOT mechanism for installed tests, but we can still add --sysroot options to commands later if real-world use cases crop up.
Comment 11 Matthew Barnes 2015-07-16 16:55:06 UTC
Merged the PR.  Commit sequence ends here:

https://git.gnome.org/browse/ostree/commit/?id=df0cae437556e0e2c7e6b0c10e9750520d0c34f2