2086 Commits

Author SHA1 Message Date
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
Alexander Larsson
a3a2dcb2c5 decomposed: Remove _decomposed prefix on functions
We now converted most of these and removed the non-prefixed functions,
so rename them back.
2020-11-10 14:32:13 +01:00
Alexander Larsson
c14486f935 Use decomposed in flatpak_summary_match_subrefs() 2020-11-10 14:32:13 +01:00
Alexander Larsson
109cac60f6 decomposed: Store a FlatpakDecomposed in FlatpakRelated 2020-11-10 14:32:13 +01:00
Alexander Larsson
59509fd82d Add flatpak_decomposed_id_has_prefix() 2020-11-10 14:32:13 +01:00
Alexander Larsson
38a0706e76 decomposed: Return decomposed from find_installed_pref/ref 2020-11-10 14:32:13 +01:00
Alexander Larsson
97767f1a69 decomposed: Pass decomposed to flatpak_dir_deploy_install/update 2020-11-10 14:32:13 +01:00
Alexander Larsson
28f1ce3d62 Remove unused (non-decomposed) flatpak_dir_list_refs 2020-11-10 14:32:13 +01:00
Alexander Larsson
1402128f22 decomposed: Convert flatpak_dir_deploy() to take decomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
7e40dbfb74 Convert flatpak_dir_deploy() to use FlatpakDecomposed 2020-11-10 14:32:13 +01:00
Alexander Larsson
e98376bdf1 decomposed: Add flatpak_decomposed_equal_except_branch ()
This is used in flatpak_dir_deploy()
2020-11-10 14:32:13 +01:00
Alexander Larsson
6897b8e2ff decomposed: Take decomposed arg in flatpak_dir_load_deployed()
Then convert all callers
2020-11-10 14:32:13 +01:00
Alexander Larsson
5a858230dd decomposed: Add flatpak_decomposed_get_kind_metadata_group()
This is a useful helper.
2020-11-10 14:32:13 +01:00
Alexander Larsson
3b7f31350e dir: Use FlatpakDecomposed in apply_extra_data()
Just replaces flatpak_decompose_ref + GStrv
2020-11-10 14:32:13 +01:00
Alexander Larsson
5ea43736d9 flatpak_dir_list_refs_decomposed: Support kinds as a flag
This lets you get both apps and runtimes in one call.
2020-11-10 14:32:13 +01:00