Commit Graph

339 Commits

Author SHA1 Message Date
Kalev Lember
bffca5733e common/dir: Fix a memory leak
Closes: #1369
Approved by: mwleeds
2018-01-31 18:03:16 +00:00
Matthew Leeds
01fe49c66b common/dir: Fix typo in debug message 2018-01-29 00:57:10 -08:00
Philip Withnall
7d1da19de2 common/dir: Add a missing OstreeAsyncProgress default key
oci_pull_init_progress() seems to set all the default keys wanted by
ostree_repo_pull_default_console_progress_changed() except the
caught-error key, which was added in OSTree commit 5c4f26bd65b492.

Add that key, just in case something queries for it (if it’s missing
when that happens, an assertion failure will be hit).

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

Closes: #1320
Approved by: cgwalters
2018-01-19 23:01:03 +00:00
Matthew Leeds
ee10c43b66 dir: Fix typos in comments 2018-01-15 22:54:27 -08:00
Matthew Leeds
ff3d2097ac dir: Fix a few comments 2017-12-27 18:07:41 -06:00
Alexander Larsson
85282668ec deploy: Create the binary wrappers after having rewritten the exports
Interestingly the telegram appid is "org.telegram.desktop", which means
the wrapper ends up having a .desktop extension which confuses the
desktop file exporter. We fix this by rewriting any exports before
creating the wrappers.

Fixes https://github.com/flathub/org.telegram.desktop/issues/18

Closes: #1270
Approved by: alexlarsson
2017-12-21 09:49:53 +00:00
Alexander Larsson
006a5f2ade Don't crash when installing bundles that have no embedded URIs
Closes: #1268
Approved by: alexlarsson
2017-12-21 08:33:46 +00:00
Philip Withnall
89243b1d9c common/dir: Don’t ignore errors when marking dir as changed
Coverity CID: 1462265

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

Closes: #1267
Approved by: alexlarsson
2017-12-20 13:03:37 +00:00
Philip Withnall
0afa7acf9b common/dir: Don’t ignore errors replacing a file on undeploy
Emit a warning about them rather than ignoring them entirely.

Coverity CID: 1376554

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

Closes: #1267
Approved by: alexlarsson
2017-12-20 13:03:37 +00:00
Philip Withnall
955fbc29bf common/dir: Fix various big and small leaks
Some of these were leaking entire file contents, or the whole of
xa.metadata.

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

Closes: #1259
Approved by: mwleeds
2017-12-19 07:12:28 +00:00
Alexander Larsson
64f82ec956 Create and export wrappers for apps
This creates a $flatpakdir/exports/bin directory that contains wrappers
for all active installed applications, named by the application id.

If you add these directories to you $PATH, then this means you can more
easily launch flatpak apps on the commandline.

Closes: #1254
Approved by: alexlarsson
2017-12-15 09:53:28 +00:00
Alexander Larsson
fdd0660379 Never export anything for runtimes
It doesn't really make sense for a runtime to export anything, so
lets just enforce that. Note, this is not necessary a security
issue, because anything exported from runtimes were rewritten
just like apps. It just enforces the expected behaviour of
runtimes.

Closes: #1254
Approved by: alexlarsson
2017-12-15 09:53:28 +00:00
Alexander Larsson
6e17756db6 install: Handle passing a file: uri as remote
Closes: #1244
Approved by: alexlarsson
2017-12-14 09:27:22 +00:00
Alexander Larsson
cd0230e117 common: Expose flatpak_dir_prune_origin_remote
Also make it work with the system helper.

Closes: #1244
Approved by: alexlarsson
2017-12-14 09:27:21 +00:00
Alexander Larsson
b00e6b661f Reuse origin remote if all the details match
Closes: #1244
Approved by: alexlarsson
2017-12-14 09:27:21 +00:00
Alexander Larsson
3ade86b292 install: Add --reinstall
If you're installing something and its already installed, we undeploy
the old install first before deploying the new. This makes it very
easy to switch an application from one remote to another, without
having to uninstall first, which is both painful and could cause
the download to be unnecessary large.

Closes: #1241
Approved by: alexlarsson
2017-12-14 09:04:38 +00:00
Alexander Larsson
97683cfbe1 override: Support global overrides
This lets you add overrides that affect all applications. Application
overrides have higher priority so will override the global overrides.

Closes: #1245
Approved by: alexlarsson
2017-12-14 08:49:23 +00:00
Alexander Larsson
403a7a7518 common: flatpak_dir_check_for_appstream_update
Closes: #1248
Approved by: alexlarsson
2017-12-14 08:20:34 +00:00
Alexander Larsson
13db7f0474 common: Add flatpak_dir_has_remote()
Closes: #1246
Approved by: alexlarsson
2017-12-13 10:03:47 +00:00
Alexander Larsson
6bb0196ffd Make flatpak remote-add --system work with an empty /var/lib/flatpak
This means flatpak can bootstrap itself from an empty /var on stateless
systems, which fixes https://github.com/flatpak/flatpak/issues/113, at
least for the CLI case.

Closes: #1195
Approved by: alexlarsson
2017-11-24 10:54:25 +00:00
Alexander Larsson
742913856e common: Add flatpak_dir_maybe_ensure_repo
This tries to ensure that FlatpakDir->repo is set, but if the
repo doesn't exists and we're unable to create it that is fine
and we continue running with repo == NULL.

This is useful because there are only a few operations that really
are useful/make sense with no repo set up, and we can ensure these
handle this well.

In particular, we want to allow flatpak remote-add using the
system-helper to work even if /var/lib/flatpak doesn't exist, so that
we can bootstrap a working flathub from a fresh /var.

Closes: #1195
Approved by: alexlarsson
2017-11-24 10:54:25 +00:00
Alexander Larsson
2c41aa5203 Use systemwide config also when running as root
We want to look for remotes in /etc/flatpak also when not
using the system helper

Closes: #1195
Approved by: alexlarsson
2017-11-24 10:54:25 +00:00
Alexander Larsson
0a9ae464f6 Add remote-info command
This shows information about a ref in a remote. Of particular interest
is the --log option which gives you a history which can be used
with update --commit=XXX to roll back an update.

Closes: #1174
Approved by: alexlarsson
2017-11-21 11:16:06 +00:00
Alexander Larsson
a026da8027 Add flatpak_dir_fetch_remote_commit
Closes: #1174
Approved by: alexlarsson
2017-11-21 11:16:06 +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
Alexander Larsson
ec08f26e17 Optionally return summary from flatpak_dir_lookup_ref_from_summary
Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Matthew Leeds
c429951755 common: Improve output for empty remote URLs
If a remote has an empty url (which can happen for automatically created
remotes from some bundle files) we can't fetch from it. So for example
if you use "flatpak remote-ls --updates" it gives you a cryptic error
message from OSTree ("Failed to parse uri: "). This commit changes
flatpak to instead print an error message that mentions the remote name.
For backwards compatibility reasons, a remote with an empty url is
considered disabled, so say so.

Closes: #1165
Approved by: alexlarsson
2017-11-15 09:05:37 +00:00
Matthew Leeds
737b1b0950 common: Print debug info when fetching summaries
Sometimes fetching a remote repository's summary file fails and it can
be hard to tell what went wrong because even with --verbose flatpak
doesn't tell you which remote it's fetching from. Add a debug statement
to fix that.

Closes: #1165
Approved by: alexlarsson
2017-11-15 09:05:37 +00:00
Alexander Larsson
5b9f55e4b8 common: Unlink the old flatpak-cache symlink if we're replacing it 2017-10-26 10:55:20 +02:00
Alexander Larsson
ec8efa4e91 Fix .flatpak-cache symlink 2017-10-26 10:53:17 +02:00
Alexander Larsson
cfb34ea888 common: Make ostree bug workaround version checked
The commitstate check in parent dir was fixed in ostree 2017.13,
so we only apply the workaround for previous versions.

Closes: #1131
Approved by: alexlarsson
2017-10-26 07:43:23 +00:00
Alexander Larsson
edfd6eae83 When updating from partial install, disable static deltas
The delta can contain references to files in the parent which don't
exist locally, which breaks.

Closes: #1126
Approved by: alexlarsson
2017-10-25 06:44:40 +00:00
Alexander Larsson
893c53d8e7 flatpak_dir_update: Fix leak
The return value of flatpak_deploy_data_get_subpaths needs a (shallow)
free, so put it in a separate autofree variable.

Closes: #1126
Approved by: alexlarsson
2017-10-25 06:44:40 +00:00
Alexander Larsson
a89de9dacc Use FlatpakBwrap in run/build
This is a mostly trivial conversion to use FlatpakBwrap instead
of separate argv_array/fd_array/envp variables. Anywhere it is
trivial to pass the bwrap we do, but for anything complicated
we keep the old code with separated args.

Closes: #1114
Approved by: alexlarsson
2017-10-24 08:22:07 +00:00
Alexander Larsson
e61071cb7b config: Move all references of "xa." prefix for config into FlatpakDir
There is no need to expose this in the API, especially the library API.

Closes: #1123
Approved by: alexlarsson
2017-10-20 20:06:38 +00:00
Alexander Larsson
b18d1c2321 Add system-helper support for configuring language.
Closes: #1123
Approved by: alexlarsson
2017-10-20 20:06:38 +00:00
Alexander Larsson
a4073b1a79 Fix issue with extension ld.so.conf files being empty
If regenerate_ld_cache was used then the fds involved in the
ld.so.conf files were used twice, which means they are at
the end the second time. So, we tweak the child setup to always
seek back to the start of all fds.

Closes: #1112
Approved by: alexlarsson
2017-10-18 08:01:05 +00:00
Philip Withnall
d09a73d440 common: Add error handling around a symlink() call
Spotted by Coverity as CID #1457791.

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

Closes: #1108
Approved by: alexlarsson
2017-10-17 10:22:27 +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
05e2afa8ce Fix up subpath handling
Whenever we add a add a local dependency we add both the languages
based on the current locale, and (in case of an update) whatever was
installed before. We also properly merge this with any normally
specified (non-dependency) update (typically happens e.g. when just
doing a "flatpak update", which adds .Locale updates both as
dependencies and regular updates).

This means you can just configure a new language and then flatpak
update will pull everything with those languages.

Closes: #1098
Approved by: alexlarsson
2017-10-11 12:48:07 +00:00
Alexander Larsson
9e1e982bf8 Add flatpak config option
This is currenly only used to configure the languages to install.

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
97d6e6a730 flatpakrefs: Don't g_critical if title is not set
The title is optional, so don't set it in the remote if it
is not set.

Closes: #1095
Approved by: alexlarsson
2017-10-10 12:24:18 +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
João Paulo Rechi Vita
2663efe7a9 dir: Prefer unmaintained related extensions
If an extension is already installed as an unmainted extension, prefer
it instead of downloading from the remote.

Closes: #1081
Approved by: alexlarsson
2017-10-05 07:37:13 +00:00
Valentin David
845a0b3bf7 Use ld.so.cache instead of LD_LIBRARY_PATH (when not building)
Instead of setting LD_LIBRARY_PATH to make the app load the right
libraries we run ldconfig to generate a ld.so.cache that we feed
to the sandbox as /etc/ld.so.cache. The cache itself is generated
by running ldconfig at run time, but for apps we cache the
result in $HOME/.var/app/$APPID/.ld.so/cache based on the
current app/runtime/extensions commit ids.

We also unset LD_LIBRARY_PATH, to ensure any host-side value
does not mess with the sandbox.

The default ld.so.conf we set (if the runtime has none, or an empty
one) is:

 include /run/flatpak/ld.so.conf.d/*.conf
 include /app/etc/ld.so.conf
 /app/lib

Additionally all the extension points that have add_ld_path set gets a
ld.so.conf snippet in /run/flatpak/ld.so.conf.d.

This allows applications and extensions to install their own paths if
needed, and if the runtime wants more location they can install a
custom ld.so.conf that includes the above.

In the flatpak build case we still use LD_LIBRARY_PATH like before,
because there is no good key (like the commit ids) for keeping the
cache up-to-date. Also, the behaviour is different when building an
app for instance. If /app/lib is not in LD_LIBRARY_PATH then the
sandbox-wide /etc/ld.so.cache must be updated for a newly installed
library to work, but the sandbox is not allowed to update
/etc/ld.so.cache.

This code was originally written by Valentin David <valentin.david@gmail.com>
with changes by Alexander Larsson <alexl@redhat.com>.

Closes: #1073
Approved by: alexlarsson
2017-10-04 10:27:14 +00:00
Alexander Larsson
0ab0e94647 Add flatpak_deploy_get_deploy_data helpers
Closes: #1069
Approved by: alexlarsson
2017-10-03 08:01:46 +00:00
Sam Spilsbury
d0af046a2f system-helper: Add PruneLocalRepo method
We might want to prune the repo from within the library or
the command line and may not be in a privileged context, so
we'll need to jump through the system helper to prune the refs.

Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00