Commit Graph

4309 Commits

Author SHA1 Message Date
Matthias Clasen
2bbdd7712a Remove unused functions
Neither flatpak_variant_builder_init_from_variant nor
flatpak_gvariant_new_empty_string_dict are used anywhere.

Closes: #2252
Approved by: matthiasclasen
2018-10-23 20:10:37 +00:00
Matthias Clasen
4ef317c9ba session-helper: Properly report p11-kit exit status
Use the API that GLib offers for this.

Closes: #2252
Approved by: matthiasclasen
2018-10-23 20:10:37 +00:00
Matthias Clasen
6b0329bf2d Cosmetic
Closes: #2252
Approved by: matthiasclasen
2018-10-23 20:10:37 +00:00
Matthias Clasen
daaac92aea tests: Improve the instance test
We now avoid sleeps in the test, instead use the proper
ways to deal with races: poll for the child pid after
launching the app, and use a child watch after killing
it.

This is using the new flatpak_installation_launch_full API.

Closes: #2221
Approved by: matthiasclasen
2018-10-23 07:15:39 +00:00
Matthias Clasen
6daf195e42 Instance: mitigate races, add new launch api
Avoid the 3-second 'afterlife' of instances by using
kill (pid, 0) instead of checking the file lock. We
trade pid for lock races, but this seems more reliable.

Also add flatpak_installation_launch_full that returns
a FlatpakInstance for the launched app, and lets us
avoid races around killing the app, by using a child
watch.

Closes: #2221
Approved by: matthiasclasen
2018-10-23 07:15:39 +00:00
Matthias Clasen
7b04db62b6 Merge pull request #2260 from alexlarsson/run-optional-repo
run: Make repos optional (again)
2018-10-20 09:19:29 +01:00
Matthias Clasen
bad9e57a1c Merge pull request #2259 from mwleeds/fix-make-distcheck
tests/Makefile.am.inc: Fix distcheck error
2018-10-20 09:18:50 +01:00
Matthias Clasen
8212ad0253 Merge pull request #2263 from mwleeds/remove-old-ostree-version-checks
Remove old OSTree version checks
2018-10-20 09:13:00 +01:00
Matthew Leeds
80c4da4374 Remove old OSTree version checks
Flatpak depends on OSTree 2018.7 now, so we don't need these.
2018-10-19 17:54:02 -07:00
Matthew Leeds
6710e85d55 tests/Makefile.am.inc: Fix distcleancheck failure 2018-10-19 13:45:22 -07:00
Matthew Leeds
cffc63ba3a tests: Skip two more tests when bwrap is missing
This adds the logic from test_install_launch_uninstall() to
test_instance() and test_overrides() so that all three are skipped in CI
environments where bwrap may not be working. This is necessary because
they all use flatpak_installation_launch().
2018-10-19 13:45:09 -07:00
Matthew Leeds
dce3c700ef tests/Makefile.am.inc: Fix distcheck error
Currently `make distcheck` fails with:

PATH=$(cd . && pwd):${PATH} tests/make-test-runtime.sh
tests/runtime-repo org.test.Platform ""
/bin/bash: tests/make-test-runtime.sh: No such file or directory

This was caused by commit b5d86fe90 and is fixed by this commit.
2018-10-19 11:09:34 -07:00
Alexander Larsson
d6eba6732f run: Make repos optional (again)
If some installation is empty (or otherwise broken) we fail the
entire run command, even though the app might exist in e.g. the
user installation. This is a regression from
651c86d3c6 which also ended up in 1.0.4.
2018-10-19 12:56:37 +02:00
Matthias Clasen
71143138b7 Merge pull request #2250 from alexlarsson/test-required-version
tests: Add a test for multi-updates and required version
2018-10-17 14:58:07 -07:00
Matthias Clasen
4b85aa7859 Merge pull request #2254 from mwleeds/instance-element-type-annotation
instance: Fix gtk-doc warning
2018-10-17 14:56:01 -07:00
Matthew Leeds
d5b8266a09 instance: Fix gtk-doc warning 2018-10-17 14:23:20 -07:00
Alexander Larsson
0e36042fdf tests: Add a test for multi-updates and required version
I had a report of (and old version of) flatpak stopping
an entire "flatpak update" because one app had a new required
version. This adds a test of this (and it seems fixed now).
2018-10-17 09:30:13 +02:00
Matthias Clasen
dcd912b463 Merge pull request #2249 from mwleeds/use-g-key-file-macro
dir: use G_KEY_FILE_DESKTOP_GROUP constant
2018-10-16 16:04:14 -07:00
Will Thompson
0d6b979212 dir: use G_KEY_FILE_DESKTOP_GROUP constant
This and all the other standard Desktop Entry Specification keys are
defined in gkeyfile.h. Who knew?
2018-10-16 14:40:55 -07:00
Matthias Clasen
fd60bfc96c Add a test for transaction with local install
Here we pass a file url instead of a remote name.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
a46527d9e1 transaction: Improve the docs
Explain that it is possible to install from a
local repo by passing the location.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
dc5d78fa33 Add more tests
The tests added here include checks for expected types in
the library (including enum types that are needed for
introspection), and for error handling around names.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
12b5c36ec9 Remove an unused function
There were no calls to flatpak_zero_mtime anywhere.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
2d331a84a3 ref: Remove some dead code
flatpak_decompose_ref guarantees that parts[0] is either
"app" or "runtime".

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
2d70866fa8 transaction: Don't call g_object_ref on a GBytes
This won't go well.

Spotted while writing tests.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
acd8cfd6bb Add a test for bad remote names
These were not handled gracefully so far.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
8462a093e7 remote: Be robust against bad names
If we use a remote name containing questionable characters
such as newlines or '[', we will run into assertions in
GKeyFile. To avoid that, check that the group name we
pass is valid, and throw an error otherwise.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
8f5c43a784 history: Always handle --columns=help
The test for --columns was failing in ci because flatpak
gets built without libsystemd there. Avoid this by always
handling --columns=help nicely, even if libsystemd is not
used.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
6d696b74f5 Test more overrides
Test some of the socket settings.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
5454707464 Add more tests
Test some more instlalation apis, and some error conditions.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
34851f99d6 Add some more tests
Test more options of build-update-repo.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
37f0284467 transaction: Add a missing error return
When trying to uninstall a non-installed app, we run
into an assertion, because the code forgets to return
after setting the expected error.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
263a2e5663 Add some more basic tests
Some tests for commandline error handling.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
9f7ddaf678 Add a test for --columns=help
Check that this produces the expected output.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
4009466913 document-list: Handle --columns=help properly
In this case, the columns helper function returns an
empty array of columns. Exit cleanly without trying
to contact the documents service, in this case.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
2ce626b069 Add various new tests
Just driving up coverage incrementally, and finding
bugs along the way.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthew Leeds
ce78f52fcc common: Reload FlatpakRemoteState after changes
Some remote metadata can cause changes to the local configuration for a
remote, but Flatpak is not properly reloading the new config after
making changes. Specifically in flatpak_transaction_update_metadata() we
call flatpak_dir_update_remote_configuration() for each remote and then
try to reload the configuration by calling flatpak_dir_recreate_repo().
The problem is that while this reloads the config instance stored by the
repo member of the FlatpakDir, the FlatpakTransaction object still has
FlatpakRemoteState objects stored which were initialized from the old
config.

A consequence of this is that if a remote repository has the
"ostree.deploy-collection-id" key set in its metadata, the next
install/update operation from that remote will fail with the error
message "Can't pull from untrusted non-gpg verified remote", and then
subsequent operations will succeed. This is because during the first
operation Flatpak will add the collection ID to the local configuration
in flatpak_transaction_update_metadata() but then in
flatpak_dir_install() the outdated FlatpakRemoteState object will be
used which still has no collection ID.

So this commit frees all the stored FlatpakRemoteState objects on the
transaction, so they will be recreated when they're needed (based on the
new config).

Closes: #2243
Approved by: alexlarsson
2018-10-12 09:09:14 +00:00
Piotr Drąg
4d1cfc28fc Update POTFILES.in
Closes: #2238
Approved by: mwleeds
2018-10-12 07:33:08 +00:00
Matthias Clasen
4975840826 Add various new tests
Just driving up coverage incrementally, and finding
bugs along the way.

Closes: #2239
Approved by: alexlarsson
2018-10-12 07:23:45 +00:00
Matthias Clasen
fd282a1ab8 installation: Don't return freed memory
flatpak_installation_load_app_overrides was returning
freed memory. Oops.

Closes: #2239
Approved by: alexlarsson
2018-10-12 07:23:45 +00:00
Patrick Griffis
d6e51ede6d Implicity grant MPRIS2 permissions
This should be safe to expose without requiring everybody request
it.

Closes: #2226
Approved by: alexlarsson
2018-10-11 12:51:55 +00:00
Matthias Clasen
afc87ad1e5 Add a history command
The history command pulls the transaction log entries
out of the journal, and presents them nicely.

We use the sd-journal api for this, so we need to
link against libsystemd now, but we make the dependency
optional. If libsystemd is not available, the history
command will simply print an error.
2018-10-11 14:51:51 +02:00
Matthias Clasen
c672c55154 dir: Add logging
Write to the systemd journal for basic operations
that modify installations, such as pull, deploy,
uninstall.  Include some useful information as
separate fields, such as OPERATION, INSTALLATION,
REMOTE, REF, COMMIT.

We add the logging in the api layer that is used
by the system-helper as well, so that changes
from that side are logged as well.

All logs we write currently use the same message
ID, defined as FLATPAK_MESSAGE_ID in the headers,
for easy retrieval of messages.
2018-10-11 14:51:51 +02:00
Matthias Clasen
e9f2d11f4a dir: Return FALSE when setting an error
This is expected behavior.
2018-10-11 14:51:51 +02:00
Matthias Clasen
1134e28400 system helper: Set the source pid
We add the callers pid as OBJECT_PID to our journal
entries, which causes journald to add number of useful
fields, such as the user and binary on whose behalf we
are acting.
2018-10-11 14:51:51 +02:00
Matthias Clasen
596f0f68d5 dir: Add an api to set a source pid
This will be used by the system helper to indicate
what process it is acting on behalf of.
2018-10-11 14:51:51 +02:00
Piotr Drąg
76dd97e918 Update POTFILES.in
Closes: #2236
Approved by: mwleeds
2018-10-10 18:15:57 +00:00
Matthias Clasen
bde3a86333 Adapt tests to the previous commit
One of the transaction tests contains the situation
that was modified in the previous commit. Update it
to expect the new behavior. At the same time, add
some comments to the tests to guide the reader.
2018-10-10 19:26:58 +02:00
Matthias Clasen
00400803fa transaction: Error if asked to uninstall deps
If a transaction contains both an install for an app
and an uninstall for the runtime that it needs, error
out, since this is inconsistent.

Closes: #2196
2018-10-10 19:26:58 +02:00
Alexander Larsson
99fbbc25c6 build-finish: Inherit permissions from runtime by default
In version 0.99.1 (065053775b) flatpak
stopped inheriting permissions from the runtime, because that made
the story about application permissions way to complicated. What
we want is to have a static set of permissions for the app that
is frozen at install time.

However, inheriting permissions from the runtime makes a lot of sense
as certain permissions are required from the runtime, in particular this
is used by the kde runtime to read the kdeglobals file, etc.

So, to combine the best of the two worlds, we now do inherit permissions,
but at build-time (and you can disable it if you want). This way
kde apps don't have to repeat themselves, but we still get static
application permissions.

Closes: #2230
Approved by: alexlarsson
2018-10-10 15:40:58 +00:00