1428 Commits

Author SHA1 Message Date
Alexander Larsson
485d51e0a7 run: Generate /run/host/font-dirs.xml config file
This file lists the directories that are remapped in the sandbox,
allowing fontconfig to use the correct cache identifier for the
host-side caches.

As an example, this generates:

```
$ ./flatpak run --command=sh org.gnome.gedit
[📦 org.gnome.gedit flatpak]$ cat /run/host/font-dirs.xml
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
	<remap-dir as-path="/usr/share/fonts">/run/host/fonts</remap-dir>
	<remap-dir as-path="/home/alex/.fonts">/run/host/user-fonts</remap-dir>
</fontconfig>
```

Closes: #2635
Approved by: alexlarsson
2019-01-25 12:21:45 +00:00
Matthias Clasen
a0d579bb9b Add utilities to switch in and out of raw mode
Closes: #2638
Approved by: alexlarsson
2019-01-25 12:03:47 +00:00
Matthias Clasen
69212da002 Parse date attributes in appdata
The spec allowed either timestamp or date to
be specified for a release, so we should support
both.

Closes: #2614

Closes: #2619
Approved by: alexlarsson
2019-01-21 08:46:57 +00:00
Matthias Clasen
7b94d827d7 Allow multiple name segments after prefix
This lets us export D-Bus service files for
names like org.foo.Bar.Application.Tracker.service
when the app-id is org.foo.Bar.

Closes: #2615

Closes: #2616
Approved by: alexlarsson
2019-01-21 08:27:09 +00:00
Philip Withnall
d9eed092cf common: Mark an error message as translatable
All the other error messages in that file are.

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

Closes: #2609
Approved by: matthiasclasen
2019-01-18 12:49:56 +00:00
Matthew Leeds
2274242301 transaction: Refuse to let root modify a user repo
If the user (erroneously) runs as root while modifying their user
installation, e.g. with "sudo flatpak --user install ...", this can
cause "permission denied" errors later on when they try to operate on
the installation as their own user. So refuse to execute a transaction
on a user-owned installation as root. Root can still operate on their
own per-user installation.

This approach does have a weakness: if flatpak is running as root when the user
installation is first created, it will be owned by root and therefore
avoid this check. I'm not sure what could be done about that.

Fixes https://github.com/flatpak/flatpak/issues/2565

Closes: #2575
Approved by: alexlarsson
2019-01-17 07:40:29 +00:00
Matthew Leeds
2e76702879 dir: Fix a few "already/not installed" error messages
There was some confusion between branches and commits.

Closes: #2604
Approved by: matthiasclasen
2019-01-16 22:00:44 +00:00
Matthew Leeds
1ea2864088 Remove no longer needed #define directives
Now that we depend on libostree 2018.9, these aren't needed.

Closes: #2593
Approved by: matthiasclasen
2019-01-15 20:02:17 +00:00
Matthias Clasen
f2303ee4c5 Export dconf data
We want to move away from using dconf inside the sandbox,
and instead use the keyfile backend for GSettings, which
has gained the capability to read defaults and locks.

This change makes the dconf database contents and locks
available in a suitable format. The files appear inside
the sandbox in the /etc/glib-2.0/settings directory.

We only export the default values for keys in the dconf
subtree whose path matches the app id, as well as prefixes
listed in paths key from the X-DConf group in metadata.

This commit adds a new dependency, since we're now linking
against libdconf.

Closes: #2295
Approved by: alexlarsson
2019-01-14 15:34:11 +00:00
Matthias Clasen
f9c6a769ef Stop linking libflatpak against listappstream-glib
We no longer use it here. flatpak itself still links
against it. This avoids problems with consumers who
might also link against libappstream.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
5db64fe342 Add a minimal GMarkup-based appdata parser
This parser nderstands just enough appdata to pull
out the strings we want.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
728f917418 Move appdata parsing to its own file
This is just moving some code around for now.
It is still using libappstream-glib.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
9dff4bbb85 Move flatpak_dir_load_appstream_store
This function has libappstream-glib types in the
api, which we want to drop. And it is only used
in app/, so move it there.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
faab490f1e Improve FlatpakInstallation docs
Document the values returned by flatpak_installation_get_id()
and by flatpak_installation_get_display_name() for standard
installations.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Matthias Clasen
f7a566e2ab Make sure we have IDs and display names
Return non-NULL strings from flatpak_dir_get_id()
and flatpak_dir_get_display_name() for user installations,
to save library users the hassle of dealing with NULL
return values.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Matthias Clasen
eaebab1285 Translate the display name of the default installation
Change the terminology from 'directory' to 'installation',
and mark the string for translation.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Alexander Larsson
cb30e7ef4e Add deploy refs for currently deployed commit.
When we deploy e.g. app/org.foo.bar/x86_64/stable, then we
also create a deploy/app/org.foo.bar/x86_64/stable ref pointing to
the latest deployed commit. We also remove it when an app is uninstalled.

This means that a prune operation will not delete objects that are deployed
(which would not save any space anyway). This is nice because this can
happen for instance when you flatpak update --no-deploy.

Fixes https://github.com/flatpak/flatpak/issues/2085

Closes: #2563
Approved by: alexlarsson
2019-01-14 11:55:12 +00:00
Matthias Clasen
3598cce951 Add utilities for showing/hiding the cursor
Closes: #2570
Approved by: alexlarsson
2019-01-14 11:41:42 +00:00
Matthew Leeds
dd5b798428 dir: Delete some outdated comments
It's no longer true that it's the pull code's job to resolve a ref to a
specific commit. Ever since commit 66eee3c2c this is the job of the
resolve_ops() function used by FlatpakTransaction (at least, when a
transaction is being used). So update a couple comments to avoid
confusion.

Closes: #2587
Approved by: alexlarsson
2019-01-14 10:34:34 +00:00
Matthias Clasen
e8e31edea2 Make number parsing more robust
We were parsing 2-6 with an out-of-range end value
as 2. Fix that.

Closes: #2578
Approved by: matthiasclasen
2019-01-12 02:05:05 +00:00
Matthias Clasen
b098d683e5 Export flatpak_parse_numbers
Export this function privately, so we can test it.

Closes: #2578
Approved by: matthiasclasen
2019-01-12 02:05:05 +00:00
Matthias Clasen
4f6fef6d82 Don't return NULL without setting an error
Set the expected error when returning NULL from
flatpak_dir_get_config due to an empty repo.

Closes: #2576

Closes: #2577
Approved by: mwleeds
2019-01-12 00:40:14 +00:00
Matthew Leeds
9aae124ca3 transaction: Fix gtk-doc warning
Closes: #2574
Approved by: matthiasclasen
2019-01-11 22:57:15 +00:00
Matthias Clasen
402e2020d8 Add a way to force fancy output on
This will be used for testing the table printer formatting.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:44 +00:00
Matthias Clasen
f39b5a2795 dir: Be more careful with self->repo
It is possible for self->repo to be NULL, therefore
call flatpak_dir_ensure_repo() in a bunch more places,
before accessing self->repo.

Closes: #2483

Closes: #2484
Approved by: matthiasclasen
2019-01-11 16:12:33 +00:00
Matthias Clasen
9ff489519c Add a utility to prompty for multiple choices
This is a variant that allows to enter multiple numbers,
either individually, or as range. Parts can be separated
by space or comma. Examples:
1-3,5
1 2 4
6

Closes: #2559
Approved by: alexlarsson
2019-01-11 15:57:44 +00:00
Matthias Clasen
b4e68422bf dir: Don't write to the console
In some cases, when NULL was passed for an OstreeProgress,
the library code would instantate its own progress object
and write progress information out to the console. That
is not a good thing for a library to do - it has the
potential to mess up the cli tools output.

Stop doing this, and require that all callers pass
a non-NULL progress.

Closes: #2468
Approved by: alexlarsson
2019-01-11 14:16:37 +00:00
Matthias Clasen
92b0ad5f7e Handle out-of-space errors nicer
Ostree just gives us a generic G_IO_ERROR_FAILED (boo!),
so we need to scrape the message to infer that this was
out-of-space. Translate this to an explicit error code
that we handle in the UI.

Closes: #2477
Approved by: alexlarsson
2019-01-11 13:46:31 +00:00
Ryan Gonzalez
f9c9c14a5c Expose whether or not devel was used in .flatpak-info
Closes: #2515
Approved by: alexlarsson
2019-01-11 13:20:35 +00:00
Matthias Clasen
7ba9af1e24 Handle FLATPAK_CONFIG_DIR/remotes.d not existing
OSTree does not like being given a nonexisting directory
here, so check and pass NULL if thats the case.

Closes: #2534
Approved by: alexlarsson
2019-01-11 12:40:35 +00:00
Matthias Clasen
3f717cfb83 Move the typedef for FlatpakCompletion
Move this typedef to flatpak-complete.h, where it
belongs. Also add a autoptr definition for it and use
it to avoid leaking the completion in flatpak-main.c.

Closes: #2534
Approved by: alexlarsson
2019-01-11 12:40:35 +00:00
Matthias Clasen
45860c56f2 transaction: Add a run vfunc
This lets us avoid extra api FlatpakCliTransaction.

Closes: #2556
Approved by: alexlarsson
2019-01-11 11:42:13 +00:00
Matthias Clasen
d2301bed53 installed ref: Plug a few memory leaks
All the appdata strings were not freed. Oops.

Closes: #2521
Approved by: mwleeds
2019-01-09 05:20:13 +00:00
Matthias Clasen
6161a43f97 Add license to the appdata fields we extract
This was requested before, so might as well add
it at the same time.

Closes: #2521
Approved by: mwleeds
2019-01-09 05:20:13 +00:00
Matthias Clasen
3548184020 Merge pull request #2522 from matthiasclasen/doc-cosmetics
Improve appdata getter docs
2019-01-07 20:33:46 -05:00
Matthias Clasen
88d25970c7 Handle app-less instances better
FlatpakInstance was not dealing well with sandboxes
that don't have an application. In this case, the
metadata does not have an Application group, but
a Runtime group instead.

Closes: #2482
Approved by: matthiasclasen
2019-01-08 00:56:09 +00:00
Matthias Clasen
86f3077be3 Nicer formatting for many choices
'flatpak install sdk' offers me 34 choices, so double digits
seem very realistic here. Make the numbers line up in this
case.

Closes: #2476
Approved by: matthiasclasen
2019-01-07 23:42:19 +00:00
Matthew Leeds
dcf207b293 dir: Fix a couple typos 2019-01-04 13:02:48 -08:00
Matthias Clasen
e4dd8b3e11 Be stricter about installation IDs
Avoid unnecessary complications from accepting installation
IDs which won't work well on the commandline or in filenames.

Closes: #2514
Approved by: mwleeds
2019-01-04 19:13:49 +00:00
Matthias Clasen
0c17af66d1 Improve apdata getter docs
There were a few small copy-paste errors.
2018-12-31 10:15:15 -05:00
Alexander Larsson
b06f616172 Drop unneeded progress reporting
When pulling the ostree-metadata branch for p2p remotes we passed
NULL for progress which caused it to report with the default console
progress, which doesn't make any sense for the (small) ostree-metadata
branch.

Closes: #2456
Approved by: alexlarsson
2018-12-21 08:45:40 +00:00
Matthias Clasen
bcb20df3a4 installation: Add api to find unused refs
This is copying code from the unstall command that
was added for the --unused option, and makes it
available as a library api.

Closes: #1747

Closes: #2444
Approved by: alexlarsson
2018-12-21 08:19:46 +00:00
Matthias Clasen
6b59406e80 Consistently use Unicode ellipsis
Now that we're moving away from a pure ASCII esthetic,
it looks odd to me to have a mixture of 3 dots and
proper ellipsis, so switch everything over to use
U+2026 instead of 3 dots.

Some minor other formatting and string changes
are included here as well.

Closes: #2454
Approved by: alexlarsson
2018-12-21 08:07:25 +00:00
Matthias Clasen
e49822653f Add more Escape sequences
Add Escape sequences for hiding and showing the cursor.

Closes: #2455
Approved by: alexlarsson
2018-12-21 08:06:49 +00:00
Alexander Larsson
2a94bb8eb2 Use shorter names for origin remotes
Use only the last section in the id for origin remotes, to avoid
the origin column being really wide when listing stuff.

Closes: #2448
Approved by: alexlarsson
2018-12-20 16:08:44 +00:00
Alexander Larsson
1ff83a8a60 utils: Add flatpak_compare_ref
This compares the refs on a per-segment basis, so
org.foo.bar comes before org.foo.bar.suffix

Closes: #2450
Approved by: alexlarsson
2018-12-20 15:50:07 +00:00
Matthias Clasen
ca9bd766e6 run: Add a --cwd option
Bubblewrap has a --chdir option to control the directory
that the command is run in. Add an argument for this to
the flatpak_run_app function, update all callers, and add
a --cwd option to flatpak run that uses this new argument.

Closes: #2443
Approved by: alexlarsson
2018-12-20 15:35:23 +00:00
Alexander Larsson
504fcf3107 lib: Add support for appdata to FlatpakInstalledRef
This adds a function to load the full appdata.xml.gz, as well as
fast accessors to the pre-parsed fields.

Closes: #2409
Approved by: alexlarsson
2018-12-19 15:45:35 +00:00
Alexander Larsson
b20ee7e26a dir: Add new version of DeployData with parsed appstream data
We load the per-app appstream xml.gz during deploy and inject name,
summary and version from it into the deploy data. For older deploys
that don't have this data we re-create it when needed (with the hope
that updates to app eventually makes this unnecessary due to new deploys).

Additionally this removes the support for generating deploy files where
they don't exist, as support for this predates xdg-app 0.6, so should not
exist in real life.

Closes: #2409
Approved by: alexlarsson
2018-12-19 15:45:35 +00:00
Alexander Larsson
9a37475e76 deploy-data: Prepare for versioning
This adds a version to the deply data format, assuming that if
there is no version then it is 0. Also extends all loaders so that
it can specify a required version, with the goal that most users
are fine with old versions, but if you need more recent we have
a (costly) conversion process to upgrade (will be added later).

The library and the flatpak list/info commands require the most
current version for full info, all other users can use any version.

Also, as part of this we now pass the ref to flatpak_load_deploy_data()
as this will be needed later for the backwards compat support.

Closes: #2409
Approved by: alexlarsson
2018-12-19 15:45:35 +00:00