4099 Commits

Author SHA1 Message Date
Laurent Bonnans
630b786402 lib/fetcher: Fix some memory leaks in curl fetcher
Closes: #1716
Approved by: cgwalters
2018-08-31 11:02:41 +00:00
Colin Walters
0d6ead1bff Post-release version bump
Closes: #1705
Approved by: jlebon
2018-08-22 13:53:24 +00:00
Colin Walters
7aa242c34c Release 2018.8
Closes: #1705
Approved by: jlebon
v2018.8
2018-08-22 13:53:24 +00:00
Robert Fairley
417b5c7067 docs: Add Contributing Tutorial to Mkdocs pages
This adds the Contributing Tutorial (contributing-tutorial.md) to
the pages setting of Mkdocs, so that the tutorial will render
in the readthedocs.io documentation.

Closes: #1711
Approved by: jlebon
2018-08-21 14:05:14 +00:00
Jonathan Lebon
bb66a03fef ostree/config: Delete rogue printf and tweak help
Minor tweak to the new `--group` flag help string. Also drop an
extraneous `printf`.

Closes: #1710
Approved by: sinnykumari
2018-08-21 10:36:12 +00:00
Jonathan Lebon
d786b9fd5f man/config: Keep cmdsynopsis for GROUP.KEY version
It's nice to still show the previous usage since it's easier to type in
trivial cases like `core.mode`.

Closes: #1710
Approved by: sinnykumari
2018-08-21 10:36:12 +00:00
bubblemelon
4148918655 docs: Add detail to CONTRIBUTING.md and link to tutorial
This adds detailed information on commit message guidelines, a link to the contributing tutorial, and minor typo fixes.

Closes: #1694
Approved by: cgwalters
2018-08-20 15:23:00 +00:00
Robert Fairley
3f1faa4f33 docs: Add contributing tutorial
This adds a tutorial for developing/contributing to OSTree. The following information is included:
- Installing build dependencies for OSTree
- Building OSTree, and running in a container and VM
- Adding a basic command to OSTree, and testing the command
- Suggested git workflows for working with the upstream repo

This is helpful to give new contributors a more detailed introduction to developing OSTree, and an idea of what the workflow looks like.

Closes: #1694
Approved by: cgwalters
2018-08-20 15:23:00 +00:00
Sinny Kumari
dde3f1c0fb src/ostree: Add --group option to ostree config
Fetching value from a repo config using 'ostree config
get SECTIONNAME.KEYNAME' didn't work in some cases like
when having dots in Group Name entry.
As per Desktop entry file specification, Group Name
may contain all ASCII characters except for [ and ]
and control characters.
Link - https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.1.html

Having --group option will help user to clearly specify
Group Name and get desired result.

It also adds test for ostree config get|set and bash
completion for --group option

Fixes https://github.com/ostreedev/ostree/issues/1565

Closes: #1696
Approved by: cgwalters
2018-08-20 14:31:15 +00:00
Philip Withnall
e7305bbc8a lib/repo-pull: Prefer object pull over from-scratch delta if ref exists
If a ref already exists, we are likely only a few commits behind the
current head of the ref, so it is probably better for bandwidth
consumption to pull the individual objects rather than the from-scratch
delta.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1709
Approved by: cgwalters
2018-08-20 13:04:58 +00:00
Will Thompson
2b19869307 repo: remove outdated note from write_config() docs
Since 9dc6ddce0848cf04b76fc1c673c8fc1a0f6f425a it has not been true that
'new_config' was simply ref'd: it's serialized, and then re-parsed into
a new GKeyFile.

Closes: #1707
Approved by: jlebon
2018-08-19 02:01:12 +00:00
Will Thompson
ada5716fb2 man/ostree.repo-config: improve min-free-space-* docs
0 is not a valid value (the units are required), and 1MB is taken to
mean 1048576 bytes, not 1000000 bytes (unlike other human-readable sizes
in libostree, which are formatted by g_format_size(), and hence use
power-of-10 units). It's probably a bit late to change this latter
point, but the documentation should mention it.

Define 'MB' etc. more precisely; include the byte counts in the
examples; and improve the formatting of the min-free-space-* paragraphs.

Signed-off-by: Will Thompson <wjt@endlessm.com>

Closes: #1706
Approved by: mwleeds
2018-08-19 01:43:05 +00:00
Jonathan Lebon
57dbd176e9 ci: Bump rpm-ostree tag we build for tests
The latest rpm-ostree release no longer requires `python3-devel` so `dnf
builddep` here is no longer pulling it in, subsequently causing issues
when building an older rpm-ostree release. Let's just bump the release
tag so we don't have to also start keeping track of older dependencies.

Closes: #1708
Approved by: cgwalters
2018-08-19 01:03:47 +00:00
Dan Nicholson
4e6b13e8b6 repo: Add OSTREE_REPO_TEST_ERROR=invalid-cache env var
Add an invalid-cache test error flag to ensure that the code that checks
for and recovers from a corrupted summary cache is hit. This helps make
sure that the recovery path is actually used without resorting to
G_MESSAGES_DEBUG.

Closes: #1698
Approved by: cgwalters
2018-08-14 13:38:11 +00:00
Dan Nicholson
1b5cb52da2 tests: Test for recovery from corrupted summary cache
Check that recovery from a corrupted summary cache (cached summary
doesn't match cached signature) works.

Closes: #1698
Approved by: cgwalters
2018-08-14 13:38:11 +00:00
Dan Nicholson
e5061f54d6 lib/pull: Fetch summary if cached version doesn't match signature
If for some reason the cached summary doesn't match the cached signature
then fetch the remote summary and verify again. Since commit c4c2b5eb
this is unlikely to happen since the summary will only be cached if it
matches the signature. However, if the summary cache has been corrupted
for any other reason then it's best to be safe and fetch the remote
summary again.

This is essentially the corollary to c4c2b5eb. Where that commit helps
you from getting into the corrupted summary cache in the first place,
this helps you get out of it. Without this the client can get wedged
until a prune or the remote server republishes the summary.

Closes: #1698
Approved by: cgwalters
2018-08-14 13:38:11 +00:00
Dan Nicholson
1c69f1ed31 lib/pull: Add debug message when loading summary from cache
This helps when debugging issues with the cached summary handling.

Closes: #1698
Approved by: cgwalters
2018-08-14 13:38:11 +00:00
Dan Nicholson
ce4eb12ffb tests: Add tests for remote summary update races
There have been subtle bugs in the past when a client pulls while the
remote server is updating the summary. The client may get the old
summary and new signature or vice versa. Add tests to simulate this
behavior to make sure there aren't regressions in the future.

Closes: #1698
Approved by: cgwalters
2018-08-14 13:38:11 +00:00
Stefan Agner
4a389b3082 Avoid race condition in case tests directory does not exist
Make sure the tests directory exists before symlinking files
into it.

Closes: #1703

Closes: #1704
Approved by: cgwalters
2018-08-14 12:50:11 +00:00
Alexander Larsson
0a53af801e ostree_repo_pull_from_remotes_async: Fix leak of options
copy_option() unnecessarily passed ownership of the value
to g_variant_dict_insert_value, but that already refs, so it was leaked.

Closes: #1702
Approved by: cgwalters
2018-08-14 12:49:28 +00:00
Alexander Larsson
24883db908 ostree_repo_static_delta_generate: Fix leak
There is no need to ref the argument of g_variant_builder_add_value

Closes: #1701
Approved by: jlebon
2018-08-13 17:50:33 +00:00
Alexander Larsson
016cae1573 Fix leak in ostree_repo_list_collection_refs
We need to have the g_auto(GLnxDirFdIterator) inside the loop, or
we don't correctly clean up when iterating several times.

Closes: #1700
Approved by: cgwalters
2018-08-13 16:29:59 +00:00
Jonathan Lebon
521e0ec3ac lib/commit: Only auto-update summary if refs were written
Closes: #1693
Approved by: mwleeds
2018-08-01 19:59:07 +00:00
Jonathan Lebon
72a54fa877 lib/config: Deprecate commit-update-summary option
Now that we have `auto-update-summary`, there is no point in having
`commit-update-summary`. The latter also only had an effect through
the `commit` CLI command, whereas the former is embedded directly in
libostree.

There is one corner case that slips through: `commit` would update the
summary file even if orphan commits were created, which we no longer do
here. I can't imagine anyone relying on this, so it seems safe to drop.

Closes: #1689

Closes: #1693
Approved by: mwleeds
2018-08-01 19:59:07 +00:00
Jonathan Lebon
786ee6bdec lib/config: Rename change-update-summary to auto-...
Mildly bikeshed, though I find the name `auto-update-summary` to be
easier to grok than `change-update-summary`. I think it's because it can
be read as "verb-verb-noun" rather than "noun-verb-noun".

Closes: #1693
Approved by: mwleeds
2018-08-01 19:59:07 +00:00
Jonathan Lebon
3e96ec9811 lib/refs: Use GLNX_HASH_TABLE_FOREACH_KV helper
Closes: #1693
Approved by: mwleeds
2018-08-01 19:59:07 +00:00
Matthew Leeds
daa57b4630 lib/repo-pull: Use correct keyring for dynamic remotes
Normally, a configured remote will only serve refs with one associated
collection ID, but temporary remotes such as USB drives or LAN peers can
serve refs from multiple collection IDs which may use different GPG
keyrings. So the OstreeRepoFinderMount and OstreeRepoFinderAvahi classes
create dynamic OstreeRemote objects for each (uri, keyring) pair. So if
for example the USB mounted at /mnt/usb serves content from the
configured remotes "eos-apps" and "eos-sdk", the OstreeRepoFinderResult
array returned by ostree_repo_find_remotes_async() will have one result
with a remote called something like
file_mnt_usb_eos-apps.trustedkeys.gpg and the list of refs on the USB
that came from eos-apps, and another result with a remote
file_mnt_usb_eos-sdk.trustedkeys.gpg and the list of refs from eos-sdk.

Unfortunately while OstreeRepoFinderMount and OstreeRepoFinderAvahi
correctly only include refs in a result if the ref uses the associated
keyring, the find_remotes_cb() function used to clean up the set of
results looks at the remote summary file and includes every ref that's
in the intersection with the requested refs, regardless of whether it
uses a different remote's keyring. This leads to an error when you try
to pull from a USB containing refs from different collection IDs: the
pull using the wrong collection ID will error out with "Refspec not
found" and the result with the correct keyring will then be ignored "as
it has no relevant refs or they have already been pulled." So the pull
ultimately fails.

This commit fixes the issue by filtering refs coming from a dynamic
remote, so that only ones with the collection ID associated with the
keyring remote are examined. This only needs to be done for dynamic
remotes because you should be able to pull any ref from a configured
remote using its keyring. It's also only done when looking at the
collection map in the summary file, because LAN/USB remotes won't have a
"main" collection ID set (OSTREE_SUMMARY_COLLECTION_ID).

Closes: #1695
Approved by: pwithnall
2018-08-01 13:57:10 +00:00
Colin Walters
dcd1522969 ostree-remount.service: RemainAfterExit=yes
This is standard practice for units like this; e.g. it's what
`systemd-remount-fs.service` does.  I think it may be part of
or the whole cause for
https://github.com/projectatomic/rpm-ostree/issues/1471

I haven't reproduced the problem exactly but it seems to me that
if the unit starts and is GC'd, then when systemd goes to execute
a later unit it might end up restarting it.

A noticeable side effect of this is that `systemctl status ostree-remount`
exits with code `0` as expected.

Closes: #1697
Approved by: jlebon
2018-07-31 21:15:57 +00:00
bubblemelon
61c37aa40c bin/refs: Clarify --create error message
Fix ref create error when existing rev not specified.

Closes: #1690
Approved by: jlebon
2018-07-30 17:54:58 +00:00
Matthew Leeds
6869bada49 config: Add a core/change-update-summary option
This commits adds and implements a boolean repo config option called
"change-update-summary" which updates the summary file every time a ref
changes (additions, updates, and deletions).

The main impetus for this feature is that the `ostree create-usb` and
`flatpak create-usb` commands depend on the repo summary being up to
date. On the command line you can work around this by asking the user to
run `ostree summary --update` but in the case of GNOME Software calling
out to `flatpak create-usb` this wouldn't work because it's running as a
user and the repo is owned by root. That strategy also means flatpak
can't update the repo metadata refs for fear of invalidating the
summary.

Another use case for this relates to LAN updates. Specifically, the
component of eos-updater that generates DNS-SD records advertising ostree
refs depends on the repo summary being up to date.

Since ostree_repo_regenerate_summary() now takes an exclusive lock, this
should be safe to enable. However it's not enabled by default because of
the performance cost, and because it's more useful on clients than
servers (which likely have another mechanism for updating the summary).

Fixes https://github.com/ostreedev/ostree/issues/1664

Closes: #1681
Approved by: jlebon
2018-07-30 17:19:12 +00:00
Matthew Leeds
fb36b62f33 lib/repo: Take exclusive lock while generating summary
This ensures that commits aren't deleted and refs aren't added, removed,
or updated while the summary is being generated. This is in preparation
for adding a repo config option that will automatically regenerate the
summary on every ref change.

Closes: #1681
Approved by: jlebon
2018-07-30 17:19:12 +00:00
Jonathan Lebon
968e8805b0 lib: Fix some logic/error-checking code
Using `MAX(0, $x)` here is useless since we're comparing against an
unsigned integer. Just unpack this and only subtract if it's safe to do
so.

Also, explicitly check for `fd >= 0` rather than just `!= -1` to be sure
it's a valid fd. And finally, explicitly check the return value of
`g_input_stream_read_all` as is done everywhere else in the tree and
make it clear that we're purposely ignoring the return value of `_flush`
here, but not in other places.

Discovered by Coverity.

Closes: #1692
Approved by: cgwalters
2018-07-26 21:01:19 +00:00
Jonathan Lebon
fcd31a195b lib: Fix some minor memory leaks
I initially was going to add a `G_DEFINE_AUTOPTR_CLEANUP_FUNC` for
`FetchStaticDeltaData`, but it honestly didn't seem worth mucking around
ownership everywhere and potentially getting it wrong.

Discovered by Coverity.

Closes: #1692
Approved by: cgwalters
2018-07-26 21:01:19 +00:00
Jonathan Lebon
9482922e5e lib: Check for NULL pointers in some more places
In `write_metadata_object()`, make sure when creating tombstone commits
that we're actually passed an expected checksum to use.

In `write_dir_entry_to_mtree_internal()`, sanity check that `dfd_iter`
is indeed not `NULL` before trying to dereference it.

Discovered by Coverity.

Closes: #1692
Approved by: cgwalters
2018-07-26 21:01:19 +00:00
Matthew Leeds
799cfcb5b3 man/ostree.repo-config: Update min-free-space-* docs
Now that it's possible to have both min-free-space-size and
min-free-space-percent set in a repo config, update the docs to make
the behavior clear in that case.

Closes: #1687
Approved by: jlebon
2018-07-25 13:21:30 +00:00
Matthew Leeds
be07c04e63 lib/repo-commit: Fix min-free-space error message
Since min_free_space_size_mb is considered before min_free_space_percent
in min_free_space_calculate_reserved_blocks(), it has to be considered
first when generating the error message in order for it to be accurate.

Closes: #1691
Approved by: jlebon
2018-07-25 13:16:18 +00:00
Colin Walters
93da568422 lib/pull: Fix minor memleak in error path
Spotted by a downstream Coverity build.

Closes: #1684
Approved by: jlebon
2018-07-20 20:32:17 +00:00
Umang Jain
bbb253238a Post-release version bump
Closes: #1683
Approved by: cgwalters
2018-07-20 19:43:18 +00:00
Umang Jain
21318bbc1f Release 2018.7
Request via flatpak: mainly to port min-free-space-size

Closes: #1683
Approved by: cgwalters
v2018.7
2018-07-20 19:43:18 +00:00
Colin Walters
988f4631ce ci: Mark insttests as not required
The reliablity has just not been what we need, and they haven't
yet caught any real bugs.  Until I can carve off some time to
truly make this reliable let's just mark it as not required.
I'd like to gather more statistics on the failure scenarios.

Closes: #1686
Approved by: jlebon
2018-07-20 18:55:48 +00:00
Umang Jain
66079c7b65 lib/repo: Allow min-free-space-size and -percent to co-exist
Previously, we would error out if both of the options were mentioned
in the config file (even if one of them is disabled with 0). There
were few suggestions that this behavior was not quite right.

Therefore, instead of throwing error and exiting, it's preferred to
warn the user. Hence, the solution that worked out is:
* Allow both options to exist simulateneously
* Check each config's value and decide:
  * If both are present and are non-zero, warn the user. Also, prefer
    to use min-free-space-size over the another.
  * If both are absent, then use -percent=3% as fallback
  * Every other case is valid hence, no warning

https://phabricator.endlessm.com/T13698
(cherry picked from commit be68991cf80f0aa1da7d36ab6e1d2c4d6c7cd3fb)
Signed-off-by: Robert McQueen <rob@endlessm.com>

Closes: #1685
Approved by: cgwalters
2018-07-20 14:58:40 +00:00
Emmanuele Bassi
7306577e61 Add a check for gpg-error via pkg-config
Some downstreams — namely, the Yocto Project — ship gpg-error with a
pkg-config file, and modify gpg-error-config to error out when you try
using it instead of pkg-config.

We can check for gpg-error via pkg-config, and if it's not available,
fall back to gpg-error-config.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

Closes: #1682
Approved by: cgwalters
2018-07-18 01:34:36 +00:00
Colin Walters
ededa9de41 Update libglnx
For `renameat2()` fix to build with latest glibc (e.g. Fedora rawhide).

Update submodule: libglnx

Closes: #1680
Approved by: jlebon
2018-07-17 19:59:18 +00:00
Colin Walters
be8bbc5f87 build-sys: Link with gpg-error directly
We use the API, and not linking breaks the build with e.g.
`-fuse-ld=gold` in a Fedora 28 buildroot as gold doesn't do the
"search indirect dependencies" thing.

Closes: #1679
Approved by: jlebon
2018-07-17 19:14:14 +00:00
Colin Walters
fef07889d3 deploy: Fix overriding kernel args for staged deployments
This is the inverse of https://github.com/ostreedev/ostree/pull/1558
aka commits cadece6c4f398ca61d21e497bd6e3fbb549f9cf6 and
3358698c86d80821d81443c906621c92672f99fb

Needed to fix `rpm-ostree kargs` test suite with default staging; skipping
a test here for now as eventually what we'll do is turn on the rpm-ostree
suite fully here.

Closes: #1677
Approved by: jlebon
2018-07-09 18:04:57 +00:00
William Manley
c7b12a8730 ostree repo commit: Speed up composing trees with --tree=ref
Running `ostree commit --tree=ref=a --tree=dir=b` involves reading the
whole of a into an `OstreeMutableTree` before composing `b` on top.  This
is inefficient if a is a complete rootfs and b is just touching one file.
We process O(size of a + size of b) directories rather than
O(number of touched dirs).

This commit makes `ostree commit` more efficient at composing multiple
directories together.  With `ostree_mutable_tree_fill_empty_from_dirtree`
we create a lazy `OstreeMutableTree` which only reads the underlying
information from disk when needed.  We don't need to read all the
subdirectories just to get the checksum of a tree already checked into the
repo.

This provides great speedups when composing a rootfs out of multiple other
rootfs as we do in our build system.  We compose multiple containers
together with:

    ostree commit --tree=ref=base-rootfs --tree=ref=container1 --tree=ref=container2

and it is much faster now.

As a test I ran

    time ostree --repo=... commit --orphan --tree=ref=big-rootfs --tree=dir=modified_etc

Where modified_etc contained a modified sudoers file under /etc.  I used
`strace` to count syscalls and I seperatly took timing measurements.  To
test with a cold cache I ran

    sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

Results:

|                      | Before | After |
| -------------------- | ------ | ----- |
| Time (cold cache)    |   8.1s | 0.12s |
| Time (warm cache)    |   3.7s | 0.08s |
| `openat` calls       |  53589 |   246 |
| `fgetxattr` calls    |  78916 |     0 |

I'm not sure if this will have some negative interaction with the
`_ostree_repo_commit_modifier_apply` which is short-circuited here.  I
think it was disabled for `--tree=ref=` anyway, but I'm not certain.  All
the tests pass anyway.

I originally implemented this in terms of the `OstreeRepoFile` APIs, but
it was *way* less efficient, opening and reading many files unnecessarily.

Closes: #1643
Approved by: cgwalters
2018-07-09 13:10:51 +00:00
Alex Kiernan
11eb0bd227 switchroot: Move late /run/ostree-booted creation to ostree-system-generator
When ostree-prepare-root is pid 1, ostree-prepare-boot defers creation of
/run/ostree-booted, which happens in ostree-remount, but that's too late
if we need ostree-system-generator to bind /var. Add the creation of the
/run/ostree-booted marker to ostree-system-generator based on the
existence of the ostree= kernel command line argument (which matches the
condition that ostree-remount uses).

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>

Closes: #1675
Approved by: cgwalters
2018-07-09 00:11:31 +00:00
Alex Kiernan
d6327f9dd9 switchroot: Fix typo in comment ENINVAL => EINVAL
Closes: #1676
Approved by: cgwalters
2018-07-08 12:41:59 +00:00
Umang Jain
eeacbc6b29 repo: Reword min-free-space-size option's error strings
It is important that we use user-friendly error strings. The reason
being error strings are seen by users such as in GNOME Software's
error banner.

Closes: #1671
Approved by: jlebon
2018-07-06 19:59:11 +00:00
Umang Jain
4c023a9585 lib/repo-commit: Factor out min-free-space-size error reporting
Improves code readability.

Closes: #1671
Approved by: jlebon
2018-07-06 19:59:10 +00:00