Commit Graph

1231 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Ryan Gonzalez
71fcf99b2e remote-delete: Manually delete origin remotes if no refs were removed
There are a few cases where -origin remotes don't get removed when
their refs are uninstalled, most notably when xa.noenumerate is set, or
somehow the uninstall gets interrupted at the wrong time. Regardless
of the reason, the remote could never be removed after this, unless a
new ref is installed from it and then removed, or noenumerate is set.

Closes: #2920

Closes: #2953
Approved by: alexlarsson
2019-06-12 07:07:30 +00:00
Ryan Gonzalez
7222a83678 build-init: Export an extension's runtime in the metadata
Without this, extensions cannot use extra-data, as there is no
indication of what runtime to run apply_extra in.

Closes: #2954
Approved by: alexlarsson
2019-06-12 06:23:07 +00:00
Ryan Gonzalez
cd231503f2 app: Avoid a potential segfault when skipping columns
Closes: #2942
Approved by: mwleeds
2019-06-07 03:48:33 +00:00
Ryan Gonzalez
6cfd399c45 app: Fix a typo
Closes: #2942
Approved by: mwleeds
2019-06-07 03:48:33 +00:00
Matthew Leeds
3af605dd39 app: Don't show arch column if it's not interesting
Flatpak already doesn't show the architecture column in the output of
"flatpak list" if every flatpak has the same architecture. This commit
does the same for the table printed for install/update/uninstall
operations, except if the user specifies an arch on the command line.

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

Closes: #2930
Approved by: matthiasclasen
2019-05-30 12:12:12 +00:00
Valentin David
8d82a3e5f7 app/flatpak-builtins-build-commit-from.c: Recalculate download-size metadata
Download size of object depends on the compression used in the ostree
repository.  When a different source repository is specified, download
size might change.  So this metadata needs to be recalculated.

This issue happens with Freedesktop SDK which for build time
optimization reason run an intermediate build-export on a bare
repository.

See issue https://gitlab.com/freedesktop-sdk/freedesktop-sdk/issues/787

Closes: #2925
Approved by: alexlarsson
2019-05-28 12:46:13 +00:00
Matthew Leeds
c0d5f1bfc8 Add FLATPAK_ERROR_REF_NOT_FOUND
This adds a new error to FlatpakError and uses it everywhere a ref is not
found, either locally or in a remote. This should hopefully be more useful than
the status quo of either returning FLATPAK_ERROR_INVALID_DATA or
G_IO_ERROR_NOT_FOUND or something else. Technically this is an API break but it
seems worth the risk. I checked gnome-software which does not seem affected by
this, and I checked eos-updater which does check for G_IO_ERROR_NOT_FOUND in
one place that will be affected by this but we can patch that.

Closes: #2895
Approved by: matthiasclasen
2019-05-13 10:57:11 +00:00
Matthew Leeds
253fcc6e35 Made wider use of flatpak_repo_resolve_rev()
As described in the last commit message, it makes sense to move toward
using flatpak_repo_resolve_rev() rather than ostree_repo_resolve_rev()
for a few reasons:
1) It means we can use OSTREE_REPO_PULL_FLAGS_MIRROR which causes refs
to be pulled into repo/refs/mirrors/ rather than repo/refs/remotes/
which fixes a few edge cases of using collection IDs[1]
2) It falls back to using ostree_repo_resolve_rev() if
ostree_repo_resolve_collection_ref() fails so we can maintain backwards
compatibility for repo/refs/remotes/
3) It distinguishes between remote and local refs, and in the local case
uses OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY and
ostree_repo_resolve_rev_ext() to make sure we don't for example
accidentally use a remote's repo metadata rather than the local repo's
metadata for the "flatpak repo" command.

So this commit changes every instance of ostree_repo_resolve_rev() in
the codebase to flatpak_repo_resolve_rev().

[1] https://github.com/flatpak/flatpak/issues/1832

Closes: #2705
Approved by: alexlarsson
2019-05-09 09:12:26 +00:00
Alexander Larsson
4ef72ab991 remote-add: Don't fail if metadata updates fail, just warn
This typically happens when the network is offline or in some weird
state.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
11c439cee2 Port flatpak remote-add to use flatpak_parse_repofile
We shouldn't be parsing this in two places in the code.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
1d49053e62 remote-add: Don't set xxx-is-set if the option comes from a flatpakrepo file
This is meant to mean that the user explicitly overrided it, and
that is not right for a flatpakrepo file.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
43aeb2499a flatpak remote-add: Special case if-not-exist to clear filter
If you're adding a remote with --if-not-exists and it exists,
apply the filter key anyway. Typically this is used to allow a
user to use the standard instructions to add a remote even if there
is a pre-existing filtered remote already configured.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
40cc39ebf6 add-remote: Support loading filter from .flatpakrepo file
This is kind of special as it handles non-existing filter keys
as "override to no filters" instead of "leave existing filters" whic
we do for other things. However, that matches how we want to use
.flatpakrepo files to override site-local filters.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
2bd55552b6 flatpak remote-modify add --filter and --no-filter options
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
9454e2d65e flatpak remote-add add --filter option
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
72a7f8aa4e flatpak remotes - show filter in list
There is an optional filter column, and a flag for filtered remotes in the
default options.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Simon McVittie
62629b44b8 app, common: Use glnx_readlinkat_malloc()
readlink() and readlinkat() have weird semantics (they return the
number of bytes they would have written if there was enough space,
even if that's larger than the buffer), but glnx_readlinkat_malloc()
takes care to do the right thing in all situations.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2873
Approved by: matthiasclasen
2019-05-01 16:39:18 +00:00
Matthias Clasen
5020790f53 Suppress debug output when completing
Any log output interferes with comletion.
We already refrain from installing our verbose
log handlers in this case, but we are still
vulnerable to GLib default message handling,
e.g. via the G_MESSAGES_DEBUG environment
variable. To avoid that, explicitly install
a message handler that suppresses all output.

Closes: https://github.com/flatpak/flatpak/issues/2860

Closes: #2862
Approved by: alexlarsson
2019-04-29 13:40:44 +00:00
Alexander Larsson
0a66707b00 remote-ls: Add --cached option
This prefers cached data, even if stale.

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
8057de20a8 remote-info: Add --cached support
This prefers any cached data if available, even if its stale.

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
6088c7d0a1 dir: Add support for getting remote state using only caches
If only_cached is TRUE we never do any network i/o, instead
returning ERROR_NOT_CACHED if this is necessary.

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
131ba30ea9 cli: Drop unnecessary "something failed" message with --noninteractive
We reported the error already, just report the exit status.

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00
Alexander Larsson
e3db7a4461 cli: Make FLATPAK_ERROR_ABORTED return a failed exit code.
We now return a NULL error meaning nothing is printed as before
but a FALSE result which means the exist code marks the failure.

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00
Alexander Larsson
7eb6467e4d main: Allow flatpak_run() to fail with NULL error
This is very useful for the CLI where you want to fail the operation and
return a failure exit code, but the user actively chose to do so on
a prompt, so you don't need to print out anything.

Semantics are: if return FALSE => print error if non-null, then exit
with failure code.

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00
Alexander Larsson
c3f2fe3279 install/update: --noninteractive implies --yes
This mostly worked because QuietTransaction doesn't ask anything, but
some early checks in the commands itself only checked opt_yes.

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00
Alexander Larsson
e1f45a3878 Fix install --noninteractive not reporting errors
We need to handle operation_error and report errors, and for
fatal errors remember this and report a failure in run(), because
otherwise it returns ABORTED, which is treated as a failure (because
generally that meant the user chose "no" on some question).

Fixes #2839, #2757

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00