2100 Commits

Author SHA1 Message Date
Alexander Larsson
ebf01791dc Download the new digested summary index sig if there
We still load the old one as a backup.
2020-12-22 13:49:59 +01:00
Alexander Larsson
f479c0f1a4 update-repo: Create an digested version of the summary index signature
In addition to the old summary.idx.sig we now create an identical file
in `summaries/$DIGEST.idx.sig`, where the digest is of the summary
index itself. This means it will have a unique name and there will
never be issues where downloading the index and signature will race
during an update.

We keep the new and the previous digested sigs every update to avoid
removing the previous one while its in use.

As suggested by simon in https://github.com/flatpak/flatpak/issues/3983
and https://github.com/ostreedev/ostree/issues/2250
2020-12-22 13:49:59 +01:00
Alexander Larsson
f87ffe26a8 Fix leak in upgrade_deploy_data() 2020-12-21 10:30:22 +01:00
Phaedrus Leeds
84f6e1c61f common: Upgrade deploy data when necessary
Now that we have version 4 of deploy data, upgrade to it before trying
to use any of the pieces of data it guarantees the presence of.
2020-12-21 10:30:22 +01:00
Phaedrus Leeds
9ab02b38bc Ensure deploy files have complete metadata
Currently if a deploy file was created (because a flatpak is installed)
using an old Flatpak version (such as 0.10.1 that's in Endless 3.3.16),
it will not include every metadata key, such as "eol" and "eolr". Those
keys were added before deploy version 1. Then when the deploy file is
upgraded to version 3, the metadata is only copied so eol/eolr are still
missing even though they exist in the commit metadata.

So this commit adds deploy version 4 which ensures all metadata keys in
the deploy file are present (when they are present in the source data).
All existing deploy files will be upgraded with this code.

This change is important because we use the end-of-life information to
decide whether an unused runtime should be uninstalled, so without this
change we are not freeing up disk space that we should be.
2020-12-21 10:30:22 +01:00
David Hewitt
d762a2f536 flatpak-dir: Allow root to bypass parental controls
In elementary OS, we're building our images with some flatpaks pre-installed. To do this, we run noninteractive `flatpak install` commands in the chroot as part of the build scripts. We've bumped into some build failures recently after switching to a version of flatpak with malcontent support built in.

After some debugging, it turns out installations are failing the parental controls checks with errors like `Failed to install org.gnome.Epiphany: Could not connect: No such file or directory` message. I'm assuming this is a failure to connect to the system bus in this method (since there isn't one in the chroot).

Is it reasonable to assume that UID 0 should be allowed to install whatever they want regardless of parental controls? I believe this would fix our issue too.
2020-12-21 09:46:31 +01:00
Phaedrus Leeds
c31dc54594 instance: Add missing nullable annotation 2020-12-21 09:11:08 +01:00
David Hewitt
e1c094be15 flatpak-transaction: Mark commit param on operation_done nullable 2020-12-21 09:09:51 +01:00
Corentin Noël
348ccb9565 flatpak-installed-ref: Add annotation to content rating table 2020-12-14 11:25:16 +01:00
Alexander Larsson
b3321e9179 extra-data: Resolve runtime from the target installation
When installing to an installation we need to find the runtime to use
for the apply-extra-data script from the installation we're targeting,
because that is the one that FlatpakTransaction guaranteed has the
required dependencies (although its possible they came from the
default dependency source too, i.e. the system repos).

In particular, we run into this issue if nothing is installed
anywhere, and then we install an extra-data app into a custom
directory. The transaction will download the runtime, and it
will not be anywhere else. Without this change flatpak only
looked for the dependency in the systam an regular user dirs
where it isn't.
2020-12-09 16:12:25 +01:00
Philip Withnall
a9f5c124c1 flatpak-installation: Add default dep sources to list installed refs
It seems that all `FlatpakTransaction`s add the default dep sources, so
the internal transaction used to list installed refs for updates should
do the same.

This fixes a bug where
`flatpak_installation_list_installed_refs_for_update()` would return an
error saying “The application x requires the runtime y which was not
found” if the app was installed in the user repo, the runtime was
installed in the system repo, and no remote was configured (or one was
configured `xa.noenumerate=true`) in the user repo to provide the
runtime. If a remote was configured, the error wouldn’t be returned, but
the app would be spuriously listed for an update as its runtime couldn’t
be found.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 09:05:13 +01:00
Simon McVittie
cc7f863707 common: Add a backport of G_DBUS_METHOD_INVOCATION_HANDLED
This is syntactic sugar added in GLib 2.67.0, which makes it more clearly
correct when we return TRUE after a GDBus error.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-12-09 08:34:19 +01:00
Alexander Larsson
97d1eb8478 Update common/flatpak-exports.c
Co-authored-by: Simon McVittie <smcv@debian.org>
2020-12-09 08:31:45 +01:00
Casey Jao
3aaea7d206 Expose /var/usrlocal if "--filesystem=host" is specified.
As /usr/local points to ../var/usrlocal on Silverblue,
/run/host/usr/local was previously a broken link inside the
sandbox. This patch checks if /var/usrlocal exists and bind-mounts it
to /run/host/var/usrlocal.

See bug #4010.
2020-12-09 08:31:45 +01:00
Alexander Larsson
a03c2739df Add back the ostree.commit.timestamp per-ref metadata for summary
The old summary had a ostree.commit.timestamp in the per-ref metadata
dict. However, since this was not used anymore by flatpak I removed it.
However, it turns out that flathub has infra that depends on this,
so I'm adding it back.

We reuse the data in the old summary for unchanged refs when
rebuilding the summary, to avoid having to read all the commits. In
the new world the new format summaries are used for this, which means
we have to keep the timestamp in that too. However, to not be
unnecessary large its now using a shorter key name, as this is
duplicated for each ref in the summary.
2020-11-20 15:20:15 +01:00
Alexander Larsson
ecda7757bb Fix multiarch support
A typo was causing us to pass the app id as arch, breaking (at least)
multiarch support.
2020-11-20 15:08:58 +01:00
Alexander Larsson
ea116809d1 remote-metadata-update: Don't clean caches if nothing changed
This was causing us to never cache the summary in user installations
2020-11-20 14:01:42 +01:00
Phaedrus Leeds
1f53e73bf3 dir: Fix spurious permission denied errors
Currently this error is happening on the eos3.9 dev branch of Endless
OS:

Nov 19 12:05:55 endless eos-updater-flatpak-installer[464]:
eos-updater-flatpak-installer: Couldn’t apply some flatpak update
actions for this boot: Error opening directory
'/root/.local/share/flatpak/app': Permission denied

The reason is that we have a check in flatpak_dir_list_unused_refs() to
check if the per-user installation exists and only try to list the refs
there if so, but the existence check falsely succeeds due to the systemd
sandboxing on eos-updater-flatpak-installer.service, and
flatpak_dir_list_refs() then fails in find_used_refs(). Specifically the
ProtectHome=yes systemd service option makes /root inaccessible, and due
to a bug in GLib[1] this makes g_file_query_exists() falsely return TRUE
for any paths under /root.

So, check for not found and permission denied errors rather than doing
an existence check, as we should be doing anyway to avoid a
time-of-check/time-of-use race, as explained in the
g_file_query_exists() documentation.

[1] https://gitlab.gnome.org/GNOME/glib/-/issues/1237
2020-11-20 09:16:57 +01:00
Alexander Larsson
09b470c0fd transaction: Add more details to the ABORTED error
This is reported when we reported an error to the user via
::operation-error signal and the app told us to not continue.

If this happens in some weird case and we see the results its nice
to have access to the original error message.
2020-11-19 18:31:40 +01:00
Alexander Larsson
f650c303e3 Don't auto-install sources for extensions
There was a bug in the extension point matcher which made it
install `org.gnome.Totem.Videosite.YouTubeDl.Sources` (in addition to
`org.gnome.Totem.Videosite.YouTubeDl`) for the `org.gnome.Totem.Videosite`
extension.

We just need to make sure we only match the extension prefix if there
is a single element in the extension name following the extension
name (i.e. '.YouTubeDl', not '.YouTubeDl.Sources').

This fixes https://github.com/flatpak/flatpak/issues/3973
2020-11-18 17:36:10 +01:00
Ludovico de Nittis
a17224cd08 context: do not use a cast to convert a pointer to an integer
Building with Clang 11 shows a warning for the cast of the 'gpointer' to
'FlatpakFilesystemMode'.
This is due to '-Wpointer-to-int-cast' being now enabled by default.

common/flatpak-context.c:2144:13: warning: cast to smaller integer type
'FlatpakFilesystemMode' from 'gpointer' (aka 'void *')
[-Wvoid-pointer-to-enum-cast]
fs_mode = (FlatpakFilesystemMode) g_hash_table_lookup (context->filesystems, "host");
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2020-11-16 11:24:38 +01:00
Alexander Larsson
39333fdb33 dir: Minor optimization to find_used_ref()
Its commonly the case that a runtime lists itself as its runtime and/or sdk.
So, short circuit this in the finding of used refs.
2020-11-16 11:23:10 +01:00
Alexander Larsson
8f07945e57 dir: Extract flatpak_dir_list_app_refs_with_runtime()
This was open-coded in flatpak_dir_uninstall(), and we want to reuse
it. So, extract to helper.
2020-11-16 11:23:10 +01:00
Alexander Larsson
7b1b706f80 decomposed: Add flatpak_decomposed_id_is_subref_of()
This checks if e.g. `org.app.App.Locale` is a subref of `org.app.App`.
2020-11-16 11:23:10 +01:00
Alexander Larsson
754e1fb5d4 Allow configuring the subset
This adds support to remote-add, remote-modify and the flatpakrepo file
parser.
2020-11-13 10:32:19 +01:00
Alexander Larsson
5496c4e4ef appstream: Pull the right branch if the remote has a subset configured 2020-11-13 10:32:19 +01:00
Alexander Larsson
3c60facb03 summary: Handle subset appstream branches
In the main summaries we drop all the subset appstream branches.
In the subset summaries we use the relevant appstream branch and drop
the normal ones.

We also leave out the old compat branch completely from the subset
summaries because it will just be used for newer flatpaks that support
the new format.
2020-11-13 10:32:19 +01:00
Alexander Larsson
4739fc147c Generate appstream branches for subsets
For all the subsets in the repo, create an appstream2/$subset-$arch branch
with the appstreams of the apps in that subset.
2020-11-13 10:32:19 +01:00
Alexander Larsson
9a7b33e4ed summary: Correctly extract the subset
We want to split $subset-$arch on the last dash, not the first,
because arch can't have dashes, while subset could.
2020-11-13 10:32:19 +01:00
Phaedrus Leeds
d406cf0ed7 installation: Include renamed apps when listing updates
Currently if an app has been renamed and you run "flatpak update" you
will be prompted to decide whether to install the new name of the app
(and uninstall the existing one). However, in such a situation
flatpak_installation_list_installed_refs_for_update() does not return
the app, and therefore gnome-software doesn't see any updates available
(except in the case where the installed commit is older than the commit
with the eol-rebase metadata).

So include end-of-life-rebased apps in the returned list. Patches to
make gnome-software update such apps properly are forthcoming.

I checked that the included unit test only passes with this patch to
libflatpak.
2020-11-11 09:00:39 +01:00
Alexander Larsson
d4dd663c88 flatpak-dir-private.h: re-indent function declarations 2020-11-10 14:32:13 +01:00
Alexander Larsson
7ab62ac3fb decomposed: Convert some more FlatpakDir apis to FlatpakDecomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
674cc1a60a decomposed: Convert more FlatpakDir APIs to use FlatpakDecomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
b111965640 decomposed: Convert flatpak_dir_read/set_active() 2020-11-10 14:32:13 +01:00
Alexander Larsson
3d29c6ee5c decomposed: Convert flatpak_load_deploy_data() to FlatpakDecomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
8a32656380 Remove unused flatpak_[de]compose_ref functions
We now all use the FlatpakDecompose versions.
2020-11-10 14:32:13 +01:00
Alexander Larsson
adb3b61f0a decomposed: Return FlatpakDecomposed from flatpak_dir_find_remote_ref() 2020-11-10 14:32:13 +01:00
Alexander Larsson
ed6ea2c97d decomposed: Remove last users of flatpak_compose_ref() 2020-11-10 14:32:13 +01:00
Alexander Larsson
f7593cd7b6 appstream: Use FlatpakDecomposed when generating 2020-11-10 14:32:13 +01:00
Alexander Larsson
1159004dc8 Add len argument to flatpak_decomposed_is_arches()
This allows this to be used both with strv (len=-1) and other arrays.
2020-11-10 14:32:13 +01:00
Alexander Larsson
b70151dabe dir: Don't crash in get_summary_for_ref() if arch has not non-compat arch 2020-11-10 14:32:13 +01:00
Alexander Larsson
c5b2c60609 decompose: Convert more FlatpakDir functions to use FlatpakDecomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
409fa1eafc decomposed: Use FlatpakDecomposed in flatpak_run_* 2020-11-10 14:32:13 +01:00
Alexander Larsson
e9806fac8b decomposed: Use decomposed in flatpak_ref_parse() 2020-11-10 14:32:13 +01:00
Alexander Larsson
48b11b3d3d lib: Add flatpak_transaction_operation_get_subpaths()
This returns the actual subpath that will be fetched during the operation,
not just what was passed in.

NOTE: We were previously doing the final resolve of this in the update
case during the pull operation, but this commit changes that to do it
up-front in order to be able to return the right value for this.
2020-11-10 14:32:13 +01:00
Alexander Larsson
f2cfd53bd1 transaction: Add private getter for the FlatpakDecomposed of the op 2020-11-10 14:32:13 +01:00
Alexander Larsson
3fd710b5f4 Remove some unused flatpak_dir_resolve_* functions
These are not used since we changed the p2p code a while ago.
2020-11-10 14:32:13 +01:00
Alexander Larsson
b6a1eb8d48 Delete some unused variables 2020-11-10 14:32:13 +01:00
Alexander Larsson
9b9c2f0a93 decomposed: Pass FlatpakDecomposed to find_*_related functions 2020-11-10 14:32:13 +01:00
Alexander Larsson
a988ee19d8 decompose: Use FlatpakDecomposed for bundles 2020-11-10 14:32:13 +01:00