Commit Graph

6119 Commits

Author SHA1 Message Date
Alexander Larsson
97fa217072 build-commit-from: Add --subset option
This sets the xa.subsets property on the commit, which we will later
use to create subsets of the repo.
2020-10-29 15:30:35 +01:00
Alexander Larsson
a32fb1e333 tests: Silence assert_remote_has_no_config
This is meant to fail, so redirect its stderr to get less confusing test
logs.
2020-10-29 15:30:35 +01:00
Alexander Larsson
67d3443999 tests: Fix unnecessary rebuilds of the test platform
The code to use the pre-generated test platform was buggy so it wasn't
used. Also, generate a "stable" branch of it too as that is used
by test-run.sh.
2020-10-29 15:30:35 +01:00
Alexander Larsson
95ba6c77b4 tests: Better logging of which tests are succeeding
This makes it easier to spot where things go wrong in the logs.
2020-10-29 15:30:35 +01:00
Alexander Larsson
d98943b400 tests: Use "flatpak build-update-repo" instead of ostree summary -u
As we tweak the summary generation code we want to use our code, not
the ostree one.
2020-10-29 15:30:35 +01:00
Alexander Larsson
3169fa58ed tests: Convert some flatpak calls to $FLATPAK
This allows these to run under valgrind when testing in valgrind.
2020-10-29 15:30:35 +01:00
Alexander Larsson
3d65276f79 Add --enable-internal-checks option and use in CI
This enables the internal checks in the generated variant parser.
2020-10-29 15:30:35 +01:00
Alexander Larsson
fb0691e895 Update to latest variant-schema-compiler with some fixes 2020-10-29 15:30:35 +01:00
Philip Withnall
7d30de344c Merge pull request #3906 from smcv/wip/tolerate-no-accountsservice
parental controls: Fail open if accountsservice is missing
2020-10-15 14:57:36 +01:00
Simon McVittie
1a58a86676 Skip parental controls checks on ServiceUnknown or NameHasNoOwner
If accountsservice isn't available on the system bus, then we can't
ask it for the user's parental controls settings, and we also can't
ask it whether it even has the malcontent extension. Since this is
not a real security boundary, fail open.

This can be dropped if we depend on a version of libmalcontent that maps
these errors to MCT_APP_FILTER_ERROR_DISABLED.

Resolves: https://github.com/flatpak/flatpak/issues/3902
Bug-Debian: https://bugs.debian.org/972138
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-15 09:24:14 +01:00
Philip Withnall
6c79a57114 http: Return HOST_UNREACHABLE on error 500
Sometimes a server might return a HTTP error 500 (this seems to happen
sometimes with Microsoft’s VSCode server, for example). Map this to
`G_IO_ERROR_HOST_UNREACHABLE` for now, which is a bit more specific than
returning `G_IO_ERROR_FAILED`, but without the hassle of introducing a
new public error domain which could give more detail.

In particular, this should allow gnome-software to show an error message
to the user for such failed downloads, rather than hiding the error and
logging the following:
```
not handling error failed for action download: While downloading http://packages.microsoft.com/repos/vscode/pool/main/c/code/code_1.45.1-1589445302_amd64.deb: Server returned status 500: Internal Server Error
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-10-12 11:04:40 +02:00
Yuri Chornoivan
0200348cf7 Update Ukrainian translation 2020-10-12 10:39:57 +02:00
Alexander Larsson
180d807d2a oci-authenticator: Fix crash if anon auth fails and no_interaction is set
We were clearing the error from the anon test, and then not doing any
non-anon auth, so error was NULL, causing a crash when returning an
error message.
2020-10-09 16:57:57 +02:00
Alexander Larsson
33d1d7b1a5 transaction: Fix error handling in authentication failures
We were not correctly returning in case of error, which caused
a cascading "owerwrite gerror" problem.
2020-10-09 16:57:57 +02:00
Alexander Larsson
aec1f62f8f CLI: Ask for transaction confirmation before authentication
If possible, ask for confirmation of the entire transaction before
starting to do the per-ref authentication. We do this by splitting
the current "ready" callback into two parts, one in ready-pre-auth
and the rest in ready.

There is some complexity added because if we do any authentication
between the two signals we can't back-patch the transaction list we
already printed. To handle this we detect this case and re-print the
table if this happens.
2020-10-09 16:57:57 +02:00
Alexander Larsson
d7716f41ac libflatpak: Report available updates for password-protected refs too.
flatpak_installation_list_installed_refs_for_update() now uses the
ready-pre-auth signal instead of the ready signal. This means we will
report updates even for refs that require authentication to install.
2020-10-09 16:57:57 +02:00
Alexander Larsson
bf8ac3cc1c Transaction: Add ready-pre-auth signal
This is similar to the ready signal, except it is called before
per-ref authentication. Apps can use this if they want to be able
to ask for user input on progress before asking for authentication.

This is nice to be able to do in general, but it is also required for
the implementation of
flatpak_installation_list_installed_refs_for_update(), as it doesn't
install any authentication handler, so it will never report updates
for protected refs if using the ready signal.

Note: In special cases we will require authentication even earlier
if authenticating is needed during the resolve operation. This happens
for instance if you are doing a update to a particular commit (rather
than the lastest commit) where we need to get the commit object directly.
2020-10-09 16:57:57 +02:00
Ryan Gonzalez
ff2e7d6e90 transaction: Don't crash on invalid ref names
It is very much possible for an invalid ref name to occur, either due to
lack of validation on Flatpak creation like #3887, or just any
manually-written ref name due to skipping Flatpak tooling or malicious
intent. Regardless, this shouldn't crash, so check the names before
creating the transaction ops.

Fixes #3887.
2020-10-08 09:46:49 +02:00
Ryan Gonzalez
719eeee461 build-init/finish: Validate extension names
Otherwise, it becomes easy to accidentally create extensions with
invalid names. Ref #3887.
2020-10-08 09:46:49 +02:00
Ryan Gonzalez
9959fd80e9 repair: Add basic and "fancy" verify progress
This change makes repair print the current ref number being verified
and the total number, that way the user can observe the repair progress.
In addition, if fancy output is not disabled, the progress will be
cleanly printed on a single line.

On a dry run, this also will still print the delete messages without
actually performing the operations, to show what actions would be
taken on a non-dry-run.
2020-10-08 09:17:28 +02:00
Phaedrus Leeds
036aba8cb8 common: Fix docs for FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED 2020-10-08 09:15:20 +02:00
Alexander Larsson
3001cb3174 Fix some clang errors 2020-10-08 09:14:51 +02:00
Alexander Larsson
a5d86b8acb transaction: inject eol status to flatpak_dir_list_unused_refs()
This way we can get the proper eol status for the new to-be-installed
refs, rather than whatever was previously installed. This allows us to
detect when a runtime is updated and the new one is eol, and nothing
uses it, so it can be auto-uninstalled.
2020-10-08 09:14:51 +02:00
Alexander Larsson
05a7bda140 transaction: Simplify add_uninstall_unused_ops()
Rather than trying to figure out which runtimes are affected byt
the current setup of ops we run flatpak_dir_list_unused_refs() twice,
once with and once without the changes the transaction will cause.

Any unused refs after the transaction that were not unused before are
caused by the transaction and we start uninstall ops for those.

Also rename flatpak_dir_list_unused_refs_with_options() to
flatpak_dir_list_unused_refs() as it need not be so long.
2020-10-08 09:14:51 +02:00
Alexander Larsson
6bdc364e95 find-unused: Don't care about origin when finding used deps
If we're auto-installing dependencies we want to limit them to those
from the same remote. However you can still (manually) install such
dependencies, so when we're looking for things to possibly uninstall
we need to check dependencies from all remotes.
2020-10-08 09:14:51 +02:00
Alexander Larsson
3642f59ea8 Fix some clang warnings for FlatpakRefPrivate atomic use 2020-10-08 09:14:51 +02:00
Alexander Larsson
478bcc0b12 Rewrite flatpak_dir_list_unused_refs_with_options()
This simplifies the implementation and makes it more effective in
avoiding to re-scan the same things several times.
2020-10-08 09:14:51 +02:00
Alexander Larsson
356b7fb346 tests: Add basic test for flatpak_dir_list_unused_refs_with_options()
This is currently failing, but I believe that is caused by actual
bugs.
2020-10-08 09:14:51 +02:00
Alexander Larsson
e83180e040 install: Add --no-auto-pin option
We want to use this for the test when we test the list unused refs
functions.
2020-10-08 09:14:51 +02:00
Alexander Larsson
84da902443 transaction: Add flatpak_transaction_set_disable_auto_pin()
This disables the automatic pinning of explicitly installed runtimes.
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
7691fc77eb app: Remove EOL unused runtimes in update command
In case a runtime becomes unused and then later becomes End-Of-Life, it
is currently not removed. So this commit removes such runtimes in the
update command, as discussed in #2639. A unit test is included.

I am planning to propose to use the FlatpakTransaction API added here in
gnome-software, so that users don't have to use the CLI at all for
runtimes to be cleaned up. KDE Discover already removes unused runtimes
periodically.
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
617f614d50 Remove EOL runtimes upon app uninstall/upgrade
We normally don't remove a runtime when the last app using it is
uninstalled, since runtimes are large and re-downloading it in the
future may be difficult. But if the runtime is end-of-life, there's a
reasonable chance it won't be used again, so uninstall it in that case.

Similarly, if the last app using a runtime is upgraded to a different
runtime, and the runtime is EOL, uninstall it.

A unit test is included, and the subsequent unit test also had to be
modified. Otherwise we get a "Update is older than current version"
error, since the runtime is installed from test-repo but
setup_repo_no_add() calls make_runtime() which uses the one in
runtime-repo instead, which is older than the one in test-repo.
2020-10-08 09:14:51 +02:00
Alexander Larsson
aa55d0088f uninstall: Use flatpak_dir_list_unused_refs_with_options()
No need to use the FlatpakInstallation version, because we just
needs the refs as strings, not FlatpakInstalledRef:s
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
44aa0d6830 Add internal API for list_unused_refs() and add _with_options()
In a few places we are using
flatpak_installation_list_unused_refs() and then only
using the ref strings not the FlatpakInstalledRef objects, so the
resources used to construct those objects are wasted. Add a flatpak_dir_
function to be used internally instead. One day we will figure out how
to make flatpak-dir.c less of a wilderness.

This also adds the flatpak_installation_list_unused_refs_with_options()
verion that has extended features.
2020-10-08 09:14:51 +02:00
Alexander Larsson
b6bd4472c5 flatpak_ref_format_ref_cached: Don't unnecessarily use g_object_set_data 2020-10-02 15:30:58 +02:00
Phaedrus Leeds
55f6abe578 Avoid string duplication in FlatpakRef
Allocate a full ref string once per object rather than once per call.
This is similar to what we do in flatpak_dir_get_name_cached().
2020-10-02 15:30:58 +02:00
Phaedrus Leeds
929fe68f55 flatpak-ref: Don't free immutable struct members
These are only set at object construction time not after.
2020-10-02 15:30:58 +02:00
Phaedrus Leeds
ce2e36d8ea dir: Remove unused variable
This is no longer needed since commit 124b0be92
2020-10-02 15:30:58 +02:00
Phaedrus Leeds
6985bf27ac installation: Fix a Since annotation
Apparently unstable release series start with a micro version of 1.
2020-10-02 15:30:58 +02:00
Kalev Lember
34bb5592c9 common: Allow skewered to camelcase DConf path conversion both ways
commit 6b46d9a0ed that added DConf path
skewering to camelcase conversion only allowed it in one direction
(skewered path1 and camelcase path2).

That turned out to be not enough to allow /org/gnome/sound-juicer/ to
/org/gnome/SoundJuicer/ conversion as the caller had the
flatpak_dconf_path_is_similar() arguments the other way around.

This commit implements it both ways to avoid confusion which way it
should be called.

F: Ignoring D-Conf migrate-path setting /org/gnome/sound-juicer/
2020-10-01 11:15:54 +02:00
Phaedrus Leeds
7a2deb1ee7 gitignore: Ignore tests/services
These services are all generated at build time.
2020-10-01 11:12:21 +02:00
Simon McVittie
7c29fc6fd6 doc: Include D-Bus APIs in the API reference documentation
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
063cbd9e78 data: Very briefly document the SystemHelper interface
I'm not documenting the individual methods here, only the fact that the
interface exists and is private to the Flatpak source tree (it's the
communication between libflatpak and the system helper).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
4ebb4db06f data: Document the Development interface
This is heavily based on the corresponding documentation for the
portal.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
727d45eb8c data: Briefly document the SessionHelper interface
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
14870402d0 portal: Adjust documentation for SpawnSignal, SpawnExited
This is based on documentation that I wrote for Steam's pressure-vessel,
which has a Launcher interface based on the API and implementation of
the Flatpak portal.

I haven't renamed exit_status to wait_status like commit 63feb3cc in
flatpak-xdg-utils, just in case the name is significant in someone's
code-generation. However, don't be fooled: it's a wait-status, not
an exit status.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
ba5c3a7e9a portal: Document the symbolic names of the flags
They aren't currently in any installed header file, but that doesn't
mean we can't suggest a name for dependent projects to #define.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
f9b90d5c32 portal: Document forwards-compatibility for flags and options
Flags are assumed to be critical, similar to the convention for modern
Linux syscalls: if an unknown flag is given, the call will fail.
Callers are expected to guard their use of flags with a version check
or a fallback.

Conversely, options are assumed to be non-critical "hints", similar
to org.freedesktop.Notifications: if an unknown option is given, the
call will succeed as though the option had not been present. Callers
are expected to carry out an explicit version check if they need to
know whether an option is going to be respected or not.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
b5a5b18103 portal: This is the flatpak portal, not the documentation portal
Also specify that it's on the session bus, not some other bus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00
Simon McVittie
4aa7af4379 portal: Fix typos in documentation
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 11:11:30 +02:00