Commit Graph

1823 Commits

Author SHA1 Message Date
Alexander Larsson
b28271bb5e Merge pull request #3498 from alexlarsson/use-symlinks-for-sideload-config
Use symlinks instead of xa.sideload-repos config option
2020-03-30 16:03:54 +02:00
Alexander Larsson
8cf75df52a dir: Rename variable to make things clearer 2020-03-30 15:37:26 +02:00
Alexander Larsson
c9878f040e dir: Add define for "sideload-repos" dir name 2020-03-30 15:36:54 +02:00
Alexander Larsson
527e6b247b Pass token to using flatpak_dir_fetch_remote_commit() when available 2020-03-30 15:03:55 +02:00
Alexander Larsson
0ef69c96db http-utils: Rename flatpak_load_http_uri to flatpak_load_uri and support file:
Various places (like the new load-commit-for-extra-data-setup) needs to
support file: uris, lets make it available generically.
2020-03-30 15:00:51 +02:00
Alexander Larsson
6deb23a322 extra-data: Simplify extra-data progress setup
We need to get the commit object to setup the extra-data progress information,
and this is currently done using a complex pull operation to a temporary
repo. According to https://github.com/flatpak/flatpak/issues/3515 it
even causes an unecessary download of the summary in some cases.

Now that we don't need to support p2p we can instead directly download
the commit object using a simple http operation (or from the sideload
repos), as we know the commit id at this point anyway.
2020-03-30 13:24:15 +02:00
Alexander Larsson
e2c8838cea Merge pull request #3482 from abderrahim/flatpak-progress
Add a FlatpakProgress object
2020-03-27 17:43:31 +01:00
Alexander Larsson
c222f03c10 FlatpakProgress: Clean up APIs for handling extra data
We don't need to keep recalculating the nr of extra_data items remaining.
We know the initial value and can just decrement it each time one
completes.
2020-03-27 17:23:13 +01:00
Alexander Larsson
ed3ba39a06 Fix calculation of extra-data total size
This is a bug introduced in b03916f5bd
where we check the extra_data refs against app/ or runtime/ prefix with
arguments in the wrong order.
2020-03-27 17:21:17 +01:00
Alexander Larsson
b7f0c17762 FlatpakProgress: Handle NULL in most methods
I noticed several places in flatpak-dir.c that didn't check for
NULL progress, so lets move the check inside the implementation so
we can ensure its always checked.
2020-03-27 16:04:36 +01:00
Alexander Larsson
52224b0463 FlatpakProgress: Move default value into FlatpakProgress 2020-03-27 16:04:36 +01:00
Alexander Larsson
b1b1a6e568 FlatpakProgress: Free the GMainContext 2020-03-27 14:45:57 +01:00
Alexander Larsson
4ef12c5bc9 FlatpakProgress: No need to allocate FlatpakMainContext
We store it on the stack instead and free with
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC.
2020-03-27 14:44:00 +01:00
Alexander Larsson
a529c149ca FlatpakProgress: Use uint for bitfields
gboolean is int which is signed, and that is not good for bitfields
2020-03-27 14:40:22 +01:00
Abderrahim Kitouni
192d31d315 Add a FlatpakProgress object
To avoid the complexities of passing (and chaining) OstreeAsyncProgress
objects around, we only create one just before calling to ostree.
The rest of flatpak only ever uses the new FlatpakProgress object.

Co-authored by: Philip Chimento <philip@endlessm.com>
2020-03-26 21:09:19 +01:00
Simon McVittie
1fd42ab660 common: Only run variant-schema-compiler once
A make rule like

    a b: x y
            command

does not mean "run command to generate a and b from x and y". Instead,
it means "run command to generate a from x and y", and, separately,
"run command to generate b from x and y". In a parallel build this
could mean that we try to run the variant-schema-compiler twice, in
parallel, with the output from each run overwriting the other.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-26 16:03:17 +01:00
Simon McVittie
7ad756c77b common: Add variant-schema-compiler output to nodist SOURCES
This means it doesn't go into dist tarballs, and we don't need to add
it to BUILT_SOURCES and CLEANFILES separately because it's already
there.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-26 16:03:17 +01:00
Simon McVittie
09f05a6f87 dir: Format 64-bit ints correctly
%ld is only 32 bits long on ILP32 (32-bit) platforms.

This partially addresses #3499.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-26 11:38:13 +00:00
Alexander Larsson
75f23be46e Merge pull request #3488 from smcv/really-deprecate
Really deprecate functions deprecated in 102c710b
2020-03-26 11:53:26 +01:00
Alexander Larsson
15c761d482 Use symlinks instead of xa.sideload-repos config option
Instead of having a global config option we scan a directory for
symlinks into the sideload repos. These come from
/var/lib/flatpak/sideload-repos and /run/flatpak/sideload-repos (for
default system installation).

This is much easier to update atomically, and the two different
options are useful for persistant (the first) or dynamic (the second)
usescase.

Fixes https://github.com/flatpak/flatpak/issues/3494
2020-03-26 11:50:54 +01:00
Simon McVittie
8d25ecf2e1 transaction: Remove a stray debugging message
I assume this isn't meant to be user-facing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-25 20:04:20 +00:00
Simon McVittie
6ba07613b4 installation: Formally deprecate deprecated methods
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-25 12:56:56 +00:00
Simon McVittie
2d3642931d installation: Fix typos in deprecations
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-25 12:45:04 +00:00
Alexander Larsson
05eba2b32c Merge pull request #3474 from flatpak/wip/hadess/more-similar-appids
common: Allow version numbers in app-id for DConf migration
2020-03-25 09:57:43 +01:00
Alexander Larsson
aa6d9550c1 Merge pull request #3476 from alexlarsson/drop-p2p
Drop support p2p in favour of simpler side-loading scheme
2020-03-25 09:54:41 +01:00
Alexander Larsson
59d34280b9 lib: Only support FLATPAK_REMOTE_TYPE_STATIC remote types
With the new sideload support usb sideload works differently, they don't
appear like separate remotes. Its just the normal remote and installs
from it will automatically work. However, to list just the sideloadable
refs we point the docs to the new ONLY_SIDELOADED flag.
2020-03-25 08:52:28 +01:00
Alexander Larsson
c092fa4cb7 installation: Reimplement flatpak_installation_list_installed_refs_for_update
Instead of doing a lot of FlatpakInstallation calls we do lower level
FlatpakDir calls, sharing a single RemoteState per remote for the
entire operation. Also, some parts of the checks are moved to FlatpakDir
as flatpak_dir_check_if_installed_ref_needs_update()
2020-03-25 08:27:18 +01:00
Alexander Larsson
102c710b39 FlatpakInstallation: Mark non-transaction install/update ops deprecated
These versions still work, but they don't do neearly as much as you'd
want (depdendencies and whatnot), so document this.
2020-03-25 08:20:18 +01:00
Alexander Larsson
1117f0d872 lib: Add new FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED option 2020-03-24 20:18:57 +01:00
Alexander Larsson
56158a0087 DeployData: Add commit timestamp to deploy data
We want to use this to do quick checks if we need to do an update.
2020-03-24 20:12:50 +01:00
Alexander Larsson
83795c210c Remove unused variable 2020-03-24 17:29:19 +01:00
Alexander Larsson
9c6bdc5bfd dir: Add flatpak_remote_state_load_data() function
This is similar to lookup_cache() but it also works for
sideloaded refs. Additionally it returns an allocated metadata
pointer rather than a pointer to the cache.

Also convert some callers to use this when it makes sense.
2020-03-24 16:15:23 +01:00
Alexander Larsson
8999e70c4a RemoteState: Try the sideload paths even for local-only states
This is so we can use these for listing sideloaded refs.
2020-03-24 16:13:24 +01:00
Alexander Larsson
a843d2d594 sideload: Add api and CLI support to specify sideload repos dynamically 2020-03-24 14:01:20 +01:00
Alexander Larsson
e4df0fa6a6 sideload: Support pulling individual objects from sideload repos
We use the localcache-repos option to ostree_repo_pull to make ostree
directly import any files that are locally available in the sideload
repo even when pulling the main commit from upstream.

This also adds a test that verifies that such files are not
pulled via http.
2020-03-24 11:46:33 +01:00
Alexander Larsson
9cf2ee7324 dir: Resolve extra-data setup from sideload repo too 2020-03-24 09:16:11 +01:00
Alexander Larsson
d30e902d9f Add build-update-repo --deploy-sideload-collection-id option
This is a new version of --deploy-collection-id that only applies
the collection id update for new (1.7.x+) version of flatpak clients.
This allows you to enable collection ids for sideload use but not
affect older clients where the p2p codepaths are not as tested.
2020-03-23 17:58:04 +01:00
Alexander Larsson
9208913664 Migrate config: Always enable gpg-verify-summary if collection id is set
This used to not be set for collection-id remotes as we used the
ostree-metadata branch for resolving. However, we now use the summary
always when doing a remote install (and not ostree-metadata for local
sideloads), so we still want to verify summary.

The signature on the summary is a nice security feature, but it is also
a very efficient small file to download to verify that no new summary
needs to be downloaded in the no-op update case.
2020-03-23 17:58:04 +01:00
Alexander Larsson
b3da5db1c3 update: Allow update --commit to install from sideloaded repo 2020-03-23 17:58:04 +01:00
Alexander Larsson
9abbb00b33 Drop xa.sideload-collection remote option in favour of regular collection-id
Nothing fundamentally happens differently in ostree if the collection-id
is set, as long as we don't call the p2p specific apis. So, lets keep
using it instead of adding our own special magic.
2020-03-23 17:58:04 +01:00
Alexander Larsson
316baff539 Don't enforce gpg-verify false when using collection id
With the new sideload approach to collection ids it is fine to require
gpg signed summaries. (Not for the child repos or the sideload repos
though, but thoser are either trusted (sideload) or safe for other
reasons like ref-bindings and signed commits).
2020-03-23 17:58:04 +01:00
Alexander Larsson
2ac6be91f3 Change how we handle refs in child-repo for system installs
We used to to do a MIRROR pull and make a copy of the upstream summary
file in the child repo. However, now that we want to allow side-loading
from a repo with a partial summary we can no longer do that.

So, the new approach is that the child repo *always* contains
"remote:ref" style refs (never heads or mirror/collection-id refs),
but in order to not let you import a signel commit into the wrong ref
name we now require the commits to have a ref-binding (they all do
since a long time anyway).
2020-03-23 17:58:04 +01:00
Alexander Larsson
bea879c0d0 FlatpakRemoteState: Drop separate tracking of metadata
We now always use the metadata from the summary, so no need
to track it separately.
2020-03-23 17:58:04 +01:00
Alexander Larsson
124b0be92e Drop more collection_id use
Most code that looks for a regular collection id set on the remote is
removed, as these should never happen in flatpak repo setups now.

Some is replaces with looking at xa.sideload-collection-id:
 * The libflatpak FlatpakRef::collection-id property now comes comes from the sideload id
 * Various CLI commands showing or changing the collection-id for a remote now uses the sideload id
 * Collection id deploy in update now sets the sideload-collection-id instead
 * Setting the collection id for a remote in libflatpak now sets the sideload id

Additionally we now delete the code that allows unsigned summaries
when there is a collection id (because there is none).

create-usb now uses the sideload id as as collection id source when exporting.

The direct repo operations (export, bundle, commit-from) still support
collection ids, because on the server we do want to set it so that we
can sideload.
2020-03-23 17:58:04 +01:00
Alexander Larsson
336a127f55 Support sideloaded repos
This adds a xa.sideload-collection-id option to the remote
configuration and a global xa.sideload-repos option (which is a list
of paths to local repos).

When resolving or listing refs, if we fail to download the real remote
summary (i.e. we're offline) then we instead look into the configured
sideloaded repos for refs that match ref and the sideloaded collection
id for the remote.

For the transaction to resolve the ref we need more metadata. In the
regular summary case we use the metadata from the summary, but that
is not available in the (partial) summary in the sideload repo, so
there we load the actual commit object and use the data from there.
(The ostree-metadata branch is not used/needed.)

This actually also fixes a longstanding issue when you "flatpak update
--checksum=XYZ" because we now handle this correctly by downloading
the commit object from the remote. Before we used the metadata in the
summary which is not right for non-HEAD commits.

To handle the sideloading we record the path to the sideload repo
when sideloading and pass the url to the repo as the remote name
when pulling, which will do a direct local pull.

We avoid using sideloaded refs when offline if the timestamp in the
commits is older than what is already installed locally.
2020-03-23 17:58:04 +01:00
Alexander Larsson
9061b855d8 Initial remove of p2p codepaths
This removes the most basic codepaths for p2p installation, as well
as the tests for it. There still remains various codepaths that
looks as the collection id, these will be removed later.

This is the first step in dropping the p2p code and replacing it with
a simpler approach that focuses on the sideloading case only.
2020-03-23 17:58:04 +01:00
Alexander Larsson
116a8b8487 transaction: Ensure the metadata in the pulled commit matches what we resolved
We're using the metadata from the summary, ostree-metadata or available
commit when making security sensitive decisions, so lets verify this
matches what we get in the actual commit we pulled.

We already did check that this then actually also matches what gets deployed,
so the new check shares code with that.

Note, we don't do this for OCI installs, because it seems the current
fedora flatpaks don't have this set, and we don't want to break
existing remotes.
2020-03-23 17:58:04 +01:00
Alexander Larsson
83ef801537 dir: Add flatpak_deploy_data_has_subpaths() helper 2020-03-23 17:58:04 +01:00
Matthew Leeds
5560132ba6 flatpak-utils-http.c: Add retry logic for transient failures
Currently if flatpak is installing an extra data app such as Spotify and
the server with the .deb file fails to complete the request, the
installation fails with a message like "Connection terminated
unexpectedly". This commit makes flatpak instead try 5 times to download
a given URI if the error returned seems like a transient one (so not,
for example, 404 not found). This is analogous to what was done in
libostree in commit 938055392fd455027a69398c441b992ae521aa87, and we use
some code from there.
2020-03-20 15:47:18 -07:00
Matthew Leeds
0b25455af1 flatpak-utils-http.c: Use more specific GIOError codes
Instead of defaulting to G_IO_ERROR_FAILED, use more specific codes when
we can. These were copied from libostree.
2020-03-20 13:46:36 -07:00