Commit Graph

5200 Commits

Author SHA1 Message Date
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
Alexander Larsson
84e7b19683 revokefs: Fix off-by-one array size in fuse implementation
The iovec write_vecs[] array on the stack was just 2 element, but we
sometimes use 3 elements of it. This was causing random crashes due to
corrupting the stack.

Closes: #3110
Approved by: alexlarsson
2019-09-18 07:17:43 +00:00
Matthew Leeds
13279af129 Merge pull request #3058 from mazen-asef/add_default_languages_key
Add extra-languages config key
2019-09-13 13:19:08 -07:00
Mazen Asef
a0666034db app: Add new extra-languages key
If xa.languages is set, use these, and no others. Otherwise, take the union
of xa.extra-languages, and the system default locales for system repos;
xa.extra-languages for user repo and the langs based on the user's locale

Fixes https://github.com/flatpak/flatpak/issues/3043
2019-09-13 15:31:14 -03:00
Matthew Leeds
07ab6e3a7a tests: Fix whitespace and typo errors
Closes: #3065
Approved by: alexlarsson
2019-09-13 08:31:41 +00:00
Matthew Leeds
af4504c8d3 dir: Ignore trailing slash in remote URIs
Currently if you have a remote configured with the URL
"https://dl.flathub.org/repo/" (as you would if you use the flatpakrepo
file) and you use a flatpakref file which specifies the URL
"https://dl.flathub.org/repo", Flatpak tries to add a duplicate remote
because it doesn't see those URLs as equal. So ignore the trailing slash
when comparing remote URLs. OSTree works equally well with both kinds
(it uses g_build_filename()).

Flathub served flatpakref files with URLs missing a trailing slash until
this commit:
https://github.com/flathub/ansible-playbook/commit/b20694f09

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

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

Closes: #3065
Approved by: alexlarsson
2019-09-13 08:31:41 +00:00
Matthew Leeds
c804042df4 dir: Match prefix when looking for extensions
When looking for deployed extensions, use the same prefix as when
looking for extension refs. E.g. look for refs that start with
"io.github.Hexchat.Plugin." rather than "io.github.Hexchat.Plugin".

This is a follow-up to https://github.com/flatpak/flatpak/pull/3067#discussion_r322173197

Closes: #3092
Approved by: alexlarsson
2019-09-13 07:40:02 +00:00
Matthew Leeds
ea19e4e5a7 flatpak-remote: Enforce GPG verification when a collection ID is set
Currently the "test_remote()" test calls
flatpak_remote_set_gpg_verify (remote, FALSE) and disables GPG
verification on a remote while a collection ID is set on it, which
should not be possible. The remote-add command enforces that GPG
verification is used if a collection ID is set, but the library API does
not. This commit changes libflatpak to return an error when such an
invalidly configured remote is being committed to disk. Also, update the
unit test to check for the newly added error, and to unset the
collection ID before disabling GPG verification.

Later in the unit test, GPG verification is re-enabled on the remote,
but libflatpak erroneously sets gpg-verify-summary=true in addition to
gpg-verify=true (summary verification is supposed to be disabled when
collections are used, but the library doesn't notice the mistake since a
collection ID isn't set in the same transaction and was already set).

This fix addresses both issues.

Closes: #3095
Approved by: alexlarsson
2019-09-13 07:21:15 +00:00
Matthew Leeds
c474c941c0 doc/flatpak-metadata: Fix a couple typos
Closes: #3096
Approved by: alexlarsson
2019-09-13 07:18:05 +00:00
Alexander Larsson
e4b1d16b7d Handle 'versions' key when finding local related ref
We were only handling the old single-value 'version' key, even though
we handled the 'versions' key when finding remote related refs.

The result of this was that some extensions, such as the 19.08 opengl
default one was installed by default (as it was found as remote related)
yet still removed with --unused (as it was not locally related).

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

Closes: #3093
Approved by: mwleeds
2019-09-10 20:23:16 +00:00
Alexander Larsson
ca72dd5474 Fix leak in flatpak_dir_find_remote_related_for_metadata
This puts the checksum autoptr in the inner scope of the loop where
it gets assigned to avoid leaking all but the last iteration value.

Closes: #3093
Approved by: mwleeds
2019-09-10 20:23:16 +00:00
Matthew Leeds
e2752abf28 tests: Add a test for uninstall --unused
Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:34 +00:00
Matthew Leeds
b3d77bec69 common: Make uninstalls robust to a missing remote
Currently if you delete a remote when it still has installed apps (using
--force), you're then unable to uninstall those orphaned apps (or
runtimes). This commit makes the uninstall operation succeed despite the
missing remote. Since we don't need a FlatpakRemoteState for an
uninstall operation, just avoid calling flatpak_ensure_remote_state().
Also, do some refactoring in flatpak_transaction_real_run() that should
improve readability and allows us to add a g_return_val_if_fail() in the
helper function, which ensures that only uninstall operations are
allowed to not have remote state.

This also includes a unit test for uninstalling with a missing remote.

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

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Matthew Leeds
bde4c9ae19 Make finding related refs tolerant of missing refs
This is similar to the last commit in that it's making
flatpak_dir_find_local_related_for_metadata() tolerant of a condition
that happens in the wake of the user running "flatpak remote-delete
--force ...". Since that command deletes refs tied to the remote being
deleted but leaves behind installed apps/runtimes, and
find_local_related_for_metadata() uses flatpak_repo_resolve_rev() to
check for extensions' existence, it misses any that are associated with
a deleted remote.

The effect of this is that if I run "flatpak remote-delete --force
kdeapps" followed by "flatpak uninstall org.kde.okular", org.kde.okular
is removed but org.kde.okular.Locale is left behind.

So this commit makes find_local_related_for_metadata() check for a
deploy of each extension if it can't find its ref, and finding either
one is reason enough to return it to the caller (which for an uninstall
operation means it will be deleted). We can't just check for the deploy,
because as evidenced by the "deployed" argument of
flatpak_dir_find_local_related(), the ref in question is not always
deployed (which presumably means the extension can't be expected to be
deployed either).

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Matthew Leeds
4b4211f18b Make finding related refs tolerant of missing remotes
As a step toward the goal of making uninstalls work when the
corresponding remote is missing, this commit makes
flatpak_dir_find_local_related_for_metadata() tolerant of the specified
remote being missing. To do this we get the collection ID from the
commit metadata rather than the remote config, which is more robust
anyway since in some cases the commit's collection may not match that of
the remote (see https://github.com/flatpak/flatpak/issues/1477).

This commit also changes the call sites of
flatpak_dir_find_local_related_for_metadata() so they pass in the commit
to be used, which means resolving transaction operations to a commit
even for uninstall operations (just the current installed commit).

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Matthew Leeds
3706695fb3 common: Fix misordering of branch and arch arguments
flatpak_dir_collect_deployed_refs() has the order of its "branch" and "arch"
arguments wrong, as does its only caller flatpak_list_deployed_refs().
When flatpak_list_deployed_refs() is called by add_extension() the arch
is put in the branch argument and vice versa. But then in the
implementation the arch is used as if it's the branch and vice versa, so
there's no functional bug here. Fix the order for readability.

Similarly, flatpak_list_unmaintained_refs() has the order wrong, but the
confusion is only within that function, since the order is correct in
its caller add_extension() and in the function it uses,
flatpak_dir_collect_unmaintained_refs(). So there's no functional bug
there either, but fix the order.

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Matthew Leeds
20c9d8477d app: Fix a use-after-free in flatpak_find_installed_pref()
Currently "flatpak --installation=default info ..." leads to an
assertion failure:

$ flatpak --installation=default info us.zoom.Zoom

(flatpak info:24593): GLib-GObject-CRITICAL **: 10:01:36.040: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

This is because in flatpak_find_installed_pref(), we set "dir =
installation_dir" but then installation_dir is freed by g_autoptr before
we try to return dir.

Fix the problem by stealing the pointer, and doing the same for the
other places dir is set.

Closes: #3077
Approved by: alexlarsson
2019-09-09 10:01:15 +00:00
Matthew Leeds
f88a9d9585 Use defined macro SYSTEM_DIR_DEFAULT_ID more
Just replace hardcoded strings with the macro, no functional change.

Closes: #3077
Approved by: alexlarsson
2019-09-09 10:01:15 +00:00
Matthew Leeds
1a5306360d dir: Construct default FlatpakDir with correct id
Currently the FlatpakDir object for the default system installation is
constructed differently depending on where the construction is
happening. In flatpak_dir_get_system_default() it's created with a NULL
DirExtraData object which means flatpak_dir_get_id() returns NULL when
called on it. But if constructed in
flatpak_get_system_base_dir_locations(), the FlatpakDir object gets a
DirExtraData object with the default values, including the id "default",
so flatpak_dir_get_id() returns "default" for it.

This commit changes flatpak_dir_get_system_default() so it constructs
the default object consistently with the other construction. This means
that in the places where the dir id is compared to "default" that check
will work correctly. Practically this means for CLI transactions the
"Proceed with these changes?" prompt will say "the system installation"
rather than "the Default system installation".

Also change flatpak_dir_get_system_by_id() so it returns the default dir
when id == "default", but continue to also return it if id == NULL. This
means the --installation=default CLI option will work correctly, but we
can avoid breaking any software that might currently be calling
flatpak_installation_new_system_with_id() with a NULL id.

And finally change flatpak_dir_get_display_name() so it continues to
return "Default system installation" for the default system
installation.

Closes: #3077
Approved by: alexlarsson
2019-09-09 10:01:15 +00:00
Alexander Larsson
aafa084bd2 CI: Install dbus-daemon rpm
Closes: #3088
Approved by: alexlarsson
2019-09-09 09:49:46 +00:00
Matthew Leeds
f5cf3e264c ci/libbuild.sh: Fix fedora release package issues
Attempt to fix the CI failure when running "yum -y install
@buildsys-build". This is copied from
https://github.com/ostreedev/ostree/commit/d85366d52

Closes: #3088
Approved by: alexlarsson
2019-09-09 09:49:46 +00:00
Matthew Leeds
cd978857bc .papr.yml: Update to Fedora 30
We need at least GLib 2.60.1 for this PR:
https://github.com/flatpak/flatpak/pull/2797

Don't update the host distro for the docker run, since F30 Atomic
doesn't exist yet. That's fine though, since the F30 container is
available.

Closes: #3088
Approved by: alexlarsson
2019-09-09 09:49:46 +00:00
Alexander Larsson
9ec61ae328 tests: Add tests for oci registries using labels instead of annotations
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
52e20d4a59 OCI: Handle NULL when marshalling manifest string maps
This was happening for the org.opencontainers.image.ref.name annotation
when we're in labels mode, but might as well be handled in a generic
way.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
618c38245f OCI: Don't crash on mirroring an OCI repo without annotations
If we're using labels the annotations hashtable may be NULL, which
was causing a crash. Just do an early check.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
51fe0307ef OCI: Handle manifests without annotations in index.json
When we export a manifest to the index, always pass the ref we're
targeting instead of relying on the org.opencontainers.image.ref.name
annotation, because that may not be set if we're using labels instead.

This is no big deal, because we know what ref we're handling anyway.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
6bff2fb19b OCI: Make use of labels or annotations configurable
If repo uri has ?index=label then query for labels, otherwise
keep querying for annotations like before.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8f4082df6d build-bundle: Add --oci-use-labels switch
This allows the user to pick at runtime whether to use
annotations or labels as OCI metadata carrier. For historical
reasons annotations is the default, but some registries don't
support this and then you can use labels instead.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
58d9a257aa OCI: Use labels as commit metadata source as well as annotations
We now pull the image config as well as the manifest and fall
back on the labels field if the keys we're looking for are not
in the annotations field.

This lets us support docker manifests too, which don't have
annotations (but do have labels).

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00