Commit Graph

7164 Commits

Author SHA1 Message Date
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
Debarshi Ray
ebf5d08f47 build: Link against libarchive only when necessary
The libarchive 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
Yuri Chornoivan
de24b11390 Update Ukrainian translation
Closes: #3056
Approved by: alexlarsson
2019-08-15 20:24:44 +00:00
Owen W. Taylor
a794c07e18 OCI: correctly handle locally present icons
If the download URL for an icon was already cached locally, the HTTP
code returned FLATPAK_OCI_ERROR_NOT_CHANGED - this was treated as a real
error, and after downloading missing icons, all present icons were
deleted!

See https://bugzilla.redhat.com/show_bug.cgi?id=1683375

Closes: #3048
Approved by: alexlarsson
2019-08-15 20:04:18 +00:00
Matthew Leeds
5e65174e8d build-bundle: Fix resolving refs
Unfortunately in commit 253fcc6e3 I broke the build-bundle command so
that it is unable to resolve remote refs (as opposed to local ones).
This means in the normal case of building a bundle for an app installed
from a remote it fails:

$ flatpak build-bundle /var/lib/flatpak/repo gnome-calculator.flatpak org.gnome.Calculator stable
error: Refspec 'app/org.gnome.Calculator/x86_64/stable' not found

This is because flatpak_repo_resolve_rev() interprets a NULL remote name
to mean the ref is local (in refs/heads/) but in this case we just don't
know which remote it's from. This commit fixes the issue by using
ostree_repo_resolve_rev() directly which searches refs/heads/ and
refs/remotes/, and if that fails falling back to iterating over refs
returned by ostree_repo_list_collection_refs() to catch collection-refs
that may be in refs/mirrors/.

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

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

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Matthew Leeds
b44c1a5799 dir: Don't overzealously rewrite an error
It's an error to call g_set_error() on an error that's already set, and
flatpak_dir_get_deploy_data() already sets FLATPAK_ERROR_NOT_INSTALLED
for us when necessary, so just pass on any errors to the caller of
flatpak_dir_get_origin(). In the case that the error is something else,
that should be treated as an error, because we never expect the deploy
directory to exist but not have a deploy file (see the implementations
of flatpak_dir_deploy() and flatpak_dir_undeploy()).

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Matthew Leeds
9a258e8a0c common: Use correct flag for ostree_repo_resolve_rev_ext()
Use the correct NONE flag, although both are 0 so this change won't make
any functional difference.

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Matthew Leeds
f09049b7aa common: Fix branch validation docs
The docs for flatpak_is_valid_branch() say branch names can't start with
a digit but the implementation doesn't enforce this, and we have lots of
branches out in the wild that start with a digit (e.g. "3.32" and
"5.12"). So make the docs imply that branches can start with a digit.

The implementation also disallows "." as the leading character for a
branch, so add that to the docs. I'm just guessing that "." was intended
to be disallowed but it makes sense; otherwise the file we create named
with the branch would be hidden.

Closes: #3023
Approved by: alexlarsson
2019-08-15 09:07:14 +00:00
Philip Withnall
f80cce6b8d installation: Fix a small leak of a FlatpakCollectionRef
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #3031
Approved by: mwleeds
2019-08-03 05:03:23 +00:00
Andre Moreira Magalhaes
eaec3a8203 cli-transaction: Fix some leaks
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>

Closes: #3025
Approved by: matthiasclasen
2019-07-23 14:54:59 +00:00
Andre Moreira Magalhaes
37a7b6edfd transaction: Append bundle to correct list on flatpak_transaction_add_install_bundle()
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>

Closes: #3025
Approved by: matthiasclasen
2019-07-23 14:54:59 +00:00
Matthew Leeds
9a0e45941a doc/flatpak-kill: Add a hint about flatpak ps 2019-07-21 12:50:50 -07:00
Matthew Leeds
5edafefa4b doc/flatpak-enter: Make a few minor improvements 2019-07-21 12:45:58 -07:00
Simon McVittie
75b5b7c763 Don't register polkit agent if we cannot connect to system bus
This works around an old polkit client library bug which would cause
a segfault in this situation. The bug was fixed long ago in upstream
polkit, but is still present in Debian 10 'buster', Ubuntu 19.04 'disco'
and all older releases, due to Debian/Ubuntu using a branch of polkit
to avoid the mozjs dependency. It should finally get fixed in Debian 11
and Ubuntu 19.10.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug-Debian: https://bugs.debian.org/923046

Closes: #2997
Approved by: matthiasclasen
2019-07-11 18:11:21 +00:00
Matthew Leeds
f1b8a4275f transaction: Fix "Can't load dependent file" error
Make the error message translatable, and add ": " between the URL and
the rest of the error.

Closes: #3003
Approved by: mwleeds
2019-07-05 15:41:56 +00:00
Matthew Leeds
9928ce757f libtest.sh: Delete unreachable exit command 2019-07-02 16:12:42 -07:00
Matthew Leeds
4fd7d7d209 main: Handle double slashes in $XDG_DATA_DIRS
When checking for Flatpak directories in $XDG_DATA_DIRS, treat
/example//path/ as equivalent to /example/path/.

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

Closes: #2990
Approved by: alexlarsson
2019-06-28 08:44:41 +00:00
Matthew Leeds
4a9ba3b346 .papr.yml: Add back -fsanitize=address
Let's see if the crash still happens which was keeping us from adding
this flag.

Closes: #2991
Approved by: alexlarsson
2019-06-28 08:42:51 +00:00
Matthew Leeds
d8e6bf425f .papr.yml: Update to Fedora 29
Fedora 28 is end-of-life, and ostree is already on F29.

Closes: #2991
Approved by: alexlarsson
2019-06-28 08:42:51 +00:00