Commit Graph

207 Commits

Author SHA1 Message Date
Iceyer
1cea02a2f6 common: Fix division by zero when calculate progress
Closes: #1331
Approved by: alexlarsson
2018-01-23 09:22:36 +00:00
Matthew Leeds
bc2534fbd5 common: Fix memory leak in flatpak_number_prompt
Closes: #1206
Approved by: alexlarsson
2017-11-28 14:35:46 +00:00
Patrick Griffis
3b78dc66c3 Add "have-intel-gpu" check, useful for VAAPI extension
Closes: #1198
Approved by: alexlarsson
2017-11-24 11:17:47 +00:00
Patrick Griffis
bc3e464051 Automatically install active Gtk theme if found
Closes: #1181
Approved by: alexlarsson
2017-11-21 09:56:05 +00:00
Alexander Larsson
bd118ff528 OCI: Add support for system-helper with new OCI approach
Since we don't have GPG signatures for the OCI images we verify
the data sent by the client by doing a query to the index from
the helper to ensure that the ref/digest tuple is correct.

Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Alexander Larsson
d6ea398dd5 Remove GPG signatures handling for OCI images
This is not really standardized for now, and most registries
depend on TLS security instead.

Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Alexander Larsson
c3b155b09a Use the new metastore index API for OCI remotes
This means the url of the remote is a service supporting:
 https://github.com/owtaylor/metastore/blob/master/docs/protocol.md

And we use that to find all flatpak images and the repository url
itself.

This also add support for docker-v2 registries that support OCI
images.

Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Gunnar Andersson
98c21473fc Fix whitespace issues (remove TAB usage)
Signed-off-by: Gunnar Andersson <gandersson@genivi.org>

Closes: #1107
Approved by: mwleeds
2017-10-17 06:21:07 +00:00
Alexander Larsson
87ed5378db Add missing translation markers
As mentioned in https://github.com/flatpak/flatpak/issues/1102 we
lack translations for some strings. This fixes the ones i found in
a quick check.

Closes: #1106
Approved by: mwleeds
2017-10-16 19:03:06 +00:00
Alexander Larsson
c763295944 common: Add flatpak_subpaths_merge
This merges to subpath sets, which is useful if two sets are
specified from different sources.

Closes: #1098
Approved by: alexlarsson
2017-10-11 12:48:07 +00:00
Alexander Larsson
62760761b7 common: Clean up the locale detection
This is mostly a cleanup of some code and extracting common code to
helper functions. But additionally, we switch the xa.languages config
value to be a list of languages, rather than dirs, although for
backwars compat we still support if it specifies dirs.

Closes: #1098
Approved by: alexlarsson
2017-10-11 12:48:07 +00:00
Alexander Larsson
f6658ad712 Use the new glnx glnx_autofd name for glnx_fd_close
This is a lot clearer

Closes: #1091
Approved by: alexlarsson
2017-10-09 10:19:00 +00:00
Alexander Larsson
aec35fd9d9 Make --verbose a counting argument, specify twice for more info
Closes: #1077
Approved by: alexlarsson
2017-10-05 07:29:31 +00:00
Alexander Larsson
e759819c5d Fix uninitialized variable read if stdout is not a tty
This showed up when running the tests in valgrind, where
ioctl (STDOUT_FILENO, TIOCGWINSZ) fails. We fall back to 80 chars
in this case.

Closes: #1079
Approved by: cgwalters
2017-10-04 15:43:59 +00:00
Philip Withnall
166a4e144d common: Don’t commit arbitrary files into the ostree-metadata branch
When building the ostree-metadata branch (which only happens when
configured with --enable-p2p), we are supposed to create empty commits
which contain only metadata. However, the code to do this was wrong, and
was instead pulling in all the files from the current working directory
and committing them.

Fix that code to actually create an empty commit.

This could have been a fairly serious bug were it not for the fact that
nobody’s using this code because it’s all experimental.

Spotted as part of https://github.com/ostreedev/ostree/pull/1158.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1066
Approved by: alexlarsson
2017-10-04 12:54:30 +00:00
Matthew Leeds
71f4a87f51 dir: Print debug output when opening flatpak dirs
It's easy to end up with multiple flatpak installations on a system, and
it's not always clear which one(s) flatpak is using. So this commit adds
some debug output in some cases when flatpak opens an installation
directory such as /var/lib/flatpak. This is especially important for
people who build flatpak themselves because if you omit --prefix=/usr
or use --with-system-install-dir your flatpak will look in non-standard
locations like /usr/local/var/lib/flatpak.

If we were to print this every time a flatpak directory is opened, it
would flood the log. So instead add a utility function and use it
strategically. Many flatpak commands will log the directory when they
use flatpak_option_context_parse(), others in
flatpak_find_deploy_for_ref(), and for others the logging has been
added manually.

Closes: #1067
Approved by: alexlarsson
2017-10-04 12:39:43 +00:00
Alexander Larsson
5cd8db035b common: Add flatpak_switch_symlink_and_remove
This creates a symlink pointing to a target, but if the symlink
already exists, it ensures (atomically) that the previous target
is deleted. This is useful to keep a single-item cache around.

Closes: #1073
Approved by: alexlarsson
2017-10-04 10:27:14 +00:00
Alexander Larsson
acdf869693 common: Add commit id to FlatpakExtension
Closes: #1069
Approved by: alexlarsson
2017-10-03 08:01:46 +00:00
Alexander Larsson
b35177e4bf appstream update: Don't skip all arches if one is unchanged
Move skip_commit from a function global to a per-loop variable so
that it is reset for each architecture.
2017-09-26 16:34:30 +02:00
Alexander Larsson
c3cfc4aa78 Remove unused variables 2017-09-26 11:58:44 +02:00
Alexander Larsson
98d3a58129 Update to latest libglnx and update tmpfile use for api change 2017-09-22 12:38:10 +02:00
Alexander Larsson
07d62fb86e generate_appstream: Add debug output when skipping commit
This might help us debug a weird behaviour on flathub where
it was never updating the appstream.
2017-09-19 16:34:26 +02:00
Philip Withnall
2faffecc42 common/utils: Fix is_number("") to return FALSE
Previously, it was possible to enter ‘ ’ (a space) at a number prompt,
and it would be stripped, passed to is_number() (which would erroneously
return TRUE), then passed to strtol() and the return value used
unconditionally.

Fix that by fixing is_number() to return FALSE for the empty string.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-09-18 15:36:24 +02:00
Alexander Larsson
75c2db1a73 Fix some leaks
g_variant_dict_end() returns a floating reference, we have to
sink it before using it with a g_autoptr.
2017-09-14 13:07:12 +02:00
Matthew Leeds
037a13cde0 completion: Make filename completions smarter
Many flatpak commands only work on *.flatpak or *.flatpakref files, so
the bash auto completion showing every file is distracting and
unnecessary. This commit makes flatpak only show relevant files when
possible by using the "-G globpattern" compgen option.
2017-09-12 16:14:43 +02:00
Alexander Larsson
4178fbdc09 update-repo: Ensure we commit the appstream data with canonical permissions 2017-08-28 11:39:17 +02:00
Alexander Larsson
18451644ff Update to latest libglnx (and fix some callers) 2017-08-18 15:34:29 +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
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
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
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
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
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
handsome_feng
c9de78fe34 fix issues #942 2017-07-31 17:44:26 +08:00
Matthias Clasen
f71655a5f8 Fix flatpak_summary_match_subrefs
We were checking the prefix twice here, instead of
checking prefix and suffix, which was obviously the
intention.

This caused extensions with non-matching architectures
to be reported as related refs.
2017-07-09 10:39:47 -04: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
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
Philip Withnall
315edcfc41 common/utils: Use a hash table as a set in the recommended way
Use g_hash_table_add() so that GHashTable can internally optimise for
use as a set, which results in slightly simpler code for the caller, and
slightly less memory usage overall.

This introduces no functional changes.

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
225e4b1e2f common/utils: Factor out code for populating the commit data cache
This introduces no functional changes. The split out function will be
reused in a later commit to additionally load commit data from the
ostree-metadata branch.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 14:41:01 +01:00
Philip Withnall
8daef223bb utils: Fix minor formatting issue in gtk-doc comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 19:42:54 +01: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
c8659e4530 progress: Update at 300msec on the CLI
Writing things on the console every 100msec doesn't really
make any sense, the progress bar is not finegrained enough
and you can't read the text that fast anyway.
2017-05-23 10:18:35 +02:00
Alexander Larsson
23399ddc35 Use the CLI progress for update --appstream too 2017-05-22 17:01:14 +02:00
Alexander Larsson
2023ca03c2 common: Add flatpak_find_current_ref helper 2017-05-22 13:12:01 +02:00
Alexander Larsson
6c5ee01d01 complete: Don't read outside string
Sometimes the shell_cur value given to us by bash
is longer than expected, so don't step outside the
string in this case.

Fixes https://github.com/flatpak/flatpak/issues/764
2017-05-19 12:52:39 +02:00