Commit Graph

2986 Commits (9989188a1ea7d49e218472cd2f64f0abb24b345e)
 

Author SHA1 Message Date
Philip Withnall 9989188a1e tests: Add support for collection IDs to test-repo.sh
This adds variable support for collection IDs: they can either be
enabled on the server, on the server and client, or not at all. If
enabled on the server, apps and runtimes are built with collection IDs
and the repository has one set. If enabled on the client, the remote
config is added to the local repository with a collection ID and GPG
verification enabled. They are controlled with
USE_COLLECTIONS_IN_{SERVER,CLIENT}={yes,no}.

These variables are used in the new wrapper tests,
test-repo-collections.sh and test-repo-collections-server-only.sh.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall dd63bdbd61 common: Prevent pulling ostree-metadata unless gpg-verify is true
Add a sanity check and error message which prevents pulling the
ostree-metadata ref (the repository metadata) unless GPG verification is
enabled, as it needs to be signed to be trusted.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 0bbf8f3d21 common: Clarify some error and debug messages in flatpak-dir.c
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall b6828cda31 repo-update: Disallow changing collection IDs
Emit an error message if the user tries to change the collection ID of
an existing repository between two non-empty values. Allow them to set a
collection ID where one was not set before. Changing the collection ID
once it’s already been set will break updates for all clients who have
previously pulled from the repository.

If a developer really wants to change the collection ID for a
repository, they’re going to have to recreate the repository from
scratch.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 5c0eef7bde remote-add: Verify that GPG is enabled if collections are
Emit an error message if a collection ID is specified but GPG is not
enabled, since pulling using collection IDs requires GPG.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 19dbbd5f8c tests: Use AM_TESTS_ENVIRONMENT rather than TESTS_ENVIRONMENT
The latter is reserved for the user to set in their environment. The
former is what the makefile is supposed to set.

See
https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 642a5a81a1 lib/remote: Add getter/setter for collection IDs
This isn’t really used internally, but will be used by gnome-software
for when it configures new flatpak remotes.

This is new public API, but is only declared if compiling with
--enable-p2p.

Includes some basic smoketests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall e5e52b4b79 common/utils: Allow collection-id to be updated from repo config
In order to provide a transition path for repositories to add collection
IDs to themselves and propagate those collection IDs to clients’ remote
configurations, add another repo config key which controls whether the
repository’s collection ID is published. If xa.collection-id is set in
the repo’s published metadata, the client will update its configuration
to the given ID — but only if no ID is set already. This is a one-time
transition to prevent malicious repositories from remotely changing the
user’s configuration to associate their remote with a well-known
collection ID they don’t own.

Add a test for this.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 36c8fdb4a4 common/dir: Support updating collection-id from remote configuration
To allow staged deployment of collection-ID-based repositories,
introduce the code to update a local repository configuration to add a
collection ID to it, based on updated metadata from the remote (as is
currently supported for other configuration keys).

As a security measure, this only allows updating the collection ID from
an empty to a non-empty value. We do not allow collection IDs to be
renamed (or a malicious repository owner could bypass the user’s manual
verification of the collection ID by changing it after the user has
configured an unrelated remote).

The idea is that most repositories should remain without collection IDs
for now, and use this mechanism to set their collection IDs in future,
once the functionality is more stable.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 550ebcc4f9 lib/remote: Add enum GType for FlatpakRemoteType
This will only be built when configured with P2P support. We can’t use
glib-mkenums here, as it doesn’t know about the #ifdef
FLATPAK_ENABLE_P2P which surrounds the enum definition. By manually
writing the get_type() function, we can surround it by #ifdefs as
appropriate.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 959d54df3b system-helper: Fix incorrect whitespace
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall d3f1dccae2 common/dir: Drop an unnecessary wrapper function
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall e972201061 common/dir: Propagate errors from invalid configurations
Rather than silently ignoring them. Note that invalid configurations
are distinct from missing configuration keys.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 358e204fb3 common/dir: Handle NULL out parameter correctly when getting config
ostree_repo_get_remote_option() requires the out parameter to be
non-NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall bc0f90764e common/dir: Fix error handling for flatpak_dir_lookup_repo_metadata()
It can return FALSE with an error set, or FALSE without one set, which
indicates the key was not found.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall bc46274ae4 common/dir: Verify commit bindings when pulling from an untrusted repo
When pulling from a local, untrusted repo (i.e. one which the user
downloaded into, and we want to pull into the trusted system repo),
verify the collection ID and ref bindings in the commit metadata for
each commit.

This is something which is normally done by libostree, but since we’re
rewriting the commit manually, we’re bypassing that part of the pull()
code path.

This is an inlined version of the check from verify_bindings() in
libostree.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall c4819af5a0 common: Support collection IDs for related refs and extensions
Add support for collection IDs to the code which finds and pulls
related refs and other extensions.

Currently, related refs must have the same collection ID as the parent
ref — this is the most likely scenario anyway. In future, it should be
possible to extend the code to support pulling related refs from other
collections.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 26eb76637d common/utils: Add collection ID support for appstream/* branches
Also add collection and ref binding metadata to the generated appstream
commits, so they can be verified when using unsigned summary files.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall b9986a7979 common/dir: Add some FIXMEs for future improvements to collections
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall e9765b82cf common/dir: Remove an unused method
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 2143e5984a common/dir: Factor out a helper function to get a remote’s collection ID
We need to consistently handle the case where the collection ID is set
to the empty string (and treat it the same as if it were unset). Best
done in a helper function.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall a220fd3cd3 app/repo: Load repository metadata from ostree-metadata ref if possible
Newer repositories will store metadata there, rather than in the summary
file (although the summary file will still be updated where possible for
backwards compatibility).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 4cb47a2112 tests: Add a test for unsigned summary support
This relies on peer to peer support also being enabled; the test is
skipped otherwise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 024d835460 common: Support unsigned summary files and separate repo metadata
In order to eliminate some race conditions around updating the
summary{,.sig} file on the server, and to decouple signing the summary
from signing commits, and to support peer to peer mirrors of content
from multiple upstream collections: add support for unsigned summary
files.

This relaxes the requirement for gpg-verify-summary=true iff
collection-id is set in a remote’s local configuration. It depends on
some pending libostree changes to verify the ref for each commit using
the commit’s signed metadata. See
https://github.com/ostreedev/ostree/issues/983.

Metadata storage has moved from the summary file to a new
ostree-metadata well-known branch on each repository, since this can be
signed for each update and for each collection separately. If the
collection-id is set in a remote’s local configuration, flatpak will
retrieve all repository metadata from this branch rather than from the
summary file. If collection-id is unset, it will ignore this branch and
continue to use the summary file, which will continue to be updated (and
externally signed as summary.sig) for backwards compatibility.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall ae7d960372 common: Support collection IDs in flatpak{ref,repo} and bundle files
These are loaded from the ref/repo/bundle metadata and added to the new
remote configuration.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 4c395cec13 lib/ref: Add collection ID support to FlatpakRef
This adds a new collection-id property which is only enabled if
FLATPAK_ENABLE_P2P is defined. The internal machinery for handling it is
always enabled, to reduce the amount of #ifdef spam.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 5b002edf06 builder: Add collection ID support to the flatpak builder
Pass a --collection-id argument through to `flatpak build-export`.

Also add a ‘collection-id’ property to manifest files, which can be used
to set the collection ID on an exported repo (when using --repo) without
having to provide a command line option.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall f3c898da05 app: Add support for collection IDs to built-in flatpak commands
This sets the collection ID on remote configs and in commit metadata
when building flatpaks.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall b5860e8f2a common/utils: Add flatpak_repo_set_collection_id() helper method
It will be used by builtins-repo-update in a following commit to allow
updating the collection ID for an upstream repo.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 68ab12fce1 lib: List dynamic remotes in flatpak_installation_list_remotes()
Also expose a new flatpak_remote_get_remote_type() API so that users can
query what type of remote something is — whether it’s a USB or LAN
remote, or something statically configured.

Make this all conditional on compiling with --enable-p2p.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 30a5cf8136 common: Support collections in check_for_updates() and forward the results
Search for updates on peer to peer sources as well as the internet in
check_for_updates(), and pass the resulting OstreeRepoFinderResult array
to the pull() calls, so a consistent set of checksums are pulled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 0d6455aa5f common/dir: Support new experimental libostree API for finding remotes
This adds support in flatpak-dir.c for using the new libostree API for
finding remotes dynamically for a given set of refs, if flatpak is
configured with --enable-p2p.

The new code paths are only taken if the repository is configured with
a collection ID set.

These changes by themselves aren’t sufficient for full P2P support, as
all the infrastructure for downloading summary files and finding refs
needs to be modified in the following commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall 655e7ce5c3 build: Add an --enable-p2p configure option for the peer to peer feature
A series of following commits will introduce a peer to peer feature for
pulling apps and runtimes from LAN peers and USB sticks without needing
an internet connection. This requires experimental API in libostree
(which needs to have been configured with --enable-experimental-api), so
needs to be hidden behind a configure option in flatpak too. It’s called
--enable-p2p, and bumps our libostree dependency to 2017.8 with
experimental API required too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Alexander Larsson f9a06a0fcd builder: Add --install-deps-from=REMOTE
This allows you to automatically install/update dependencies required
by the manifest. The dependencies include:
 Runtime, Sdk, Base, Sdk Extensions and Platform Extensions

There is also a --install-deps-only switch to make the build
stop after the dependencies are installed.

Fixes https://github.com/flatpak/flatpak/issues/955
2017-08-18 11:04:13 +02:00
Alexander Larsson 4e15d9a5f8 common: Add GSubprocessFlags to flatpak_spawnv
This is useful to e.g. hide stderr
2017-08-18 10:56:15 +02:00
Alexander Larsson 85ba1f75eb Require ostree 2017.10
This includes a change in how ostree reports missing gpg signatures
which makes the test-suite pass. Additionally that change requires
us to change how we detect such missing gpg signatures in one place.

We could try to support both versions, but the easiest fix is to just
require the latest ostree.
2017-08-15 18:41:44 +02:00
Matthias Clasen a2267359ed Merge pull request #965 from pwithnall/coverity
Various minor Coverity fixes
2017-08-15 08:28:30 -04:00
Philip Withnall cd2a555675 common/dir: Clarify the nullability of some variables
flatpak_decompose_ref() can fail, but in this situation we know it won’t
since find_matching_refs() checks it for us and hence guarantees that it
only returns decomposable refs. Add some assertions to make this clearer
and to shut Coverity up.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:28:28 +01:00
Philip Withnall c157719616 common/dir: Avoid a potential NULL pointer dereference
Everywhere else that index->manifests is used, it’s checked for being
NULL beforehand, which probably means that, sometimes, it might be NULL.
Let’s check that here too.

Coverity issue: 1452432

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:27:28 +01:00
Philip Withnall ecbf42d7fa builder/utils: Remove an unnecessary if-condition
We unconditionally allocate s above, so it can’t be NULL.

Coverity issue: 1376586

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:26:05 +01:00
Philip Withnall 0cd65edc8b builder/module: Drop some unreachable code
use_builddir is TRUE if meson is TRUE, so there can never be a meson
case in the !use_builddir case.

Coverity issue: 1452428

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:24:01 +01:00
Philip Withnall 2106b80965 builder/module: Fix a crash if realpath() fails
If realpath() fails (unlikely) it returns NULL, which we later merrily
dereference. Fix that by taking the unexpanded path.

Also fix a minor indentation problem later on.

Coverity issue 1452435.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:22:45 +01:00
Philip Withnall 4bb3f4da36 builder/context: Add a missing va_end() call
This prevents a resource leak, although not really in practice because
va_args are free on common platforms.

Coverity issue 1452430.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:16:16 +01:00
Jonathan Lebon bb3ff4ac46 ci/build.sh: also install git 2017-08-14 16:05:59 +02:00
Jonathan Lebon 23b496f74f ci: bump tests to use F26 host & container 2017-08-14 16:05:59 +02:00
Matthias Clasen 2082b50871 Merge pull request #910 from matthiasclasen/language-config
Allow setting the locale subpaths in repo config
2017-08-04 01:57:06 +01:00
Matthias Clasen 1f60624472 Merge pull request #948 from pwithnall/build-system-helper
system-helper: Ensure template files are always distributed
2017-08-04 01:50:05 +01:00
Philip Withnall 4fb3f71475 system-helper: Ensure template files are always distributed
Previously they weren’t getting distributed unless the system helper was
enabled at configure time for distcheck. They should be distributed
unconditionally so the user can choose whether to enable the system
helper when they call configure.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-03 16:50:22 +01:00
Matthias Clasen ea0fc59119 Merge pull request #939 from piotrdrag/potfiles-update-170730
Update POTFILES.in
2017-07-31 13:25:52 +01:00
Matthias Clasen e40c736b3b Merge pull request #943 from handsome-feng/master
fix issues #942
2017-07-31 13:22:38 +01:00