Commit Graph

5228 Commits

Author SHA1 Message Date
Alexander Larsson
c15c1946ff test: Add test for update-portal monitoring
We add socat to the test runtime, and then we use that to run a
test app outside the sandbox as if it was inside.

The testcase connects creates a monitor and ensure we properly get signals
for updates.
2019-10-02 14:57:11 +02:00
Alexander Larsson
82328bee85 portal: Add option for poll frequency
We want to use these to get a quick turnaround in the tests.
2019-10-02 14:57:11 +02:00
Alexander Larsson
a4b2068bbc portal: Support application self-updates
This allows an application to request it to be updated to the latest version.

The updates are done out-of-process by re-spawning the portal (via
/proc/self/exe) and proxying the relevant events over a socket pair, in
order to avoid any long term stability or memory requirements from
running the update operation.
2019-10-02 14:57:11 +02:00
Alexander Larsson
e719463adf Bump the version of the flatpak portal interface to 2
Also mention this in the create monitor docs.
2019-10-02 14:57:11 +02:00
Matthias Clasen
fe0b8aa860 portal: Add updates monitoring
Add update monitoring to the flatpak portal.
No support yet for triggering updates.
2019-10-02 14:57:11 +02:00
Matthias Clasen
8ca4addc73 Find portal implementations properly
Share the portal implementation loading code
from xdg-desktop-portal, so we can select the
Access backend propertly.
2019-10-02 14:57:11 +02:00
Alexander Larsson
ae574f2a14 dir: flatpak_dir_get_by_path()
This automatically picks up whether the path is a system or user installation.
We'll need this in the update portal.
2019-10-02 14:57:11 +02:00
Alexander Larsson
32ec943adf CI: Store individual test logs also on failure (not just cancel)
This way we can get more detail on the failed test.
2019-10-02 14:57:11 +02:00
Alexander Larsson
93c314d46b CI: Install socat 2019-10-02 14:57:11 +02:00
Alexander Larsson
8ab48d5198 tests: Fix whitespace in makefile 2019-10-02 14:57:11 +02:00
Alexander Larsson
8832e7c7d1 Make test output a bit less noicy
This gets rid of some unnecessary spew that happens in every
test run and just makes the logs harder to read.
2019-10-02 14:57:11 +02:00
Matthias Clasen
ea8ecdbeb9 eol: Use the right ref in the confirmation message
We were using the old ref here, instead of the new
one, when asking whether to go ahead.

Closes: https://github.com/flatpak/flatpak/issues/3139
2019-10-02 14:56:44 +02:00
Alexander Larsson
b3272f156c Update: Don't update an extension if it is an extension and the base is masked
For example, if org.the.App or org.the.Platform is masked that means
we don't want to get any updates to it. Its very likely that we also
don't want updates to extensions of this app or runtime. For example,
we definately don't want to update the .Locale or .Debug extensions.
2019-10-02 11:18:02 +02:00
Alexander Larsson
84eb154e83 Track extension-of in deploy data
This tracks for installed apps if they are extensions of some
ref. This will be useful later to avoid updating extensions of
masked apps.
2019-10-02 11:18:02 +02:00
Alexander Larsson
d91660fe2a Work around deadlocks in g_spawn by manually clo-exec:ing fds
As per https://gitlab.gnome.org/GNOME/glib/merge_requests/490
there is a bug in glib < 2.60 where g_spawn_* can sometimes deadlock
due to using malloc in the child func to close fds.

We work around this in places where the code is (potentially) threaded
by passing glib flags to leave fds alone and then do a very naive
(but safe) fd cloexec loop ourselves.
2019-09-30 12:15:36 +02:00
Alexander Larsson
9c715096aa man: Reference flatpak-mask.1 from flatpak.1 2019-09-30 10:52:06 +02:00
Alexander Larsson
02b542789a Add manpage for flatpak mask 2019-09-30 10:52:06 +02:00
Alexander Larsson
178845d6d6 mask: Support masking of updates
In addition to just masking auto-downloads, masking now also means
pinning of the currently installed version of an already installed ref.
2019-09-30 10:52:06 +02:00
Alexander Larsson
2c7fab39b0 Add flatpak_dir_ref_is_masked helper 2019-09-30 10:52:06 +02:00
Alexander Larsson
f9fad17b51 Add flatpak mask command
This commands lets you selectively disable auto-download of extensions
based on patterns. With this we can have extensions that install
by default, yet still allow the user to not have them re-installed
each time flatpak update is run.

This fixes https://github.com/flatpak/flatpak/issues/3090
2019-09-30 10:52:06 +02:00
Alexander Larsson
9f6fc5591c common: Export glob_to_regexp util and make it handle empty parts as *
This means you can use "org.foo.bar//stable" instead of "org.foo.bar/*/stable"
which is similar to what other APIs do.

We want to use this for masking extensions too, thus the export.
2019-09-30 10:52:06 +02:00
David Hewitt
c601a808a8 transaction: Annotate enums with their type
This allows the introspection data to be generated with the correct type for each of these properties, instead of just `int`. This should improve the quality of the documentation as well as bindings generated from the introspection data.
2019-09-30 10:22:26 +02:00
Alexander Larsson
161a13951b Add flatpak install --or-update operation
This allows you to ensure that a particular app/runtime is installed
and with the latest version in a single operation, which is useful
for instance in automatic use, like CI systems.
2019-09-27 09:07:13 +02:00
Matthew Leeds
593f0e563b doc/flatpak-create-usb: Clarify how to install from USB 2019-09-27 08:53:04 +02:00
Matthew Leeds
584a531a58 Merge pull request #3135 from wjt/3134-NULL-dereference-in-list_installed_refs_for_update
installation: don't dereference possibly-NULL array
2019-09-26 10:17:57 -07:00
Will Thompson
a732de2a28 installation: don't dereference possibly-NULL array
If the installation contains 1 or more installed refs, but none of those
refs have a remote with a collection ID, then 'results' will be NULL but
'installed' will be non-NULL. Since
c29e686246, 'results[0]' is used in this
situation – a NULL pointer dereference. There is an existing 'results !=
NULL' check inside the body of this loop, but this is too late.

Check whether 'results' is NULL before dereferencing it.

Fixes #3134.
2019-09-26 08:47:47 -07:00
Alexander Larsson
aaac533ca4 Add action that checks for autosquash commits in pull requests
We want to block merging for these, to ensure that you autosquash
before merging.

Ideally we'd like automatic (or at least via a bot) autosquashing, but
that is not currently possible.
2019-09-26 13:00:22 +02:00
Alexander Larsson
a046843fea Trigger CI on pull_request too
But, only to a limited subset of branches
2019-09-25 16:43:50 +02:00
Alexander Larsson
266e12e432 Use github actions for CI 2019-09-25 13:07:46 +02:00
Matthias Clasen
bbd4bedecc Take char width into account for formatting
When formatting text for terminal output, take
character width into account.

Fixes https://github.com/flatpak/flatpak/issues/2910

Closes: #3124
Approved by: alexlarsson
2019-09-23 08:39:49 +00:00
Kukuh Syafaat
1f7cbf2c4a Update Indonesian translation
Closes: #3125
Approved by: matthiasclasen
2019-09-21 14:32:30 +00:00
Matthew Leeds
96822b21e5 dir: Fix a typo in a comment 2019-09-20 13:02:06 -07:00
Alexander Larsson
0a3963b479 Only define GLIB_VERSION_MIN_REQUIRED if we detect a new glib
Otherwise the build failed on older glib version, but with this setup
we still disable all the GTimeVal deprecation warnings.

Closes: #3122
Approved by: alexlarsson
2019-09-20 13:58:46 +00:00
Alexander Larsson
a641bb76b2 Don't use deprecated g_type_class_add_private API
Instead use G_DEFINE_TYPE_WITH_PRIVATE like we do in other places already.

Closes: #3119
Approved by: alexlarsson
2019-09-19 16:53:11 +00:00
Alexander Larsson
8e9e134446 configure: Fix detection of archive_read_support_filter_all
This got broken with the dependency split-outs.

Closes: #3119
Approved by: alexlarsson
2019-09-19 16:53:11 +00:00
Alexander Larsson
8227224c84 Ignore glib deprecations past 2.60
We generally want to avoid using deprecated stuff as much as we
can, while still depending on an old glib version. However, the GTimeVal
deprecation in 2.62 just is impossible to work around without bumping
the requirements, so ignore newer deprecations.

Closes: #3119
Approved by: alexlarsson
2019-09-19 16:53:11 +00:00
Alexander Larsson
c719710907 tests: Some cosmetic fixes for the version check test
Closes: #3118
Approved by: alexlarsson
2019-09-19 16:17:34 +00:00
Philip Withnall
5236608d86 tests: Fix a warning about ignoring the return value of symlink()
Assert it was successful instead. This is probably pointless from the
point of view of testing things (why would symlink() ever realistically
fail but everything else succeed?), but it does shut up a compiler
warning, which gives us a better chance to spot legitimate warnings in
future.

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

Closes: #3116
Approved by: alexlarsson
2019-09-19 15:51:11 +00:00
Matthew Leeds
d647bc105e installation: Make fetching remote refs work offline
Currently flatpak_installation_fetch_remote_ref_sync() does not work
offline. It returns an error when it fails to fetch the remote's summary
in flatpak_dir_get_remote_state(). This is a problem since GNOME
Software (or at least the Endless fork) uses this library function to
display apps it finds on a USB drive (see gs_plugin_refine_item_origin()
in gs-flatpak.c) and that's something that should work even offline.

So this commit changes flatpak_dir_get_remote_state_optional() so that
it accepts the only_cached option, and updates the call sites. Also have
fetch_remote_ref_sync() use flatpak_dir_get_remote_state_optional(),
which means that when we're offline we will use the xa.cache data in the
ostree-metadata ref as a list of refs list instead of using a summary.
However since the commit checksums are not in xa.cache, we don't have
enough information to form a FlatpakRemoteRef. So also call
ostree_repo_find_remotes_async() to get the commit from any LAN or USB
sources that may be available. This may not be very performant but at
least it only happens if the ref wasn't found in a remote summary; see
https://github.com/flatpak/flatpak/issues/1862

It's sad this code is so long-winded but it's difficult to break out a
helper function that could be shared with
list_remotes_for_configured_remote() above. Longer term we could improve
the ostree_repo_find_remotes_async() API and add options to remove the
need to manually handle OstreeRepoFinder objects.

Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
ed766dc6db installation: Don't try to stop a NULL OstreeRepoFinderAvahi
Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
5c9da49cf8 installation: Remove an unused variable
Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
989b18bba8 Set a collection ID on FlatpakInstalledRef objects
Currently FlatpakInstalledRef objects are constructed without the
collection-id property set. This is a problem because in the USB app
update support in the Endless fork of GNOME Software, when we find a
FlatpakRemoteRef on a USB drive which matches the ref of a
FlatpakInstalledRef object, the collection IDs of the two objects must
also match, and currently the installed one has a NULL collection ID.

So get the collection ID on the relevant configured remote when
constructing a FlatpakInstalledRef. This should be good enough in most
cases but isn't perfect; see
https://github.com/flatpak/flatpak/issues/3103

Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
9c3b42d67e testlibrary: Fix type for FlatpakTransaction::add-new-remote @reason
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
f374a80ed7 testlibrary: Fix a typo in a URL
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
e048dde8e7 installation: Fix a couple typos in docs
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
c29e686246 installation: Don't return an error checking for updates offline
In commit b8a3075d8 I changed a few places to check if the array
returned by ostree_repo_find_remotes_finish() is empty, which would mean
either none of the configured remotes (or P2P sources) provide the
requested refs, or the one(s) that do are offline. That was mostly
correct but in the case of
flatpak_installation_list_installed_refs_for_update() we don't want to
treat empty results as an error, because otherwise GNOME Software prints
an error message when offline: "No remotes found which provide these
refs: ...".

So this commit makes list_installed_refs_for_update() return an empty
array in case it can't find any updates (we don't distinguish "remotes
checked and provide no updates" from "remotes couldn't be reached").
This matches the behavior of the non-P2P code: the for loop above which
handles remotes without collection IDs prints a debug message if an
error is encountered.

Also, add a unit test that fails without this patch.

Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthias Clasen
d346fa6b7e Avoid suggesting titles
The commands array contains entries that serve
just as section titles; avoid returning those
when looking for misspelt commands.

Pointed out in https://github.com/flatpak/flatpak/issues/3040

Closes: #3107
Approved by: matthiasclasen
2019-09-18 15:24:11 +00:00
Alexander Larsson
5026f01153 Support multiple versions in required-flatpak metadata key
Support a list of versions that are supported. This will be useful
for e.g. the extra_data for extensions once that is backported to
1.2, because that will require it to say that it is supported for
> 1.2.5 in the 1.2 series and > 1.4.2 otherwise.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Alexander Larsson
62117308c1 tests: Add test for required-flatpak versioning
This sets required-flatpak in the metadata to some different versions
and ensure we're properly able or not able to install it.

Additionally it uses some options with multiple versions. This is not
yet supported but I want to test the existing code and make sure it
properly falls back to just using the first element of the list.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Matthias Clasen
535e1a66b1 Include options in 'Did you mean...' suggestions
Suggest --help for 'flatpak help' and similar for
other options.

Suggested in https://github.com/flatpak/flatpak/issues/3040

Closes: #3106
Approved by: alexlarsson
2019-09-18 07:42:15 +00:00