Commit Graph

4227 Commits

Author SHA1 Message Date
Jonathan Lebon 367be40a89 boot: Remove [Install] from ostree-finalize-staged
Let's just make this service not installable anymore. It should only be
activated manually.

Closes: #1750
Approved by: cgwalters
2018-10-05 21:17:54 +00:00
Matthew Leeds 039bbe5682 man/create-usb: Don't recommend summary updates
This commit removes the recommendation in the create-usb man page for
the user to update the summary in the source repo before using the
create-usb command. I'm not sure where I got the idea that create-usb
depends on a summary in the source repo. I went back to the first commit
that introduced the create-usb command and even using that a summary
isn't required, so it seems unlikely that this changed recently.

This is good news because the exclusive lock that's taken for summary
updates has been causing problems on Endless (due to other processes
having a lock for the duration of the 30 second acquire time out
period).

Closes: #1746
Approved by: cgwalters
2018-10-02 15:49:42 +00:00
Colin Walters 2c55bc6997 Only verify OSTREE_MAX_METADATA_SIZE for HTTP fetches
There are use cases for libostree as a local content store
for content derived or delivered via other mechanisms (e.g. OCI
images, RPMs, etc.).  rpm-ostree today imports RPMs into OSTree
branches, and puts the RPM header value as commit metadata.
Some of these can be quite large because the header includes
permissions for each file.  Similarly, some OCI metadata is large.

Since there's no security issues with this, support committing
such content.

We still by default limit the size of metadata fetches, although
for good measure we make this configurable too via a new
`max-metadata-size` value.

Closes: https://github.com/ostreedev/ostree/issues/1721

Closes: #1744
Approved by: jlebon
2018-10-01 13:23:50 +00:00
Matthew Leeds 5cada0f051 bash-completion: Fix --repo autocomplete
This commit fixes the bash tab completion handling of the "--repo"
argument. Before this commit, the completion only works if "--repo"
comes after the main command. After this commit, you can use "--repo"
directly after "ostree" in the command line, as is natural.

Closes: #1745
Approved by: jlebon
2018-10-01 13:19:27 +00:00
Jonathan Lebon 39d5db7e1e lib/mutable-tree: Port to new style
Some therapeutic style conversion to finish off the week. Pretty
straightforward overall.

Closes: #1742
Approved by: cgwalters
2018-09-28 21:49:36 +00:00
Colin Walters 899b0bfad2 lib/progress: Fix leak of GSource
Closes: https://github.com/ostreedev/ostree/issues/1738

Closes: #1741
Approved by: jlebon
2018-09-28 21:40:41 +00:00
Jonathan Lebon 6e3d4f9054 ci: Bump rpm-ostree tag to 2018.8
2018.7 started failing `test-ucontainer.sh`. I don't have the cycles to
look more deeply into what was going on there, but bumping to 2018.8
fixes it at least. (And of course, it's passing in rpm-ostree too.)

Closes: #1728
Approved by: cgwalters
2018-09-28 19:06:08 +00:00
Matthew Leeds 1a7536c0f9 man/ostree.repo-config: Document locking options
This commit documents the "locking" and "lock-timeout-secs" options
which have been around for a few releases.

Closes: #1737
Approved by: jlebon
2018-09-28 15:49:11 +00:00
Matthew Leeds 7892d35c0b lib/repo: Fix minor mistake in locking docs
The config option is "lock-timeout-secs" not "lock-timeout".

Closes: #1737
Approved by: jlebon
2018-09-28 15:49:11 +00:00
Matthew Leeds 0c8a6d64ed lib/repo: Allow disabling lock timeout
Currently the locking code checks if the value -1 was set for the config
key "lock-timeout-secs" and if so, a thread trying to acquire a lock
will block indefinitely. Positive values specify how long to attempt to
acquire a lock in a non-blocking way (the attempt is made once every
second). But when the value is read from the config file,
g_ascii_strtoull() is used, which converts it to an unsigned integer.
This commit makes libostree use g_ascii_strtoll() instead, so that it's
possible to set that key to -1 as intended.

Closes: #1737
Approved by: jlebon
2018-09-28 15:49:11 +00:00
Matthew Leeds 9a06c5409e create-usb: Add a --commit option
Currently on Endless OS, the OSTree ref for the operating system is
something like os/eos/amd64/eos3, so that's what gets passed to `ostree
create-usb` when copying the OS to a USB drive (for offline updates).
However, when eos-updater checks for updates it pulls the metadata for a
candidate commit and in so doing updates that eos3 ref to point to the
partial commit being examined as a potential update rather than the
deployed commit. This causes `ostree create-usb` to fail with an error
like "No such metadata object
7fb045cb2d1f1f3a81bfc157c6128ff443eb56350315b9536bdb56aee0659863.dirtree".

OSTree creates deployment refs that look like "ostree/1/1/0" to maintain
a pointer to the deployed commit, but create-usb can't use these because
it shows up in the summary as just a ref, not a collection-ref.

So this commit adds a --commit option to the create-usb command, so we
can use the appropriate ref but copy the deployed commit rather than a
(potentially partial) update commit.

Closes: #1735
Approved by: cgwalters
2018-09-25 15:47:25 +00:00
Colin Walters c141fe610b lib/commit: Don't copy xattrs for metadata objects
Copying the xattrs on metadata objects is wrong in general, we
don't "own" them.  Notably this would fail in the situation of
doing a pull from e.g. a `bare-user` source to a destination
that was on a different mount point (so we couldn't hardlink),
and the source had e.g. a `security.selinux` attribute.

Closes: #1734

Closes: #1736
Approved by: jlebon
2018-09-25 14:49:22 +00:00
Matthew Leeds fc357adb79 create-usb: Always use archive mode
Change the create-usb command so that it always creates the destination
repository using the "archive" mode, rather than using archive mode when
xattrs aren't supported and bare-user otherwise. This has a few
advantages:

1. The archive mode works with FAT filesystems, which is what most
USB drives are, and which doesn't support xattrs.

2. At least in some quick testing I did, archive mode is about
twice as performant as bare-user mode, in terms of how long it takes for
the create-usb command to complete.

3. This ensures that a tool can safely change the permissions on
".ostree/repo" and subdirectories after create-usb completes, which is
important for Endless since otherwise you can't use `ostree create-usb`
as root and then `flatpak create-usb` as a non-root user on the same USB
drive (or in other words copy OS updates and apps to the same USB).

Closes: #1733
Approved by: cgwalters
2018-09-25 13:52:38 +00:00
Jonathan Lebon 4aadbe2159 lib/fetcher-curl: Prefix fatal errors with full URL
Just include the whole URL that failed if libcurl failed with something
elementary like CURLE_COULDNT_CONNECT or CURLE_COULDNT_RESOLVE_HOST.

Closes: #1731

Closes: #1732
Approved by: cgwalters
2018-09-21 18:43:09 +00:00
Jonathan Lebon a88032a09e lib/fetcher-curl: Drop unnecessary check
`_ostree_fetcher_journal_failure()` already checks that we only log
messages which have remotes.

Closes: #1732
Approved by: cgwalters
2018-09-21 18:43:09 +00:00
Jonathan Lebon 8b2940aa13 lib/fetcher-util: Mark journaled msgs as LOG_ERR
E.g. for filtering, and so it shows up in red.

Closes: #1732
Approved by: cgwalters
2018-09-21 18:43:09 +00:00
Colin Walters 44d5f1cb8c deploy: Fix removing /var/.updated with separate /var mount
There's some subtlety to this, we don't handle all cases.
But the 99% cases are using `--sysroot deploy` to create an
initial deployment, and then doing upgrades from inside
a booted deployment.

It was only the latter case that didn't work with a separate `/var`.
Fixing all of them would probably require libostree to learn
how to e.g. look at `/etc/fstab` (or worse, systemd mount units?)
and handle the mounting.  I don't think we want to do anything
like that right now, since there are no active drivers for the
use case.

Closes: https://github.com/ostreedev/ostree/issues/1729

Closes: #1730
Approved by: akiernan
2018-09-21 15:47:43 +00:00
Umang Jain 5d2e62affb tests: Update tests for ostree_repo_get_min_free_space_bytes()
https://github.com/ostreedev/ostree/issues/1720

Closes: #1722
Approved by: pwithnall
2018-09-21 15:09:12 +00:00
Umang Jain a0937b6cf0 lib/repo: Separate min-free-space-* calculation from transaction codepath
Earlier, the actual reserved space (in blocks) were calculated inside the
transaction codepath ostree_repo_prepare_transaction(). However, while
reworking on ostree_repo_get_min_free_space_bytes() API, it was realized that
this calculation can be done independently from the transaction's codepaths, hence
enabling the usage for ostree_repo_get_min_free_space_bytes() API irrespective
of whether there is an ongoing transaction or not.

https://github.com/ostreedev/ostree/issues/1720

Closes: #1722
Approved by: pwithnall
2018-09-21 15:09:12 +00:00
Matthew Leeds fc84fb402c lib/repo: Define a metadata key, ostree.deploy-collection-id
This commit defines a metadata key that tells clients to update their
remote config to add a collection ID. This functionality is currently
implemented in Flatpak for the key "xa.collection-id", but there are two
good reasons for moving the key to OSTree:

1) Servers such as Flathub shouldn't set xa.collection-id in their
metadata now or in the medium term future, because many users are still
using old versions of Flatpak and OSTree[1] which would hit various
bugs[2][3][4] on the P2P code paths that are enabled by collection IDs.
Defining a new key means that only clients running recent
(as-yet-unreleased) versions of Flatpak and OSTree will pay attention to
it and deploy the collection ID, leaving the users on old versions
unaffected.

2) OSTree is as "invested" in collection IDs as Flatpak, so there's no
reason the key should be defined in Flatpak rather than here. According
to Philip Withnall, the reason the key was put in Flatpak originally was
that at the time there was uncertainty about tying OSTree to collection
IDs.

[1] https://ahayzen.com/direct/flathub.html#downloadsbyflatpakstacked
[2] https://github.com/ostreedev/ostree/commit/e4e6d85ea
[3] https://github.com/flatpak/flatpak/commit/5813639f
[4] https://github.com/flatpak/flatpak/commit/5b21a5b7

Closes: #1726
Approved by: pwithnall
2018-09-21 13:04:51 +00:00
Robert McQueen b32c9e0df9 OstreeMutableTree: add _remove method
There is no API method to remove a file or subdirectory from a MutableTree
besides directly manipulating the GHashTable returned by _get_files or
_get_subdirs. This isn't possible from an introspection binding that transforms
the returned GHashTable, and may also leave the tree checksum in an invalid
state. Introduce a new method so that removing files or subdirectories is
safe, and possible from bindings.

Closes: #1724
Approved by: jlebon
2018-09-20 17:49:55 +00:00
Matthew Leeds 6b37fe8310 lib/repo: Clean up OstreeRepo docs
This fixes typos and grammar in the docs for OstreeRepo, and copies the
information about OSTREE_REPO_MODE_BARE_USER_ONLY from ostree-core.h

Closes: #1725
Approved by: jlebon
2018-09-20 17:05:34 +00:00
Jonathan Lebon 3c46bcdb50 ci: Disable f28-rpmostree for now
It started failing with:

```
ERROR: tests/check/test-ucontainer.sh - too few tests run (expected 2, got 0)
tap-driver.sh: internal error getting exit status
tap-driver.sh: fatal: I/O or internal error
make[4]: *** [Makefile:4353: tests/check/test-ucontainer.sh.log] Error 1
make[4]: *** Waiting for unfinished jobs....
```

And the artifacts are not being saved for some reason:

```
+ cleanup
+ mv test-suite.log /var/tmp/checkout
mv: cannot stat 'test-suite.log': No such file or directory
+ true
+ mv vmcheck /var/tmp/checkout
mv: cannot stat 'vmcheck': No such file or directory
+ true
```

Let's just disable this for now so that some other pending patches can
go in while we investigate.

Closes: #1727
Approved by: cgwalters
2018-09-20 16:59:41 +00:00
Matthew Leeds e4e6d85ea4 avahi: Be robust to missing refs in peer summaries
In the OstreeRepoFinderAvahi implementation,
ostree_avahi_service_build_repo_finder_result() is where the DNS-SD
records are processed and turned into OstreeRepoFinderResult objects.
Each result object is supposed to have a hash table mapping refs to
checksums, so this is accomplished by first adding a placeholder (a ref
mapping to a NULL checksum) for each ref matched by the bloom filter,
and later filling in the checksums using the remote's summary file,
which happens in get_checksums(). The problem is that there's no
guarantee all the checksums will be resolved (non-NULL), so the
ostree_repo_finder_result_new() call then hits an assertion failure in
is_valid_collection_ref_map() leading to a crash (in the case that one
or more refs had NULL checksums).

There are at least two situations where the ref checksum might not be
found in the peer remote's summary file:
1) The bloom filter match was a false positive. This is going to happen
sometimes by design.
2) The peer remote's summary is out of sync with its DNS-SD records.
This shouldn't normally happen but it's still good to be robust to the
possibility; in Endless OS nothing guarantees the atomicity of updating
the summary and DNS-SD records.

This commit changes libostree to be robust to the possibility of refs
missing from the peer remote's summary, by removing any that still have
a NULL checksum associated with them after the summary has been fetched
and processed.

The other OstreeRepoFinder implementations don't have this issue because
they use summary files directly and therefore always have access to the
checksum.

Closes: #1717
Approved by: pwithnall
2018-09-07 10:19:24 +00:00
Umang Jain a70d2f6731 Add tests for ostree_repo_get_min_free_space_bytes
https://phabricator.endlessm.com/T23694

Closes: #1715
Approved by: cgwalters
2018-09-04 21:31:34 +00:00
Umang Jain 68420f70bb lib/repo: Add an API to get min-free-space-* reserved bytes
https://phabricator.endlessm.com/T23694

Closes: #1715
Approved by: cgwalters
2018-09-04 21:31:34 +00:00
Umang Jain 3814d075cb lib/repo: Ensure min-free-space* config value doesn't overflow
when converted to bytes

In a subsequent commit, we add a public API to read the value of
min-free-space-* value in bytes. The value for free space check
is enforced in terms of block size instead of bytes. Therefore,
for consistency we check while preparing the transaction that the
value doesn't overflow when converted to bytes.

https://phabricator.endlessm.com/T23694

Closes: #1715
Approved by: cgwalters
2018-09-04 21:31:33 +00:00
Felix Krull 74bdf7e173 lib/grub2: Support Debian-style grub.cfg path
Debian and Debian-derived systems have their GRUB configuration file in
/boot/grub/grub.cfg, rather than /boot/grub2/grub.cfg. Detecting this
file is necessary to correctly generate GRUB boot configuration on
Debian systems.

Closes: #1714
Approved by: cgwalters
2018-09-04 20:47:46 +00:00
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
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 9dc6ddce08 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