Commit Graph

1534 Commits

Author SHA1 Message Date
Patrick
e110bf7c7f Merge branch 'main' into appstreamcli-compose 2023-01-07 18:48:28 -06:00
Phaedrus Leeds
523cedc275 trivial: Trim some long lines, etc. 2023-01-02 20:45:19 -06:00
Phaedrus Leeds
8ca1604a94 repair: Fix off-by-one error in fancy output
Fixes https://github.com/flatpak/flatpak/issues/5204
2023-01-02 20:45:19 -06:00
Simon McVittie
c2c034733e common: Make flatpak_debug2() use the same domain as g_debug()
Now that we are logging `flatpak -v` messages with log level INFO,
and printing INFO messages in the same way as DEBUG, we can reserve
log level DEBUG for `flatpak -v -v` messages. This means we no longer
need a weird secondary debug domain.

There is a very small behaviour change here: G_MESSAGES_DEBUG=flatpak
is now similar to `flatpak -v -v` (previously `flatpak -v`), and
G_MESSAGES_DEBUG=flatpak2 no longer has any effect. This seems more in
line with what would be expected from a GLib-based application.

In flatpak(1) and the system helper, this does not change behaviour
other than that: the same messages are logged by `-v` and by `-v -v`
as before.

In daemons that do not implement `-v -v` (the OCI authenticator, portal
and session helper), it continues to be necessary to use
G_MESSAGES_DEBUG to see flatpak_debug2() messages.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00:00
Simon McVittie
522a933bc9 app: Use g_info() for messages that will be shown by flatpak -v
This brings us one step closer to being able to stop using the flatpak2
log domain for messages that are exclusive to `flatpak -v -v`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00:00
Simon McVittie
ac4e322629 main: Treat g_info() as equivalent to g_debug()
This makes us consistent with the default behaviour of GLib, and
its behaviour with G_MESSAGES_DEBUG=all. g_debug() and g_info() are
the two lowest priority levels, and GLib normally silences them by
default.

At the moment, Flatpak uses G_LOG_LEVEL_DEBUG in the flatpak2 domain
as its lowest-priority log level (only shown with flatpak -v -v), and
G_LOG_LEVEL_DEBUG in the flatpak domain as its second-lowest
(shown with flatpak -v or higher). I want to move towards using
G_LOG_LEVEL_INFO for flatpak -v messages, and G_LOG_LEVEL_DEBUG for
flapak -v -v, so that we don't need a second log domain: this is a
policy I've used successfully in Flatpak-derived Steam Runtime code.

This change does not fully implement that policy, but gives us a
migration path towards it, by allowing us to start using g_info() for
flatpak -v messages.

Helps: https://github.com/flatpak/flatpak/issues/5001
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-14 20:02:35 +00:00
Simon McVittie
1eed25617c Replace calls to g_memdup() with g_memdup2()
g_memdup() is subject to an integer overflow on 64-bit machines if the
object being copied is larger than UINT_MAX bytes. I suspect none of
these objects can actually be that large in practice, but it's easier
to replace all the calls than it is to assess whether we need to
replace them.

A backport in libglnx is used on systems where GLib is older than 2.68.x.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-12 19:15:52 +00:00
Jan Alexander Steffens (heftig)
d83b262ded app/meson.build: Add missing dep
Since we include the base private headers, we need the common base
sources to be generated.
2022-11-03 15:27:58 -05:00
Simon McVittie
9eb824f863 Add a Meson build system
Resolves: https://github.com/flatpak/flatpak/issues/2241
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-24 16:12:14 +01:00
Robert Ancell
b204ed2466 app: Fix warning when listing a document with no permissions.
(flatpak documents:2965757): GLib-CRITICAL **: 11:27:35.128: g_variant_iter_next_value: must not be called again after NULL has already been returned.

This is due to the applications iterator being checked twice even though it is empty.
2022-09-06 13:18:09 +02:00
Phaedrus Leeds
600e18567c Add a vim modeline and .editorconfig
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.

The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
2022-08-22 19:48:10 -07:00
Phaedrus Leeds
ff8490a91e app: Add -u alias for --user
Save folks a few keystrokes. There is a command which already has a '-u'
option, document-export, but it doesn't support --user so there should
be no conflict. However '-s' is used by the info command among others,
so we can't use that for --system.
2022-08-16 10:50:29 +02:00
Simon McVittie
a03111a3d1 enter: Don't overwrite the DISPLAY
Now that we're using the same display number in the sandbox as on the
host, we can forget about overwriting it with :99.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-08-16 10:45:08 +02:00
Phaedrus Leeds
60005cfcc2 build-export: Don't warn on missing Exec= if DBusActivatable=true
The Desktop Entry spec says that Exec= is only required if
DBusActivatable= is not set to true, so don't emit a warning when Exec=
is missing but not required.
2022-08-16 10:42:06 +02:00
Danilo Bargen
298286be2d build-export: Explicitly allow empty Exec values in desktop file 2022-08-16 10:42:06 +02:00
Danilo Bargen
6dbc097ac5 build-export: Avoid segfault if Exec line is missing from desktop file 2022-08-16 10:42:06 +02:00
Phaedrus Leeds
6db7806762 build-export: Fully ignore stdout content of icon validation
The docs for g_spawn_sync() say:
"Note that you must set the G_SPAWN_STDOUT_TO_DEV_NULL and
G_SPAWN_STDERR_TO_DEV_NULL flags when passing NULL for standard_output
and standard_error."

So add in the stdout flag when calling flatpak-validate-icon in the
build-export command. Without this, there's output in the test logs
from when they're building the test app, due to
https://github.com/flatpak/flatpak/pull/4803
2022-07-25 16:58:16 -04:00
Phaedrus Leeds
cf8979b1b0 app: Un-split translatable strings again
As with the previous commits, try not to split translatable sentences.
See the discussion here about whether the "Warning: "/"Error: " prefix
should be separable:
https://github.com/flatpak/flatpak/pull/4963#discussion_r908326539

Also, don't translate the "(internal error..." message since internal
errors shouldn't be translated to make debugging easier.
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
0465c464af app: Remove a duplicated else if block 2022-07-23 14:18:50 -05:00
Phaedrus Leeds
da5a38c17c app: Un-split some translatable strings
Also make them a bit prettier while we're here

Fixes https://github.com/flatpak/flatpak/issues/4877
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
bf2a0cc2ec app: Un-split EOL translatable sentences
Fixes https://github.com/flatpak/flatpak/issues/4956
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
e1e6465f26 uninstall: Prompt for confirmation on used runtime removal
It doesn't make a lot of sense to prompt for confirmation when an in-use
extension is requested to be uninstalled, but not do so for an in-use
runtime, even if (or perhaps especially since) the latter causes the
transaction to fail later on.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
bf99c266a8 app: Tweak messages about dependent apps
Use a "Info: " prefix which matches the message printed in
print_eol_info_message(). Also make the message accurately use either
the word "runtime" or "extension" as appropriate.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
65a4bb0a3d uninstall: Ask for confirmation for used runtime extensions
Based on discussions on the issue tracker, it seems that users sometimes
remove runtime extensions without really understanding whether they're
in use. Add a confirmation prompt to address this.

Helps: #4549
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
ae0de69b17 app: Improve checking for dependent apps in EOL messages
flatpak_dir_list_app_refs_with_runtime_extension() only works when the
runtime extension it is passed and the apps it returns are both
installed. Sometimes a end-of-life message is printed for a runtime that
is not installed but is being installed by the current transaction, or a
runtime that is installed but one of the apps that needs it is being
installed by the current transaction. To cover these cases, check the
operations in the current transaction when building informational
messages about EOL runtimes.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
e739773056 app: List apps that use a runtime extension when it's EOL
Currently if a runtime extension, e.g.
org.freedesktop.Platform.html5-codecs//18.08 is used by a runtime
org.kde.Platform//5.12 which itself is used by one or more apps, when we
print a message to the user about html5-codecs being EOL, we don't find
any apps using it and don't print any. Fix this by including apps that
indirectly use a runtime extension in the "Applications using this
runtime:" list.

In a later commit we can re-use the helper function added here to add a
confirmation dialog if the user tries to remove a runtime extension
that's being used; currently we just let them remove it.

This is limited to only looking in the current flatpak installation, so
a per-user app using a system-wide runtime extension would not be found.

This is implemented using in-memory caches because otherwise it is
horribly slow; see
https://github.com/flatpak/flatpak/pull/4835#discussion_r876425289

Helps: #3531
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
320889c1a2 app/flatpak-complete.c: Fix typo 2022-07-18 18:51:07 -05:00
Phaedrus Leeds
bf93e004e9 app: Fix inefficiency in pin and mask commands
There's no point reading data from disk on a code path that doesn't do
anything with it.
2022-07-18 18:51:07 -05:00
Fina Wilke
f4b038c8b1 Increase verbosity of extension missing error messages
Adds arch and branch to the error message to help with locating the required
extension arch and branch.
2022-07-17 15:36:21 -05:00
Alexander Larsson
1c9e65d5e4 Move all use of soup APIs into flatpak-utils-http
This will allow us to make the soup dependency optional.
2022-06-16 13:49:45 +02:00
Alexander Larsson
b1083a4c41 http utils: Make a generic FlatpakHttpSession instead of SoupSession
Its still just a SoupSession, but now the implementation is more
centralized and can be something else down the line.
2022-06-16 13:49:45 +02:00
Phaedrus Leeds
e9030fe2f6 update: Add newline before nothing to do message
This looks better in case there are warnings or info messages printed
during the update operation, since those are separated from each other
by newlines (at least the EOL ones).
2022-06-15 16:44:17 -07:00
Phaedrus Leeds
f8d24a9b1e app: Use bold app ID for permissions heading 2022-06-15 16:44:17 -07:00
Phaedrus Leeds
6a9a71b2de uninstall: Fix support for --noninteractive
Just copy the same way we set opt_yes in the install and update
commands.
2022-06-15 16:44:17 -07:00
Phaedrus Leeds
1f7ff92c51 app: Improve end-of-life info message
I think the "app//branch" syntax is pretty ugly, and maybe not all users
understand it.

Helps: #3531
2022-06-15 16:44:17 -07:00
Phaedrus Leeds
4869437880 app: Fix typo in debug message 2022-06-15 16:44:17 -07:00
Alexander Larsson
204abd772f main: Don't install polkit agent when running in tests, fixing slowness.
In the tests we don't use a systemwide helper anyway, so the polkit
stuff is unnecessary. Also, for some reason this was taking a very
long time for me, causing the tests to be super slow.
2022-06-13 20:02:04 +01:00
Debarshi Ray
ed3a1b5f45 build: Don't leak the destination prefix
Clearly, 'dest' can't be a 'const char *' when it's pointing at
g_strdup:ed strings.
2022-06-03 10:53:03 +02:00
Bartłomiej Piotrowski
b61a6d836c WIP: Add support for files generated by appstreamcli compose 2022-05-18 16:01:46 +02:00
Ryan Gonzalez
12305b2cae Add --include-sdk/debug to install SDK/debuginfo along with a ref
This makes it a lot easier to give guidance on using `flatpak run -d` or
`flatpak-coredumpctl`, because there's an easy way to install the
relevant refs.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-05-06 17:35:30 -07:00
Phaedrus Leeds
239706c9c1 uninstall: Make help message more accurate 2022-04-23 14:54:58 +01:00
Phaedrus Leeds
c7d262b375 app: Disable fuzzy matching if not on a tty
As discussed in #4848, this disables fuzzy matching entirely if stdin or
stdout is not a tty, meaning that something like "flatpak install
firefox" would be treated as incorrect syntax, since this syntax is
intended for interactive CLI use. Even before this commit, "flatpak
install firefox" would error out if run without a tty, since we don't
automatically choose a matching app ID even if there is only one match.
However "flatpak install -y firefox" could work before, but won't any
more. People should be specifying the full app ID in any context other
than a tty.

This commit also introduces a new env var so the unit tests can continue
to check the fuzzy matching behavior, despite them being run without a
tty.
2022-04-21 20:53:46 +01:00
Phaedrus Leeds
5acb4ee7e4 app: Disable fuzzy ref matching when id has a period
As discussed in #4848, this disables fuzzy matching when the string
given has a period in it. So for example "flatpak install org.mozilla"
would not offer "org.mozilla.firefox" even though the string given is a
substring of the app ID. This is desirable because it helps ensure fuzzy
matching is only used when the user intended to use it.

As with the previous commit that fixed #4829, this does technically
break backwards compatibility, but only in an interface intended for
interactive use by a human, not an interface that's used
programmatically, so it seems okay.
2022-04-21 20:53:46 +01:00
Phaedrus Leeds
23926b7090 app: Disable fuzzy ref matching when id has a slash
Fixes https://github.com/flatpak/flatpak/issues/4829
2022-04-21 20:53:46 +01:00
Phaedrus Leeds
9e6b28daf5 uninstall: Make error message prettier
The "*unspecified*" bits are ugly, and the ref/arch/branch syntax is
especially confusing when we're doing fuzzy matching, since it implies
the id was searched for exactly.
2022-04-19 15:38:44 +01:00
Phaedrus Leeds
a30ef8f007 uninstall: Error out when all refs are invalid
Currently if you specify one non-existent ref to the uninstall command,
it exits with a non-zero status:

$ flatpak uninstall notaflatpak
error: notaflatpak/*unspecified*/*unspecified* not installed

...but if you specify more than one non-existent ref you get warnings
for each and a zero exit status:

$ flatpak uninstall notaflatpak alsonot
Warning: notaflatpak is not installed
Warning: alsonot is not installed

So make the latter case error out like the former.
2022-04-19 15:38:44 +01:00
Simon McVittie
c68f31d86a build: Consistently include libglnx header as "libglnx.h"
Recent Meson versions have warnings if you add the subprojects
directory as an include path, because the way Meson wants to consume
subprojects is by the subproject's build system producing a Meson
dependency object that encapsulates its include directory. Flatpak
doesn't have a Meson build system yet, but I'm working on that.

libglnx seems to be set up to have the libglnx directory be its include
path instead: for example, ostree (by the author of libglnx) already
uses "libglnx.h" or <libglnx.h> everywhere. Do the same here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-11 10:32:34 +02:00
Phaedrus Leeds
03f11864b9 Improve --sideload-repo option to take create-usb dirs
Currently, when using the sideloading support for offline updates, there
are two types of directories that are interesting: an ostree repo
directory on a directory that was passed to `flatpak create-usb`. By
default the latter has a repo at the subpath ".ostree/repo", and if a
custom destination was specified with "--destination-repo", a symlink is
created pointing to it in ".ostree/repos.d".

Currently Flatpak supports either repos or create-usb dirs in the
`sideload-repos` directory in either the Flatpak installation or
`/run/flatpak` (see flatpak(1)), but only supports repo directories
being passed to "--sideload-repo" for the install and update commands.

This is pretty confusing and actually made me think the sideload support
was broken because I forgot about this limitation. So change things so
we can accept either type of directory specified either way: via option
or via the "sideload-repos" directories.

I've tested all of the following cases:
- pointing to a repo with --sideload-repo
- pointing to a create-usb dir with --sideload-repo
- linking to a repo in ~/.local/share/flatpak/sideload-repos
- linking to a create-usb dir in ~/.local/share/flatpak/sideload-repos
- pulling from a sideload repo when online as a performance improvement
2022-04-11 10:31:13 +02:00
Phaedrus Leeds
759a525771 app: Don't overzealously tab complete options
If the user hasn't typed a '-', don't offer options in the tab
autocompletion. This is consistent with other linux commands, and less
messy.

Fixes https://github.com/flatpak/flatpak/issues/4753
2022-02-21 22:47:16 +00:00
Phaedrus Leeds
12ebf8fd9a Delete some unreachable ref-not-found code
flatpak_remote_state_lookup_ref() always sets the error to
FLATPAK_ERROR_REF_NOT_FOUND when it returns FALSE.

Found by coverity CID 1514265
2022-02-19 15:32:34 +00:00