Commit Graph

1883 Commits

Author SHA1 Message Date
Léo Stefanesco
66dfb63075 Fix segfault when reporting error during install
flatpak_dir_install was returning FALSE but leaving error to NULL, which
would crash when printing the error.

Fixes #3646
2020-06-05 17:02:45 +02:00
Ryan Gonzalez
1735d88f01 Clean up duplicated instance collection code
It was completely identical in flatpak-run.c and flatpak-instance.c.
2020-06-05 16:36:13 +02:00
alaviss
ea1830e108 common/flatpak-run: respect user's XDG base directories (#3626)
This makes flatpak respects XDG_DATA_HOME and XDG_CACHE_HOME for binding
user's fonts and icons into the sandbox.
2020-06-05 16:31:39 +02:00
Alexander Larsson
b042abc71c oci: Handle io.github.containers.DeltaUrl in index
If the magical io.github.containers.DeltaUrl label is set in the
index, then try to download this to use as the delta manifest for the
image. This allows servers to store deltas outside the registry
itself. The label is propagated to the xa.delta-url metadata in the
generated "fake summary" for the remote, and read back on pull.

Note that the delta manifest layers descriptor will need to have a
"urls" key where it references the blobs if the blobs are also not
stored on the registry.

If the specified manifest doesn't exist or doesn't apply to the target
image we fall back to resolving via the _deltaindex tag.
2020-06-05 09:35:30 +02:00
Alexander Larsson
fd197300b9 oci: Fix potential crash
Call flatpak_remote_state_ensure_summary() before dereferencing
RemoteState->summary to return an error instead of crashing if
downloading the summary failed.
2020-06-05 09:35:30 +02:00
Alexander Larsson
47daa077c2 OCI: Support (and use) alternative urls specified in OCI descriptors 2020-06-05 09:35:30 +02:00
Alexander Larsson
aaa36bab45 oci: Support deltas when using system-helper
When mirroring to a local OCI dir we apply deltas and generate
uncompressed layer blobs instead of regular blobs. Then we pick this
up on the system-helper side.
2020-06-05 09:35:30 +02:00
Alexander Larsson
f2cb157294 oci: Use the correct progress layer size when using deltas 2020-06-05 09:35:30 +02:00
Alexander Larsson
37dcccea61 oci: Add flatpak_oci_registry_apply_delta_to_blob()
This is a version of flatpak_oci_registry_apply_delta() that generates
a new blob in a local repo, rather than a temporary file. This is used
when mirroring using a delta into a child oci registry for system-helper
use.
2020-06-05 09:35:30 +02:00
Alexander Larsson
5d8fd2d1be oci: Set token on child oci registry and pass to system-helper
When we create a system child registry we also set the current token on
it. This is not used directly in the client, however its saved in a
file called .token and re-read in the system-helper, allowing it to
also do the remote registry operations it needs to verify the child
registry.
2020-06-05 09:35:30 +02:00
Alexander Larsson
d4962628aa oci: Add flatpak_oci_registry_is_local() 2020-06-05 09:35:30 +02:00
Alexander Larsson
8c454f99f2 oci: Add debug spew when using deltas 2020-06-05 09:35:30 +02:00
Alexander Larsson
4539d186a5 oci: Make libzstd optional (and disable OCI deltas if not there) 2020-06-05 09:35:30 +02:00
Alexander Larsson
7be653a14d oci: Find and apply available deltas when pulling 2020-06-05 09:35:30 +02:00
Alexander Larsson
0fce4c6d7f oci: Pass FlatpakPullFlags to pull_from_oci()
We want to handle FLATPAK_PULL_FLAGS_NO_STATIC_DELTAS
2020-06-05 09:35:30 +02:00
Alexander Larsson
abf5b2db44 oci: Add basic functions to find and apply OCI deltas
This is based on the OCI delta work at:
  https://github.com/containers/image/pull/902
2020-06-05 09:35:30 +02:00
Alexander Larsson
3d8ca04565 oci: Add helpers to parse OCI delta index and manifest 2020-06-05 09:35:30 +02:00
Alexander Larsson
eaeb52b6a3 flatpak_oci_registry_load_blob: Allow tags (and digests) arg
We typically only load by digest id, resolving tags in other ways.
However, we need to load the _deltaindex tag by tagname, so support
this when possible.
2020-06-05 09:35:30 +02:00
Alexander Larsson
29da4ca430 oci: Store the last layer diff-id in the commit metadata (xa.diff-id)
We an use the commit content as original data for deltas going from
this diff-id, so this will be useful later.
2020-06-05 09:35:30 +02:00
Alexander Larsson
90f5fdb44d oci: Add flatpak_oci_image_get_n_layers() helper 2020-06-05 09:35:30 +02:00
Alexander Larsson
e0a25e7650 http: Also accept image indexes when FLATPAK_HTTP_FLAGS_ACCEPT_OCI 2020-06-05 09:35:30 +02:00
Alexander Larsson
01919d251e oci: Use content type from server if not in contents 2020-06-05 09:35:30 +02:00
Alexander Larsson
7820057336 Add content_type output to flatpak_load_uri()
We want this to get the oci mimetypes
2020-06-05 09:35:30 +02:00
Alexander Larsson
bfa71e208a Add FlatpakZstdDecompressor converter (and libzstd dep)
We will need this to decompress oci deltas.
2020-06-05 09:35:30 +02:00
Alexander Larsson
8e0e5a5749 oci: Always checksum entire layer when pulling
It turns out that libarchive doesn't always read the entire file until
the end if it can figure out that the tarfile ended. Normally this is
not hit, because the decompressor reads all the input, but for
uncompressed tarfiles (like those from applied deltas) this is
important.
2020-06-05 09:35:30 +02:00
Alexander Larsson
c2529d0bf8 oci: Use /var/tmp for tmpdir instead of /tmp
The files we're creating could potentially be large, so lets
not overflow ram if /tmp is a tmpfs.
2020-06-05 09:35:30 +02:00
Henri Chain
0c291cf1c9 run: Change systemd unit name
As per https://github.com/systemd/systemd/pull/15647 replace "apps-" with "app-" in the scope name. Also escape app id to avoid using the special char `.`.
2020-05-13 09:57:53 +02:00
Alexander Larsson
171218969b tokens: Request tokens during resolve if we get 401 status
If downloading a specific commit (or oci manifest) we may get a 401 back.
If so, request a token and try again. In this case we don't yet know the
token type, so pass MAXINT32 for "don't know".
2020-05-05 13:08:57 +02:00
Alexander Larsson
f6a0fa41a1 Add FLATPAK_HTTP_ERROR_UNAUTHORIZED (i.e. http status 401) 2020-05-05 13:08:57 +02:00
Alexander Larsson
e3c31309a4 Rename internal error FLATPAK_OCI_ERROR to FLATPAK_HTTP_ERROR
This is what it is really, and I want to extend it with more http errors
that are not necessarily oci related.
2020-05-05 13:08:57 +02:00
Alexander Larsson
6c3f150a05 oci: Don't crash when loading manifest by digest with no ref label 2020-05-05 11:26:20 +02:00
Alexander Larsson
a94e36d002 oci: Actually respect the commit argument when pulling
We now allow this to be set with update --commit=123abc in the oci case
too.
2020-05-05 09:33:09 +02:00
Alexander Larsson
cf49bd4ac8 oci: Support reconstructure individual commit objects (sorta)
This downloads a manifest by digest and reconstructs the commit except
for the tree/metadata reference. This allows things like flatpak remote-info
and flatpak update --commit=xxx to work.
2020-05-05 09:33:09 +02:00
Alexander Larsson
56f530ca1f dir: Add flatpak_remote_state_new_oci_registry helper
This is duplicated in a few places
2020-05-05 09:33:09 +02:00
Alexander Larsson
2028a5323f dir: Share some code that downloads commit objects
Only have the single function flatpak_remote_state_load_ref_commit()
that loads the commit objects (and don't support loading other types
of objects as that is not used).

This is a minor cleanup, but it also will be useful later when
we want to be able to "load" commits from OCI repositories.
2020-05-05 09:33:09 +02:00
Alexander Larsson
1ee132e70e oci authenticator: Accept the right docker manifest when authenticating
Without this I got for the fedora registry:

```
getting token for https://registry.fedoraproject.org/v2/f32/flatpak-runtime/manifests/sha256:bd83b4f6974094848efac22b933419c1dbe11b553def148a82f821faf595de8a
F: Anonymous authentication failed: Unexpected response status 404 from repo
```
2020-05-04 16:32:22 +02:00
Alexander Larsson
fdfcae7a91 By default, always try to auth to OCI remotes
This makes for instance docker hub work.
2020-05-04 16:32:22 +02:00
Abderrahim Kitouni
d145723fe3 dir: set cache directory when creating child repos 2020-05-04 12:15:21 +02:00
David Edmundson
e481e3ea58 Rename registered cgroups to have app- prefix
The newly added https://systemd.io/DESKTOP_ENVIRONMENTS/ lists an XDG
defined specification for how cgroups for applications should be named.

This will allow flatpak's to correctly follow any drop-in's set for
applications on the system as well as help next-gen system monitor's
treat flatpaks as applications.

flatpak-session-helper.service is unaffected.
2020-05-04 12:07:24 +02:00
Philip Withnall
82d0a3f50a flatpak-transaction: Change related_to_op to related_to_ops
Since a single runtime (for example) can be related-to several apps,
that needs to be representable in the data format.

This is an API break, but only of API which has not been released yet.

See https://github.com/flatpak/flatpak/pull/3568#issuecomment-618251958

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-30 13:14:45 +01:00
Philip Withnall
1c2024dc8d flatpak-transaction: Clarify units in documentation
While it can be worked out from the context, it’s clearer to state the
units that download and installed sizes are calculated in explicitly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-23 10:13:19 +02:00
Philip Withnall
b743ca6478 flatpak-transaction: Clarify some documentation around skipped ops
Make it explicit that skipped ops are excluded when returning the ops in
a transaction, or when working out whether it’s empty.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-23 10:13:19 +02:00
Philip Withnall
5824668418 flatpak-transaction: Add flatpak_transaction_operation_get_is_skipped()
This exposes the `skip` member of `FlatpakTransactionOperation`, as it’s
needed for callers to usefully traverse the operation graph (which is
now accessible using
`flatpak_transaction_operation_get_related_to_op()`).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-23 10:13:19 +02:00
Philip Withnall
d51e7468e1 dir: Fix a typo in a flags enum name
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-23 09:56:35 +02:00
Matthew Leeds
129d72e667 transaction: Fix a typo in a comment 2020-04-16 09:22:11 +02:00
Matthew Leeds
e847bb31b6 installation: Re-implement list_installed_refs_for_update()
Re-implement flatpak_installation_list_installed_refs_for_update() using
a FlatpakTransaction, so we can guarantee it always gives the same set
of things to update as the update command. This API is used by GNOME
Software and many times in the past g-s has not shown the same list of
apps to be updated as the flatpak CLI. See:
- https://gitlab.gnome.org/GNOME/gnome-software/issues/539
- https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/430

This commit also expands the unit tests for this API, which were already
quite good. Now we test that missing subpaths of locale extensions show
up as updates, and updates that have been pulled but not deployed show
up as well. The latter is a break from how this function used to behave,
but it seems unlikely to break any application.
2020-04-16 09:22:11 +02:00
Matthew Leeds
f61f9d17da transaction: Use correct subpaths for locales
Currently, if you add an app update to a transaction and its locale
extension does not have subpaths installed for every configured
language, the locale will be updated accordingly. But if you add only
the locale extension to the transaction to be updated, the transaction
is a no-op because we treat subpaths == NULL to mean the currently
installed set of subpaths, and
flatpak_dir_needs_update_for_commit_and_subpaths() decides there's
nothing to do.

This doesn't seem like the right behavior, so update
flatpak_transaction_add_ref() so that we take the configured set of
locales into account as we do in add_related().

This will help the unit test in the following commit to pass.
2020-04-16 09:22:11 +02:00
Matthew Leeds
e6b906f842 transaction: Add transaction_operation_get_related_to_op()
This will be used in the following commit, so we can track what
installed thing needs an update when there's a transaction operation to
e.g. install its missing runtime or extension.
2020-04-16 09:22:11 +02:00
Matthew Leeds
56071df5fb installation: Replace some debug statements
These were committed recently by accident; use g_debug() instead.
2020-04-16 09:22:11 +02:00
Jan Grulich
f3c0d3e87f CUPS socket: do not print error when we found CUPS server 2020-04-16 08:54:44 +02:00