Commit Graph

2006 Commits

Author SHA1 Message Date
Phaedrus Leeds
08e55a36aa transaction: Fix docs around op authentication 2020-10-29 20:26:08 -07:00
Alexander Larsson
7b5a0a5c86 Fix extra-data progress reporting
We were never calling the progress callback for extra-data downloaded
bytes.
2020-10-29 17:19:38 +01:00
Alexander Larsson
308e30c8f0 transaction: Remove transfer annotation for boolean
This doesn't do anything (and was causing warnings).
2020-10-29 16:08:12 +01:00
Alexander Larsson
c04df80ee1 Drop some spew from flatpak_dir_list_unused_refs()
This was showing up in every flatpak update, making it hard
to see the important stuff.
2020-10-29 16:08:12 +01:00
Alexander Larsson
e6d7a1148e summaries: Cache subsummaries per-arch
We store the cached subsummaries as `$remote-$arch-digest.sub`, this
way we can prune everything but the most recent (i.e. highest mtime)
rather than looking at the index. This way we don't prune old
subsummaries for other arches when we update one arch, which would not
let us use deltas for those.

Some details:
 * If mtimes are identical (mtime precision issue) for several
   subsummaries we keep all.
 * If we just saved a subsummary in the cache we don't prune that
   in case there is something wonky with mtimes.

The subsets for a remote are pruned every time we write a new cached
subsummary.
2020-10-29 15:30:35 +01:00
Alexander Larsson
2c8fe5b94c Use the new FlatpakDecomposed when mathing refs
This avoids lots of re-splitting and re-validation as well as strdups.
2020-10-29 15:30:35 +01:00
Alexander Larsson
472939f538 utils: Add FlatpakDecomposed helper
This is a ref-counted version of a ref string that is guaranteed
to be in the proper form, and is pre-decomposed for efficient partial
matches.
2020-10-29 15:30:35 +01:00
Alexander Larsson
7483a98769 utils: Allow passing sizes to more utils
These now take (optional) string length args:
  flatpak_id_has_subref_suffix()
  flatpak_levenshtein_distance()
  flatpak_is_valid_name()
  flatpak_is_valid_branch()
2020-10-29 15:30:35 +01:00
Alexander Larsson
5b52b64cd1 Export flatpak_repo_load_summary_index() and flatpak_repo_load_digested_summary() 2020-10-29 15:30:35 +01:00
Alexander Larsson
98e20c18f9 summaries: Support using summary deltas on client
Also prune old unreferenced subsummaries on each transaction.
2020-10-29 15:30:35 +01:00
Alexander Larsson
2c6fec556f summaries: Generate summary deltas when updating repo 2020-10-29 15:30:35 +01:00
Alexander Larsson
0221f5a1fa summaries: Ensure we can support non-default arches W/ indexed summaries
We need to load the ensure the right arch whenever we need it.

Also this restructures the RemoteState handling a bit in general so that
we avoid loading the same remote state multiple times when converting
partial refs to full refs.
2020-10-29 15:30:35 +01:00
Alexander Larsson
dce6f748bb summaries: Rework the debug spew for summary/cache loading
This way its easier to tell exactly what happens.
2020-10-29 15:30:35 +01:00
Alexander Larsson
5821f79d88 dir: Make flatpak_transaction_ensure_remote_state non-static
This moves it to fatpak-transaction-private.h so that we can use it
internally to be able to re-use the remote-states from the transaction
outside it.
2020-10-29 15:30:35 +01:00
Alexander Larsson
0d2cf085af Add option to disable generating summary index
This is mainly useful for the tests
2020-10-29 15:30:35 +01:00
Alexander Larsson
57954e2efc summary: Enable use of indexed summaries in the client
We first try to download the index, then fall back to the old format.
2020-10-29 15:30:35 +01:00
Alexander Larsson
0597f246c8 build-update-repo: Generate new summary format
In addition to the old summary file we create a summary.idx and
a set of per-arch subsummaries (and extra copies of these if any commit
specify a subset). These are much smaller, and eventually we will also
get deltas for them.

We are not yet using these new formats, although the code is there
to use them once we start downloading them.
2020-10-29 15:30:35 +01:00
Alexander Larsson
096daf91f2 summary: Implement a new, more efficient, summary format
This drops the deltas from the summary and uses the per-commit
metadata field to add the cache data to avoid the need for the separate
xa.cache and xa.sparse-cache indexes. This way we avoid repeating the
refs in multiple places.

Nothing uses this format yet, but we still pass make check if we enable
it.
2020-10-29 15:30:35 +01:00
Alexander Larsson
b094585545 utils: Expose get_compat_arch_reverse() and get_arch_for_ref()
We need to use these from some other files too.
2020-10-29 15:30:35 +01:00
Alexander Larsson
c5d76e5a85 summary: Extract the summary generation code to helper 2020-10-29 15:30:35 +01:00
Alexander Larsson
b7e90d3809 summaries: Add support for limiting which arches end up in summary
This is in preparation for adding other formats for summary and we
might not want all the arches in the fallback summary format.
2020-10-29 15:30:35 +01:00
Alexander Larsson
f84b48ac58 utils: Reimplement summary generation
This moves the generation of the summary files completely into flatpak
allowing us to (later) customise what goes into it in more detail and
generate other forms of summaries.
2020-10-29 15:30:35 +01:00
Alexander Larsson
387bb8c64e Add flatpak_dir_get_remote_subset()
Reads the subset config for the remote, if any.
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
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
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
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
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
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
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
Bastien Nocera
6b46d9a0ed common: Allow skewering when converting in app-id for DConf migration
Allow a snake-case in the app-id to convert to a '-' or '_' in the
DConf path to be considered similar enough for DConf migration purposes.

This allows the org.gnome.SoundJuicer app-id to migrate its
/org/gnome/sound-juicer DConf path.

F: Ignoring D-Conf migrate-path setting /org/gnome/sound-juicer/
2020-09-15 08:59:53 +02:00
Bastien Nocera
c6802d2c0e common: Prepare DConf path parsing for changes
Separate the variables used to keep track of which character we were
checking in each of the paths.

No functional changes.
2020-09-15 08:59:53 +02:00
Phaedrus Leeds
92742d8387 dir: Remove superfluous flatpak_dir_ensure_repo()
This is no longer needed since a FlatpakRemoteState is passed in, which
ensures the repo exists. The similar call was already removed from
flatpak_dir_install().
2020-09-15 08:58:49 +02:00