Commit Graph

5182 Commits

Author SHA1 Message Date
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
Alexander Larsson
8cdd3a5e61 OCI: Don't crash if mediaType field missing in flatpak_oci_versioned_from_json
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
79f5f13fec OCI: Add flatpak_oci_registry_load_image_config helper
We can't use load_versioned() for images because in the docker
case there is no mediatype field.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
45e31735f1 OCI: Accept docker v2 manifests as well as OCI manifests
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
37533ed315 OCI: Add docker v2 media type defines
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
3e1b701d5b oci: Query for org.flatpak.ref label instead of annotation
This is not compatible with the old stuff, but works with registries
that only support the docker manifest format.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
afd532bb8b oci: Allow reading metadata from labels too
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
be9961ecf6 oci: Always generate a history, quay needs this
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8416add254 Put annotations also in the labels
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
2303672458 oci: Add an easy api to set the labels in the image manifest
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
af96ceb9eb OCI: Break out the annotation generation code into a helper
This doesn't change the behaviour, it just breaks out everything related
to flatpak-specific annotations into one place where it can be resued.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Zander
89526100ce Add English (UK)
Closes: #3068
Approved by: mwleeds
2019-08-30 22:57:31 +00:00
Zander
dc930ce7f6 Add en_GB
Closes: #3068
Approved by: mwleeds
2019-08-30 22:57:31 +00:00
Bartłomiej Piotrowski
8f7c96f408 Default end-of-life-rebase prompt to yes
Closes: #3063
Approved by: mwleeds
2019-08-20 21:15:21 +00:00
Heiko Becker
1678d0cb9f Avoid installing empty dirs with --disable-selinux-module
...by moving everything selinux specific into the scope of the
if.
2019-08-16 12:53:52 +02:00
Philip Withnall
791f31898b flatpak-installation: Handle an unconfigured remote when listing remotes
This prevents a crash in flatpak_installation_list_remotes_by_type() if
the `FlatpakDir` can’t ensure it has a repo configured.

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

Closes: #3028
Approved by: alexlarsson
2019-08-16 09:33:18 +00:00
Debarshi Ray
e82efa8603 Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by
flatpak(1) or applications running as Flatpaks. It's also used by
toolbox(1) for similar reasons:
 * To keep various configuration files inside the container
   synchronized with the host
 * To let the container request certain commands to be run on the host

The org.freedesktop.Flatpak D-Bus service itself doesn't need much in
the way of dependencies, but inherits a lot of unused shared library
linkages through the libflatpak-common.la convenience library. Removing
these unused shared libraries reduces the footprint of toolbox(1) for
those who care about such things. eg., Fedora CoreOS.

This commit brings down the number of shared libraries to 19 from 62.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +00:00
Debarshi Ray
61d4316043 common, session-helper: Make the session helper more self-contained
... by moving the definition of FlatpakHostCommandFlags from the
'common' sub-directory to 'session-helper'. It hasn't been used by
anything else ever since flatpak-builder was moved to a separate
repository in commit 52bd146561.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +00:00
Debarshi Ray
cde7934041 build: Link against libxml only when necessary
The libxml API is used in a relatively few places inside the 'common'
sub-directory. It's definitely not as widespread as GLib. A subsequent
commit will leverage this to prevent unused shared libraries from
being linked to the session helper.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +00:00