Commit Graph

1506 Commits

Author SHA1 Message Date
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
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
Phaedrus Leeds
6dc067ca33 search: Improve memory efficiency 2022-02-17 08:29:20 -06:00
Phaedrus Leeds
af11e25975 search: Properly get branch values 2022-02-17 08:29:20 -06:00
Phaedrus Leeds
2af0c17297 search: Fix printing app ID with no .desktop suffix
In https://github.com/flatpak/flatpak/issues/4535 it was brough to light
that the search command strips the ".desktop" suffix from app IDs even
if they genuinely end in .desktop. This commit fixes the reverse issue
now that we've ported to libappstream: don't include the .desktop suffix
even if it's present in the id of the appstream component, which it
sometimes is.

Fortunately we already ignore any components that don't have flatpak
<bundle> elements, so we can unambiguously get the ID there.

Fixes #4535
2022-02-17 08:29:20 -06:00
Phaedrus Leeds
924d71d5d2 app: Check appstream file not found error code
Now that we switched from appstream-glib we don't need this hack.

See https://github.com/ximion/appstream/pull/362
2022-02-17 08:29:20 -06:00
Phaedrus Leeds
44117ee0cb Add macro for having appstream 0.14.0
Older versions of libappstream don't provide AS_CHECK_VERSION() so we
can't use that, and we need the check because as_component_get_branch()
is only in libappstream >= 0.14.0, and the return value of
as_metadata_parse_file() changed in 0.14.0
2022-02-17 08:29:20 -06:00
Philip Withnall
f027d49a79 app: Drop unnecessary wrappers
Since the port from libappstream-glib to libappstream, these wrappers
are trivially thin and can be dropped.

This commit introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-17 08:29:20 -06:00
Philip Withnall
9c059def69 app: Port to libappstream
libappstream-glib is mostly unmaintained, and libappstream is more
actively developed (and up to date with the AppStream specification).

Port from libappstream-glib to libappstream. Handily, a lot of the APIs
are exactly the same. The main changes are:
 * `AsApp` → `AsComponent`
 * `AsStore` → `AsMetadata`

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

(Mostly done by Philip, then Phaedrus finished this)
2022-02-17 08:29:20 -06:00
Phaedrus Leeds
fca2e5285f Revert "search: Don't strip .desktop suffix overzealously"
This reverts commit 62e09b406b.

This is implemented differently after the libappstream port.
2022-02-17 08:29:20 -06:00
Phaedrus Leeds
036542c28b Revert "search: Use <bundle> ID to determine flatpak app ID"
This reverts commit 39de0ef280.

This is implemented differently after the libappstream port.
2022-02-17 08:29:20 -06:00
Will Thompson
a62f8cfb62 build-init: Write .gitignore in build dir
It is common for the build directory to be within a Git checkout.
Developers never want to check this directory into Git.

Make 'flatpak build-init', and hence 'flatpak-builder', create a blanket
.gitignore file inside this directory, so the containing checkout
doesn't need to predict the name of the build directory and ignore it.

(Inspired by Meson's treatment of its build directory.)
2022-02-14 15:21:45 +00:00
Simon McVittie
3f144d1e02 app: Make ALL_DIRS and STANDARD_DIRS imply OPTIONAL_REPO
It is already the case that when we are using ALL_DIRS, we always
combine it with OPTIONAL_REPO, meaning no need to populate empty
installations. ALL_DIRS is used for commands that iterate through all
known installations to enumerate apps/runtimes, such as `flatpak run`
and `flatpak list`; for these commands, it's reasonable to say that
if the installation does not have a libostree repository, then that's
equivalent to it having a libostree repository with no apps and no
runtimes. Make this happen automatically if forgotten.

For STANDARD_DIRS, we were inconsistent about this: `flatpak remote-list`
had OPTIONAL_REPO, but the other commands did not.
STANDARD_DIRS is used for `flatpak create-usb`, and for all the commands
that manipulate remotes.

For the commands that manipulate remotes, it seems reasonable to say
that if an installation has no libostree repository and we are unable
to create one, then that's equivalent to an installation with a
libostree repository but no remotes.

Similarly, for create-usb, an installation where we are unable to create
a libostree repository seems like it should be equivalent to an
installation whose libostree repository does not contain any of the
refs we are interested in.

Resolves: https://github.com/flatpak/flatpak/issues/4111
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-11 15:49:15 +01:00
Simon McVittie
97db30f38d Don't rely on AS_BUNDLE_KIND_FLATPAK existing
The appstream-glib in Ubuntu 16.04 didn't have this.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-01-12 13:55:49 -08:00
Phaedrus Leeds
3c63cac8f9 Export to share/metainfo not share/appdata
Read metainfo files from both share/appdata and share/metainfo to
support new and old versions of flatpak-builder
(https://github.com/flatpak/flatpak-builder/pull/441) but only export to
the new path.

Fixes https://github.com/flatpak/flatpak/issues/4599
2022-01-10 09:55:26 +01:00
Phaedrus Leeds
4d9fd30578 document-unexport: Finish implementing --doc-id
Picking up Matthias' commit from a few years ago to get it mergeable.
2022-01-10 09:40:40 +01:00
Matthias Clasen
9e090b845a document-unexport: Allow unexporting by docid
If the backing document has been deleted, then looking
up the doc-id fails. To work around this, allow specifying
the doc-id directly.

Closes: #1897
2022-01-10 09:40:40 +01:00
Phaedrus Leeds
6fac58a9b9 repair: Properly mark invalid commits as partial
Commits that are found to have missing or invalid objects need to be
marked partial so that when the thing referencing them is reinstalled,
the missing objects will be pulled. libostree treats non-partial commits
as complete even if they're not, since verifying their completeness is
an expensive operation.

This exactly mirrors what the "ostree fsck" command does when it finds
corruption in a commit.

This fix is especially important because corrupt repos have been an
issue lately so we at least need repair to work properly.

Relatedly, delete invalid commit objects to ensure they are
re-downloaded, though it's not clear that code path is almost ever
reachable.

Fixes https://github.com/flatpak/flatpak/issues/4618
2022-01-10 09:36:49 +01:00
Phaedrus Leeds
e6702161da app: Don't use polkit agent in history command
There's no need to use polkit in the history command, so don't start the
agent in flatpak-main.c. This means we can avoid a test failure in
test-history.sh which was caused by old versions of valgrind being
unaware of syscall sched_getattr, which is used in g_bus_get_sync(),
itself called by install_polkit_agent().
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
2f13aabad6 history: Fix exclusion of temp repos
Without this change there are history entries showing pulls into
temporary repos which we don't want.
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
72aef63c58 history: Omit entries for appstream refs
Currently we include entries in the output of the history command for
pulls of appstream refs, e.g. "appstream2/x86_64". However since they
don't have an application ID the Application column shows up blank and
it seems like a pull of nothing which is confusing. These are basically
an implementation detail like the temp repo pulls we already exclude, so
I think it makes sense to exclude them from the output.

It would also make sense to exclude pulls of ostree-metadata refs, but
for some reason I don't see those in practice, even with a collection ID
set on the remote.
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
7b6dba8803 history: Fix printing refs
The history command seems to have been broken since it was changed to
use FlatpakDecomposed, since that type only works for app or runtime
refs, resulting in errors such as:
$ flatpak history
error: appstream2/x86_64 is not application or runtime

Fix this by making the logic a bit smarter, and don't let any one
invalid ref entry prevent the whole command from working.

Fixes #4332
2022-01-04 11:42:00 -08:00
Patrick Griffis
17b05b0c91 run: Fix session-bus and a11y-bus args being incorrect
This would incorrectly overwrite the a11y-bus option and not set the default
session-bus options.
2022-01-04 13:02:04 -06:00
Phaedrus Leeds
4619bedfdb app: Refuse to work with sudo and --user
Have heard of people running Flatpak commands with both sudo and --user,
and not expecting it work on the root user's installation. Let's just
not allow it since it's not something people ever do intentionally.
2022-01-04 11:49:07 +00:00
Phaedrus Leeds
470b321c63 list: Tweak logic for excluding Locale/Debug extensions
The man page states that the --all option for the list command includes
runtime extensions (e.g. that end in .Locale or .Debug) and this is the
case. When --all is omitted, we only show such extensions when the thing
they extend is not already in the list. However when you run a command
like "flatpak list --runtime --columns=application,branch", you get a
list that excludes runtime locale extensions but includes app locale
extensions, since the corresponding apps are not in the list despite
presumably being installed. This doesn't seem like the right behavior,
so tweak the logic so that app locale extensions are excluded when --all
is omitted and --runtime is used.

Strictly speaking the "extension-of" information is not guaranteed to be
present in the deploy data (which acquires it from the metadata), but in
practice it seems to be present for all but Sources extensions, and I
think it should be considered required since we are already using it to
implement functionality elsewhere in Flatpak:
https://github.com/flatpak/flatpak/issues/4585
2021-11-18 15:20:05 +01:00
Phaedrus Leeds
2c4c84ffee app: Don't tab-complete on aliases
Fixes https://github.com/flatpak/flatpak/issues/4036
2021-11-18 15:11:05 +01:00
Phaedrus Leeds
388c23cfc5 Make test suite logs prettier
This fixes a few issues with the unit test logs that make them ugly:
1. Currently some lines of output from a command will appear after the
   line from xtrace which has the next command, since the command was
   printing to stdout and xtrace uses stderr. E.g. "Installation complete."
   will appear after "+ flatpak --user install -y ..." but it is from the
   previous install command.
2. Lines of output have many spaces after them to pad them to the table
   width but this is not needed for non-fancy output.
3. Lines of output are mixed with output from httpd since they don't end
   with a newline character, e.g. "Installing… ▊
   4%127.0.0.1 - - [16/Nov/2021 00:18:24] "GET /..."
2021-11-16 11:00:34 -08:00
Guido Günther
766bf5f08a build-finish: Export appstream metainfo into a single directory
This is similar to what is done for desktop files and allows
applications to use a flatpak's metainfo to retrieve e.g.  required
input controllers or the supported screen sizes. Similar to what can be
done for non-flatpak'ed apps by looking at
/usr/share/{metainfo,appdata}.

Since flatpak moves the metadata from metainfo/ to appdata/ during build
we only need to export files from that single directory.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2021-11-15 11:34:24 +01:00
Phaedrus Leeds
3aa9a7f3a1 app: Fix behavior when installing end-of-life-rebased ref
Currently if the user specifies a ref to install that has been renamed
via the end-of-life-rebased mechanism, for example "flatpak install
com.visualstudio.code.oss", Flatpak erroneously tries to install both
the old and new versions of the app. This happens because the code
handling end-of-life-rebase conditions is written assuming the rebased
app is being updated rather than installed for the first time.

Specifically, in FlatpakCliTransaction and FlatpakQuietTransaction, in
end_of_lifed_with_rebase(), we treat a failure of
flatpak_transaction_add_uninstall() as fatal and return FALSE from the
signal handler, which means that the install operation that triggered
the signal will not be skipped (see the docs for
FlatpakTransaction::end-of-lifed-with-rebase).

So, instead check for the FLATPAK_ERROR_NOT_INSTALLED error code and
ignore it, so that the installation of the old version of the renamed
app will be properly cancelled.

Fixes https://github.com/flatpak/flatpak/issues/3754
2021-11-15 11:13:51 +01:00
Phaedrus Leeds
17fbe516c4 build-update-repo: Don't try to generate deltas of unknown refs
Spotted this by code inspection. Ignoring such refs was clearly the
intended behavior based on the comment.
2021-11-15 10:55:50 +01:00