Commit Graph

1392 Commits

Author SHA1 Message Date
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
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
Matthias Clasen
f9a73904bd Set a custom prompt
Differentiate sandbox shells by a custom prompt.
We set FLATPAK_ID to the app id, and PS1 to a prompt
using it. PS1 can be overridden by runtimes or --env.

Closes: #2447
Approved by: alexlarsson
2018-12-19 14:35:39 +00:00
Matthias Clasen
e7871a03c6 transaction: Try harder to identify empty transactions
It turns out a transaction can contain operations, and still
nothing happened after it ran - when all operations are skipped.
We only know this when the transaction is fully resolved, but
we may call is_empty from the ready signal or after run returns,
and it seems nice to tell the truth then.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
3a3ec26ebf transaction: Add api to get the start time of progress
This lets us calculate the download speed, and estimated
time remaining.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
030eb4de3f transaction: Add api to get transferred size
Add a function to FlatpakTransactionProgress to get the
number of transferred bytes. This is useful information
to show during a long-running download.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
a5b9b59c7b Add a utility for formatting choices
This prints the common pattern of

Choices:

  1) bla
  2) bla

with consistent formatting, so we don't have
to worry about matching newlines and spaces
all over the codebase.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
ba92cb7126 Add a way to disable fancy output
We disable fancy output when we can detect it,
but it is a good idea to have a way to explicitly
opt out too.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
19368bd00b transaction: Add api for sizes
Add api to get the download and installed size
of resolved operations. This is useful information
to present to the user before running the transaction.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
03d197f302 p2p resolve: Return sizes as well
Make flatpak_dir_resolve_p2p_refs return the
download and installed sizes as well. This is
useful information to present to the user before
doing an install or update.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
732ee49fee Add some tty handling utilities
Add a function to query the window size and cursor position,
and definitions for some more ANSI escape sequences that we
will use in the following commits.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
970697f21c transaction: Add useful details to the docs
The guaranteed sequence of signals is useful information
for any user this api.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
2a8a0ec69a Pass host xdg dirs into the sandbox
There are some use cases where apps might legitimately need
to know the host values of xdg variables. Since we use them
for our own purposes, we can't just propagate them as-is.
Instead, set HOST_XDG_{DATA,CONFIG,CACHE}_HOME if the corresponding
xdg variables are set on the host.

Closes: #2424

Closes: #2440
Approved by: alexlarsson
2018-12-17 08:14:43 +00:00
Matthias Clasen
11a9bef97e Merge pull request #2432 from aleixpol/clangbuild
Fix build with clang
2018-12-14 15:55:51 -05:00
Aleix Pol
192066517c Fix build with clang
Fixes #2430
2018-12-14 18:50:05 +01:00
Aleix Pol
b6eddbccff Don't use the last percentage if the total size changed
It happens sometimes that the first processed total is 1, when this gets
downloaded we have 100% already and then the total changes making this
percentage faulty.
This makes the progress regress sometimes, but I'd say it's better than
a permanent, ficticious number.

Fixes #2428
2018-12-14 18:27:17 +01:00
Alexander Larsson
9d8216ece2 Fix memleak in flatpak_bwrap_bundle_args 2018-12-10 13:53:08 +01:00
Alexander Larsson
45171e0ab0 Fix memleak in get_locale_langs_from_accounts_dbus 2018-12-10 13:52:54 +01:00
Alexander Larsson
bfa9fabd52 Fix leak in flatpak_get_current_locale_langs() 2018-12-10 11:50:55 +01:00
Alexander Larsson
185fe43fb7 extra_data: In system-helper case, canonicalize uid/gid
Make sure all files produced by apply_extra are owned by root.

Closes: #2398
Approved by: matthiasclasen
2018-12-07 20:38:45 +00:00
Matthias Clasen
43d4fb6a3e Fix oci pull progress reporting
Comparing the code in flatpak-utils.c:progress_cb,
we need to set bytes-transferred for the total amount
of data that has been transferred so far. The value
we were setting so far, fetched-delta-part-size, refers
to the size of the objects we already have locally, and
is subtracted from the total, which explains oci progress
running backwards.

Closes: #2392

Closes: #2400
Approved by: matthiasclasen
2018-12-07 19:51:11 +00:00
Matthias Clasen
b8cad064eb Add our own polkit listener implementation
This lets us respect the fancy output setting, and
it lets us do some other things that make it better
integrated.

Closes: #2379
Approved by: alexlarsson
2018-12-06 15:01:14 +00:00
Matthias Clasen
c685f05f8a trivial: Fix a gtk-doc warning
gtk-doc complains if parameter names don't match between
headers and doc comments, so make them match, for a quieter build.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:58 +00:00
Matthias Clasen
a2f57f64fd Add flags that allow to 'upgrade' permissions
This is to avoid multiple polkit dialogs, regardless
of transaction ordering.

FlatpakTransaction calculates the 'strongest' op it has,
and passes the hints accordingly. FlatpakInstallation
doesn't pass hints, since it does individual operations.

The system helper uses the hints to determine which PolicyKit
permission to request. Since the policy typically has 'keep'
set, this mean that the following operations in the same
transaction will be able to reuse the permission obtained
for the first one.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:57 +00:00
Matthias Clasen
c516a22e4d session-helper: Improve HostCommand life-cycle handling
Add flag that instructs the session-helper to kill
the spawned command when the caller drops off the bus.

Closes: #2326

Closes: #2365
Approved by: alexlarsson
2018-12-06 13:10:51 +00:00
Matthias Clasen
f3f7417b16 installation: Add a no-interaction property
Allow to mark a FlatpakInstallation as no-interaction, which
will get passed to the system helper to prevent it from presenting
polkit dialogs.

We make this a property on the object, since not all relevant
methods have flags that would let us pass this information.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthias Clasen
929da90a3e dir: Add a no-interaction property
Allow to mark a FlatpakDir as no-interaction, which will
get passed to the system helper to prevent it from presenting
polkit dialogs.

We make this a property on the object since the alternative
would require plumbing the flag through tons of API all over
the code.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthias Clasen
c148c7eeec system-helper: Allow non-interactive tasks
Add a new 'no-interaction' flag to all system-helper methods
that have flags, and don't allow polkit user interaction if
it is set. This will let tools like GNOME Software do automatic
updates in the background without interrupting the user with dialogs.

For methods that don't have flags, we always allow user interaction.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthias Clasen
1ba30f7ef1 system-helper: Add flags to all methods
Some methods were missing a flags argument. This
will be a problem in the future, when we want to
pass a no-interaction flag to all methods. Therefore,
add an empty flags enum for every method that is lacking
one now.

This is an api change for the system-helper interface.

Closes: #2370
Approved by: alexlarsson
2018-12-03 12:52:17 +00:00
TingPing
e5218a5623 Also add /dev/nvidia-uvm-tools
This may sometimes be needed also.
Closes: #2358
Approved by: matthiasclasen
2018-12-01 00:31:11 +00:00
Alexander Larsson
0b6a66013c OCI: Use system helper to generate summary for OCI remotes
The OCI support relies on downloading a json index and converting it
to a ostree-style summary, which we the use in all sorts of operations
in the client code. Currently this happens in the user code, which means
that it will fail (due to permissions) in the system installation case.

We could do the conversion as the user, but when eventually installing
something the system-helper will anyway do this download and
conversion, so that would only double the work and risk things going out
of sync. Also, the OCI index is not gpg signed, so we can't realy on
downloads done as the user.

So, the solution done here is to add a GenerateOciSummary
system-helper call which we use instead of directly generating the
oci summary.

This fixes https://github.com/flatpak/flatpak/issues/2350

Closes: #2363
Approved by: matthiasclasen
2018-12-01 00:16:08 +00:00
Owen W. Taylor
05cc3c0f66 flatpak_cache_http_uri: save downloaded files with permission 0644
Previously, downloaded files were being saved with 0600 permissions,
which prevented OCI icons downloaded by the system helper at appstream
creation time from being read by users.

Closes: #2362
Approved by: matthiasclasen
2018-11-30 23:53:10 +00:00
Patrick Griffis
9895014124 Grant access to /dev/nvidia-uvm for OpenCL/CUDA
Closes #2266

Closes: #2356
Approved by: alexlarsson
2018-11-30 07:36:41 +00:00
Kalev Lember
c915f73b41 remote: Add a way to get/set xa.main-ref
This is useful for gnome-software in order to figure out which app to
show from noenumerate remotes.

Closes: #2340
Approved by: matthiasclasen
2018-11-25 18:31:06 +00:00
Patrick Griffis
182b2674aa Add condition for XDG_CURRENT_DESKTOP checks
Firstly this changes the "download-if" and "enable-if" properties
to accept a `;` separated list of multiple conditions.

Secondly it adds `on-xdg-desktop-*` which will check against
the XDG_CURRENT_DESKTOP env var (case-insensitively).

This is done entirely for the Qt GNOME Platform so it can do this:

```
"org.kde.PlatformTheme.QGnomePlugin" : {
  "download-if": "on-xdg-desktop-GNOME;on-xdg-desktop-GNOME-classic"
}
```

Closes: #1436
Approved by: matthiasclasen
2018-11-17 23:42:49 +00:00
Matthew Leeds
5fe2a0aabe uninstall: Add support for fuzzy matching
This adds support for fuzzy matching ref names (AKA "typo helper") to
the uninstall command to mirror what the install command has. In short,
this means you can do "flatpak uninstall gedit" instead of "flatpak
uninstall org.gnome.gedit". Flatpak will prompt you to choose between
similarly named installed refs, and will only make the choice for you if
--assumeyes was used and there's only one match.

Note that this commit does have the side effect that if there are
multiple matching refs with the same ID (e.g. with different branches or
in different installations) you are prompted to choose between them.
Previously you were shown an error message.

Closes: #2330
Approved by: matthiasclasen
2018-11-17 13:00:33 +00:00
Matthew Leeds
7d35de18e4 app: Fix a couple memory leaks
Closes: #2330
Approved by: matthiasclasen
2018-11-17 13:00:33 +00:00
Erick555
ad9599d3e3 Mount common sockets as read-only
This is similar case as with x11_socket, 0af71792b4

Closes: #2333
Approved by: matthiasclasen
2018-11-16 21:18:12 +00:00