Commit Graph

574 Commits (9989188a1ea7d49e218472cd2f64f0abb24b345e)

Author SHA1 Message Date
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 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 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 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 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 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 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
Matthias Clasen 776f3b17b9 Merge pull request #922 from chergert/wip/chergert/fix-855
flatpak-enter: warn when not running as root
2017-07-14 16:03:26 -04:00
Matthias Clasen 941caede42 Merge pull request #921 from ramcq/missing-app-crash
fix crash in flatpak info when app is not present in origin
2017-07-14 13:57:20 -04:00
Robert McQueen 230e18db7b fix crash in flatpak info when app is not present in origin 2017-07-14 12:21:32 +01:00
Robert McQueen 5fccf0cc0d remote-add: also ignore resolver errors
Resolver errors are more likely in offline remote adds than IO
errors. Catch them first when we're downgrading metadata update
errors to a warning.

https://phabricator.endlessm.com/T17172
2017-07-12 18:43:21 +01:00
Robert McQueen f2dbaecf86 allow remote add to succeed when offline
Updating the metadata at the end of adding a remote means that it fails
if we're offline, even if we have the .flatpakrepo file available.
Unlike the other error cases in the process, which mean the operation
really has messed up, the remote is actually usable even if the
metadata update fails, because future operations will grab the
summary and any new metadata - so we should change this to a warning
to allow the operation to succeed when we're offline.

https://github.com/flatpak/flatpak/issues/917
2017-07-12 11:20:26 +01:00
Christian Hergert 7bf60270fe flatpak-enter: warn when not running as root
Currently, all conceivable configurations and installations of
flatpak require root to perform this operation. That may not be
the case in the future, but until then, we should warn when the
user is not root as the operation will fail.

Fixes https://github.com/flatpak/flatpak/issues/855
2017-07-09 14:27:26 -07:00
Matthias Clasen ed08538f92 Merge pull request #900 from pwithnall/lan-and-usb-preparation
LAN/USB preparation refactoring
2017-07-08 20:54:28 -04:00
Matthias Clasen 261ff03b63 Merge pull request #907 from smcv/metadata
Document all metadata groups and keys
2017-07-07 17:50:15 -04:00
Philip Withnall 81301f0ef4 general: Remove trailing \n from GLib log messages
The GLib logging framework automatically appends a \n to messages, so it
doesn’t need to be added by callers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-07 17:18:24 +01:00
Simon McVittie 489bfddfb3 common: Add and use constants for flatpak-metadata(5) groups and keys
This makes it easier to avoid typos, and also makes it easier to see
what groups and keys are in use. In the header file, they are
clustered according to the group in which the keys are used.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 16:06:21 +01:00
Philip Withnall f47a696392 build: Add AM_* variables to all per-target special variables
For example, add $(AM_CFLAGS) to mumble_CFLAGS. Since $(WARN_CFLAGS) is
only added to $(AM_CFLAGS), this fixes the lack of inclusion of the
compiler warning flags in the compilation of half of flatpak.

Note that $(AM_*) variables are only used by automake if a more specific
(per-target) special variable is not defined instead. So if you define
mumble_CFLAGS, AM_CFLAGS will not be used for that target unless
explicitly included in mumble_CFLAGS.

See
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html.

Do the same for $(AM_LIBADD), $(AM_LDFLAGS), etc. These are not
currently defined, but it’s good practice to include them in
mumble_LIBADD (etc.) just in case they’re defined in future. Hopefully
their inclusions will be cargo-culted to any new targets which are
added, retaining full coverage of the code base.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Philip Withnall 548f60ebc0 general: Add missing `static` modifier to various local methods
The compiler warning flag which was supposed to warn about this was not
being included in the CFLAGS for these targets. That will be fixed in an
upcoming commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 14:41:21 +01:00
Philip Withnall 4ffe706cd9 app/repo: Use utility function to load repository summary
Rather than reinventing the code.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 14:41:01 +01:00
Matthias Clasen a80a1b9bb2 Merge pull request #896 from pwithnall/missing-n
app/build-export: Add missing N_() around a translatable option
2017-07-05 12:48:14 -04:00
Philip Withnall 574f3692ec app/build-export: Fix gcc warning about too many arguments for printf
Drop the spurious final argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-05 15:56:43 +01:00
Philip Withnall c4228fac67 app/build-export: Add missing N_() around a translatable option
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-05 15:51:02 +01:00
Philip Withnall a8ad392750 common/dir: Factor out common code for getting repo metadata
There are several places which query keys in the metadata in the summary
file. Factor out a common function to do that, and write it in such a
way that it could be extended to read the metadata from somewhere else
in future (the plan being that metadata will move to an ostree-metadata
branch rather than the summary file).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 16:06:50 +02:00
Philip Withnall 2c931a9267 app/repo: Factor out common GVariant operation
Factor out a common GVariant child getter from all the print_*()
functions. This will make upcoming changes a little easier to integrate.

This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 10:17:34 +02:00
Alexander Larsson 06b14a8960 export: Record flatpak version in default commit version 2017-06-20 09:45:26 +02:00
Alexander Larsson 504a3a25ea info: Make --show-metadata machine parseable
This is useful mainly to parse the keyfile, and is not very
nice for pretty output.
2017-06-19 10:58:09 +02:00
Alexander Larsson e5aa73f4a5 build-export: Canonicalize file permissions
This canonicalizes the file modes for directories to 0755, and
for files to 0755 for executables or 0644 otherwise.

This means we never get files/dirs writable by non-root in the
system repo, and we never get setuid/setgid/sticky-bit, all
which could potentially be a problem if we store them in the
system repo.

See https://github.com/flatpak/flatpak/pull/837 for some discussion
about this.
2017-06-08 08:50:46 +02:00
Philip Withnall 9ef301beeb ls-remote: Drop unused variable
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 20:09:07 +01:00
Alexander Larsson 4119de9eae build-commit-from: Don't copy old xa.ref in metadata
This caused installations of the new commit to break because the
first xa.ref was used, which was the old one.
2017-06-05 12:45:20 +02:00
Alexander Larsson e69237f792 Handle app ids with dashes when ignoring locale/debug.
org.foo.foo-bar extensions become org.foo.foo_bar.Locale, etc, so
we need to handle this properly.
2017-05-30 18:07:46 +02:00
Alexander Larsson 005fb63cc0 list/remote-ls: Also ignore .Sources by default 2017-05-30 17:45:12 +02:00
Alexander Larsson d1fae1f476 remote-ls: Don't show Locale/Debug and secondary arches by default.
Locale and Debug extensions, and refs for a secondary arch, when the
primary arch alternative exists, are not shown unless you specify
--all or -a.

This makes the default output more useful.
2017-05-30 17:41:24 +02:00
Alexander Larsson f072d585b0 list: Don't list .Locale and .Debug by default (override with -a) 2017-05-30 17:41:01 +02:00
Alexander Larsson f616ada02b build-update-repo: Remove unwanted deltas before updating summary
The list of deltas is stored in the summary, so we need to delete
them before we generate the summary, not before.

This means there is a short period where people may use the old summary
which references the old, now deleted summaries. However, that is
better than it referencing the deleted deltas forever.
2017-05-30 15:16:12 +02:00
Alexander Larsson aeb31f7941 export: Always set a xa.ref commit metadata
This makes it easier to reverse-map from commits to refs, for
e.g. statistics, but it also in the future will allow use to
not sign the summary and still use the system-helper.
2017-05-22 17:30:04 +02:00
Alexander Larsson 23399ddc35 Use the CLI progress for update --appstream too 2017-05-22 17:01:14 +02:00
Alexander Larsson ea2af15dc0 run: Use new flatpak_find_current_ref helper. 2017-05-22 13:12:01 +02:00
Alexander Larsson 07609559b8 progress: Don't report ??? in the bar while estimating 2017-05-18 15:37:35 +02:00
Alexander Larsson 7ac5d41bea Use the nicer progress reporting for the CLI too
We now use the same progress calculations as in libflatpak
so we get a nice progress bar also in the CLI.
2017-05-18 09:51:35 +02:00
Alexander Larsson 703a0d7900 update: flatpak update --subpath= means all subpaths 2017-05-11 12:44:15 +02:00
Alexander Larsson 3fca1584ff remote-ls: Don't rely on active symlink value, use deploy data
We want to tweak the active symlink value so we can't rely
on this being exactly the commit id.
2017-05-11 12:27:36 +02:00
Alexander Larsson c35bce077f remote-add: Use the new system-helper for initial metadata update
This removes some duplicated code, and also follows the new
redirect-url property on initial add.

This also means we're requiring gpg signatures to be correct
on remote-add, so fix up the tests
2017-05-11 11:20:39 +02:00
Alexander Larsson c6d4330cea export: Add install/download size and metadata to commit
This way we can faster access this when updating the
summary, and also have a way to access this in case we ever
want to not have it in the summary.
2017-05-11 10:09:39 +02:00
Matthias Clasen 3ce8be47a9 Improve error wording
I just saw a confusing error messages that looked like two error
messages just running into each other. Better to end the first
one with a colon when using g_prefix_error.
2017-05-11 08:38:01 +02:00
Matthias Clasen 9998b0e6a1 repo: Print out gpg key hash too
This seems useful, at least it shows that a key is there.
2017-05-10 16:01:24 +02:00
Matthias Clasen c30e00eef2 Make it possible to unset values in update-repo
The underlying setters interpret NULL as 'unset this key', but
we never pass NULL. Since empty strings are not useful values
for title or default-branch or redirect-url, just interpret
an explicit empty value as 'unset this key'. E.g. to unset
the redirect url, use

flatpak build-update-repo --redirect-url= ~/my-repo/
2017-05-10 11:53:01 +02:00
Matthias Clasen 0ea9d93001 repo: Print out redirect url too
This is useful information about a repository, so make
the repo command print it out.
2017-05-10 11:53:01 +02:00