Commit Graph

6184 Commits

Author SHA1 Message Date
Alexander Larsson
08dc7cb2aa dir: Remove unused non-_decomposed() helpers
This removes flatpak_dir_list_remote_refs() and
flatpak_dir_list_all_remote_refs() which have no more users, as everything
migrated to the _decomposed() versions.
2020-11-10 14:32:13 +01:00
Alexander Larsson
877cede50b decomposed: Store ref data inline if possible.
When we're not taking the string from elsewhere, store the string data
inline.
2020-11-10 14:32:13 +01:00
Alexander Larsson
cd34088969 Transaction: Convert internal refs to FlatpakDecomposed
We convert early in the API so that we can rely on the format everywhere
and use the faster getters for the parts of the refs.
2020-11-10 14:32:13 +01:00
Alexander Larsson
840cb2ed3d decomposed: Add id_has_suffix() helper 2020-11-10 14:32:13 +01:00
Alexander Larsson
db11607016 installation: Use the FlatpakDecomposed APIs to create FlatpakRef:s
This means we do a bit less string operations, but it also allows us
to pick up the collection-id when listing refs from a file: uri, fixing
the issues described in https://github.com/flatpak/flatpak/pull/3909

This slightly changes the behaviour of collection ids and remotes.
When listing regular remotes we only ever return the refs with the
collection id specified by the configuration of that remote. However,
when specifying a file: uri for the remote name we return all the refs
in the repo, with their corresponding collection id.

This means the test suite has to change a bit as before we returned
all the collrefs from the remote, not just the one matching the configured
collection id.
2020-11-05 10:43:10 +01:00
Alexander Larsson
247fed25ff remote-state: For local repos, set collection id for main ref table too
If you're listing a file: uri we (as before) add the collection-ref
tables, but we now also set the proper collection-id for the main ref
table if the ostree.summary.collection-id key is set.
2020-11-05 10:43:10 +01:00
Alexander Larsson
bd5029e72a dir: Add flatpak_dir_list_refs_decomposed() 2020-11-05 10:43:10 +01:00
Alexander Larsson
abb097f812 decomposed: Support defaults in flatpak_decomposed_new_from_parts
This allows NULL for arch and branch, similar to
e.g. flatpak_build_runtime_ref().
2020-11-05 10:43:10 +01:00
Alexander Larsson
3b63c51ce6 decomposed: Add support for FlatpakRefKind 2020-11-05 10:43:10 +01:00
Alexander Larsson
425147e4b1 Add flatpak_decomposed_new_from_parts() 2020-11-05 10:43:10 +01:00
Alexander Larsson
5dae1fc6bc Break out ref helper functions to separate file
flatpak-utils.c is getting large, and also I got some issues with
include order, so split out things that are purely handling ref stings
in various ways to its own file.
2020-11-05 10:43:10 +01:00
Alexander Larsson
ed192e1044 remote-ls: Add a smarter fallback for names if appstream is missing
Rather than just taking the last element of the name we also
look at known extensions like .Platform, .Sdk, .Debug, .Locale, etc.
2020-11-05 10:43:10 +01:00
Alexander Larsson
7757b1dea7 RemoteState: For a local repos, add refs with all collection ids.
If you are listing a remote named (e.g.) file:///some/path/to/repo then we
have no idea what the actual collection id is for that remote, so we can't
pick the right part. In practice, this is typically done when listing
a side-load repo, such as described in
https://blogs.gnome.org/mclasen/2018/08/26/about-flatpak-installations/
or by the endless software installer that lists available offline apps.

This kinda abuses the FlatpakDecomposed object to store the collection
id, even if that doesn't normally carry this. This is not optimal, but it
is kind of a weird case and there isn't really any other place for it that
makes sense either, and having it there is efficient and keeps the APIs.
2020-11-05 10:43:10 +01:00
Alexander Larsson
e1da8d9455 remote-ls: Use list_decomposed() 2020-11-05 10:43:10 +01:00
Alexander Larsson
089a5bebd5 Add flatpak_dir_list_remote_refs_decomposed() 2020-11-05 10:43:10 +01:00
Alexander Larsson
7465ba0f18 Various FlatpakDecomposed API updates
getters now have three forms:
  const char *foo_peek() returns pointer into data and length
  const char* foo_get() returns zero terminated pointer into data
  char *foo_dup() returns allocated zero terminated pointer

Not everything has all of these (as that is not always possible), but
it is clear what each one does.

We also now support storing a collection id for a
FlatpakDecomposed. This is not typically done (as we use the source
remote to define the collecion id and don't expose this concept to the
user). However, for the case when directly listing a local repo (such as
a side-load repo) we need this.

We now validate the arch string. The valid chars are a-z, A-Z, 0-9 and
_. This was't previously verified, but no arches in existance have other
chars.

There is a new flatpak_decomposed_new_from_decomposed() which lets you
modify part of another ref. Say replace the arch or the branch and
keep the rest the same.
2020-11-05 10:43:10 +01:00
Phaedrus Leeds
ce377e577f transaction: Tweak docs around eol-rebase 2020-11-05 09:33:26 +01:00
Alexander Larsson
97740ab3f6 remote state: Try loading non-index summary from memory cache before fetching
We used to go:
 * indexed summary memory cache
 * indexed summary fetch
 * compat summary memory cache
 * compat summary fetch

But now we go:
 * indexed summary memory cache
 * compat summary memory cache
 * indexed summary fetch
 * compat summary fetch

This means in the compat case we don't constantly have to fail the
summary fetch before using the memory cache.
2020-11-03 15:14:16 +01:00
Alexander Larsson
dddeaca8c3 transaction: Reuse FlatpakRemoteState when finding dependencies
This moves a bunch of code from FlatpakDir to FlatpakTransaction which was
only used to find dependencies. This allows us to reuse the existing
cache of FlatpakRemoteState objects in the transaction.
2020-11-03 14:19:58 +01:00
Alexander Larsson
d61721022d Change the last user of flatpak_dir_list_all_remote_refs to use _decomposed
This will let us remove the non-decomposed one.
2020-11-03 12:57:37 +01:00
Alexander Larsson
3ebcd200ca Remove should-retry debug spew
Every http operation (even when successfull) was spewing info about
whether to retry it which made it hard to read the logs.
2020-11-03 12:57:37 +01:00
Alexander Larsson
3522d183bc summaries: When regenerating summaries, ensure they get newer mtimes
The st_mtime field is all we can guarantee to keep, so whenever we
write a new summary file for a repo we ensure it is newer than the old
by checking if st_mtime is equal (or less) and if so, use the old
st_mtime plus one.

This means sometimes the generated summary files will be in the future but
that only happens in the corner case of multiple changes inside one
second, and in that particular case we need this change.

This fixes some issues I had with the mtime chacking in the tests due to
the python httpd handling If-Modified-Since based on st_mtime.
2020-11-03 12:57:37 +01:00
Alexander Larsson
6fc480dcbc Bump libglnx to version with GLNX_FILE_REPLACE_INCREASING_MTIME
(See  https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/21)
2020-11-03 12:57:37 +01:00
Alexander Larsson
f647a5ea79 remote-modify: Clear cached summaries when the remote is modified.
This fixed some issues in the test where changing the url cause the
cache:ing to fail to update due to the mtimes being to new in combination
with the HTTP If-Modified-Since use.
2020-11-03 12:57:37 +01:00
Alexander Larsson
a3eaa36ce4 dir: Clear summary cache when updating metadata
For example, if the url changes we need to re-read the summary. This
was causing issues in a repo test where we re-wrote the url, and then
the new summary was not downloaded because of a st_mtime based
If-Modified-After check in the python httpd.
2020-11-03 12:57:37 +01:00
Alexander Larsson
a8fe3247e7 summary cache: Rename CachedSummary.remote to CachedSummary.name
This doesn't change the results but makes it more clear now that we don't
only use the remote name as the cache key.
2020-11-03 12:57:37 +01:00
Phaedrus Leeds
2486961014 system-helper: Check for errors getting installation
I don't think this error code path will really be hit in practice,
except perhaps for a maliciously crafted D-Bus message trying to get the
system helper to crash.
2020-11-02 09:23:49 +01:00
Phaedrus Leeds
c9cb2752ee system-helper: Make uninstall auth message friendlier
Currently when a polkit prompt is created for an app uninstallation, the
message is something like "Authentication is required to uninstall
app/us.zoom.Zoom/x86_64/stable" which is not very friendly for
non-technical users. Change it to "Authentication is required to
uninstall Zoom".

For many of the other polkit actions used by the system-helper, we just
say "software" rather than specifying the app/runtime, since we use the
authorization from one action for others via imply annotations, so the
user is really authorizing several things at once in some cases. In the
case of app-uninstall actions, the only implied action is
runtime-uninstall, and runtimes aren't something users should generally
have to worry about anyway, so it seems alright to specify the app. I
presume that was why commit 21f845c1a didn't remove the ref from the
app-uninstall action message.
2020-11-02 09:23:49 +01:00
Yuri Chornoivan
df0362f012 Update Ukrainian translation 2020-11-02 08:54:45 +01:00
Phaedrus Leeds
08f3f1efb7 Merge pull request #3911 from flatpak/txn-auth-docs
transaction: Fix docs around op authentication
2020-10-30 10:25:07 -07:00
Phaedrus Leeds
08e55a36aa transaction: Fix docs around op authentication 2020-10-29 20:26:08 -07:00
Alexander Larsson
a0dd41d8c4 docs: Add initial document describing the flatpak summary files. 2020-10-29 17:19:47 +01: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
Mejans
2c22604f9b Adds Occitan 2020-10-29 16:12:08 +01:00
Mejans
fa8f3735eb First commit for Occitan language 2020-10-29 16:12:08 +01:00
Phaedrus Leeds
835d2c78e6 testlibrary: Tweak one of the tests to avoid CLI
It seems cleaner to use library API than the CLI here.
2020-10-29 16:08:39 +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
Phaedrus Leeds
ea7b262049 CI: Ignore some paths that don't affect build
No need to waste resources running every test after the README
changes.
2020-10-29 16:07:56 +01:00
Alexander Larsson
b8db46d0e2 tests: Add some tests for subsummaries 2020-10-29 15:30:35 +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
97099bde37 CI: Build ostree from git (needed for new summary format) 2020-10-29 15:30:35 +01:00
Alexander Larsson
a60e2cbe2d Remove some unused variables 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
f147df908a repo: Support indexed summaries in existing code and add new support
If indexes are available we now use those. Also we now allow listing
subsummaries and filtering by subset prefix.
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
caa1c8c839 table printer: Add some helpers
Allow looking up pre-existing rows (by key) and appending to existing
cells.
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